java_gen: reworked type system, cleaned up ChannelUtils
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/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);
+ }
+}