Reorganized virtual port interface name in vport create message.
diff --git a/src/python/loxi/of12/common.py b/src/python/loxi/of12/common.py
index 1b79e71..dee40f1 100644
--- a/src/python/loxi/of12/common.py
+++ b/src/python/loxi/of12/common.py
@@ -140,11 +140,7 @@
class bsn_vport_q_in_q(object):
type = 0
- def __init__(self, if_name=None, port_no=None, ingress_tpid=None, ingress_vlan_id=None, egress_tpid=None, egress_vlan_id=None):
- if if_name != None:
- self.if_name = if_name
- else:
- self.if_name = ""
+ def __init__(self, port_no=None, ingress_tpid=None, ingress_vlan_id=None, egress_tpid=None, egress_vlan_id=None, if_name=None):
if port_no != None:
self.port_no = port_no
else:
@@ -165,20 +161,24 @@
self.egress_vlan_id = egress_vlan_id
else:
self.egress_vlan_id = 0
+ if if_name != None:
+ self.if_name = if_name
+ else:
+ self.if_name = ""
return
def pack(self):
packed = []
packed.append(struct.pack("!H", self.type))
- packed.append(struct.pack("!16s", self.if_name))
- packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ 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))
+ packed.append(struct.pack("!16s", self.if_name))
length = sum([len(x) for x in packed])
- packed[2] = struct.pack("!H", length)
+ packed[1] = struct.pack("!H", length)
return ''.join(packed)
@staticmethod
@@ -190,23 +190,23 @@
reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 0)
- obj.if_name = reader.read("!16s")[0].rstrip("\x00")
_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]
+ obj.if_name = reader.read("!16s")[0].rstrip("\x00")
return obj
def __eq__(self, other):
if type(self) != type(other): return False
- if self.if_name != other.if_name: 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
+ if self.if_name != other.if_name: return False
return True
def __ne__(self, other):
@@ -221,9 +221,6 @@
with q.group():
with q.indent(2):
q.breakable()
- q.text("if_name = ");
- q.pp(self.if_name)
- q.text(","); q.breakable()
q.text("port_no = ");
q.text("%#x" % self.port_no)
q.text(","); q.breakable()
@@ -238,6 +235,9 @@
q.text(","); q.breakable()
q.text("egress_vlan_id = ");
q.text("%#x" % self.egress_vlan_id)
+ q.text(","); q.breakable()
+ q.text("if_name = ");
+ q.pp(self.if_name)
q.breakable()
q.text('}')