Merge branch 'master' of github.com:andi-bigswitch/loxigen
diff --git a/java_gen/codegen.py b/java_gen/codegen.py
index 07b910a..f3619d4 100644
--- a/java_gen/codegen.py
+++ b/java_gen/codegen.py
@@ -108,13 +108,23 @@
""" Create the OF classes with implementations for each of the interfaces and versions """
for interface in self.java_model.interfaces:
for java_class in interface.versioned_classes:
- if not self.java_model.generate_class(java_class):
- continue
- self.render_class(clazz=java_class,
- template='of_class.java', version=java_class.version, msg=java_class,
- impl_class=java_class.name)
+ if self.java_model.generate_class(java_class):
+ if not java_class.is_virtual:
+ self.render_class(clazz=java_class,
+ template='of_class.java', version=java_class.version, msg=java_class,
+ impl_class=java_class.name)
- self.create_unit_test(java_class.unit_test)
+ self.create_unit_test(java_class.unit_test)
+ else:
+ disc = java_class.discriminator
+ if disc:
+ self.render_class(clazz=java_class,
+ template='of_virtual_class.java', version=java_class.version, msg=java_class,
+ impl_class=java_class.name, model=self.java_model)
+ else:
+ print "Class %s virtual but no discriminator" % java_class.name
+ else:
+ print "Class %s ignored by generate_class" % java_class.name
def create_unit_test(self, unit_test):
if unit_test.has_test_data:
diff --git a/java_gen/java_model.py b/java_gen/java_model.py
index a118fdf..4ac497f 100644
--- a/java_gen/java_model.py
+++ b/java_gen/java_model.py
@@ -48,8 +48,8 @@
class JavaModel(object):
enum_blacklist = set(("OFDefinitions",))
enum_entry_blacklist = defaultdict(lambda: set(), OFFlowWildcards=set([ "NW_DST_BITS", "NW_SRC_BITS", "NW_SRC_SHIFT", "NW_DST_SHIFT" ]))
- write_blacklist = defaultdict(lambda: set(), OFOxm=set(('typeLen',)), OFAction=set(('type',)), OFInstruction=set(('type',)))
- virtual_interfaces = set(['OFOxm', 'OFAction', 'OFInstruction' ])
+ write_blacklist = defaultdict(lambda: set(), OFOxm=set(('typeLen',)), OFAction=set(('type',)), OFInstruction=set(('type',)), OFFlowMod=set(('command', )))
+ virtual_interfaces = set(['OFOxm', 'OFInstruction', 'OFFlowMod', 'OFBsnVport' ])
@property
@memoize
@@ -78,6 +78,11 @@
@property
@memoize
+ def all_classes(self):
+ return [clazz for interface in self.interfaces for clazz in interface.versioned_classes]
+
+ @property
+ @memoize
def enums(self):
name_version_enum_map = OrderedDefaultDict(lambda: OrderedDict())
@@ -109,12 +114,11 @@
members=self.interfaces)
def generate_class(self, clazz):
- if clazz.interface.is_virtual:
- return False
- if clazz.interface.name == "OFTableMod":
- return False
if clazz.interface.name.startswith("OFMatchV"):
return True
+ elif clazz.name == "OFTableModVer10":
+ # tablemod ver 10 is a hack and has no oftype defined
+ return False
if loxi_utils.class_is_message(clazz.interface.c_name):
return True
if loxi_utils.class_is_oxm(clazz.interface.c_name):
@@ -124,7 +128,7 @@
if loxi_utils.class_is_instruction(clazz.interface.c_name):
return True
else:
- return False
+ return True
class OFFactory(namedtuple("OFFactory", ("package", "name", "members"))):
@@ -186,7 +190,7 @@
def __init__(self, c_name, version_map):
self.c_name = c_name
self.version_map = version_map
- self.name = java_type.name_c_to_caps_camel(c_name)
+ self.name = java_type.name_c_to_caps_camel(c_name) if c_name != "of_header" else "OFMessage"
self.variable_name = self.name[2].lower() + self.name[3:]
self.constant_name = c_name.upper().replace("OF_", "")
@@ -198,20 +202,39 @@
self.parent_interface = None
def class_info(self):
- if re.match(r'OFFlow(Add|Modify(Strict)?|Delete(Strict)?)$', self.name):
+ if re.match(r'OF.+StatsRequest$', self.name):
+ return ("", "OFStatsRequest")
+ elif re.match(r'OF.+StatsReply$', self.name):
+ return ("", "OFStatsReply")
+ elif re.match(r'OFFlow(Add|Modify(Strict)?|Delete(Strict)?)$', self.name):
return ("", "OFFlowMod")
+ elif loxi_utils.class_is_message(self.c_name) and re.match(r'OFBsn.+$', self.name):
+ return ("", "OFBsnHeader")
+ elif loxi_utils.class_is_message(self.c_name) and re.match(r'OFNicira.+$', self.name):
+ return ("", "OFNiciraHeader")
elif re.match(r'OFMatch.*', self.name):
return ("", "Match")
elif loxi_utils.class_is_message(self.c_name):
return ("", "OFMessage")
elif loxi_utils.class_is_action(self.c_name):
- return ("action", "OFAction")
+ if re.match(r'OFActionBsn.*', self.name):
+ return ("action", "OFActionBsn")
+ elif re.match(r'OFActionNicira.*', self.name):
+ return ("action", "OFActionNicira")
+ else:
+ return ("action", "OFAction")
+ elif re.match(r'OFBsnVport.+$', self.name):
+ return ("", "OFBsnVport")
elif loxi_utils.class_is_oxm(self.c_name):
return ("oxm", "OFOxm")
elif loxi_utils.class_is_instruction(self.c_name):
return ("instruction", "OFInstruction")
elif loxi_utils.class_is_meter_band(self.c_name):
return ("meterband", "OFMeterBand")
+ elif loxi_utils.class_is_queue_prop(self.c_name):
+ return ("queueprop", "OFQueueProp")
+ elif loxi_utils.class_is_hello_elem(self.c_name):
+ return ("", "OFHelloElem")
else:
return ("", None)
@@ -235,7 +258,7 @@
@property
@memoize
def is_virtual(self):
- return self.name in model.virtual_interfaces
+ return self.name in model.virtual_interfaces or all(ir_class.virtual for ir_class in self.version_map.values())
@property
def is_universal(self):
@@ -255,9 +278,6 @@
@property
@memoize
def versioned_classes(self):
- if self.is_virtual:
- return []
- else:
return [ self.versioned_class(version) for version in self.all_versions ]
#######################################################################
@@ -448,6 +468,10 @@
return isinstance(self.member, OFFieldLengthMember)
@property
+ def is_discriminator(self):
+ return isinstance(self.member, OFDiscriminatorMember)
+
+ @property
def is_length_value(self):
return isinstance(self.member, OFLengthMember)
@@ -471,10 +495,18 @@
return self.msg.version.int_version
elif self.name == "length" or self.name == "len":
return self.msg.length
- elif self.java_type.public_type in ("int", "short", "byte") and self.member.value > 100:
- return "0x%x" % self.member.value
else:
- return self.member.value
+ return self.java_type.format_value(self.member.value)
+
+ @property
+ def priv_value(self):
+ if self.name == "version":
+ return self.msg.version.int_version
+ elif self.name == "length" or self.name == "len":
+ return self.msg.length
+ else:
+ return self.java_type.format_value(self.member.value, pub_type=False)
+
@property
def is_writeable(self):
diff --git a/java_gen/java_type.py b/java_gen/java_type.py
index 75bde01..38ce1ff 100644
--- a/java_gen/java_type.py
+++ b/java_gen/java_type.py
@@ -1,3 +1,4 @@
+import loxi_utils.loxi_utils as loxi_utils
import os
import errno
import re
@@ -22,6 +23,30 @@
java_primitive_types = set("byte char short int long".split(" "))
+java_primitives_info = {
+ 'byte' : (True, 8),
+ 'char' : (False, 16),
+ 'short' : (True, 16),
+ 'int' : (True, 32),
+ 'long' : (True, 64),
+}
+
+def format_primitive_value(t, value):
+ signed, bits = java_primitives_info[t]
+ max = (1 << bits)-1
+ if value > max:
+ raise Exception("Value %d to large for type %s" % (value, t))
+
+ if signed:
+ max_pos = (1 << (bits-1)) - 1
+
+ if value > max_pos:
+ if t == "long":
+ return str((1 << bits) - value)
+ else:
+ return "(%s) 0x%x" % (t, value)
+ else:
+ return "0x%x" % value
ANY = 0xFFFFFFFFFFFFFFFF
@@ -50,24 +75,18 @@
# 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)
+ def op(self, version=ANY, read=None, write=None, pub_type=ANY):
+ pub_types = [ pub_type ] if pub_type is not ANY else [ False, True ]
+ for pub_type in pub_types:
+ self.ops[(version,pub_type)] = VersionOp(version, read, write)
return self
- def cast(self, min):
- """ declares that the value has to be cast to itself for values >= min.
- This is to deal with Java signedness """
- def format_cast_value(value):
- if value >= min:
- return "(%s) 0x%x" % (self.pub_type, value)
- else:
- return "0x%x" % (value)
-
- self.format_value = format_cast_value
- return self
-
- def format_value(self, value):
- return value
+ def format_value(self, value, pub_type=True):
+ t = self.pub_type if pub_type else self.priv_type
+ if t in java_primitive_types:
+ return format_primitive_value(t, value)
+ else:
+ return value
@property
def public_type(self):
@@ -82,16 +101,16 @@
""" Is the private type different from the public one?"""
return self.pub_type != self.priv_type
- def read_op(self, version=None, length=None):
+ def read_op(self, version=None, length=None, pub_type=True):
if length is None:
- length = "length - bb.readerIndex()";
+ length = "length - (bb.readerIndex() - start)";
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 (ver, pub_type) in self.ops:
+ _read_op = self.ops[(ver, pub_type)].read or self.ops[(ANY, pub_type)].read
+ elif (ANY, pub_type) in self.ops:
+ _read_op = self.ops[(ANY, pub_type)].read
if _read_op is None:
_read_op = 'ChannelUtilsVer$version.read%s(bb)' % self.pub_type
if callable(_read_op):
@@ -99,13 +118,13 @@
else:
return _read_op.replace("$length", str(length)).replace("$version", version.of_version)
- def write_op(self, version=None, name=None):
+ def write_op(self, version=None, name=None, pub_type=True):
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 (ver, pub_type) in self.ops:
+ _write_op = self.ops[(ver, pub_type)].write or self.ops[(ANY, pub_type)].write
+ elif (ANY, pub_type) in self.ops:
+ _write_op = self.ops[(ANY, pub_type)].write
if _write_op is None:
_write_op = 'ChannelUtilsVer$version.write%s(bb, $name)' % self.pub_type
if callable(_write_op):
@@ -113,6 +132,9 @@
else:
return _write_op.replace("$name", str(name)).replace("$version", version.of_version)
+ def skip_op(self, version=None, length=None):
+ return self.read_op(version, length)
+
@property
def is_primitive(self):
return self.pub_type in java_primitive_types
@@ -125,55 +147,52 @@
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)')
+ .op(read='ChannelUtils.readList(bb, $length, U8.READER)', write='ChannelUtils.writeList(bb, $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)')
+ .op(read='ChannelUtils.readList(bb, $length, U32.READER)', write='ChannelUtils.writeList(bb, $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='ChannelUtilsVer$version.readBytes(bb, 1)', write='ChannelUtilsVer$version.writeBytes(bb, $name)')
+ .op(read='ChannelUtils.readBytes(bb, 1)', write='bb.writeBytes($name)')
two_byte_array = JType('byte[]', size=2) \
- .op(read='ChannelUtilsVer$version.readBytes(bb, 2)', write='ChannelUtilsVer$version.writeBytes(bb, $name)')
+ .op(read='ChannelUtils.readBytes(bb, 2)', write='bb.writeBytes($name)')
three_byte_array = JType('byte[]', size=3) \
- .op(read='ChannelUtilsVer$version.readBytes(bb, 3)', write='ChannelUtilsVer$version.writeBytes(bb, $name)')
+ .op(read='ChannelUtils.readBytes(bb, 3)', write='bb.writeBytes($name)')
four_byte_array = JType('byte[]', size=4) \
- .op(read='ChannelUtilsVer$version.readBytes(bb, 4)', write='ChannelUtilsVer$version.writeBytes(bb, $name)')
+ .op(read='ChannelUtils.readBytes(bb, 4)', write='bb.writeBytes($name)')
five_byte_array = JType('byte[]', size=5) \
- .op(read='ChannelUtilsVer$version.readBytes(bb, 5)', write='ChannelUtilsVer$version.writeBytes(bb, $name)')
+ .op(read='ChannelUtils.readBytes(bb, 5)', write='bb.writeBytes($name)')
six_byte_array = JType('byte[]', size=6) \
- .op(read='ChannelUtilsVer$version.readBytes(bb, 6)', write='ChannelUtilsVer$version.writeBytes(bb, $name)')
+ .op(read='ChannelUtils.readBytes(bb, 6)', write='bb.writeBytes($name)')
seven_byte_array = JType('byte[]', size=7) \
- .op(read='ChannelUtilsVer$version.readBytes(bb, 7)', write='ChannelUtilsVer$version.writeBytes(bb, $name)')
-actions_list = JType('List<OFAction>', size='ChannelUtilsVer$version.calcListSize($name)') \
- .op(read='ChannelUtilsVer$version.readActionsList(bb, $length)', write='ChannelUtilsVer$version.writeActionsList(bb, $name);')
-instructions_list = JType('List<OFInstruction>', size='ChannelUtilsVer$version.calcListSize($name)') \
- .op(read='ChannelUtilsVer$version.readInstructionsList(bb, $length)', \
- write='ChannelUtilsVer$version.writeList(bb, $name)')
+ .op(read='ChannelUtils.readBytes(bb, 7)', write='bb.writeBytes($name)')
+actions_list = JType('List<OFAction>') \
+ .op(read='ChannelUtils.readList(bb, $length, OFActionVer$version.READER)', write='ChannelUtils.writeList(bb, $name);')
+instructions_list = JType('List<OFInstruction>') \
+ .op(read='ChannelUtils.readList(bb, $length, OFInstructionVer$version.READER)', \
+ write='ChannelUtils.writeList(bb, $name)')
buckets_list = JType('List<OFBucket>', size='ChannelUtilsVer$version.calcListSize($name)') \
- .op(read='ChannelUtilsVer$version.readBucketList(bb, $length)', \
- write='ChannelUtilsVer$version.writeList(bb, $name)')
+ .op(read='ChannelUtils.readList(bb, $length, OFBucketVer$version.READER)', write='ChannelUtils.writeList(bb, $name)')
port_desc_list = JType('List<OFPhysicalPort>', size='ChannelUtilsVer$version.calcListSize($name)') \
- .op(read='ChannelUtilsVer$version.readPhysicalPortList(bb, $length)', \
- write='ChannelUtilsVer$version.writePhysicalPortList(bb, $name)')
+ .op(read='ChannelUtils.readList(bb, $length, OFPhysicalPort.READER)', write='ChannelUtils.writeList(bb, $name)')
port_desc = JType('OFPortDesc', size='$name.getLength()') \
- .op(read='null; // TODO OFPortDescVer$version.READER.read(bb)', \
+ .op(read='OFPortDescVer$version.READER.readFrom(bb)', \
write='$name.writeTo(bb)')
packet_queue_list = JType('List<OFPacketQueue>', size='ChannelUtilsVer$version.calcListSize($name)') \
- .op(read='ChannelUtilsVer$version.readPacketQueueList(bb, $length)', \
- write='ChannelUtilsVer$version.writeList(bb, $name)')
+ .op(read='ChannelUtils.readList(bb, $length, OFPacketQueueVer$version.READER)', write='ChannelUtils.writeList(bb, $name);')
octets = JType('byte[]', size="$length") \
- .op(read='ChannelUtilsVer$version.readBytes(bb, $length)', \
+ .op(read='ChannelUtils.readBytes(bb, $length)', \
write='bb.writeBytes($name)')
of_match = JType('Match', size="$name.getLength()") \
.op(read='ChannelUtilsVer$version.readOFMatch(bb)', \
- write='ChannelUtilsVer$version.writeOFMatch(bb, $name)')
+ write='$name.writeTo(bb)');
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)")
@@ -181,17 +200,17 @@
.op(read="MacAddress.read6Bytes(bb)", \
write="$name.write6Bytes(bb)")
port_name = JType('String', size=16) \
- .op(read='ChannelUtilsVer$version.readFixedLengthString(bb, 16)', \
- write='ChannelUtilsVer$version.writeFixedLengthString(bb, $name, 16)')
+ .op(read='ChannelUtils.readFixedLengthString(bb, 16)', \
+ write='ChannelUtils.writeFixedLengthString(bb, $name, 16)')
desc_str = JType('String', size=256) \
- .op(read='ChannelUtilsVer$version.readFixedLengthString(bb, 256)', \
- write='ChannelUtilsVer$version.writeFixedLengthString(bb, $name, 256)')
+ .op(read='ChannelUtils.readFixedLengthString(bb, 256)', \
+ write='ChannelUtils.writeFixedLengthString(bb, $name, 256)')
serial_num = JType('String', size=32) \
- .op(read='ChannelUtilsVer$version.readFixedLengthString(bb, 32)', \
- write='ChannelUtilsVer$version.writeFixedLengthString(bb, $name, 32)')
+ .op(read='ChannelUtils.readFixedLengthString(bb, 32)', \
+ write='ChannelUtils.writeFixedLengthString(bb, $name, 32)')
table_name = JType('String', size=32) \
- .op(read='ChannelUtilsVer$version.readFixedLengthString(bb, 32)', \
- write='ChannelUtilsVer$version.writeFixedLengthString(bb, $name, 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)")
@@ -200,6 +219,15 @@
write="$name.write16Bytes(bb)")
packetin_reason = JType("OFPacketInReason")\
.op(read="OFPacketInReasonSerializerVer$version.readFrom(bb)", write="OFPacketInReasonSerializerVer$version.writeTo(bb, $name)")
+wildcards = JType("Wildcards")\
+ .op(read="Wildcards.of(bb.readInt())", write="bb.writeInt($name.getInt())");
+transport_port = JType("TransportPort")\
+ .op(read="TransportPort.read2Bytes(bb)", write="$name.write2Bytes(bb)")
+oxm = JType("OFOxm")\
+ .op(read="OFOxmVer$version.READER.readFrom(bb)", write="$name.writeTo(bb)")
+meter_features = JType("OFMeterFeatures")\
+ .op(read="OFMeterFeaturesVer$version.READER.readFrom(bb)", write="$name.writeTo(bb)")
+
default_mtype_to_jtype_convert_map = {
'uint8_t' : u8,
@@ -232,7 +260,9 @@
'of_table_name_t': table_name,
'of_ipv4_t': ipv4,
'of_ipv6_t': ipv6,
- 'of_wc_bmap_t': JType("Wildcards")
+ 'of_wc_bmap_t': wildcards,
+ 'of_oxm_t': oxm,
+ 'of_meter_features_t': meter_features,
}
## This is where we drop in special case handling for certain types
@@ -241,14 +271,17 @@
'data' : octets,
'reason': packetin_reason
},
+ 'of_oxm_tcp_src' : {
+ 'value' : transport_port
+ },
}
enum_wire_types = {
- "uint8_t": JType("byte").op(read="bb.readByte()", write="bb.writeByte($name)").cast(min=1<<7),
- "uint16_t": JType("short").op(read="bb.readShort()", write="bb.writeShort($name)").cast(min=1<<15),
- "uint32_t": JType("int").op(read="bb.readInt()", write="bb.writeInt($name)").cast(min=1<<31),
- "uint64_t": JType("long").op(read="bb.readLong()", write="bb.writeLong($name)").cast(min=1<<31)
+ "uint8_t": JType("byte").op(read="bb.readByte()", write="bb.writeByte($name)"),
+ "uint16_t": JType("short").op(read="bb.readShort()", write="bb.writeShort($name)"),
+ "uint32_t": JType("int").op(read="bb.readInt()", write="bb.writeInt($name)"),
+ "uint64_t": JType("long").op(read="bb.readLong()", write="bb.writeLong($name)"),
}
def convert_enum_wire_type_to_jtype(wire_type):
@@ -261,20 +294,21 @@
base_name = m.group(1)
java_base_name = name_c_to_caps_camel(base_name)
return JType("List<OF%s>" % java_base_name) \
- .op(read='ChannelUtilsVer$version.read%sList(bb, $length)' % java_base_name, \
- write='ChannelUtilsVer$version.write%sList(bb, $name)' % java_base_name)
+ .op(read= 'ChannelUtils.readList(bb, $length, OF%sVer$version.READER)' % java_base_name, \
+ write='ChannelUtils.writeList(bb, $name)')
def convert_to_jtype(obj_name, field_name, c_type):
""" Convert from a C type ("uint_32") to a java type ("U32")
and return a JType object with the size, internal type, and marshalling functions"""
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":
+ elif ( obj_name == "of_header" or loxi_utils.class_is_message(obj_name)) and field_name == "type" and c_type == "uint8_t":
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) \
- .op(read='bb.readShort()', write='bb.writeShort($name)')
+ .op(read='bb.readShort()', write='bb.writeShort($name)', pub_type=False)\
+ .op(read="OFActionTypeSerializerVer$version.readFrom(bb)", write="OFActionTypeSerializerVer$version.writeTo(bb, $name)", pub_type=True)
elif field_name == "version" and c_type == "uint8_t":
return JType("OFVersion", 'byte', size=1) \
.op(read='bb.readByte()', write='bb.writeByte($name)')
diff --git a/java_gen/pre-written/src/main/java/org/openflow/protocol/OFFlowMod.java b/java_gen/pre-written/src/main/java/org/openflow/protocol/OFFlowMod.java
deleted file mode 100644
index 06d8049..0000000
--- a/java_gen/pre-written/src/main/java/org/openflow/protocol/OFFlowMod.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package org.openflow.protocol;
-
-public interface OFFlowMod extends OFMessage {
-
- public interface Builder extends OFMessage.Builder {
-
- }
-}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/protocol/OFMessage.java b/java_gen/pre-written/src/main/java/org/openflow/protocol/OFMessage.java
deleted file mode 100644
index 32319fa..0000000
--- a/java_gen/pre-written/src/main/java/org/openflow/protocol/OFMessage.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.openflow.protocol;
-
-public interface OFMessage extends OFObject {
- int getXid();
-
- OFType getType();
-
- OFVersion getVersion();
-
- interface Builder {
-
- }
-}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/protocol/OFObject.java b/java_gen/pre-written/src/main/java/org/openflow/protocol/OFObject.java
index 140182b..aae6178 100644
--- a/java_gen/pre-written/src/main/java/org/openflow/protocol/OFObject.java
+++ b/java_gen/pre-written/src/main/java/org/openflow/protocol/OFObject.java
@@ -1,17 +1,8 @@
package org.openflow.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
/**
* Base interface of all OpenFlow objects (e.g., messages, actions, stats, etc.)
- *
- * All objects have a length and can be read and written from a buffer. When
- * writing, the length field is dynamically updated, so it need not be managed
- * manually. However, you can override the auto calculated length with
- * overrideLength() call, if, for example, you want to intentionally create
- * malformed packets, for example, for negative testing.
*/
-
-public interface OFObject {
- void writeTo(ChannelBuffer bb);
+public interface OFObject extends Writeable {
}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/protocol/Wildcards.java b/java_gen/pre-written/src/main/java/org/openflow/protocol/Wildcards.java
index e1993f5..8c03b93 100644
--- a/java_gen/pre-written/src/main/java/org/openflow/protocol/Wildcards.java
+++ b/java_gen/pre-written/src/main/java/org/openflow/protocol/Wildcards.java
@@ -288,7 +288,7 @@
* @return
*/
public static Wildcards of(int paramFlags) {
- int flags = sanitizeInt(paramFlags);
+ int flags = paramFlags; //sanitizeInt(paramFlags);
switch(flags) {
case 0x0000:
return EXACT;
diff --git a/java_gen/pre-written/src/main/java/org/openflow/protocol/Writeable.java b/java_gen/pre-written/src/main/java/org/openflow/protocol/Writeable.java
new file mode 100644
index 0000000..0ff7df6
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/openflow/protocol/Writeable.java
@@ -0,0 +1,7 @@
+package org.openflow.protocol;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface Writeable {
+ void writeTo(ChannelBuffer bb);
+}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/protocol/ver10/ChannelUtilsVer10.java b/java_gen/pre-written/src/main/java/org/openflow/protocol/ver10/ChannelUtilsVer10.java
index 67c914d..50acc7f 100644
--- a/java_gen/pre-written/src/main/java/org/openflow/protocol/ver10/ChannelUtilsVer10.java
+++ b/java_gen/pre-written/src/main/java/org/openflow/protocol/ver10/ChannelUtilsVer10.java
@@ -1,36 +1,9 @@
package org.openflow.protocol.ver10;
-import java.util.List;
-
import org.jboss.netty.buffer.ChannelBuffer;
-import org.openflow.protocol.OFBsnInterface;
+import org.openflow.exceptions.OFParseError;
import org.openflow.protocol.OFBsnVportQInQ;
-import org.openflow.protocol.OFBsnVportQInQT;
-import org.openflow.protocol.OFBucket;
-import org.openflow.protocol.OFFlowStatsEntry;
-import org.openflow.protocol.OFGroupDescStatsEntry;
-import org.openflow.protocol.OFGroupStatsEntry;
-import org.openflow.protocol.OFHelloElem;
-import org.openflow.protocol.OFMeterFeatures;
-import org.openflow.protocol.OFMeterStats;
-import org.openflow.protocol.OFObject;
-import org.openflow.protocol.OFPacketQueue;
-import org.openflow.protocol.OFPortStatsEntry;
-import org.openflow.protocol.OFQueueStatsEntry;
-import org.openflow.protocol.OFTableFeature;
-import org.openflow.protocol.OFTableFeatures;
-import org.openflow.protocol.OFTableStatsEntry;
-import org.openflow.protocol.Wildcards;
-import org.openflow.protocol.action.OFAction;
-import org.openflow.protocol.instruction.OFInstruction;
import org.openflow.protocol.match.Match;
-import org.openflow.protocol.meterband.OFMeterBand;
-import org.openflow.protocol.oxm.OFOxm;
-import org.openflow.types.OFFlowModCmd;
-import org.openflow.types.OFHelloElement;
-import org.openflow.types.OFPhysicalPort;
-
-import com.google.common.base.Charsets;
/**
* Collection of helper functions for reading and writing into ChannelBuffers
@@ -39,323 +12,18 @@
*/
public class ChannelUtilsVer10 {
-
- static public byte[] readBytes(final ChannelBuffer bb, final int length) {
- byte byteArray[] = new byte[length];
- bb.readBytes(byteArray);
- return byteArray;
+ public static Match readOFMatch(final ChannelBuffer bb) throws OFParseError {
+ return OFMatchV1Ver10.READER.readFrom(bb);
}
- static public void writeBytes(final ChannelBuffer bb,
- final byte byteArray[]) {
- bb.writeBytes(byteArray);
- }
-
- public static List<OFPhysicalPort> readPhysicalPortList(
- final ChannelBuffer bb, final int i) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static List<OFInstruction> readInstructionsList(
- final ChannelBuffer bb, final int i) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static Match readOFMatch(final ChannelBuffer bb) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static OFFlowModCmd readOFFlowModCmd(final ChannelBuffer bb) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static List<OFAction> readActionsList(final ChannelBuffer bb,
- final int i) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static List<OFBsnInterface> readBsnInterfaceList(
- final ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static OFPhysicalPort readPhysicalPort(final ChannelBuffer bb) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static List<OFPacketQueue> readPacketQueueList(
- final ChannelBuffer bb, final int i) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static List<OFHelloElement> readHelloElementList(
- final ChannelBuffer bb) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static List<OFBucket> readBucketList(final ChannelBuffer bb,
- final int length) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static List<OFMeterBand> readMeterBandList(final ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writeOFMatch(ChannelBuffer bb, Match match) {
- // TODO Auto-generated method stub
-
- }
-
- public static void writeList(ChannelBuffer bb, List<? extends OFObject> objects) {
- for(OFObject o : objects) {
- o.writeTo(bb);
- }
- }
-
- public static void writeOFFlowModCmd(ChannelBuffer bb, OFFlowModCmd command) {
- // TODO Auto-generated method stub
-
- }
-
- public static String readFixedLengthString(ChannelBuffer bb, int length) {
- byte[] dst = new byte[length];
- bb.readBytes(dst, 0, length);
- return new String(dst, Charsets.US_ASCII);
- }
-
- public static void writeFixedLengthString(ChannelBuffer bb, String string,
- int length) {
- int l = string.length();
- if (l > length) {
- throw new IllegalArgumentException("Error writing string: length="
- + l + " > max Length=" + length);
- }
- bb.writeBytes(string.getBytes(Charsets.US_ASCII));
- if (l < length) {
- bb.writeZero(length - l);
- }
- }
-
- public static void writeBsnInterfaceList(ChannelBuffer bb,
- List<OFBsnInterface> interfaces) {
- // TODO Auto-generated method stub
-
- }
-
- public static void writeTableFeatureList(ChannelBuffer bb,
- List<OFTableFeature> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static void writeBsnInterface(ChannelBuffer bb,
- List<OFBsnInterface> interfaces) {
- // TODO Auto-generated method stub
-
- }
-
- public static void writeFlowStatsEntry(ChannelBuffer bb,
- List<OFFlowStatsEntry> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static List<OFFlowStatsEntry> readFlowStatsEntry(ChannelBuffer bb) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writeTableStatsEntryList(ChannelBuffer bb,
- List<OFTableStatsEntry> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static List<OFTableStatsEntry> readTableStatsEntryList(
- ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static List<OFFlowStatsEntry> readFlowStatsEntryList(ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writeFlowStatsEntryList(ChannelBuffer bb,
- List<OFFlowStatsEntry> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static void writeGroupDescStatsEntryList(ChannelBuffer bb,
- List<OFGroupDescStatsEntry> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static List<OFGroupDescStatsEntry> readGroupDescStatsEntryList(
- ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writeOFBsnVportQInQT(ChannelBuffer bb,
- OFBsnVportQInQT vport) {
- // TODO Auto-generated method stub
-
- }
-
- public static void writeMeterBandList(ChannelBuffer bb,
- List<OFMeterBand> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static int writeActionsList(ChannelBuffer bb, List<OFAction> actions) {
- // TODO Auto-generated method stub
- return 0;
- }
-
+ // TODO these need to be figured out / removed
public static OFBsnVportQInQ readOFBsnVportQInQ(ChannelBuffer bb) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writePortStatsEntryList(ChannelBuffer bb,
- List<OFPortStatsEntry> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static void write(ChannelBuffer bb, OFPhysicalPort desc) {
- // TODO Auto-generated method stub
-
- }
-
- public static List<OFPortStatsEntry> readPortStatsEntryList(ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
+ throw new UnsupportedOperationException("not implemented");
}
public static void writeOFBsnVportQInQ(ChannelBuffer bb,
OFBsnVportQInQ vport) {
- // TODO Auto-generated method stub
-
- }
-
- public static List<OFHelloElem> readHelloElemList(ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writeHelloElemList(ChannelBuffer bb,
- List<OFHelloElem> elements) {
- // TODO Auto-generated method stub
-
- }
-
- public static List<OFGroupStatsEntry> readGroupStatsEntryList(
- ChannelBuffer bb) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writeGroupStatsEntryList(ChannelBuffer bb,
- List<OFGroupStatsEntry> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static List<OFQueueStatsEntry> readQueueStatsEntryList(
- ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writeQueueStatsEntryList(ChannelBuffer bb,
- List<OFQueueStatsEntry> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static OFMeterFeatures readOFMeterFeatures(ChannelBuffer bb) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writeOFMeterFeatures(ChannelBuffer bb,
- OFMeterFeatures features) {
- // TODO Auto-generated method stub
-
- }
-
- public static List<OFMeterStats> readMeterStatsList(ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writeMeterStatsList(ChannelBuffer bb,
- List<OFMeterStats> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static List<OFTableFeatures> readTableFeaturesList(ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writeTableFeaturesList(ChannelBuffer bb,
- List<OFTableFeatures> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static OFOxm readOFOxm(ChannelBuffer bb) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writeOFOxm(ChannelBuffer bb, OFOxm field) {
- // TODO Auto-generated method stub
-
- }
-
- public static void writeOxmList(ChannelBuffer bb, List<OFOxm> oxmList) {
- for(OFOxm o: oxmList) {
- o.writeTo(bb);
- }
- }
-
- public static List<OFOxm> readOxmList(ChannelBuffer bb, int length) {
- return null;
- }
-
- public static Wildcards readWildcards(ChannelBuffer bb) {
- return Wildcards.of(bb.readInt());
- }
-
- public static void writeWildcards(ChannelBuffer bb, Wildcards wildcards) {
- // TODO Auto-generated method stub
-
- }
-
- public static void writePhysicalPortList(ChannelBuffer bb,
- List<OFPhysicalPort> ports) {
- // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("not implemented");
}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/protocol/ver11/ChannelUtilsVer11.java b/java_gen/pre-written/src/main/java/org/openflow/protocol/ver11/ChannelUtilsVer11.java
index 1a0df58..1322acd 100644
--- a/java_gen/pre-written/src/main/java/org/openflow/protocol/ver11/ChannelUtilsVer11.java
+++ b/java_gen/pre-written/src/main/java/org/openflow/protocol/ver11/ChannelUtilsVer11.java
@@ -1,36 +1,11 @@
package org.openflow.protocol.ver11;
-import java.util.List;
-
import org.jboss.netty.buffer.ChannelBuffer;
-import org.openflow.protocol.OFBsnInterface;
+import org.openflow.exceptions.OFParseError;
import org.openflow.protocol.OFBsnVportQInQ;
-import org.openflow.protocol.OFBsnVportQInQT;
-import org.openflow.protocol.OFBucket;
-import org.openflow.protocol.OFFlowStatsEntry;
-import org.openflow.protocol.OFGroupDescStatsEntry;
-import org.openflow.protocol.OFGroupStatsEntry;
-import org.openflow.protocol.OFHelloElem;
-import org.openflow.protocol.OFMeterFeatures;
-import org.openflow.protocol.OFMeterStats;
-import org.openflow.protocol.OFObject;
-import org.openflow.protocol.OFPacketQueue;
-import org.openflow.protocol.OFPortStatsEntry;
-import org.openflow.protocol.OFQueueStatsEntry;
-import org.openflow.protocol.OFTableFeature;
-import org.openflow.protocol.OFTableFeatures;
-import org.openflow.protocol.OFTableStatsEntry;
-import org.openflow.protocol.Wildcards;
-import org.openflow.protocol.action.OFAction;
-import org.openflow.protocol.instruction.OFInstruction;
+import org.openflow.protocol.OFMatchBmap;
import org.openflow.protocol.match.Match;
-import org.openflow.protocol.meterband.OFMeterBand;
-import org.openflow.protocol.oxm.OFOxm;
-import org.openflow.types.OFFlowModCmd;
-import org.openflow.types.OFHelloElement;
-import org.openflow.types.OFPhysicalPort;
-import com.google.common.base.Charsets;
/**
* Collection of helper functions for reading and writing into ChannelBuffers
@@ -39,325 +14,26 @@
*/
public class ChannelUtilsVer11 {
-
- static public byte[] readBytes(final ChannelBuffer bb, final int length) {
- byte byteArray[] = new byte[length];
- bb.readBytes(byteArray);
- return byteArray;
+ public static Match readOFMatch(final ChannelBuffer bb) throws OFParseError {
+ return OFMatchV2Ver11.READER.readFrom(bb);
}
- static public void writeBytes(final ChannelBuffer bb,
- final byte byteArray[]) {
- bb.writeBytes(byteArray);
- }
-
- public static List<OFPhysicalPort> readPhysicalPortList(
- final ChannelBuffer bb, final int i) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static List<OFInstruction> readInstructionsList(
- final ChannelBuffer bb, final int i) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static Match readOFMatch(final ChannelBuffer bb) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static OFFlowModCmd readOFFlowModCmd(final ChannelBuffer bb) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static List<OFAction> readActionsList(final ChannelBuffer bb,
- final int i) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static List<OFBsnInterface> readBsnInterfaceList(
- final ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static OFPhysicalPort readPhysicalPort(final ChannelBuffer bb) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static List<OFPacketQueue> readPacketQueueList(
- final ChannelBuffer bb, final int i) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static List<OFHelloElement> readHelloElementList(
- final ChannelBuffer bb) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static List<OFBucket> readBucketList(final ChannelBuffer bb,
- final int length) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static List<OFMeterBand> readMeterBandList(final ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writeOFMatch(ChannelBuffer bb, Match match) {
- // TODO Auto-generated method stub
-
- }
-
- public static void writeList(ChannelBuffer bb, List<? extends OFObject> objects) {
- for(OFObject o : objects) {
- o.writeTo(bb);
- }
- }
-
- public static void writeOFFlowModCmd(ChannelBuffer bb, OFFlowModCmd command) {
- // TODO Auto-generated method stub
-
- }
-
- public static String readFixedLengthString(ChannelBuffer bb, int length) {
- byte[] dst = new byte[length];
- bb.readBytes(dst, 0, length);
- return new String(dst, Charsets.US_ASCII);
- }
-
- public static void writeFixedLengthString(ChannelBuffer bb, String string,
- int length) {
- int l = string.length();
- if (l > length) {
- throw new IllegalArgumentException("Error writing string: length="
- + l + " > max Length=" + length);
- }
- bb.writeBytes(string.getBytes(Charsets.US_ASCII));
- if (l < length) {
- bb.writeZero(length - l);
- }
- }
-
- public static void writeBsnInterfaceList(ChannelBuffer bb,
- List<OFBsnInterface> interfaces) {
- // TODO Auto-generated method stub
-
- }
-
- public static void writeTableFeatureList(ChannelBuffer bb,
- List<OFTableFeature> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static void writeBsnInterface(ChannelBuffer bb,
- List<OFBsnInterface> interfaces) {
- // TODO Auto-generated method stub
-
- }
-
- public static void writeFlowStatsEntry(ChannelBuffer bb,
- List<OFFlowStatsEntry> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static List<OFFlowStatsEntry> readFlowStatsEntry(ChannelBuffer bb) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writeTableStatsEntryList(ChannelBuffer bb,
- List<OFTableStatsEntry> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static List<OFTableStatsEntry> readTableStatsEntryList(
- ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static List<OFFlowStatsEntry> readFlowStatsEntryList(ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writeFlowStatsEntryList(ChannelBuffer bb,
- List<OFFlowStatsEntry> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static void writeGroupDescStatsEntryList(ChannelBuffer bb,
- List<OFGroupDescStatsEntry> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static List<OFGroupDescStatsEntry> readGroupDescStatsEntryList(
- ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writeOFBsnVportQInQT(ChannelBuffer bb,
- OFBsnVportQInQT vport) {
- // TODO Auto-generated method stub
-
- }
-
- public static void writeMeterBandList(ChannelBuffer bb,
- List<OFMeterBand> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static int writeActionsList(ChannelBuffer bb, List<OFAction> actions) {
- // TODO Auto-generated method stub
- return 0;
- }
-
+ // TODO these need to be figured out / removed
public static OFBsnVportQInQ readOFBsnVportQInQ(ChannelBuffer bb) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writePortStatsEntryList(ChannelBuffer bb,
- List<OFPortStatsEntry> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static void write(ChannelBuffer bb, OFPhysicalPort desc) {
- // TODO Auto-generated method stub
-
- }
-
- public static List<OFPortStatsEntry> readPortStatsEntryList(ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
+ throw new UnsupportedOperationException("not implemented");
}
public static void writeOFBsnVportQInQ(ChannelBuffer bb,
OFBsnVportQInQ vport) {
- // TODO Auto-generated method stub
-
+ throw new UnsupportedOperationException("not implemented");
}
- public static List<OFHelloElem> readHelloElemList(ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
+
+ public static OFMatchBmap readOFMatchBmap(ChannelBuffer bb) {
+ throw new UnsupportedOperationException("not implemented");
}
- public static void writeHelloElemList(ChannelBuffer bb,
- List<OFHelloElem> elements) {
- // TODO Auto-generated method stub
-
+ public static void writeOFMatchBmap(ChannelBuffer bb, OFMatchBmap match) {
+ throw new UnsupportedOperationException("not implemented");
}
-
- public static List<OFGroupStatsEntry> readGroupStatsEntryList(
- ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writeGroupStatsEntryList(ChannelBuffer bb,
- List<OFGroupStatsEntry> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static List<OFQueueStatsEntry> readQueueStatsEntryList(
- ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writeQueueStatsEntryList(ChannelBuffer bb,
- List<OFQueueStatsEntry> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static OFMeterFeatures readOFMeterFeatures(ChannelBuffer bb) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writeOFMeterFeatures(ChannelBuffer bb,
- OFMeterFeatures features) {
- // TODO Auto-generated method stub
-
- }
-
- public static List<OFMeterStats> readMeterStatsList(ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writeMeterStatsList(ChannelBuffer bb,
- List<OFMeterStats> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static List<OFTableFeatures> readTableFeaturesList(ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writeTableFeaturesList(ChannelBuffer bb,
- List<OFTableFeatures> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static OFOxm readOFOxm(ChannelBuffer bb) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writeOFOxm(ChannelBuffer bb, OFOxm field) {
- // TODO Auto-generated method stub
-
- }
-
- public static void writeOxmList(ChannelBuffer bb, List<OFOxm> oxmList) {
- for(OFOxm o: oxmList) {
- o.writeTo(bb);
- }
- }
-
- public static List<OFOxm> readOxmList(ChannelBuffer bb, int length) {
- return null;
- }
-
- public static void writePhysicalPortList(ChannelBuffer bb,
- List<OFPhysicalPort> ports) {
- // TODO Auto-generated method stub
-
- }
-
- public static Wildcards readWildcards(ChannelBuffer bb) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writeWildcards(ChannelBuffer bb, Wildcards wildcards) {
- // TODO Auto-generated method stub
-
- }
-
}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/protocol/ver12/ChannelUtilsVer12.java b/java_gen/pre-written/src/main/java/org/openflow/protocol/ver12/ChannelUtilsVer12.java
index a66fb70..c194fbc 100644
--- a/java_gen/pre-written/src/main/java/org/openflow/protocol/ver12/ChannelUtilsVer12.java
+++ b/java_gen/pre-written/src/main/java/org/openflow/protocol/ver12/ChannelUtilsVer12.java
@@ -1,35 +1,11 @@
package org.openflow.protocol.ver12;
-import java.util.List;
-
import org.jboss.netty.buffer.ChannelBuffer;
-import org.openflow.protocol.OFBsnInterface;
+import org.openflow.exceptions.OFParseError;
import org.openflow.protocol.OFBsnVportQInQ;
-import org.openflow.protocol.OFBsnVportQInQT;
-import org.openflow.protocol.OFBucket;
-import org.openflow.protocol.OFFlowStatsEntry;
-import org.openflow.protocol.OFGroupDescStatsEntry;
-import org.openflow.protocol.OFGroupStatsEntry;
-import org.openflow.protocol.OFHelloElem;
-import org.openflow.protocol.OFMeterFeatures;
-import org.openflow.protocol.OFMeterStats;
-import org.openflow.protocol.OFObject;
-import org.openflow.protocol.OFPacketQueue;
-import org.openflow.protocol.OFPortStatsEntry;
-import org.openflow.protocol.OFQueueStatsEntry;
-import org.openflow.protocol.OFTableFeature;
-import org.openflow.protocol.OFTableFeatures;
-import org.openflow.protocol.OFTableStatsEntry;
-import org.openflow.protocol.action.OFAction;
-import org.openflow.protocol.instruction.OFInstruction;
+import org.openflow.protocol.OFMatchBmap;
import org.openflow.protocol.match.Match;
-import org.openflow.protocol.meterband.OFMeterBand;
-import org.openflow.protocol.oxm.OFOxm;
-import org.openflow.types.OFFlowModCmd;
-import org.openflow.types.OFHelloElement;
-import org.openflow.types.OFPhysicalPort;
-import com.google.common.base.Charsets;
/**
* Collection of helper functions for reading and writing into ChannelBuffers
@@ -38,315 +14,27 @@
*/
public class ChannelUtilsVer12 {
-
- static public byte[] readBytes(final ChannelBuffer bb, final int length) {
- byte byteArray[] = new byte[length];
- bb.readBytes(byteArray);
- return byteArray;
+ public static Match readOFMatch(final ChannelBuffer bb) throws OFParseError {
+ return OFMatchV3Ver12.READER.readFrom(bb);
}
- static public void writeBytes(final ChannelBuffer bb,
- final byte byteArray[]) {
- bb.writeBytes(byteArray);
- }
-
- public static List<OFPhysicalPort> readPhysicalPortList(
- final ChannelBuffer bb, final int i) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static List<OFInstruction> readInstructionsList(
- final ChannelBuffer bb, final int i) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static Match readOFMatch(final ChannelBuffer bb) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static OFFlowModCmd readOFFlowModCmd(final ChannelBuffer bb) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static List<OFAction> readActionsList(final ChannelBuffer bb,
- final int i) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static List<OFBsnInterface> readBsnInterfaceList(
- final ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static OFPhysicalPort readPhysicalPort(final ChannelBuffer bb) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static List<OFPacketQueue> readPacketQueueList(
- final ChannelBuffer bb, final int i) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static List<OFHelloElement> readHelloElementList(
- final ChannelBuffer bb) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static List<OFBucket> readBucketList(final ChannelBuffer bb,
- final int length) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static List<OFMeterBand> readMeterBandList(final ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writeOFMatch(ChannelBuffer bb, Match match) {
- // TODO Auto-generated method stub
-
- }
-
- public static void writeList(ChannelBuffer bb, List<? extends OFObject> objects) {
- for(OFObject o : objects) {
- o.writeTo(bb);
- }
- }
-
- public static void writeOFFlowModCmd(ChannelBuffer bb, OFFlowModCmd command) {
- // TODO Auto-generated method stub
-
- }
-
- public static String readFixedLengthString(ChannelBuffer bb, int length) {
- byte[] dst = new byte[length];
- bb.readBytes(dst, 0, length);
- return new String(dst, Charsets.US_ASCII);
- }
-
- public static void writeFixedLengthString(ChannelBuffer bb, String string,
- int length) {
- int l = string.length();
- if (l > length) {
- throw new IllegalArgumentException("Error writing string: length="
- + l + " > max Length=" + length);
- }
- bb.writeBytes(string.getBytes(Charsets.US_ASCII));
- if (l < length) {
- bb.writeZero(length - l);
- }
- }
-
- public static void writeBsnInterfaceList(ChannelBuffer bb,
- List<OFBsnInterface> interfaces) {
- // TODO Auto-generated method stub
-
- }
-
- public static void writeTableFeatureList(ChannelBuffer bb,
- List<OFTableFeature> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static void writeBsnInterface(ChannelBuffer bb,
- List<OFBsnInterface> interfaces) {
- // TODO Auto-generated method stub
-
- }
-
- public static void writeFlowStatsEntry(ChannelBuffer bb,
- List<OFFlowStatsEntry> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static List<OFFlowStatsEntry> readFlowStatsEntry(ChannelBuffer bb) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writeTableStatsEntryList(ChannelBuffer bb,
- List<OFTableStatsEntry> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static List<OFTableStatsEntry> readTableStatsEntryList(
- ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static List<OFFlowStatsEntry> readFlowStatsEntryList(ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writeFlowStatsEntryList(ChannelBuffer bb,
- List<OFFlowStatsEntry> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static void writeGroupDescStatsEntryList(ChannelBuffer bb,
- List<OFGroupDescStatsEntry> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static List<OFGroupDescStatsEntry> readGroupDescStatsEntryList(
- ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writeOFBsnVportQInQT(ChannelBuffer bb,
- OFBsnVportQInQT vport) {
- // TODO Auto-generated method stub
-
- }
-
- public static void writeMeterBandList(ChannelBuffer bb,
- List<OFMeterBand> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static int writeActionsList(ChannelBuffer bb, List<OFAction> actions) {
- // TODO Auto-generated method stub
- return 0;
- }
+ // TODO these need to be figured out / removed
public static OFBsnVportQInQ readOFBsnVportQInQ(ChannelBuffer bb) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writePortStatsEntryList(ChannelBuffer bb,
- List<OFPortStatsEntry> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static void write(ChannelBuffer bb, OFPhysicalPort desc) {
- // TODO Auto-generated method stub
-
- }
-
- public static List<OFPortStatsEntry> readPortStatsEntryList(ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
+ throw new UnsupportedOperationException("not implemented");
}
public static void writeOFBsnVportQInQ(ChannelBuffer bb,
OFBsnVportQInQ vport) {
- // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("not implemented");
}
- public static List<OFHelloElem> readHelloElemList(ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
+ public static OFMatchBmap readOFMatchBmap(ChannelBuffer bb) {
+ throw new UnsupportedOperationException("not implemented");
}
- public static void writeHelloElemList(ChannelBuffer bb,
- List<OFHelloElem> elements) {
- // TODO Auto-generated method stub
-
+ public static void writeOFMatchBmap(ChannelBuffer bb, OFMatchBmap match) {
+ throw new UnsupportedOperationException("not implemented");
}
-
- public static List<OFGroupStatsEntry> readGroupStatsEntryList(
- ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writeGroupStatsEntryList(ChannelBuffer bb,
- List<OFGroupStatsEntry> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static List<OFQueueStatsEntry> readQueueStatsEntryList(
- ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writeQueueStatsEntryList(ChannelBuffer bb,
- List<OFQueueStatsEntry> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static OFMeterFeatures readOFMeterFeatures(ChannelBuffer bb) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writeOFMeterFeatures(ChannelBuffer bb,
- OFMeterFeatures features) {
- // TODO Auto-generated method stub
-
- }
-
- public static List<OFMeterStats> readMeterStatsList(ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writeMeterStatsList(ChannelBuffer bb,
- List<OFMeterStats> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static List<OFTableFeatures> readTableFeaturesList(ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writeTableFeaturesList(ChannelBuffer bb,
- List<OFTableFeatures> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static OFOxm readOFOxm(ChannelBuffer bb) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writeOFOxm(ChannelBuffer bb, OFOxm field) {
- // TODO Auto-generated method stub
-
- }
-
- public static void writeOxmList(ChannelBuffer bb, List<OFOxm> oxmList) {
- for(OFOxm o: oxmList) {
- o.writeTo(bb);
- }
- }
-
- public static List<OFOxm> readOxmList(ChannelBuffer bb, int length) {
- return null;
- }
-
- public static void writePhysicalPortList(ChannelBuffer bb,
- List<OFPhysicalPort> ports) {
- // TODO Auto-generated method stub
-
- }
-
}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/protocol/ver13/ChannelUtilsVer13.java b/java_gen/pre-written/src/main/java/org/openflow/protocol/ver13/ChannelUtilsVer13.java
index 73b240e..bcfbdbc 100644
--- a/java_gen/pre-written/src/main/java/org/openflow/protocol/ver13/ChannelUtilsVer13.java
+++ b/java_gen/pre-written/src/main/java/org/openflow/protocol/ver13/ChannelUtilsVer13.java
@@ -1,36 +1,10 @@
package org.openflow.protocol.ver13;
-import java.util.List;
-
import org.jboss.netty.buffer.ChannelBuffer;
import org.openflow.exceptions.OFParseError;
-import org.openflow.protocol.OFBsnInterface;
import org.openflow.protocol.OFBsnVportQInQ;
-import org.openflow.protocol.OFBsnVportQInQT;
-import org.openflow.protocol.OFBucket;
-import org.openflow.protocol.OFFlowStatsEntry;
-import org.openflow.protocol.OFGroupDescStatsEntry;
-import org.openflow.protocol.OFGroupStatsEntry;
-import org.openflow.protocol.OFHelloElem;
-import org.openflow.protocol.OFMeterFeatures;
-import org.openflow.protocol.OFMeterStats;
-import org.openflow.protocol.OFObject;
-import org.openflow.protocol.OFPacketQueue;
-import org.openflow.protocol.OFPortStatsEntry;
-import org.openflow.protocol.OFQueueStatsEntry;
-import org.openflow.protocol.OFTableFeature;
-import org.openflow.protocol.OFTableFeatures;
-import org.openflow.protocol.OFTableStatsEntry;
-import org.openflow.protocol.action.OFAction;
-import org.openflow.protocol.instruction.OFInstruction;
+import org.openflow.protocol.OFMatchBmap;
import org.openflow.protocol.match.Match;
-import org.openflow.protocol.meterband.OFMeterBand;
-import org.openflow.protocol.oxm.OFOxm;
-import org.openflow.types.OFFlowModCmd;
-import org.openflow.types.OFHelloElement;
-import org.openflow.types.OFPhysicalPort;
-
-import com.google.common.base.Charsets;
/**
* Collection of helper functions for reading and writing into ChannelBuffers
@@ -39,313 +13,26 @@
*/
public class ChannelUtilsVer13 {
-
- static public byte[] readBytes(final ChannelBuffer bb, final int length) {
- byte byteArray[] = new byte[length];
- bb.readBytes(byteArray);
- return byteArray;
- }
-
- static public void writeBytes(final ChannelBuffer bb,
- final byte byteArray[]) {
- bb.writeBytes(byteArray);
- }
-
- public static List<OFPhysicalPort> readPhysicalPortList(
- final ChannelBuffer bb, final int i) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static List<OFInstruction> readInstructionsList(
- final ChannelBuffer bb, final int i) {
- // TODO Auto-generated method stub
- return null;
- }
-
public static Match readOFMatch(final ChannelBuffer bb) throws OFParseError {
return OFMatchV3Ver13.READER.readFrom(bb);
}
- public static OFFlowModCmd readOFFlowModCmd(final ChannelBuffer bb) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static List<OFAction> readActionsList(final ChannelBuffer bb,
- final int i) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static List<OFBsnInterface> readBsnInterfaceList(
- final ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static OFPhysicalPort readPhysicalPort(final ChannelBuffer bb) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static List<OFPacketQueue> readPacketQueueList(
- final ChannelBuffer bb, final int i) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static List<OFHelloElement> readHelloElementList(
- final ChannelBuffer bb) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static List<OFBucket> readBucketList(final ChannelBuffer bb,
- final int length) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static List<OFMeterBand> readMeterBandList(final ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writeOFMatch(ChannelBuffer bb, Match match) {
- match.writeTo(bb);
- }
-
- public static void writeList(ChannelBuffer bb, List<? extends OFObject> objects) {
- for(OFObject o : objects) {
- o.writeTo(bb);
- }
- }
-
- public static void writeOFFlowModCmd(ChannelBuffer bb, OFFlowModCmd command) {
- // TODO Auto-generated method stub
-
- }
-
- public static String readFixedLengthString(ChannelBuffer bb, int length) {
- byte[] dst = new byte[length];
- bb.readBytes(dst, 0, length);
- return new String(dst, Charsets.US_ASCII);
- }
-
- public static void writeFixedLengthString(ChannelBuffer bb, String string,
- int length) {
- int l = string.length();
- if (l > length) {
- throw new IllegalArgumentException("Error writing string: length="
- + l + " > max Length=" + length);
- }
- bb.writeBytes(string.getBytes(Charsets.US_ASCII));
- if (l < length) {
- bb.writeZero(length - l);
- }
- }
-
- public static void writeBsnInterfaceList(ChannelBuffer bb,
- List<OFBsnInterface> interfaces) {
- // TODO Auto-generated method stub
-
- }
-
- public static void writeTableFeatureList(ChannelBuffer bb,
- List<OFTableFeature> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static void writeBsnInterface(ChannelBuffer bb,
- List<OFBsnInterface> interfaces) {
- // TODO Auto-generated method stub
-
- }
-
- public static void writeFlowStatsEntry(ChannelBuffer bb,
- List<OFFlowStatsEntry> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static List<OFFlowStatsEntry> readFlowStatsEntry(ChannelBuffer bb) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writeTableStatsEntryList(ChannelBuffer bb,
- List<OFTableStatsEntry> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static List<OFTableStatsEntry> readTableStatsEntryList(
- ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static List<OFFlowStatsEntry> readFlowStatsEntryList(ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writeFlowStatsEntryList(ChannelBuffer bb,
- List<OFFlowStatsEntry> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static void writeGroupDescStatsEntryList(ChannelBuffer bb,
- List<OFGroupDescStatsEntry> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static List<OFGroupDescStatsEntry> readGroupDescStatsEntryList(
- ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writeOFBsnVportQInQT(ChannelBuffer bb,
- OFBsnVportQInQT vport) {
- // TODO Auto-generated method stub
-
- }
-
- public static void writeMeterBandList(ChannelBuffer bb,
- List<OFMeterBand> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static int writeActionsList(ChannelBuffer bb, List<OFAction> actions) {
- // TODO Auto-generated method stub
- return 0;
- }
+ // TODO these need to be figured out / removed
public static OFBsnVportQInQ readOFBsnVportQInQ(ChannelBuffer bb) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writePortStatsEntryList(ChannelBuffer bb,
- List<OFPortStatsEntry> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static void write(ChannelBuffer bb, OFPhysicalPort desc) {
- // TODO Auto-generated method stub
-
- }
-
- public static List<OFPortStatsEntry> readPortStatsEntryList(ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
+ throw new UnsupportedOperationException("not implemented");
}
public static void writeOFBsnVportQInQ(ChannelBuffer bb,
OFBsnVportQInQ vport) {
- // TODO Auto-generated method stub
-
+ throw new UnsupportedOperationException("not implemented");
}
- public static List<OFHelloElem> readHelloElemList(ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
+ public static OFMatchBmap readOFMatchBmap(ChannelBuffer bb) {
+ throw new UnsupportedOperationException("not implemented");
}
- public static void writeHelloElemList(ChannelBuffer bb,
- List<OFHelloElem> elements) {
- // TODO Auto-generated method stub
-
+ public static void writeOFMatchBmap(ChannelBuffer bb, OFMatchBmap match) {
+ throw new UnsupportedOperationException("not implemented");
}
-
- public static List<OFGroupStatsEntry> readGroupStatsEntryList(
- ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writeGroupStatsEntryList(ChannelBuffer bb,
- List<OFGroupStatsEntry> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static List<OFQueueStatsEntry> readQueueStatsEntryList(
- ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writeQueueStatsEntryList(ChannelBuffer bb,
- List<OFQueueStatsEntry> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static OFMeterFeatures readOFMeterFeatures(ChannelBuffer bb) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writeOFMeterFeatures(ChannelBuffer bb,
- OFMeterFeatures features) {
- // TODO Auto-generated method stub
-
- }
-
- public static List<OFMeterStats> readMeterStatsList(ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writeMeterStatsList(ChannelBuffer bb,
- List<OFMeterStats> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static List<OFTableFeatures> readTableFeaturesList(ChannelBuffer bb, int length) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writeTableFeaturesList(ChannelBuffer bb,
- List<OFTableFeatures> entries) {
- // TODO Auto-generated method stub
-
- }
-
- public static OFOxm readOFOxm(ChannelBuffer bb) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public static void writeOFOxm(ChannelBuffer bb, OFOxm field) {
- // TODO Auto-generated method stub
-
- }
-
- public static void writeOxmList(ChannelBuffer bb, List<OFOxm> oxmList) {
- for(OFOxm o: oxmList) {
- o.writeTo(bb);
- }
- }
-
- public static List<OFOxm> readOxmList(ChannelBuffer bb, int length) {
- return null;
- }
-
- public static void writePhysicalPortList(ChannelBuffer bb,
- List<OFPhysicalPort> entries) {
- // TODO Auto-generated method stub
-
- }
-
}
diff --git a/java_gen/pre-written/src/main/java/org/openflow/util/ChannelUtils.java b/java_gen/pre-written/src/main/java/org/openflow/util/ChannelUtils.java
new file mode 100644
index 0000000..e9a3356
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/openflow/util/ChannelUtils.java
@@ -0,0 +1,67 @@
+package org.openflow.util;
+
+import java.util.List;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.openflow.exceptions.OFParseError;
+import org.openflow.protocol.OFMessageReader;
+import org.openflow.protocol.Writeable;
+
+import com.google.common.base.Charsets;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableList.Builder;
+
+/**
+ * Collection of helper functions for reading and writing into ChannelBuffers
+ *
+ * @author capveg
+ */
+
+public class ChannelUtils {
+ public static String readFixedLengthString(ChannelBuffer bb, int length) {
+ byte[] dst = new byte[length];
+ bb.readBytes(dst, 0, length);
+ return new String(dst, Charsets.US_ASCII);
+ }
+
+ public static void writeFixedLengthString(ChannelBuffer bb, String string,
+ int length) {
+ int l = string.length();
+ if (l > length) {
+ throw new IllegalArgumentException("Error writing string: length="
+ + l + " > max Length=" + length);
+ }
+ bb.writeBytes(string.getBytes(Charsets.US_ASCII));
+ if (l < length) {
+ bb.writeZero(length - l);
+ }
+ }
+
+ static public byte[] readBytes(final ChannelBuffer bb, final int length) {
+ byte byteArray[] = new byte[length];
+ bb.readBytes(byteArray);
+ return byteArray;
+ }
+
+ static public void writeBytes(final ChannelBuffer bb,
+ final byte byteArray[]) {
+ bb.writeBytes(byteArray);
+ }
+
+ public static <T> List<T> readList(ChannelBuffer bb, int length, OFMessageReader<T> reader) throws OFParseError {
+ int end = bb.readerIndex() + length;
+ Builder<T> builder = ImmutableList.<T>builder();
+ while(bb.readerIndex() < end) {
+ builder.add(reader.readFrom(bb));
+ }
+ if(bb.readerIndex() != end) {
+ throw new IllegalStateException("Overread length: length="+length + " overread by "+ (bb.readerIndex() - end) + " reader: "+reader);
+ }
+ return builder.build();
+ }
+
+ public static void writeList(ChannelBuffer bb, List<? extends Writeable> writeables) {
+ for(Writeable w: writeables)
+ w.writeTo(bb);
+ }
+}
diff --git a/java_gen/templates/_imports.java b/java_gen/templates/_imports.java
index bac7065..5b86571 100644
--- a/java_gen/templates/_imports.java
+++ b/java_gen/templates/_imports.java
@@ -7,6 +7,7 @@
import org.openflow.protocol.instruction.*;
import org.openflow.protocol.match.*;
import org.openflow.protocol.oxm.*;
+import org.openflow.protocol.queueprop.*;
import org.openflow.types.*;
import org.openflow.types.*;
import org.openflow.util.*;
diff --git a/java_gen/templates/of_class.java b/java_gen/templates/of_class.java
index 05018d3..0781dcf 100644
--- a/java_gen/templates/of_class.java
+++ b/java_gen/templates/of_class.java
@@ -129,26 +129,27 @@
static class Reader implements OFMessageReader<${msg.interface.name}> {
@Override
public ${msg.interface.name} readFrom(ChannelBuffer bb) throws OFParseError {
+ int start = bb.readerIndex();
//:: fields_with_length_member = {}
//:: for prop in msg.members:
//:: if prop.is_data:
- ${prop.java_type.public_type} ${prop.name} = ${prop.java_type.read_op(version,
+ ${prop.java_type.public_type} ${prop.name} = ${prop.java_type.read_op(version, pub_type=True,
length=fields_with_length_member[prop.c_name] if prop.c_name in fields_with_length_member else None)};
//:: elif prop.is_pad:
// pad: ${prop.length} bytes
bb.skipBytes(${prop.length});
//:: elif prop.is_fixed_value:
// fixed value property ${prop.name} == ${prop.value}
- ${prop.java_type.priv_type} ${prop.name} = ${prop.java_type.read_op(version)};
- if(${prop.name} != ${prop.value})
+ ${prop.java_type.priv_type} ${prop.name} = ${prop.java_type.read_op(version, pub_type=False)};
+ if(${prop.name} != ${prop.priv_value})
throw new OFParseError("Wrong ${prop.name}: Expected=${prop.enum_value}(${prop.value}), got="+${prop.name});
//:: elif prop.is_length_value:
- ${prop.java_type.public_type} ${prop.name} = ${prop.java_type.read_op(version)};
+ ${prop.java_type.public_type} ${prop.name} = ${prop.java_type.read_op(version, pub_type=False)};
if(${prop.name} < MINIMUM_LENGTH)
throw new OFParseError("Wrong ${prop.name}: Expected to be >= " + MINIMUM_LENGTH + ", was: " + ${prop.name});
//:: elif prop.is_field_length_value:
//:: fields_with_length_member[prop.member.field_name] = prop.name
- int ${prop.name} = ${prop.java_type.read_op(version)};
+ int ${prop.name} = ${prop.java_type.read_op(version, pub_type=False)};
//:: else:
// fixme: todo ${prop.name}
//:: #endif
@@ -173,32 +174,33 @@
static class Writer implements OFMessageWriter<${impl_class}> {
@Override
public void write(ChannelBuffer bb, ${impl_class} message) {
-//:: if not msg.is_fixed_length:
int startIndex = bb.writerIndex();
-//:: #end
-
//:: fields_with_length_member = {}
//:: for prop in msg.members:
//:: if prop.c_name in fields_with_length_member:
int ${prop.name}StartIndex = bb.writerIndex();
//:: #endif
//:: if prop.is_data:
- ${prop.java_type.write_op(version, "message." + prop.name)};
+ ${prop.java_type.write_op(version, "message." + prop.name, pub_type=True)};
//:: elif prop.is_pad:
// pad: ${prop.length} bytes
bb.writeZero(${prop.length});
//:: elif prop.is_fixed_value:
// fixed value property ${prop.name} = ${prop.value}
- ${prop.java_type.write_op(version, prop.value)};
+ ${prop.java_type.write_op(version, prop.value, pub_type=False)};
//:: elif prop.is_length_value:
// ${prop.name} is length of variable message, will be updated at the end
+//:: if not msg.is_fixed_length:
+ int lengthIndex = bb.writerIndex();
+//:: #end
${prop.java_type.write_op(version, 0)};
+
//:: elif prop.is_field_length_value:
//:: fields_with_length_member[prop.member.field_name] = prop.name
// ${prop.name} is length indicator for ${prop.member.field_name}, will be
// udpated when ${prop.member.field_name} has been written
int ${prop.name}Index = bb.writerIndex();
- ${prop.java_type.write_op(version, 0)};
+ ${prop.java_type.write_op(version, 0, pub_type=False)};
//:: else:
// FIXME: todo write ${prop.name}
//:: #endif
@@ -213,7 +215,7 @@
//:: if not msg.is_fixed_length:
// update length field
int length = bb.writerIndex() - startIndex;
- bb.setShort(startIndex + 2, length);
+ bb.setShort(lengthIndex, length);
//:: if msg.align:
// align message to ${msg.align} bytes
bb.writeZero( ((length + ${msg.align-1})/${msg.align} * ${msg.align}) - length);
diff --git a/java_gen/templates/of_interface.java b/java_gen/templates/of_interface.java
index 186b787..4dec92f 100644
--- a/java_gen/templates/of_interface.java
+++ b/java_gen/templates/of_interface.java
@@ -51,6 +51,5 @@
Builder set${prop.title_name}(${prop.java_type.public_type} ${prop.name})${ "" if prop.is_universal else " throws UnsupportedOperationException"};
//:: #endif
//:: #endfor
-
}
}
diff --git a/java_gen/templates/of_virtual_class.java b/java_gen/templates/of_virtual_class.java
new file mode 100644
index 0000000..f1ac849
--- /dev/null
+++ b/java_gen/templates/of_virtual_class.java
@@ -0,0 +1,102 @@
+//:: # Copyright 2013, Big Switch Networks, Inc.
+//:: #
+//:: # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+//:: # the following special exception:
+//:: #
+//:: # LOXI Exception
+//:: #
+//:: # As a special exception to the terms of the EPL, you may distribute libraries
+//:: # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+//:: # that copyright and licensing notices generated by LoxiGen are not altered or removed
+//:: # from the LoxiGen Libraries and the notice provided below is (i) included in
+//:: # the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+//:: # documentation for the LoxiGen Libraries, if distributed in binary form.
+//:: #
+//:: # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+//:: #
+//:: # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+//:: # a copy of the EPL at:
+//:: #
+//:: # http::: #www.eclipse.org/legal/epl-v10.html
+//:: #
+//:: # Unless required by applicable law or agreed to in writing, software
+//:: # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+//:: # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+//:: # EPL for the specific language governing permissions and limitations
+//:: # under the EPL.
+//::
+//:: from loxi_ir import *
+//:: import os
+//:: import itertools
+//:: import of_g
+//:: include('_copyright.java')
+
+//:: include('_autogen.java')
+
+package ${msg.package};
+
+//:: include("_imports.java", msg=msg)
+
+abstract class ${msg.name} implements ${msg.interface.name} {
+ // version: ${version}
+ private final static byte WIRE_VERSION = ${version.int_version};
+//:: if msg.is_fixed_length:
+ private final static int LENGTH = ${msg.length};
+//:: else:
+ private final static int MINIMUM_LENGTH = ${msg.min_length};
+//:: #endif
+
+
+ public final static ${msg.name}.Reader READER = new Reader();
+
+ static class Reader implements OFMessageReader<${msg.interface.name}> {
+ @Override
+ public ${msg.interface.name} readFrom(ChannelBuffer bb) throws OFParseError {
+ int start = bb.readerIndex();
+//:: fields_with_length_member = {}
+//:: for prop in msg.members:
+//:: if prop.is_data:
+ ${prop.java_type.skip_op(version,
+ length=fields_with_length_member[prop.c_name] if prop.c_name in fields_with_length_member else None)};
+//:: elif prop.is_pad:
+ // pad: ${prop.length} bytes
+ bb.skipBytes(${prop.length});
+//:: elif prop.is_fixed_value:
+ // fixed value property ${prop.name} == ${prop.value}
+ ${prop.java_type.priv_type} ${prop.name} = ${prop.java_type.read_op(version, pub_type=False)};
+ if(${prop.name} != ${prop.value})
+ throw new OFParseError("Wrong ${prop.name}: Expected=${prop.enum_value}(${prop.value}), got="+${prop.name});
+//:: elif prop.is_length_value:
+ ${prop.java_type.public_type} ${prop.name} = ${prop.java_type.read_op(version, pub_type=True)};
+ if(${prop.name} < MINIMUM_LENGTH)
+ throw new OFParseError("Wrong ${prop.name}: Expected to be >= " + MINIMUM_LENGTH + ", was: " + ${prop.name});
+//:: elif prop.is_field_length_value:
+//:: fields_with_length_member[prop.member.field_name] = prop.name
+ int ${prop.name} = ${prop.java_type.read_op(version)};
+//:: elif prop.is_discriminator:
+ ${prop.java_type.priv_type} ${prop.name} = ${prop.java_type.read_op(version, pub_type=False)};
+ bb.readerIndex(start);
+ switch(${prop.name}) {
+//:: for sub in msg.subclasses:
+//:: if not model.generate_class(sub):
+ // skip ${sub.name} - excluded from generation
+//:: else:
+//:: m = sub.get_member(prop.name)
+//:: if not m.is_fixed_value:
+//:: raise Exception("subtype %s of %s does not have fixed value for discriminator %s" %
+//:: (sub.name, msg.name, prop.name))
+//:: #endif
+ case ${m.priv_value}:
+ // discriminator value ${m.enum_value}=${m.value} for class ${sub.name}
+ return ${sub.name}.READER.readFrom(bb);
+//:: #endif # generate_class
+//:: #endfor
+ default:
+ throw new OFParseError("Unknown value for discriminator ${prop.name} of class ${msg.name}: " + ${prop.name});
+ }
+//:: break
+//:: #endif
+//:: #endfor
+ }
+ }
+}
diff --git a/java_gen/templates/unit_test.java b/java_gen/templates/unit_test.java
index 1462465..45472f2 100644
--- a/java_gen/templates/unit_test.java
+++ b/java_gen/templates/unit_test.java
@@ -77,7 +77,7 @@
// FIXME should invoke the overall reader once implemented
${var_type} ${var_name}Read = ${msg.name}.READER.readFrom(input);
- assertEquals(${var_name}Read, ${var_name}Built);
+ assertEquals(${var_name}Built, ${var_name}Read);
}
//:: else:
// FIXME: No java stanza in test_data for this class. Add for more comprehensive unit testing
diff --git a/openflow_input/bsn_vport b/openflow_input/bsn_vport
index 06198df..52f7c1d 100644
--- a/openflow_input/bsn_vport
+++ b/openflow_input/bsn_vport
@@ -45,7 +45,7 @@
// BSN Virtual port object header
// FIXME For now, inheritance is not exercised. See below.
struct of_bsn_vport {
- uint16_t type; /* Discriminate virtual port type */
+ uint16_t type == ?; /* Discriminate virtual port type */
uint16_t length; /* Length in bytes of this structure with this header */
/* Remainder of data is specific to the port type */
};
diff --git a/openflow_input/standard-1.3 b/openflow_input/standard-1.3
index ed2610b..7a58b60 100644
--- a/openflow_input/standard-1.3
+++ b/openflow_input/standard-1.3
@@ -569,7 +569,7 @@
};
struct of_hello_elem {
- uint16_t type;
+ uint16_t type == ?;
uint16_t length;
};
diff --git a/test_data/of13/packet_in.data b/test_data/of13/packet_in.data
index e7d602a..71e17b1 100644
--- a/test_data/of13/packet_in.data
+++ b/test_data/of13/packet_in.data
@@ -29,3 +29,21 @@
ofp.oxm.arp_op(value=1),
ofp.oxm.in_port_masked(value=4, value_mask=5)]),
data="abc")
+-- java
+builder
+ .setXid(0x12345678)
+ .setBufferId(100)
+ .setTotalLen(17000)
+ .setReason(OFPacketInReason.ACTION)
+ .setTableId((byte) 20)
+ .setCookie(U64.parseHex("FEDCBA9876543210"))
+ .setMatch(
+ factory.createMatchV3Builder().setOxmList(
+ ImmutableList.of(
+ factory.createOxmArpOpBuilder().setValue(1).getMessage(),
+ factory.createOxmInPortMaskedBuilder().setValue(OFPort.of(4)).setValueMask(OFPort.of(5)).getMessage()
+ )
+ ).getMessage()
+ )
+ .setData(new byte[] { 97, 98, 99 } );
+