Merge into master from pull request #39:
Java_gen: improvements to the value types, courtesy of Yotam (https://github.com/floodlight/loxigen/pull/39)
diff --git a/java_gen/java_model.py b/java_gen/java_model.py
index 3755c82..35f334c 100644
--- a/java_gen/java_model.py
+++ b/java_gen/java_model.py
@@ -150,7 +150,7 @@
self.parent_interface = None
def class_info(self):
- if re.match(r'OFFlow(Add|Modify(Strict?)|Deleted(Strict?))', self.name):
+ if re.match(r'OFFlow(Add|Modify(Strict)?|Delete(Strict)?)$', self.name):
return ("", "OFFlowMod")
elif utils.class_is_message(self.c_name):
return ("", "OFMessage")
diff --git a/java_gen/java_type.py b/java_gen/java_type.py
index 3fa9e81..8580f37 100644
--- a/java_gen/java_type.py
+++ b/java_gen/java_type.py
@@ -21,6 +21,19 @@
return camel
+ANY = 0xFFFFFFFFFFFFFFFF
+
+
+class VersionOp:
+ def __init__(self, version=ANY, read=None, write=None):
+ self.version = version
+ self.read = read
+ self.write = write
+
+ def __str__(self):
+ return "[Version: %d, Read: '%s', Write: '%s']" % (self.version, self.read, self.write)
+
+
class JType(object):
""" Wrapper class to hold C to Java type conversion information """
def __init__(self, pub_type, priv_type=None, size=None, read_op=None, write_op=None):
@@ -29,12 +42,17 @@
priv_type = pub_type
self.priv_type = priv_type # the internal storage type
self.size = size # bytes on the wire; None == variable length or hard to calc
- if read_op is None:
- read_op = 'ChannelUtils.read%s(bb)' % self.pub_type
- if write_op is None:
- write_op = 'ChannelUtils.write%s(bb, $name)' % self.pub_type
- self._read_op = read_op
- self._write_op = write_op
+ self.ops = {}
+# if read_op is None:
+# read_op = 'ChannelUtils.read%s(bb)' % self.pub_type
+# if write_op is None:
+# write_op = 'ChannelUtils.write%s(bb, $name)' % self.pub_type
+# self._read_op = read_op
+# self._write_op = write_op
+
+ def op(self, version=ANY, read=None, write=None):
+ self.ops[version] = VersionOp(version, read, write)
+ return self
@property
def public_type(self):
@@ -53,105 +71,111 @@
if length is None:
length = "length - bb.readerIndex()";
- if callable(self._read_op):
- return self._read_op(version)
+ ver = ANY if version is None else version.int_version
+ _read_op = None
+ if ver in self.ops:
+ _read_op = self.ops[ver].read or self.ops[ANY].read
+ elif ANY in self.ops:
+ _read_op = self.ops[ANY].read
+ if _read_op is None:
+ _read_op = 'ChannelUtils.read%s(bb)' % self.pub_type
+ if callable(_read_op):
+ return _read_op(version)
else:
- return self._read_op.replace("$length", str(length)).replace("$version", version.of_version)
+ return _read_op.replace("$length", str(length)).replace("$version", version.of_version)
def write_op(self, version=None, name=None):
- if callable(self._write_op):
- return self._write_op(version, name)
+ ver = ANY if version is None else version.int_version
+ _write_op = None
+ if ver in self.ops:
+ _write_op = self.ops[ver].write or self.ops[ANY].write
+ elif ANY in self.ops:
+ _write_op = self.ops[ANY].write
+ if _write_op is None:
+ _write_op = 'ChannelUtils.write%s(bb, $name)' % self.pub_type
+ if callable(_write_op):
+ return _write_op(version, name)
else:
- return self._write_op.replace("$name", str(name)).replace("$version", version.of_version)
+ return _write_op.replace("$name", str(name)).replace("$version", version.of_version)
-hello_elem_list = JType("List<OFHelloElement>",
- read_op = 'ChannelUtils.readHelloElementList(bb)',
- write_op = 'ChannelUtils.writeHelloElementList(bb)'
- )
-u8 = JType('byte', size=1, read_op='bb.readByte()',
- write_op='bb.writeByte($name)')
-u8_list = JType('List<U8>', size=1, read_op='bb.readByte()',
- write_op='bb.writeByte($name)')
-u16 = JType('int', 'int', size=2, read_op='U16.f(bb.readShort())',
- write_op='bb.writeShort(U16.t($name))')
-u32 = JType('int', 'int', size=4, read_op='bb.readInt()',
- write_op='bb.writeInt($name)')
-u32_list = JType('List<U32>', 'int[]', size=4, read_op='bb.readInt()',
- write_op='bb.writeInt($name)')
-u64 = JType('U64', 'U64', size=8, read_op='U64.of(bb.readLong())',
- write_op='bb.writeLong($name.getValue())')
-of_port= JType('OFPort',size=None,
- read_op=lambda version: 'OFPort.ofShort(bb.readShort())' if version.int_version < 2 else 'OFPort.ofInt(bb.readInt())',
- write_op=lambda version, name: 'bb.writeShort(%s.getShortPortNumber())' % name if version.int_version < 2 else 'bb.writeInt(%s.getPortNumber())' % name)
-one_byte_array = JType('byte[]', size=1,
- read_op = 'ChannelUtils.readBytes(bb, 1)',
- write_op = 'ChannelUtils.writeBytes(bb, $name)')
-two_byte_array = JType('byte[]', size=2,
- read_op = 'ChannelUtils.readBytes(bb, 2)',
- write_op = 'ChannelUtils.writeBytes(bb, $name)')
-three_byte_array = JType('byte[]', size=3,
- read_op = 'ChannelUtils.readBytes(bb, 3)',
- write_op = 'ChannelUtils.writeBytes(bb, $name)')
-four_byte_array = JType('byte[]', size=4,
- read_op = 'ChannelUtils.readBytes(bb, 4)',
- write_op = 'ChannelUtils.writeBytes(bb, $name)')
-five_byte_array = JType('byte[]', size=5,
- read_op = 'ChannelUtils.readBytes(bb, 5)',
- write_op = 'ChannelUtils.writeBytes(bb, $name)')
-six_byte_array = JType('byte[]', size=6,
- read_op = 'ChannelUtils.readBytes(bb, 6)',
- write_op = 'ChannelUtils.writeBytes(bb, $name)')
-seven_byte_array = JType('byte[]', size=7,
- read_op = 'ChannelUtils.readBytes(bb, 7)',
- write_op = 'ChannelUtils.writeBytes(bb, $name)')
-actions_list = JType('List<OFAction>', size='ChannelUtils.calcListSize($name)',
- read_op = 'ChannelUtils.readActionsList(bb, $length)',
- write_op = 'ChannelUtils.writeActionsList(bb, $name);')
-instructions_list = JType('List<OFInstruction>', size='ChannelUtils.calcListSize($name)',
- read_op = 'ChannelUtils.readInstructionsList(bb, $length)',
- write_op = 'ChannelUtils.writeList(bb, $name)')
-buckets_list = JType('List<OFBucket>', size='ChannelUtils.calcListSize($name)',
- read_op = 'ChannelUtils.readBucketList(bb, $length)',
- write_op = 'ChannelUtils.writeList(bb, $name)')
-port_desc_list = JType('List<OFPhysicalPort>', size='ChannelUtils.calcListSize($name)',
- read_op = 'ChannelUtils.readPhysicalPortList(bb, $length)',
- write_op = 'ChannelUtils.writeList(bb, $name)')
-port_desc = JType('OFPortDesc', size='$name.getLength()',
- read_op = 'null; // TODO OFPortDescVer$version.READER.read(bb)',
- write_op = '$name.writeTo(bb)')
-packet_queue_list = JType('List<OFPacketQueue>', size='ChannelUtils.calcListSize($name)',
- read_op = 'ChannelUtils.readPacketQueueList(bb, $length)',
- write_op = 'ChannelUtils.writeList(bb, $name)')
-octets = JType('byte[]', size="$length",
- read_op = 'ChannelUtils.readBytes(bb, $length)',
- write_op = 'bb.writeBytes($name)')
-of_match = JType('Match', size="$name.getLength()",
- read_op = 'ChannelUtils.readOFMatch(bb)',
- write_op = 'ChannelUtils.writeOFMatch(bb, $name)')
-flow_mod_cmd = JType('OFFlowModCommand', 'short', size="$name.getLength()",
- read_op = lambda v: "bb.readShort()" if v.int_version == 1 else "bb.readByte()",
- write_op = lambda v, name: "bb.writeShort(%s)" % name if v.int_version == 1 else "bb.writeByte(%s)" % name)
-mac_addr = JType('MacAddress', 'byte[]', size=6,
- read_op = 'MacAddress.readFrom(bb)',
- write_op = '$name.writeTo(bb)')
-port_name = JType('String', size=16,
- read_op = 'ChannelUtils.readFixedLengthString(bb, 16)',
- write_op = 'ChannelUtils.writeFixedLengthString(bb, $name, 16)')
-desc_str = JType('String', size=256,
- read_op = 'ChannelUtils.readFixedLengthString(bb, 256)',
- write_op = 'ChannelUtils.writeFixedLengthString(bb, $name, 256)')
-serial_num = JType('String', size=32,
- read_op = 'ChannelUtils.readFixedLengthString(bb, 32)',
- write_op = 'ChannelUtils.writeFixedLengthString(bb, $name, 32)')
-table_name = JType('String', size=32,
- read_op = 'ChannelUtils.readFixedLengthString(bb, 32)',
- write_op = 'ChannelUtils.writeFixedLengthString(bb, $name, 32)')
-ipv4 = JType("IPv4",
- read_op = "IPv4.readFrom(bb)",
- write_op = "$name.writeTo(bb)")
-ipv6 = JType("IPv6",
- read_op = "IPv6.readFrom(bb)",
- write_op = "$name.writeTo(bb)")
+hello_elem_list = JType("List<OFHelloElement>") \
+ .op(read='ChannelUtils.readHelloElementList(bb)', write='ChannelUtils.writeHelloElementList(bb)')
+u8 = JType('byte', size=1) \
+ .op(read='bb.readByte()', write='bb.writeByte($name)')
+u8_list = JType('List<U8>', size=1) \
+ .op(read='bb.readByte()', write='bb.writeByte($name)')
+u16 = JType('int', 'int', size=2) \
+ .op(read='U16.f(bb.readShort())', write='bb.writeShort(U16.t($name))')
+u32 = JType('int', 'int', size=4) \
+ .op(read='bb.readInt()', write='bb.writeInt($name)')
+u32_list = JType('List<U32>', 'int[]', size=4) \
+ .op(read='bb.readInt()', write='bb.writeInt($name)')
+u64 = JType('U64', 'U64', size=8) \
+ .op(read='U64.of(bb.readLong())', write='bb.writeLong($name.getValue())')
+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)")
+one_byte_array = JType('byte[]', size=1) \
+ .op(read='ChannelUtils.readBytes(bb, 1)', write='ChannelUtils.writeBytes(bb, $name)')
+two_byte_array = JType('byte[]', size=2) \
+ .op(read='ChannelUtils.readBytes(bb, 2)', write='ChannelUtils.writeBytes(bb, $name)')
+three_byte_array = JType('byte[]', size=3) \
+ .op(read='ChannelUtils.readBytes(bb, 3)', write='ChannelUtils.writeBytes(bb, $name)')
+four_byte_array = JType('byte[]', size=4) \
+ .op(read='ChannelUtils.readBytes(bb, 4)', write='ChannelUtils.writeBytes(bb, $name)')
+five_byte_array = JType('byte[]', size=5) \
+ .op(read='ChannelUtils.readBytes(bb, 5)', write='ChannelUtils.writeBytes(bb, $name)')
+six_byte_array = JType('byte[]', size=6) \
+ .op(read='ChannelUtils.readBytes(bb, 6)', write='ChannelUtils.writeBytes(bb, $name)')
+seven_byte_array = JType('byte[]', size=7) \
+ .op(read='ChannelUtils.readBytes(bb, 7)', write='ChannelUtils.writeBytes(bb, $name)')
+actions_list = JType('List<OFAction>', size='ChannelUtils.calcListSize($name)') \
+ .op(read='ChannelUtils.readActionsList(bb, $length)', write='ChannelUtils.writeActionsList(bb, $name);')
+instructions_list = JType('List<OFInstruction>', size='ChannelUtils.calcListSize($name)') \
+ .op(read='ChannelUtils.readInstructionsList(bb, $length)', \
+ write='ChannelUtils.writeList(bb, $name)')
+buckets_list = JType('List<OFBucket>', size='ChannelUtils.calcListSize($name)') \
+ .op(read='ChannelUtils.readBucketList(bb, $length)', \
+ write='ChannelUtils.writeList(bb, $name)')
+port_desc_list = JType('List<OFPhysicalPort>', size='ChannelUtils.calcListSize($name)') \
+ .op(read='ChannelUtils.readPhysicalPortList(bb, $length)', \
+ write='ChannelUtils.writeList(bb, $name)')
+port_desc = JType('OFPortDesc', size='$name.getLength()') \
+ .op(read='null; // TODO OFPortDescVer$version.READER.read(bb)', \
+ write='$name.writeTo(bb)')
+packet_queue_list = JType('List<OFPacketQueue>', size='ChannelUtils.calcListSize($name)') \
+ .op(read='ChannelUtils.readPacketQueueList(bb, $length)', \
+ write='ChannelUtils.writeList(bb, $name)')
+octets = JType('byte[]', size="$length") \
+ .op(read='ChannelUtils.readBytes(bb, $length)', \
+ write='bb.writeBytes($name)')
+of_match = JType('Match', size="$name.getLength()") \
+ .op(read='ChannelUtils.readOFMatch(bb)', \
+ write='ChannelUtils.writeOFMatch(bb, $name)')
+flow_mod_cmd = JType('OFFlowModCommand', 'short', size="$name.getLength()") \
+ .op(version=1, read="bb.readShort()", write="bb.writeShort($name)") \
+ .op(version=ANY, read="bb.readByte()", write="bb.writeByte($name)")
+mac_addr = JType('MacAddress', 'byte[]', size=6) \
+ .op(read="MacAddress.read6Bytes(bb)", \
+ write="$name.write6Bytes(bb)")
+port_name = JType('String', size=16) \
+ .op(read='ChannelUtils.readFixedLengthString(bb, 16)', \
+ write='ChannelUtils.writeFixedLengthString(bb, $name, 16)')
+desc_str = JType('String', size=256) \
+ .op(read='ChannelUtils.readFixedLengthString(bb, 256)', \
+ write='ChannelUtils.writeFixedLengthString(bb, $name, 256)')
+serial_num = JType('String', size=32) \
+ .op(read='ChannelUtils.readFixedLengthString(bb, 32)', \
+ write='ChannelUtils.writeFixedLengthString(bb, $name, 32)')
+table_name = JType('String', size=32) \
+ .op(read='ChannelUtils.readFixedLengthString(bb, 32)', \
+ write='ChannelUtils.writeFixedLengthString(bb, $name, 32)')
+ipv4 = JType("IPv4") \
+ .op(read="IPv4.read4Bytes(bb)", \
+ write="$name.write4Bytes(bb)")
+ipv6 = JType("IPv6") \
+ .op(read="IPv6.read16Bytes(bb)", \
+ write="$name.write16Bytes(bb)")
default_mtype_to_jtype_convert_map = {
'uint8_t' : u8,
@@ -201,10 +225,9 @@
raise Exception("Not a recgonized standard list type declaration: %s" % c_type)
base_name = m.group(1)
java_base_name = name_c_to_caps_camel(base_name)
- return JType("List<OF%s>" % java_base_name,
- read_op = 'ChannelUtils.read%sList(bb)' % java_base_name,
- write_op = 'ChannelUtils.write%sList(bb, $name)' % java_base_name
- )
+ return JType("List<OF%s>" % java_base_name) \
+ .op(read='ChannelUtils.read%sList(bb)' % java_base_name, \
+ write='ChannelUtils.write%sList(bb, $name)' % java_base_name)
def convert_to_jtype(obj_name, field_name, c_type):
""" Convert from a C type ("uint_32") to a java type ("U32")
@@ -212,14 +235,14 @@
if obj_name in exceptions and field_name in exceptions[obj_name]:
return exceptions[obj_name][field_name]
elif field_name == "type" and c_type == "uint8_t":
- return JType("OFType", 'byte', size=1, read_op='bb.readByte()',
- write_op='bb.writeByte($name)')
+ return JType("OFType", 'byte', size=1) \
+ .op(read='bb.readByte()', write='bb.writeByte($name)')
elif field_name == "type" and re.match(r'of_action.*', obj_name):
- return JType("OFActionType", 'short', size=2, read_op='bb.readShort()',
- write_op='bb.writeShort($name)')
+ return JType("OFActionType", 'short', size=2) \
+ .op(read='bb.readShort()', write='bb.writeShort($name)')
elif field_name == "version" and c_type == "uint8_t":
- return JType("OFVersion", 'byte', size=1, read_op='bb.readByte()',
- write_op='bb.writeByte($name)')
+ return JType("OFVersion", 'byte', size=1) \
+ .op(read='bb.readByte()', write='bb.writeByte($name)')
elif c_type in default_mtype_to_jtype_convert_map:
return default_mtype_to_jtype_convert_map[c_type]
elif re.match(r'list\(of_([a-zA-Z_]+)_t\)', c_type):
diff --git a/java_gen/pre-written/src/main/java/org/openflow/protocol/match/Match.java b/java_gen/pre-written/src/main/java/org/openflow/protocol/match/Match.java
index 5c1e7b5..fa42737 100644
--- a/java_gen/pre-written/src/main/java/org/openflow/protocol/match/Match.java
+++ b/java_gen/pre-written/src/main/java/org/openflow/protocol/match/Match.java
@@ -1,21 +1,20 @@
package org.openflow.protocol.match;
import org.openflow.protocol.OFObject;
+import org.openflow.types.OFValueType;
public interface Match extends OFObject {
- public <F> F get(MatchField<F, ?> match);
+ public <F extends OFValueType> F get(MatchField<F> match);
- public <M> M getMasked(MatchField<?, M> match);
+ public boolean supports(MatchField<?> field);
- public boolean supports(MatchField<?, ?> field);
+ public boolean supportsMasked(MatchField<?> field);
- public boolean supportsMasked(MatchField<?, ?> field);
+ public boolean isExact(MatchField<?> field);
- public boolean isExact(MatchField<?, ?> field);
+ public boolean isFullyWildcarded(MatchField<?> field);
- public boolean isFullyWildcarded(MatchField<?, ?> field);
-
- public boolean isPartiallyMasked(MatchField<?, ?> field);
+ public boolean isPartiallyMasked(MatchField<?> field);
public MatchBuilder getBuilder();
}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/protocol/match/MatchBuilder.java b/java_gen/pre-written/src/main/java/org/openflow/protocol/match/MatchBuilder.java
index 7a5e57c..3c601f8 100644
--- a/java_gen/pre-written/src/main/java/org/openflow/protocol/match/MatchBuilder.java
+++ b/java_gen/pre-written/src/main/java/org/openflow/protocol/match/MatchBuilder.java
@@ -1,9 +1,11 @@
package org.openflow.protocol.match;
-public interface MatchBuilder extends Match {
- public <F> MatchBuilder set(MatchField<F, ?> match, F value);
+import org.openflow.types.OFValueType;
- public <M> void setMasked(MatchField<?, M> match, M value);
+public interface MatchBuilder extends Match {
+ public <F extends OFValueType> MatchBuilder set(MatchField<F> match, F value);
+
+ //public <M> void setMasked(MatchField<?, M> match, M value);
public Match getMatch();
}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/protocol/match/MatchBuilderVer10.java b/java_gen/pre-written/src/main/java/org/openflow/protocol/match/MatchBuilderVer10.java
index f00e1b4..0fbe84b 100644
--- a/java_gen/pre-written/src/main/java/org/openflow/protocol/match/MatchBuilderVer10.java
+++ b/java_gen/pre-written/src/main/java/org/openflow/protocol/match/MatchBuilderVer10.java
@@ -1,12 +1,13 @@
package org.openflow.protocol.match;
import org.jboss.netty.buffer.ChannelBuffer;
-import org.openflow.protocol.types.IpDscp;
import org.openflow.types.EthType;
import org.openflow.types.IPv4;
+import org.openflow.types.IpDscp;
import org.openflow.types.IpProtocol;
import org.openflow.types.MacAddress;
import org.openflow.types.OFPort;
+import org.openflow.types.OFValueType;
import org.openflow.types.U16;
import org.openflow.types.VlanPcp;
import org.openflow.types.VlanVid;
@@ -65,7 +66,7 @@
@SuppressWarnings("unchecked")
@Override
- public <F> F get(final MatchField<F, ?> match) {
+ public <F extends OFValueType> F get(final MatchField<F> match) {
switch (match.id) {
case 0:
return (F) inputPort;
@@ -78,7 +79,7 @@
@SuppressWarnings("unchecked")
@Override
- public <F> MatchBuilder set(final MatchField<F, ?> match, final F value) {
+ public <F extends OFValueType> MatchBuilder set(final MatchField<F> match, final F value) {
switch (match.id) {
case 0:
inputPort = (OFPort) value;
@@ -107,37 +108,31 @@
}
@Override
- public <M> M getMasked(final MatchField<?, M> match) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public boolean supports(final MatchField<?, ?> field) {
+ public boolean supports(final MatchField<?> field) {
// TODO Auto-generated method stub
return false;
}
@Override
- public boolean supportsMasked(final MatchField<?, ?> field) {
+ public boolean supportsMasked(final MatchField<?> field) {
// TODO Auto-generated method stub
return false;
}
@Override
- public boolean isExact(final MatchField<?, ?> field) {
+ public boolean isExact(final MatchField<?> field) {
// TODO Auto-generated method stub
return false;
}
@Override
- public boolean isFullyWildcarded(final MatchField<?, ?> field) {
+ public boolean isFullyWildcarded(final MatchField<?> field) {
// TODO Auto-generated method stub
return false;
}
@Override
- public boolean isPartiallyMasked(final MatchField<?, ?> field) {
+ public boolean isPartiallyMasked(final MatchField<?> field) {
// TODO Auto-generated method stub
return false;
}
@@ -159,13 +154,13 @@
// TODO Auto-generated method stub
}
-
+/*
@Override
public <M> void setMasked(final MatchField<?, M> match, final M value) {
// TODO Auto-generated method stub
}
-
+*/
@Override
public Match getMatch() {
// TODO Auto-generated method stub
diff --git a/java_gen/pre-written/src/main/java/org/openflow/protocol/match/MatchField.java b/java_gen/pre-written/src/main/java/org/openflow/protocol/match/MatchField.java
index b6e8317..d9d68ec 100644
--- a/java_gen/pre-written/src/main/java/org/openflow/protocol/match/MatchField.java
+++ b/java_gen/pre-written/src/main/java/org/openflow/protocol/match/MatchField.java
@@ -1,21 +1,24 @@
package org.openflow.protocol.match;
+import org.openflow.types.ArpOpcode;
import org.openflow.types.EthType;
-import org.openflow.types.IPv4;
+import org.openflow.types.ICMPv4Code;
+import org.openflow.types.ICMPv4Type;
import org.openflow.types.IPv4WithMask;
-import org.openflow.types.IPv6;
+import org.openflow.types.IPv6FlowLabel;
import org.openflow.types.IPv6WithMask;
+import org.openflow.types.IpDscp;
+import org.openflow.types.IpEcn;
import org.openflow.types.IpProtocol;
import org.openflow.types.MacAddress;
-import org.openflow.types.MacAddressWithMask;
+import org.openflow.types.Masked;
import org.openflow.types.OFPort;
-import org.openflow.types.U16;
-import org.openflow.types.U8;
+import org.openflow.types.OFValueType;
+import org.openflow.types.TransportPort;
import org.openflow.types.VlanPcp;
import org.openflow.types.VlanVid;
-import org.openflow.types.VlanVidWithMask.VlanVidWithMask;
-public class MatchField<F, M> {
+public class MatchField<F extends OFValueType> {
private final String name;
public final int id;
@@ -29,75 +32,77 @@
this.id = id;
}
- public final static MatchField<OFPort, NoMatch> IN_PORT =
- new MatchField<OFPort, NoMatch>("in_port", 0);
- public final static MatchField<OFPort, NoMatch> IN_PHY_PORT =
- new MatchField<OFPort, NoMatch>("in_phy_port");
- public final static MatchField<OFPort, NoMatch> METADATA =
- new MatchField<OFPort, NoMatch>("metadata");
+ public final static MatchField<OFPort> IN_PORT =
+ new MatchField<OFPort>("in_port", 0);
+ public final static MatchField<OFPort> IN_PHY_PORT =
+ new MatchField<OFPort>("in_phy_port");
+ public final static MatchField<OFPort> METADATA =
+ new MatchField<OFPort>("metadata");
- public final static MatchField<MacAddress, MacAddressWithMask> ETH_DST =
- new MatchField<MacAddress, MacAddressWithMask>("eth_dst");
- public final static MatchField<MacAddress, MacAddressWithMask> ETH_SRC =
- new MatchField<MacAddress, MacAddressWithMask>("eth_src", 1);
+ public final static MatchField<Masked<MacAddress>> ETH_DST =
+ new MatchField<Masked<MacAddress>>("eth_dst");
+ public final static MatchField<Masked<MacAddress>> ETH_SRC =
+ new MatchField<Masked<MacAddress>>("eth_src", 1);
- public final static MatchField<EthType, NoMatch> ETH_TYPE =
- new MatchField<EthType, NoMatch>("eth_type");
- public final static MatchField<VlanVid, VlanVidWithMask> VLAN_VID =
- new MatchField<VlanVid, VlanVidWithMask>("vlan_vid");
- public final static MatchField<VlanPcp, NoMatch> VLAN_PCP =
- new MatchField<VlanPcp, NoMatch>("vlan_pcp");
+ public final static MatchField<EthType> ETH_TYPE =
+ new MatchField<EthType>("eth_type");
+
+ public final static MatchField<Masked<VlanVid>> VLAN_VID =
+ new MatchField<Masked<VlanVid>>("vlan_vid");
+ public final static MatchField<VlanPcp> VLAN_PCP =
+ new MatchField<VlanPcp>("vlan_pcp");
+
+
+ public final static MatchField<IpDscp> IP_DSCP =
+ new MatchField<IpDscp>("ip_dscp");
+ public final static MatchField<IpEcn> IP_ECN =
+ new MatchField<IpEcn>("ip_dscp");
+ public final static MatchField<IpProtocol> IP_PROTO =
+ new MatchField<IpProtocol>("ip_proto");
- public final static MatchField<NoMatch, NoMatch> IP_DSCP =
- new MatchField<NoMatch, NoMatch>("ip_dscp");
- public final static MatchField<NoMatch, NoMatch> IP_ECN =
- new MatchField<NoMatch, NoMatch>("ip_dscp");
- public final static MatchField<IpProtocol, NoMatch> IP_PROTO =
- new MatchField<IpProtocol, NoMatch>("ip_proto");
+ public final static MatchField<IPv4WithMask> IPV4_SRC =
+ new MatchField<IPv4WithMask>("ipv4_src");
+ public final static MatchField<IPv4WithMask> IPV4_DST =
+ new MatchField<IPv4WithMask>("ipv4_dst");
- public final static MatchField<IPv4, IPv4WithMask> IPV4_SRC =
- new MatchField<IPv4, IPv4WithMask>("ipv4_src");
- public final static MatchField<IPv4, IPv4WithMask> IPV4_DST =
- new MatchField<IPv4, IPv4WithMask>("ipv4_dst");
-
- public final static MatchField<U16, NoMatch> TCP_SRC = new MatchField<U16, NoMatch>(
+ public final static MatchField<TransportPort> TCP_SRC = new MatchField<TransportPort>(
"tcp_src");
- public final static MatchField<U16, NoMatch> TCP_DST = new MatchField<U16, NoMatch>(
+ public final static MatchField<TransportPort> TCP_DST = new MatchField<TransportPort>(
"tcp_dst");
- public final static MatchField<U16, NoMatch> UDP_SRC = new MatchField<U16, NoMatch>(
+ public final static MatchField<TransportPort> UDP_SRC = new MatchField<TransportPort>(
"udp_src");
- public final static MatchField<U16, NoMatch> UDP_DST = new MatchField<U16, NoMatch>(
+ public final static MatchField<TransportPort> UDP_DST = new MatchField<TransportPort>(
"udp_dst");
- public final static MatchField<U16, NoMatch> SCTP_SRC = new MatchField<U16, NoMatch>(
+ public final static MatchField<TransportPort> SCTP_SRC = new MatchField<TransportPort>(
"sctp_src");
- public final static MatchField<U16, NoMatch> SCTP_DST = new MatchField<U16, NoMatch>(
+ public final static MatchField<TransportPort> SCTP_DST = new MatchField<TransportPort>(
"sctp_dst");
- public final static MatchField<U8, NoMatch> ICMPV4_TYPE = new MatchField<U8, NoMatch>(
+ public final static MatchField<ICMPv4Type> ICMPV4_TYPE = new MatchField<ICMPv4Type>(
"icmpv4_src");
- public final static MatchField<U8, NoMatch> ICMPV4_CODE = new MatchField<U8, NoMatch>(
+ public final static MatchField<ICMPv4Code> ICMPV4_CODE = new MatchField<ICMPv4Code>(
"icmpv4_dst");
- public final static MatchField<U16, NoMatch> ARP_OP = new MatchField<U16, NoMatch>(
+ public final static MatchField<ArpOpcode> ARP_OP = new MatchField<ArpOpcode>(
"arp_op");
- public final static MatchField<IPv4, IPv4WithMask> ARP_SPA =
- new MatchField<IPv4, IPv4WithMask>("arp_spa");
- public final static MatchField<IPv4, IPv4WithMask> ARP_TPA =
- new MatchField<IPv4, IPv4WithMask>("arp_tpa");
- public final static MatchField<MacAddress, MacAddressWithMask> ARP_SHA =
- new MatchField<MacAddress, MacAddressWithMask>("arp_sha");
- public final static MatchField<MacAddress, MacAddressWithMask> ARP_THA =
- new MatchField<MacAddress, MacAddressWithMask>("arp_tha");
+ public final static MatchField<IPv4WithMask> ARP_SPA =
+ new MatchField<IPv4WithMask>("arp_spa");
+ public final static MatchField<IPv4WithMask> ARP_TPA =
+ new MatchField<IPv4WithMask>("arp_tpa");
+ public final static MatchField<Masked<MacAddress>> ARP_SHA =
+ new MatchField<Masked<MacAddress>>("arp_sha");
+ public final static MatchField<Masked<MacAddress>> ARP_THA =
+ new MatchField<Masked<MacAddress>>("arp_tha");
- public final static MatchField<IPv6, IPv6WithMask> IPV6_SRC =
- new MatchField<IPv6, IPv6WithMask>("ipv6_src");
- public final static MatchField<IPv6, IPv6WithMask> IPV6_DST =
- new MatchField<IPv6, IPv6WithMask>("ipv6_dst");
+ public final static MatchField<IPv6WithMask> IPV6_SRC =
+ new MatchField<IPv6WithMask>("ipv6_src");
+ public final static MatchField<IPv6WithMask> IPV6_DST =
+ new MatchField<IPv6WithMask>("ipv6_dst");
- public final static MatchField<U8, IPv6WithMask> IPV6_FLABEL =
- new MatchField<U8, IPv6WithMask>("ipv6_flabel");
+ public final static MatchField<Masked<IPv6FlowLabel>> IPV6_FLABEL =
+ new MatchField<Masked<IPv6FlowLabel>>("ipv6_flabel");
public String getName() {
return name;
diff --git a/java_gen/pre-written/src/main/java/org/openflow/protocol/match/NoMatch.java b/java_gen/pre-written/src/main/java/org/openflow/protocol/match/NoMatch.java
deleted file mode 100644
index b314a59..0000000
--- a/java_gen/pre-written/src/main/java/org/openflow/protocol/match/NoMatch.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.openflow.protocol.match;
-
-public class NoMatch {
-
-}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/protocol/types/IpDscp.java b/java_gen/pre-written/src/main/java/org/openflow/protocol/types/IpDscp.java
deleted file mode 100644
index dcc242a..0000000
--- a/java_gen/pre-written/src/main/java/org/openflow/protocol/types/IpDscp.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.openflow.protocol.types;
-
-public class IpDscp {
-
-}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/types/ArpOpcode.java b/java_gen/pre-written/src/main/java/org/openflow/types/ArpOpcode.java
new file mode 100644
index 0000000..852aa20
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/openflow/types/ArpOpcode.java
@@ -0,0 +1,145 @@
+package org.openflow.types;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public class ArpOpcode implements OFValueType {
+
+ final static int LENGTH = 2;
+
+ private static final int ARP_OPCODE_VAL_REQUEST = 1;
+ private static final int ARP_OPCODE_VAL_REPLY = 2;
+ private static final int ARP_OPCODE_VAL_REQUEST_REVERSE = 3;
+ private static final int ARP_OPCODE_VAL_REPLY_REVERSE = 4;
+ private static final int ARP_OPCODE_VAL_DRARP_REQUEST = 5;
+ private static final int ARP_OPCODE_VAL_DRARP_REPLY = 6;
+ private static final int ARP_OPCODE_VAL_DRARP_ERROR = 7;
+ private static final int ARP_OPCODE_VAL_INARP_REQUEST = 8;
+ private static final int ARP_OPCODE_VAL_INARP_REPLY = 9;
+ private static final int ARP_OPCODE_VAL_ARP_NAK = 10;
+ private static final int ARP_OPCODE_VAL_MARS_REQUEST = 11;
+ private static final int ARP_OPCODE_VAL_MARS_MULTI = 12;
+ private static final int ARP_OPCODE_VAL_MARS_MSERV = 13;
+ private static final int ARP_OPCODE_VAL_MARS_JOIN = 14;
+ private static final int ARP_OPCODE_VAL_MARS_LEAVE = 15;
+ private static final int ARP_OPCODE_VAL_MARS_NAK = 16;
+ private static final int ARP_OPCODE_VAL_MARS_UNSERV = 17;
+ private static final int ARP_OPCODE_VAL_MARS_SJOIN = 18;
+ private static final int ARP_OPCODE_VAL_MARS_SLEAVE = 19;
+ private static final int ARP_OPCODE_VAL_MARS_GROUPLIST_REQUEST = 20;
+ private static final int ARP_OPCODE_VAL_MARS_GROUPLIST_REPLY = 21;
+ private static final int ARP_OPCODE_VAL_MARS_REDIRECT_MAP = 22;
+ private static final int ARP_OPCODE_VAL_MAPOS_UNARP = 23;
+ private static final int ARP_OPCODE_VAL_OP_EXP1 = 24;
+ private static final int ARP_OPCODE_VAL_OP_EXP2 = 25;
+
+ public static ArpOpcode ARP_OPCODE_REQUEST = new ArpOpcode(ARP_OPCODE_VAL_REQUEST);
+ public static ArpOpcode ARP_OPCODE_REPLY = new ArpOpcode(ARP_OPCODE_VAL_REPLY);
+ public static ArpOpcode ARP_OPCODE_REQUEST_REVERSE = new ArpOpcode(ARP_OPCODE_VAL_REQUEST_REVERSE);
+ public static ArpOpcode ARP_OPCODE_REPLY_REVERSE = new ArpOpcode(ARP_OPCODE_VAL_REPLY_REVERSE);
+ public static ArpOpcode ARP_OPCODE_DRARP_REQUEST = new ArpOpcode(ARP_OPCODE_VAL_DRARP_REQUEST);
+ public static ArpOpcode ARP_OPCODE_DRARP_REPLY = new ArpOpcode(ARP_OPCODE_VAL_DRARP_REPLY);
+ public static ArpOpcode ARP_OPCODE_DRARP_ERROR = new ArpOpcode(ARP_OPCODE_VAL_DRARP_ERROR);
+ public static ArpOpcode ARP_OPCODE_INARP_REQUEST = new ArpOpcode(ARP_OPCODE_VAL_INARP_REQUEST);
+ public static ArpOpcode ARP_OPCODE_INARP_REPLY = new ArpOpcode(ARP_OPCODE_VAL_INARP_REPLY);
+ public static ArpOpcode ARP_OPCODE_ARP_NAK = new ArpOpcode(ARP_OPCODE_VAL_ARP_NAK);
+ public static ArpOpcode ARP_OPCODE_MARS_REQUEST = new ArpOpcode(ARP_OPCODE_VAL_MARS_REQUEST);
+ public static ArpOpcode ARP_OPCODE_MARS_MULTI = new ArpOpcode(ARP_OPCODE_VAL_MARS_MULTI);
+ public static ArpOpcode ARP_OPCODE_MARS_MSERV = new ArpOpcode(ARP_OPCODE_VAL_MARS_MSERV);
+ public static ArpOpcode ARP_OPCODE_MARS_JOIN = new ArpOpcode(ARP_OPCODE_VAL_MARS_JOIN);
+ public static ArpOpcode ARP_OPCODE_MARS_LEAVE = new ArpOpcode(ARP_OPCODE_VAL_MARS_LEAVE);
+ public static ArpOpcode ARP_OPCODE_MARS_NAK = new ArpOpcode(ARP_OPCODE_VAL_MARS_NAK);
+ public static ArpOpcode ARP_OPCODE_MARS_UNSERV = new ArpOpcode(ARP_OPCODE_VAL_MARS_UNSERV);
+ public static ArpOpcode ARP_OPCODE_MARS_SJOIN = new ArpOpcode(ARP_OPCODE_VAL_MARS_SJOIN);
+ public static ArpOpcode ARP_OPCODE_MARS_SLEAVE = new ArpOpcode(ARP_OPCODE_VAL_MARS_SLEAVE);
+ public static ArpOpcode ARP_OPCODE_MARS_GROUPLIST_REQUEST = new ArpOpcode(ARP_OPCODE_VAL_MARS_GROUPLIST_REQUEST);
+ public static ArpOpcode ARP_OPCODE_MARS_GROUPLIST_REPLY = new ArpOpcode(ARP_OPCODE_VAL_MARS_GROUPLIST_REPLY);
+ public static ArpOpcode ARP_OPCODE_MARS_REDIRECT_MAP = new ArpOpcode(ARP_OPCODE_VAL_MARS_REDIRECT_MAP);
+ public static ArpOpcode ARP_OPCODE_MAPOS_UNARP = new ArpOpcode(ARP_OPCODE_VAL_MAPOS_UNARP);
+ public static ArpOpcode ARP_OPCODE_OP_EXP1 = new ArpOpcode(ARP_OPCODE_VAL_OP_EXP1);
+ public static ArpOpcode ARP_OPCODE_OP_EXP2 = new ArpOpcode(ARP_OPCODE_VAL_OP_EXP2);
+
+ private static final int MIN_OPCODE = 0;
+ private static final int MAX_OPCODE = 0xFFFF;
+
+ private final int opcode;
+
+ private ArpOpcode(int opcode) {
+ this.opcode = opcode;
+ }
+
+ @Override
+ public int getLength() {
+ return LENGTH;
+ }
+
+ public int getOpcode() {
+ return this.opcode;
+ }
+
+ public static ArpOpcode of(int opcode) {
+ if (opcode < MIN_OPCODE || opcode > MAX_OPCODE)
+ throw new IllegalArgumentException("Invalid ARP opcode: " + opcode);
+ switch (opcode) {
+ case ARP_OPCODE_VAL_REQUEST:
+ return ARP_OPCODE_REQUEST;
+ case ARP_OPCODE_VAL_REPLY:
+ return ARP_OPCODE_REPLY;
+ case ARP_OPCODE_VAL_REQUEST_REVERSE:
+ return ARP_OPCODE_REQUEST_REVERSE;
+ case ARP_OPCODE_VAL_REPLY_REVERSE:
+ return ARP_OPCODE_REPLY_REVERSE;
+ case ARP_OPCODE_VAL_DRARP_REQUEST:
+ return ARP_OPCODE_DRARP_REQUEST;
+ case ARP_OPCODE_VAL_DRARP_REPLY:
+ return ARP_OPCODE_DRARP_REPLY;
+ case ARP_OPCODE_VAL_DRARP_ERROR:
+ return ARP_OPCODE_DRARP_ERROR;
+ case ARP_OPCODE_VAL_INARP_REQUEST:
+ return ARP_OPCODE_INARP_REQUEST;
+ case ARP_OPCODE_VAL_INARP_REPLY:
+ return ARP_OPCODE_INARP_REPLY;
+ case ARP_OPCODE_VAL_ARP_NAK:
+ return ARP_OPCODE_ARP_NAK;
+ case ARP_OPCODE_VAL_MARS_REQUEST:
+ return ARP_OPCODE_MARS_REQUEST;
+ case ARP_OPCODE_VAL_MARS_MULTI:
+ return ARP_OPCODE_MARS_MULTI;
+ case ARP_OPCODE_VAL_MARS_MSERV:
+ return ARP_OPCODE_MARS_MSERV;
+ case ARP_OPCODE_VAL_MARS_JOIN:
+ return ARP_OPCODE_MARS_JOIN;
+ case ARP_OPCODE_VAL_MARS_LEAVE:
+ return ARP_OPCODE_MARS_LEAVE;
+ case ARP_OPCODE_VAL_MARS_NAK:
+ return ARP_OPCODE_MARS_NAK;
+ case ARP_OPCODE_VAL_MARS_UNSERV:
+ return ARP_OPCODE_MARS_UNSERV;
+ case ARP_OPCODE_VAL_MARS_SJOIN:
+ return ARP_OPCODE_MARS_SJOIN;
+ case ARP_OPCODE_VAL_MARS_SLEAVE:
+ return ARP_OPCODE_MARS_SLEAVE;
+ case ARP_OPCODE_VAL_MARS_GROUPLIST_REQUEST:
+ return ARP_OPCODE_MARS_GROUPLIST_REQUEST;
+ case ARP_OPCODE_VAL_MARS_GROUPLIST_REPLY:
+ return ARP_OPCODE_MARS_GROUPLIST_REPLY;
+ case ARP_OPCODE_VAL_MARS_REDIRECT_MAP:
+ return ARP_OPCODE_MARS_REDIRECT_MAP;
+ case ARP_OPCODE_VAL_MAPOS_UNARP:
+ return ARP_OPCODE_MAPOS_UNARP;
+ case ARP_OPCODE_VAL_OP_EXP1:
+ return ARP_OPCODE_OP_EXP1;
+ case ARP_OPCODE_VAL_OP_EXP2:
+ return ARP_OPCODE_OP_EXP2;
+ default:
+ return new ArpOpcode(opcode);
+ }
+ }
+
+ public void write2Bytes(ChannelBuffer c) {
+ c.writeShort(this.opcode);
+ }
+
+ public static ArpOpcode read2Bytes(ChannelBuffer c) {
+ return ArpOpcode.of(c.readUnsignedShort());
+ }
+}
\ No newline at end of file
diff --git a/java_gen/pre-written/src/main/java/org/openflow/types/EthType.java b/java_gen/pre-written/src/main/java/org/openflow/types/EthType.java
index d319e57..f0f0a2c 100644
--- a/java_gen/pre-written/src/main/java/org/openflow/types/EthType.java
+++ b/java_gen/pre-written/src/main/java/org/openflow/types/EthType.java
@@ -1,5 +1,238 @@
package org.openflow.types;
-public class EthType {
+import org.jboss.netty.buffer.ChannelBuffer;
+
+
+/**
+ * EtherType field representation.
+ *
+ * @author Yotam Harchol (yotam.harchol@bigswitch.com)
+ */
+public class EthType implements OFValueType {
+ static final int LENGTH = 2;
+
+ 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
+
+ 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 );
+
+ private EthType(int type) {
+ this.rawValue = type;
+ }
+
+ @Override
+ public int getLength() {
+ return LENGTH;
+ }
+
+ 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;
+ default:
+ // TODO: What's here?
+ return new EthType(type);
+ }
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof EthType))
+ return false;
+ EthType o = (EthType)obj;
+ if (o.rawValue != this.rawValue)
+ return false;
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 37;
+ int result = 1;
+ result = prime * result + rawValue;
+ return result;
+ }
+
+ @Override
+ 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());
+ }
}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/types/ICMPv4Code.java b/java_gen/pre-written/src/main/java/org/openflow/types/ICMPv4Code.java
new file mode 100644
index 0000000..147b5f7
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/openflow/types/ICMPv4Code.java
@@ -0,0 +1,44 @@
+package org.openflow.types;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+
+/**
+ *
+ * @author Yotam Harchol (yotam.harchol@bigswitch.com)
+ *
+ */
+public class ICMPv4Code implements OFValueType {
+
+ final static int LENGTH = 1;
+ final static short MAX_CODE = 0xFF;
+
+ private final short code;
+
+ private ICMPv4Code(short code) {
+ this.code = code;
+ }
+
+ public static ICMPv4Code of(short code) {
+ if (code > MAX_CODE || code < 0)
+ throw new IllegalArgumentException("Illegal ICMPv4 code: " + code);
+ return new ICMPv4Code(code);
+ }
+
+ @Override
+ 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());
+ }
+
+}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/types/ICMPv4Type.java b/java_gen/pre-written/src/main/java/org/openflow/types/ICMPv4Type.java
new file mode 100644
index 0000000..01d6e8f
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/openflow/types/ICMPv4Type.java
@@ -0,0 +1,158 @@
+package org.openflow.types;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public class ICMPv4Type implements OFValueType {
+
+ final static int LENGTH = 1;
+
+ private static final short ICMPV4_TYPE_VAL_ECHO_REPLY = 0;
+ private static final short ICMPV4_TYPE_VAL_DESTINATION_UNREACHABLE = 3;
+ private static final short ICMPV4_TYPE_VAL_SOURCE_QUENCH = 4;
+ private static final short ICMPV4_TYPE_VAL_REDIRECT = 5;
+ private static final short ICMPV4_TYPE_VAL_ALTERNATE_HOST_ADDRESS = 6;
+ private static final short ICMPV4_TYPE_VAL_ECHO = 8;
+ private static final short ICMPV4_TYPE_VAL_ROUTER_ADVERTISEMENT = 9;
+ private static final short ICMPV4_TYPE_VAL_ROUTER_SOLICITATION = 10;
+ private static final short ICMPV4_TYPE_VAL_TIME_EXCEEDED = 11;
+ private static final short ICMPV4_TYPE_VAL_PARAMETER_PROBLEM = 12;
+ private static final short ICMPV4_TYPE_VAL_TIMESTAMP = 13;
+ private static final short ICMPV4_TYPE_VAL_TIMESTAMP_REPLY = 14;
+ private static final short ICMPV4_TYPE_VAL_INFORMATION_REQUEST = 15;
+ private static final short ICMPV4_TYPE_VAL_INFORMATION_REPLY = 16;
+ private static final short ICMPV4_TYPE_VAL_ADDRESS_MASK_REQUEST = 17;
+ private static final short ICMPV4_TYPE_VAL_ADDRESS_MASK_REPLY = 18;
+ private static final short ICMPV4_TYPE_VAL_TRACEROUTE = 30;
+ private static final short ICMPV4_TYPE_VAL_DATAGRAM_CONVERSION_ERROR = 31;
+ private static final short ICMPV4_TYPE_VAL_MOBILE_HOST_REDIRECT = 32;
+ private static final short ICMPV4_TYPE_VAL_IPV6_WHERE_ARE_YOU = 33;
+ private static final short ICMPV4_TYPE_VAL_IPV6_I_AM_HERE = 34;
+ private static final short ICMPV4_TYPE_VAL_MOBILE_REGISTRATION_REQUEST = 35;
+ private static final short ICMPV4_TYPE_VAL_MOBILE_REGISTRATION_REPLY = 36;
+ private static final short ICMPV4_TYPE_VAL_DOMAIN_NAME_REQUEST = 37;
+ private static final short ICMPV4_TYPE_VAL_DOMAIN_NAME_REPLY = 38;
+ private static final short ICMPV4_TYPE_VAL_SKIP = 39;
+ private static final short ICMPV4_TYPE_VAL_PHOTURIS = 40;
+ private static final short ICMPV4_TYPE_VAL_EXPERIMENTAL_MOBILITY = 41;
+
+ public static final ICMPv4Type ICMPV4_TYPE_ECHO_REPLY = new ICMPv4Type(ICMPV4_TYPE_VAL_ECHO_REPLY);
+ public static final ICMPv4Type ICMPV4_TYPE_DESTINATION_UNREACHABLE = new ICMPv4Type(ICMPV4_TYPE_VAL_DESTINATION_UNREACHABLE);
+ public static final ICMPv4Type ICMPV4_TYPE_SOURCE_QUENCH = new ICMPv4Type(ICMPV4_TYPE_VAL_SOURCE_QUENCH);
+ public static final ICMPv4Type ICMPV4_TYPE_REDIRECT = new ICMPv4Type(ICMPV4_TYPE_VAL_REDIRECT);
+ public static final ICMPv4Type ICMPV4_TYPE_ALTERNATE_HOST_ADDRESS = new ICMPv4Type(ICMPV4_TYPE_VAL_ALTERNATE_HOST_ADDRESS);
+ public static final ICMPv4Type ICMPV4_TYPE_ECHO = new ICMPv4Type(ICMPV4_TYPE_VAL_ECHO);
+ public static final ICMPv4Type ICMPV4_TYPE_ROUTER_ADVERTISEMENT = new ICMPv4Type(ICMPV4_TYPE_VAL_ROUTER_ADVERTISEMENT);
+ public static final ICMPv4Type ICMPV4_TYPE_ROUTER_SOLICITATION = new ICMPv4Type(ICMPV4_TYPE_VAL_ROUTER_SOLICITATION);
+ public static final ICMPv4Type ICMPV4_TYPE_TIME_EXCEEDED = new ICMPv4Type(ICMPV4_TYPE_VAL_TIME_EXCEEDED);
+ public static final ICMPv4Type ICMPV4_TYPE_PARAMETER_PROBLEM = new ICMPv4Type(ICMPV4_TYPE_VAL_PARAMETER_PROBLEM);
+ public static final ICMPv4Type ICMPV4_TYPE_TIMESTAMP = new ICMPv4Type(ICMPV4_TYPE_VAL_TIMESTAMP);
+ public static final ICMPv4Type ICMPV4_TYPE_TIMESTAMP_REPLY = new ICMPv4Type(ICMPV4_TYPE_VAL_TIMESTAMP_REPLY);
+ public static final ICMPv4Type ICMPV4_TYPE_INFORMATION_REQUEST = new ICMPv4Type(ICMPV4_TYPE_VAL_INFORMATION_REQUEST);
+ public static final ICMPv4Type ICMPV4_TYPE_INFORMATION_REPLY = new ICMPv4Type(ICMPV4_TYPE_VAL_INFORMATION_REPLY);
+ public static final ICMPv4Type ICMPV4_TYPE_ADDRESS_MASK_REQUEST = new ICMPv4Type(ICMPV4_TYPE_VAL_ADDRESS_MASK_REQUEST);
+ public static final ICMPv4Type ICMPV4_TYPE_ADDRESS_MASK_REPLY = new ICMPv4Type(ICMPV4_TYPE_VAL_ADDRESS_MASK_REPLY);
+ public static final ICMPv4Type ICMPV4_TYPE_TRACEROUTE = new ICMPv4Type(ICMPV4_TYPE_VAL_TRACEROUTE);
+ public static final ICMPv4Type ICMPV4_TYPE_DATAGRAM_CONVERSION_ERROR = new ICMPv4Type(ICMPV4_TYPE_VAL_DATAGRAM_CONVERSION_ERROR);
+ public static final ICMPv4Type ICMPV4_TYPE_MOBILE_HOST_REDIRECT = new ICMPv4Type(ICMPV4_TYPE_VAL_MOBILE_HOST_REDIRECT);
+ public static final ICMPv4Type ICMPV4_TYPE_IPV6_WHERE_ARE_YOU = new ICMPv4Type(ICMPV4_TYPE_VAL_IPV6_WHERE_ARE_YOU);
+ public static final ICMPv4Type ICMPV4_TYPE_IPV6_I_AM_HERE = new ICMPv4Type(ICMPV4_TYPE_VAL_IPV6_I_AM_HERE);
+ public static final ICMPv4Type ICMPV4_TYPE_MOBILE_REGISTRATION_REQUEST = new ICMPv4Type(ICMPV4_TYPE_VAL_MOBILE_REGISTRATION_REQUEST);
+ public static final ICMPv4Type ICMPV4_TYPE_MOBILE_REGISTRATION_REPLY = new ICMPv4Type(ICMPV4_TYPE_VAL_MOBILE_REGISTRATION_REPLY);
+ public static final ICMPv4Type ICMPV4_TYPE_DOMAIN_NAME_REQUEST = new ICMPv4Type(ICMPV4_TYPE_VAL_DOMAIN_NAME_REQUEST);
+ public static final ICMPv4Type ICMPV4_TYPE_DOMAIN_NAME_REPLY = new ICMPv4Type(ICMPV4_TYPE_VAL_DOMAIN_NAME_REPLY);
+ public static final ICMPv4Type ICMPV4_TYPE_SKIP = new ICMPv4Type(ICMPV4_TYPE_VAL_SKIP);
+ 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);
+
+ private final short type;
+
+ private static final int MIN_TYPE = 0;
+ private static final int MAX_TYPE = 0xFF;
+
+ private ICMPv4Type(short type) {
+ this.type = type;
+ }
+
+ public static ICMPv4Type of(short type) {
+ if (type < MIN_TYPE || type > MAX_TYPE)
+ throw new IllegalArgumentException("Invalid ICMPv4 type: " + type);
+ switch (type) {
+ case ICMPV4_TYPE_VAL_ECHO_REPLY:
+ return ICMPV4_TYPE_ECHO_REPLY;
+ case ICMPV4_TYPE_VAL_DESTINATION_UNREACHABLE:
+ return ICMPV4_TYPE_DESTINATION_UNREACHABLE;
+ case ICMPV4_TYPE_VAL_SOURCE_QUENCH:
+ return ICMPV4_TYPE_SOURCE_QUENCH;
+ case ICMPV4_TYPE_VAL_REDIRECT:
+ return ICMPV4_TYPE_REDIRECT;
+ case ICMPV4_TYPE_VAL_ALTERNATE_HOST_ADDRESS:
+ return ICMPV4_TYPE_ALTERNATE_HOST_ADDRESS;
+ case ICMPV4_TYPE_VAL_ECHO:
+ return ICMPV4_TYPE_ECHO;
+ case ICMPV4_TYPE_VAL_ROUTER_ADVERTISEMENT:
+ return ICMPV4_TYPE_ROUTER_ADVERTISEMENT;
+ case ICMPV4_TYPE_VAL_ROUTER_SOLICITATION:
+ return ICMPV4_TYPE_ROUTER_SOLICITATION;
+ case ICMPV4_TYPE_VAL_TIME_EXCEEDED:
+ return ICMPV4_TYPE_TIME_EXCEEDED;
+ case ICMPV4_TYPE_VAL_PARAMETER_PROBLEM:
+ return ICMPV4_TYPE_PARAMETER_PROBLEM;
+ case ICMPV4_TYPE_VAL_TIMESTAMP:
+ return ICMPV4_TYPE_TIMESTAMP;
+ case ICMPV4_TYPE_VAL_TIMESTAMP_REPLY:
+ return ICMPV4_TYPE_TIMESTAMP_REPLY;
+ case ICMPV4_TYPE_VAL_INFORMATION_REQUEST:
+ return ICMPV4_TYPE_INFORMATION_REQUEST;
+ case ICMPV4_TYPE_VAL_INFORMATION_REPLY:
+ return ICMPV4_TYPE_INFORMATION_REPLY;
+ case ICMPV4_TYPE_VAL_ADDRESS_MASK_REQUEST:
+ return ICMPV4_TYPE_ADDRESS_MASK_REQUEST;
+ case ICMPV4_TYPE_VAL_ADDRESS_MASK_REPLY:
+ return ICMPV4_TYPE_ADDRESS_MASK_REPLY;
+ case ICMPV4_TYPE_VAL_TRACEROUTE:
+ return ICMPV4_TYPE_TRACEROUTE;
+ case ICMPV4_TYPE_VAL_DATAGRAM_CONVERSION_ERROR:
+ return ICMPV4_TYPE_DATAGRAM_CONVERSION_ERROR;
+ case ICMPV4_TYPE_VAL_MOBILE_HOST_REDIRECT:
+ return ICMPV4_TYPE_MOBILE_HOST_REDIRECT;
+ case ICMPV4_TYPE_VAL_IPV6_WHERE_ARE_YOU:
+ return ICMPV4_TYPE_IPV6_WHERE_ARE_YOU;
+ case ICMPV4_TYPE_VAL_IPV6_I_AM_HERE:
+ return ICMPV4_TYPE_IPV6_I_AM_HERE;
+ case ICMPV4_TYPE_VAL_MOBILE_REGISTRATION_REQUEST:
+ return ICMPV4_TYPE_MOBILE_REGISTRATION_REQUEST;
+ case ICMPV4_TYPE_VAL_MOBILE_REGISTRATION_REPLY:
+ return ICMPV4_TYPE_MOBILE_REGISTRATION_REPLY;
+ case ICMPV4_TYPE_VAL_DOMAIN_NAME_REQUEST:
+ return ICMPV4_TYPE_DOMAIN_NAME_REQUEST;
+ case ICMPV4_TYPE_VAL_DOMAIN_NAME_REPLY:
+ return ICMPV4_TYPE_DOMAIN_NAME_REPLY;
+ case ICMPV4_TYPE_VAL_SKIP:
+ return ICMPV4_TYPE_SKIP;
+ case ICMPV4_TYPE_VAL_PHOTURIS:
+ return ICMPV4_TYPE_PHOTURIS;
+ case ICMPV4_TYPE_VAL_EXPERIMENTAL_MOBILITY:
+ return ICMPV4_TYPE_EXPERIMENTAL_MOBILITY;
+ default:
+ return new ICMPv4Type(type);
+ }
+ }
+
+ @Override
+ 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());
+ }
+
+}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/types/IPv4.java b/java_gen/pre-written/src/main/java/org/openflow/types/IPv4.java
index 0583d6f..78b8dd2 100644
--- a/java_gen/pre-written/src/main/java/org/openflow/types/IPv4.java
+++ b/java_gen/pre-written/src/main/java/org/openflow/types/IPv4.java
@@ -1,14 +1,15 @@
package org.openflow.types;
import org.jboss.netty.buffer.ChannelBuffer;
-import org.openflow.protocol.OFObject;
+
+
/**
* Wrapper around an IPv4 address
*
* @author Andreas Wundsam <andreas.wundsam@bigswitch.com>
*/
-public class IPv4 implements OFObject {
+public class IPv4 implements OFValueType {
static final int LENGTH = 4;
private final int rawValue;
@@ -82,15 +83,6 @@
return LENGTH;
}
- public static IPv4 readFrom(final ChannelBuffer bb) {
- return IPv4.of(bb.readInt());
- }
-
- @Override
- public void writeTo(final ChannelBuffer bb) {
- bb.writeInt(rawValue);
- }
-
@Override
public String toString() {
StringBuilder res = new StringBuilder();
@@ -122,5 +114,13 @@
return false;
return true;
}
-
+
+ public void write4Bytes(ChannelBuffer c) {
+ c.writeInt(rawValue);
+ }
+
+ public static IPv4 read4Bytes(ChannelBuffer c) {
+ return IPv4.of(c.readInt());
+ }
+
}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/types/IPv4WithMask.java b/java_gen/pre-written/src/main/java/org/openflow/types/IPv4WithMask.java
index ec777c0..afb89ed 100644
--- a/java_gen/pre-written/src/main/java/org/openflow/types/IPv4WithMask.java
+++ b/java_gen/pre-written/src/main/java/org/openflow/types/IPv4WithMask.java
@@ -1,5 +1,83 @@
package org.openflow.types;
-public class IPv4WithMask {
+public class IPv4WithMask extends Masked<IPv4> {
+
+ private IPv4WithMask(int rawValue, int rawMask) {
+ super(IPv4.of(rawValue), IPv4.of(rawMask));
+ }
+
+ private IPv4WithMask(IPv4 value, IPv4 mask) {
+ super(value, mask);
+ }
+
+ public static IPv4WithMask of(int rawValue, int rawMask) {
+ return new IPv4WithMask(rawValue, rawMask);
+ }
+
+ public static IPv4WithMask of(IPv4 value, IPv4 mask) {
+ return new IPv4WithMask(value, mask);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder res = new StringBuilder();
+ res.append(((IPv4)value).toString());
+
+ int maskint = ((IPv4)mask).getInt();
+ res.append('/');
+ if (Integer.bitCount((~maskint) + 1) == 1) {
+ // CIDR notation
+ res.append(Integer.bitCount(maskint));
+ } else {
+ // Full address mask
+ res.append(((IPv4)mask).toString());
+ }
+
+ return res.toString();
+ }
+
+ public static OFValueType ofPossiblyMasked(final String string) {
+ int slashPos;
+ String ip = string;
+ int maskBits = 0;
+ IPv4 maskAddress = null;
+
+ // Read mask suffix
+ if ((slashPos = string.indexOf('/')) != -1) {
+ ip = string.substring(0, slashPos);
+ try {
+ String suffix = string.substring(slashPos + 1);
+ if (suffix.length() == 0)
+ throw new IllegalArgumentException("IP Address not well formed: " + string);
+ if (suffix.indexOf('.') != -1) {
+ // Full mask
+ maskAddress = IPv4.of(suffix);
+ } else {
+ // CIDR Suffix
+ maskBits = Integer.parseInt(suffix);
+ }
+ } catch (NumberFormatException e) {
+ throw new IllegalArgumentException("IP Address not well formed: " + string);
+ }
+ if (maskBits < 0 || maskBits > 32) {
+ throw new IllegalArgumentException("IP Address not well formed: " + string);
+ }
+ }
+
+ // Read IP
+ IPv4 ipv4 = IPv4.of(ip);
+
+ if (maskAddress != null) {
+ // Full address mask
+ return IPv4WithMask.of(ipv4, maskAddress);
+ } else if (maskBits == 0) {
+ // No mask
+ return ipv4;
+ } else {
+ // With mask
+ int mask = (-1) << (32 - maskBits);
+ return IPv4WithMask.of(ipv4, IPv4.of(mask));
+ }
+ }
}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/types/IPv6.java b/java_gen/pre-written/src/main/java/org/openflow/types/IPv6.java
index 19002d9..e3166fd 100644
--- a/java_gen/pre-written/src/main/java/org/openflow/types/IPv6.java
+++ b/java_gen/pre-written/src/main/java/org/openflow/types/IPv6.java
@@ -4,7 +4,6 @@
import org.jboss.netty.buffer.ChannelBuffer;
import org.openflow.exceptions.OFParseError;
-import org.openflow.protocol.OFObject;
/**
* IPv6 address object. Instance controlled, immutable. Internal representation:
@@ -12,7 +11,7 @@
*
* @author Andreas Wundsam <andreas.wundsam@teleteach.de>
*/
-public class IPv6 implements OFObject {
+public class IPv6 implements OFValueType {
static final int LENGTH = 16;
private final long raw1;
private final long raw2;
@@ -159,16 +158,6 @@
return LENGTH;
}
- public static IPv6 readFrom(final ChannelBuffer bb) throws OFParseError {
- return IPv6.of(bb.readLong(), bb.readLong());
- }
-
- @Override
- public void writeTo(final ChannelBuffer bb) {
- bb.writeLong(raw1);
- bb.writeLong(raw2);
- }
-
@Override
public String toString() {
return toString(true, false);
@@ -280,5 +269,13 @@
return false;
return true;
}
+
+ public void write16Bytes(ChannelBuffer c) {
+ c.writeLong(this.raw1);
+ c.writeLong(this.raw2);
+ }
+ public static IPv6 read16Bytes(ChannelBuffer c) throws OFParseError {
+ return IPv6.of(c.readLong(), c.readLong());
+ }
}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/types/IPv6FlowLabel.java b/java_gen/pre-written/src/main/java/org/openflow/types/IPv6FlowLabel.java
new file mode 100644
index 0000000..6d9bfb5
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/openflow/types/IPv6FlowLabel.java
@@ -0,0 +1,56 @@
+package org.openflow.types;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.openflow.exceptions.OFParseError;
+
+public class IPv6FlowLabel implements OFValueType {
+
+ static final int LENGTH = 4;
+
+ private final int label;
+
+ private IPv6FlowLabel(int label) {
+ this.label = label;
+ }
+
+ public static IPv6FlowLabel of(int label) {
+ return new IPv6FlowLabel(label);
+ }
+
+ @Override
+ public int getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof IPv6FlowLabel))
+ return false;
+ IPv6FlowLabel other = (IPv6FlowLabel)obj;
+ if (other.label != this.label)
+ return false;
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 59;
+ int result = 1;
+ result = prime * result + label;
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return Integer.toHexString(label);
+ }
+
+ public void write4Bytes(ChannelBuffer c) {
+ c.writeInt(this.label);
+ }
+
+ public static IPv6FlowLabel read4Bytes(ChannelBuffer c) throws OFParseError {
+ return IPv6FlowLabel.of((int)(c.readUnsignedInt() & 0xFFFFFFFF));
+ }
+
+}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/types/IPv6WithMask.java b/java_gen/pre-written/src/main/java/org/openflow/types/IPv6WithMask.java
index 0fb3281..f809d67 100644
--- a/java_gen/pre-written/src/main/java/org/openflow/types/IPv6WithMask.java
+++ b/java_gen/pre-written/src/main/java/org/openflow/types/IPv6WithMask.java
@@ -1,5 +1,91 @@
package org.openflow.types;
-public class IPv6WithMask {
+import java.math.BigInteger;
+import java.util.Arrays;
+
+public class IPv6WithMask extends Masked<IPv6> {
+
+ private IPv6WithMask(IPv6 value, IPv6 mask) {
+ super(value, mask);
+ }
+
+ public static IPv6WithMask of(IPv6 value, IPv6 mask) {
+ return new IPv6WithMask(value, mask);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder res = new StringBuilder();
+ res.append(((IPv6)value).toString());
+ res.append('/');
+
+ BigInteger maskint = new BigInteger(((IPv6)mask).getBytes());
+ if (maskint.not().add(BigInteger.ONE).bitCount() == 1) {
+ // CIDR notation
+ res.append(maskint.bitCount());
+ } else {
+ // Full address mask
+ res.append(((IPv6)mask).toString());
+ }
+
+ return res.toString();
+ }
+
+ public static OFValueType ofPossiblyMasked(final String string) {
+ int slashPos;
+ String ip = string;
+ int maskBits = 0;
+ IPv6 maskAddress = null;
+
+ // Read mask suffix
+ if ((slashPos = string.indexOf('/')) != -1) {
+ ip = string.substring(0, slashPos);
+ try {
+ String suffix = string.substring(slashPos + 1);
+ if (suffix.length() == 0)
+ throw new IllegalArgumentException("IPv6 Address not well formed: " + string);
+ if (suffix.indexOf(':') != -1) {
+ // Full mask
+ maskAddress = IPv6.of(suffix);
+ } else {
+ // CIDR Suffix
+ maskBits = Integer.parseInt(suffix);
+ }
+ } catch (NumberFormatException e) {
+ throw new IllegalArgumentException("IPv6 Address not well formed: " + string);
+ }
+ if (maskBits < 0 || maskBits > 128) {
+ throw new IllegalArgumentException("IPv6 Address not well formed: " + string);
+ }
+ }
+
+ // Read IP
+ IPv6 ipv6 = IPv6.of(ip);
+
+ if (maskAddress != null) {
+ // Full address mask
+ return IPv6WithMask.of(ipv6, maskAddress);
+ } else if (maskBits == 0) {
+ // No mask
+ return ipv6;
+ } else {
+ // With mask
+ BigInteger mask = BigInteger.ONE.negate().shiftLeft(128 - maskBits);
+ byte[] maskBytesTemp = mask.toByteArray();
+ byte[] maskBytes;
+ if (maskBytesTemp.length < 16) {
+ maskBytes = new byte[16];
+ System.arraycopy(maskBytesTemp, 0, maskBytes, 16 - maskBytesTemp.length, maskBytesTemp.length);
+ Arrays.fill(maskBytes, 0, 16 - maskBytesTemp.length, (byte)(0xFF));
+ } else if (maskBytesTemp.length > 16) {
+ maskBytes = new byte[16];
+ System.arraycopy(maskBytesTemp, 0, maskBytes, 0, maskBytes.length);
+ } else {
+ maskBytes = maskBytesTemp;
+ }
+ return IPv6WithMask.of(ipv6, IPv6.of(maskBytes));
+ }
+ }
+
}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/types/IpDscp.java b/java_gen/pre-written/src/main/java/org/openflow/types/IpDscp.java
new file mode 100644
index 0000000..033e574
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/openflow/types/IpDscp.java
@@ -0,0 +1,233 @@
+package org.openflow.types;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.openflow.exceptions.OFParseError;
+
+public enum IpDscp implements OFValueType {
+ DSCP_0((byte)0),
+ DSCP_1((byte)1),
+ DSCP_2((byte)2),
+ DSCP_3((byte)3),
+ DSCP_4((byte)4),
+ DSCP_5((byte)5),
+ DSCP_6((byte)6),
+ DSCP_7((byte)7),
+ DSCP_8((byte)8),
+ DSCP_9((byte)9),
+ DSCP_10((byte)10),
+ DSCP_11((byte)11),
+ DSCP_12((byte)12),
+ DSCP_13((byte)13),
+ DSCP_14((byte)14),
+ DSCP_15((byte)15),
+ DSCP_16((byte)16),
+ DSCP_17((byte)17),
+ DSCP_18((byte)18),
+ DSCP_19((byte)19),
+ DSCP_20((byte)20),
+ DSCP_21((byte)21),
+ DSCP_22((byte)22),
+ DSCP_23((byte)23),
+ DSCP_24((byte)24),
+ DSCP_25((byte)25),
+ DSCP_26((byte)26),
+ DSCP_27((byte)27),
+ DSCP_28((byte)28),
+ DSCP_29((byte)29),
+ DSCP_30((byte)30),
+ DSCP_31((byte)31),
+ DSCP_32((byte)32),
+ DSCP_33((byte)33),
+ DSCP_34((byte)34),
+ DSCP_35((byte)35),
+ DSCP_36((byte)36),
+ DSCP_37((byte)37),
+ DSCP_38((byte)38),
+ DSCP_39((byte)39),
+ DSCP_40((byte)40),
+ DSCP_41((byte)41),
+ DSCP_42((byte)42),
+ DSCP_43((byte)43),
+ DSCP_44((byte)44),
+ DSCP_45((byte)45),
+ DSCP_46((byte)46),
+ DSCP_47((byte)47),
+ DSCP_48((byte)48),
+ DSCP_49((byte)49),
+ DSCP_50((byte)50),
+ DSCP_51((byte)51),
+ DSCP_52((byte)52),
+ DSCP_53((byte)53),
+ DSCP_54((byte)54),
+ DSCP_55((byte)55),
+ DSCP_56((byte)56),
+ DSCP_57((byte)57),
+ DSCP_58((byte)58),
+ DSCP_59((byte)59),
+ DSCP_60((byte)60),
+ DSCP_61((byte)61),
+ DSCP_62((byte)62),
+ DSCP_63((byte)63);
+
+ static final int LENGTH = 1;
+
+ private final byte dscp;
+
+ private IpDscp(byte dscp) {
+ this.dscp = dscp;
+ }
+
+ public static IpDscp of(byte dscp) {
+ switch (dscp) {
+ case 0:
+ return DSCP_0;
+ case 1:
+ return DSCP_1;
+ case 2:
+ return DSCP_2;
+ case 3:
+ return DSCP_3;
+ case 4:
+ return DSCP_4;
+ case 5:
+ return DSCP_5;
+ case 6:
+ return DSCP_6;
+ case 7:
+ return DSCP_7;
+ case 8:
+ return DSCP_8;
+ case 9:
+ return DSCP_9;
+ case 10:
+ return DSCP_10;
+ case 11:
+ return DSCP_11;
+ case 12:
+ return DSCP_12;
+ case 13:
+ return DSCP_13;
+ case 14:
+ return DSCP_14;
+ case 15:
+ return DSCP_15;
+ case 16:
+ return DSCP_16;
+ case 17:
+ return DSCP_17;
+ case 18:
+ return DSCP_18;
+ case 19:
+ return DSCP_19;
+ case 20:
+ return DSCP_20;
+ case 21:
+ return DSCP_21;
+ case 22:
+ return DSCP_22;
+ case 23:
+ return DSCP_23;
+ case 24:
+ return DSCP_24;
+ case 25:
+ return DSCP_25;
+ case 26:
+ return DSCP_26;
+ case 27:
+ return DSCP_27;
+ case 28:
+ return DSCP_28;
+ case 29:
+ return DSCP_29;
+ case 30:
+ return DSCP_30;
+ case 31:
+ return DSCP_31;
+ case 32:
+ return DSCP_32;
+ case 33:
+ return DSCP_33;
+ case 34:
+ return DSCP_34;
+ case 35:
+ return DSCP_35;
+ case 36:
+ return DSCP_36;
+ case 37:
+ return DSCP_37;
+ case 38:
+ return DSCP_38;
+ case 39:
+ return DSCP_39;
+ case 40:
+ return DSCP_40;
+ case 41:
+ return DSCP_41;
+ case 42:
+ return DSCP_42;
+ case 43:
+ return DSCP_43;
+ case 44:
+ return DSCP_44;
+ case 45:
+ return DSCP_45;
+ case 46:
+ return DSCP_46;
+ case 47:
+ return DSCP_47;
+ case 48:
+ return DSCP_48;
+ case 49:
+ return DSCP_49;
+ case 50:
+ return DSCP_50;
+ case 51:
+ return DSCP_51;
+ case 52:
+ return DSCP_52;
+ case 53:
+ return DSCP_53;
+ case 54:
+ return DSCP_54;
+ case 55:
+ return DSCP_55;
+ case 56:
+ return DSCP_56;
+ case 57:
+ return DSCP_57;
+ case 58:
+ return DSCP_58;
+ case 59:
+ return DSCP_59;
+ case 60:
+ return DSCP_60;
+ case 61:
+ return DSCP_61;
+ case 62:
+ return DSCP_62;
+ case 63:
+ return DSCP_63;
+ default:
+ throw new IllegalArgumentException("Illegal IPv4 DSCP value: " + dscp);
+ }
+ }
+
+ @Override
+ public int getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public String toString() {
+ return Integer.toHexString(dscp);
+ }
+
+ public void writeByte(ChannelBuffer c) {
+ c.writeByte(this.dscp);
+ }
+
+ public static IpDscp readByte(ChannelBuffer c) throws OFParseError {
+ return IpDscp.of((byte)(c.readUnsignedByte()));
+ }
+
+}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/types/IpEcn.java b/java_gen/pre-written/src/main/java/org/openflow/types/IpEcn.java
new file mode 100644
index 0000000..b261d41
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/openflow/types/IpEcn.java
@@ -0,0 +1,53 @@
+package org.openflow.types;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.openflow.exceptions.OFParseError;
+
+public enum IpEcn implements OFValueType {
+ ECN_00((byte)0),
+ ECN_01((byte)1),
+ ECN_10((byte)2),
+ ECN_11((byte)3);
+
+ static final int LENGTH = 1;
+
+ private final byte ecn;
+
+ private IpEcn(byte ecn) {
+ this.ecn = ecn;
+ }
+
+ public static IpEcn of(byte ecn) {
+ switch (ecn) {
+ case 0:
+ return ECN_00;
+ case 1:
+ return ECN_01;
+ case 2:
+ return ECN_10;
+ case 3:
+ return ECN_11;
+ default:
+ throw new IllegalArgumentException("Illegal IP ECN value: " + ecn);
+ }
+ }
+
+ @Override
+ public int getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public String toString() {
+ return (ecn < 3 ? "0" : "") + Integer.toBinaryString(ecn);
+ }
+
+ public void writeByte(ChannelBuffer c) {
+ c.writeByte(this.ecn);
+ }
+
+ public static IpEcn readByte(ChannelBuffer c) throws OFParseError {
+ return IpEcn.of((byte)(c.readUnsignedByte()));
+ }
+
+}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/types/IpProtocol.java b/java_gen/pre-written/src/main/java/org/openflow/types/IpProtocol.java
index a295cb2..436db1d 100644
--- a/java_gen/pre-written/src/main/java/org/openflow/types/IpProtocol.java
+++ b/java_gen/pre-written/src/main/java/org/openflow/types/IpProtocol.java
@@ -1,5 +1,635 @@
package org.openflow.types;
-public class IpProtocol {
+import org.jboss.netty.buffer.ChannelBuffer;
+/**
+ * IP-Protocol field representation
+ *
+ * @author Yotam Harchol (yotam.harchol@bigswitch.com)
+ */
+public class IpProtocol implements OFValueType {
+
+ static final short MAX_PROTO = 0xFF;
+ static final int LENGTH = 1;
+
+ private final short proto;
+
+ static final short IP_PROTO_NUM_HOPOPT = 0x00;
+ static final short IP_PROTO_NUM_ICMP = 0x01;
+ static final short IP_PROTO_NUM_IGMP = 0x02;
+ static final short IP_PROTO_NUM_GGP = 0x03;
+ static final short IP_PROTO_NUM_IPv4 = 0x04;
+ static final short IP_PROTO_NUM_ST = 0x05;
+ static final short IP_PROTO_NUM_TCP = 0x06;
+ static final short IP_PROTO_NUM_CBT = 0x07;
+ static final short IP_PROTO_NUM_EGP = 0x08;
+ static final short IP_PROTO_NUM_IGP = 0x09;
+ static final short IP_PROTO_NUM_BBN_RCC_MON = 0x0A;
+ static final short IP_PROTO_NUM_NVP_II = 0x0B;
+ static final short IP_PROTO_NUM_PUP = 0x0C;
+ static final short IP_PROTO_NUM_ARGUS = 0x0D;
+ static final short IP_PROTO_NUM_EMCON = 0x0E;
+ static final short IP_PROTO_NUM_XNET = 0x0F;
+ static final short IP_PROTO_NUM_CHAOS = 0x10;
+ static final short IP_PROTO_NUM_UDP = 0x11;
+ static final short IP_PROTO_NUM_MUX = 0x12;
+ static final short IP_PROTO_NUM_DCN_MEAS = 0x13;
+ static final short IP_PROTO_NUM_HMP = 0x14;
+ static final short IP_PROTO_NUM_PRM = 0x15;
+ static final short IP_PROTO_NUM_XNS_IDP = 0x16;
+ static final short IP_PROTO_NUM_TRUNK_1 = 0x17;
+ static final short IP_PROTO_NUM_TRUNK_2 = 0x18;
+ static final short IP_PROTO_NUM_LEAF_1 = 0x19;
+ static final short IP_PROTO_NUM_LEAF_2 = 0x1A;
+ static final short IP_PROTO_NUM_RDP = 0x1B;
+ static final short IP_PROTO_NUM_IRTP = 0x1C;
+ static final short IP_PROTO_NUM_ISO_TP4 = 0x1D;
+ static final short IP_PROTO_NUM_NETBLT = 0x1E;
+ static final short IP_PROTO_NUM_MFE_NSP = 0x1F;
+ static final short IP_PROTO_NUM_MERIT_INP = 0x20;
+ static final short IP_PROTO_NUM_DCCP = 0x21;
+ static final short IP_PROTO_NUM_3PC = 0x22;
+ static final short IP_PROTO_NUM_IDPR = 0x23;
+ static final short IP_PROTO_NUM_XTP = 0x24;
+ static final short IP_PROTO_NUM_DDP = 0x25;
+ static final short IP_PROTO_NUM_IDPR_CMTP = 0x26;
+ static final short IP_PROTO_NUM_TP_PP = 0x27;
+ static final short IP_PROTO_NUM_IL = 0x28;
+ static final short IP_PROTO_NUM_IPv6 = 0x29;
+ static final short IP_PROTO_NUM_SDRP = 0x2A;
+ static final short IP_PROTO_NUM_IPv6_ROUTE = 0x2B;
+ static final short IP_PROTO_NUM_IPv6_FRAG = 0x2C;
+ static final short IP_PROTO_NUM_IDRP = 0x2D;
+ static final short IP_PROTO_NUM_RSVP = 0x2E;
+ static final short IP_PROTO_NUM_GRE = 0x2F;
+ static final short IP_PROTO_NUM_MHRP = 0x30;
+ static final short IP_PROTO_NUM_BNA = 0x31;
+ static final short IP_PROTO_NUM_ESP = 0x32;
+ static final short IP_PROTO_NUM_AH = 0x33;
+ static final short IP_PROTO_NUM_I_NLSP = 0x34;
+ static final short IP_PROTO_NUM_SWIPE = 0x35;
+ static final short IP_PROTO_NUM_NARP = 0x36;
+ static final short IP_PROTO_NUM_MOBILE = 0x37;
+ static final short IP_PROTO_NUM_TLSP = 0x38;
+ static final short IP_PROTO_NUM_SKIP = 0x39;
+ static final short IP_PROTO_NUM_IPv6_ICMP = 0x3A;
+ static final short IP_PROTO_NUM_IPv6_NO_NXT = 0x3B;
+ static final short IP_PROTO_NUM_IPv6_OPTS = 0x3C;
+ static final short IP_PROTO_NUM_HOST_INTERNAL = 0x3D;
+ static final short IP_PROTO_NUM_CFTP = 0x3E;
+ static final short IP_PROTO_NUM_LOCAL_NET = 0x3F;
+ static final short IP_PROTO_NUM_SAT_EXPAK = 0x40;
+ static final short IP_PROTO_NUM_KRYPTOLAN = 0x41;
+ static final short IP_PROTO_NUM_RVD = 0x42;
+ static final short IP_PROTO_NUM_IPPC = 0x43;
+ static final short IP_PROTO_NUM_DIST_FS = 0x44;
+ static final short IP_PROTO_NUM_SAT_MON = 0x45;
+ static final short IP_PROTO_NUM_VISA = 0x46;
+ static final short IP_PROTO_NUM_IPCV = 0x47;
+ static final short IP_PROTO_NUM_CPNX = 0x48;
+ static final short IP_PROTO_NUM_CPHB = 0x49;
+ static final short IP_PROTO_NUM_WSN = 0x4A;
+ static final short IP_PROTO_NUM_PVP = 0x4B;
+ static final short IP_PROTO_NUM_BR_SAT_MON = 0x4C;
+ static final short IP_PROTO_NUM_SUN_ND = 0x4D;
+ static final short IP_PROTO_NUM_WB_MON = 0x4E;
+ static final short IP_PROTO_NUM_WB_EXPAK = 0x4F;
+ static final short IP_PROTO_NUM_ISO_IP = 0x50;
+ static final short IP_PROTO_NUM_VMTP = 0x51;
+ static final short IP_PROTO_NUM_SECURE_VMTP = 0x52;
+ static final short IP_PROTO_NUM_VINES = 0x53;
+ static final short IP_PROTO_NUM_TTP_IPTM = 0x54;
+ static final short IP_PROTO_NUM_NSFNET_IGP = 0x55;
+ static final short IP_PROTO_NUM_DGP = 0x56;
+ static final short IP_PROTO_NUM_TCF = 0x57;
+ static final short IP_PROTO_NUM_EIGRP = 0x58;
+ static final short IP_PROTO_NUM_OSPF = 0x59;
+ static final short IP_PROTO_NUM_Sprite_RPC = 0x5A;
+ static final short IP_PROTO_NUM_LARP = 0x5B;
+ static final short IP_PROTO_NUM_MTP = 0x5C;
+ static final short IP_PROTO_NUM_AX_25 = 0x5D;
+ static final short IP_PROTO_NUM_IPIP = 0x5E;
+ static final short IP_PROTO_NUM_MICP = 0x5F;
+ static final short IP_PROTO_NUM_SCC_SP = 0x60;
+ static final short IP_PROTO_NUM_ETHERIP = 0x61;
+ static final short IP_PROTO_NUM_ENCAP = 0x62;
+ static final short IP_PROTO_NUM_PRIVATE_ENCRYPT = 0x63;
+ static final short IP_PROTO_NUM_GMTP = 0x64;
+ static final short IP_PROTO_NUM_IFMP = 0x65;
+ static final short IP_PROTO_NUM_PNNI = 0x66;
+ static final short IP_PROTO_NUM_PIM = 0x67;
+ static final short IP_PROTO_NUM_ARIS = 0x68;
+ static final short IP_PROTO_NUM_SCPS = 0x69;
+ static final short IP_PROTO_NUM_QNX = 0x6A;
+ static final short IP_PROTO_NUM_A_N = 0x6B;
+ static final short IP_PROTO_NUM_IP_COMP = 0x6C;
+ static final short IP_PROTO_NUM_SNP = 0x6D;
+ static final short IP_PROTO_NUM_COMPAQ_PEER = 0x6E;
+ static final short IP_PROTO_NUM_IPX_IN_IP = 0x6F;
+ static final short IP_PROTO_NUM_VRRP = 0x70;
+ static final short IP_PROTO_NUM_PGM = 0x71;
+ static final short IP_PROTO_NUM_ZERO_HOP = 0x72;
+ static final short IP_PROTO_NUM_L2TP = 0x73;
+ static final short IP_PROTO_NUM_DDX = 0x74;
+ static final short IP_PROTO_NUM_IATP = 0x75;
+ static final short IP_PROTO_NUM_STP = 0x76;
+ static final short IP_PROTO_NUM_SRP = 0x77;
+ static final short IP_PROTO_NUM_UTI = 0x78;
+ static final short IP_PROTO_NUM_SMP = 0x79;
+ static final short IP_PROTO_NUM_SM = 0x7A;
+ static final short IP_PROTO_NUM_PTP = 0x7B;
+ static final short IP_PROTO_NUM_IS_IS_OVER_IPv4 = 0x7C;
+ static final short IP_PROTO_NUM_FIRE = 0x7D;
+ static final short IP_PROTO_NUM_CRTP = 0x7E;
+ static final short IP_PROTO_NUM_CRUDP = 0x7F;
+ static final short IP_PROTO_NUM_SSCOPMCE = 0x80;
+ static final short IP_PROTO_NUM_IPLT = 0x81;
+ static final short IP_PROTO_NUM_SPS = 0x82;
+ static final short IP_PROTO_NUM_PIPE = 0x83;
+ static final short IP_PROTO_NUM_SCTP = 0x84;
+ static final short IP_PROTO_NUM_FC = 0x85;
+ static final short IP_PROTO_NUM_RSVP_E2E_IGNORE = 0x86;
+ static final short IP_PROTO_NUM_MOBILITY_HEADER = 0x87;
+ static final short IP_PROTO_NUM_UDP_LITE = 0x88;
+ static final short IP_PROTO_NUM_MPLS_IN_IP = 0x89;
+ static final short IP_PROTO_NUM_MANET = 0x8A;
+ static final short IP_PROTO_NUM_HIP = 0x8B;
+ static final short IP_PROTO_NUM_SHIM6 = 0x8C;
+
+ public static final IpProtocol IP_PROTO_HOPOPT = new IpProtocol(IP_PROTO_NUM_HOPOPT);
+ public static final IpProtocol IP_PROTO_ICMP = new IpProtocol(IP_PROTO_NUM_ICMP);
+ public static final IpProtocol IP_PROTO_IGMP = new IpProtocol(IP_PROTO_NUM_IGMP);
+ public static final IpProtocol IP_PROTO_GGP = new IpProtocol(IP_PROTO_NUM_GGP);
+ public static final IpProtocol IP_PROTO_IPv4 = new IpProtocol(IP_PROTO_NUM_IPv4);
+ public static final IpProtocol IP_PROTO_ST = new IpProtocol(IP_PROTO_NUM_ST);
+ public static final IpProtocol IP_PROTO_TCP = new IpProtocol(IP_PROTO_NUM_TCP);
+ public static final IpProtocol IP_PROTO_CBT = new IpProtocol(IP_PROTO_NUM_CBT);
+ public static final IpProtocol IP_PROTO_EGP = new IpProtocol(IP_PROTO_NUM_EGP);
+ public static final IpProtocol IP_PROTO_IGP = new IpProtocol(IP_PROTO_NUM_IGP);
+ public static final IpProtocol IP_PROTO_BBN_RCC_MON = new IpProtocol(IP_PROTO_NUM_BBN_RCC_MON);
+ public static final IpProtocol IP_PROTO_NVP_II = new IpProtocol(IP_PROTO_NUM_NVP_II);
+ public static final IpProtocol IP_PROTO_PUP = new IpProtocol(IP_PROTO_NUM_PUP);
+ public static final IpProtocol IP_PROTO_ARGUS = new IpProtocol(IP_PROTO_NUM_ARGUS);
+ public static final IpProtocol IP_PROTO_EMCON = new IpProtocol(IP_PROTO_NUM_EMCON);
+ public static final IpProtocol IP_PROTO_XNET = new IpProtocol(IP_PROTO_NUM_XNET);
+ public static final IpProtocol IP_PROTO_CHAOS = new IpProtocol(IP_PROTO_NUM_CHAOS);
+ public static final IpProtocol IP_PROTO_UDP = new IpProtocol(IP_PROTO_NUM_UDP);
+ public static final IpProtocol IP_PROTO_MUX = new IpProtocol(IP_PROTO_NUM_MUX);
+ public static final IpProtocol IP_PROTO_DCN_MEAS = new IpProtocol(IP_PROTO_NUM_DCN_MEAS);
+ public static final IpProtocol IP_PROTO_HMP = new IpProtocol(IP_PROTO_NUM_HMP);
+ public static final IpProtocol IP_PROTO_PRM = new IpProtocol(IP_PROTO_NUM_PRM);
+ public static final IpProtocol IP_PROTO_XNS_IDP = new IpProtocol(IP_PROTO_NUM_XNS_IDP);
+ public static final IpProtocol IP_PROTO_TRUNK_1 = new IpProtocol(IP_PROTO_NUM_TRUNK_1);
+ public static final IpProtocol IP_PROTO_TRUNK_2 = new IpProtocol(IP_PROTO_NUM_TRUNK_2);
+ public static final IpProtocol IP_PROTO_LEAF_1 = new IpProtocol(IP_PROTO_NUM_LEAF_1);
+ public static final IpProtocol IP_PROTO_LEAF_2 = new IpProtocol(IP_PROTO_NUM_LEAF_2);
+ public static final IpProtocol IP_PROTO_RDP = new IpProtocol(IP_PROTO_NUM_RDP);
+ public static final IpProtocol IP_PROTO_IRTP = new IpProtocol(IP_PROTO_NUM_IRTP);
+ public static final IpProtocol IP_PROTO_ISO_TP4 = new IpProtocol(IP_PROTO_NUM_ISO_TP4);
+ public static final IpProtocol IP_PROTO_NETBLT = new IpProtocol(IP_PROTO_NUM_NETBLT);
+ public static final IpProtocol IP_PROTO_MFE_NSP = new IpProtocol(IP_PROTO_NUM_MFE_NSP);
+ public static final IpProtocol IP_PROTO_MERIT_INP = new IpProtocol(IP_PROTO_NUM_MERIT_INP);
+ public static final IpProtocol IP_PROTO_DCCP = new IpProtocol(IP_PROTO_NUM_DCCP);
+ public static final IpProtocol IP_PROTO_3PC = new IpProtocol(IP_PROTO_NUM_3PC);
+ public static final IpProtocol IP_PROTO_IDPR = new IpProtocol(IP_PROTO_NUM_IDPR);
+ public static final IpProtocol IP_PROTO_XTP = new IpProtocol(IP_PROTO_NUM_XTP);
+ public static final IpProtocol IP_PROTO_DDP = new IpProtocol(IP_PROTO_NUM_DDP);
+ public static final IpProtocol IP_PROTO_IDPR_CMTP = new IpProtocol(IP_PROTO_NUM_IDPR_CMTP);
+ public static final IpProtocol IP_PROTO_TP_PP = new IpProtocol(IP_PROTO_NUM_TP_PP);
+ public static final IpProtocol IP_PROTO_IL = new IpProtocol(IP_PROTO_NUM_IL);
+ public static final IpProtocol IP_PROTO_IPv6 = new IpProtocol(IP_PROTO_NUM_IPv6);
+ public static final IpProtocol IP_PROTO_SDRP = new IpProtocol(IP_PROTO_NUM_SDRP);
+ public static final IpProtocol IP_PROTO_IPv6_ROUTE = new IpProtocol(IP_PROTO_NUM_IPv6_ROUTE);
+ public static final IpProtocol IP_PROTO_IPv6_FRAG = new IpProtocol(IP_PROTO_NUM_IPv6_FRAG);
+ public static final IpProtocol IP_PROTO_IDRP = new IpProtocol(IP_PROTO_NUM_IDRP);
+ public static final IpProtocol IP_PROTO_RSVP = new IpProtocol(IP_PROTO_NUM_RSVP);
+ public static final IpProtocol IP_PROTO_GRE = new IpProtocol(IP_PROTO_NUM_GRE);
+ public static final IpProtocol IP_PROTO_MHRP = new IpProtocol(IP_PROTO_NUM_MHRP);
+ public static final IpProtocol IP_PROTO_BNA = new IpProtocol(IP_PROTO_NUM_BNA);
+ public static final IpProtocol IP_PROTO_ESP = new IpProtocol(IP_PROTO_NUM_ESP);
+ public static final IpProtocol IP_PROTO_AH = new IpProtocol(IP_PROTO_NUM_AH);
+ public static final IpProtocol IP_PROTO_I_NLSP = new IpProtocol(IP_PROTO_NUM_I_NLSP);
+ public static final IpProtocol IP_PROTO_SWIPE = new IpProtocol(IP_PROTO_NUM_SWIPE);
+ public static final IpProtocol IP_PROTO_NARP = new IpProtocol(IP_PROTO_NUM_NARP);
+ public static final IpProtocol IP_PROTO_MOBILE = new IpProtocol(IP_PROTO_NUM_MOBILE);
+ public static final IpProtocol IP_PROTO_TLSP = new IpProtocol(IP_PROTO_NUM_TLSP);
+ public static final IpProtocol IP_PROTO_SKIP = new IpProtocol(IP_PROTO_NUM_SKIP);
+ public static final IpProtocol IP_PROTO_IPv6_ICMP = new IpProtocol(IP_PROTO_NUM_IPv6_ICMP);
+ public static final IpProtocol IP_PROTO_IPv6_NO_NXT = new IpProtocol(IP_PROTO_NUM_IPv6_NO_NXT);
+ public static final IpProtocol IP_PROTO_IPv6_OPTS = new IpProtocol(IP_PROTO_NUM_IPv6_OPTS);
+ public static final IpProtocol IP_PROTO_HOST_INTERNAL = new IpProtocol(IP_PROTO_NUM_HOST_INTERNAL);
+ public static final IpProtocol IP_PROTO_CFTP = new IpProtocol(IP_PROTO_NUM_CFTP);
+ public static final IpProtocol IP_PROTO_LOCAL_NET = new IpProtocol(IP_PROTO_NUM_LOCAL_NET);
+ public static final IpProtocol IP_PROTO_SAT_EXPAK = new IpProtocol(IP_PROTO_NUM_SAT_EXPAK);
+ public static final IpProtocol IP_PROTO_KRYPTOLAN = new IpProtocol(IP_PROTO_NUM_KRYPTOLAN);
+ public static final IpProtocol IP_PROTO_RVD = new IpProtocol(IP_PROTO_NUM_RVD);
+ public static final IpProtocol IP_PROTO_IPPC = new IpProtocol(IP_PROTO_NUM_IPPC);
+ public static final IpProtocol IP_PROTO_DIST_FS = new IpProtocol(IP_PROTO_NUM_DIST_FS);
+ public static final IpProtocol IP_PROTO_SAT_MON = new IpProtocol(IP_PROTO_NUM_SAT_MON);
+ public static final IpProtocol IP_PROTO_VISA = new IpProtocol(IP_PROTO_NUM_VISA);
+ public static final IpProtocol IP_PROTO_IPCV = new IpProtocol(IP_PROTO_NUM_IPCV);
+ public static final IpProtocol IP_PROTO_CPNX = new IpProtocol(IP_PROTO_NUM_CPNX);
+ public static final IpProtocol IP_PROTO_CPHB = new IpProtocol(IP_PROTO_NUM_CPHB);
+ public static final IpProtocol IP_PROTO_WSN = new IpProtocol(IP_PROTO_NUM_WSN);
+ public static final IpProtocol IP_PROTO_PVP = new IpProtocol(IP_PROTO_NUM_PVP);
+ public static final IpProtocol IP_PROTO_BR_SAT_MON = new IpProtocol(IP_PROTO_NUM_BR_SAT_MON);
+ public static final IpProtocol IP_PROTO_SUN_ND = new IpProtocol(IP_PROTO_NUM_SUN_ND);
+ public static final IpProtocol IP_PROTO_WB_MON = new IpProtocol(IP_PROTO_NUM_WB_MON);
+ public static final IpProtocol IP_PROTO_WB_EXPAK = new IpProtocol(IP_PROTO_NUM_WB_EXPAK);
+ public static final IpProtocol IP_PROTO_ISO_IP = new IpProtocol(IP_PROTO_NUM_ISO_IP);
+ public static final IpProtocol IP_PROTO_VMTP = new IpProtocol(IP_PROTO_NUM_VMTP);
+ public static final IpProtocol IP_PROTO_SECURE_VMTP = new IpProtocol(IP_PROTO_NUM_SECURE_VMTP);
+ public static final IpProtocol IP_PROTO_VINES = new IpProtocol(IP_PROTO_NUM_VINES);
+ public static final IpProtocol IP_PROTO_TTP_IPTM = new IpProtocol(IP_PROTO_NUM_TTP_IPTM);
+ public static final IpProtocol IP_PROTO_NSFNET_IGP = new IpProtocol(IP_PROTO_NUM_NSFNET_IGP);
+ public static final IpProtocol IP_PROTO_DGP = new IpProtocol(IP_PROTO_NUM_DGP);
+ public static final IpProtocol IP_PROTO_TCF = new IpProtocol(IP_PROTO_NUM_TCF);
+ public static final IpProtocol IP_PROTO_EIGRP = new IpProtocol(IP_PROTO_NUM_EIGRP);
+ public static final IpProtocol IP_PROTO_OSPF = new IpProtocol(IP_PROTO_NUM_OSPF);
+ public static final IpProtocol IP_PROTO_Sprite_RPC = new IpProtocol(IP_PROTO_NUM_Sprite_RPC);
+ public static final IpProtocol IP_PROTO_LARP = new IpProtocol(IP_PROTO_NUM_LARP);
+ public static final IpProtocol IP_PROTO_MTP = new IpProtocol(IP_PROTO_NUM_MTP);
+ public static final IpProtocol IP_PROTO_AX_25 = new IpProtocol(IP_PROTO_NUM_AX_25);
+ public static final IpProtocol IP_PROTO_IPIP = new IpProtocol(IP_PROTO_NUM_IPIP);
+ public static final IpProtocol IP_PROTO_MICP = new IpProtocol(IP_PROTO_NUM_MICP);
+ public static final IpProtocol IP_PROTO_SCC_SP = new IpProtocol(IP_PROTO_NUM_SCC_SP);
+ public static final IpProtocol IP_PROTO_ETHERIP = new IpProtocol(IP_PROTO_NUM_ETHERIP);
+ public static final IpProtocol IP_PROTO_ENCAP = new IpProtocol(IP_PROTO_NUM_ENCAP);
+ public static final IpProtocol IP_PROTO_PRIVATE_ENCRYPT = new IpProtocol(IP_PROTO_NUM_PRIVATE_ENCRYPT);
+ public static final IpProtocol IP_PROTO_GMTP = new IpProtocol(IP_PROTO_NUM_GMTP);
+ public static final IpProtocol IP_PROTO_IFMP = new IpProtocol(IP_PROTO_NUM_IFMP);
+ public static final IpProtocol IP_PROTO_PNNI = new IpProtocol(IP_PROTO_NUM_PNNI);
+ public static final IpProtocol IP_PROTO_PIM = new IpProtocol(IP_PROTO_NUM_PIM);
+ public static final IpProtocol IP_PROTO_ARIS = new IpProtocol(IP_PROTO_NUM_ARIS);
+ public static final IpProtocol IP_PROTO_SCPS = new IpProtocol(IP_PROTO_NUM_SCPS);
+ public static final IpProtocol IP_PROTO_QNX = new IpProtocol(IP_PROTO_NUM_QNX);
+ public static final IpProtocol IP_PROTO_A_N = new IpProtocol(IP_PROTO_NUM_A_N);
+ public static final IpProtocol IP_PROTO_IP_COMP = new IpProtocol(IP_PROTO_NUM_IP_COMP);
+ public static final IpProtocol IP_PROTO_SNP = new IpProtocol(IP_PROTO_NUM_SNP);
+ public static final IpProtocol IP_PROTO_COMPAQ_PEER = new IpProtocol(IP_PROTO_NUM_COMPAQ_PEER);
+ public static final IpProtocol IP_PROTO_IPX_IN_IP = new IpProtocol(IP_PROTO_NUM_IPX_IN_IP);
+ public static final IpProtocol IP_PROTO_VRRP = new IpProtocol(IP_PROTO_NUM_VRRP);
+ public static final IpProtocol IP_PROTO_PGM = new IpProtocol(IP_PROTO_NUM_PGM);
+ public static final IpProtocol IP_PROTO_ZERO_HOP = new IpProtocol(IP_PROTO_NUM_ZERO_HOP);
+ public static final IpProtocol IP_PROTO_L2TP = new IpProtocol(IP_PROTO_NUM_L2TP);
+ public static final IpProtocol IP_PROTO_DDX = new IpProtocol(IP_PROTO_NUM_DDX);
+ public static final IpProtocol IP_PROTO_IATP = new IpProtocol(IP_PROTO_NUM_IATP);
+ public static final IpProtocol IP_PROTO_STP = new IpProtocol(IP_PROTO_NUM_STP);
+ public static final IpProtocol IP_PROTO_SRP = new IpProtocol(IP_PROTO_NUM_SRP);
+ public static final IpProtocol IP_PROTO_UTI = new IpProtocol(IP_PROTO_NUM_UTI);
+ public static final IpProtocol IP_PROTO_SMP = new IpProtocol(IP_PROTO_NUM_SMP);
+ public static final IpProtocol IP_PROTO_SM = new IpProtocol(IP_PROTO_NUM_SM);
+ public static final IpProtocol IP_PROTO_PTP = new IpProtocol(IP_PROTO_NUM_PTP);
+ public static final IpProtocol IP_PROTO_IS_IS_OVER_IPv4 = new IpProtocol(IP_PROTO_NUM_IS_IS_OVER_IPv4);
+ public static final IpProtocol IP_PROTO_FIRE = new IpProtocol(IP_PROTO_NUM_FIRE);
+ public static final IpProtocol IP_PROTO_CRTP = new IpProtocol(IP_PROTO_NUM_CRTP);
+ public static final IpProtocol IP_PROTO_CRUDP = new IpProtocol(IP_PROTO_NUM_CRUDP);
+ public static final IpProtocol IP_PROTO_SSCOPMCE = new IpProtocol(IP_PROTO_NUM_SSCOPMCE);
+ public static final IpProtocol IP_PROTO_IPLT = new IpProtocol(IP_PROTO_NUM_IPLT);
+ public static final IpProtocol IP_PROTO_SPS = new IpProtocol(IP_PROTO_NUM_SPS);
+ public static final IpProtocol IP_PROTO_PIPE = new IpProtocol(IP_PROTO_NUM_PIPE);
+ public static final IpProtocol IP_PROTO_SCTP = new IpProtocol(IP_PROTO_NUM_SCTP);
+ public static final IpProtocol IP_PROTO_FC = new IpProtocol(IP_PROTO_NUM_FC);
+ public static final IpProtocol IP_PROTO_RSVP_E2E_IGNORE = new IpProtocol(IP_PROTO_NUM_RSVP_E2E_IGNORE);
+ public static final IpProtocol IP_PROTO_MOBILITY_HEADER = new IpProtocol(IP_PROTO_NUM_MOBILITY_HEADER);
+ public static final IpProtocol IP_PROTO_UDP_LITE = new IpProtocol(IP_PROTO_NUM_UDP_LITE);
+ public static final IpProtocol IP_PROTO_MPLS_IN_IP = new IpProtocol(IP_PROTO_NUM_MPLS_IN_IP);
+ public static final IpProtocol IP_PROTO_MANET = new IpProtocol(IP_PROTO_NUM_MANET);
+ 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);
+
+ private IpProtocol(short version) {
+ this.proto = version;
+ }
+
+
+ @Override
+ public int getLength() {
+ return LENGTH;
+ }
+
+ public static IpProtocol of(short proto) {
+ switch (proto) {
+ case IP_PROTO_NUM_HOPOPT:
+ return IP_PROTO_HOPOPT;
+ case IP_PROTO_NUM_ICMP:
+ return IP_PROTO_ICMP;
+ case IP_PROTO_NUM_IGMP:
+ return IP_PROTO_IGMP;
+ case IP_PROTO_NUM_GGP:
+ return IP_PROTO_GGP;
+ case IP_PROTO_NUM_IPv4:
+ return IP_PROTO_IPv4;
+ case IP_PROTO_NUM_ST:
+ return IP_PROTO_ST;
+ case IP_PROTO_NUM_TCP:
+ return IP_PROTO_TCP;
+ case IP_PROTO_NUM_CBT:
+ return IP_PROTO_CBT;
+ case IP_PROTO_NUM_EGP:
+ return IP_PROTO_EGP;
+ case IP_PROTO_NUM_IGP:
+ return IP_PROTO_IGP;
+ case IP_PROTO_NUM_BBN_RCC_MON:
+ return IP_PROTO_BBN_RCC_MON;
+ case IP_PROTO_NUM_NVP_II:
+ return IP_PROTO_NVP_II;
+ case IP_PROTO_NUM_PUP:
+ return IP_PROTO_PUP;
+ case IP_PROTO_NUM_ARGUS:
+ return IP_PROTO_ARGUS;
+ case IP_PROTO_NUM_EMCON:
+ return IP_PROTO_EMCON;
+ case IP_PROTO_NUM_XNET:
+ return IP_PROTO_XNET;
+ case IP_PROTO_NUM_CHAOS:
+ return IP_PROTO_CHAOS;
+ case IP_PROTO_NUM_UDP:
+ return IP_PROTO_UDP;
+ case IP_PROTO_NUM_MUX:
+ return IP_PROTO_MUX;
+ case IP_PROTO_NUM_DCN_MEAS:
+ return IP_PROTO_DCN_MEAS;
+ case IP_PROTO_NUM_HMP:
+ return IP_PROTO_HMP;
+ case IP_PROTO_NUM_PRM:
+ return IP_PROTO_PRM;
+ case IP_PROTO_NUM_XNS_IDP:
+ return IP_PROTO_XNS_IDP;
+ case IP_PROTO_NUM_TRUNK_1:
+ return IP_PROTO_TRUNK_1;
+ case IP_PROTO_NUM_TRUNK_2:
+ return IP_PROTO_TRUNK_2;
+ case IP_PROTO_NUM_LEAF_1:
+ return IP_PROTO_LEAF_1;
+ case IP_PROTO_NUM_LEAF_2:
+ return IP_PROTO_LEAF_2;
+ case IP_PROTO_NUM_RDP:
+ return IP_PROTO_RDP;
+ case IP_PROTO_NUM_IRTP:
+ return IP_PROTO_IRTP;
+ case IP_PROTO_NUM_ISO_TP4:
+ return IP_PROTO_ISO_TP4;
+ case IP_PROTO_NUM_NETBLT:
+ return IP_PROTO_NETBLT;
+ case IP_PROTO_NUM_MFE_NSP:
+ return IP_PROTO_MFE_NSP;
+ case IP_PROTO_NUM_MERIT_INP:
+ return IP_PROTO_MERIT_INP;
+ case IP_PROTO_NUM_DCCP:
+ return IP_PROTO_DCCP;
+ case IP_PROTO_NUM_3PC:
+ return IP_PROTO_3PC;
+ case IP_PROTO_NUM_IDPR:
+ return IP_PROTO_IDPR;
+ case IP_PROTO_NUM_XTP:
+ return IP_PROTO_XTP;
+ case IP_PROTO_NUM_DDP:
+ return IP_PROTO_DDP;
+ case IP_PROTO_NUM_IDPR_CMTP:
+ return IP_PROTO_IDPR_CMTP;
+ case IP_PROTO_NUM_TP_PP:
+ return IP_PROTO_TP_PP;
+ case IP_PROTO_NUM_IL:
+ return IP_PROTO_IL;
+ case IP_PROTO_NUM_IPv6:
+ return IP_PROTO_IPv6;
+ case IP_PROTO_NUM_SDRP:
+ return IP_PROTO_SDRP;
+ case IP_PROTO_NUM_IPv6_ROUTE:
+ return IP_PROTO_IPv6_ROUTE;
+ case IP_PROTO_NUM_IPv6_FRAG:
+ return IP_PROTO_IPv6_FRAG;
+ case IP_PROTO_NUM_IDRP:
+ return IP_PROTO_IDRP;
+ case IP_PROTO_NUM_RSVP:
+ return IP_PROTO_RSVP;
+ case IP_PROTO_NUM_GRE:
+ return IP_PROTO_GRE;
+ case IP_PROTO_NUM_MHRP:
+ return IP_PROTO_MHRP;
+ case IP_PROTO_NUM_BNA:
+ return IP_PROTO_BNA;
+ case IP_PROTO_NUM_ESP:
+ return IP_PROTO_ESP;
+ case IP_PROTO_NUM_AH:
+ return IP_PROTO_AH;
+ case IP_PROTO_NUM_I_NLSP:
+ return IP_PROTO_I_NLSP;
+ case IP_PROTO_NUM_SWIPE:
+ return IP_PROTO_SWIPE;
+ case IP_PROTO_NUM_NARP:
+ return IP_PROTO_NARP;
+ case IP_PROTO_NUM_MOBILE:
+ return IP_PROTO_MOBILE;
+ case IP_PROTO_NUM_TLSP:
+ return IP_PROTO_TLSP;
+ case IP_PROTO_NUM_SKIP:
+ return IP_PROTO_SKIP;
+ case IP_PROTO_NUM_IPv6_ICMP:
+ return IP_PROTO_IPv6_ICMP;
+ case IP_PROTO_NUM_IPv6_NO_NXT:
+ return IP_PROTO_IPv6_NO_NXT;
+ case IP_PROTO_NUM_IPv6_OPTS:
+ return IP_PROTO_IPv6_OPTS;
+ case IP_PROTO_NUM_HOST_INTERNAL:
+ return IP_PROTO_HOST_INTERNAL;
+ case IP_PROTO_NUM_CFTP:
+ return IP_PROTO_CFTP;
+ case IP_PROTO_NUM_LOCAL_NET:
+ return IP_PROTO_LOCAL_NET;
+ case IP_PROTO_NUM_SAT_EXPAK:
+ return IP_PROTO_SAT_EXPAK;
+ case IP_PROTO_NUM_KRYPTOLAN:
+ return IP_PROTO_KRYPTOLAN;
+ case IP_PROTO_NUM_RVD:
+ return IP_PROTO_RVD;
+ case IP_PROTO_NUM_IPPC:
+ return IP_PROTO_IPPC;
+ case IP_PROTO_NUM_DIST_FS:
+ return IP_PROTO_DIST_FS;
+ case IP_PROTO_NUM_SAT_MON:
+ return IP_PROTO_SAT_MON;
+ case IP_PROTO_NUM_VISA:
+ return IP_PROTO_VISA;
+ case IP_PROTO_NUM_IPCV:
+ return IP_PROTO_IPCV;
+ case IP_PROTO_NUM_CPNX:
+ return IP_PROTO_CPNX;
+ case IP_PROTO_NUM_CPHB:
+ return IP_PROTO_CPHB;
+ case IP_PROTO_NUM_WSN:
+ return IP_PROTO_WSN;
+ case IP_PROTO_NUM_PVP:
+ return IP_PROTO_PVP;
+ case IP_PROTO_NUM_BR_SAT_MON:
+ return IP_PROTO_BR_SAT_MON;
+ case IP_PROTO_NUM_SUN_ND:
+ return IP_PROTO_SUN_ND;
+ case IP_PROTO_NUM_WB_MON:
+ return IP_PROTO_WB_MON;
+ case IP_PROTO_NUM_WB_EXPAK:
+ return IP_PROTO_WB_EXPAK;
+ case IP_PROTO_NUM_ISO_IP:
+ return IP_PROTO_ISO_IP;
+ case IP_PROTO_NUM_VMTP:
+ return IP_PROTO_VMTP;
+ case IP_PROTO_NUM_SECURE_VMTP:
+ return IP_PROTO_SECURE_VMTP;
+ case IP_PROTO_NUM_VINES:
+ return IP_PROTO_VINES;
+ case IP_PROTO_NUM_TTP_IPTM:
+ return IP_PROTO_TTP_IPTM;
+ case IP_PROTO_NUM_NSFNET_IGP:
+ return IP_PROTO_NSFNET_IGP;
+ case IP_PROTO_NUM_DGP:
+ return IP_PROTO_DGP;
+ case IP_PROTO_NUM_TCF:
+ return IP_PROTO_TCF;
+ case IP_PROTO_NUM_EIGRP:
+ return IP_PROTO_EIGRP;
+ case IP_PROTO_NUM_OSPF:
+ return IP_PROTO_OSPF;
+ case IP_PROTO_NUM_Sprite_RPC:
+ return IP_PROTO_Sprite_RPC;
+ case IP_PROTO_NUM_LARP:
+ return IP_PROTO_LARP;
+ case IP_PROTO_NUM_MTP:
+ return IP_PROTO_MTP;
+ case IP_PROTO_NUM_AX_25:
+ return IP_PROTO_AX_25;
+ case IP_PROTO_NUM_IPIP:
+ return IP_PROTO_IPIP;
+ case IP_PROTO_NUM_MICP:
+ return IP_PROTO_MICP;
+ case IP_PROTO_NUM_SCC_SP:
+ return IP_PROTO_SCC_SP;
+ case IP_PROTO_NUM_ETHERIP:
+ return IP_PROTO_ETHERIP;
+ case IP_PROTO_NUM_ENCAP:
+ return IP_PROTO_ENCAP;
+ case IP_PROTO_NUM_PRIVATE_ENCRYPT:
+ return IP_PROTO_PRIVATE_ENCRYPT;
+ case IP_PROTO_NUM_GMTP:
+ return IP_PROTO_GMTP;
+ case IP_PROTO_NUM_IFMP:
+ return IP_PROTO_IFMP;
+ case IP_PROTO_NUM_PNNI:
+ return IP_PROTO_PNNI;
+ case IP_PROTO_NUM_PIM:
+ return IP_PROTO_PIM;
+ case IP_PROTO_NUM_ARIS:
+ return IP_PROTO_ARIS;
+ case IP_PROTO_NUM_SCPS:
+ return IP_PROTO_SCPS;
+ case IP_PROTO_NUM_QNX:
+ return IP_PROTO_QNX;
+ case IP_PROTO_NUM_A_N:
+ return IP_PROTO_A_N;
+ case IP_PROTO_NUM_IP_COMP:
+ return IP_PROTO_IP_COMP;
+ case IP_PROTO_NUM_SNP:
+ return IP_PROTO_SNP;
+ case IP_PROTO_NUM_COMPAQ_PEER:
+ return IP_PROTO_COMPAQ_PEER;
+ case IP_PROTO_NUM_IPX_IN_IP:
+ return IP_PROTO_IPX_IN_IP;
+ case IP_PROTO_NUM_VRRP:
+ return IP_PROTO_VRRP;
+ case IP_PROTO_NUM_PGM:
+ return IP_PROTO_PGM;
+ case IP_PROTO_NUM_ZERO_HOP:
+ return IP_PROTO_ZERO_HOP;
+ case IP_PROTO_NUM_L2TP:
+ return IP_PROTO_L2TP;
+ case IP_PROTO_NUM_DDX:
+ return IP_PROTO_DDX;
+ case IP_PROTO_NUM_IATP:
+ return IP_PROTO_IATP;
+ case IP_PROTO_NUM_STP:
+ return IP_PROTO_STP;
+ case IP_PROTO_NUM_SRP:
+ return IP_PROTO_SRP;
+ case IP_PROTO_NUM_UTI:
+ return IP_PROTO_UTI;
+ case IP_PROTO_NUM_SMP:
+ return IP_PROTO_SMP;
+ case IP_PROTO_NUM_SM:
+ return IP_PROTO_SM;
+ case IP_PROTO_NUM_PTP:
+ return IP_PROTO_PTP;
+ case IP_PROTO_NUM_IS_IS_OVER_IPv4:
+ return IP_PROTO_IS_IS_OVER_IPv4;
+ case IP_PROTO_NUM_FIRE:
+ return IP_PROTO_FIRE;
+ case IP_PROTO_NUM_CRTP:
+ return IP_PROTO_CRTP;
+ case IP_PROTO_NUM_CRUDP:
+ return IP_PROTO_CRUDP;
+ case IP_PROTO_NUM_SSCOPMCE:
+ return IP_PROTO_SSCOPMCE;
+ case IP_PROTO_NUM_IPLT:
+ return IP_PROTO_IPLT;
+ case IP_PROTO_NUM_SPS:
+ return IP_PROTO_SPS;
+ case IP_PROTO_NUM_PIPE:
+ return IP_PROTO_PIPE;
+ case IP_PROTO_NUM_SCTP:
+ return IP_PROTO_SCTP;
+ case IP_PROTO_NUM_FC:
+ return IP_PROTO_FC;
+ case IP_PROTO_NUM_RSVP_E2E_IGNORE:
+ return IP_PROTO_RSVP_E2E_IGNORE;
+ case IP_PROTO_NUM_MOBILITY_HEADER:
+ return IP_PROTO_MOBILITY_HEADER;
+ case IP_PROTO_NUM_UDP_LITE:
+ return IP_PROTO_UDP_LITE;
+ case IP_PROTO_NUM_MPLS_IN_IP:
+ return IP_PROTO_MPLS_IN_IP;
+ case IP_PROTO_NUM_MANET:
+ return IP_PROTO_MANET;
+ case IP_PROTO_NUM_HIP:
+ return IP_PROTO_HIP;
+ case IP_PROTO_NUM_SHIM6:
+ return IP_PROTO_SHIM6;
+ default:
+ if (proto >= MAX_PROTO) {
+ throw new IllegalArgumentException("Illegal IP protocol number: "
+ + proto);
+ } else {
+ return new IpProtocol(proto);
+ }
+ }
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof IpProtocol))
+ return false;
+ IpProtocol o = (IpProtocol)obj;
+ if (o.proto != this.proto)
+ return false;
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 37;
+ int result = 1;
+ result = prime * result + proto;
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return Integer.toHexString(proto);
+ }
+
+ public void writeByte(ChannelBuffer c) {
+ c.writeByte(this.proto);
+ }
+
+ public static IpProtocol readByte(ChannelBuffer c) {
+ return IpProtocol.of(c.readUnsignedByte());
+ }
}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/types/MacAddress.java b/java_gen/pre-written/src/main/java/org/openflow/types/MacAddress.java
index 8806bb3..a18dff3 100644
--- a/java_gen/pre-written/src/main/java/org/openflow/types/MacAddress.java
+++ b/java_gen/pre-written/src/main/java/org/openflow/types/MacAddress.java
@@ -2,7 +2,6 @@
import org.jboss.netty.buffer.ChannelBuffer;
import org.openflow.exceptions.OFParseError;
-import org.openflow.protocol.OFObject;
import org.openflow.util.HexString;
/**
@@ -11,7 +10,7 @@
* @author Andreas Wundsam <andreas.wundsam@bigswitch.com>
*/
-public class MacAddress implements OFObject {
+public class MacAddress implements OFValueType {
static final int MacAddrLen = 6;
private final long rawValue;
@@ -77,17 +76,6 @@
return MacAddrLen;
}
- public static MacAddress readFrom(final ChannelBuffer bb) throws OFParseError {
- long raw = bb.readUnsignedInt() << 16 | bb.readUnsignedShort();
- return MacAddress.of(raw);
- }
-
- @Override
- public void writeTo(final ChannelBuffer bb) {
- bb.writeInt((int) (rawValue >> 16));
- bb.writeShort((int) rawValue & 0xFFFF);
- }
-
@Override
public String toString() {
return HexString.toHexString(rawValue, 6);
@@ -119,4 +107,16 @@
return rawValue;
}
+ public void write6Bytes(ChannelBuffer c) {
+ c.writeInt((int) (this.rawValue >> 16));
+ c.writeShort((int) this.rawValue & 0xFFFF);
+ }
+
+ public static MacAddress read6Bytes(ChannelBuffer c) throws OFParseError {
+ long raw = c.readUnsignedInt() << 16 | c.readUnsignedShort();
+ return MacAddress.of(raw);
+ }
+
+
+
}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/types/MacAddressWithMask.java b/java_gen/pre-written/src/main/java/org/openflow/types/MacAddressWithMask.java
deleted file mode 100644
index ffa5fa7..0000000
--- a/java_gen/pre-written/src/main/java/org/openflow/types/MacAddressWithMask.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.openflow.types;
-
-public class MacAddressWithMask {
-
-}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/types/Masked.java b/java_gen/pre-written/src/main/java/org/openflow/types/Masked.java
index 98a8e0b..011bae8 100644
--- a/java_gen/pre-written/src/main/java/org/openflow/types/Masked.java
+++ b/java_gen/pre-written/src/main/java/org/openflow/types/Masked.java
@@ -1,5 +1,52 @@
package org.openflow.types;
-public class Masked<T> {
+
+public class Masked<T extends OFValueType> implements OFValueType {
+ protected T value;
+ protected T mask;
+
+ protected Masked(T value, T mask) {
+ this.value = value;
+ this.mask = mask;
+ }
+
+ public T getValue() {
+ return value;
+ }
+
+ public T getMask() {
+ return mask;
+ }
+
+ @Override
+ public int getLength() {
+ return this.value.getLength() + this.mask.getLength();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof Masked<?>))
+ return false;
+ Masked<?> mobj = (Masked<?>)obj;
+ return this.value.equals(mobj.value) && this.mask.equals(mobj.mask);
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 59;
+ int result = 1;
+ result = prime * result + this.value.hashCode();
+ result = prime * result + this.mask.hashCode();
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ // General representation: value/mask
+ StringBuilder sb = new StringBuilder();
+ sb.append(value.toString()).append('/').append(mask.toString());
+ return sb.toString();
+ }
+
}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/types/OFPhysicalPort.java b/java_gen/pre-written/src/main/java/org/openflow/types/OFPhysicalPort.java
index 0853fea..d8f71a3 100644
--- a/java_gen/pre-written/src/main/java/org/openflow/types/OFPhysicalPort.java
+++ b/java_gen/pre-written/src/main/java/org/openflow/types/OFPhysicalPort.java
@@ -1,5 +1,8 @@
package org.openflow.types;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.openflow.exceptions.OFParseError;
+
/**
* A wrapper around the OpenFlow physical port description. The interfaces to
* this object are version agnostic.
@@ -7,6 +10,54 @@
* @author capveg
*/
-public class OFPhysicalPort {
+public class OFPhysicalPort implements OFValueType {
+
+ static final int LENGTH = 4;
+
+ private final int port;
+
+ 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);
+ }
+
+ public static OFPhysicalPort read4Bytes(ChannelBuffer c) throws OFParseError {
+ return OFPhysicalPort.of((int)(c.readUnsignedInt() & 0xFFFFFFFF));
+ }
}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/types/OFPort.java b/java_gen/pre-written/src/main/java/org/openflow/types/OFPort.java
index 4156f1f..3272660 100644
--- a/java_gen/pre-written/src/main/java/org/openflow/types/OFPort.java
+++ b/java_gen/pre-written/src/main/java/org/openflow/types/OFPort.java
@@ -1,6 +1,8 @@
package org.openflow.types;
+import org.jboss.netty.buffer.ChannelBuffer;
import org.openflow.annotations.Immutable;
+import org.openflow.exceptions.OFParseError;
/**
* Abstraction of an logical / OpenFlow switch port (ofp_port_no) in OpenFlow.
@@ -13,7 +15,9 @@
* @author Andreas Wundsam <andreas.wundsam@bigswitch.com>
*/
@Immutable
-public class OFPort {
+public class OFPort implements OFValueType {
+ 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_ANY_INT = 0xFFffFFff;
@@ -488,4 +492,42 @@
}
}
+ @Override
+ public int getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof OFPort))
+ return false;
+ OFPort other = (OFPort)obj;
+ if (other.portNumber != this.portNumber)
+ return false;
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 53;
+ int result = 1;
+ result = prime * result + portNumber;
+ return result;
+ }
+
+ public void write2Bytes(ChannelBuffer c) {
+ c.writeShort(this.portNumber);
+ }
+
+ public static OFPort read2Bytes(ChannelBuffer c) throws OFParseError {
+ return OFPort.of((c.readUnsignedShort() & 0x0FFFF));
+ }
+
+ public void write4Bytes(ChannelBuffer c) {
+ c.writeInt(this.portNumber);
+ }
+
+ public static OFPort read4Bytes(ChannelBuffer c) throws OFParseError {
+ return OFPort.of((int)(c.readUnsignedInt() & 0xFFFFFFFF));
+ }
}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/types/OFValueType.java b/java_gen/pre-written/src/main/java/org/openflow/types/OFValueType.java
new file mode 100644
index 0000000..51c8b36
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/openflow/types/OFValueType.java
@@ -0,0 +1,10 @@
+package org.openflow.types;
+
+
+
+
+public interface OFValueType {
+
+ public int getLength();
+
+}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/types/TransportPort.java b/java_gen/pre-written/src/main/java/org/openflow/types/TransportPort.java
new file mode 100644
index 0000000..cecb349
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/openflow/types/TransportPort.java
@@ -0,0 +1,66 @@
+package org.openflow.types;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.openflow.exceptions.OFParseError;
+
+/**
+ * Represents L4 (Transport Layer) port (TCP, UDP, etc.)
+ *
+ * @author Yotam Harchol (yotam.harchol@bigswitch.com)
+ */
+public class TransportPort implements OFValueType {
+
+ static final int LENGTH = 2;
+ static final int MAX_PORT = 0xFFFF;
+ static final int MIN_PORT = 0;
+
+ private final int port;
+
+ private TransportPort(int port) {
+ this.port = port;
+ }
+
+ public static TransportPort of(int port) {
+ if (port < MIN_PORT || port > MAX_PORT) {
+ throw new IllegalArgumentException("Illegal transport layer port number: " + port);
+ }
+ return new TransportPort(port);
+ }
+
+ @Override
+ public int getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof TransportPort))
+ return false;
+ TransportPort other = (TransportPort)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.toString(port);
+ }
+
+ public void write2Bytes(ChannelBuffer c) {
+ c.writeShort(this.port);
+ }
+
+ public static TransportPort read2Bytes(ChannelBuffer c) throws OFParseError {
+ return TransportPort.of((c.readUnsignedShort() & 0x0FFFF));
+ }
+
+}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/types/VlanPcp.java b/java_gen/pre-written/src/main/java/org/openflow/types/VlanPcp.java
index bda2dc1..2f406c8 100644
--- a/java_gen/pre-written/src/main/java/org/openflow/types/VlanPcp.java
+++ b/java_gen/pre-written/src/main/java/org/openflow/types/VlanPcp.java
@@ -1,5 +1,61 @@
package org.openflow.types;
-public class VlanPcp {
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.openflow.exceptions.OFParseError;
+public class VlanPcp implements OFValueType {
+
+ private static final byte VALIDATION_MASK = 0x07;
+ static final int LENGTH = 1;
+
+ private final byte pcp;
+
+ private VlanPcp(byte pcp) {
+ this.pcp = pcp;
+ }
+
+ public static VlanPcp of(byte pcp) {
+ if ((pcp & VALIDATION_MASK) != pcp)
+ throw new IllegalArgumentException("Illegal VLAN PCP value: " + pcp);
+ return new VlanPcp(pcp);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof VlanPcp))
+ return false;
+ VlanPcp other = (VlanPcp)obj;
+ if (other.pcp != this.pcp)
+ return false;
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int prime = 20173;
+ return this.pcp * prime;
+ }
+
+ @Override
+ public String toString() {
+ return "0x" + Integer.toHexString(pcp);
+ }
+
+ public byte getValue() {
+ return pcp;
+ }
+
+ @Override
+ public int getLength() {
+ return LENGTH;
+ }
+
+ public void writeByte(ChannelBuffer c) {
+ c.writeShort(this.pcp);
+ }
+
+ public static VlanPcp readByte(ChannelBuffer c) throws OFParseError {
+ return VlanPcp.of((byte)(c.readUnsignedByte() & 0xFF));
+ }
+
}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/types/VlanVid.java b/java_gen/pre-written/src/main/java/org/openflow/types/VlanVid.java
index 0f9eaf7..a2b38b2 100644
--- a/java_gen/pre-written/src/main/java/org/openflow/types/VlanVid.java
+++ b/java_gen/pre-written/src/main/java/org/openflow/types/VlanVid.java
@@ -1,5 +1,77 @@
package org.openflow.types;
-public class VlanVid {
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.openflow.exceptions.OFParseError;
+public class VlanVid implements OFValueType {
+
+ private static final short VALIDATION_MASK = 0x0FFF;
+ final static int LENGTH = 2;
+
+ private final short vid;
+
+ private VlanVid(short vid) {
+ this.vid = vid;
+ }
+
+ public static VlanVid of(short vid) {
+ if ((vid & VALIDATION_MASK) != vid)
+ throw new IllegalArgumentException("Illegal VLAN VID value: " + vid);
+ return new VlanVid(vid);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof VlanVid))
+ return false;
+ VlanVid other = (VlanVid)obj;
+ if (other.vid != this.vid)
+ return false;
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int prime = 13873;
+ return this.vid * prime;
+ }
+
+ @Override
+ public String toString() {
+ return "0x" + Integer.toHexString(vid);
+ }
+
+ public short getValue() {
+ return vid;
+ }
+
+ @Override
+ public int getLength() {
+ return LENGTH;
+ }
+
+
+ volatile byte[] bytesCache = null;
+
+ public byte[] getBytes() {
+ if (bytesCache == null) {
+ synchronized (this) {
+ if (bytesCache == null) {
+ bytesCache =
+ new byte[] { (byte) ((vid >>> 8) & 0xFF),
+ (byte) ((vid >>> 0) & 0xFF) };
+ }
+ }
+ }
+ return bytesCache;
+ }
+
+ public void write2Bytes(ChannelBuffer c) {
+ c.writeShort(this.vid);
+ }
+
+ public VlanVid read2Bytes(ChannelBuffer c) throws OFParseError {
+ return VlanVid.of(c.readShort());
+ }
+
}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/types/VlanVidWithMask/VlanVidWithMask.java b/java_gen/pre-written/src/main/java/org/openflow/types/VlanVidWithMask/VlanVidWithMask.java
deleted file mode 100644
index 610b11c..0000000
--- a/java_gen/pre-written/src/main/java/org/openflow/types/VlanVidWithMask/VlanVidWithMask.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.openflow.types.VlanVidWithMask;
-
-public class VlanVidWithMask {
-
-}
diff --git a/java_gen/pre-written/src/test/java/org/openflow/types/IPv4Test.java b/java_gen/pre-written/src/test/java/org/openflow/types/IPv4Test.java
index b19233c..d344021 100644
--- a/java_gen/pre-written/src/test/java/org/openflow/types/IPv4Test.java
+++ b/java_gen/pre-written/src/test/java/org/openflow/types/IPv4Test.java
@@ -42,6 +42,27 @@
"1.x.3.4",
"1.2x.3.4"
};
+
+ String[] ipsWithMask = {
+ "1.2.3.4/24",
+ "192.168.130.140/255.255.192.0",
+ "127.0.0.1/8",
+ "8.8.8.8",
+ };
+
+ boolean[] hasMask = {
+ true,
+ true,
+ true,
+ false
+ };
+
+ byte[][][] ipsWithMaskValues = {
+ new byte[][] { new byte[] { (byte)0x01, (byte)0x02, (byte)0x03, (byte)0x04 }, new byte[] { (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0x00 } },
+ new byte[][] { new byte[] { (byte)0xC0, (byte)0xA8, (byte)0x82, (byte)0x8C }, new byte[] { (byte)0xFF, (byte)0xFF, (byte)0xC0, (byte)0x00 } },
+ new byte[][] { new byte[] { (byte)0x7F, (byte)0x00, (byte)0x00, (byte)0x01 }, new byte[] { (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x00 } },
+ new byte[][] { new byte[] { (byte)0x08, (byte)0x08, (byte)0x08, (byte)0x08 }, null }
+ };
@Test
@@ -67,7 +88,7 @@
@Test
public void testReadFrom() throws OFParseError, OFShortRead {
for(int i=0; i < testAddresses.length; i++ ) {
- IPv4 ip = IPv4.readFrom(ChannelBuffers.copiedBuffer(testAddresses[i]));
+ IPv4 ip = IPv4.read4Bytes(ChannelBuffers.copiedBuffer(testAddresses[i]));
assertEquals(testInts[i], ip.getInt());
assertArrayEquals(testAddresses[i], ip.getBytes());
assertEquals(testStrings[i], ip.toString());
@@ -86,4 +107,31 @@
}
}
}
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testOfPossiblyMasked() throws OFParseError, OFShortRead {
+ for (int i = 0; i < ipsWithMask.length; i++) {
+ OFValueType value = IPv4WithMask.ofPossiblyMasked(ipsWithMask[i]);
+ if (value instanceof IPv4 && !hasMask[i]) {
+ // Types OK, check values
+ IPv4 ip = (IPv4)value;
+ assertArrayEquals(ipsWithMaskValues[i][0], ip.getBytes());
+ } else if (value instanceof Masked && hasMask[i]) {
+ Masked<IPv4> ip = null;
+ try {
+ ip = (Masked<IPv4>)value;
+ } catch (ClassCastException e) {
+ fail("Invalid Masked<T> type.");
+ }
+ // Types OK, check values
+ assertArrayEquals(ipsWithMaskValues[i][0], ip.getValue().getBytes());
+ assertArrayEquals(ipsWithMaskValues[i][1], ip.getMask().getBytes());
+ } else if (value instanceof IPv4) {
+ fail("Expected masked IPv4, got unmasked IPv4.");
+ } else {
+ fail("Expected unmasked IPv4, got masked IPv4.");
+ }
+ }
+ }
}
diff --git a/java_gen/pre-written/src/test/java/org/openflow/types/IPv6Test.java b/java_gen/pre-written/src/test/java/org/openflow/types/IPv6Test.java
index e3d5c81..f2f6fe8 100644
--- a/java_gen/pre-written/src/test/java/org/openflow/types/IPv6Test.java
+++ b/java_gen/pre-written/src/test/java/org/openflow/types/IPv6Test.java
@@ -21,6 +21,72 @@
"ffe0::",
"1:2:3:4:5:6:7:8"
};
+
+ String[] ipsWithMask = {
+ "1::1/80",
+ "1:2:3:4::/ffff:ffff:ffff:ff00::",
+ "ffff:ffee:1::/ff00:ff00:ff00:ff00::",
+ "8:8:8:8:8:8:8:8",
+ };
+
+ byte[][] masks = {
+ new byte[] { (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff,
+ (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff,
+ (byte)0xff, (byte)0xff, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00 },
+ new byte[] { (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff,
+ (byte)0xff, (byte)0xff, (byte)0xff, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00 },
+ new byte[] { (byte)0xff, (byte)0x00, (byte)0xff, (byte)0x00,
+ (byte)0xff, (byte)0x00, (byte)0xff, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00 },
+ new byte[] { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00 }
+ };
+
+ boolean[] hasMask = {
+ true,
+ true,
+ true,
+ false
+ };
+
+ @Test
+ public void testMasked() throws UnknownHostException {
+ for(int i=0; i < ipsWithMask.length; i++ ) {
+ OFValueType value = IPv6WithMask.ofPossiblyMasked(ipsWithMask[i]);
+ if (value instanceof IPv6 && !hasMask[i]) {
+ // Types OK, check values
+ IPv6 ip = (IPv6)value;
+ InetAddress inetAddress = InetAddress.getByName(ipsWithMask[i]);
+
+ assertArrayEquals(ip.getBytes(), inetAddress.getAddress());
+ assertEquals(ipsWithMask[i], ip.toString());
+ } else if (value instanceof IPv6WithMask && hasMask[i]) {
+ IPv6WithMask ip = null;
+ try {
+ ip = (IPv6WithMask)value;
+ } catch (ClassCastException e) {
+ fail("Invalid Masked<T> type.");
+ }
+ // Types OK, check values
+ InetAddress inetAddress = InetAddress.getByName(ipsWithMask[i].substring(0, ipsWithMask[i].indexOf('/')));
+
+ assertArrayEquals(ip.value.getBytes(), inetAddress.getAddress());
+ assertEquals(ipsWithMask[i].substring(0, ipsWithMask[i].indexOf('/')), ip.value.toString());
+ assertArrayEquals(masks[i], ip.mask.getBytes());
+ } else if (value instanceof IPv6) {
+ fail("Expected masked IPv6, got unmasked IPv6.");
+ } else {
+ fail("Expected unmasked IPv6, got masked IPv6.");
+ }
+ }
+ }
+
@Test
public void testOfString() throws UnknownHostException {
@@ -47,7 +113,7 @@
public void testReadFrom() throws OFParseError, OFShortRead, UnknownHostException {
for(int i=0; i < testStrings.length; i++ ) {
byte[] bytes = Inet6Address.getByName(testStrings[i]).getAddress();
- IPv6 ip = IPv6.readFrom(ChannelBuffers.copiedBuffer(bytes));
+ IPv6 ip = IPv6.read16Bytes(ChannelBuffers.copiedBuffer(bytes));
assertEquals(testStrings[i], ip.toString());
assertArrayEquals(bytes, ip.getBytes());
}
diff --git a/java_gen/pre-written/src/test/java/org/openflow/types/MacAddressTest.java b/java_gen/pre-written/src/test/java/org/openflow/types/MacAddressTest.java
index af86d9b..78728e1 100644
--- a/java_gen/pre-written/src/test/java/org/openflow/types/MacAddressTest.java
+++ b/java_gen/pre-written/src/test/java/org/openflow/types/MacAddressTest.java
@@ -64,7 +64,7 @@
@Test
public void testReadFrom() throws OFParseError, OFShortRead {
for(int i=0; i < testAddresses.length; i++ ) {
- MacAddress ip = MacAddress.readFrom(ChannelBuffers.copiedBuffer(testAddresses[i]));
+ MacAddress ip = MacAddress.read6Bytes(ChannelBuffers.copiedBuffer(testAddresses[i]));
assertEquals(testInts[i], ip.getLong());
assertArrayEquals(testAddresses[i], ip.getBytes());
assertEquals(testStrings[i], ip.toString());