changes from loxigen e8e6401509
diff --git a/src/python/loxi/of12/common.py b/src/python/loxi/of12/common.py
index 13cc2f4..f2d2493 100644
--- a/src/python/loxi/of12/common.py
+++ b/src/python/loxi/of12/common.py
@@ -1,6 +1,7 @@
# Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
# Copyright (c) 2011, 2012 Open Networking Foundation
# Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+# See the file LICENSE.pyloxi which should have been included in the source distribution
# Automatically generated by LOXI from template common.py
# Do not modify
@@ -98,8 +99,8 @@
obj.hw_addr = list(reader.read('!6B'))
reader.skip(2)
obj.name = reader.read("!16s")[0].rstrip("\x00")
- obj.ipv4_addr = reader.read('!L')[0]
- obj.ipv4_netmask = reader.read('!L')[0]
+ obj.ipv4_addr = reader.read("!L")[0]
+ obj.ipv4_netmask = reader.read("!L")[0]
return obj
def __eq__(self, other):
@@ -136,6 +137,100 @@
q.breakable()
q.text('}')
+class bsn_vport_q_in_q(object):
+ type = 0
+
+ def __init__(self, port_no=None, ingress_tpid=None, ingress_vlan_id=None, egress_tpid=None, egress_vlan_id=None):
+ if port_no != None:
+ self.port_no = port_no
+ else:
+ self.port_no = 0
+ if ingress_tpid != None:
+ self.ingress_tpid = ingress_tpid
+ else:
+ self.ingress_tpid = 0
+ if ingress_vlan_id != None:
+ self.ingress_vlan_id = ingress_vlan_id
+ else:
+ self.ingress_vlan_id = 0
+ if egress_tpid != None:
+ self.egress_tpid = egress_tpid
+ else:
+ self.egress_tpid = 0
+ if egress_vlan_id != None:
+ self.egress_vlan_id = egress_vlan_id
+ else:
+ self.egress_vlan_id = 0
+ return
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!H", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
+ packed.append(struct.pack("!L", self.port_no))
+ packed.append(struct.pack("!H", self.ingress_tpid))
+ packed.append(struct.pack("!H", self.ingress_vlan_id))
+ packed.append(struct.pack("!H", self.egress_tpid))
+ packed.append(struct.pack("!H", self.egress_vlan_id))
+ length = sum([len(x) for x in packed])
+ packed[1] = struct.pack("!H", length)
+ return ''.join(packed)
+
+ @staticmethod
+ def unpack(buf):
+ obj = bsn_vport_q_in_q()
+ if type(buf) == loxi.generic_util.OFReader:
+ reader = buf
+ else:
+ reader = loxi.generic_util.OFReader(buf)
+ _type = reader.read("!H")[0]
+ assert(_type == 0)
+ _length = reader.read("!H")[0]
+ obj.port_no = reader.read("!L")[0]
+ obj.ingress_tpid = reader.read("!H")[0]
+ obj.ingress_vlan_id = reader.read("!H")[0]
+ obj.egress_tpid = reader.read("!H")[0]
+ obj.egress_vlan_id = reader.read("!H")[0]
+ return obj
+
+ def __eq__(self, other):
+ if type(self) != type(other): return False
+ if self.port_no != other.port_no: return False
+ if self.ingress_tpid != other.ingress_tpid: return False
+ if self.ingress_vlan_id != other.ingress_vlan_id: return False
+ if self.egress_tpid != other.egress_tpid: return False
+ if self.egress_vlan_id != other.egress_vlan_id: return False
+ return True
+
+ def __ne__(self, other):
+ return not self.__eq__(other)
+
+ def show(self):
+ import loxi.pp
+ return loxi.pp.pp(self)
+
+ def pretty_print(self, q):
+ q.text("bsn_vport_q_in_q {")
+ with q.group():
+ with q.indent(2):
+ q.breakable()
+ q.text("port_no = ");
+ q.text("%#x" % self.port_no)
+ q.text(","); q.breakable()
+ q.text("ingress_tpid = ");
+ q.text("%#x" % self.ingress_tpid)
+ q.text(","); q.breakable()
+ q.text("ingress_vlan_id = ");
+ q.text("%#x" % self.ingress_vlan_id)
+ q.text(","); q.breakable()
+ q.text("egress_tpid = ");
+ q.text("%#x" % self.egress_tpid)
+ q.text(","); q.breakable()
+ q.text("egress_vlan_id = ");
+ q.text("%#x" % self.egress_vlan_id)
+ q.breakable()
+ q.text('}')
+
class bucket(object):
def __init__(self, weight=None, watch_port=None, watch_group=None, actions=None):
@@ -161,10 +256,10 @@
packed = []
packed.append(struct.pack("!H", 0)) # placeholder for len at index 0
packed.append(struct.pack("!H", self.weight))
- packed.append(struct.pack("!L", self.watch_port))
+ packed.append(util.pack_port_no(self.watch_port))
packed.append(struct.pack("!L", self.watch_group))
packed.append('\x00' * 4)
- packed.append("".join([x.pack() for x in self.actions]))
+ packed.append(util.pack_list(self.actions))
length = sum([len(x) for x in packed])
packed[0] = struct.pack("!H", length)
return ''.join(packed)
@@ -176,10 +271,10 @@
reader = buf
else:
reader = loxi.generic_util.OFReader(buf)
- _len = reader.read('!H')[0]
- obj.weight = reader.read('!H')[0]
- obj.watch_port = reader.read('!L')[0]
- obj.watch_group = reader.read('!L')[0]
+ _len = reader.read("!H")[0]
+ obj.weight = reader.read("!H")[0]
+ obj.watch_port = util.unpack_port_no(reader)
+ obj.watch_group = reader.read("!L")[0]
reader.skip(4)
obj.actions = action.unpack_list(reader)
return obj
@@ -244,8 +339,8 @@
reader = buf
else:
reader = loxi.generic_util.OFReader(buf)
- obj.packet_count = reader.read('!Q')[0]
- obj.byte_count = reader.read('!Q')[0]
+ obj.packet_count = reader.read("!Q")[0]
+ obj.byte_count = reader.read("!Q")[0]
return obj
def __eq__(self, other):
@@ -338,7 +433,7 @@
packed.append(struct.pack("!Q", self.packet_count))
packed.append(struct.pack("!Q", self.byte_count))
packed.append(self.match.pack())
- packed.append("".join([x.pack() for x in self.instructions]))
+ packed.append(util.pack_list(self.instructions))
length = sum([len(x) for x in packed])
packed[0] = struct.pack("!H", length)
return ''.join(packed)
@@ -350,18 +445,18 @@
reader = buf
else:
reader = loxi.generic_util.OFReader(buf)
- _length = reader.read('!H')[0]
- obj.table_id = reader.read('!B')[0]
+ _length = reader.read("!H")[0]
+ obj.table_id = reader.read("!B")[0]
reader.skip(1)
- obj.duration_sec = reader.read('!L')[0]
- obj.duration_nsec = reader.read('!L')[0]
- obj.priority = reader.read('!H')[0]
- obj.idle_timeout = reader.read('!H')[0]
- obj.hard_timeout = reader.read('!H')[0]
+ obj.duration_sec = reader.read("!L")[0]
+ obj.duration_nsec = reader.read("!L")[0]
+ obj.priority = reader.read("!H")[0]
+ obj.idle_timeout = reader.read("!H")[0]
+ obj.hard_timeout = reader.read("!H")[0]
reader.skip(6)
- obj.cookie = reader.read('!Q')[0]
- obj.packet_count = reader.read('!Q')[0]
- obj.byte_count = reader.read('!Q')[0]
+ obj.cookie = reader.read("!Q")[0]
+ obj.packet_count = reader.read("!Q")[0]
+ obj.byte_count = reader.read("!Q")[0]
obj.match = common.match.unpack(reader)
obj.instructions = instruction.unpack_list(reader)
return obj
@@ -451,7 +546,7 @@
packed.append(struct.pack("!B", self.type))
packed.append('\x00' * 1)
packed.append(struct.pack("!L", self.group_id))
- packed.append("".join([x.pack() for x in self.buckets]))
+ packed.append(util.pack_list(self.buckets))
length = sum([len(x) for x in packed])
packed[0] = struct.pack("!H", length)
return ''.join(packed)
@@ -463,10 +558,10 @@
reader = buf
else:
reader = loxi.generic_util.OFReader(buf)
- _length = reader.read('!H')[0]
- obj.type = reader.read('!B')[0]
+ _length = reader.read("!H")[0]
+ obj.type = reader.read("!B")[0]
reader.skip(1)
- obj.group_id = reader.read('!L')[0]
+ obj.group_id = reader.read("!L")[0]
obj.buckets = common.unpack_list_bucket(reader)
return obj
@@ -534,7 +629,7 @@
packed.append('\x00' * 4)
packed.append(struct.pack("!Q", self.packet_count))
packed.append(struct.pack("!Q", self.byte_count))
- packed.append("".join([x.pack() for x in self.bucket_stats]))
+ packed.append(util.pack_list(self.bucket_stats))
length = sum([len(x) for x in packed])
packed[0] = struct.pack("!H", length)
return ''.join(packed)
@@ -546,13 +641,13 @@
reader = buf
else:
reader = loxi.generic_util.OFReader(buf)
- _length = reader.read('!H')[0]
+ _length = reader.read("!H")[0]
reader.skip(2)
- obj.group_id = reader.read('!L')[0]
- obj.ref_count = reader.read('!L')[0]
+ obj.group_id = reader.read("!L")[0]
+ obj.ref_count = reader.read("!L")[0]
reader.skip(4)
- obj.packet_count = reader.read('!Q')[0]
- obj.byte_count = reader.read('!Q')[0]
+ obj.packet_count = reader.read("!Q")[0]
+ obj.byte_count = reader.read("!Q")[0]
obj.bucket_stats = loxi.generic_util.unpack_list(reader, common.bucket_counter.unpack)
return obj
@@ -608,7 +703,7 @@
packed = []
packed.append(struct.pack("!H", self.type))
packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
- packed.append("".join([x.pack() for x in self.oxm_list]))
+ packed.append(util.pack_list(self.oxm_list))
length = sum([len(x) for x in packed])
packed[1] = struct.pack("!H", length)
packed.append('\x00' * ((length + 7)/8*8 - length))
@@ -621,9 +716,9 @@
reader = buf
else:
reader = loxi.generic_util.OFReader(buf)
- _type = reader.read('!H')[0]
+ _type = reader.read("!H")[0]
assert(_type == 1)
- _length = reader.read('!H')[0]
+ _length = reader.read("!H")[0]
obj.oxm_list = oxm.unpack_list(reader.slice(_length-4))
reader.skip((_length + 7)/8*8 - _length)
return obj
@@ -670,10 +765,10 @@
def pack(self):
packed = []
packed.append(struct.pack("!L", self.queue_id))
- packed.append(struct.pack("!L", self.port))
+ packed.append(util.pack_port_no(self.port))
packed.append(struct.pack("!H", 0)) # placeholder for len at index 2
packed.append('\x00' * 6)
- packed.append("".join([x.pack() for x in self.properties]))
+ packed.append(util.pack_list(self.properties))
length = sum([len(x) for x in packed])
packed[2] = struct.pack("!H", length)
return ''.join(packed)
@@ -685,9 +780,9 @@
reader = buf
else:
reader = loxi.generic_util.OFReader(buf)
- obj.queue_id = reader.read('!L')[0]
- obj.port = reader.read('!L')[0]
- _len = reader.read('!H')[0]
+ obj.queue_id = reader.read("!L")[0]
+ obj.port = util.unpack_port_no(reader)
+ _len = reader.read("!H")[0]
reader.skip(6)
obj.properties = common.unpack_list_queue_prop(reader)
return obj
@@ -773,7 +868,7 @@
def pack(self):
packed = []
- packed.append(struct.pack("!L", self.port_no))
+ packed.append(util.pack_port_no(self.port_no))
packed.append('\x00' * 4)
packed.append(struct.pack("!6B", *self.hw_addr))
packed.append('\x00' * 2)
@@ -795,19 +890,19 @@
reader = buf
else:
reader = loxi.generic_util.OFReader(buf)
- obj.port_no = reader.read('!L')[0]
+ obj.port_no = util.unpack_port_no(reader)
reader.skip(4)
obj.hw_addr = list(reader.read('!6B'))
reader.skip(2)
obj.name = reader.read("!16s")[0].rstrip("\x00")
- obj.config = reader.read('!L')[0]
- obj.state = reader.read('!L')[0]
- obj.curr = reader.read('!L')[0]
- obj.advertised = reader.read('!L')[0]
- obj.supported = reader.read('!L')[0]
- obj.peer = reader.read('!L')[0]
- obj.curr_speed = reader.read('!L')[0]
- obj.max_speed = reader.read('!L')[0]
+ obj.config = reader.read("!L")[0]
+ obj.state = reader.read("!L")[0]
+ obj.curr = reader.read("!L")[0]
+ obj.advertised = reader.read("!L")[0]
+ obj.supported = reader.read("!L")[0]
+ obj.peer = reader.read("!L")[0]
+ obj.curr_speed = reader.read("!L")[0]
+ obj.max_speed = reader.read("!L")[0]
return obj
def __eq__(self, other):
@@ -931,7 +1026,7 @@
def pack(self):
packed = []
- packed.append(struct.pack("!L", self.port_no))
+ packed.append(util.pack_port_no(self.port_no))
packed.append('\x00' * 4)
packed.append(struct.pack("!Q", self.rx_packets))
packed.append(struct.pack("!Q", self.tx_packets))
@@ -954,20 +1049,20 @@
reader = buf
else:
reader = loxi.generic_util.OFReader(buf)
- obj.port_no = reader.read('!L')[0]
+ obj.port_no = util.unpack_port_no(reader)
reader.skip(4)
- obj.rx_packets = reader.read('!Q')[0]
- obj.tx_packets = reader.read('!Q')[0]
- obj.rx_bytes = reader.read('!Q')[0]
- obj.tx_bytes = reader.read('!Q')[0]
- obj.rx_dropped = reader.read('!Q')[0]
- obj.tx_dropped = reader.read('!Q')[0]
- obj.rx_errors = reader.read('!Q')[0]
- obj.tx_errors = reader.read('!Q')[0]
- obj.rx_frame_err = reader.read('!Q')[0]
- obj.rx_over_err = reader.read('!Q')[0]
- obj.rx_crc_err = reader.read('!Q')[0]
- obj.collisions = reader.read('!Q')[0]
+ obj.rx_packets = reader.read("!Q")[0]
+ obj.tx_packets = reader.read("!Q")[0]
+ obj.rx_bytes = reader.read("!Q")[0]
+ obj.tx_bytes = reader.read("!Q")[0]
+ obj.rx_dropped = reader.read("!Q")[0]
+ obj.tx_dropped = reader.read("!Q")[0]
+ obj.rx_errors = reader.read("!Q")[0]
+ obj.tx_errors = reader.read("!Q")[0]
+ obj.rx_frame_err = reader.read("!Q")[0]
+ obj.rx_over_err = reader.read("!Q")[0]
+ obj.rx_crc_err = reader.read("!Q")[0]
+ obj.collisions = reader.read("!Q")[0]
return obj
def __eq__(self, other):
@@ -1041,7 +1136,7 @@
q.text('}')
class queue_prop_experimenter(object):
- type = const.OFPQT_EXPERIMENTER
+ type = 65535
def __init__(self, experimenter=None, data=None):
if experimenter != None:
@@ -1051,7 +1146,7 @@
if data != None:
self.data = data
else:
- self.data = ""
+ self.data = ''
return
def pack(self):
@@ -1073,11 +1168,11 @@
reader = buf
else:
reader = loxi.generic_util.OFReader(buf)
- _type = reader.read('!H')[0]
- assert(_type == const.OFPQT_EXPERIMENTER)
- _len = reader.read('!H')[0]
+ _type = reader.read("!H")[0]
+ assert(_type == 65535)
+ _len = reader.read("!H")[0]
reader.skip(4)
- obj.experimenter = reader.read('!L')[0]
+ obj.experimenter = reader.read("!L")[0]
reader.skip(4)
obj.data = str(reader.read_all())
return obj
@@ -1109,7 +1204,7 @@
q.text('}')
class queue_prop_max_rate(object):
- type = const.OFPQT_MAX_RATE
+ type = 2
def __init__(self, rate=None):
if rate != None:
@@ -1136,11 +1231,11 @@
reader = buf
else:
reader = loxi.generic_util.OFReader(buf)
- _type = reader.read('!H')[0]
- assert(_type == const.OFPQT_MAX_RATE)
- _len = reader.read('!H')[0]
+ _type = reader.read("!H")[0]
+ assert(_type == 2)
+ _len = reader.read("!H")[0]
reader.skip(4)
- obj.rate = reader.read('!H')[0]
+ obj.rate = reader.read("!H")[0]
reader.skip(6)
return obj
@@ -1167,7 +1262,7 @@
q.text('}')
class queue_prop_min_rate(object):
- type = const.OFPQT_MIN_RATE
+ type = 1
def __init__(self, rate=None):
if rate != None:
@@ -1194,11 +1289,11 @@
reader = buf
else:
reader = loxi.generic_util.OFReader(buf)
- _type = reader.read('!H')[0]
- assert(_type == const.OFPQT_MIN_RATE)
- _len = reader.read('!H')[0]
+ _type = reader.read("!H")[0]
+ assert(_type == 1)
+ _len = reader.read("!H")[0]
reader.skip(4)
- obj.rate = reader.read('!H')[0]
+ obj.rate = reader.read("!H")[0]
reader.skip(6)
return obj
@@ -1251,7 +1346,7 @@
def pack(self):
packed = []
- packed.append(struct.pack("!L", self.port_no))
+ packed.append(util.pack_port_no(self.port_no))
packed.append(struct.pack("!L", self.queue_id))
packed.append(struct.pack("!Q", self.tx_bytes))
packed.append(struct.pack("!Q", self.tx_packets))
@@ -1265,11 +1360,11 @@
reader = buf
else:
reader = loxi.generic_util.OFReader(buf)
- obj.port_no = reader.read('!L')[0]
- obj.queue_id = reader.read('!L')[0]
- obj.tx_bytes = reader.read('!Q')[0]
- obj.tx_packets = reader.read('!Q')[0]
- obj.tx_errors = reader.read('!Q')[0]
+ obj.port_no = util.unpack_port_no(reader)
+ obj.queue_id = reader.read("!L")[0]
+ obj.tx_bytes = reader.read("!Q")[0]
+ obj.tx_packets = reader.read("!Q")[0]
+ obj.tx_errors = reader.read("!Q")[0]
return obj
def __eq__(self, other):
@@ -1324,11 +1419,11 @@
if match != None:
self.match = match
else:
- self.match = 0
+ self.match = util.init_match_bmap()
if wildcards != None:
self.wildcards = wildcards
else:
- self.wildcards = 0
+ self.wildcards = util.init_wc_bmap()
if write_actions != None:
self.write_actions = write_actions
else:
@@ -1384,8 +1479,8 @@
packed.append(struct.pack("!B", self.table_id))
packed.append('\x00' * 7)
packed.append(struct.pack("!32s", self.name))
- packed.append(struct.pack("!Q", self.match))
- packed.append(struct.pack("!Q", self.wildcards))
+ packed.append(util.pack_match_bmap(self.match))
+ packed.append(util.pack_wc_bmap(self.wildcards))
packed.append(struct.pack("!L", self.write_actions))
packed.append(struct.pack("!L", self.apply_actions))
packed.append(struct.pack("!Q", self.write_setfields))
@@ -1407,23 +1502,23 @@
reader = buf
else:
reader = loxi.generic_util.OFReader(buf)
- obj.table_id = reader.read('!B')[0]
+ obj.table_id = reader.read("!B")[0]
reader.skip(7)
obj.name = reader.read("!32s")[0].rstrip("\x00")
- obj.match = reader.read('!Q')[0]
- obj.wildcards = reader.read('!Q')[0]
- obj.write_actions = reader.read('!L')[0]
- obj.apply_actions = reader.read('!L')[0]
- obj.write_setfields = reader.read('!Q')[0]
- obj.apply_setfields = reader.read('!Q')[0]
- obj.metadata_match = reader.read('!Q')[0]
- obj.metadata_write = reader.read('!Q')[0]
- obj.instructions = reader.read('!L')[0]
- obj.config = reader.read('!L')[0]
- obj.max_entries = reader.read('!L')[0]
- obj.active_count = reader.read('!L')[0]
- obj.lookup_count = reader.read('!Q')[0]
- obj.matched_count = reader.read('!Q')[0]
+ obj.match = util.unpack_match_bmap(reader)
+ obj.wildcards = util.unpack_wc_bmap(reader)
+ obj.write_actions = reader.read("!L")[0]
+ obj.apply_actions = reader.read("!L")[0]
+ obj.write_setfields = reader.read("!Q")[0]
+ obj.apply_setfields = reader.read("!Q")[0]
+ obj.metadata_match = reader.read("!Q")[0]
+ obj.metadata_write = reader.read("!Q")[0]
+ obj.instructions = reader.read("!L")[0]
+ obj.config = reader.read("!L")[0]
+ obj.max_entries = reader.read("!L")[0]
+ obj.active_count = reader.read("!L")[0]
+ obj.lookup_count = reader.read("!Q")[0]
+ obj.matched_count = reader.read("!Q")[0]
return obj
def __eq__(self, other):