Support for specifying interface name while creating virtual port.
diff --git a/src/python/loxi/of12/common.py b/src/python/loxi/of12/common.py
index 698fe7a..1b79e71 100644
--- a/src/python/loxi/of12/common.py
+++ b/src/python/loxi/of12/common.py
@@ -140,7 +140,11 @@
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):
+ 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 = ""
if port_no != None:
self.port_no = port_no
else:
@@ -166,14 +170,15 @@
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("!16s", self.if_name))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
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)
+ packed[2] = struct.pack("!H", length)
return ''.join(packed)
@staticmethod
@@ -185,6 +190,7 @@
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]
@@ -195,6 +201,7 @@
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
@@ -214,6 +221,9 @@
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()
@@ -1135,74 +1145,6 @@
q.breakable()
q.text('}')
-class queue_prop_experimenter(object):
- type = 65535
-
- def __init__(self, experimenter=None, data=None):
- if experimenter != None:
- self.experimenter = experimenter
- else:
- self.experimenter = 0
- if data != None:
- self.data = data
- else:
- self.data = ''
- return
-
- def pack(self):
- packed = []
- packed.append(struct.pack("!H", self.type))
- packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
- packed.append('\x00' * 4)
- packed.append(struct.pack("!L", self.experimenter))
- packed.append('\x00' * 4)
- packed.append(self.data)
- length = sum([len(x) for x in packed])
- packed[1] = struct.pack("!H", length)
- return ''.join(packed)
-
- @staticmethod
- def unpack(buf):
- obj = queue_prop_experimenter()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
- _type = reader.read("!H")[0]
- assert(_type == 65535)
- _len = reader.read("!H")[0]
- reader.skip(4)
- obj.experimenter = reader.read("!L")[0]
- reader.skip(4)
- obj.data = str(reader.read_all())
- return obj
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- if self.experimenter != other.experimenter: return False
- if self.data != other.data: 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("queue_prop_experimenter {")
- with q.group():
- with q.indent(2):
- q.breakable()
- q.text("experimenter = ");
- q.text("%#x" % self.experimenter)
- q.text(","); q.breakable()
- q.text("data = ");
- q.pp(self.data)
- q.breakable()
- q.text('}')
-
class queue_prop_max_rate(object):
type = 2