Merge branch 'master' of github.com:floodlight/loxigen
diff --git a/Makefile b/Makefile
index b9b25de..401b2f1 100644
--- a/Makefile
+++ b/Makefile
@@ -49,7 +49,7 @@
c: .loxi_ts.c
-.loxi_ts.c: ${LOXI_PY_FILES} ${LOXI_TEMPLATE_FILES} ${INPUT_FILES ${TEST_DATA}
+.loxi_ts.c: ${LOXI_PY_FILES} ${LOXI_TEMPLATE_FILES} ${INPUT_FILES} ${TEST_DATA}
./loxigen.py --install-dir=${LOXI_OUTPUT_DIR} --lang=c
touch $@
@@ -86,7 +86,6 @@
clean:
rm -rf loxi_output # only delete generated files in the default directory
- rm -rf openflowj-loxi
rm -f loxigen.log loxigen-test.log .loxi_ts.c .loxi_ts.python .loxi_ts.java
debug:
diff --git a/java_gen/java_model.py b/java_gen/java_model.py
index 13a0d09..282cf98 100644
--- a/java_gen/java_model.py
+++ b/java_gen/java_model.py
@@ -47,12 +47,23 @@
from java_gen.java_type import erase_type_annotation
class JavaModel(object):
+ # registry for enums that should not be generated
+ # set(${java_enum_name})
enum_blacklist = set(("OFDefinitions",))
+ # registry for enum *entry* that should not be generated
+ # map: ${java_enum_name} -> set(${java_entry_entry_name})
enum_entry_blacklist = defaultdict(lambda: set(), OFFlowWildcards=set([ "NW_DST_BITS", "NW_SRC_BITS", "NW_SRC_SHIFT", "NW_DST_SHIFT" ]))
+
+ # registry of interfaces that should not be generated
+ # set(java_names)
# OFUint structs are there for god-knows what in loci. We certainly don't need them.
interface_blacklist = set( ("OFUint8", "OFUint32",))
+ # registry of interface properties that should not be generated
+ # map: $java_type -> set(java_name_property)
read_blacklist = defaultdict(lambda: set(), OFExperimenter=set(('data','subtype')), OFActionExperimenter=set(('data',)))
+ # map: $java_type -> set(java_name_property)
write_blacklist = defaultdict(lambda: set(), OFOxm=set(('typeLen',)), OFAction=set(('type',)), OFInstruction=set(('type',)), OFFlowMod=set(('command', )), OFExperimenter=set(('data','subtype')), OFActionExperimenter=set(('data',)))
+ # interfaces that are virtual
virtual_interfaces = set(['OFOxm', 'OFInstruction', 'OFFlowMod', 'OFBsnVport' ])
OxmMapEntry = namedtuple("OxmMapEntry", ["type_name", "value", "masked" ])
@@ -130,13 +141,33 @@
"OFOxmMplsTcMasked": OxmMapEntry("U8", "MPLS_TC", True)
}
+ # Registry of nullable properties:
+ # ${java_class_name} -> set(${java_property_name})
+ nullable_map = defaultdict(lambda: set(),
+ )
+
+ # represents a subgroup of a bitmask enum that is actualy a normal enumerable within a masked part of the enum
+ # e.g., the flags STP.* in OF1.0 port state are bit mask entries, but instead enumerables according to the mask "STP_MASK"
+ # name: a name for the group
+ # mask: java name of the enum entry that defines the mask
+ # members: set of names of the members of the group
MaskedEnumGroup = namedtuple("MaskedEnumGroup", ("name", "mask", "members"))
+ # registry of MaskedEnumGroups (see above).
+ # map: ${java_enum_name}: tuple(MaskedEnumGroup)
masked_enum_groups = defaultdict(lambda: (),
OFPortState= (MaskedEnumGroup("stp_flags", mask="STP_MASK", members=set(("STP_LISTEN", "STP_LEARN", "STP_FORWARD", "STP_BLOCK"))), )
)
+ # represents a metadata property associated with an EnumClass
+ # name:
class OFEnumPropertyMetadata(namedtuple("OFEnumPropertyMetadata", ("name", "type", "value"))):
+ """
+ represents a metadata property associated with an Enum Class
+ @param name name of metadata property
+ @param type java_type instance describing the type
+ @value: Generator function f(entry) that generates the value
+ """
@property
def variable_name(self):
return self.name[0].lower() + self.name[1:]
@@ -146,9 +177,11 @@
prefix = "is" if self.type == java_type.boolean else "get"
return prefix+self.name
+ """ Metadata container. """
OFEnumMetadata = namedtuple("OFEnumMetadata", ("properties", "to_string"))
def gen_port_speed(enum_entry):
+ """ Generator function for OFortFeatures.PortSpeed"""
splits = enum_entry.name.split("_")
if len(splits)>=2:
m = re.match(r'\d+[MGTP]B', splits[1])
@@ -157,12 +190,15 @@
return "PortSpeed.SPEED_NONE";
def gen_stp_state(enum_entry):
+ """ Generator function for OFPortState.StpState"""
splits = enum_entry.name.split("_")
if len(splits)>=1:
if splits[0] == "STP":
return "true"
return "false"
+ # registry for metadata properties for enums
+ # map: ${java_enum_name}: OFEnumMetadata
enum_metadata_map = defaultdict(lambda: JavaModel.OFEnumMetadata((), None),
OFPortFeatures = OFEnumMetadata((OFEnumPropertyMetadata("PortSpeed", java_type.port_speed, gen_port_speed),), None),
OFPortState = OFEnumMetadata((OFEnumPropertyMetadata("StpState", java_type.boolean, gen_stp_state),), None),
@@ -747,24 +783,14 @@
@property
def default_value(self):
- java_type = self.java_type.public_type;
-
if self.is_fixed_value:
return self.enum_value
- elif java_type == "OFOxmList":
- return "OFOxmList.EMPTY"
- elif re.match(r'Set.*', java_type):
- return "Collections.emptySet()"
- elif re.match(r'List.*', java_type):
- return "Collections.emptyList()"
- elif java_type == "boolean":
- return "false";
- elif self.java_type.is_array:
- return "new %s[0]" % java_type[:-2]
- elif java_type in ("byte", "char", "short", "int", "long"):
- return "({0}) 0".format(java_type);
else:
- return "null";
+ default = self.java_type.default_op(self.msg.version)
+ if default == "null" and not self.is_nullable:
+ return None
+ else:
+ return default
@property
def enum_value(self):
@@ -894,6 +920,11 @@
return False
return (self.name,) == (other.name,)
+ @property
+ def is_nullable(self):
+ return self.name in model.nullable_map[self.msg.name]
+
+
class JavaVirtualMember(JavaMember):
""" Models a virtual property (member) of an openflow class that is not backed by a loxi ir member """
def __init__(self, msg, name, java_type, value=None):
@@ -940,7 +971,7 @@
while test_data.exists(data_file_template.format(i=i)):
self.test_units.append(JavaUnitTest(java_class, data_file_template.format(i=i), test_class_name + str(i)))
i = i + 1
-
+
@property
def package(self):
return self.java_class.package
@@ -952,7 +983,7 @@
@property
def length(self):
return len(self.test_units)
-
+
def get_test_unit(self, i):
return self.test_units[i]
@@ -969,7 +1000,7 @@
self.test_class_name = self.java_class.name + "Test"
else:
self.test_class_name = test_class_name
-
+
@property
def package(self):
return self.java_class.package
diff --git a/java_gen/java_type.py b/java_gen/java_type.py
index d011c96..ea1ce2a 100644
--- a/java_gen/java_type.py
+++ b/java_gen/java_type.py
@@ -70,13 +70,14 @@
ANY = 0xFFFFFFFFFFFFFFFF
class VersionOp:
- def __init__(self, version=ANY, read=None, write=None):
+ def __init__(self, version=ANY, read=None, write=None, default=None):
self.version = version
self.read = read
self.write = write
+ self.default = default
def __str__(self):
- return "[Version: %d, Read: '%s', Write: '%s']" % (self.version, self.read, self.write)
+ return "[Version: %d, Read: '%s', Write: '%s', Default: '%s' ]" % (self.version, self.read, self.write, self.default )
### FIXME: This class should really be cleaned up
class JType(object):
@@ -85,14 +86,14 @@
read from and written to ChannelBuffers.
"""
- def __init__(self, pub_type, priv_type=None, read_op=None, write_op=None):
+ def __init__(self, pub_type, priv_type=None):
self.pub_type = pub_type # the type we expose externally, e.g. 'U8'
if priv_type is None:
priv_type = pub_type
self.priv_type = priv_type # the internal storage type
self.ops = {}
- def op(self, version=ANY, read=None, write=None, pub_type=ANY):
+ def op(self, version=ANY, read=None, write=None, default=None, pub_type=ANY):
"""
define operations to be performed for reading and writing this type
(when read_op, write_op is called). The operations 'read' and 'write'
@@ -108,7 +109,7 @@
pub_types = [ pub_type ] if pub_type is not ANY else [ False, True ]
for pub_type in pub_types:
- self.ops[(version, pub_type)] = VersionOp(version, read, write)
+ self.ops[(version, pub_type)] = VersionOp(version, read, write, default)
return self
def format_value(self, value, pub_type=True):
@@ -184,6 +185,24 @@
else:
return _write_op.replace("$name", str(name)).replace("$version", version.of_version)
+ def default_op(self, version=None, pub_type=True):
+ """ return a Java stanza that returns a default value of this JType.
+ @param version JavaOFVersion
+ @return string containing generated Java expression.
+ """
+ ver = ANY if version is None else version.int_version
+ _default_op = None
+ if (ver, pub_type) in self.ops:
+ _default_op = self.ops[(ver, pub_type)].default or self.ops[(ANY, pub_type)].default
+ elif (ANY, pub_type) in self.ops:
+ _default_op = self.ops[(ANY, pub_type)].default
+ if _default_op is None:
+ _default_op = self.format_value(0) if self.is_primitive else "null"
+ if callable(_default_op):
+ return _default_op(version, name)
+ else:
+ return _default_op.replace("$version", version.of_version)
+
def skip_op(self, version=None, length=None):
""" return a java stanza that skips an instance of JType in the input ChannelBuffer 'bb'.
This is used in the Reader implementations for virtual classes (because after the
@@ -200,7 +219,7 @@
@property
def is_array(self):
""" return true iff the pub_type is a Java array (and thus requires special
- treament for equals / toString etc.) """
+ treatment for equals / toString etc.) """
return self.pub_type.endswith("[]")
@@ -218,33 +237,46 @@
.op(read='U32.f(bb.readInt())', write='bb.writeInt(U32.t($name))', pub_type=True) \
.op(read='bb.readInt()', write='bb.writeInt($name)', pub_type=False)
u32_list = JType('List<U32>', 'int[]') \
- .op(read='ChannelUtils.readList(bb, $length, U32.READER)', write='ChannelUtils.writeList(bb, $name)')
+ .op(
+ read='ChannelUtils.readList(bb, $length, U32.READER)',
+ write='ChannelUtils.writeList(bb, $name)',
+ default="ImmutableList.<U32>of()");
u8obj = JType('U8', 'U8') \
- .op(read='U8.of(bb.readByte())', write='bb.writeByte($name.getRaw())')
+ .op(read='U8.of(bb.readByte())', write='bb.writeByte($name.getRaw())', default="U8.ZERO")
u32obj = JType('U32', 'U32') \
- .op(read='U32.of(bb.readInt())', write='bb.writeInt($name.getRaw())')
+ .op(read='U32.of(bb.readInt())', write='bb.writeInt($name.getRaw())', default="U32.ZERO")
u64 = JType('U64', 'U64') \
- .op(read='U64.ofRaw(bb.readLong())', write='bb.writeLong($name.getValue())')
+ .op(read='U64.ofRaw(bb.readLong())', write='bb.writeLong($name.getValue())', default="U64.ZERO")
of_port = JType("OFPort") \
- .op(version=1, read="OFPort.read2Bytes(bb)", write="$name.write2Bytes(bb)") \
- .op(version=ANY, read="OFPort.read4Bytes(bb)", write="$name.write4Bytes(bb)")
+ .op(version=1, read="OFPort.read2Bytes(bb)", write="$name.write2Bytes(bb)", default="OFPort.NONE") \
+ .op(version=ANY, read="OFPort.read4Bytes(bb)", write="$name.write4Bytes(bb)", default="OFPort.NONE")
actions_list = JType('List<OFAction>') \
- .op(read='ChannelUtils.readList(bb, $length, OFActionVer$version.READER)', write='ChannelUtils.writeList(bb, $name);')
+ .op(read='ChannelUtils.readList(bb, $length, OFActionVer$version.READER)',
+ write='ChannelUtils.writeList(bb, $name);',
+ default='ImmutableList.<OFAction>of()')
instructions_list = JType('List<OFInstruction>') \
.op(read='ChannelUtils.readList(bb, $length, OFInstructionVer$version.READER)', \
- write='ChannelUtils.writeList(bb, $name)')
+ write='ChannelUtils.writeList(bb, $name)',
+ default='ImmutableList.<OFInstruction>of()')
buckets_list = JType('List<OFBucket>') \
- .op(read='ChannelUtils.readList(bb, $length, OFBucketVer$version.READER)', write='ChannelUtils.writeList(bb, $name)')
+ .op(read='ChannelUtils.readList(bb, $length, OFBucketVer$version.READER)',
+ write='ChannelUtils.writeList(bb, $name)',
+ default='ImmutableList.<OFBucket>of()')
port_desc_list = JType('List<OFPortDesc>') \
- .op(read='ChannelUtils.readList(bb, $length, OFPortDescVer$version.READER)', write='ChannelUtils.writeList(bb, $name)')
+ .op(read='ChannelUtils.readList(bb, $length, OFPortDescVer$version.READER)',
+ write='ChannelUtils.writeList(bb, $name)',
+ default='ImmutableList.<OFPortDesc>of()')
port_desc = JType('OFPortDesc') \
.op(read='OFPortDescVer$version.READER.readFrom(bb)', \
write='$name.writeTo(bb)')
packet_queue_list = JType('List<OFPacketQueue>') \
- .op(read='ChannelUtils.readList(bb, $length, OFPacketQueueVer$version.READER)', write='ChannelUtils.writeList(bb, $name);')
+ .op(read='ChannelUtils.readList(bb, $length, OFPacketQueueVer$version.READER)',
+ write='ChannelUtils.writeList(bb, $name);',
+ default='ImmutableList.<OFPacketQueue>of()')
octets = JType('byte[]') \
.op(read='ChannelUtils.readBytes(bb, $length)', \
- write='bb.writeBytes($name)')
+ write='bb.writeBytes($name)', \
+ default="new byte[0]");
of_match = JType('Match') \
.op(read='ChannelUtilsVer$version.readOFMatch(bb)', \
write='$name.writeTo(bb)');
@@ -253,65 +285,104 @@
.op(version=ANY, read="bb.readByte()", write="bb.writeByte($name)")
mac_addr = JType('MacAddress') \
.op(read="MacAddress.read6Bytes(bb)", \
- write="$name.write6Bytes(bb)")
+ write="$name.write6Bytes(bb)",
+ default="MacAddress.NONE")
port_name = JType('String') \
.op(read='ChannelUtils.readFixedLengthString(bb, 16)', \
- write='ChannelUtils.writeFixedLengthString(bb, $name, 16)')
+ write='ChannelUtils.writeFixedLengthString(bb, $name, 16)',
+ default='""')
desc_str = JType('String') \
.op(read='ChannelUtils.readFixedLengthString(bb, 256)', \
- write='ChannelUtils.writeFixedLengthString(bb, $name, 256)')
+ write='ChannelUtils.writeFixedLengthString(bb, $name, 256)',
+ default='""')
serial_num = JType('String') \
.op(read='ChannelUtils.readFixedLengthString(bb, 32)', \
- write='ChannelUtils.writeFixedLengthString(bb, $name, 32)')
+ write='ChannelUtils.writeFixedLengthString(bb, $name, 32)',
+ default='""')
table_name = JType('String') \
.op(read='ChannelUtils.readFixedLengthString(bb, 32)', \
- write='ChannelUtils.writeFixedLengthString(bb, $name, 32)')
+ write='ChannelUtils.writeFixedLengthString(bb, $name, 32)',
+ default='""')
ipv4 = JType("IPv4Address") \
.op(read="IPv4Address.read4Bytes(bb)", \
- write="$name.write4Bytes(bb)")
+ write="$name.write4Bytes(bb)",
+ default='IPv4Address.NONE')
ipv6 = JType("IPv6Address") \
.op(read="IPv6Address.read16Bytes(bb)", \
- write="$name.write16Bytes(bb)")
+ write="$name.write16Bytes(bb)",
+ default='IPv6Address.NONE')
packetin_reason = JType("OFPacketInReason")\
- .op(read="OFPacketInReasonSerializerVer$version.readFrom(bb)", write="OFPacketInReasonSerializerVer$version.writeTo(bb, $name)")
-wildcards = JType("Wildcards")\
- .op(read="Wildcards.of(bb.readInt())", write="bb.writeInt($name.getInt())");
+ .op(read="OFPacketInReasonSerializerVer$version.readFrom(bb)",
+ write="OFPacketInReasonSerializerVer$version.writeTo(bb, $name)")
transport_port = JType("TransportPort")\
- .op(read="TransportPort.read2Bytes(bb)", write="$name.write2Bytes(bb)")
+ .op(read="TransportPort.read2Bytes(bb)",
+ write="$name.write2Bytes(bb)",
+ default="TransportPort.NONE")
eth_type = JType("EthType")\
- .op(read="EthType.read2Bytes(bb)", write="$name.write2Bytes(bb)")
+ .op(read="EthType.read2Bytes(bb)",
+ write="$name.write2Bytes(bb)",
+ default="EthType.NONE")
vlan_vid = JType("VlanVid")\
- .op(read="VlanVid.read2Bytes(bb)", write="$name.write2Bytes(bb)")
+ .op(read="VlanVid.read2Bytes(bb)",
+ write="$name.write2Bytes(bb)",
+ default="VlanVid.NONE")
vlan_pcp = JType("VlanPcp")\
- .op(read="VlanPcp.readByte(bb)", write="$name.writeByte(bb)")
+ .op(read="VlanPcp.readByte(bb)",
+ write="$name.writeByte(bb)",
+ default="VlanPcp.NONE")
ip_dscp = JType("IpDscp")\
- .op(read="IpDscp.readByte(bb)", write="$name.writeByte(bb)")
+ .op(read="IpDscp.readByte(bb)",
+ write="$name.writeByte(bb)",
+ default="IpDscp.NONE")
ip_ecn = JType("IpEcn")\
- .op(read="IpEcn.readByte(bb)", write="$name.writeByte(bb)")
+ .op(read="IpEcn.readByte(bb)",
+ write="$name.writeByte(bb)",
+ default="IpEcn.NONE")
ip_proto = JType("IpProtocol")\
- .op(read="IpProtocol.readByte(bb)", write="$name.writeByte(bb)")
+ .op(read="IpProtocol.readByte(bb)",
+ write="$name.writeByte(bb)",
+ default="IpProtocol.NONE")
icmpv4_type = JType("ICMPv4Type")\
- .op(read="ICMPv4Type.readByte(bb)", write="$name.writeByte(bb)")
+ .op(read="ICMPv4Type.readByte(bb)",
+ write="$name.writeByte(bb)",
+ default="ICMPv4Type.NONE")
icmpv4_code = JType("ICMPv4Code")\
- .op(read="ICMPv4Code.readByte(bb)", write="$name.writeByte(bb)")
+ .op(read="ICMPv4Code.readByte(bb)",
+ write="$name.writeByte(bb)",
+ default="ICMPv4Code.NONE")
arp_op = JType("ArpOpcode")\
- .op(read="ArpOpcode.read2Bytes(bb)", write="$name.write2Bytes(bb)")
+ .op(read="ArpOpcode.read2Bytes(bb)",
+ write="$name.write2Bytes(bb)",
+ default="ArpOpcode.NONE")
ipv6_flabel = JType("IPv6FlowLabel")\
- .op(read="IPv6FlowLabel.read4Bytes(bb)", write="$name.write4Bytes(bb)")
+ .op(read="IPv6FlowLabel.read4Bytes(bb)",
+ write="$name.write4Bytes(bb)",
+ default="IPv6FlowLabel.NONE")
metadata = JType("OFMetadata")\
- .op(read="OFMetadata.read8Bytes(bb)", write="$name.write8Bytes(bb)")
+ .op(read="OFMetadata.read8Bytes(bb)",
+ write="$name.write8Bytes(bb)",
+ default="OFMetadata.NONE")
oxm = JType("OFOxm<?>")\
.op( read="OFOxmVer$version.READER.readFrom(bb)",
write="$name.writeTo(bb)")
oxm_list = JType("OFOxmList") \
.op(
read= 'OFOxmList.readFrom(bb, $length, OFOxmVer$version.READER)', \
- write='$name.writeTo(bb)')
+ write='$name.writeTo(bb)',
+ default="OFOxmList.EMPTY")
meter_features = JType("OFMeterFeatures")\
- .op(read="OFMeterFeaturesVer$version.READER.readFrom(bb)", write="$name.writeTo(bb)")
+ .op(read="OFMeterFeaturesVer$version.READER.readFrom(bb)",
+ write="$name.writeTo(bb)")
+flow_wildcards = JType("int") \
+ .op(read='bb.readInt()',
+ write='bb.writeInt($name)',
+ default="OFFlowWildcardsSerializerVer$version.ALL_VAL")
+table_stats_wildcards = JType("int") \
+ .op(read='bb.readInt()',
+ write='bb.writeInt($name)')
port_speed = JType("PortSpeed")
-boolean = JType("boolean")
+boolean = JType("boolean").op(default="false")
generic_t = JType("T")
@@ -341,7 +412,7 @@
'of_table_name_t': table_name,
'of_ipv4_t': ipv4,
'of_ipv6_t': ipv6,
- 'of_wc_bmap_t': wildcards,
+ 'of_wc_bmap_t': flow_wildcards,
'of_oxm_t': oxm,
'of_meter_features_t': meter_features,
}
@@ -397,6 +468,12 @@
'of_oxm_mpls_label_masked' : { 'value' : u32obj, 'value_mask' : u32obj },
'of_oxm_mpls_tc' : { 'value' : u8obj },
'of_oxm_mpls_tc_masked' : { 'value' : u8obj, 'value_mask' : u8obj },
+
+ 'of_table_stats_entry': { 'wildcards': table_stats_wildcards },
+ 'of_match_v1': { 'vlan_vid' : vlan_vid, 'vlan_pcp': vlan_pcp,
+ 'eth_type': eth_type, 'ip_dscp': ip_dscp, 'ip_proto': ip_proto,
+ 'tcp_src': transport_port, 'tcp_dst': transport_port
+ }
}
@@ -407,11 +484,17 @@
for protocol in of_g.ir.values():
for enum in protocol.enums:
java_name = name_c_to_caps_camel(re.sub(r'_t$', "", enum.name))
- java_type = java_name if not enum.is_bitmask else "Set<{}>".format(java_name)
+ if enum.is_bitmask:
+ java_type = "Set<{}>".format(java_name)
+ default_value = "ImmutableSet.<{}>of()".format(java_name)
+ else:
+ java_type = java_name
+ default_value = "null"
enum_types[enum.name] = \
JType(java_type)\
- .op(read = "{}SerializerVer$version.readFrom(bb)".format(java_name),
- write ="{}SerializerVer$version.writeTo(bb, $name)".format(java_name))
+ .op(read="{}SerializerVer$version.readFrom(bb)".format(java_name),
+ write="{}SerializerVer$version.writeTo(bb, $name)".format(java_name),
+ default=default_value)
return enum_types
def make_match_field_jtype(sub_type_name="?"):
@@ -429,10 +512,12 @@
# read op assumes the class has a public final static field READER that implements
# OFMessageReader<$class> i.e., can deserialize an instance of class from a ChannelBuffer
# write op assumes class implements Writeable
- return JType("List<OF%s>" % java_base_name) \
+ return JType("List<OF{}>".format(java_base_name)) \
.op(
- read= 'ChannelUtils.readList(bb, $length, OF%sVer$version.READER)' % java_base_name, \
- write='ChannelUtils.writeList(bb, $name)')
+ read= 'ChannelUtils.readList(bb, $length, OF{}Ver$version.READER)'.format(java_base_name), \
+ write='ChannelUtils.writeList(bb, $name)',
+ default="ImmutableList.<OF{}>of()".format(java_base_name)
+ )
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/Wildcards.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/Wildcards.java
deleted file mode 100644
index 2268ce6..0000000
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/Wildcards.java
+++ /dev/null
@@ -1,656 +0,0 @@
-/**
- * Copyright 2013, Big Switch Networks, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License. You may obtain
- * a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- **/
-
-package org.projectfloodlight.openflow.protocol;
-
-import java.util.ArrayList;
-import java.util.EnumSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import com.google.common.base.Joiner;
-
-/**
- * a more user friendly representation of the wildcards bits in an OpenFlow
- * match. The Wildcards object is
- * <ul>
- * <li>immutable (i.e., threadsafe)</li>
- * <li>instance managed (don't instantiate it yourself), instead call "of"</li>
- * <ul>
- * <p>
- * You can construct a Wildcard object from either its integer representation
- * </p>
- * <code>
- * Wildcard.of(0x3820e0);
- * </code>
- * <p>
- * Or start with either an empty or full wildcard, and select/unselect foo.
- * </p>
- * <code>
- * Wildcard w = Wildcards.NONE
- * .set(Flag.DL_SRC, Flag. DL_DST, Flag.DL_VLAN_PCP)
- * .setNwDstMask(8)
- * .setNwSrcMask(8);
- * </code>
- * <p>
- * <b>Remember:</b> Wildcards objects are immutable. set... operations have
- * <b>NO EFFECT</b> on the current wildcard object. You HAVE to use the returned
- * changed object.
- * </p>
- *
- * @author Andreas Wundsam <andreas.wundsam@bigswitch.com>
- */
-public class Wildcards {
- public class OFWildcardFlags {
- final public static int OFPFW_ALL = ((1 << 22) - 1);
-
- final public static int OFPFW_IN_PORT = 1 << 0; /* Switch input port. */
- final public static int OFPFW_DL_VLAN = 1 << 1; /* VLAN id. */
- final public static int OFPFW_DL_SRC = 1 << 2; /* Ethernet source address. */
- final public static int OFPFW_DL_DST = 1 << 3; /*
- * Ethernet destination
- * address.
- */
- final public static int OFPFW_DL_TYPE = 1 << 4; /* Ethernet frame type. */
- final public static int OFPFW_NW_PROTO = 1 << 5; /* IP protocol. */
- final public static int OFPFW_TP_SRC = 1 << 6; /* TCP/UDP source port. */
- final public static int OFPFW_TP_DST = 1 << 7; /* TCP/UDP destination port. */
-
- /*
- * IP source address wildcard bit count. 0 is exact match, 1 ignores the
- * LSB, 2 ignores the 2 least-significant bits, ..., 32 and higher wildcard
- * the entire field. This is the *opposite* of the usual convention where
- * e.g. /24 indicates that 8 bits (not 24 bits) are wildcarded.
- */
- final public static int OFPFW_NW_SRC_SHIFT = 8;
- final public static int OFPFW_NW_SRC_BITS = 6;
- final public static int OFPFW_NW_SRC_MASK = ((1 << OFPFW_NW_SRC_BITS) - 1) << OFPFW_NW_SRC_SHIFT;
- final public static int OFPFW_NW_SRC_ALL = 32 << OFPFW_NW_SRC_SHIFT;
-
- /* IP destination address wildcard bit count. Same format as source. */
- final public static int OFPFW_NW_DST_SHIFT = 14;
- final public static int OFPFW_NW_DST_BITS = 6;
- final public static int OFPFW_NW_DST_MASK = ((1 << OFPFW_NW_DST_BITS) - 1) << OFPFW_NW_DST_SHIFT;
- final public static int OFPFW_NW_DST_ALL = 32 << OFPFW_NW_DST_SHIFT;
-
- final public static int OFPFW_DL_VLAN_PCP = 1 << 20; /* VLAN priority. */
- final public static int OFPFW_NW_TOS = 1 << 21; /*
- * IP ToS (DSCP field, 6
- * bits).
- */
-
- final public static int OFPFW_ALL_SANITIZED = (((1 << 22) - 1)
- & ~OFPFW_NW_SRC_MASK & ~OFPFW_NW_DST_MASK)
- | OFPFW_NW_SRC_ALL
- | OFPFW_NW_DST_ALL;
-
-
- }
-
- public final static Wildcards FULL = new Wildcards(OFWildcardFlags.OFPFW_ALL_SANITIZED);
- private static final int FULL_INT = FULL.getInt();
-
- public final static Wildcards EXACT = new Wildcards(0);
-
- // floodlight common case: matches on inport + l2
- public final static int INT_INPORT_L2_MATCH = 0x3820e0;
- public final static Wildcards INPORT_L2_MATCH = new Wildcards(
- INT_INPORT_L2_MATCH);
-
- /**
- * enum type for the binary flags that can be set in the wildcards field of
- * an OFWildcardFlags. Replaces the unwieldy c-ish int constants in OFWildcardFlags.
- */
- public static enum Flag {
- IN_PORT(OFWildcardFlags.OFPFW_IN_PORT), /* Switch input port. */
- DL_VLAN(OFWildcardFlags.OFPFW_DL_VLAN), /* VLAN id. */
- DL_SRC(OFWildcardFlags.OFPFW_DL_SRC), /* Ethernet source address. */
- DL_DST(OFWildcardFlags.OFPFW_DL_DST), /* Ethernet destination addr */
- DL_TYPE(OFWildcardFlags.OFPFW_DL_TYPE), /* Ethernet frame type. */
- NW_PROTO(OFWildcardFlags.OFPFW_NW_PROTO), /* IP protocol. */
- TP_SRC(OFWildcardFlags.OFPFW_TP_SRC), /* TCP/UDP source port. */
- TP_DST(OFWildcardFlags.OFPFW_TP_DST), /* TCP/UDP destination port. */
- DL_VLAN_PCP(OFWildcardFlags.OFPFW_DL_VLAN_PCP), /* VLAN priority. */
- NW_SRC(-1) { /*
- * virtual NW_SRC flag => translates to the strange 6 bits
- * in the header
- */
- @Override
- boolean isBolean() {
- return false;
- }
-
- @Override
- int getInt(int flags) {
- return ((flags & OFWildcardFlags.OFPFW_NW_SRC_MASK) >> OFWildcardFlags.OFPFW_NW_SRC_SHIFT);
- }
-
- @Override
- int setInt(int flags, int srcMask) {
- return (flags & ~OFWildcardFlags.OFPFW_NW_SRC_MASK) | (srcMask << OFWildcardFlags.OFPFW_NW_SRC_SHIFT);
- }
-
- @Override
- int wildcard(int flags) {
- return flags & ~OFWildcardFlags.OFPFW_NW_SRC_MASK;
- }
-
- @Override
- int matchOn(int flags) {
- return flags | OFWildcardFlags.OFPFW_NW_SRC_ALL;
- }
-
- @Override
- boolean isPartiallyOn(int flags) {
- int intValue = getInt(flags);
- return intValue > 0 && intValue < 32;
- }
-
- @Override
- boolean isFullyOn(int flags) {
- return getInt(flags) >= 32;
- }
-
- },
- NW_DST(-1) { /*
- * virtual NW_SRC flag => translates to the strange 6 bits
- * in the header
- */
- @Override
- boolean isBolean() {
- return false;
- }
-
- @Override
- int getInt(int flags) {
- return ((flags & OFWildcardFlags.OFPFW_NW_DST_MASK) >> OFWildcardFlags.OFPFW_NW_DST_SHIFT);
- }
-
- @Override
- int setInt(int flags, int srcMask) {
- return (flags & ~OFWildcardFlags.OFPFW_NW_DST_MASK) | (srcMask << OFWildcardFlags.OFPFW_NW_DST_SHIFT);
- }
-
- @Override
- int wildcard(int flags) {
- return flags & ~OFWildcardFlags.OFPFW_NW_DST_MASK;
- }
-
- @Override
- int matchOn(int flags) {
- return flags | OFWildcardFlags.OFPFW_NW_DST_ALL;
- }
-
- @Override
- boolean isFullyOn(int flags) {
- return getInt(flags) >= 32;
- }
- },
- NW_TOS(OFWildcardFlags.OFPFW_NW_TOS); /* IP ToS (DSCP field, 6 bits). */
-
- final int bitPosition;
-
- Flag(int bitPosition) {
- this.bitPosition = bitPosition;
- }
-
- /**
- * @return a modified OF-1.0 flags field with this flag cleared (match
- * on this field)
- */
- int matchOn(int flags) {
- return flags & ~this.bitPosition;
- }
-
- /**
- * @return a modified OF-1.0 flags field with this flag set (wildcard
- * this field)
- */
- int wildcard(int flags) {
- return flags | this.bitPosition;
- }
-
- /**
- * @return true iff this is a true boolean flag that can either be off
- * or on.True in OF-1.0 for all fields except NW_SRC and NW_DST
- */
- boolean isBolean() {
- return false;
- }
-
- /**
- * @return true iff this wildcard field is currently 'partially on'.
- * Always false for true Boolean Flags. Can be true in OF-1.0
- * for NW_SRC, NW_DST.
- */
- boolean isPartiallyOn(int flags) {
- return false;
- }
-
- /**
- * @return true iff this wildcard field currently fully on (fully
- * wildcarded). Equivalent to the boolean flag being set in the
- * bitmask for bit flags, and to the wildcarded bit length set
- * to >=32 for NW_SRC and NW_DST
- * @param flags
- * @return
- */
- boolean isFullyOn(int flags) {
- return (flags & this.bitPosition) != 0;
- }
-
- /**
- * set the integer representation of this flag. only for NW_SRC and
- * NW_DST
- */
- int setInt(int flags, int srcMask) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * set the integer representation of this flag. only for NW_SRC and
- * NW_DST
- */
- int getInt(int flags) {
- throw new UnsupportedOperationException();
- }
-
-
- }
-
- private final int flags;
-
- /** private constructor. use Wildcard.of() instead */
- private Wildcards(int flags) {
- this.flags = flags;
- }
-
- /**
- * return a wildcard object matching the given int flags. May reuse / cache
- * frequently used wildcard instances. Don't rely on it though (use equals
- * not ==).
- *
- * @param flags
- * @return
- */
- public static Wildcards of(int paramFlags) {
- int flags = paramFlags; //sanitizeInt(paramFlags);
- switch(flags) {
- case 0x0000:
- return EXACT;
- case OFWildcardFlags.OFPFW_ALL_SANITIZED:
- return FULL;
- case INT_INPORT_L2_MATCH:
- return INPORT_L2_MATCH;
- default:
- return new Wildcards(flags);
- }
- }
-
- /** convience method return a wildcard for exactly one set flag */
- public static Wildcards of(Wildcards.Flag setFlag) {
- return Wildcards.of(setFlag.wildcard(0));
- }
-
- /** convience method return a wildcard for exactly two set flags */
- public static Wildcards of(Wildcards.Flag setFlag, Wildcards.Flag setFlag2) {
- return Wildcards.of(setFlag.wildcard(setFlag2.wildcard(0)));
- }
-
- /** convience method return a wildcard for an arbitrary number of set flags */
- public static Wildcards of(Wildcards.Flag... setFlags) {
- int flags = 0;
- for (Wildcards.Flag flag : setFlags)
- flags = flag.wildcard(0);
- return Wildcards.of(flags);
- }
-
- /** convience method return a wildcards for ofmatches that match on one flag */
- public static Wildcards ofMatches(Wildcards.Flag setFlag) {
- return Wildcards.of(setFlag.matchOn(FULL_INT));
- }
-
- /**
- * convience method return a wildcard for for an ofmatch that match on two
- * flags
- */
- public static Wildcards ofMatches(Wildcards.Flag setFlag, Wildcards.Flag setFlag2) {
- return Wildcards.of(setFlag.matchOn(setFlag2.matchOn(FULL_INT)));
- }
-
- /**
- * convience method return a wildcard for an ofmatch that amtch on an
- * arbitrary number of set flags
- */
- public static Wildcards ofMatches(Wildcards.Flag... setFlags) {
- int flags = FULL_INT;
- for (Wildcards.Flag flag : setFlags)
- flags = flag.matchOn(flags);
- return Wildcards.of(flags);
- }
-
- public static Wildcards ofMatches(Set<Wildcards.Flag> wSet) {
- int flags = FULL_INT;
- for (Wildcards.Flag flag : wSet)
- flags = flag.matchOn(flags);
- return Wildcards.of(flags);
- }
-
- /**
- * return a Wildcards object that has the given flags set
- * <p>
- * <b>NOTE:</b> NOT a mutator function. 'this' wildcard object stays
- * unmodified. </b>
- */
- public Wildcards wildcard(Wildcards.Flag flag) {
- int flags = flag.wildcard(this.flags);
- if (flags == this.flags)
- return this;
- else
- return new Wildcards(flags);
- }
-
- /**
- * return a Wildcards object that has the given flags set
- * <p>
- * <b>NOTE:</b> NOT a mutator function. 'this' wildcard object stays
- * unmodified. </b>
- */
- public Wildcards wildcard(Wildcards.Flag flag, Wildcards.Flag flag2) {
- int flags = flag.wildcard(flag2.wildcard(this.flags));
- if (flags == this.flags)
- return this;
- else
- return new Wildcards(flags);
- }
-
- /**
- * return a Wildcards object that has the given flags wildcarded
- * <p>
- * <b>NOTE:</b> NOT a mutator function. 'this' wildcard object stays
- * unmodified. </b>
- */
- public Wildcards wildcard(Wildcards.Flag... setFlags) {
- int flags = this.flags;
- for (Wildcards.Flag flag : setFlags)
- flags = flag.wildcard(flags);
- if (flags == this.flags)
- return this;
- else
- return new Wildcards(flags);
- }
-
- /**
- * return a Wildcards object that matches on exactly the given flag
- * <p>
- * <b>NOTE:</b> NOT a mutator function. 'this' wildcard object stays
- * unmodified. </b>
- */
- public Wildcards matchOn(Wildcards.Flag flag) {
- int flags = flag.matchOn(this.flags);
- if (flags == this.flags)
- return this;
- else
- return new Wildcards(flags);
- }
-
- /**
- * return a Wildcards object that matches on exactly the given flags
- * <p>
- * <b>NOTE:</b> NOT a mutator function. 'this' wildcard object stays
- * unmodified. </b>
- */
- public Wildcards matchOn(Wildcards.Flag flag, Wildcards.Flag flag2) {
- int flags = flag.matchOn(flag2.matchOn(this.flags));
- if (flags == this.flags)
- return this;
- else
- return new Wildcards(flags);
- }
-
- /**
- * return a Wildcards object that matches on exactly the given flags
- * <p>
- * <b>NOTE:</b> NOT a mutator function. 'this' wildcard object stays
- * unmodified. </b>
- */
- public Wildcards matchOn(Wildcards.Flag... setFlags) {
- int flags = this.flags;
- for (Wildcards.Flag flag : setFlags)
- flags = flag.matchOn(flags);
- if (flags == this.flags)
- return this;
- else
- return new Wildcards(flags);
- }
-
- /**
- * return the nw src mask in normal CIDR style, e.g., 8 means x.x.x.x/8
- * means 8 bits wildcarded
- */
- public int getNwSrcMask() {
- return Math.max(0, 32 - Flag.NW_SRC.getInt(flags));
- }
-
- /**
- * return the nw dst mask in normal CIDR style, e.g., 8 means x.x.x.x/8
- * means 8 bits wildcarded
- */
- public int getNwDstMask() {
- return Math.max(0, 32 - Flag.NW_DST.getInt(flags));
- }
-
- /**
- * return a Wildcard object that has the given nwSrcCidrMask set.
- * <b>NOTE:</b> NOT a mutator function. 'this' wildcard object stays
- * unmodified. </b>
- *
- * @param srcCidrMask
- * source mask to set in <b>normal CIDR notation</b>, i.e., 8
- * means x.x.x.x/8
- * @return a modified object
- */
- public Wildcards withNwSrcMask(int srcCidrMask) {
- int flags = Flag.NW_SRC.setInt(this.flags, Math.max(0, 32 - srcCidrMask));
- if (flags == this.flags)
- return this;
- else
- return new Wildcards(flags);
- }
-
- /**
- * return a Wildcard object that has the given nwDstCidrMask set.
- * <b>NOTE:</b> NOT a mutator function. 'this' wildcard object stays
- * unmodified. </b>
- *
- * @param dstCidrMask
- * dest mask to set in <b>normal CIDR notation</b>, i.e., 8 means
- * x.x.x.x/8
- * @return a modified object
- */
- public Wildcards withNwDstMask(int dstCidrMask) {
- int flags = Flag.NW_DST.setInt(this.flags, Math.max(0, 32 - dstCidrMask));
- if (flags == this.flags)
- return this;
- else
- return new Wildcards(flags);
- }
-
- /**
- * return a Wildcard object that is inverted to this wildcard object.
- * <b>NOTE:</b> NOT a mutator function. 'this' wildcard object stays
- * unmodified. </b>
- * @return a modified object
- */
- public Wildcards inverted() {
- return Wildcards.of(flags ^ OFWildcardFlags.OFPFW_ALL_SANITIZED);
- }
-
- public boolean isWildcarded(Flag flag) {
- return flag.isFullyOn(flags);
- }
-
- /**
- * return all wildcard flags that are fully wildcarded as an EnumSet. Do not
- * modify. Note: some flags (like NW_SRC and NW_DST) that are partially
- * wildcarded are not returned in this set.
- *
- * @return the EnumSet of wildcards
- */
- public EnumSet<Wildcards.Flag> getWildcardedFlags() {
- EnumSet<Wildcards.Flag> res = EnumSet.noneOf(Wildcards.Flag.class);
- for (Wildcards.Flag flag : Flag.values()) {
- if (flag.isFullyOn(flags)) {
- res.add(flag);
- }
- }
- return res;
- }
-
- /** return the OpenFlow 'wire' integer representation of these wildcards */
- public int getInt() {
- return flags;
- }
-
- /**
- * return the OpenFlow 'wire' integer representation of these wildcards.
- * Sanitize nw_src and nw_dst to be max. 32 (values > 32 are technically
- * possible, but don't make semantic sense)
- */
- public static int sanitizeInt(int flags) {
- if (((flags & OFWildcardFlags.OFPFW_NW_SRC_MASK) >> OFWildcardFlags.OFPFW_NW_SRC_SHIFT) > 32) {
- flags = (flags & ~OFWildcardFlags.OFPFW_NW_SRC_MASK) | OFWildcardFlags.OFPFW_NW_SRC_ALL;
- }
- if (((flags & OFWildcardFlags.OFPFW_NW_DST_MASK) >> OFWildcardFlags.OFPFW_NW_DST_SHIFT) > 32) {
- flags = (flags & ~OFWildcardFlags.OFPFW_NW_DST_MASK) | OFWildcardFlags.OFPFW_NW_DST_ALL;
- }
- return flags;
- }
-
- /**
- * is this a wildcard set that has all flags set + and full (/0) nw_src and
- * nw_dst wildcarding ?
- */
- public boolean isFull() {
- return flags == OFWildcardFlags.OFPFW_ALL || flags == OFWildcardFlags.OFPFW_ALL_SANITIZED;
- }
-
- /** is this a wildcard of an exact match */
- public boolean isExact() {
- return flags == 0;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + flags;
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- Wildcards other = (Wildcards) obj;
- if (flags != other.flags)
- return false;
- return true;
- }
-
- private final static Joiner pipeJoiner = Joiner.on("|");
-
- @Override
- public String toString() {
- List<String> res = new ArrayList<String>();
- for (Wildcards.Flag flag : Flag.values()) {
- if (flag.isFullyOn(flags)) {
- res.add(flag.name().toLowerCase());
- }
- }
-
- if (Flag.NW_SRC.isPartiallyOn(flags)) {
- res.add("nw_src(/" + getNwSrcMask() + ")");
- }
-
- if (Flag.NW_DST.isPartiallyOn(flags)) {
- res.add("nw_dst(/" + getNwDstMask() + ")");
- }
-
- return pipeJoiner.join(res);
- }
-
- private final static Joiner commaJoiner = Joiner.on(", ");
-
- /** a Java expression that constructs 'this' wildcards set */
- public String toJava() {
- if(isFull()) {
- return "Wildcards.FULL";
- } else if (isExact()){
- return "Wildcards.EXACT";
- }
-
- StringBuilder b = new StringBuilder();
-
- EnumSet<Flag> myFlags = getWildcardedFlags();
- if (myFlags.size() < 3) {
- // default to start with empty
- b.append("Wildcards.of("
- + commaJoiner.join(prefix("Flag.", myFlags.iterator())) + ")");
- } else {
- // too many - start with full
-
- EnumSet<Flag> invFlags = inverted().getWildcardedFlags();
- b.append("Wildcards.ofMatches("
- + commaJoiner.join(prefix("Flag.", invFlags.iterator())) + ")");
- }
- if (Flag.NW_SRC.isPartiallyOn(flags)) {
- b.append(".setNwSrcMask(" + getNwSrcMask() + ")");
- }
- if (Flag.NW_DST.isPartiallyOn(flags)) {
- b.append(".setNwDstMask(" + getNwDstMask() + ")");
- }
- return b.toString();
- }
-
- private Iterator<String> prefix(final String prefix, final Iterator<?> i) {
- return new Iterator<String>() {
-
- @Override
- public boolean hasNext() {
- return i.hasNext();
- }
-
- @Override
- public String next() {
- Object next = i.next();
- return next == null ? null : prefix + next.toString();
- }
-
- @Override
- public void remove() {
- i.remove();
- }
- };
- }
-
-
-}
\ No newline at end of file
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/match/MatchField.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/match/MatchField.java
index 611898f..47ca9da 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/match/MatchField.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/protocol/match/MatchField.java
@@ -60,23 +60,23 @@
public final static MatchField<IpDscp> IP_DSCP =
new MatchField<IpDscp>("ip_dscp", MatchFields.IP_DSCP,
- new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ETH_TYPE_IPv4, EthType.ETH_TYPE_IPv6));
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.IPv4, EthType.IPv6));
public final static MatchField<IpEcn> IP_ECN =
new MatchField<IpEcn>("ip_dscp", MatchFields.IP_ECN,
- new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ETH_TYPE_IPv4, EthType.ETH_TYPE_IPv6));
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.IPv4, EthType.IPv6));
public final static MatchField<IpProtocol> IP_PROTO =
new MatchField<IpProtocol>("ip_proto", MatchFields.IP_PROTO,
- new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ETH_TYPE_IPv4, EthType.ETH_TYPE_IPv6));
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.IPv4, EthType.IPv6));
public final static MatchField<IPv4Address> IPV4_SRC =
new MatchField<IPv4Address>("ipv4_src", MatchFields.IPV4_SRC,
- new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ETH_TYPE_IPv4));
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.IPv4));
public final static MatchField<IPv4Address> IPV4_DST =
new MatchField<IPv4Address>("ipv4_dst", MatchFields.IPV4_DST,
- new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ETH_TYPE_IPv4));
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.IPv4));
public final static MatchField<TransportPort> TCP_SRC = new MatchField<TransportPort>(
"tcp_src", MatchFields.TCP_SRC,
@@ -112,35 +112,35 @@
public final static MatchField<ArpOpcode> ARP_OP = new MatchField<ArpOpcode>(
"arp_op", MatchFields.ARP_OP,
- new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ETH_TYPE_ARP));
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ARP));
public final static MatchField<IPv4Address> ARP_SPA =
new MatchField<IPv4Address>("arp_spa", MatchFields.ARP_SPA,
- new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ETH_TYPE_ARP));
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ARP));
public final static MatchField<IPv4Address> ARP_TPA =
new MatchField<IPv4Address>("arp_tpa", MatchFields.ARP_TPA,
- new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ETH_TYPE_ARP));
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ARP));
public final static MatchField<MacAddress> ARP_SHA =
new MatchField<MacAddress>("arp_sha", MatchFields.ARP_SHA,
- new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ETH_TYPE_ARP));
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ARP));
public final static MatchField<MacAddress> ARP_THA =
new MatchField<MacAddress>("arp_tha", MatchFields.ARP_THA,
- new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ETH_TYPE_ARP));
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ARP));
public final static MatchField<IPv6Address> IPV6_SRC =
new MatchField<IPv6Address>("ipv6_src", MatchFields.IPV6_SRC,
- new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ETH_TYPE_IPv6));
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.IPv6));
public final static MatchField<IPv6Address> IPV6_DST =
new MatchField<IPv6Address>("ipv6_dst", MatchFields.IPV6_DST,
- new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ETH_TYPE_IPv6));
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.IPv6));
public final static MatchField<IPv6FlowLabel> IPV6_FLABEL =
new MatchField<IPv6FlowLabel>("ipv6_flabel", MatchFields.IPV6_FLABEL,
- new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ETH_TYPE_IPv6));
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.IPv6));
public final static MatchField<U8> ICMPV6_TYPE =
new MatchField<U8>("icmpv6_type", MatchFields.ICMPV6_TYPE,
@@ -164,11 +164,11 @@
public final static MatchField<U32> MPLS_LABEL =
new MatchField<U32>("mpls_label", MatchFields.MPLS_LABEL,
- new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ETH_TYPE_MPLS_UNICAST, EthType.ETH_TYPE_MPLS_MULTICAST));
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.MPLS_UNICAST, EthType.MPLS_MULTICAST));
public final static MatchField<U8> MPLS_TC =
new MatchField<U8>("mpls_tc", MatchFields.MPLS_TC,
- new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ETH_TYPE_MPLS_UNICAST, EthType.ETH_TYPE_MPLS_MULTICAST));
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.MPLS_UNICAST, EthType.MPLS_MULTICAST));
public String getName() {
return name;
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/ArpOpcode.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/ArpOpcode.java
index 5e710ca..5ab940d 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/ArpOpcode.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/ArpOpcode.java
@@ -60,7 +60,10 @@
private static final int MIN_OPCODE = 0;
private static final int MAX_OPCODE = 0xFFFF;
-
+
+ private static final int NONE_VAL = 0;
+ public static final ArpOpcode NONE = new ArpOpcode(NONE_VAL);
+
public static final ArpOpcode NO_MASK = new ArpOpcode(0xFFFFFFFF);
public static final ArpOpcode FULL_MASK = new ArpOpcode(0x00000000);
@@ -83,6 +86,8 @@
if (opcode < MIN_OPCODE || opcode > MAX_OPCODE)
throw new IllegalArgumentException("Invalid ARP opcode: " + opcode);
switch (opcode) {
+ case NONE_VAL:
+ return NONE;
case ARP_OPCODE_VAL_REQUEST:
return ARP_OPCODE_REQUEST;
case ARP_OPCODE_VAL_REPLY:
@@ -137,11 +142,11 @@
return new ArpOpcode(opcode);
}
}
-
+
public void write2Bytes(ChannelBuffer c) {
c.writeShort(this.opcode);
}
-
+
public static ArpOpcode read2Bytes(ChannelBuffer c) {
return ArpOpcode.of(c.readUnsignedShort());
}
@@ -150,9 +155,9 @@
public ArpOpcode applyMask(ArpOpcode mask) {
return ArpOpcode.of(this.opcode & mask.opcode);
}
-
+
public int getOpCode() {
return opcode;
}
-
+
}
\ No newline at end of file
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/EthType.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/EthType.java
index 52f5455..abd4bff 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/EthType.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/EthType.java
@@ -5,7 +5,7 @@
/**
* EtherType field representation.
- *
+ *
* @author Yotam Harchol (yotam.harchol@bigswitch.com)
*/
public class EthType implements OFValueType<EthType> {
@@ -13,93 +13,97 @@
private final int rawValue;
- static final int ETH_TYPE_VAL_IPv4 = 0x0800; // Internet Protocol version 4 (IPv4)
- static final int ETH_TYPE_VAL_ARP = 0x0806; // Address Resolution Protocol (ARP)
- static final int ETH_TYPE_VAL_WAKE_ON_LAN = 0x0842; // Wake-on-LAN[3]
- static final int ETH_TYPE_VAL_TRILL = 0x22F3; // IETF TRILL Protocol
- static final int ETH_TYPE_VAL_DECNET_IV = 0x6003; // DECnet Phase IV
- static final int ETH_TYPE_VAL_REV_ARP = 0x8035; // Reverse Address Resolution Protocol
- static final int ETH_TYPE_VAL_APPLE_TALK = 0x809B; // AppleTalk (Ethertalk)
- static final int ETH_TYPE_VAL_APPLE_TALK_ARP = 0x80F3; // AppleTalk Address Resolution Protocol (AARP)
- static final int ETH_TYPE_VAL_VLAN_FRAME = 0x8100; // VLAN-tagged frame (IEEE 802.1Q) & Shortest Path Bridging IEEE 802.1aq[4]
- static final int ETH_TYPE_VAL_IPX_8137 = 0x8137; // IPX
- static final int ETH_TYPE_VAL_IPX_8138 = 0x8138; // IPX
- static final int ETH_TYPE_VAL_QNX = 0x8204; // QNX Qnet
- static final int ETH_TYPE_VAL_IPv6 = 0x86DD; // Internet Protocol Version 6 (IPv6)
- static final int ETH_TYPE_VAL_ETH_FLOW = 0x8808; // Ethernet flow control
- static final int ETH_TYPE_VAL_SLOW_PROTOCOLS = 0x8809; // Slow Protocols (IEEE 802.3)
- static final int ETH_TYPE_VAL_COBRANET = 0x8819; // CobraNet
- static final int ETH_TYPE_VAL_MPLS_UNICAST = 0x8847; // MPLS unicast
- static final int ETH_TYPE_VAL_MPLS_MULTICAST = 0x8848; // MPLS multicast
- static final int ETH_TYPE_VAL_PPPoE_DISCOVERY = 0x8863; // PPPoE Discovery Stage
- static final int ETH_TYPE_VAL_PPPoE_SESSION = 0x8864; // PPPoE Session Stage
- static final int ETH_TYPE_VAL_JUMBO_FRAMES = 0x8870; // Jumbo Frames
- static final int ETH_TYPE_VAL_HOMEPLUG_10 = 0x887B; // HomePlug 1.0 MME
- static final int ETH_TYPE_VAL_EAP_OVER_LAN = 0x888E; // EAP over LAN (IEEE 802.1X)
- static final int ETH_TYPE_VAL_PROFINET = 0x8892; // PROFINET Protocol
- static final int ETH_TYPE_VAL_HYPERSCSI = 0x889A; // HyperSCSI (SCSI over Ethernet)
- static final int ETH_TYPE_VAL_ATA_OVER_ETH = 0x88A2; // ATA over Ethernet
- static final int ETH_TYPE_VAL_ETHERCAT = 0x88A4; // EtherCAT Protocol
- static final int ETH_TYPE_VAL_BRIDGING = 0x88A8; // Provider Bridging (IEEE 802.1ad) & Shortest Path Bridging IEEE 802.1aq[5]
- static final int ETH_TYPE_VAL_POWERLINK = 0x88AB; // Ethernet Powerlink[citation needed]
- static final int ETH_TYPE_VAL_LLDP = 0x88CC; // Link Layer Discovery Protocol (LLDP)
- static final int ETH_TYPE_VAL_SERCOS = 0x88CD; // SERCOS III
- static final int ETH_TYPE_VAL_HOMEPLUG_AV = 0x88E1; // HomePlug AV MME[citation needed]
- static final int ETH_TYPE_VAL_MRP = 0x88E3; // Media Redundancy Protocol (IEC62439-2)
- static final int ETH_TYPE_VAL_MAC_SEC = 0x88E5; // MAC security (IEEE 802.1AE)
- static final int ETH_TYPE_VAL_PTP = 0x88F7; // Precision Time Protocol (IEEE 1588)
- static final int ETH_TYPE_VAL_CFM = 0x8902; // IEEE 802.1ag Connectivity Fault Management (CFM) Protocol / ITU-T Recommendation Y.1731 (OAM)
- static final int ETH_TYPE_VAL_FCoE = 0x8906; // Fibre Channel over Ethernet (FCoE)
- static final int ETH_TYPE_VAL_FCoE_INIT = 0x8914; // FCoE Initialization Protocol
- static final int ETH_TYPE_VAL_RoCE = 0x8915; // RDMA over Converged Ethernet (RoCE)
- static final int ETH_TYPE_VAL_HSR = 0x892F; // High-availability Seamless Redundancy (HSR)
- static final int ETH_TYPE_VAL_CONF_TEST = 0x9000; // Ethernet Configuration Testing Protocol[6]
- static final int ETH_TYPE_VAL_Q_IN_Q = 0x9100; // Q-in-Q
- static final int ETH_TYPE_VAL_LLT = 0xCAFE; // Veritas Low Latency Transport (LLT)[7] for Veritas Cluster Server
+ static final int VAL_IPv4 = 0x0800; // Internet Protocol version 4 (IPv4)
+ static final int VAL_ARP = 0x0806; // Address Resolution Protocol (ARP)
+ static final int VAL_WAKE_ON_LAN = 0x0842; // Wake-on-LAN[3]
+ static final int VAL_TRILL = 0x22F3; // IETF TRILL Protocol
+ static final int VAL_DECNET_IV = 0x6003; // DECnet Phase IV
+ static final int VAL_REV_ARP = 0x8035; // Reverse Address Resolution Protocol
+ static final int VAL_APPLE_TALK = 0x809B; // AppleTalk (Ethertalk)
+ static final int VAL_APPLE_TALK_ARP = 0x80F3; // AppleTalk Address Resolution Protocol (AARP)
+ static final int VAL_VLAN_FRAME = 0x8100; // VLAN-tagged frame (IEEE 802.1Q) & Shortest Path Bridging IEEE 802.1aq[4]
+ static final int VAL_IPX_8137 = 0x8137; // IPX
+ static final int VAL_IPX_8138 = 0x8138; // IPX
+ static final int VAL_QNX = 0x8204; // QNX Qnet
+ static final int VAL_IPv6 = 0x86DD; // Internet Protocol Version 6 (IPv6)
+ static final int VAL_ETH_FLOW = 0x8808; // Ethernet flow control
+ static final int VAL_SLOW_PROTOCOLS = 0x8809; // Slow Protocols (IEEE 802.3)
+ static final int VAL_COBRANET = 0x8819; // CobraNet
+ static final int VAL_MPLS_UNICAST = 0x8847; // MPLS unicast
+ static final int VAL_MPLS_MULTICAST = 0x8848; // MPLS multicast
+ static final int VAL_PPPoE_DISCOVERY = 0x8863; // PPPoE Discovery Stage
+ static final int VAL_PPPoE_SESSION = 0x8864; // PPPoE Session Stage
+ static final int VAL_JUMBO_FRAMES = 0x8870; // Jumbo Frames
+ static final int VAL_HOMEPLUG_10 = 0x887B; // HomePlug 1.0 MME
+ static final int VAL_EAP_OVER_LAN = 0x888E; // EAP over LAN (IEEE 802.1X)
+ static final int VAL_PROFINET = 0x8892; // PROFINET Protocol
+ static final int VAL_HYPERSCSI = 0x889A; // HyperSCSI (SCSI over Ethernet)
+ static final int VAL_ATA_OVER_ETH = 0x88A2; // ATA over Ethernet
+ static final int VAL_ETHERCAT = 0x88A4; // EtherCAT Protocol
+ static final int VAL_BRIDGING = 0x88A8; // Provider Bridging (IEEE 802.1ad) & Shortest Path Bridging IEEE 802.1aq[5]
+ static final int VAL_POWERLINK = 0x88AB; // Ethernet Powerlink[citation needed]
+ static final int VAL_LLDP = 0x88CC; // Link Layer Discovery Protocol (LLDP)
+ static final int VAL_SERCOS = 0x88CD; // SERCOS III
+ static final int VAL_HOMEPLUG_AV = 0x88E1; // HomePlug AV MME[citation needed]
+ static final int VAL_MRP = 0x88E3; // Media Redundancy Protocol (IEC62439-2)
+ static final int VAL_MAC_SEC = 0x88E5; // MAC security (IEEE 802.1AE)
+ static final int VAL_PTP = 0x88F7; // Precision Time Protocol (IEEE 1588)
+ static final int VAL_CFM = 0x8902; // IEEE 802.1ag Connectivity Fault Management (CFM) Protocol / ITU-T Recommendation Y.1731 (OAM)
+ static final int VAL_FCoE = 0x8906; // Fibre Channel over Ethernet (FCoE)
+ static final int VAL_FCoE_INIT = 0x8914; // FCoE Initialization Protocol
+ static final int VAL_RoCE = 0x8915; // RDMA over Converged Ethernet (RoCE)
+ static final int VAL_HSR = 0x892F; // High-availability Seamless Redundancy (HSR)
+ static final int VAL_CONF_TEST = 0x9000; // Ethernet Configuration Testing Protocol[6]
+ static final int VAL_Q_IN_Q = 0x9100; // Q-in-Q
+ static final int VAL_LLT = 0xCAFE; // Veritas Low Latency Transport (LLT)[7] for Veritas Cluster Server
- public static final EthType ETH_TYPE_IPv4 = new EthType(ETH_TYPE_VAL_IPv4);
- public static final EthType ETH_TYPE_ARP = new EthType(ETH_TYPE_VAL_ARP);
- public static final EthType ETH_TYPE_WAKE_ON_LAN = new EthType(ETH_TYPE_VAL_WAKE_ON_LAN);
- public static final EthType ETH_TYPE_TRILL = new EthType(ETH_TYPE_VAL_TRILL);
- public static final EthType ETH_TYPE_DECNET_IV = new EthType(ETH_TYPE_VAL_DECNET_IV);
- public static final EthType ETH_TYPE_REV_ARP = new EthType(ETH_TYPE_VAL_REV_ARP );
- public static final EthType ETH_TYPE_APPLE_TALK = new EthType(ETH_TYPE_VAL_APPLE_TALK);
- public static final EthType ETH_TYPE_APPLE_TALK_ARP = new EthType(ETH_TYPE_VAL_APPLE_TALK_ARP);
- public static final EthType ETH_TYPE_VLAN_FRAME = new EthType(ETH_TYPE_VAL_VLAN_FRAME );
- public static final EthType ETH_TYPE_IPX_8137 = new EthType(ETH_TYPE_VAL_IPX_8137 );
- public static final EthType ETH_TYPE_IPX_8138 = new EthType(ETH_TYPE_VAL_IPX_8138 );
- public static final EthType ETH_TYPE_QNX = new EthType(ETH_TYPE_VAL_QNX );
- public static final EthType ETH_TYPE_IPv6 = new EthType(ETH_TYPE_VAL_IPv6 );
- public static final EthType ETH_TYPE_ETH_FLOW = new EthType(ETH_TYPE_VAL_ETH_FLOW);
- public static final EthType ETH_TYPE_SLOW_PROTOCOLS = new EthType(ETH_TYPE_VAL_SLOW_PROTOCOLS );
- public static final EthType ETH_TYPE_COBRANET = new EthType(ETH_TYPE_VAL_COBRANET );
- public static final EthType ETH_TYPE_MPLS_UNICAST = new EthType(ETH_TYPE_VAL_MPLS_UNICAST );
- public static final EthType ETH_TYPE_MPLS_MULTICAST = new EthType(ETH_TYPE_VAL_MPLS_MULTICAST );
- public static final EthType ETH_TYPE_PPPoE_DISCOVERY = new EthType(ETH_TYPE_VAL_PPPoE_DISCOVERY);
- public static final EthType ETH_TYPE_PPPoE_SESSION = new EthType(ETH_TYPE_VAL_PPPoE_SESSION );
- public static final EthType ETH_TYPE_JUMBO_FRAMES = new EthType(ETH_TYPE_VAL_JUMBO_FRAMES );
- public static final EthType ETH_TYPE_HOMEPLUG_10 = new EthType(ETH_TYPE_VAL_HOMEPLUG_10 );
- public static final EthType ETH_TYPE_EAP_OVER_LAN = new EthType(ETH_TYPE_VAL_EAP_OVER_LAN );
- public static final EthType ETH_TYPE_PROFINET = new EthType(ETH_TYPE_VAL_PROFINET );
- public static final EthType ETH_TYPE_HYPERSCSI = new EthType(ETH_TYPE_VAL_HYPERSCSI );
- public static final EthType ETH_TYPE_ATA_OVER_ETH = new EthType(ETH_TYPE_VAL_ATA_OVER_ETH);
- public static final EthType ETH_TYPE_ETHERCAT = new EthType(ETH_TYPE_VAL_ETHERCAT );
- public static final EthType ETH_TYPE_BRIDGING = new EthType(ETH_TYPE_VAL_BRIDGING );
- public static final EthType ETH_TYPE_POWERLINK = new EthType(ETH_TYPE_VAL_POWERLINK );
- public static final EthType ETH_TYPE_LLDP = new EthType(ETH_TYPE_VAL_LLDP );
- public static final EthType ETH_TYPE_SERCOS = new EthType(ETH_TYPE_VAL_SERCOS );
- public static final EthType ETH_TYPE_HOMEPLUG_AV = new EthType(ETH_TYPE_VAL_HOMEPLUG_AV );
- public static final EthType ETH_TYPE_MRP = new EthType(ETH_TYPE_VAL_MRP );
- public static final EthType ETH_TYPE_MAC_SEC = new EthType(ETH_TYPE_VAL_MAC_SEC);
- public static final EthType ETH_TYPE_PTP = new EthType(ETH_TYPE_VAL_PTP );
- public static final EthType ETH_TYPE_CFM = new EthType(ETH_TYPE_VAL_CFM );
- public static final EthType ETH_TYPE_FCoE = new EthType(ETH_TYPE_VAL_FCoE );
- public static final EthType ETH_TYPE_FCoE_INIT = new EthType(ETH_TYPE_VAL_FCoE_INIT );
- public static final EthType ETH_TYPE_RoCE = new EthType(ETH_TYPE_VAL_RoCE );
- public static final EthType ETH_TYPE_HSR = new EthType(ETH_TYPE_VAL_HSR );
- public static final EthType ETH_TYPE_CONF_TEST = new EthType(ETH_TYPE_VAL_CONF_TEST );
- public static final EthType ETH_TYPE_Q_IN_Q = new EthType(ETH_TYPE_VAL_Q_IN_Q );
- public static final EthType ETH_TYPE_LLT = new EthType(ETH_TYPE_VAL_LLT );
+ public static final EthType IPv4 = new EthType(VAL_IPv4);
+ public static final EthType ARP = new EthType(VAL_ARP);
+ public static final EthType WAKE_ON_LAN = new EthType(VAL_WAKE_ON_LAN);
+ public static final EthType TRILL = new EthType(VAL_TRILL);
+ public static final EthType DECNET_IV = new EthType(VAL_DECNET_IV);
+ public static final EthType REV_ARP = new EthType(VAL_REV_ARP );
+ public static final EthType APPLE_TALK = new EthType(VAL_APPLE_TALK);
+ public static final EthType APPLE_TALK_ARP = new EthType(VAL_APPLE_TALK_ARP);
+ public static final EthType VLAN_FRAME = new EthType(VAL_VLAN_FRAME );
+ public static final EthType IPX_8137 = new EthType(VAL_IPX_8137 );
+ public static final EthType IPX_8138 = new EthType(VAL_IPX_8138 );
+ public static final EthType QNX = new EthType(VAL_QNX );
+ public static final EthType IPv6 = new EthType(VAL_IPv6 );
+ public static final EthType ETH_FLOW = new EthType(VAL_ETH_FLOW);
+ public static final EthType SLOW_PROTOCOLS = new EthType(VAL_SLOW_PROTOCOLS );
+ public static final EthType COBRANET = new EthType(VAL_COBRANET );
+ public static final EthType MPLS_UNICAST = new EthType(VAL_MPLS_UNICAST );
+ public static final EthType MPLS_MULTICAST = new EthType(VAL_MPLS_MULTICAST );
+ public static final EthType PPPoE_DISCOVERY = new EthType(VAL_PPPoE_DISCOVERY);
+ public static final EthType PPPoE_SESSION = new EthType(VAL_PPPoE_SESSION );
+ public static final EthType JUMBO_FRAMES = new EthType(VAL_JUMBO_FRAMES );
+ public static final EthType HOMEPLUG_10 = new EthType(VAL_HOMEPLUG_10 );
+ public static final EthType EAP_OVER_LAN = new EthType(VAL_EAP_OVER_LAN );
+ public static final EthType PROFINET = new EthType(VAL_PROFINET );
+ public static final EthType HYPERSCSI = new EthType(VAL_HYPERSCSI );
+ public static final EthType ATA_OVER_ETH = new EthType(VAL_ATA_OVER_ETH);
+ public static final EthType ETHERCAT = new EthType(VAL_ETHERCAT );
+ public static final EthType BRIDGING = new EthType(VAL_BRIDGING );
+ public static final EthType POWERLINK = new EthType(VAL_POWERLINK );
+ public static final EthType LLDP = new EthType(VAL_LLDP );
+ public static final EthType SERCOS = new EthType(VAL_SERCOS );
+ public static final EthType HOMEPLUG_AV = new EthType(VAL_HOMEPLUG_AV );
+ public static final EthType MRP = new EthType(VAL_MRP );
+ public static final EthType MAC_SEC = new EthType(VAL_MAC_SEC);
+ public static final EthType PTP = new EthType(VAL_PTP );
+ public static final EthType CFM = new EthType(VAL_CFM );
+ public static final EthType FCoE = new EthType(VAL_FCoE );
+ public static final EthType FCoE_INIT = new EthType(VAL_FCoE_INIT );
+ public static final EthType RoCE = new EthType(VAL_RoCE );
+ public static final EthType HSR = new EthType(VAL_HSR );
+ public static final EthType CONF_TEST = new EthType(VAL_CONF_TEST );
+ public static final EthType Q_IN_Q = new EthType(VAL_Q_IN_Q );
+ public static final EthType LLT = new EthType(VAL_LLT );
+
+
+ private static final int NONE_VAL = 0x0;
+ public static final EthType NONE = new EthType(NONE_VAL);
public static final EthType NO_MASK = new EthType(0xFFFFFFFF);
public static final EthType FULL_MASK = new EthType(0x00000000);
@@ -115,92 +119,94 @@
public static EthType of(int type) {
switch (type) {
- case ETH_TYPE_VAL_IPv4:
- return ETH_TYPE_IPv4;
- case ETH_TYPE_VAL_ARP:
- return ETH_TYPE_ARP;
- case ETH_TYPE_VAL_WAKE_ON_LAN:
- return ETH_TYPE_WAKE_ON_LAN;
- case ETH_TYPE_VAL_TRILL:
- return ETH_TYPE_TRILL;
- case ETH_TYPE_VAL_DECNET_IV:
- return ETH_TYPE_DECNET_IV;
- case ETH_TYPE_VAL_REV_ARP:
- return ETH_TYPE_REV_ARP;
- case ETH_TYPE_VAL_APPLE_TALK:
- return ETH_TYPE_APPLE_TALK;
- case ETH_TYPE_VAL_APPLE_TALK_ARP:
- return ETH_TYPE_APPLE_TALK_ARP;
- case ETH_TYPE_VAL_VLAN_FRAME:
- return ETH_TYPE_VLAN_FRAME;
- case ETH_TYPE_VAL_IPX_8137:
- return ETH_TYPE_IPX_8137;
- case ETH_TYPE_VAL_IPX_8138:
- return ETH_TYPE_IPX_8138;
- case ETH_TYPE_VAL_QNX:
- return ETH_TYPE_QNX;
- case ETH_TYPE_VAL_IPv6:
- return ETH_TYPE_IPv6;
- case ETH_TYPE_VAL_ETH_FLOW:
- return ETH_TYPE_ETH_FLOW;
- case ETH_TYPE_VAL_SLOW_PROTOCOLS:
- return ETH_TYPE_SLOW_PROTOCOLS;
- case ETH_TYPE_VAL_COBRANET:
- return ETH_TYPE_COBRANET;
- case ETH_TYPE_VAL_MPLS_UNICAST:
- return ETH_TYPE_MPLS_UNICAST;
- case ETH_TYPE_VAL_MPLS_MULTICAST:
- return ETH_TYPE_MPLS_MULTICAST;
- case ETH_TYPE_VAL_PPPoE_DISCOVERY:
- return ETH_TYPE_PPPoE_DISCOVERY;
- case ETH_TYPE_VAL_PPPoE_SESSION:
- return ETH_TYPE_PPPoE_SESSION;
- case ETH_TYPE_VAL_JUMBO_FRAMES:
- return ETH_TYPE_JUMBO_FRAMES;
- case ETH_TYPE_VAL_HOMEPLUG_10:
- return ETH_TYPE_HOMEPLUG_10;
- case ETH_TYPE_VAL_EAP_OVER_LAN:
- return ETH_TYPE_EAP_OVER_LAN;
- case ETH_TYPE_VAL_PROFINET:
- return ETH_TYPE_PROFINET;
- case ETH_TYPE_VAL_HYPERSCSI:
- return ETH_TYPE_HYPERSCSI;
- case ETH_TYPE_VAL_ATA_OVER_ETH:
- return ETH_TYPE_ATA_OVER_ETH;
- case ETH_TYPE_VAL_ETHERCAT:
- return ETH_TYPE_ETHERCAT;
- case ETH_TYPE_VAL_BRIDGING:
- return ETH_TYPE_BRIDGING;
- case ETH_TYPE_VAL_POWERLINK:
- return ETH_TYPE_POWERLINK;
- case ETH_TYPE_VAL_LLDP:
- return ETH_TYPE_LLDP;
- case ETH_TYPE_VAL_SERCOS:
- return ETH_TYPE_SERCOS;
- case ETH_TYPE_VAL_HOMEPLUG_AV:
- return ETH_TYPE_HOMEPLUG_AV;
- case ETH_TYPE_VAL_MRP:
- return ETH_TYPE_MRP;
- case ETH_TYPE_VAL_MAC_SEC:
- return ETH_TYPE_MAC_SEC;
- case ETH_TYPE_VAL_PTP:
- return ETH_TYPE_PTP;
- case ETH_TYPE_VAL_CFM:
- return ETH_TYPE_CFM;
- case ETH_TYPE_VAL_FCoE:
- return ETH_TYPE_FCoE;
- case ETH_TYPE_VAL_FCoE_INIT:
- return ETH_TYPE_FCoE_INIT;
- case ETH_TYPE_VAL_RoCE:
- return ETH_TYPE_RoCE;
- case ETH_TYPE_VAL_HSR:
- return ETH_TYPE_HSR;
- case ETH_TYPE_VAL_CONF_TEST:
- return ETH_TYPE_CONF_TEST;
- case ETH_TYPE_VAL_Q_IN_Q:
- return ETH_TYPE_Q_IN_Q;
- case ETH_TYPE_VAL_LLT:
- return ETH_TYPE_LLT;
+ case NONE_VAL:
+ return NONE;
+ case VAL_IPv4:
+ return IPv4;
+ case VAL_ARP:
+ return ARP;
+ case VAL_WAKE_ON_LAN:
+ return WAKE_ON_LAN;
+ case VAL_TRILL:
+ return TRILL;
+ case VAL_DECNET_IV:
+ return DECNET_IV;
+ case VAL_REV_ARP:
+ return REV_ARP;
+ case VAL_APPLE_TALK:
+ return APPLE_TALK;
+ case VAL_APPLE_TALK_ARP:
+ return APPLE_TALK_ARP;
+ case VAL_VLAN_FRAME:
+ return VLAN_FRAME;
+ case VAL_IPX_8137:
+ return IPX_8137;
+ case VAL_IPX_8138:
+ return IPX_8138;
+ case VAL_QNX:
+ return QNX;
+ case VAL_IPv6:
+ return IPv6;
+ case VAL_ETH_FLOW:
+ return ETH_FLOW;
+ case VAL_SLOW_PROTOCOLS:
+ return SLOW_PROTOCOLS;
+ case VAL_COBRANET:
+ return COBRANET;
+ case VAL_MPLS_UNICAST:
+ return MPLS_UNICAST;
+ case VAL_MPLS_MULTICAST:
+ return MPLS_MULTICAST;
+ case VAL_PPPoE_DISCOVERY:
+ return PPPoE_DISCOVERY;
+ case VAL_PPPoE_SESSION:
+ return PPPoE_SESSION;
+ case VAL_JUMBO_FRAMES:
+ return JUMBO_FRAMES;
+ case VAL_HOMEPLUG_10:
+ return HOMEPLUG_10;
+ case VAL_EAP_OVER_LAN:
+ return EAP_OVER_LAN;
+ case VAL_PROFINET:
+ return PROFINET;
+ case VAL_HYPERSCSI:
+ return HYPERSCSI;
+ case VAL_ATA_OVER_ETH:
+ return ATA_OVER_ETH;
+ case VAL_ETHERCAT:
+ return ETHERCAT;
+ case VAL_BRIDGING:
+ return BRIDGING;
+ case VAL_POWERLINK:
+ return POWERLINK;
+ case VAL_LLDP:
+ return LLDP;
+ case VAL_SERCOS:
+ return SERCOS;
+ case VAL_HOMEPLUG_AV:
+ return HOMEPLUG_AV;
+ case VAL_MRP:
+ return MRP;
+ case VAL_MAC_SEC:
+ return MAC_SEC;
+ case VAL_PTP:
+ return PTP;
+ case VAL_CFM:
+ return CFM;
+ case VAL_FCoE:
+ return FCoE;
+ case VAL_FCoE_INIT:
+ return FCoE_INIT;
+ case VAL_RoCE:
+ return RoCE;
+ case VAL_HSR:
+ return HSR;
+ case VAL_CONF_TEST:
+ return CONF_TEST;
+ case VAL_Q_IN_Q:
+ return Q_IN_Q;
+ case VAL_LLT:
+ return LLT;
default:
// TODO: What's here?
return new EthType(type);
@@ -229,11 +235,11 @@
public String toString() {
return Integer.toHexString(rawValue);
}
-
+
public void write2Bytes(ChannelBuffer c) {
c.writeShort(this.rawValue);
}
-
+
public static EthType read2Bytes(ChannelBuffer c) {
return EthType.of(c.readUnsignedShort());
}
@@ -242,10 +248,10 @@
public EthType applyMask(EthType mask) {
return EthType.of(this.rawValue & mask.rawValue);
}
-
+
public int getValue() {
return rawValue;
}
-
+
}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/ICMPv4Code.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/ICMPv4Code.java
index 46ada58..a6544c9 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/ICMPv4Code.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/ICMPv4Code.java
@@ -3,7 +3,7 @@
import org.jboss.netty.buffer.ChannelBuffer;
/**
- *
+ *
* @author Yotam Harchol (yotam.harchol@bigswitch.com)
*
*/
@@ -13,7 +13,10 @@
final static short MAX_CODE = 0xFF;
private final short code;
-
+
+ private static final short NONE_VAL = 0;
+ public static final ICMPv4Code NONE = new ICMPv4Code(NONE_VAL);
+
public static final ICMPv4Code NO_MASK = new ICMPv4Code((short)0xFFFF);
public static final ICMPv4Code FULL_MASK = new ICMPv4Code((short)0x0000);
@@ -22,6 +25,9 @@
}
public static ICMPv4Code of(short code) {
+ if(code == NONE_VAL)
+ return NONE;
+
if (code > MAX_CODE || code < 0)
throw new IllegalArgumentException("Illegal ICMPv4 code: " + code);
return new ICMPv4Code(code);
@@ -31,15 +37,15 @@
public int getLength() {
return LENGTH;
}
-
+
public short getCode() {
return code;
}
-
+
public void writeByte(ChannelBuffer c) {
c.writeByte(this.code);
}
-
+
public static ICMPv4Code readByte(ChannelBuffer c) {
return ICMPv4Code.of(c.readUnsignedByte());
}
@@ -49,5 +55,5 @@
return ICMPv4Code.of((short)(this.code & mask.code));
}
-
+
}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/ICMPv4Type.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/ICMPv4Type.java
index 00a789b..5190d4e 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/ICMPv4Type.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/ICMPv4Type.java
@@ -64,13 +64,16 @@
public static final ICMPv4Type ICMPV4_TYPE_PHOTURIS = new ICMPv4Type(ICMPV4_TYPE_VAL_PHOTURIS);
public static final ICMPv4Type ICMPV4_TYPE_EXPERIMENTAL_MOBILITY = new ICMPv4Type(ICMPV4_TYPE_VAL_EXPERIMENTAL_MOBILITY);
+ // HACK alert - we're disapproriating ICMPV4_TYPE_ECHO_REPLY (value 0) as 'none' as well
+ public static final ICMPv4Type NONE = ICMPV4_TYPE_ECHO_REPLY;
+
public static final ICMPv4Type NO_MASK = new ICMPv4Type((short)0xFFFF);
public static final ICMPv4Type FULL_MASK = new ICMPv4Type((short)0x0000);
private final short type;
-
+
private static final int MIN_TYPE = 0;
- private static final int MAX_TYPE = 0xFF;
+ private static final int MAX_TYPE = 0xFF;
private ICMPv4Type(short type) {
this.type = type;
@@ -145,15 +148,15 @@
public int getLength() {
return LENGTH;
}
-
+
public short getType() {
return type;
}
-
+
public void writeByte(ChannelBuffer c) {
c.writeByte(this.type);
}
-
+
public static ICMPv4Type readByte(ChannelBuffer c) {
return ICMPv4Type.of(c.readUnsignedByte());
}
@@ -163,5 +166,5 @@
return ICMPv4Type.of((short)(this.type & mask.type));
}
-
+
}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv4Address.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv4Address.java
index ad454eb..5ef301b 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv4Address.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv4Address.java
@@ -13,6 +13,9 @@
static final int LENGTH = 4;
private final int rawValue;
+ private final static int NONE_VAL = 0x0;
+ public final static IPv4Address NONE = new IPv4Address(NONE_VAL);
+
public static final IPv4Address NO_MASK = IPv4Address.of(0xFFFFFFFF);
public static final IPv4Address FULL_MASK = IPv4Address.of(0x00000000);
@@ -33,6 +36,8 @@
}
public static IPv4Address of(final int raw) {
+ if(raw == NONE_VAL)
+ return NONE;
return new IPv4Address(raw);
}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv4AddressWithMask.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv4AddressWithMask.java
index a6ec439..45f10d1 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv4AddressWithMask.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv4AddressWithMask.java
@@ -1,6 +1,7 @@
package org.projectfloodlight.openflow.types;
public class IPv4AddressWithMask extends Masked<IPv4Address> {
+ public final static IPv4AddressWithMask NONE = of(IPv4Address.NONE, IPv4Address.NONE);
private IPv4AddressWithMask(int rawValue, int rawMask) {
super(IPv4Address.of(rawValue), IPv4Address.of(rawMask));
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6Address.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6Address.java
index 001f185..ea71c65 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6Address.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6Address.java
@@ -16,6 +16,10 @@
private final long raw1;
private final long raw2;
+ private final static long NONE_VAL1 = 0x0L;
+ private final static long NONE_VAL2 = 0x0L;
+ public static final IPv6Address NONE = new IPv6Address(NONE_VAL1, NONE_VAL2);
+
public static final IPv6Address NO_MASK = IPv6Address.of(0xFFFFFFFFFFFFFFFFl, 0xFFFFFFFFFFFFFFFFl);
public static final IPv6Address FULL_MASK = IPv6Address.of(0x0, 0x0);
@@ -123,6 +127,8 @@
}
public static IPv6Address of(final long raw1, final long raw2) {
+ if(raw1==NONE_VAL1 && raw2 == NONE_VAL2)
+ return NONE;
return new IPv6Address(raw1, raw2);
}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6AddressWithMask.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6AddressWithMask.java
index 16ff5b1..dcaa0b6 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6AddressWithMask.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6AddressWithMask.java
@@ -4,33 +4,34 @@
import java.util.Arrays;
public class IPv6AddressWithMask extends Masked<IPv6Address> {
+ public final static IPv6AddressWithMask NONE = of(IPv6Address.NONE, IPv6Address.NONE);
private IPv6AddressWithMask(IPv6Address value, IPv6Address mask) {
super(value, mask);
}
-
+
public static IPv6AddressWithMask of(IPv6Address value, IPv6Address mask) {
return new IPv6AddressWithMask(value, mask);
}
-
+
@Override
public String toString() {
StringBuilder res = new StringBuilder();
- res.append(((IPv6Address)value).toString());
+ res.append(value.toString());
res.append('/');
-
- BigInteger maskint = new BigInteger(((IPv6Address)mask).getBytes());
+
+ BigInteger maskint = new BigInteger(mask.getBytes());
if (maskint.not().add(BigInteger.ONE).bitCount() == 1) {
// CIDR notation
res.append(maskint.bitCount());
} else {
// Full address mask
- res.append(((IPv6Address)mask).toString());
+ res.append(mask.toString());
}
-
+
return res.toString();
}
-
+
public static IPv6AddressWithMask of(final String string) {
int slashPos;
String ip = string;
@@ -58,10 +59,10 @@
throw new IllegalArgumentException("IPv6 Address not well formed: " + string);
}
}
-
+
// Read IP
IPv6Address ipv6 = IPv6Address.of(ip);
-
+
if (maskAddress != null) {
// Full address mask
return IPv6AddressWithMask.of(ipv6, maskAddress);
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6FlowLabel.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6FlowLabel.java
index 7feb0d9..7dbf9bb 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6FlowLabel.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6FlowLabel.java
@@ -9,6 +9,9 @@
private final int label;
+ private final static int NONE_VAL = 0x0;
+ public static final IPv6FlowLabel NONE = new IPv6FlowLabel(NONE_VAL);
+
public static final IPv6FlowLabel NO_MASK = IPv6FlowLabel.of(0xFFFFFFFF);
public static final IPv6FlowLabel FULL_MASK = IPv6FlowLabel.of(0x0);
@@ -17,6 +20,8 @@
}
public static IPv6FlowLabel of(int label) {
+ if(label == NONE_VAL)
+ return NONE;
return new IPv6FlowLabel(label);
}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IpDscp.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IpDscp.java
index f311d9d..ec78315 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IpDscp.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IpDscp.java
@@ -72,6 +72,8 @@
static final int LENGTH = 1;
+ public static final IpDscp NONE = DSCP_0;
+
public static final IpDscp NO_MASK = DSCP_NO_MASK;
public static final IpDscp FULL_MASK = DSCP_0;
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IpEcn.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IpEcn.java
index 5ecd251..7e1cdf0 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IpEcn.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IpEcn.java
@@ -10,6 +10,7 @@
ECN_11((byte)3),
ECN_NO_MASK((byte)0xFF);
+ public static final IpEcn NONE = ECN_00;
public static final IpEcn NO_MASK = ECN_NO_MASK;
public static final IpEcn FULL_MASK = ECN_00;
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IpProtocol.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IpProtocol.java
index e78c97b..36a76a2 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IpProtocol.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IpProtocol.java
@@ -4,7 +4,7 @@
/**
* IP-Protocol field representation
- *
+ *
* @author Yotam Harchol (yotam.harchol@bigswitch.com)
*/
public class IpProtocol implements OFValueType<IpProtocol> {
@@ -298,6 +298,8 @@
public static final IpProtocol IP_PROTO_HIP = new IpProtocol(IP_PROTO_NUM_HIP);
public static final IpProtocol IP_PROTO_SHIM6 = new IpProtocol(IP_PROTO_NUM_SHIM6);
+ public static final IpProtocol NONE = IP_PROTO_HOPOPT;
+
public static final IpProtocol NO_MASK = IP_PROTO_HOPOPT;
public static final IpProtocol FULL_MASK = new IpProtocol((short)0x0000);
@@ -627,7 +629,7 @@
public String toString() {
return Integer.toHexString(proto);
}
-
+
public void writeByte(ChannelBuffer c) {
c.writeByte(this.proto);
}
@@ -644,5 +646,5 @@
public short getIpProtocolNumber() {
return proto;
}
-
+
}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/MacAddress.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/MacAddress.java
index 040d875..cc047ca 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/MacAddress.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/MacAddress.java
@@ -14,6 +14,9 @@
static final int MacAddrLen = 6;
private final long rawValue;
+ private final static long NONE_VAL = 0x0L;
+ public static final MacAddress NONE = new MacAddress(NONE_VAL);
+
public static final MacAddress NO_MASK = MacAddress.of(0xFFFFFFFFFFFFFFFFl);
public static final MacAddress FULL_MASK = MacAddress.of(0x0);
@@ -30,6 +33,9 @@
}
public static MacAddress of(final long raw) {
+ if(raw == NONE_VAL)
+ return NONE;
+
return new MacAddress(raw);
}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/Metadata.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/Metadata.java
index 1d0aea7..e4eed77 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/Metadata.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/Metadata.java
@@ -5,6 +5,10 @@
@Immutable
public class Metadata {
static final int LENGTH = 4;
+
+ private final static int NONE_VAL = 0;
+ public final static Metadata NONE = new Metadata(NONE_VAL);
+
private final int rawValue;
private Metadata(final int rawValue) {
@@ -12,6 +16,9 @@
}
public static Metadata of(final int raw) {
+ if(raw == NONE_VAL)
+ return NONE;
+
return new Metadata(raw);
}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFMetadata.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFMetadata.java
index 861d4a8..766ade1 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFMetadata.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFMetadata.java
@@ -8,6 +8,8 @@
private final U64 u64;
+ public static final OFMetadata NONE = OFMetadata.of(U64.ZERO);
+
public static final OFMetadata NO_MASK = OFMetadata.of(U64.ofRaw(0xFFFFFFFFFFFFFFFFl));
public static final OFMetadata FULL_MASK = OFMetadata.of(U64.ofRaw(0x0));
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFPhysicalPort.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFPhysicalPort.java
deleted file mode 100644
index ca662f7..0000000
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFPhysicalPort.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package org.projectfloodlight.openflow.types;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.projectfloodlight.openflow.exceptions.OFParseError;
-import org.projectfloodlight.openflow.protocol.OFMessageReader;
-import org.projectfloodlight.openflow.protocol.Writeable;
-
-/**
- * A wrapper around the OpenFlow physical port description. The interfaces to
- * this object are version agnostic.
- *
- * @author capveg
- */
-
-public class OFPhysicalPort implements OFValueType<OFPhysicalPort>, Writeable {
-
- static final int LENGTH = 4;
-
- private final int port;
-
- public static final OFPhysicalPort NO_MASK = OFPhysicalPort.of(0xFFFFFFFF);
- public static final OFPhysicalPort FULL_MASK = OFPhysicalPort.of(0x0);
-
- private OFPhysicalPort(int port) {
- this.port = port;
- }
-
- public static OFPhysicalPort of(int port) {
- return new OFPhysicalPort(port);
- }
-
- @Override
- public int getLength() {
- return LENGTH;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (!(obj instanceof OFPhysicalPort))
- return false;
- OFPhysicalPort other = (OFPhysicalPort)obj;
- if (other.port != this.port)
- return false;
- return true;
- }
-
- @Override
- public int hashCode() {
- final int prime = 59;
- int result = 1;
- result = prime * result + port;
- return result;
- }
-
- @Override
- public String toString() {
- return Integer.toHexString(port);
- }
-
- public void write4Bytes(ChannelBuffer c) {
- c.writeInt(this.port);
- }
-
- @Override
- public void writeTo(ChannelBuffer bb) {
- write4Bytes(bb);
- }
-
- public static OFPhysicalPort read4Bytes(ChannelBuffer c) throws OFParseError {
- return OFPhysicalPort.of((int)(c.readUnsignedInt() & 0xFFFFFFFF));
- }
-
- @Override
- public OFPhysicalPort applyMask(OFPhysicalPort mask) {
- return OFPhysicalPort.of(this.port & mask.port);
- }
-
- public int getPortNumber() {
- return port;
- }
-
- public final static Reader READER = new Reader();
- private static class Reader implements OFMessageReader<OFPhysicalPort> {
- @Override
- public OFPhysicalPort readFrom(ChannelBuffer bb) throws OFParseError {
- return OFPhysicalPort.read4Bytes(bb);
- }
-
- }
-}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFPort.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFPort.java
index d65d0aa..db7bd5f 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFPort.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFPort.java
@@ -17,9 +17,10 @@
@Immutable
public class OFPort implements OFValueType<OFPort> {
static final int LENGTH = 4;
-
+
// private int constants (OF1.1+) to avoid duplication in the code
// should not have to use these outside this class
+ private static final int OFPP_NONE_INT = 0x0;
private static final int OFPP_ANY_INT = 0xFFffFFff;
private static final int OFPP_LOCAL_INT = 0xFFffFFfe;
private static final int OFPP_CONTROLLER_INT = 0xFFffFFfd;
@@ -86,9 +87,12 @@
*/
public final static OFPort ANY = new NamedPort(OFPP_ANY_INT, "any");
+ /** port number 0, read of the wire, e.g, if not set */
+ public final static OFPort NONE = new NamedPort(OFPP_NONE_INT, "none");
+
public static final OFPort NO_MASK = OFPort.of(0xFFFFFFFF);
public static final OFPort FULL_MASK = OFPort.of(0x0);
-
+
/** cache of frequently used ports */
private static class PrecachedPort {
private final static OFPort p1 = new OFPort(1);
@@ -158,6 +162,8 @@
*/
public static OFPort ofInt(final int portNumber) {
switch (portNumber) {
+ case 0:
+ return NONE;
case 1:
return PrecachedPort.p1;
case 2:
@@ -300,6 +306,8 @@
*/
public static OFPort ofShort(final short portNumber) {
switch (portNumber) {
+ case 0:
+ return NONE;
case 1:
return PrecachedPort.p1;
case 2:
@@ -499,7 +507,7 @@
public int getLength() {
return LENGTH;
}
-
+
@Override
public boolean equals(Object obj) {
if (!(obj instanceof OFPort))
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/TransportPort.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/TransportPort.java
index 4cf5b90..6efd813 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/TransportPort.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/TransportPort.java
@@ -14,6 +14,9 @@
static final int MAX_PORT = 0xFFFF;
static final int MIN_PORT = 0;
+ private final static int NONE_VAL = 0;
+ public final static TransportPort NONE = new TransportPort(NONE_VAL);
+
public static final TransportPort NO_MASK = new TransportPort(0xFFFFFFFF);
public static final TransportPort FULL_MASK = TransportPort.of(0x0);
@@ -24,7 +27,9 @@
}
public static TransportPort of(int port) {
- if (port < MIN_PORT || port > MAX_PORT) {
+ if(port == NONE_VAL)
+ return NONE;
+ else if (port < MIN_PORT || port > MAX_PORT) {
throw new IllegalArgumentException("Illegal transport layer port number: " + port);
}
return new TransportPort(port);
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/U16.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/U16.java
index 55a467e..43bec7a 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/U16.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/U16.java
@@ -23,6 +23,9 @@
import org.projectfloodlight.openflow.protocol.Writeable;
public class U16 implements Writeable, OFValueType<U16> {
+ private final static short ZERO_VAL = 0;
+ public final static U16 ZERO = new U16(ZERO_VAL);
+
public static int f(final short i) {
return i & 0xffff;
}
@@ -38,11 +41,13 @@
}
public static final U16 of(int value) {
- return new U16(t(value));
+ return ofRaw(t(value));
}
- public static final U16 ofRaw(short value) {
- return new U16(value);
+ public static final U16 ofRaw(short raw) {
+ if(raw == ZERO_VAL)
+ return ZERO;
+ return new U16(raw);
}
public int getValue() {
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/U32.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/U32.java
index 2634ed1..f56a528 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/U32.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/U32.java
@@ -23,6 +23,9 @@
import org.projectfloodlight.openflow.protocol.Writeable;
public class U32 implements Writeable, OFValueType<U32> {
+ private final static int ZERO_VAL = 0;
+ public final static U32 ZERO = new U32(ZERO_VAL);
+
private final int raw;
private U32(int raw) {
@@ -30,11 +33,13 @@
}
public static U32 of(long value) {
- return new U32(U32.t(value));
+ return ofRaw(U32.t(value));
}
- public static U32 ofRaw(int value) {
- return new U32(value);
+ public static U32 ofRaw(int raw) {
+ if(raw == ZERO_VAL)
+ return ZERO;
+ return new U32(raw);
}
public long getValue() {
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/U64.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/U64.java
index 5de62dc..3b89e24 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/U64.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/U64.java
@@ -24,6 +24,8 @@
public class U64 implements Writeable, OFValueType<U64> {
private static final long UNSIGNED_MASK = 0x7fffffffffffffffL;
+ private final static long ZERO_VAL = 0;
+ public final static U64 ZERO = new U64(ZERO_VAL);
private final long raw;
@@ -36,6 +38,8 @@
}
public static U64 ofRaw(final long raw) {
+ if(raw == ZERO_VAL)
+ return ZERO;
return new U64(raw);
}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/U8.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/U8.java
index 41e740e..f85bfae 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/U8.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/U8.java
@@ -23,6 +23,9 @@
import org.projectfloodlight.openflow.protocol.Writeable;
public class U8 implements Writeable, OFValueType<U8> {
+ private final static byte ZERO_VAL = 0;
+ public final static U8 ZERO = new U8(ZERO_VAL);
+
private final byte raw;
private U8(byte raw) {
@@ -30,6 +33,9 @@
}
public static final U8 of(short value) {
+ if(value == ZERO_VAL)
+ return ZERO;
+
return new U8(t(value));
}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/VlanPcp.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/VlanPcp.java
index f6993fe..7d15fb7 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/VlanPcp.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/VlanPcp.java
@@ -6,10 +6,12 @@
public class VlanPcp implements OFValueType<VlanPcp> {
private static final byte VALIDATION_MASK = 0x07;
+ private static final byte NONE_VAL = 0x00;
static final int LENGTH = 1;
private final byte pcp;
+ public static final VlanPcp NONE = new VlanPcp(NONE_VAL);
public static final VlanPcp NO_MASK = new VlanPcp((byte)0xFF);
public static final VlanPcp FULL_MASK = VlanPcp.of((byte)0x0);
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/VlanVid.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/VlanVid.java
index 63b8831..5c23779 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/VlanVid.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/VlanVid.java
@@ -6,8 +6,10 @@
public class VlanVid implements OFValueType<VlanVid> {
private static final short VALIDATION_MASK = 0x0FFF;
+ private static final short NONE_VAL = 0x0000;
final static int LENGTH = 2;
+ public static final VlanVid NONE = new VlanVid(NONE_VAL);
public static final VlanVid NO_MASK = new VlanVid((short)0xFFFF);
public static final VlanVid FULL_MASK = VlanVid.of((short)0x0);
@@ -18,7 +20,9 @@
}
public static VlanVid of(short vid) {
- if ((vid & VALIDATION_MASK) != vid)
+ if(vid == NONE_VAL)
+ return NONE;
+ else if ((vid & VALIDATION_MASK) != vid)
throw new IllegalArgumentException("Illegal VLAN VID value: " + vid);
return new VlanVid(vid);
}
diff --git a/java_gen/pre-written/src/test/java/org/projectfloodlight/test/TestUtils.java b/java_gen/pre-written/src/test/java/org/projectfloodlight/test/TestUtils.java
new file mode 100644
index 0000000..7a5b8b0
--- /dev/null
+++ b/java_gen/pre-written/src/test/java/org/projectfloodlight/test/TestUtils.java
@@ -0,0 +1,62 @@
+package org.projectfloodlight.test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Assert;
+
+import com.google.common.base.Function;
+import com.google.common.base.Joiner;
+import com.google.common.collect.Lists;
+import com.google.common.primitives.Bytes;
+
+public class TestUtils {
+ private TestUtils() {}
+
+ private static final int PER_LINE = 8;
+
+ public static void betterAssertArrayEquals(byte[] expected, byte[] got) {
+ int maxlen = Math.max(expected.length, got.length);
+
+ List<String> expectedList = formatHex(Bytes.asList(expected));
+ List<String> gotList = formatHex(Bytes.asList(got));
+
+ boolean fail = false;
+ for (int i = 0; i < maxlen;i+= PER_LINE) {
+ int maxThisLine = Math.min(maxlen, PER_LINE);
+ boolean print = false;
+
+ ArrayList<String> changeMarkers = new ArrayList<String>();
+
+ for (int j = i; j < maxThisLine; j++) {
+ if (j >= expected.length || j >= got.length || expected[j] != got[j]) {
+ print = true;
+ fail = true;
+ changeMarkers.add("==");
+ break;
+ } else {
+ changeMarkers.add(" ");
+ }
+ }
+ if(print) {
+ System.out.println(String.format("%4x: %s", i, Joiner.on(" ").join(expectedList.subList(i, Math.min(expectedList.size(), i+PER_LINE)))));
+ System.out.println(String.format("%4x: %s", i, Joiner.on(" ").join(gotList.subList(i, Math.min(gotList.size(), i+PER_LINE)))));
+ System.out.println(String.format("%4s %s", "", Joiner.on(" ").join(changeMarkers)));
+ System.out.println("\n");
+ }
+ }
+ if(fail) {
+ Assert.fail("Array comparison failed");
+ }
+
+ }
+
+ private static List<String> formatHex(List<Byte> b) {
+ return Lists.transform(b, new Function<Byte, String>() {
+ @Override
+ public String apply(Byte input) {
+ return String.format("%02x", input);
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/java_gen/templates/_imports.java b/java_gen/templates/_imports.java
index 2d93b22..7fd0719 100644
--- a/java_gen/templates/_imports.java
+++ b/java_gen/templates/_imports.java
@@ -17,3 +17,4 @@
import org.jboss.netty.buffer.ChannelBuffers;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
diff --git a/java_gen/templates/custom/OFMatchV1Ver10.Builder.java b/java_gen/templates/custom/OFMatchV1Ver10.Builder.java
index 6570df8..769a687 100644
--- a/java_gen/templates/custom/OFMatchV1Ver10.Builder.java
+++ b/java_gen/templates/custom/OFMatchV1Ver10.Builder.java
@@ -1,71 +1,459 @@
+ @SuppressWarnings("unchecked")
+ @Override
+ public <F extends OFValueType<F>> F get(MatchField<F> field)
+ throws UnsupportedOperationException {
+ if (isFullyWildcarded(field))
+ return null;
- @Override
- public <F extends OFValueType<F>> F get(MatchField<F> field)
- throws UnsupportedOperationException {
- // FIXME yotam - please replace with real implementation
- return null;
- }
+ Object result;
+ switch (field.id) {
+ case IN_PORT:
+ result = inPort;
+ break;
+ case ETH_DST:
+ result = ethDst;
+ break;
+ case ETH_SRC:
+ result = ethSrc;
+ break;
+ case ETH_TYPE:
+ result = ethType;
+ break;
+ case VLAN_VID:
+ result = vlanVid;
+ break;
+ case VLAN_PCP:
+ result = vlanPcp;
+ break;
+ case IP_DSCP:
+ result = ipDscp;
+ break;
+ case IP_PROTO:
+ result = ipProto;
+ break;
+ case IPV4_SRC:
+ result = ipv4Dst;
+ break;
+ case IPV4_DST:
+ result = ipv4Dst;
+ break;
+ case TCP_SRC:
+ result = ipv4Src;
+ break;
+ case TCP_DST:
+ result = tcpDst;
+ break;
+ case UDP_SRC:
+ result = tcpSrc;
+ break;
+ case UDP_DST:
+ result = tcpDst;
+ break;
+ case SCTP_SRC:
+ result = tcpSrc;
+ break;
+ case SCTP_DST:
+ result = tcpDst;
+ break;
+ case ICMPV4_TYPE:
+ result = tcpSrc;
+ break;
+ case ICMPV4_CODE:
+ result = tcpDst;
+ break;
+ // NOT SUPPORTED:
+ default:
+ throw new UnsupportedOperationException("OFMatch does not support matching on field " + field.getName());
+ }
+ return (F)result;
+ }
- @Override
- public <F extends OFValueType<F>> Masked<F> getMasked(MatchField<F> field)
- throws UnsupportedOperationException {
- // FIXME yotam - please replace with real implementation
- return null;
- }
+ @SuppressWarnings("unchecked")
+ @Override
+ public <F extends OFValueType<F>> Masked<F> getMasked(MatchField<F> field)
+ throws UnsupportedOperationException {
+ if (!isPartiallyMasked(field))
+ return null;
+ Object result;
+ switch (field.id) {
+ case IPV4_SRC:
+ int srcBitMask = (-1) << (32 - getIpv4SrcCidrMaskLen());
+ result = IPv4AddressWithMask.of(ipv4Src, IPv4Address.of(srcBitMask));
+ break;
+ case IPV4_DST:
+ int dstMaskedBits = Math.min(32, (wildcards & OFPFW_NW_DST_MASK) >> OFPFW_NW_DST_SHIFT);
+ int dstBitMask = (-1) << (32 - getIpv4DstCidrMaskLen());
- @Override
- public boolean supports(MatchField<?> field) {
- // FIXME yotam - please replace with real implementation
- return false;
- }
+ result = IPv4AddressWithMask.of(ipv4Dst, IPv4Address.of(dstBitMask));
+ break;
+ default:
+ throw new UnsupportedOperationException("OFMatch does not support masked matching on field " + field.getName());
+ }
+ return (Masked<F>)result;
+ }
- @Override
- public boolean supportsMasked(MatchField<?> field) {
- // FIXME yotam - please replace with real implementation
- return false;
- }
+ @Override
+ public boolean supports(MatchField<?> field) {
+ switch (field.id) {
+ case IN_PORT:
+ case ETH_DST:
+ case ETH_SRC:
+ case ETH_TYPE:
+ case VLAN_VID:
+ case VLAN_PCP:
+ case IP_DSCP:
+ case IP_PROTO:
+ case IPV4_SRC:
+ case IPV4_DST:
+ case TCP_SRC:
+ case TCP_DST:
+ case UDP_SRC:
+ case UDP_DST:
+ case SCTP_SRC:
+ case SCTP_DST:
+ case ICMPV4_TYPE:
+ case ICMPV4_CODE:
+ return true;
+ default:
+ return false;
+ }
+ }
- @Override
- public boolean isExact(MatchField<?> field) {
- // FIXME yotam - please replace with real implementation
- return false;
- }
+ @Override
+ public boolean supportsMasked(MatchField<?> field) {
+ switch (field.id) {
+ case IPV4_SRC:
+ case IPV4_DST:
+ return true;
+ default:
+ return false;
+ }
+ }
- @Override
- public boolean isFullyWildcarded(MatchField<?> field) {
- // FIXME yotam - please replace with real implementation
- return false;
- }
+ @Override
+ public boolean isExact(MatchField<?> field) {
+ switch (field.id) {
+ case IN_PORT:
+ return (this.wildcards & OFPFW_IN_PORT) == 0;
+ case ETH_DST:
+ return (this.wildcards & OFPFW_DL_DST) == 0;
+ case ETH_SRC:
+ return (this.wildcards & OFPFW_DL_SRC) == 0;
+ case ETH_TYPE:
+ return (this.wildcards & OFPFW_DL_TYPE) == 0;
+ case VLAN_VID:
+ return (this.wildcards & OFPFW_DL_VLAN) == 0;
+ case VLAN_PCP:
+ return (this.wildcards & OFPFW_DL_VLAN_PCP) == 0;
+ case IP_DSCP:
+ return (this.wildcards & OFPFW_NW_TOS) == 0;
+ case IP_PROTO:
+ return (this.wildcards & OFPFW_NW_PROTO) == 0;
+ case IPV4_SRC:
+ return this.getIpv4SrcCidrMaskLen() >= 32;
+ case IPV4_DST:
+ return this.getIpv4DstCidrMaskLen() >= 32;
+ case TCP_SRC:
+ return (this.wildcards & OFPFW_TP_SRC) == 0;
+ case TCP_DST:
+ return (this.wildcards & OFPFW_TP_DST) == 0;
+ case UDP_SRC:
+ return (this.wildcards & OFPFW_TP_SRC) == 0;
+ case UDP_DST:
+ return (this.wildcards & OFPFW_TP_DST) == 0;
+ case SCTP_SRC:
+ return (this.wildcards & OFPFW_TP_SRC) == 0;
+ case SCTP_DST:
+ return (this.wildcards & OFPFW_TP_DST) == 0;
+ case ICMPV4_TYPE:
+ return (this.wildcards & OFPFW_TP_SRC) == 0;
+ case ICMPV4_CODE:
+ return (this.wildcards & OFPFW_TP_DST) == 0;
+ default:
+ throw new UnsupportedOperationException("OFMatch does not support matching on field " + field.getName());
+ }
+ }
- @Override
- public boolean isPartiallyMasked(MatchField<?> field) {
- // FIXME yotam - please replace with real implementation
- return false;
- }
+ /**
+ * Parse this match's wildcard fields and return the number of significant
+ * bits in the IP destination field. NOTE: this returns the number of bits
+ * that are fixed, i.e., like CIDR, not the number of bits that are free
+ * like OpenFlow encodes.
+ *
+ * @return A number between 0 (matches all IPs) and 32 (exact match)
+ */
+ public int getIpv4DstCidrMaskLen() {
+ return Math.max(32 - ((wildcards & OFPFW_NW_DST_MASK) >> OFPFW_NW_DST_SHIFT),
+ 0);
+ }
- @Override
- public <F extends OFValueType<F>> Match.Builder setExact(
- MatchField<F> field, F value) {
- // FIXME yotam - please replace with real implementation
- return null;
- }
+ /**
+ * Parse this match's wildcard fields and return the number of significant
+ * bits in the IP destination field. NOTE: this returns the number of bits
+ * that are fixed, i.e., like CIDR, not the number of bits that are free
+ * like OpenFlow encodes.
+ *
+ * @return A number between 0 (matches all IPs) and 32 (exact match)
+ */
+ public int getIpv4SrcCidrMaskLen() {
+ return Math.max(32 - ((wildcards & OFPFW_NW_SRC_MASK) >> OFPFW_NW_SRC_SHIFT),
+ 0);
+ }
- @Override
- public <F extends OFValueType<F>> Match.Builder setMasked(
- MatchField<F> field, F value, F mask) {
- // FIXME yotam - please replace with real implementation
- return null;
- }
- @Override
- public <F extends OFValueType<F>> Match.Builder setMasked(
- MatchField<F> field, Masked<F> valueWithMask) {
- // FIXME yotam - please replace with real implementation
- return null;
- }
+ @Override
+ public boolean isFullyWildcarded(MatchField<?> field) {
+ switch (field.id) {
+ case IN_PORT:
+ return (this.wildcards & OFPFW_IN_PORT) != 0;
+ case ETH_DST:
+ return (this.wildcards & OFPFW_DL_DST) != 0;
+ case ETH_SRC:
+ return (this.wildcards & OFPFW_DL_SRC) != 0;
+ case ETH_TYPE:
+ return (this.wildcards & OFPFW_DL_TYPE) != 0;
+ case VLAN_VID:
+ return (this.wildcards & OFPFW_DL_VLAN) != 0;
+ case VLAN_PCP:
+ return (this.wildcards & OFPFW_DL_VLAN_PCP) != 0;
+ case IP_DSCP:
+ return (this.wildcards & OFPFW_NW_TOS) != 0;
+ case IP_PROTO:
+ return (this.wildcards & OFPFW_NW_PROTO) != 0;
+ case TCP_SRC:
+ return (this.wildcards & OFPFW_TP_SRC) != 0;
+ case TCP_DST:
+ return (this.wildcards & OFPFW_TP_DST) != 0;
+ case UDP_SRC:
+ return (this.wildcards & OFPFW_TP_SRC) != 0;
+ case UDP_DST:
+ return (this.wildcards & OFPFW_TP_DST) != 0;
+ case SCTP_SRC:
+ return (this.wildcards & OFPFW_TP_SRC) != 0;
+ case SCTP_DST:
+ return (this.wildcards & OFPFW_TP_DST) != 0;
+ case ICMPV4_TYPE:
+ return (this.wildcards & OFPFW_TP_SRC) != 0;
+ case ICMPV4_CODE:
+ return (this.wildcards & OFPFW_TP_DST) != 0;
+ case IPV4_SRC:
+ return this.getIpv4SrcCidrMaskLen() <= 0;
+ case IPV4_DST:
+ return this.getIpv4DstCidrMaskLen() <= 0;
+ default:
+ throw new UnsupportedOperationException("OFMatch does not support matching on field " + field.getName());
+ }
+ }
- @Override
- public <F extends OFValueType<F>> Match.Builder wildcard(MatchField<F> field) {
- // FIXME yotam - please replace with real implementation
- return null;
- }
+ @Override
+ public boolean isPartiallyMasked(MatchField<?> field) {
+ switch (field.id) {
+ case IPV4_SRC:
+ int srcCidrLen = getIpv4SrcCidrMaskLen();
+ return srcCidrLen > 0 && srcCidrLen < 32;
+ case IPV4_DST:
+ int dstCidrLen = getIpv4SrcCidrMaskLen();
+ return dstCidrLen > 0 && dstCidrLen < 32;
+ default:
+ throw new UnsupportedOperationException("OFMatch does not support masked matching on field " + field.getName());
+ }
+ }
+
+ private final void initWildcards() {
+ if(!wildcardsSet) {
+ //:: if has_parent:
+ wildcards = parentMessage.wildcards;
+ //:: else:
+ wildcards = OFPFW_ALL;
+ //:: #endif
+ wildcardsSet = true;
+ }
+ }
+
+ @Override
+ public <F extends OFValueType<F>> Match.Builder setExact(MatchField<F> field,
+ F value) {
+ initWildcards();
+ Object val = value;
+ switch (field.id) {
+ case ETH_DST:
+ setEthDst((MacAddress) value);
+ wildcards &= ~OFPFW_DL_DST;
+ break;
+ case ETH_SRC:
+ setEthSrc((MacAddress) value);
+ wildcards &= ~OFPFW_DL_SRC;
+ break;
+ case ETH_TYPE:
+ setEthType((EthType) value);
+ wildcards &= ~OFPFW_DL_TYPE;
+ break;
+ case ICMPV4_CODE:
+ setTcpDst((TransportPort) value);
+ wildcards &= ~OFPFW_TP_DST;
+ break;
+ case ICMPV4_TYPE:
+ setTcpSrc((TransportPort) value);
+ wildcards &= ~OFPFW_TP_SRC;
+ break;
+ case IN_PORT:
+ setInPort((OFPort) value);
+ wildcards &= ~OFPFW_IN_PORT;
+ break;
+ case IPV4_DST:
+ setIpv4Dst((IPv4Address) value);
+ wildcards &= ~OFPFW_NW_DST_MASK;
+ break;
+ case IPV4_SRC:
+ setIpv4Src((IPv4Address) value);
+ wildcards &= ~OFPFW_NW_SRC_MASK;
+ break;
+ case IP_DSCP:
+ setIpDscp((IpDscp) value);
+ wildcards &= ~OFPFW_NW_TOS;
+ break;
+ case IP_PROTO:
+ setIpProto((IpProtocol) value);
+ wildcards &= ~OFPFW_NW_PROTO;
+ break;
+ case SCTP_DST:
+ setTcpDst((TransportPort) value);
+ wildcards &= ~OFPFW_TP_DST;
+ break;
+ case SCTP_SRC:
+ setTcpSrc((TransportPort) value);
+ wildcards &= ~OFPFW_TP_SRC;
+ break;
+ case TCP_DST:
+ setTcpDst((TransportPort) value);
+ wildcards &= ~OFPFW_TP_DST;
+ break;
+ case TCP_SRC:
+ setTcpSrc((TransportPort) value);
+ wildcards &= ~OFPFW_TP_SRC;
+ break;
+ case UDP_DST:
+ setTcpDst((TransportPort) value);
+ wildcards &= ~OFPFW_TP_DST;
+ break;
+ case UDP_SRC:
+ setTcpSrc((TransportPort) value);
+ wildcards &= ~OFPFW_TP_SRC;
+ break;
+ case VLAN_PCP:
+ setVlanPcp((VlanPcp) value);
+ wildcards &= ~OFPFW_DL_VLAN_PCP;
+ break;
+ case VLAN_VID:
+ setVlanVid((VlanVid) value);
+ wildcards &= ~OFPFW_DL_VLAN;
+ default:
+ throw new UnsupportedOperationException(
+ "OFMatch does not support matching on field " + field.getName());
+ }
+ return this;
+ }
+
+ @Override
+ public <F extends OFValueType<F>> Match.Builder setMasked(MatchField<F> field,
+ F value, F mask) {
+ initWildcards();
+ switch (field.id) {
+ case IPV4_DST:
+ case IPV4_SRC:
+ Object valObj = value;
+ Object masObj = mask;
+ IPv4Address ip = ((IPv4Address)valObj);
+ int maskval = ((IPv4Address)masObj).getInt();
+ if (Integer.bitCount(~maskval + 1) != 1)
+ throw new UnsupportedOperationException("OFMatch only supports CIDR masks for IPv4");
+ int maskLen = 32 - Integer.bitCount(maskval);
+ switch(field.id) {
+ case IPV4_DST:
+ setIpv4Dst(ip);
+ wildcards = (wildcards &~OFPFW_NW_DST_MASK) | (maskLen << OFPFW_NW_DST_SHIFT);
+ break;
+ case IPV4_SRC:
+ setIpv4Src(ip);
+ wildcards = (wildcards &~OFPFW_NW_SRC_MASK) | (maskLen << OFPFW_NW_SRC_SHIFT);
+ break;
+ default:
+ // Cannot really get here
+ break;
+ }
+ break;
+ default:
+ throw new UnsupportedOperationException("OFMatch does not support masked matching on field " + field.getName());
+ }
+ return this;
+ }
+
+ @Override
+ public <F extends OFValueType<F>> Match.Builder setMasked(MatchField<F> field, Masked<F> valueWithMask)
+ throws UnsupportedOperationException {
+ return this.setMasked(field, valueWithMask.getValue(), valueWithMask.getMask());
+ }
+
+ @Override
+ public <F extends OFValueType<F>> Match.Builder wildcard(MatchField<F> field) {
+ initWildcards();
+ switch (field.id) {
+ case ETH_DST:
+ setEthDst(MacAddress.NONE);
+ wildcards |= OFPFW_DL_DST;
+ break;
+ case ETH_SRC:
+ setEthSrc(MacAddress.NONE);
+ wildcards |= OFPFW_DL_SRC;
+ break;
+ case ETH_TYPE:
+ setEthType(EthType.NONE);
+ wildcards |= OFPFW_DL_TYPE;
+ break;
+ case ICMPV4_CODE:
+ case TCP_DST:
+ case UDP_DST:
+ case SCTP_DST:
+ setTcpDst(TransportPort.NONE);
+ wildcards |= OFPFW_TP_DST;
+ break;
+ case ICMPV4_TYPE:
+ case TCP_SRC:
+ case UDP_SRC:
+ case SCTP_SRC:
+ setTcpSrc(TransportPort.NONE);
+ wildcards |= OFPFW_TP_SRC;
+ break;
+ case IN_PORT:
+ setInPort(OFPort.NONE);
+ wildcards |= OFPFW_IN_PORT;
+ break;
+ case IPV4_DST:
+ setIpv4Dst(IPv4Address.NONE);
+ wildcards |= OFPFW_NW_DST_MASK;
+ break;
+ case IPV4_SRC:
+ setIpv4Src(IPv4Address.NONE);
+ wildcards |= OFPFW_NW_SRC_MASK;
+ break;
+ case IP_DSCP:
+ setIpDscp(IpDscp.NONE);
+ wildcards |= OFPFW_NW_TOS;
+ break;
+ case IP_PROTO:
+ setIpProto(IpProtocol.NONE);
+ wildcards |= OFPFW_NW_PROTO;
+ break;
+ case VLAN_PCP:
+ setVlanPcp(VlanPcp.NONE);
+ wildcards |= OFPFW_DL_VLAN_PCP;
+ break;
+ case VLAN_VID:
+ setVlanVid(VlanVid.NONE);
+ wildcards |= OFPFW_DL_VLAN;
+ break;
+ default:
+ throw new UnsupportedOperationException("OFMatch does not support matching on field " + field.getName());
+ }
+ return this;
+ }
diff --git a/java_gen/templates/custom/OFMatchV1Ver10.Builder_normalize_clear_wildcards_stanza.java b/java_gen/templates/custom/OFMatchV1Ver10.Builder_normalize_clear_wildcards_stanza.java
new file mode 100644
index 0000000..56b5662
--- /dev/null
+++ b/java_gen/templates/custom/OFMatchV1Ver10.Builder_normalize_clear_wildcards_stanza.java
@@ -0,0 +1,53 @@
+ // normalize wildcard fields to mimic old OpenVSwitch behavior. When prerequisites for a field were not met
+ // e.g., eth_type is not set to 0x800, old OVS would set the value of the corresponding ignored fields (e.g.,
+ // ip_src, tcp_dst) to 0, AND ALSO SET THE WILDCARD to 0. It doesn't do that any more as of 1.1.2 and 1.4
+ if(ethType.equals(EthType.IPv4)) {
+ // IP
+ if(ipProto.equals(IpProtocol.IP_PROTO_TCP) || ipProto.equals(IpProtocol.IP_PROTO_UDP) || ipProto.equals(IpProtocol.IP_PROTO_ICMP)) {
+ // fully speced, wildcards and all values are fine
+ // normalize 32-63 ipv4 src 'mask' to a full bitmask
+ if((wildcards & OFPFW_NW_SRC_ALL) != 0)
+ wildcards |= OFPFW_NW_SRC_MASK;
+
+ // normalize 32-63 ipv4 dst 'mask' to a full bitmask
+ if((wildcards & OFPFW_NW_DST_ALL) != 0)
+ wildcards |= OFPFW_NW_DST_MASK;
+
+ } else {
+ // normalize 32-63 ipv4 src 'mask' to a full bitmask
+ if((wildcards & OFPFW_NW_SRC_ALL) != 0)
+ wildcards |= OFPFW_NW_SRC_MASK;
+
+ // normalize 32-63 ipv4 dst 'mask' to a full bitmask
+ if((wildcards & OFPFW_NW_DST_ALL) != 0)
+ wildcards |= OFPFW_NW_DST_MASK;
+
+ // not TCP/UDP/ICMP -> Clear TP wildcards for the wire
+ wildcards &= ~(OFPFW_TP_SRC | OFPFW_TP_DST);
+ tcpSrc = TransportPort.NONE;
+ tcpDst = TransportPort.NONE;
+ }
+ } else if (ethType.equals(EthType.ARP)) {
+ // normalize 32-63 ipv4 src 'mask' to a full bitmask
+ if((wildcards & OFPFW_NW_SRC_ALL) != 0)
+ wildcards |= OFPFW_NW_SRC_MASK;
+
+ // normalize 32-63 ipv4 dst 'mask' to a full bitmask
+ if((wildcards & OFPFW_NW_DST_ALL) != 0)
+ wildcards |= OFPFW_NW_DST_MASK;
+
+ // ARP: clear NW_TOS / TP wildcards for the wire
+ wildcards &= ~( OFPFW_NW_TOS | OFPFW_TP_SRC | OFPFW_TP_DST);
+ ipDscp = IpDscp.NONE;
+ tcpSrc = TransportPort.NONE;
+ tcpDst = TransportPort.NONE;
+ } else {
+ // not even IP. Clear NW/TP wildcards for the wire
+ wildcards &= ~( OFPFW_NW_TOS | OFPFW_NW_PROTO | OFPFW_NW_SRC_MASK | OFPFW_NW_DST_MASK | OFPFW_TP_SRC | OFPFW_TP_DST);
+ ipDscp = IpDscp.NONE;
+ ipProto = IpProtocol.NONE;
+ ipv4Src = IPv4Address.NONE;
+ ipv4Dst = IPv4Address.NONE;
+ tcpSrc = TransportPort.NONE;
+ tcpDst = TransportPort.NONE;
+ }
diff --git a/java_gen/templates/custom/OFMatchV1Ver10.Builder_normalize_set_wildcards_stanza.java b/java_gen/templates/custom/OFMatchV1Ver10.Builder_normalize_set_wildcards_stanza.java
new file mode 100644
index 0000000..3545f55
--- /dev/null
+++ b/java_gen/templates/custom/OFMatchV1Ver10.Builder_normalize_set_wildcards_stanza.java
@@ -0,0 +1,53 @@
+ // normalize match fields according to current OpenVSwitch behavior. When prerequisites for a field are not met
+ // e.g., eth_type is not set to 0x800, OVS sets the value of corresponding ignored fields (e.g.,
+ // ip_src, tcp_dst) to 0, and sets the wildcard bit to 1.
+ if(ethType.equals(EthType.IPv4)) {
+ // IP
+ if(ipProto.equals(IpProtocol.IP_PROTO_TCP) || ipProto.equals(IpProtocol.IP_PROTO_UDP) || ipProto.equals(IpProtocol.IP_PROTO_ICMP)) {
+ // fully speced, wildcards and all values are fine
+ // normalize 32-63 ipv4 src 'mask' to a full bitmask
+ if((wildcards & OFPFW_NW_SRC_ALL) != 0)
+ wildcards |= OFPFW_NW_SRC_MASK;
+
+ // normalize 32-63 ipv4 dst 'mask' to a full bitmask
+ if((wildcards & OFPFW_NW_DST_ALL) != 0)
+ wildcards |= OFPFW_NW_DST_MASK;
+
+ } else {
+ // normalize 32-63 ipv4 src 'mask' to a full bitmask
+ if((wildcards & OFPFW_NW_SRC_ALL) != 0)
+ wildcards |= OFPFW_NW_SRC_MASK;
+
+ // normalize 32-63 ipv4 dst 'mask' to a full bitmask
+ if((wildcards & OFPFW_NW_DST_ALL) != 0)
+ wildcards |= OFPFW_NW_DST_MASK;
+
+ // not TCP/UDP/ICMP -> Clear TP wildcards for the wire
+ wildcards |= (OFPFW_TP_SRC | OFPFW_TP_DST);
+ tcpSrc = TransportPort.NONE;
+ tcpDst = TransportPort.NONE;
+ }
+ } else if (ethType.equals(EthType.ARP)) {
+ // normalize 32-63 ipv4 src 'mask' to a full bitmask
+ if((wildcards & OFPFW_NW_SRC_ALL) != 0)
+ wildcards |= OFPFW_NW_SRC_MASK;
+
+ // normalize 32-63 ipv4 dst 'mask' to a full bitmask
+ if((wildcards & OFPFW_NW_DST_ALL) != 0)
+ wildcards |= OFPFW_NW_DST_MASK;
+
+ // ARP: clear NW_TOS / TP wildcards for the wire
+ wildcards |= ( OFPFW_NW_TOS | OFPFW_TP_SRC | OFPFW_TP_DST);
+ ipDscp = IpDscp.NONE;
+ tcpSrc = TransportPort.NONE;
+ tcpDst = TransportPort.NONE;
+ } else {
+ // not even IP. Clear NW/TP wildcards for the wire
+ wildcards |= ( OFPFW_NW_TOS | OFPFW_NW_PROTO | OFPFW_NW_SRC_MASK | OFPFW_NW_DST_MASK | OFPFW_TP_SRC | OFPFW_TP_DST);
+ ipDscp = IpDscp.NONE;
+ ipProto = IpProtocol.NONE;
+ ipv4Src = IPv4Address.NONE;
+ ipv4Dst = IPv4Address.NONE;
+ tcpSrc = TransportPort.NONE;
+ tcpDst = TransportPort.NONE;
+ }
diff --git a/java_gen/templates/custom/OFMatchV1Ver10.Builder_normalize_stanza.java b/java_gen/templates/custom/OFMatchV1Ver10.Builder_normalize_stanza.java
new file mode 100644
index 0000000..3050563
--- /dev/null
+++ b/java_gen/templates/custom/OFMatchV1Ver10.Builder_normalize_stanza.java
@@ -0,0 +1 @@
+//:: include("custom/%s.Builder_normalize_set_wildcards_stanza.java" % msg.name, msg=msg, has_parent=False)
diff --git a/java_gen/templates/custom/OFMatchV1Ver10.Reader_normalize_stanza.java b/java_gen/templates/custom/OFMatchV1Ver10.Reader_normalize_stanza.java
new file mode 100644
index 0000000..1de18df
--- /dev/null
+++ b/java_gen/templates/custom/OFMatchV1Ver10.Reader_normalize_stanza.java
@@ -0,0 +1 @@
+//:: include("custom/%s.Builder_normalize_stanza.java" % msg.name, msg=msg, has_parent=False)
diff --git a/java_gen/templates/custom/OFMatchV1Ver10.java b/java_gen/templates/custom/OFMatchV1Ver10.java
index ec7bfcc..7b1f110 100644
--- a/java_gen/templates/custom/OFMatchV1Ver10.java
+++ b/java_gen/templates/custom/OFMatchV1Ver10.java
@@ -1,44 +1,307 @@
+ final public static int OFPFW_ALL = ((1 << 22) - 1);
+ final public static int OFPFW_IN_PORT = 1 << 0; /* Switch input port. */
+ final public static int OFPFW_DL_VLAN = 1 << 1; /* VLAN id. */
+ final public static int OFPFW_DL_SRC = 1 << 2; /* Ethernet source address. */
+ final public static int OFPFW_DL_DST = 1 << 3; /*
+ * Ethernet destination
+ * address.
+ */
+ final public static int OFPFW_DL_TYPE = 1 << 4; /* Ethernet frame type. */
+ final public static int OFPFW_NW_PROTO = 1 << 5; /* IP protocol. */
+ final public static int OFPFW_TP_SRC = 1 << 6; /* TCP/UDP source port. */
+ final public static int OFPFW_TP_DST = 1 << 7; /* TCP/UDP destination port. */
+
+ /*
+ * IP source address wildcard bit count. 0 is exact match, 1 ignores the
+ * LSB, 2 ignores the 2 least-significant bits, ..., 32 and higher wildcard
+ * the entire field. This is the *opposite* of the usual convention where
+ * e.g. /24 indicates that 8 bits (not 24 bits) are wildcarded.
+ */
+ final public static int OFPFW_NW_SRC_SHIFT = 8;
+ final public static int OFPFW_NW_SRC_BITS = 6;
+ final public static int OFPFW_NW_SRC_MASK = ((1 << OFPFW_NW_SRC_BITS) - 1) << OFPFW_NW_SRC_SHIFT;
+ final public static int OFPFW_NW_SRC_ALL = 32 << OFPFW_NW_SRC_SHIFT;
+
+ /* IP destination address wildcard bit count. Same format as source. */
+ final public static int OFPFW_NW_DST_SHIFT = 14;
+ final public static int OFPFW_NW_DST_BITS = 6;
+ final public static int OFPFW_NW_DST_MASK = ((1 << OFPFW_NW_DST_BITS) - 1) << OFPFW_NW_DST_SHIFT;
+ final public static int OFPFW_NW_DST_ALL = 32 << OFPFW_NW_DST_SHIFT;
+
+ final public static int OFPFW_DL_VLAN_PCP = 1 << 20; /* VLAN priority. */
+ final public static int OFPFW_NW_TOS = 1 << 21; /* IP ToS (DSCP field, 6bits) */
+
+ @SuppressWarnings("unchecked")
@Override
public <F extends OFValueType<F>> F get(MatchField<F> field)
throws UnsupportedOperationException {
- // FIXME yotam - please replace with real implementation
- return null;
+ if (isFullyWildcarded(field))
+ return null;
+ if (!field.arePrerequisitesOK(this))
+ return null;
+
+ Object result;
+ switch (field.id) {
+ case IN_PORT:
+ result = inPort;
+ break;
+ case ETH_DST:
+ result = ethDst;
+ break;
+ case ETH_SRC:
+ result = ethSrc;
+ break;
+ case ETH_TYPE:
+ result = ethType;
+ break;
+ case VLAN_VID:
+ result = vlanVid;
+ break;
+ case VLAN_PCP:
+ result = vlanPcp;
+ break;
+ case IP_DSCP:
+ result = ipDscp;
+ break;
+ case IP_PROTO:
+ result = ipProto;
+ break;
+ case IPV4_SRC:
+ result = ipv4Dst;
+ break;
+ case IPV4_DST:
+ result = ipv4Dst;
+ break;
+ case TCP_SRC:
+ result = ipv4Src;
+ break;
+ case TCP_DST:
+ result = tcpDst;
+ break;
+ case UDP_SRC:
+ result = tcpSrc;
+ break;
+ case UDP_DST:
+ result = tcpDst;
+ break;
+ case SCTP_SRC:
+ result = tcpSrc;
+ break;
+ case SCTP_DST:
+ result = tcpDst;
+ break;
+ case ICMPV4_TYPE:
+ result = tcpSrc;
+ break;
+ case ICMPV4_CODE:
+ result = tcpDst;
+ break;
+ // NOT SUPPORTED:
+ default:
+ throw new UnsupportedOperationException("OFMatch does not support matching on field " + field.getName());
+ }
+ return (F)result;
}
+ @SuppressWarnings("unchecked")
@Override
public <F extends OFValueType<F>> Masked<F> getMasked(MatchField<F> field)
throws UnsupportedOperationException {
- // FIXME yotam - please replace with real implementation
- return null;
+ if (!isPartiallyMasked(field))
+ return null;
+ if (!field.arePrerequisitesOK(this))
+ return null;
+ Object result;
+ switch (field.id) {
+ case IPV4_SRC:
+ int srcBitMask = (-1) << (32 - getIpv4SrcCidrMaskLen());
+ result = IPv4AddressWithMask.of(ipv4Src, IPv4Address.of(srcBitMask));
+ break;
+ case IPV4_DST:
+ int dstMaskedBits = Math.min(32, (wildcards & OFPFW_NW_DST_MASK) >> OFPFW_NW_DST_SHIFT);
+ int dstBitMask = (-1) << (32 - getIpv4DstCidrMaskLen());
+
+ result = IPv4AddressWithMask.of(ipv4Dst, IPv4Address.of(dstBitMask));
+ break;
+ default:
+ throw new UnsupportedOperationException("OFMatch does not support masked matching on field " + field.getName());
+ }
+ return (Masked<F>)result;
}
@Override
public boolean supports(MatchField<?> field) {
- // FIXME yotam - please replace with real implementation
- return false;
+ switch (field.id) {
+ case IN_PORT:
+ case ETH_DST:
+ case ETH_SRC:
+ case ETH_TYPE:
+ case VLAN_VID:
+ case VLAN_PCP:
+ case IP_DSCP:
+ case IP_PROTO:
+ case IPV4_SRC:
+ case IPV4_DST:
+ case TCP_SRC:
+ case TCP_DST:
+ case UDP_SRC:
+ case UDP_DST:
+ case SCTP_SRC:
+ case SCTP_DST:
+ case ICMPV4_TYPE:
+ case ICMPV4_CODE:
+ return true;
+ default:
+ return false;
+ }
}
@Override
public boolean supportsMasked(MatchField<?> field) {
- // FIXME yotam - please replace with real implementation
- return false;
+ switch (field.id) {
+ case IPV4_SRC:
+ case IPV4_DST:
+ return true;
+ default:
+ return false;
+ }
}
@Override
public boolean isExact(MatchField<?> field) {
- // FIXME yotam - please replace with real implementation
- return false;
+ if (!field.arePrerequisitesOK(this))
+ return false;
+
+ switch (field.id) {
+ case IN_PORT:
+ return (this.wildcards & OFPFW_IN_PORT) == 0;
+ case ETH_DST:
+ return (this.wildcards & OFPFW_DL_DST) == 0;
+ case ETH_SRC:
+ return (this.wildcards & OFPFW_DL_SRC) == 0;
+ case ETH_TYPE:
+ return (this.wildcards & OFPFW_DL_TYPE) == 0;
+ case VLAN_VID:
+ return (this.wildcards & OFPFW_DL_VLAN) == 0;
+ case VLAN_PCP:
+ return (this.wildcards & OFPFW_DL_VLAN_PCP) == 0;
+ case IP_DSCP:
+ return (this.wildcards & OFPFW_NW_TOS) == 0;
+ case IP_PROTO:
+ return (this.wildcards & OFPFW_NW_PROTO) == 0;
+ case IPV4_SRC:
+ return this.getIpv4SrcCidrMaskLen() >= 32;
+ case IPV4_DST:
+ return this.getIpv4DstCidrMaskLen() >= 32;
+ case TCP_SRC:
+ return (this.wildcards & OFPFW_TP_SRC) == 0;
+ case TCP_DST:
+ return (this.wildcards & OFPFW_TP_DST) == 0;
+ case UDP_SRC:
+ return (this.wildcards & OFPFW_TP_SRC) == 0;
+ case UDP_DST:
+ return (this.wildcards & OFPFW_TP_DST) == 0;
+ case SCTP_SRC:
+ return (this.wildcards & OFPFW_TP_SRC) == 0;
+ case SCTP_DST:
+ return (this.wildcards & OFPFW_TP_DST) == 0;
+ case ICMPV4_TYPE:
+ return (this.wildcards & OFPFW_TP_SRC) == 0;
+ case ICMPV4_CODE:
+ return (this.wildcards & OFPFW_TP_DST) == 0;
+ default:
+ throw new UnsupportedOperationException("OFMatch does not support matching on field " + field.getName());
+ }
}
+ /**
+ * Parse this match's wildcard fields and return the number of significant
+ * bits in the IP destination field. NOTE: this returns the number of bits
+ * that are fixed, i.e., like CIDR, not the number of bits that are free
+ * like OpenFlow encodes.
+ *
+ * @return A number between 0 (matches all IPs) and 32 (exact match)
+ */
+ public int getIpv4DstCidrMaskLen() {
+ return Math.max(32 - ((wildcards & OFPFW_NW_DST_MASK) >> OFPFW_NW_DST_SHIFT),
+ 0);
+ }
+
+ /**
+ * Parse this match's wildcard fields and return the number of significant
+ * bits in the IP destination field. NOTE: this returns the number of bits
+ * that are fixed, i.e., like CIDR, not the number of bits that are free
+ * like OpenFlow encodes.
+ *
+ * @return A number between 0 (matches all IPs) and 32 (exact match)
+ */
+ public int getIpv4SrcCidrMaskLen() {
+ return Math.max(32 - ((wildcards & OFPFW_NW_SRC_MASK) >> OFPFW_NW_SRC_SHIFT),
+ 0);
+ }
+
+
@Override
public boolean isFullyWildcarded(MatchField<?> field) {
- // FIXME yotam - please replace with real implementation
- return false;
+ if (!field.arePrerequisitesOK(this))
+ return true;
+
+ switch (field.id) {
+ case IN_PORT:
+ return (this.wildcards & OFPFW_IN_PORT) != 0;
+ case ETH_DST:
+ return (this.wildcards & OFPFW_DL_DST) != 0;
+ case ETH_SRC:
+ return (this.wildcards & OFPFW_DL_SRC) != 0;
+ case ETH_TYPE:
+ return (this.wildcards & OFPFW_DL_TYPE) != 0;
+ case VLAN_VID:
+ return (this.wildcards & OFPFW_DL_VLAN) != 0;
+ case VLAN_PCP:
+ return (this.wildcards & OFPFW_DL_VLAN_PCP) != 0;
+ case IP_DSCP:
+ return (this.wildcards & OFPFW_NW_TOS) != 0;
+ case IP_PROTO:
+ return (this.wildcards & OFPFW_NW_PROTO) != 0;
+ case TCP_SRC:
+ return (this.wildcards & OFPFW_TP_SRC) != 0;
+ case TCP_DST:
+ return (this.wildcards & OFPFW_TP_DST) != 0;
+ case UDP_SRC:
+ return (this.wildcards & OFPFW_TP_SRC) != 0;
+ case UDP_DST:
+ return (this.wildcards & OFPFW_TP_DST) != 0;
+ case SCTP_SRC:
+ return (this.wildcards & OFPFW_TP_SRC) != 0;
+ case SCTP_DST:
+ return (this.wildcards & OFPFW_TP_DST) != 0;
+ case ICMPV4_TYPE:
+ return (this.wildcards & OFPFW_TP_SRC) != 0;
+ case ICMPV4_CODE:
+ return (this.wildcards & OFPFW_TP_DST) != 0;
+ case IPV4_SRC:
+ return this.getIpv4SrcCidrMaskLen() <= 0;
+ case IPV4_DST:
+ return this.getIpv4DstCidrMaskLen() <= 0;
+ default:
+ throw new UnsupportedOperationException("OFMatch does not support matching on field " + field.getName());
+ }
}
@Override
public boolean isPartiallyMasked(MatchField<?> field) {
- // FIXME yotam - please replace with real implementation
- return false;
+ if (!field.arePrerequisitesOK(this))
+ return false;
+
+ switch (field.id) {
+ case IPV4_SRC:
+ int srcCidrLen = getIpv4SrcCidrMaskLen();
+ return srcCidrLen > 0 && srcCidrLen < 32;
+ case IPV4_DST:
+ int dstCidrLen = getIpv4SrcCidrMaskLen();
+ return dstCidrLen > 0 && dstCidrLen < 32;
+ default:
+ throw new UnsupportedOperationException("OFMatch does not support masked matching on field " + field.getName());
+ }
}
diff --git a/java_gen/templates/of_class.java b/java_gen/templates/of_class.java
index d03ffbf..aa68d04 100644
--- a/java_gen/templates/of_class.java
+++ b/java_gen/templates/of_class.java
@@ -47,7 +47,9 @@
//:: #endif
//:: for prop in msg.data_members:
- private final static ${prop.java_type.public_type} ${prop.default_name} = ${prop.default_value};
+ //:: if prop.default_value:
+ private final static ${prop.java_type.public_type} ${prop.default_name} = ${prop.default_value};
+ //:: #endif
//:: #end
// OF message fields
@@ -97,13 +99,27 @@
//:: include("_field_accessors.java", msg=msg, generate_setters=True, builder=True, has_parent=True)
+
@Override
public ${msg.interface.name} build() {
+ //:: for prop in msg.data_members:
+ ${prop.java_type.public_type} ${prop.name} = this.${prop.name}Set ? this.${prop.name} : parentMessage.${prop.name};
+ //:: if not prop.is_nullable and not prop.java_type.is_primitive:
+ if(${prop.name} == null)
+ throw new NullPointerException("Property ${prop.name} must not be null");
+ //:: #endif
+ //:: #endfor
+
+ //
+ //:: if os.path.exists("%s/custom/%s.Builder_normalize_stanza.java" % (template_dir, msg.name)):
+ //:: include("custom/%s.Builder_normalize_stanza.java" % msg.name, msg=msg, has_parent=False)
+ //:: #endif
return new ${impl_class}(
- ${",\n ".join(
- [ "this.{0}Set ? this.{0} : parentMessage.{0}".format(prop.name)
- for prop in msg.data_members])}
- );
+ //:: for i, prop in enumerate(msg.data_members):
+ //:: comma = "," if i < len(msg.data_members)-1 else ""
+ ${prop.name}${comma}
+ //:: #endfor
+ );
}
//:: if os.path.exists("%s/custom/%s.Builder.java" % (template_dir, msg.name)):
//:: include("custom/%s.Builder.java" % msg.name, msg=msg, has_parent=True)
@@ -122,10 +138,28 @@
//
@Override
public ${msg.interface.name} build() {
+ //:: for prop in msg.data_members:
+ //:: if prop.default_value:
+ ${prop.java_type.public_type} ${prop.name} = this.${prop.name}Set ? this.${prop.name} : ${prop.default_name};
+ //:: else:
+ if(!this.${prop.name}Set)
+ throw new IllegalStateException("Property ${prop.name} doesn't have default value -- must be set");
+ //:: #endif
+ //:: if not prop.is_nullable and not prop.java_type.is_primitive:
+ if(${prop.name} == null)
+ throw new NullPointerException("Property ${prop.name} must not be null");
+ //:: #endif
+ //:: #endfor
+
+ //:: if os.path.exists("%s/custom/%s.Builder_normalize_stanza.java" % (template_dir, msg.name)):
+ //:: include("custom/%s.Builder_normalize_stanza.java" % msg.name, msg=msg, has_parent=False)
+ //:: #endif
+
return new ${impl_class}(
- ${",\n ".join(
- [ "this.{0}Set ? this.{0} : {1}.{2}".format(prop.name, impl_class, prop.default_name)
- for prop in msg.data_members])}
+ //:: for i, prop in enumerate(msg.data_members):
+ //:: comma = "," if i < len(msg.data_members)-1 else ""
+ ${prop.name}${comma}
+ //:: #endfor
);
}
//:: if os.path.exists("%s/custom/%s.Builder.java" % (template_dir, msg.name)):
@@ -190,7 +224,10 @@
//:: #endif
//:: if msg.data_members:
- return new ${impl_class}(
+ //:: if os.path.exists("%s/custom/%s.Reader_normalize_stanza.java" % (template_dir, msg.name)):
+ //:: include("custom/%s.Reader_normalize_stanza.java" % msg.name, msg=msg, has_parent=False)
+ //:: #endif
+ return new ${impl_class}(
${",\n ".join(
[ prop.name for prop in msg.data_members])}
);
diff --git a/test_data/of10/flow_add.data b/test_data/of10/flow_add.data
index fc09a23..d1a4dd3 100644
--- a/test_data/of10/flow_add.data
+++ b/test_data/of10/flow_add.data
@@ -1,24 +1,49 @@
-- binary
-01 0e 00 70 12 34 56 78
-00 10 00 02 00 03 01 23
-45 67 89 ab cd ef 01 23
-45 67 00 00 00 00 00 00
-00 00 00 00 c0 a8 03 7f
-ff ff ff ff 00 00 00 00
-00 00 00 00 00 00 00 00
-00 00 00 05 00 00 00 00
-00 00 00 00 00 00 00 02
-00 00 00 08 ff fb 00 00
-ff ff 00 10 00 00 23 20
-00 12 00 00 00 00 00 00
-ff ff 00 10 00 5c 16 c7
-00 00 00 02 00 00 00 00
+01 0e # version, type
+00 70 # length
+12 34 56 78 # xid
+
+#### ofp_flow_mod
+00 30 00 e2 # wild cards=(OFPFW_DL_VLAN|OFPFW_NW_PROTO|OFPFW_TP_SRC|OFPFW_TP_DST|OFPFW_DL_VLAN_PCP|OFPFW_NW_TOS)
+00 03 # in_port
+01 23 45 67 89 ab # eth_src
+cd ef 01 23 45 67 # eth_dst
+00 00 # dl_vlan
+00 00 # dl_pcp, pad
+08 00 # dl_type
+00 00 00 00 # nw_tos, nw_proto, pad[2]
+c0 a8 03 7f # nw_src
+ff ff ff ff # nw_dst
+00 00 00 00 # tcp_src, tcp_dst
+
+00 00 00 00 00 00 00 00 # cookie
+00 00 # command
+00 05 # idle_timeout
+00 00 # hard_timeout
+00 00 # priority
+00 00 00 00 # buffer_id
+00 00 #out_port
+00 02 # flags (CHECK_OVERLAP)
+
+#list(ofp_action)
+00 00 00 08 # type=OUTPUT, len=8
+ff fb # port=FLOOD
+00 00 # maxLen=0
+ff ff 00 10 # type=VENDOR, len=16
+00 00 23 20 # vendor = Nicira
+00 12 # subtype=dec_ttl
+00 00 00 00 00 00 # pad(6)
+ff ff 00 10 # type=VENDOR, len=16
+00 5c 16 c7 # vendor = BSN
+00 00 00 02 # subype = set_tunnel_dst
+00 00 00 00 # tunnel dst ip
-- python
ofp.message.flow_add(
xid=0x12345678,
match=ofp.match(
- wildcards=ofp.OFPFW_DL_VLAN|ofp.OFPFW_DL_VLAN_PCP,
+ wildcards=ofp.OFPFW_DL_VLAN|ofp.OFPFW_NW_PROTO|ofp.OFPFW_TP_SRC|ofp.OFPFW_TP_DST|ofp.OFPFW_DL_VLAN_PCP|ofp.OFPFW_NW_TOS,
in_port=3,
+ eth_type=0x800,
ipv4_src=0xc0a8037f,
ipv4_dst=0xffffffff,
eth_src=[0x01, 0x23, 0x45, 0x67, 0x89, 0xab],
@@ -33,13 +58,13 @@
flow_add {
xid = 0x12345678,
match = match_v1 {
- wildcards = OFPFW_DL_VLAN|OFPFW_DL_VLAN_PCP,
+ wildcards = OFPFW_DL_VLAN|OFPFW_NW_PROTO|OFPFW_TP_SRC|OFPFW_TP_DST|OFPFW_DL_VLAN_PCP|OFPFW_NW_TOS,
in_port = 3,
eth_src = 01:23:45:67:89:ab,
eth_dst = cd:ef:01:23:45:67,
vlan_vid = 0x0,
vlan_pcp = 0x0,
- eth_type = 0x0,
+ eth_type = 0x800,
ip_dscp = 0x0,
ip_proto = 0x0,
ipv4_src = 192.168.3.127,
@@ -70,20 +95,22 @@
match.fields.in_port = 3;
match.fields.eth_src = (of_mac_addr_t) { { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab } };
match.fields.eth_dst = (of_mac_addr_t) { { 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67 } };
+ match.fields.eth_type = 0x800;
match.fields.ipv4_src = 0xc0a8037f;
match.fields.ipv4_dst = 0xffffffff;
OF_MATCH_MASK_IN_PORT_EXACT_SET(&match);
OF_MATCH_MASK_ETH_SRC_EXACT_SET(&match);
OF_MATCH_MASK_ETH_DST_EXACT_SET(&match);
+ OF_MATCH_MASK_ETH_TYPE_EXACT_SET(&match);
//OF_MATCH_MASK_VLAN_VID_EXACT_SET(&match);
//OF_MATCH_MASK_VLAN_PCP_EXACT_SET(&match);
OF_MATCH_MASK_ETH_TYPE_EXACT_SET(&match);
- OF_MATCH_MASK_IP_DSCP_EXACT_SET(&match);
- OF_MATCH_MASK_IP_PROTO_EXACT_SET(&match);
+ //OF_MATCH_MASK_IP_DSCP_EXACT_SET(&match);
+ //OF_MATCH_MASK_IP_PROTO_EXACT_SET(&match);
OF_MATCH_MASK_IPV4_SRC_EXACT_SET(&match);
OF_MATCH_MASK_IPV4_DST_EXACT_SET(&match);
- OF_MATCH_MASK_TCP_SRC_EXACT_SET(&match);
- OF_MATCH_MASK_TCP_DST_EXACT_SET(&match);
+ //OF_MATCH_MASK_TCP_SRC_EXACT_SET(&match);
+ //OF_MATCH_MASK_TCP_DST_EXACT_SET(&match);
of_flow_add_match_set(obj, &match);
}
{
@@ -106,3 +133,24 @@
of_list_action_append_bind(&actions, &action);
}
}
+-- java
+builder.setXid(0x12345678)
+ .setMatch(
+ factory.buildMatch()
+ .setExact(MatchField.IN_PORT, OFPort.of(3))
+ .setExact(MatchField.ETH_TYPE, EthType.IPv4)
+ .setExact(MatchField.IPV4_SRC, IPv4Address.of(0xc0a8037f))
+ .setExact(MatchField.IPV4_DST, IPv4Address.of(0xffffffff))
+ .setExact(MatchField.ETH_SRC, MacAddress.of("01:23:45:67:89:ab"))
+ .setExact(MatchField.ETH_DST, MacAddress.of("cd:ef:01:23:45:67"))
+ .build()
+ )
+ .setIdleTimeout(5)
+ .setFlags(Sets.immutableEnumSet(OFFlowModFlags.CHECK_OVERLAP))
+ .setActions(
+ ImmutableList.of(
+ factory.actions().output(OFPort.FLOOD, 0),
+ factory.actions().niciraDecTtl(),
+ factory.actions().bsnSetTunnelDst(0)
+ )
+ );
diff --git a/test_data/of10/flow_stats_entry.data b/test_data/of10/flow_stats_entry.data
index 2f9df64..3422064 100644
--- a/test_data/of10/flow_stats_entry.data
+++ b/test_data/of10/flow_stats_entry.data
@@ -2,12 +2,20 @@
00 68 # length
03 # table_id
00 # pad
-00 3f ff ff # match.wildcards
-00 00 00 00 # remaining match fields
-00 00 00 00 00 00 00 00 # ...
-00 00 00 00 00 00 00 00 # ...
-00 00 00 00 00 00 00 00 # ...
-00 00 00 00 00 00 00 00 # ...
+
+#### ofp_match_v1
+00 30 00 e2 # wild cards=(OFPFW_DL_VLAN|OFPFW_NW_PROTO|OFPFW_TP_SRC|OFPFW_TP_DST|OFPFW_DL_VLAN_PCP|OFPFW_NW_TOS)
+00 03 # in_port
+01 23 45 67 89 ab # eth_src
+cd ef 01 23 45 67 # eth_dst
+00 00 # dl_vlan
+00 00 # dl_pcp, pad
+08 00 # dl_type
+00 00 00 00 # nw_tos, nw_proto, pad[2]
+c0 a8 03 7f # nw_src
+ff ff ff ff # nw_dst
+00 00 00 00 # tcp_src, tcp_dst
+
00 00 00 01 # duration_sec
00 00 00 02 # duration_nsec
00 64 # priority
@@ -28,7 +36,14 @@
-- python
ofp.flow_stats_entry(
table_id=3,
- match=ofp.match(),
+ match=ofp.match(
+ wildcards=ofp.OFPFW_DL_VLAN|ofp.OFPFW_NW_PROTO|ofp.OFPFW_TP_SRC|ofp.OFPFW_TP_DST|ofp.OFPFW_DL_VLAN_PCP|ofp.OFPFW_NW_TOS,
+ in_port=3,
+ eth_type=0x800,
+ ipv4_src=0xc0a8037f,
+ ipv4_dst=0xffffffff,
+ eth_src=[0x01, 0x23, 0x45, 0x67, 0x89, 0xab],
+ eth_dst=[0xcd, 0xef, 0x01, 0x23, 0x45, 0x67]),
duration_sec=1,
duration_nsec=2,
priority=100,
@@ -60,6 +75,7 @@
of_object_delete(obj);
}
}
+
of_flow_stats_entry_byte_count_set(obj, 1000);
of_flow_stats_entry_cookie_set(obj, 81985529216486895);
of_flow_stats_entry_duration_nsec_set(obj, 2);
@@ -68,8 +84,54 @@
of_flow_stats_entry_idle_timeout_set(obj, 5);
{
of_match_t match = { OF_VERSION_1_0 };
+ match.fields.in_port = 3;
+ match.fields.eth_src = (of_mac_addr_t) { { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab } };
+ match.fields.eth_dst = (of_mac_addr_t) { { 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67 } };
+ match.fields.eth_type = 0x800;
+ match.fields.ipv4_src = 0xc0a8037f;
+ match.fields.ipv4_dst = 0xffffffff;
+ OF_MATCH_MASK_IN_PORT_EXACT_SET(&match);
+ OF_MATCH_MASK_ETH_SRC_EXACT_SET(&match);
+ OF_MATCH_MASK_ETH_DST_EXACT_SET(&match);
+ OF_MATCH_MASK_ETH_TYPE_EXACT_SET(&match);
+ //OF_MATCH_MASK_VLAN_VID_EXACT_SET(&match);
+ //OF_MATCH_MASK_VLAN_PCP_EXACT_SET(&match);
+ OF_MATCH_MASK_ETH_TYPE_EXACT_SET(&match);
+ //OF_MATCH_MASK_IP_DSCP_EXACT_SET(&match);
+ //OF_MATCH_MASK_IP_PROTO_EXACT_SET(&match);
+ OF_MATCH_MASK_IPV4_SRC_EXACT_SET(&match);
+ OF_MATCH_MASK_IPV4_DST_EXACT_SET(&match);
+ //OF_MATCH_MASK_TCP_SRC_EXACT_SET(&match);
+ //OF_MATCH_MASK_TCP_DST_EXACT_SET(&match);
of_flow_stats_entry_match_set(obj, &match);
}
of_flow_stats_entry_packet_count_set(obj, 10);
of_flow_stats_entry_priority_set(obj, 100);
of_flow_stats_entry_table_id_set(obj, 3);
+-- java
+ builder
+ .setTableId((short) 3)
+ .setMatch(
+ factory.buildMatch()
+ .setExact(MatchField.IN_PORT, OFPort.of(3))
+ .setExact(MatchField.ETH_TYPE, EthType.IPv4)
+ .setExact(MatchField.IPV4_SRC, IPv4Address.of(0xc0a8037f))
+ .setExact(MatchField.IPV4_DST, IPv4Address.of(0xffffffff))
+ .setExact(MatchField.ETH_SRC, MacAddress.of("01:23:45:67:89:ab"))
+ .setExact(MatchField.ETH_DST, MacAddress.of("cd:ef:01:23:45:67"))
+ .build()
+ )
+ .setDurationSec(1)
+ .setDurationNsec(2)
+ .setPriority(100)
+ .setIdleTimeout(5)
+ .setHardTimeout(10)
+ .setCookie(U64.of(0x0123456789abcdefL))
+ .setPacketCount(U64.of(10))
+ .setByteCount(U64.of(1000))
+ .setActions(
+ ImmutableList.<OFAction>of(
+ factory.actions().output(OFPort.of(1), 0),
+ factory.actions().output(OFPort.of(2), 0)
+ )
+ );
diff --git a/test_data/of13/flow_add.data b/test_data/of13/flow_add.data
index 049d797..692a7b9 100644
--- a/test_data/of13/flow_add.data
+++ b/test_data/of13/flow_add.data
@@ -87,7 +87,7 @@
.setMatch(
factory.buildMatch()
.setMasked(MatchField.IN_PORT, OFPort.of(4), OFPort.of(5))
- .setExact(MatchField.ETH_TYPE, EthType.ETH_TYPE_IPv6)
+ .setExact(MatchField.ETH_TYPE, EthType.IPv6)
.setExact(MatchField.IP_PROTO, IpProtocol.IP_PROTO_TCP)
.setMasked(MatchField.IPV6_SRC,
IPv6Address.of(0x1CCAFE1CB1101C00l, 0x0028000000000000l),
diff --git a/test_data/of13/flow_delete.data b/test_data/of13/flow_delete.data
index 268304c..3762fab 100644
--- a/test_data/of13/flow_delete.data
+++ b/test_data/of13/flow_delete.data
@@ -87,7 +87,7 @@
.setMatch(
factory.buildMatch()
.setMasked(MatchField.IN_PORT, OFPort.of(4), OFPort.of(5))
- .setExact(MatchField.ETH_TYPE, EthType.ETH_TYPE_IPv6)
+ .setExact(MatchField.ETH_TYPE, EthType.IPv6)
.setExact(MatchField.IP_PROTO, IpProtocol.IP_PROTO_TCP)
.setMasked(MatchField.IPV6_SRC,
IPv6Address.of(0x1CCAFE1CB1101C00l, 0x0028000000000000l),
diff --git a/test_data/of13/flow_delete_strict.data b/test_data/of13/flow_delete_strict.data
index 6165405..7a0347c 100644
--- a/test_data/of13/flow_delete_strict.data
+++ b/test_data/of13/flow_delete_strict.data
@@ -87,7 +87,7 @@
.setMatch(
factory.buildMatch()
.setMasked(MatchField.IN_PORT, OFPort.of(4), OFPort.of(5))
- .setExact(MatchField.ETH_TYPE, EthType.ETH_TYPE_IPv6)
+ .setExact(MatchField.ETH_TYPE, EthType.IPv6)
.setExact(MatchField.IP_PROTO, IpProtocol.IP_PROTO_TCP)
.setMasked(MatchField.IPV6_SRC,
IPv6Address.of(0x1CCAFE1CB1101C00l, 0x0028000000000000l),
diff --git a/test_data/of13/flow_modify.data b/test_data/of13/flow_modify.data
index 188ab3d..620af3d 100644
--- a/test_data/of13/flow_modify.data
+++ b/test_data/of13/flow_modify.data
@@ -87,7 +87,7 @@
.setMatch(
factory.buildMatch()
.setMasked(MatchField.IN_PORT, OFPort.of(4), OFPort.of(5))
- .setExact(MatchField.ETH_TYPE, EthType.ETH_TYPE_IPv6)
+ .setExact(MatchField.ETH_TYPE, EthType.IPv6)
.setExact(MatchField.IP_PROTO, IpProtocol.IP_PROTO_TCP)
.setMasked(MatchField.IPV6_SRC,
IPv6Address.of(0x1CCAFE1CB1101C00l, 0x0028000000000000l),
diff --git a/test_data/of13/flow_modify_strict.data b/test_data/of13/flow_modify_strict.data
index a40210a..79814e3 100644
--- a/test_data/of13/flow_modify_strict.data
+++ b/test_data/of13/flow_modify_strict.data
@@ -87,7 +87,7 @@
.setMatch(
factory.buildMatch()
.setMasked(MatchField.IN_PORT, OFPort.of(4), OFPort.of(5))
- .setExact(MatchField.ETH_TYPE, EthType.ETH_TYPE_IPv6)
+ .setExact(MatchField.ETH_TYPE, EthType.IPv6)
.setExact(MatchField.IP_PROTO, IpProtocol.IP_PROTO_TCP)
.setMasked(MatchField.IPV6_SRC,
IPv6Address.of(0x1CCAFE1CB1101C00l, 0x0028000000000000l),