update pyloxi to 026ff024585f1588a7f11fa4c1a9a48d44dc098d
diff --git a/src/python/loxi/of11/action.py b/src/python/loxi/of11/action.py
index 644319d..06f6695 100644
--- a/src/python/loxi/of11/action.py
+++ b/src/python/loxi/of11/action.py
@@ -3,27 +3,60 @@
# 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 action.py
+# Automatically generated by LOXI from template module.py
# Do not modify
import struct
+import loxi
import const
+import common
+import action
+import instruction
import util
import loxi.generic_util
-import loxi
-def unpack_list(reader):
- def deserializer(reader, typ):
- parser = parsers.get(typ)
- if not parser: raise loxi.ProtocolError("unknown action type %d" % typ)
- return parser(reader)
- return loxi.generic_util.unpack_list_tlv16(reader, deserializer)
+class action(loxi.OFObject):
+ subtypes = {}
-class Action(object):
- type = None # override in subclass
- pass
+ @staticmethod
+ def unpack(reader):
+ subtype, = reader.peek('!H', 0)
+ try:
+ subclass = action.subtypes[subtype]
+ except KeyError:
+ raise loxi.ProtocolError("unknown action subtype %#x" % subtype)
+ return subclass.unpack(reader)
-class bsn_mirror(Action):
+
+class experimenter(action):
+ subtypes = {}
+
+ @staticmethod
+ def unpack(reader):
+ subtype, = reader.peek('!L', 4)
+ try:
+ subclass = experimenter.subtypes[subtype]
+ except KeyError:
+ raise loxi.ProtocolError("unknown experimenter action subtype %#x" % subtype)
+ return subclass.unpack(reader)
+
+action.subtypes[65535] = experimenter
+
+class bsn(experimenter):
+ subtypes = {}
+
+ @staticmethod
+ def unpack(reader):
+ subtype, = reader.peek('!L', 8)
+ try:
+ subclass = bsn.subtypes[subtype]
+ except KeyError:
+ raise loxi.ProtocolError("unknown bsn experimenter action subtype %#x" % subtype)
+ return subclass.unpack(reader)
+
+experimenter.subtypes[6035143] = bsn
+
+class bsn_mirror(bsn):
type = 65535
experimenter = 6035143
subtype = 1
@@ -58,15 +91,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = bsn_mirror()
- 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]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
_experimenter = reader.read("!L")[0]
assert(_experimenter == 6035143)
_subtype = reader.read("!L")[0]
@@ -84,13 +115,6 @@
if self.copy_stage != other.copy_stage: 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_mirror {")
with q.group():
@@ -107,7 +131,9 @@
q.breakable()
q.text('}')
-class bsn_set_tunnel_dst(Action):
+bsn.subtypes[1] = bsn_mirror
+
+class bsn_set_tunnel_dst(bsn):
type = 65535
experimenter = 6035143
subtype = 2
@@ -131,15 +157,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = bsn_set_tunnel_dst()
- 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]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
_experimenter = reader.read("!L")[0]
assert(_experimenter == 6035143)
_subtype = reader.read("!L")[0]
@@ -152,13 +176,6 @@
if self.dst != other.dst: 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_set_tunnel_dst {")
with q.group():
@@ -169,7 +186,9 @@
q.breakable()
q.text('}')
-class copy_ttl_in(Action):
+bsn.subtypes[2] = bsn_set_tunnel_dst
+
+class copy_ttl_in(action):
type = 12
def __init__(self):
@@ -185,15 +204,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = copy_ttl_in()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 12)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
reader.skip(4)
return obj
@@ -201,13 +218,6 @@
if type(self) != type(other): 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("copy_ttl_in {")
with q.group():
@@ -216,7 +226,9 @@
q.breakable()
q.text('}')
-class copy_ttl_out(Action):
+action.subtypes[12] = copy_ttl_in
+
+class copy_ttl_out(action):
type = 11
def __init__(self):
@@ -232,15 +244,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = copy_ttl_out()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 11)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
reader.skip(4)
return obj
@@ -248,13 +258,6 @@
if type(self) != type(other): 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("copy_ttl_out {")
with q.group():
@@ -263,7 +266,9 @@
q.breakable()
q.text('}')
-class dec_mpls_ttl(Action):
+action.subtypes[11] = copy_ttl_out
+
+class dec_mpls_ttl(action):
type = 16
def __init__(self):
@@ -279,15 +284,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = dec_mpls_ttl()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 16)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
reader.skip(4)
return obj
@@ -295,13 +298,6 @@
if type(self) != type(other): 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("dec_mpls_ttl {")
with q.group():
@@ -310,7 +306,9 @@
q.breakable()
q.text('}')
-class dec_nw_ttl(Action):
+action.subtypes[16] = dec_mpls_ttl
+
+class dec_nw_ttl(action):
type = 24
def __init__(self):
@@ -326,15 +324,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = dec_nw_ttl()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 24)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
reader.skip(4)
return obj
@@ -342,13 +338,6 @@
if type(self) != type(other): 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("dec_nw_ttl {")
with q.group():
@@ -357,7 +346,9 @@
q.breakable()
q.text('}')
-class group(Action):
+action.subtypes[24] = dec_nw_ttl
+
+class group(action):
type = 22
def __init__(self, group_id=None):
@@ -377,15 +368,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = group()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 22)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
obj.group_id = reader.read("!L")[0]
return obj
@@ -394,13 +383,6 @@
if self.group_id != other.group_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("group {")
with q.group():
@@ -411,7 +393,23 @@
q.breakable()
q.text('}')
-class nicira_dec_ttl(Action):
+action.subtypes[22] = group
+
+class nicira(experimenter):
+ subtypes = {}
+
+ @staticmethod
+ def unpack(reader):
+ subtype, = reader.peek('!H', 8)
+ try:
+ subclass = nicira.subtypes[subtype]
+ except KeyError:
+ raise loxi.ProtocolError("unknown nicira experimenter action subtype %#x" % subtype)
+ return subclass.unpack(reader)
+
+experimenter.subtypes[8992] = nicira
+
+class nicira_dec_ttl(nicira):
type = 65535
experimenter = 8992
subtype = 18
@@ -432,15 +430,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = nicira_dec_ttl()
- 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]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
_experimenter = reader.read("!L")[0]
assert(_experimenter == 8992)
_subtype = reader.read("!H")[0]
@@ -453,13 +449,6 @@
if type(self) != type(other): 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("nicira_dec_ttl {")
with q.group():
@@ -468,7 +457,9 @@
q.breakable()
q.text('}')
-class output(Action):
+nicira.subtypes[18] = nicira_dec_ttl
+
+class output(action):
type = 0
def __init__(self, port=None, max_len=None):
@@ -494,15 +485,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = output()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 0)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
obj.port = util.unpack_port_no(reader)
obj.max_len = reader.read("!H")[0]
reader.skip(6)
@@ -514,13 +503,6 @@
if self.max_len != other.max_len: 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("output {")
with q.group():
@@ -534,7 +516,9 @@
q.breakable()
q.text('}')
-class pop_mpls(Action):
+action.subtypes[0] = output
+
+class pop_mpls(action):
type = 20
def __init__(self, ethertype=None):
@@ -555,15 +539,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = pop_mpls()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 20)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
obj.ethertype = reader.read("!H")[0]
reader.skip(2)
return obj
@@ -573,13 +555,6 @@
if self.ethertype != other.ethertype: 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("pop_mpls {")
with q.group():
@@ -590,7 +565,9 @@
q.breakable()
q.text('}')
-class pop_vlan(Action):
+action.subtypes[20] = pop_mpls
+
+class pop_vlan(action):
type = 18
def __init__(self):
@@ -606,15 +583,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = pop_vlan()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 18)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
reader.skip(4)
return obj
@@ -622,13 +597,6 @@
if type(self) != type(other): 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("pop_vlan {")
with q.group():
@@ -637,7 +605,9 @@
q.breakable()
q.text('}')
-class push_mpls(Action):
+action.subtypes[18] = pop_vlan
+
+class push_mpls(action):
type = 19
def __init__(self, ethertype=None):
@@ -658,15 +628,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = push_mpls()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 19)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
obj.ethertype = reader.read("!H")[0]
reader.skip(2)
return obj
@@ -676,13 +644,6 @@
if self.ethertype != other.ethertype: 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("push_mpls {")
with q.group():
@@ -693,7 +654,9 @@
q.breakable()
q.text('}')
-class push_vlan(Action):
+action.subtypes[19] = push_mpls
+
+class push_vlan(action):
type = 17
def __init__(self, ethertype=None):
@@ -714,15 +677,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = push_vlan()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 17)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
obj.ethertype = reader.read("!H")[0]
reader.skip(2)
return obj
@@ -732,13 +693,6 @@
if self.ethertype != other.ethertype: 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("push_vlan {")
with q.group():
@@ -749,7 +703,9 @@
q.breakable()
q.text('}')
-class set_dl_dst(Action):
+action.subtypes[17] = push_vlan
+
+class set_dl_dst(action):
type = 4
def __init__(self, dl_addr=None):
@@ -770,15 +726,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = set_dl_dst()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 4)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
obj.dl_addr = list(reader.read('!6B'))
reader.skip(6)
return obj
@@ -788,13 +742,6 @@
if self.dl_addr != other.dl_addr: 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("set_dl_dst {")
with q.group():
@@ -805,7 +752,9 @@
q.breakable()
q.text('}')
-class set_dl_src(Action):
+action.subtypes[4] = set_dl_dst
+
+class set_dl_src(action):
type = 3
def __init__(self, dl_addr=None):
@@ -826,15 +775,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = set_dl_src()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 3)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
obj.dl_addr = list(reader.read('!6B'))
reader.skip(6)
return obj
@@ -844,13 +791,6 @@
if self.dl_addr != other.dl_addr: 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("set_dl_src {")
with q.group():
@@ -861,7 +801,9 @@
q.breakable()
q.text('}')
-class set_mpls_label(Action):
+action.subtypes[3] = set_dl_src
+
+class set_mpls_label(action):
type = 13
def __init__(self, mpls_label=None):
@@ -881,15 +823,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = set_mpls_label()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 13)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
obj.mpls_label = reader.read("!L")[0]
return obj
@@ -898,13 +838,6 @@
if self.mpls_label != other.mpls_label: 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("set_mpls_label {")
with q.group():
@@ -915,7 +848,9 @@
q.breakable()
q.text('}')
-class set_mpls_tc(Action):
+action.subtypes[13] = set_mpls_label
+
+class set_mpls_tc(action):
type = 14
def __init__(self, mpls_tc=None):
@@ -936,15 +871,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = set_mpls_tc()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 14)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
obj.mpls_tc = reader.read("!B")[0]
reader.skip(3)
return obj
@@ -954,13 +887,6 @@
if self.mpls_tc != other.mpls_tc: 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("set_mpls_tc {")
with q.group():
@@ -971,7 +897,9 @@
q.breakable()
q.text('}')
-class set_mpls_ttl(Action):
+action.subtypes[14] = set_mpls_tc
+
+class set_mpls_ttl(action):
type = 15
def __init__(self, mpls_ttl=None):
@@ -992,15 +920,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = set_mpls_ttl()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 15)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
obj.mpls_ttl = reader.read("!B")[0]
reader.skip(3)
return obj
@@ -1010,13 +936,6 @@
if self.mpls_ttl != other.mpls_ttl: 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("set_mpls_ttl {")
with q.group():
@@ -1027,7 +946,9 @@
q.breakable()
q.text('}')
-class set_nw_dst(Action):
+action.subtypes[15] = set_mpls_ttl
+
+class set_nw_dst(action):
type = 6
def __init__(self, nw_addr=None):
@@ -1047,15 +968,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = set_nw_dst()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 6)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
obj.nw_addr = reader.read("!L")[0]
return obj
@@ -1064,13 +983,6 @@
if self.nw_addr != other.nw_addr: 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("set_nw_dst {")
with q.group():
@@ -1081,7 +993,9 @@
q.breakable()
q.text('}')
-class set_nw_ecn(Action):
+action.subtypes[6] = set_nw_dst
+
+class set_nw_ecn(action):
type = 8
def __init__(self, nw_ecn=None):
@@ -1102,15 +1016,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = set_nw_ecn()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 8)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
obj.nw_ecn = reader.read("!B")[0]
reader.skip(3)
return obj
@@ -1120,13 +1032,6 @@
if self.nw_ecn != other.nw_ecn: 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("set_nw_ecn {")
with q.group():
@@ -1137,7 +1042,9 @@
q.breakable()
q.text('}')
-class set_nw_src(Action):
+action.subtypes[8] = set_nw_ecn
+
+class set_nw_src(action):
type = 5
def __init__(self, nw_addr=None):
@@ -1157,15 +1064,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = set_nw_src()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 5)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
obj.nw_addr = reader.read("!L")[0]
return obj
@@ -1174,13 +1079,6 @@
if self.nw_addr != other.nw_addr: 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("set_nw_src {")
with q.group():
@@ -1191,7 +1089,9 @@
q.breakable()
q.text('}')
-class set_nw_tos(Action):
+action.subtypes[5] = set_nw_src
+
+class set_nw_tos(action):
type = 7
def __init__(self, nw_tos=None):
@@ -1212,15 +1112,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = set_nw_tos()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 7)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
obj.nw_tos = reader.read("!B")[0]
reader.skip(3)
return obj
@@ -1230,13 +1128,6 @@
if self.nw_tos != other.nw_tos: 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("set_nw_tos {")
with q.group():
@@ -1247,7 +1138,9 @@
q.breakable()
q.text('}')
-class set_nw_ttl(Action):
+action.subtypes[7] = set_nw_tos
+
+class set_nw_ttl(action):
type = 23
def __init__(self, nw_ttl=None):
@@ -1268,15 +1161,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = set_nw_ttl()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 23)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
obj.nw_ttl = reader.read("!B")[0]
reader.skip(3)
return obj
@@ -1286,13 +1177,6 @@
if self.nw_ttl != other.nw_ttl: 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("set_nw_ttl {")
with q.group():
@@ -1303,7 +1187,9 @@
q.breakable()
q.text('}')
-class set_queue(Action):
+action.subtypes[23] = set_nw_ttl
+
+class set_queue(action):
type = 21
def __init__(self, queue_id=None):
@@ -1323,15 +1209,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = set_queue()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 21)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
obj.queue_id = reader.read("!L")[0]
return obj
@@ -1340,13 +1224,6 @@
if self.queue_id != other.queue_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("set_queue {")
with q.group():
@@ -1357,7 +1234,9 @@
q.breakable()
q.text('}')
-class set_tp_dst(Action):
+action.subtypes[21] = set_queue
+
+class set_tp_dst(action):
type = 10
def __init__(self, tp_port=None):
@@ -1378,15 +1257,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = set_tp_dst()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 10)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
obj.tp_port = reader.read("!H")[0]
reader.skip(2)
return obj
@@ -1396,13 +1273,6 @@
if self.tp_port != other.tp_port: 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("set_tp_dst {")
with q.group():
@@ -1413,7 +1283,9 @@
q.breakable()
q.text('}')
-class set_tp_src(Action):
+action.subtypes[10] = set_tp_dst
+
+class set_tp_src(action):
type = 9
def __init__(self, tp_port=None):
@@ -1434,15 +1306,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = set_tp_src()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 9)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
obj.tp_port = reader.read("!H")[0]
reader.skip(2)
return obj
@@ -1452,13 +1322,6 @@
if self.tp_port != other.tp_port: 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("set_tp_src {")
with q.group():
@@ -1469,7 +1332,9 @@
q.breakable()
q.text('}')
-class set_vlan_pcp(Action):
+action.subtypes[9] = set_tp_src
+
+class set_vlan_pcp(action):
type = 2
def __init__(self, vlan_pcp=None):
@@ -1490,15 +1355,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = set_vlan_pcp()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 2)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
obj.vlan_pcp = reader.read("!B")[0]
reader.skip(3)
return obj
@@ -1508,13 +1371,6 @@
if self.vlan_pcp != other.vlan_pcp: 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("set_vlan_pcp {")
with q.group():
@@ -1525,7 +1381,9 @@
q.breakable()
q.text('}')
-class set_vlan_vid(Action):
+action.subtypes[2] = set_vlan_pcp
+
+class set_vlan_vid(action):
type = 1
def __init__(self, vlan_vid=None):
@@ -1546,15 +1404,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = set_vlan_vid()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 1)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
obj.vlan_vid = reader.read("!H")[0]
reader.skip(2)
return obj
@@ -1564,13 +1420,6 @@
if self.vlan_vid != other.vlan_vid: 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("set_vlan_vid {")
with q.group():
@@ -1581,56 +1430,6 @@
q.breakable()
q.text('}')
+action.subtypes[1] = set_vlan_vid
-def parse_experimenter(reader):
- experimenter, = reader.peek("!4xL")
- if experimenter == 0x005c16c7: # Big Switch Networks
- subtype, = reader.peek("!8xL")
- elif experimenter == 0x00002320: # Nicira
- subtype, = reader.peek("!8xH")
- else:
- raise loxi.ProtocolError("unexpected experimenter id %#x" % experimenter)
- if subtype in experimenter_parsers[experimenter]:
- return experimenter_parsers[experimenter][subtype](reader)
- else:
- raise loxi.ProtocolError("unexpected BSN experimenter subtype %#x" % subtype)
-
-parsers = {
- const.OFPAT_OUTPUT : output.unpack,
- const.OFPAT_SET_VLAN_VID : set_vlan_vid.unpack,
- const.OFPAT_SET_VLAN_PCP : set_vlan_pcp.unpack,
- const.OFPAT_SET_DL_SRC : set_dl_src.unpack,
- const.OFPAT_SET_DL_DST : set_dl_dst.unpack,
- const.OFPAT_SET_NW_SRC : set_nw_src.unpack,
- const.OFPAT_SET_NW_DST : set_nw_dst.unpack,
- const.OFPAT_SET_NW_TOS : set_nw_tos.unpack,
- const.OFPAT_SET_NW_ECN : set_nw_ecn.unpack,
- const.OFPAT_SET_TP_SRC : set_tp_src.unpack,
- const.OFPAT_SET_TP_DST : set_tp_dst.unpack,
- const.OFPAT_COPY_TTL_OUT : copy_ttl_out.unpack,
- const.OFPAT_COPY_TTL_IN : copy_ttl_in.unpack,
- const.OFPAT_SET_MPLS_LABEL : set_mpls_label.unpack,
- const.OFPAT_SET_MPLS_TC : set_mpls_tc.unpack,
- const.OFPAT_SET_MPLS_TTL : set_mpls_ttl.unpack,
- const.OFPAT_DEC_MPLS_TTL : dec_mpls_ttl.unpack,
- const.OFPAT_PUSH_VLAN : push_vlan.unpack,
- const.OFPAT_POP_VLAN : pop_vlan.unpack,
- const.OFPAT_PUSH_MPLS : push_mpls.unpack,
- const.OFPAT_POP_MPLS : pop_mpls.unpack,
- const.OFPAT_SET_QUEUE : set_queue.unpack,
- const.OFPAT_GROUP : group.unpack,
- const.OFPAT_SET_NW_TTL : set_nw_ttl.unpack,
- const.OFPAT_DEC_NW_TTL : dec_nw_ttl.unpack,
- const.OFPAT_EXPERIMENTER : parse_experimenter,
-}
-
-experimenter_parsers = {
- 8992 : {
- 18: nicira_dec_ttl.unpack,
- },
- 6035143 : {
- 1: bsn_mirror.unpack,
- 2: bsn_set_tunnel_dst.unpack,
- },
-}
diff --git a/src/python/loxi/of11/common.py b/src/python/loxi/of11/common.py
index 868f86d..548edfd 100644
--- a/src/python/loxi/of11/common.py
+++ b/src/python/loxi/of11/common.py
@@ -2,62 +2,20 @@
# 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
+
+# Automatically generated by LOXI from template module.py
# Do not modify
-import sys
import struct
-import action
-import instruction # for unpack_list
+import loxi
import const
+import common
+import action
+import instruction
import util
import loxi.generic_util
-
-# HACK make this module visible as 'common' to simplify code generation
-common = sys.modules[__name__]
-
-def unpack_list_flow_stats_entry(reader):
- return loxi.generic_util.unpack_list_lv16(reader, flow_stats_entry.unpack)
-
-def unpack_list_queue_prop(reader):
- def deserializer(reader, typ):
- if typ == const.OFPQT_MIN_RATE:
- return queue_prop_min_rate.unpack(reader)
- else:
- raise loxi.ProtocolError("unknown queue prop %d" % typ)
- return loxi.generic_util.unpack_list_tlv16(reader, deserializer)
-
-def unpack_list_packet_queue(reader):
- def wrapper(reader):
- length, = reader.peek('!4xH')
- return packet_queue.unpack(reader.slice(length))
- return loxi.generic_util.unpack_list(reader, wrapper)
-
-def unpack_list_hello_elem(reader):
- def deserializer(reader, typ):
- if typ == const.OFPHET_VERSIONBITMAP:
- return hello_elem_versionbitmap.unpack(reader)
- else:
- return None
- return [x for x in loxi.generic_util.unpack_list_tlv16(reader, deserializer) if x != None]
-
-def unpack_list_bucket(reader):
- return loxi.generic_util.unpack_list_lv16(reader, bucket.unpack)
-
-def unpack_list_group_desc_stats_entry(reader):
- return loxi.generic_util.unpack_list_lv16(reader, group_desc_stats_entry.unpack)
-
-def unpack_list_group_stats_entry(reader):
- return loxi.generic_util.unpack_list_lv16(reader, group_stats_entry.unpack)
-
-def unpack_list_meter_stats(reader):
- def wrapper(reader):
- length, = reader.peek('!4xH')
- return meter_stats.unpack(reader.slice(length))
- return loxi.generic_util.unpack_list(reader, wrapper)
-
-class bsn_interface(object):
+class bsn_interface(loxi.OFObject):
def __init__(self, hw_addr=None, name=None, ipv4_addr=None, ipv4_netmask=None):
if hw_addr != None:
@@ -88,12 +46,8 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = bsn_interface()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
obj.hw_addr = list(reader.read('!6B'))
reader.skip(2)
obj.name = reader.read("!16s")[0].rstrip("\x00")
@@ -109,13 +63,6 @@
if self.ipv4_netmask != other.ipv4_netmask: 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_interface {")
with q.group():
@@ -135,7 +82,21 @@
q.breakable()
q.text('}')
-class bsn_vport_q_in_q(object):
+
+class bsn_vport(loxi.OFObject):
+ subtypes = {}
+
+ @staticmethod
+ def unpack(reader):
+ subtype, = reader.peek('!H', 0)
+ try:
+ subclass = bsn_vport.subtypes[subtype]
+ except KeyError:
+ raise loxi.ProtocolError("unknown bsn_vport subtype %#x" % subtype)
+ return subclass.unpack(reader)
+
+
+class bsn_vport_q_in_q(bsn_vport):
type = 0
def __init__(self, port_no=None, ingress_tpid=None, ingress_vlan_id=None, egress_tpid=None, egress_vlan_id=None, if_name=None):
@@ -180,15 +141,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
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]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.port_no = reader.read("!L")[0]
obj.ingress_tpid = reader.read("!H")[0]
obj.ingress_vlan_id = reader.read("!H")[0]
@@ -207,13 +166,6 @@
if self.if_name != other.if_name: 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():
@@ -239,7 +191,9 @@
q.breakable()
q.text('}')
-class bucket(object):
+bsn_vport.subtypes[0] = bsn_vport_q_in_q
+
+class bucket(loxi.OFObject):
def __init__(self, weight=None, watch_port=None, watch_group=None, actions=None):
if weight != None:
@@ -267,24 +221,22 @@
packed.append(util.pack_port_no(self.watch_port))
packed.append(struct.pack("!L", self.watch_group))
packed.append('\x00' * 4)
- packed.append(util.pack_list(self.actions))
+ packed.append(loxi.generic_util.pack_list(self.actions))
length = sum([len(x) for x in packed])
packed[0] = struct.pack("!H", length)
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = bucket()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (0 + 2))
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)
+ obj.actions = loxi.generic_util.unpack_list(reader, action.action.unpack)
return obj
def __eq__(self, other):
@@ -295,13 +247,6 @@
if self.actions != other.actions: 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("bucket {")
with q.group():
@@ -321,7 +266,8 @@
q.breakable()
q.text('}')
-class bucket_counter(object):
+
+class bucket_counter(loxi.OFObject):
def __init__(self, packet_count=None, byte_count=None):
if packet_count != None:
@@ -341,12 +287,8 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = bucket_counter()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
obj.packet_count = reader.read("!Q")[0]
obj.byte_count = reader.read("!Q")[0]
return obj
@@ -357,13 +299,6 @@
if self.byte_count != other.byte_count: 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("bucket_counter {")
with q.group():
@@ -377,7 +312,8 @@
q.breakable()
q.text('}')
-class flow_stats_entry(object):
+
+class flow_stats_entry(loxi.OFObject):
def __init__(self, table_id=None, duration_sec=None, duration_nsec=None, priority=None, idle_timeout=None, hard_timeout=None, cookie=None, packet_count=None, byte_count=None, match=None, instructions=None):
if table_id != None:
@@ -441,19 +377,17 @@
packed.append(struct.pack("!Q", self.packet_count))
packed.append(struct.pack("!Q", self.byte_count))
packed.append(self.match.pack())
- packed.append(util.pack_list(self.instructions))
+ packed.append(loxi.generic_util.pack_list(self.instructions))
length = sum([len(x) for x in packed])
packed[0] = struct.pack("!H", length)
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = flow_stats_entry()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (0 + 2))
obj.table_id = reader.read("!B")[0]
reader.skip(1)
obj.duration_sec = reader.read("!L")[0]
@@ -466,7 +400,7 @@
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)
+ obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
return obj
def __eq__(self, other):
@@ -484,13 +418,6 @@
if self.instructions != other.instructions: 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("flow_stats_entry {")
with q.group():
@@ -531,7 +458,8 @@
q.breakable()
q.text('}')
-class group_desc_stats_entry(object):
+
+class group_desc_stats_entry(loxi.OFObject):
def __init__(self, group_type=None, group_id=None, buckets=None):
if group_type != None:
@@ -554,23 +482,21 @@
packed.append(struct.pack("!B", self.group_type))
packed.append('\x00' * 1)
packed.append(struct.pack("!L", self.group_id))
- packed.append(util.pack_list(self.buckets))
+ packed.append(loxi.generic_util.pack_list(self.buckets))
length = sum([len(x) for x in packed])
packed[0] = struct.pack("!H", length)
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = group_desc_stats_entry()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (0 + 2))
obj.group_type = reader.read("!B")[0]
reader.skip(1)
obj.group_id = reader.read("!L")[0]
- obj.buckets = common.unpack_list_bucket(reader)
+ obj.buckets = loxi.generic_util.unpack_list(reader, common.bucket.unpack)
return obj
def __eq__(self, other):
@@ -580,13 +506,6 @@
if self.buckets != other.buckets: 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("group_desc_stats_entry {")
with q.group():
@@ -603,7 +522,8 @@
q.breakable()
q.text('}')
-class group_stats_entry(object):
+
+class group_stats_entry(loxi.OFObject):
def __init__(self, group_id=None, ref_count=None, packet_count=None, byte_count=None, bucket_stats=None):
if group_id != None:
@@ -637,19 +557,17 @@
packed.append('\x00' * 4)
packed.append(struct.pack("!Q", self.packet_count))
packed.append(struct.pack("!Q", self.byte_count))
- packed.append(util.pack_list(self.bucket_stats))
+ packed.append(loxi.generic_util.pack_list(self.bucket_stats))
length = sum([len(x) for x in packed])
packed[0] = struct.pack("!H", length)
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = group_stats_entry()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (0 + 2))
reader.skip(2)
obj.group_id = reader.read("!L")[0]
obj.ref_count = reader.read("!L")[0]
@@ -668,13 +586,6 @@
if self.bucket_stats != other.bucket_stats: 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("group_stats_entry {")
with q.group():
@@ -697,7 +608,8 @@
q.breakable()
q.text('}')
-class match_v2(object):
+
+class match_v2(loxi.OFObject):
type = 0
def __init__(self, in_port=None, wildcards=None, eth_src=None, eth_src_mask=None, eth_dst=None, eth_dst_mask=None, vlan_vid=None, vlan_pcp=None, eth_type=None, ip_dscp=None, ip_proto=None, ipv4_src=None, ipv4_src_mask=None, ipv4_dst=None, ipv4_dst_mask=None, tcp_src=None, tcp_dst=None, mpls_label=None, mpls_tc=None, metadata=None, metadata_mask=None):
@@ -819,15 +731,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = match_v2()
- 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]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.in_port = util.unpack_port_no(reader)
obj.wildcards = util.unpack_wc_bmap(reader)
obj.eth_src = list(reader.read('!6B'))
@@ -878,13 +788,6 @@
if self.metadata_mask != other.metadata_mask: 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("match_v2 {")
with q.group():
@@ -955,7 +858,8 @@
q.breakable()
q.text('}')
-class packet_queue(object):
+
+class packet_queue(loxi.OFObject):
def __init__(self, queue_id=None, properties=None):
if queue_id != None:
@@ -973,22 +877,20 @@
packed.append(struct.pack("!L", self.queue_id))
packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
packed.append('\x00' * 2)
- packed.append(util.pack_list(self.properties))
+ packed.append(loxi.generic_util.pack_list(self.properties))
length = sum([len(x) for x in packed])
packed[1] = struct.pack("!H", length)
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = packet_queue()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
obj.queue_id = reader.read("!L")[0]
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (4 + 2))
reader.skip(2)
- obj.properties = common.unpack_list_queue_prop(reader)
+ obj.properties = loxi.generic_util.unpack_list(reader, common.queue_prop.unpack)
return obj
def __eq__(self, other):
@@ -997,13 +899,6 @@
if self.properties != other.properties: 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("packet_queue {")
with q.group():
@@ -1017,7 +912,8 @@
q.breakable()
q.text('}')
-class port_desc(object):
+
+class port_desc(loxi.OFObject):
def __init__(self, port_no=None, hw_addr=None, name=None, config=None, state=None, curr=None, advertised=None, supported=None, peer=None, curr_speed=None, max_speed=None):
if port_no != None:
@@ -1084,12 +980,8 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = port_desc()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
obj.port_no = util.unpack_port_no(reader)
reader.skip(4)
obj.hw_addr = list(reader.read('!6B'))
@@ -1120,13 +1012,6 @@
if self.max_speed != other.max_speed: 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("port_desc {")
with q.group():
@@ -1167,7 +1052,8 @@
q.breakable()
q.text('}')
-class port_stats_entry(object):
+
+class port_stats_entry(loxi.OFObject):
def __init__(self, port_no=None, rx_packets=None, tx_packets=None, rx_bytes=None, tx_bytes=None, rx_dropped=None, tx_dropped=None, rx_errors=None, tx_errors=None, rx_frame_err=None, rx_over_err=None, rx_crc_err=None, collisions=None):
if port_no != None:
@@ -1243,12 +1129,8 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = port_stats_entry()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
obj.port_no = util.unpack_port_no(reader)
reader.skip(4)
obj.rx_packets = reader.read("!Q")[0]
@@ -1282,13 +1164,6 @@
if self.collisions != other.collisions: 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("port_stats_entry {")
with q.group():
@@ -1335,7 +1210,21 @@
q.breakable()
q.text('}')
-class queue_prop_min_rate(object):
+
+class queue_prop(loxi.OFObject):
+ subtypes = {}
+
+ @staticmethod
+ def unpack(reader):
+ subtype, = reader.peek('!H', 0)
+ try:
+ subclass = queue_prop.subtypes[subtype]
+ except KeyError:
+ raise loxi.ProtocolError("unknown queue_prop subtype %#x" % subtype)
+ return subclass.unpack(reader)
+
+
+class queue_prop_min_rate(queue_prop):
type = 1
def __init__(self, rate=None):
@@ -1357,15 +1246,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = queue_prop_min_rate()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 1)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
reader.skip(4)
obj.rate = reader.read("!H")[0]
reader.skip(6)
@@ -1376,13 +1263,6 @@
if self.rate != other.rate: 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_min_rate {")
with q.group():
@@ -1393,7 +1273,9 @@
q.breakable()
q.text('}')
-class queue_stats_entry(object):
+queue_prop.subtypes[1] = queue_prop_min_rate
+
+class queue_stats_entry(loxi.OFObject):
def __init__(self, port_no=None, queue_id=None, tx_bytes=None, tx_packets=None, tx_errors=None):
if port_no != None:
@@ -1428,12 +1310,8 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = queue_stats_entry()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
obj.port_no = util.unpack_port_no(reader)
obj.queue_id = reader.read("!L")[0]
obj.tx_bytes = reader.read("!Q")[0]
@@ -1450,13 +1328,6 @@
if self.tx_errors != other.tx_errors: 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_stats_entry {")
with q.group():
@@ -1479,7 +1350,8 @@
q.breakable()
q.text('}')
-class table_stats_entry(object):
+
+class table_stats_entry(loxi.OFObject):
def __init__(self, table_id=None, name=None, wildcards=None, match=None, instructions=None, write_actions=None, apply_actions=None, config=None, max_entries=None, active_count=None, lookup_count=None, matched_count=None):
if table_id != None:
@@ -1550,12 +1422,8 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = table_stats_entry()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
obj.table_id = reader.read("!B")[0]
reader.skip(7)
obj.name = reader.read("!32s")[0].rstrip("\x00")
@@ -1587,13 +1455,6 @@
if self.matched_count != other.matched_count: 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("table_stats_entry {")
with q.group():
@@ -1638,4 +1499,5 @@
q.text('}')
+
match = match_v2
diff --git a/src/python/loxi/of11/instruction.py b/src/python/loxi/of11/instruction.py
index 38bcdb6..e93e070 100644
--- a/src/python/loxi/of11/instruction.py
+++ b/src/python/loxi/of11/instruction.py
@@ -3,28 +3,32 @@
# 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 instruction.py
+# Automatically generated by LOXI from template module.py
# Do not modify
import struct
-import action
+import loxi
import const
+import common
+import action
+import instruction
import util
import loxi.generic_util
-import loxi
-def unpack_list(reader):
- def deserializer(reader, typ):
- parser = parsers.get(typ)
- if not parser: raise loxi.ProtocolError("unknown instruction type %d" % typ)
- return parser(reader)
- return loxi.generic_util.unpack_list_tlv16(reader, deserializer)
+class instruction(loxi.OFObject):
+ subtypes = {}
-class Instruction(object):
- type = None # override in subclass
- pass
+ @staticmethod
+ def unpack(reader):
+ subtype, = reader.peek('!H', 0)
+ try:
+ subclass = instruction.subtypes[subtype]
+ except KeyError:
+ raise loxi.ProtocolError("unknown instruction subtype %#x" % subtype)
+ return subclass.unpack(reader)
-class apply_actions(Instruction):
+
+class apply_actions(instruction):
type = 4
def __init__(self, actions=None):
@@ -39,23 +43,21 @@
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(util.pack_list(self.actions))
+ packed.append(loxi.generic_util.pack_list(self.actions))
length = sum([len(x) for x in packed])
packed[1] = struct.pack("!H", length)
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = apply_actions()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 4)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
reader.skip(4)
- obj.actions = action.unpack_list(reader)
+ obj.actions = loxi.generic_util.unpack_list(reader, action.action.unpack)
return obj
def __eq__(self, other):
@@ -63,13 +65,6 @@
if self.actions != other.actions: 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("apply_actions {")
with q.group():
@@ -80,7 +75,9 @@
q.breakable()
q.text('}')
-class clear_actions(Instruction):
+instruction.subtypes[4] = apply_actions
+
+class clear_actions(instruction):
type = 5
def __init__(self):
@@ -96,15 +93,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = clear_actions()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 5)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
reader.skip(4)
return obj
@@ -112,13 +107,6 @@
if type(self) != type(other): 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("clear_actions {")
with q.group():
@@ -127,7 +115,23 @@
q.breakable()
q.text('}')
-class goto_table(Instruction):
+instruction.subtypes[5] = clear_actions
+
+class experimenter(instruction):
+ subtypes = {}
+
+ @staticmethod
+ def unpack(reader):
+ subtype, = reader.peek('!L', 4)
+ try:
+ subclass = experimenter.subtypes[subtype]
+ except KeyError:
+ raise loxi.ProtocolError("unknown experimenter instruction subtype %#x" % subtype)
+ return subclass.unpack(reader)
+
+instruction.subtypes[65535] = experimenter
+
+class goto_table(instruction):
type = 1
def __init__(self, table_id=None):
@@ -148,15 +152,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = goto_table()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 1)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
obj.table_id = reader.read("!B")[0]
reader.skip(3)
return obj
@@ -166,13 +168,6 @@
if self.table_id != other.table_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("goto_table {")
with q.group():
@@ -183,7 +178,9 @@
q.breakable()
q.text('}')
-class write_actions(Instruction):
+instruction.subtypes[1] = goto_table
+
+class write_actions(instruction):
type = 3
def __init__(self, actions=None):
@@ -198,23 +195,21 @@
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(util.pack_list(self.actions))
+ packed.append(loxi.generic_util.pack_list(self.actions))
length = sum([len(x) for x in packed])
packed[1] = struct.pack("!H", length)
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = write_actions()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 3)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
reader.skip(4)
- obj.actions = action.unpack_list(reader)
+ obj.actions = loxi.generic_util.unpack_list(reader, action.action.unpack)
return obj
def __eq__(self, other):
@@ -222,13 +217,6 @@
if self.actions != other.actions: 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("write_actions {")
with q.group():
@@ -239,7 +227,9 @@
q.breakable()
q.text('}')
-class write_metadata(Instruction):
+instruction.subtypes[3] = write_actions
+
+class write_metadata(instruction):
type = 2
def __init__(self, metadata=None, metadata_mask=None):
@@ -265,15 +255,13 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
+ def unpack(reader):
obj = write_metadata()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_type = reader.read("!H")[0]
assert(_type == 2)
_len = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_len - (2 + 2))
reader.skip(4)
obj.metadata = reader.read("!Q")[0]
obj.metadata_mask = reader.read("!Q")[0]
@@ -285,13 +273,6 @@
if self.metadata_mask != other.metadata_mask: 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("write_metadata {")
with q.group():
@@ -305,26 +286,6 @@
q.breakable()
q.text('}')
+instruction.subtypes[2] = write_metadata
-def parse_experimenter(reader):
- experimenter, = reader.peek("!4xL")
- if experimenter == 0x005c16c7: # Big Switch Networks
- subtype, = reader.peek("!8xL")
- else:
- raise loxi.ProtocolError("unexpected experimenter id %#x" % experimenter)
- if subtype in experimenter_parsers[experimenter]:
- return experimenter_parsers[experimenter][subtype](reader)
- else:
- raise loxi.ProtocolError("unexpected experimenter id %#x subtype %#x" % (experimenter, subtype))
-
-parsers = {
- const.OFPIT_GOTO_TABLE : goto_table.unpack,
- const.OFPIT_WRITE_METADATA : write_metadata.unpack,
- const.OFPIT_WRITE_ACTIONS : write_actions.unpack,
- const.OFPIT_APPLY_ACTIONS : apply_actions.unpack,
- const.OFPIT_CLEAR_ACTIONS : clear_actions.unpack,
-}
-
-experimenter_parsers = {
-}
diff --git a/src/python/loxi/of11/message.py b/src/python/loxi/of11/message.py
index 0566f03..7e2b111 100644
--- a/src/python/loxi/of11/message.py
+++ b/src/python/loxi/of11/message.py
@@ -3,30 +3,55 @@
# 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 message.py
+# Automatically generated by LOXI from template module.py
# Do not modify
import struct
import loxi
import const
import common
-import action # for unpack_list
-import instruction # for unpack_list
+import action
+import instruction
import util
import loxi.generic_util
-class Message(object):
- version = const.OFP_VERSION
- type = None # override in subclass
- xid = None
+class message(loxi.OFObject):
+ subtypes = {}
-class aggregate_stats_reply(Message):
+ @staticmethod
+ def unpack(reader):
+ subtype, = reader.peek('B', 1)
+ try:
+ subclass = message.subtypes[subtype]
+ except KeyError:
+ raise loxi.ProtocolError("unknown message subtype %#x" % subtype)
+ return subclass.unpack(reader)
+
+
+class stats_reply(message):
+ subtypes = {}
+
+ @staticmethod
+ def unpack(reader):
+ subtype, = reader.peek('!H', 8)
+ try:
+ subclass = stats_reply.subtypes[subtype]
+ except KeyError:
+ raise loxi.ProtocolError("unknown stats_reply message subtype %#x" % subtype)
+ return subclass.unpack(reader)
+
+message.subtypes[19] = stats_reply
+
+class aggregate_stats_reply(stats_reply):
version = 2
type = 19
stats_type = 2
def __init__(self, xid=None, flags=None, packet_count=None, byte_count=None, flow_count=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if flags != None:
self.flags = flags
else:
@@ -43,6 +68,7 @@
self.flow_count = flow_count
else:
self.flow_count = 0
+ return
def pack(self):
packed = []
@@ -62,18 +88,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = aggregate_stats_reply()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 19)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_stats_type = reader.read("!H")[0]
assert(_stats_type == 2)
@@ -87,8 +110,6 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.flags != other.flags: return False
if self.packet_count != other.packet_count: return False
@@ -96,16 +117,6 @@
if self.flow_count != other.flow_count: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("aggregate_stats_reply {")
with q.group():
@@ -131,13 +142,32 @@
q.breakable()
q.text('}')
-class aggregate_stats_request(Message):
+stats_reply.subtypes[2] = aggregate_stats_reply
+
+class stats_request(message):
+ subtypes = {}
+
+ @staticmethod
+ def unpack(reader):
+ subtype, = reader.peek('!H', 8)
+ try:
+ subclass = stats_request.subtypes[subtype]
+ except KeyError:
+ raise loxi.ProtocolError("unknown stats_request message subtype %#x" % subtype)
+ return subclass.unpack(reader)
+
+message.subtypes[18] = stats_request
+
+class aggregate_stats_request(stats_request):
version = 2
type = 18
stats_type = 2
def __init__(self, xid=None, flags=None, table_id=None, out_port=None, out_group=None, cookie=None, cookie_mask=None, match=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if flags != None:
self.flags = flags
else:
@@ -166,6 +196,7 @@
self.match = match
else:
self.match = common.match()
+ return
def pack(self):
packed = []
@@ -189,18 +220,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = aggregate_stats_request()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 18)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_stats_type = reader.read("!H")[0]
assert(_stats_type == 2)
@@ -218,8 +246,6 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.flags != other.flags: return False
if self.table_id != other.table_id: return False
@@ -230,16 +256,6 @@
if self.match != other.match: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("aggregate_stats_request {")
with q.group():
@@ -274,13 +290,32 @@
q.breakable()
q.text('}')
-class bad_action_error_msg(Message):
+stats_request.subtypes[2] = aggregate_stats_request
+
+class error_msg(message):
+ subtypes = {}
+
+ @staticmethod
+ def unpack(reader):
+ subtype, = reader.peek('!H', 8)
+ try:
+ subclass = error_msg.subtypes[subtype]
+ except KeyError:
+ raise loxi.ProtocolError("unknown error_msg message subtype %#x" % subtype)
+ return subclass.unpack(reader)
+
+message.subtypes[1] = error_msg
+
+class bad_action_error_msg(error_msg):
version = 2
type = 1
err_type = 2
def __init__(self, xid=None, code=None, data=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if code != None:
self.code = code
else:
@@ -289,6 +324,7 @@
self.data = data
else:
self.data = ''
+ return
def pack(self):
packed = []
@@ -304,18 +340,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = bad_action_error_msg()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 1)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_err_type = reader.read("!H")[0]
assert(_err_type == 2)
@@ -325,23 +358,11 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.code != other.code: return False
if self.data != other.data: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("bad_action_error_msg {")
with q.group():
@@ -361,13 +382,18 @@
q.breakable()
q.text('}')
-class bad_instruction_error_msg(Message):
+error_msg.subtypes[2] = bad_action_error_msg
+
+class bad_instruction_error_msg(error_msg):
version = 2
type = 1
err_type = 3
def __init__(self, xid=None, code=None, data=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if code != None:
self.code = code
else:
@@ -376,6 +402,7 @@
self.data = data
else:
self.data = ''
+ return
def pack(self):
packed = []
@@ -391,18 +418,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = bad_instruction_error_msg()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 1)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_err_type = reader.read("!H")[0]
assert(_err_type == 3)
@@ -412,23 +436,11 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.code != other.code: return False
if self.data != other.data: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("bad_instruction_error_msg {")
with q.group():
@@ -448,13 +460,18 @@
q.breakable()
q.text('}')
-class bad_match_error_msg(Message):
+error_msg.subtypes[3] = bad_instruction_error_msg
+
+class bad_match_error_msg(error_msg):
version = 2
type = 1
err_type = 4
def __init__(self, xid=None, code=None, data=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if code != None:
self.code = code
else:
@@ -463,6 +480,7 @@
self.data = data
else:
self.data = ''
+ return
def pack(self):
packed = []
@@ -478,18 +496,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = bad_match_error_msg()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 1)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_err_type = reader.read("!H")[0]
assert(_err_type == 4)
@@ -499,23 +514,11 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.code != other.code: return False
if self.data != other.data: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("bad_match_error_msg {")
with q.group():
@@ -535,13 +538,18 @@
q.breakable()
q.text('}')
-class bad_request_error_msg(Message):
+error_msg.subtypes[4] = bad_match_error_msg
+
+class bad_request_error_msg(error_msg):
version = 2
type = 1
err_type = 1
def __init__(self, xid=None, code=None, data=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if code != None:
self.code = code
else:
@@ -550,6 +558,7 @@
self.data = data
else:
self.data = ''
+ return
def pack(self):
packed = []
@@ -565,18 +574,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = bad_request_error_msg()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 1)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_err_type = reader.read("!H")[0]
assert(_err_type == 1)
@@ -586,23 +592,11 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.code != other.code: return False
if self.data != other.data: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("bad_request_error_msg {")
with q.group():
@@ -622,12 +616,18 @@
q.breakable()
q.text('}')
-class barrier_reply(Message):
+error_msg.subtypes[1] = bad_request_error_msg
+
+class barrier_reply(message):
version = 2
type = 21
def __init__(self, xid=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
+ return
def pack(self):
packed = []
@@ -640,38 +640,23 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = barrier_reply()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 21)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
return obj
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("barrier_reply {")
with q.group():
@@ -685,12 +670,18 @@
q.breakable()
q.text('}')
-class barrier_request(Message):
+message.subtypes[21] = barrier_reply
+
+class barrier_request(message):
version = 2
type = 20
def __init__(self, xid=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
+ return
def pack(self):
packed = []
@@ -703,38 +694,23 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = barrier_request()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 20)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
return obj
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("barrier_request {")
with q.group():
@@ -748,18 +724,52 @@
q.breakable()
q.text('}')
-class bsn_bw_clear_data_reply(Message):
+message.subtypes[20] = barrier_request
+
+class experimenter(message):
+ subtypes = {}
+
+ @staticmethod
+ def unpack(reader):
+ subtype, = reader.peek('!L', 8)
+ try:
+ subclass = experimenter.subtypes[subtype]
+ except KeyError:
+ raise loxi.ProtocolError("unknown experimenter message subtype %#x" % subtype)
+ return subclass.unpack(reader)
+
+message.subtypes[4] = experimenter
+
+class bsn_header(experimenter):
+ subtypes = {}
+
+ @staticmethod
+ def unpack(reader):
+ subtype, = reader.peek('!L', 12)
+ try:
+ subclass = bsn_header.subtypes[subtype]
+ except KeyError:
+ raise loxi.ProtocolError("unknown bsn_header experimenter message subtype %#x" % subtype)
+ return subclass.unpack(reader)
+
+experimenter.subtypes[6035143] = bsn_header
+
+class bsn_bw_clear_data_reply(bsn_header):
version = 2
type = 4
experimenter = 6035143
subtype = 22
def __init__(self, xid=None, status=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if status != None:
self.status = status
else:
self.status = 0
+ return
def pack(self):
packed = []
@@ -775,18 +785,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = bsn_bw_clear_data_reply()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 4)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_experimenter = reader.read("!L")[0]
assert(_experimenter == 6035143)
@@ -797,22 +804,10 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.status != other.status: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("bsn_bw_clear_data_reply {")
with q.group():
@@ -829,14 +824,20 @@
q.breakable()
q.text('}')
-class bsn_bw_clear_data_request(Message):
+bsn_header.subtypes[22] = bsn_bw_clear_data_reply
+
+class bsn_bw_clear_data_request(bsn_header):
version = 2
type = 4
experimenter = 6035143
subtype = 21
def __init__(self, xid=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
+ return
def pack(self):
packed = []
@@ -851,18 +852,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = bsn_bw_clear_data_request()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 4)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_experimenter = reader.read("!L")[0]
assert(_experimenter == 6035143)
@@ -872,21 +870,9 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("bsn_bw_clear_data_request {")
with q.group():
@@ -900,18 +886,24 @@
q.breakable()
q.text('}')
-class bsn_bw_enable_get_reply(Message):
+bsn_header.subtypes[21] = bsn_bw_clear_data_request
+
+class bsn_bw_enable_get_reply(bsn_header):
version = 2
type = 4
experimenter = 6035143
subtype = 20
def __init__(self, xid=None, enabled=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if enabled != None:
self.enabled = enabled
else:
self.enabled = 0
+ return
def pack(self):
packed = []
@@ -927,18 +919,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = bsn_bw_enable_get_reply()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 4)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_experimenter = reader.read("!L")[0]
assert(_experimenter == 6035143)
@@ -949,22 +938,10 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.enabled != other.enabled: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("bsn_bw_enable_get_reply {")
with q.group():
@@ -981,14 +958,20 @@
q.breakable()
q.text('}')
-class bsn_bw_enable_get_request(Message):
+bsn_header.subtypes[20] = bsn_bw_enable_get_reply
+
+class bsn_bw_enable_get_request(bsn_header):
version = 2
type = 4
experimenter = 6035143
subtype = 19
def __init__(self, xid=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
+ return
def pack(self):
packed = []
@@ -1003,18 +986,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = bsn_bw_enable_get_request()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 4)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_experimenter = reader.read("!L")[0]
assert(_experimenter == 6035143)
@@ -1024,21 +1004,9 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("bsn_bw_enable_get_request {")
with q.group():
@@ -1052,14 +1020,19 @@
q.breakable()
q.text('}')
-class bsn_bw_enable_set_reply(Message):
+bsn_header.subtypes[19] = bsn_bw_enable_get_request
+
+class bsn_bw_enable_set_reply(bsn_header):
version = 2
type = 4
experimenter = 6035143
subtype = 23
def __init__(self, xid=None, enable=None, status=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if enable != None:
self.enable = enable
else:
@@ -1068,6 +1041,7 @@
self.status = status
else:
self.status = 0
+ return
def pack(self):
packed = []
@@ -1084,18 +1058,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = bsn_bw_enable_set_reply()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 4)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_experimenter = reader.read("!L")[0]
assert(_experimenter == 6035143)
@@ -1107,23 +1078,11 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.enable != other.enable: return False
if self.status != other.status: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("bsn_bw_enable_set_reply {")
with q.group():
@@ -1143,18 +1102,24 @@
q.breakable()
q.text('}')
-class bsn_bw_enable_set_request(Message):
+bsn_header.subtypes[23] = bsn_bw_enable_set_reply
+
+class bsn_bw_enable_set_request(bsn_header):
version = 2
type = 4
experimenter = 6035143
subtype = 18
def __init__(self, xid=None, enable=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if enable != None:
self.enable = enable
else:
self.enable = 0
+ return
def pack(self):
packed = []
@@ -1170,18 +1135,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = bsn_bw_enable_set_request()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 4)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_experimenter = reader.read("!L")[0]
assert(_experimenter == 6035143)
@@ -1192,22 +1154,10 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.enable != other.enable: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("bsn_bw_enable_set_request {")
with q.group():
@@ -1224,18 +1174,24 @@
q.breakable()
q.text('}')
-class bsn_get_interfaces_reply(Message):
+bsn_header.subtypes[18] = bsn_bw_enable_set_request
+
+class bsn_get_interfaces_reply(bsn_header):
version = 2
type = 4
experimenter = 6035143
subtype = 10
def __init__(self, xid=None, interfaces=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if interfaces != None:
self.interfaces = interfaces
else:
self.interfaces = []
+ return
def pack(self):
packed = []
@@ -1245,24 +1201,21 @@
packed.append(struct.pack("!L", self.xid))
packed.append(struct.pack("!L", self.experimenter))
packed.append(struct.pack("!L", self.subtype))
- packed.append(util.pack_list(self.interfaces))
+ packed.append(loxi.generic_util.pack_list(self.interfaces))
length = sum([len(x) for x in packed])
packed[2] = struct.pack("!H", length)
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = bsn_get_interfaces_reply()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 4)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_experimenter = reader.read("!L")[0]
assert(_experimenter == 6035143)
@@ -1273,22 +1226,10 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.interfaces != other.interfaces: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("bsn_get_interfaces_reply {")
with q.group():
@@ -1305,14 +1246,20 @@
q.breakable()
q.text('}')
-class bsn_get_interfaces_request(Message):
+bsn_header.subtypes[10] = bsn_get_interfaces_reply
+
+class bsn_get_interfaces_request(bsn_header):
version = 2
type = 4
experimenter = 6035143
subtype = 9
def __init__(self, xid=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
+ return
def pack(self):
packed = []
@@ -1327,18 +1274,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = bsn_get_interfaces_request()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 4)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_experimenter = reader.read("!L")[0]
assert(_experimenter == 6035143)
@@ -1348,21 +1292,9 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("bsn_get_interfaces_request {")
with q.group():
@@ -1376,18 +1308,24 @@
q.breakable()
q.text('}')
-class bsn_get_mirroring_reply(Message):
+bsn_header.subtypes[9] = bsn_get_interfaces_request
+
+class bsn_get_mirroring_reply(bsn_header):
version = 2
type = 4
experimenter = 6035143
subtype = 5
def __init__(self, xid=None, report_mirror_ports=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if report_mirror_ports != None:
self.report_mirror_ports = report_mirror_ports
else:
self.report_mirror_ports = 0
+ return
def pack(self):
packed = []
@@ -1404,18 +1342,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = bsn_get_mirroring_reply()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 4)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_experimenter = reader.read("!L")[0]
assert(_experimenter == 6035143)
@@ -1427,22 +1362,10 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.report_mirror_ports != other.report_mirror_ports: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("bsn_get_mirroring_reply {")
with q.group():
@@ -1459,18 +1382,24 @@
q.breakable()
q.text('}')
-class bsn_get_mirroring_request(Message):
+bsn_header.subtypes[5] = bsn_get_mirroring_reply
+
+class bsn_get_mirroring_request(bsn_header):
version = 2
type = 4
experimenter = 6035143
subtype = 4
def __init__(self, xid=None, report_mirror_ports=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if report_mirror_ports != None:
self.report_mirror_ports = report_mirror_ports
else:
self.report_mirror_ports = 0
+ return
def pack(self):
packed = []
@@ -1487,18 +1416,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = bsn_get_mirroring_request()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 4)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_experimenter = reader.read("!L")[0]
assert(_experimenter == 6035143)
@@ -1510,22 +1436,10 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.report_mirror_ports != other.report_mirror_ports: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("bsn_get_mirroring_request {")
with q.group():
@@ -1542,14 +1456,19 @@
q.breakable()
q.text('}')
-class bsn_pdu_rx_reply(Message):
+bsn_header.subtypes[4] = bsn_get_mirroring_request
+
+class bsn_pdu_rx_reply(bsn_header):
version = 2
type = 4
experimenter = 6035143
subtype = 34
def __init__(self, xid=None, status=None, port_no=None, slot_num=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if status != None:
self.status = status
else:
@@ -1562,6 +1481,7 @@
self.slot_num = slot_num
else:
self.slot_num = 0
+ return
def pack(self):
packed = []
@@ -1579,18 +1499,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = bsn_pdu_rx_reply()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 4)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_experimenter = reader.read("!L")[0]
assert(_experimenter == 6035143)
@@ -1603,24 +1520,12 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.status != other.status: return False
if self.port_no != other.port_no: return False
if self.slot_num != other.slot_num: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("bsn_pdu_rx_reply {")
with q.group():
@@ -1643,14 +1548,19 @@
q.breakable()
q.text('}')
-class bsn_pdu_rx_request(Message):
+bsn_header.subtypes[34] = bsn_pdu_rx_reply
+
+class bsn_pdu_rx_request(bsn_header):
version = 2
type = 4
experimenter = 6035143
subtype = 33
def __init__(self, xid=None, timeout_ms=None, port_no=None, slot_num=None, data=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if timeout_ms != None:
self.timeout_ms = timeout_ms
else:
@@ -1667,6 +1577,7 @@
self.data = data
else:
self.data = ''
+ return
def pack(self):
packed = []
@@ -1686,18 +1597,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = bsn_pdu_rx_request()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 4)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_experimenter = reader.read("!L")[0]
assert(_experimenter == 6035143)
@@ -1712,8 +1620,6 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.timeout_ms != other.timeout_ms: return False
if self.port_no != other.port_no: return False
@@ -1721,16 +1627,6 @@
if self.data != other.data: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("bsn_pdu_rx_request {")
with q.group():
@@ -1756,14 +1652,19 @@
q.breakable()
q.text('}')
-class bsn_pdu_rx_timeout(Message):
+bsn_header.subtypes[33] = bsn_pdu_rx_request
+
+class bsn_pdu_rx_timeout(bsn_header):
version = 2
type = 4
experimenter = 6035143
subtype = 35
def __init__(self, xid=None, port_no=None, slot_num=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if port_no != None:
self.port_no = port_no
else:
@@ -1772,6 +1673,7 @@
self.slot_num = slot_num
else:
self.slot_num = 0
+ return
def pack(self):
packed = []
@@ -1788,18 +1690,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = bsn_pdu_rx_timeout()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 4)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_experimenter = reader.read("!L")[0]
assert(_experimenter == 6035143)
@@ -1811,23 +1710,11 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.port_no != other.port_no: return False
if self.slot_num != other.slot_num: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("bsn_pdu_rx_timeout {")
with q.group():
@@ -1847,14 +1734,19 @@
q.breakable()
q.text('}')
-class bsn_pdu_tx_reply(Message):
+bsn_header.subtypes[35] = bsn_pdu_rx_timeout
+
+class bsn_pdu_tx_reply(bsn_header):
version = 2
type = 4
experimenter = 6035143
subtype = 32
def __init__(self, xid=None, status=None, port_no=None, slot_num=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if status != None:
self.status = status
else:
@@ -1867,6 +1759,7 @@
self.slot_num = slot_num
else:
self.slot_num = 0
+ return
def pack(self):
packed = []
@@ -1884,18 +1777,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = bsn_pdu_tx_reply()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 4)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_experimenter = reader.read("!L")[0]
assert(_experimenter == 6035143)
@@ -1908,24 +1798,12 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.status != other.status: return False
if self.port_no != other.port_no: return False
if self.slot_num != other.slot_num: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("bsn_pdu_tx_reply {")
with q.group():
@@ -1948,14 +1826,19 @@
q.breakable()
q.text('}')
-class bsn_pdu_tx_request(Message):
+bsn_header.subtypes[32] = bsn_pdu_tx_reply
+
+class bsn_pdu_tx_request(bsn_header):
version = 2
type = 4
experimenter = 6035143
subtype = 31
def __init__(self, xid=None, tx_interval_ms=None, port_no=None, slot_num=None, data=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if tx_interval_ms != None:
self.tx_interval_ms = tx_interval_ms
else:
@@ -1972,6 +1855,7 @@
self.data = data
else:
self.data = ''
+ return
def pack(self):
packed = []
@@ -1991,18 +1875,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = bsn_pdu_tx_request()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 4)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_experimenter = reader.read("!L")[0]
assert(_experimenter == 6035143)
@@ -2017,8 +1898,6 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.tx_interval_ms != other.tx_interval_ms: return False
if self.port_no != other.port_no: return False
@@ -2026,16 +1905,6 @@
if self.data != other.data: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("bsn_pdu_tx_request {")
with q.group():
@@ -2061,18 +1930,24 @@
q.breakable()
q.text('}')
-class bsn_set_mirroring(Message):
+bsn_header.subtypes[31] = bsn_pdu_tx_request
+
+class bsn_set_mirroring(bsn_header):
version = 2
type = 4
experimenter = 6035143
subtype = 3
def __init__(self, xid=None, report_mirror_ports=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if report_mirror_ports != None:
self.report_mirror_ports = report_mirror_ports
else:
self.report_mirror_ports = 0
+ return
def pack(self):
packed = []
@@ -2089,18 +1964,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = bsn_set_mirroring()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 4)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_experimenter = reader.read("!L")[0]
assert(_experimenter == 6035143)
@@ -2112,22 +1984,10 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.report_mirror_ports != other.report_mirror_ports: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("bsn_set_mirroring {")
with q.group():
@@ -2144,18 +2004,24 @@
q.breakable()
q.text('}')
-class bsn_set_pktin_suppression_reply(Message):
+bsn_header.subtypes[3] = bsn_set_mirroring
+
+class bsn_set_pktin_suppression_reply(bsn_header):
version = 2
type = 4
experimenter = 6035143
subtype = 25
def __init__(self, xid=None, status=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if status != None:
self.status = status
else:
self.status = 0
+ return
def pack(self):
packed = []
@@ -2171,18 +2037,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = bsn_set_pktin_suppression_reply()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 4)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_experimenter = reader.read("!L")[0]
assert(_experimenter == 6035143)
@@ -2193,22 +2056,10 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.status != other.status: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("bsn_set_pktin_suppression_reply {")
with q.group():
@@ -2225,14 +2076,19 @@
q.breakable()
q.text('}')
-class bsn_set_pktin_suppression_request(Message):
+bsn_header.subtypes[25] = bsn_set_pktin_suppression_reply
+
+class bsn_set_pktin_suppression_request(bsn_header):
version = 2
type = 4
experimenter = 6035143
subtype = 11
def __init__(self, xid=None, enabled=None, idle_timeout=None, hard_timeout=None, priority=None, cookie=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if enabled != None:
self.enabled = enabled
else:
@@ -2253,6 +2109,7 @@
self.cookie = cookie
else:
self.cookie = 0
+ return
def pack(self):
packed = []
@@ -2273,18 +2130,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = bsn_set_pktin_suppression_request()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 4)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_experimenter = reader.read("!L")[0]
assert(_experimenter == 6035143)
@@ -2300,8 +2154,6 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.enabled != other.enabled: return False
if self.idle_timeout != other.idle_timeout: return False
@@ -2310,16 +2162,6 @@
if self.cookie != other.cookie: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("bsn_set_pktin_suppression_request {")
with q.group():
@@ -2348,14 +2190,75 @@
q.breakable()
q.text('}')
-class bsn_virtual_port_create_reply(Message):
+bsn_header.subtypes[11] = bsn_set_pktin_suppression_request
+
+class experimenter_stats_reply(stats_reply):
+ subtypes = {}
+
+ @staticmethod
+ def unpack(reader):
+ subtype, = reader.peek('!L', 16)
+ try:
+ subclass = experimenter_stats_reply.subtypes[subtype]
+ except KeyError:
+ raise loxi.ProtocolError("unknown experimenter_stats_reply stats_reply message subtype %#x" % subtype)
+ return subclass.unpack(reader)
+
+stats_reply.subtypes[65535] = experimenter_stats_reply
+
+class bsn_stats_reply(experimenter_stats_reply):
+ subtypes = {}
+
+ @staticmethod
+ def unpack(reader):
+ subtype, = reader.peek('!L', 20)
+ try:
+ subclass = bsn_stats_reply.subtypes[subtype]
+ except KeyError:
+ raise loxi.ProtocolError("unknown bsn_stats_reply experimenter_stats_reply stats_reply message subtype %#x" % subtype)
+ return subclass.unpack(reader)
+
+experimenter_stats_reply.subtypes[6035143] = bsn_stats_reply
+
+class experimenter_stats_request(stats_request):
+ subtypes = {}
+
+ @staticmethod
+ def unpack(reader):
+ subtype, = reader.peek('!L', 16)
+ try:
+ subclass = experimenter_stats_request.subtypes[subtype]
+ except KeyError:
+ raise loxi.ProtocolError("unknown experimenter_stats_request stats_request message subtype %#x" % subtype)
+ return subclass.unpack(reader)
+
+stats_request.subtypes[65535] = experimenter_stats_request
+
+class bsn_stats_request(experimenter_stats_request):
+ subtypes = {}
+
+ @staticmethod
+ def unpack(reader):
+ subtype, = reader.peek('!L', 20)
+ try:
+ subclass = bsn_stats_request.subtypes[subtype]
+ except KeyError:
+ raise loxi.ProtocolError("unknown bsn_stats_request experimenter_stats_request stats_request message subtype %#x" % subtype)
+ return subclass.unpack(reader)
+
+experimenter_stats_request.subtypes[6035143] = bsn_stats_request
+
+class bsn_virtual_port_create_reply(bsn_header):
version = 2
type = 4
experimenter = 6035143
subtype = 16
def __init__(self, xid=None, status=None, vport_no=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if status != None:
self.status = status
else:
@@ -2364,6 +2267,7 @@
self.vport_no = vport_no
else:
self.vport_no = 0
+ return
def pack(self):
packed = []
@@ -2380,18 +2284,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = bsn_virtual_port_create_reply()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 4)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_experimenter = reader.read("!L")[0]
assert(_experimenter == 6035143)
@@ -2403,23 +2304,11 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.status != other.status: return False
if self.vport_no != other.vport_no: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("bsn_virtual_port_create_reply {")
with q.group():
@@ -2439,18 +2328,24 @@
q.breakable()
q.text('}')
-class bsn_virtual_port_create_request(Message):
+bsn_header.subtypes[16] = bsn_virtual_port_create_reply
+
+class bsn_virtual_port_create_request(bsn_header):
version = 2
type = 4
experimenter = 6035143
subtype = 15
def __init__(self, xid=None, vport=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if vport != None:
self.vport = vport
else:
self.vport = common.bsn_vport_q_in_q()
+ return
def pack(self):
packed = []
@@ -2466,18 +2361,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = bsn_virtual_port_create_request()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 4)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_experimenter = reader.read("!L")[0]
assert(_experimenter == 6035143)
@@ -2488,22 +2380,10 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.vport != other.vport: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("bsn_virtual_port_create_request {")
with q.group():
@@ -2520,18 +2400,24 @@
q.breakable()
q.text('}')
-class bsn_virtual_port_remove_reply(Message):
+bsn_header.subtypes[15] = bsn_virtual_port_create_request
+
+class bsn_virtual_port_remove_reply(bsn_header):
version = 2
type = 4
experimenter = 6035143
subtype = 26
def __init__(self, xid=None, status=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if status != None:
self.status = status
else:
self.status = 0
+ return
def pack(self):
packed = []
@@ -2547,18 +2433,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = bsn_virtual_port_remove_reply()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 4)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_experimenter = reader.read("!L")[0]
assert(_experimenter == 6035143)
@@ -2569,22 +2452,10 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.status != other.status: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("bsn_virtual_port_remove_reply {")
with q.group():
@@ -2601,18 +2472,24 @@
q.breakable()
q.text('}')
-class bsn_virtual_port_remove_request(Message):
+bsn_header.subtypes[26] = bsn_virtual_port_remove_reply
+
+class bsn_virtual_port_remove_request(bsn_header):
version = 2
type = 4
experimenter = 6035143
subtype = 17
def __init__(self, xid=None, vport_no=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if vport_no != None:
self.vport_no = vport_no
else:
self.vport_no = 0
+ return
def pack(self):
packed = []
@@ -2628,18 +2505,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = bsn_virtual_port_remove_request()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 4)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_experimenter = reader.read("!L")[0]
assert(_experimenter == 6035143)
@@ -2650,22 +2524,10 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.vport_no != other.vport_no: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("bsn_virtual_port_remove_request {")
with q.group():
@@ -2682,13 +2544,18 @@
q.breakable()
q.text('}')
-class desc_stats_reply(Message):
+bsn_header.subtypes[17] = bsn_virtual_port_remove_request
+
+class desc_stats_reply(stats_reply):
version = 2
type = 19
stats_type = 0
def __init__(self, xid=None, flags=None, mfr_desc=None, hw_desc=None, sw_desc=None, serial_num=None, dp_desc=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if flags != None:
self.flags = flags
else:
@@ -2713,6 +2580,7 @@
self.dp_desc = dp_desc
else:
self.dp_desc = ""
+ return
def pack(self):
packed = []
@@ -2733,18 +2601,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = desc_stats_reply()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 19)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_stats_type = reader.read("!H")[0]
assert(_stats_type == 0)
@@ -2759,8 +2624,6 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.flags != other.flags: return False
if self.mfr_desc != other.mfr_desc: return False
@@ -2770,16 +2633,6 @@
if self.dp_desc != other.dp_desc: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("desc_stats_reply {")
with q.group():
@@ -2811,17 +2664,23 @@
q.breakable()
q.text('}')
-class desc_stats_request(Message):
+stats_reply.subtypes[0] = desc_stats_reply
+
+class desc_stats_request(stats_request):
version = 2
type = 18
stats_type = 0
def __init__(self, xid=None, flags=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if flags != None:
self.flags = flags
else:
self.flags = 0
+ return
def pack(self):
packed = []
@@ -2837,18 +2696,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = desc_stats_request()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 18)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_stats_type = reader.read("!H")[0]
assert(_stats_type == 0)
@@ -2858,22 +2714,10 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.flags != other.flags: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("desc_stats_request {")
with q.group():
@@ -2890,16 +2734,22 @@
q.breakable()
q.text('}')
-class echo_reply(Message):
+stats_request.subtypes[0] = desc_stats_request
+
+class echo_reply(message):
version = 2
type = 3
def __init__(self, xid=None, data=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if data != None:
self.data = data
else:
self.data = ''
+ return
def pack(self):
packed = []
@@ -2913,40 +2763,25 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = echo_reply()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 3)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
obj.data = str(reader.read_all())
return obj
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.data != other.data: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("echo_reply {")
with q.group():
@@ -2963,16 +2798,22 @@
q.breakable()
q.text('}')
-class echo_request(Message):
+message.subtypes[3] = echo_reply
+
+class echo_request(message):
version = 2
type = 2
def __init__(self, xid=None, data=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if data != None:
self.data = data
else:
self.data = ''
+ return
def pack(self):
packed = []
@@ -2986,40 +2827,25 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = echo_request()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 2)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
obj.data = str(reader.read_all())
return obj
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.data != other.data: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("echo_request {")
with q.group():
@@ -3036,12 +2862,17 @@
q.breakable()
q.text('}')
-class features_reply(Message):
+message.subtypes[2] = echo_request
+
+class features_reply(message):
version = 2
type = 6
def __init__(self, xid=None, datapath_id=None, n_buffers=None, n_tables=None, capabilities=None, reserved=None, ports=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if datapath_id != None:
self.datapath_id = datapath_id
else:
@@ -3066,6 +2897,7 @@
self.ports = ports
else:
self.ports = []
+ return
def pack(self):
packed = []
@@ -3079,24 +2911,21 @@
packed.append('\x00' * 3)
packed.append(struct.pack("!L", self.capabilities))
packed.append(struct.pack("!L", self.reserved))
- packed.append(util.pack_list(self.ports))
+ packed.append(loxi.generic_util.pack_list(self.ports))
length = sum([len(x) for x in packed])
packed[2] = struct.pack("!H", length)
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = features_reply()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 6)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
obj.datapath_id = reader.read("!Q")[0]
obj.n_buffers = reader.read("!L")[0]
@@ -3109,8 +2938,6 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.datapath_id != other.datapath_id: return False
if self.n_buffers != other.n_buffers: return False
@@ -3120,16 +2947,6 @@
if self.ports != other.ports: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("features_reply {")
with q.group():
@@ -3161,12 +2978,18 @@
q.breakable()
q.text('}')
-class features_request(Message):
+message.subtypes[6] = features_reply
+
+class features_request(message):
version = 2
type = 5
def __init__(self, xid=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
+ return
def pack(self):
packed = []
@@ -3179,38 +3002,23 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = features_request()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 5)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
return obj
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("features_request {")
with q.group():
@@ -3224,13 +3032,32 @@
q.breakable()
q.text('}')
-class flow_add(Message):
+message.subtypes[5] = features_request
+
+class flow_mod(message):
+ subtypes = {}
+
+ @staticmethod
+ def unpack(reader):
+ subtype, = reader.peek('B', 25)
+ try:
+ subclass = flow_mod.subtypes[subtype]
+ except KeyError:
+ raise loxi.ProtocolError("unknown flow_mod message subtype %#x" % subtype)
+ return subclass.unpack(reader)
+
+message.subtypes[14] = flow_mod
+
+class flow_add(flow_mod):
version = 2
type = 14
_command = 0
def __init__(self, xid=None, cookie=None, cookie_mask=None, table_id=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, out_group=None, flags=None, match=None, instructions=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if cookie != None:
self.cookie = cookie
else:
@@ -3279,6 +3106,7 @@
self.instructions = instructions
else:
self.instructions = []
+ return
def pack(self):
packed = []
@@ -3299,24 +3127,21 @@
packed.append(struct.pack("!H", self.flags))
packed.append('\x00' * 2)
packed.append(self.match.pack())
- packed.append(util.pack_list(self.instructions))
+ packed.append(loxi.generic_util.pack_list(self.instructions))
length = sum([len(x) for x in packed])
packed[2] = struct.pack("!H", length)
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = flow_add()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 14)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
obj.cookie = reader.read("!Q")[0]
obj.cookie_mask = reader.read("!Q")[0]
@@ -3332,13 +3157,11 @@
obj.flags = reader.read("!H")[0]
reader.skip(2)
obj.match = common.match.unpack(reader)
- obj.instructions = instruction.unpack_list(reader)
+ obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
return obj
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.cookie != other.cookie: return False
if self.cookie_mask != other.cookie_mask: return False
@@ -3354,16 +3177,6 @@
if self.instructions != other.instructions: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("flow_add {")
with q.group():
@@ -3413,13 +3226,18 @@
q.breakable()
q.text('}')
-class flow_delete(Message):
+flow_mod.subtypes[0] = flow_add
+
+class flow_delete(flow_mod):
version = 2
type = 14
_command = 3
def __init__(self, xid=None, cookie=None, cookie_mask=None, table_id=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, out_group=None, flags=None, match=None, instructions=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if cookie != None:
self.cookie = cookie
else:
@@ -3468,6 +3286,7 @@
self.instructions = instructions
else:
self.instructions = []
+ return
def pack(self):
packed = []
@@ -3488,24 +3307,21 @@
packed.append(struct.pack("!H", self.flags))
packed.append('\x00' * 2)
packed.append(self.match.pack())
- packed.append(util.pack_list(self.instructions))
+ packed.append(loxi.generic_util.pack_list(self.instructions))
length = sum([len(x) for x in packed])
packed[2] = struct.pack("!H", length)
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = flow_delete()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 14)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
obj.cookie = reader.read("!Q")[0]
obj.cookie_mask = reader.read("!Q")[0]
@@ -3521,13 +3337,11 @@
obj.flags = reader.read("!H")[0]
reader.skip(2)
obj.match = common.match.unpack(reader)
- obj.instructions = instruction.unpack_list(reader)
+ obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
return obj
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.cookie != other.cookie: return False
if self.cookie_mask != other.cookie_mask: return False
@@ -3543,16 +3357,6 @@
if self.instructions != other.instructions: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("flow_delete {")
with q.group():
@@ -3602,13 +3406,18 @@
q.breakable()
q.text('}')
-class flow_delete_strict(Message):
+flow_mod.subtypes[3] = flow_delete
+
+class flow_delete_strict(flow_mod):
version = 2
type = 14
_command = 4
def __init__(self, xid=None, cookie=None, cookie_mask=None, table_id=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, out_group=None, flags=None, match=None, instructions=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if cookie != None:
self.cookie = cookie
else:
@@ -3657,6 +3466,7 @@
self.instructions = instructions
else:
self.instructions = []
+ return
def pack(self):
packed = []
@@ -3677,24 +3487,21 @@
packed.append(struct.pack("!H", self.flags))
packed.append('\x00' * 2)
packed.append(self.match.pack())
- packed.append(util.pack_list(self.instructions))
+ packed.append(loxi.generic_util.pack_list(self.instructions))
length = sum([len(x) for x in packed])
packed[2] = struct.pack("!H", length)
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = flow_delete_strict()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 14)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
obj.cookie = reader.read("!Q")[0]
obj.cookie_mask = reader.read("!Q")[0]
@@ -3710,13 +3517,11 @@
obj.flags = reader.read("!H")[0]
reader.skip(2)
obj.match = common.match.unpack(reader)
- obj.instructions = instruction.unpack_list(reader)
+ obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
return obj
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.cookie != other.cookie: return False
if self.cookie_mask != other.cookie_mask: return False
@@ -3732,16 +3537,6 @@
if self.instructions != other.instructions: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("flow_delete_strict {")
with q.group():
@@ -3791,13 +3586,18 @@
q.breakable()
q.text('}')
-class flow_mod_failed_error_msg(Message):
+flow_mod.subtypes[4] = flow_delete_strict
+
+class flow_mod_failed_error_msg(error_msg):
version = 2
type = 1
err_type = 5
def __init__(self, xid=None, code=None, data=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if code != None:
self.code = code
else:
@@ -3806,6 +3606,7 @@
self.data = data
else:
self.data = ''
+ return
def pack(self):
packed = []
@@ -3821,18 +3622,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = flow_mod_failed_error_msg()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 1)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_err_type = reader.read("!H")[0]
assert(_err_type == 5)
@@ -3842,23 +3640,11 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.code != other.code: return False
if self.data != other.data: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("flow_mod_failed_error_msg {")
with q.group():
@@ -3878,13 +3664,18 @@
q.breakable()
q.text('}')
-class flow_modify(Message):
+error_msg.subtypes[5] = flow_mod_failed_error_msg
+
+class flow_modify(flow_mod):
version = 2
type = 14
_command = 1
def __init__(self, xid=None, cookie=None, cookie_mask=None, table_id=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, out_group=None, flags=None, match=None, instructions=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if cookie != None:
self.cookie = cookie
else:
@@ -3933,6 +3724,7 @@
self.instructions = instructions
else:
self.instructions = []
+ return
def pack(self):
packed = []
@@ -3953,24 +3745,21 @@
packed.append(struct.pack("!H", self.flags))
packed.append('\x00' * 2)
packed.append(self.match.pack())
- packed.append(util.pack_list(self.instructions))
+ packed.append(loxi.generic_util.pack_list(self.instructions))
length = sum([len(x) for x in packed])
packed[2] = struct.pack("!H", length)
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = flow_modify()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 14)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
obj.cookie = reader.read("!Q")[0]
obj.cookie_mask = reader.read("!Q")[0]
@@ -3986,13 +3775,11 @@
obj.flags = reader.read("!H")[0]
reader.skip(2)
obj.match = common.match.unpack(reader)
- obj.instructions = instruction.unpack_list(reader)
+ obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
return obj
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.cookie != other.cookie: return False
if self.cookie_mask != other.cookie_mask: return False
@@ -4008,16 +3795,6 @@
if self.instructions != other.instructions: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("flow_modify {")
with q.group():
@@ -4067,13 +3844,18 @@
q.breakable()
q.text('}')
-class flow_modify_strict(Message):
+flow_mod.subtypes[1] = flow_modify
+
+class flow_modify_strict(flow_mod):
version = 2
type = 14
_command = 2
def __init__(self, xid=None, cookie=None, cookie_mask=None, table_id=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, out_group=None, flags=None, match=None, instructions=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if cookie != None:
self.cookie = cookie
else:
@@ -4122,6 +3904,7 @@
self.instructions = instructions
else:
self.instructions = []
+ return
def pack(self):
packed = []
@@ -4142,24 +3925,21 @@
packed.append(struct.pack("!H", self.flags))
packed.append('\x00' * 2)
packed.append(self.match.pack())
- packed.append(util.pack_list(self.instructions))
+ packed.append(loxi.generic_util.pack_list(self.instructions))
length = sum([len(x) for x in packed])
packed[2] = struct.pack("!H", length)
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = flow_modify_strict()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 14)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
obj.cookie = reader.read("!Q")[0]
obj.cookie_mask = reader.read("!Q")[0]
@@ -4175,13 +3955,11 @@
obj.flags = reader.read("!H")[0]
reader.skip(2)
obj.match = common.match.unpack(reader)
- obj.instructions = instruction.unpack_list(reader)
+ obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
return obj
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.cookie != other.cookie: return False
if self.cookie_mask != other.cookie_mask: return False
@@ -4197,16 +3975,6 @@
if self.instructions != other.instructions: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("flow_modify_strict {")
with q.group():
@@ -4256,12 +4024,17 @@
q.breakable()
q.text('}')
-class flow_removed(Message):
+flow_mod.subtypes[2] = flow_modify_strict
+
+class flow_removed(message):
version = 2
type = 11
def __init__(self, xid=None, cookie=None, priority=None, reason=None, table_id=None, duration_sec=None, duration_nsec=None, idle_timeout=None, packet_count=None, byte_count=None, match=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if cookie != None:
self.cookie = cookie
else:
@@ -4302,6 +4075,7 @@
self.match = match
else:
self.match = common.match()
+ return
def pack(self):
packed = []
@@ -4325,18 +4099,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = flow_removed()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 11)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
obj.cookie = reader.read("!Q")[0]
obj.priority = reader.read("!H")[0]
@@ -4353,8 +4124,6 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.cookie != other.cookie: return False
if self.priority != other.priority: return False
@@ -4368,16 +4137,6 @@
if self.match != other.match: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("flow_removed {")
with q.group():
@@ -4421,13 +4180,18 @@
q.breakable()
q.text('}')
-class flow_stats_reply(Message):
+message.subtypes[11] = flow_removed
+
+class flow_stats_reply(stats_reply):
version = 2
type = 19
stats_type = 1
def __init__(self, xid=None, flags=None, entries=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if flags != None:
self.flags = flags
else:
@@ -4436,6 +4200,7 @@
self.entries = entries
else:
self.entries = []
+ return
def pack(self):
packed = []
@@ -4446,51 +4211,36 @@
packed.append(struct.pack("!H", self.stats_type))
packed.append(struct.pack("!H", self.flags))
packed.append('\x00' * 4)
- packed.append(util.pack_list(self.entries))
+ packed.append(loxi.generic_util.pack_list(self.entries))
length = sum([len(x) for x in packed])
packed[2] = struct.pack("!H", length)
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = flow_stats_reply()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 19)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_stats_type = reader.read("!H")[0]
assert(_stats_type == 1)
obj.flags = reader.read("!H")[0]
reader.skip(4)
- obj.entries = common.unpack_list_flow_stats_entry(reader)
+ obj.entries = loxi.generic_util.unpack_list(reader, common.flow_stats_entry.unpack)
return obj
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.flags != other.flags: return False
if self.entries != other.entries: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("flow_stats_reply {")
with q.group():
@@ -4510,13 +4260,18 @@
q.breakable()
q.text('}')
-class flow_stats_request(Message):
+stats_reply.subtypes[1] = flow_stats_reply
+
+class flow_stats_request(stats_request):
version = 2
type = 18
stats_type = 1
def __init__(self, xid=None, flags=None, table_id=None, out_port=None, out_group=None, cookie=None, cookie_mask=None, match=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if flags != None:
self.flags = flags
else:
@@ -4545,6 +4300,7 @@
self.match = match
else:
self.match = common.match()
+ return
def pack(self):
packed = []
@@ -4568,18 +4324,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = flow_stats_request()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 18)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_stats_type = reader.read("!H")[0]
assert(_stats_type == 1)
@@ -4597,8 +4350,6 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.flags != other.flags: return False
if self.table_id != other.table_id: return False
@@ -4609,16 +4360,6 @@
if self.match != other.match: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("flow_stats_request {")
with q.group():
@@ -4653,12 +4394,17 @@
q.breakable()
q.text('}')
-class get_config_reply(Message):
+stats_request.subtypes[1] = flow_stats_request
+
+class get_config_reply(message):
version = 2
type = 8
def __init__(self, xid=None, flags=None, miss_send_len=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if flags != None:
self.flags = flags
else:
@@ -4667,6 +4413,7 @@
self.miss_send_len = miss_send_len
else:
self.miss_send_len = 0
+ return
def pack(self):
packed = []
@@ -4681,18 +4428,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = get_config_reply()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 8)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
obj.flags = reader.read("!H")[0]
obj.miss_send_len = reader.read("!H")[0]
@@ -4700,23 +4444,11 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.flags != other.flags: return False
if self.miss_send_len != other.miss_send_len: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("get_config_reply {")
with q.group():
@@ -4736,12 +4468,18 @@
q.breakable()
q.text('}')
-class get_config_request(Message):
+message.subtypes[8] = get_config_reply
+
+class get_config_request(message):
version = 2
type = 7
def __init__(self, xid=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
+ return
def pack(self):
packed = []
@@ -4754,38 +4492,23 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = get_config_request()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 7)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
return obj
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("get_config_request {")
with q.group():
@@ -4799,13 +4522,32 @@
q.breakable()
q.text('}')
-class group_add(Message):
+message.subtypes[7] = get_config_request
+
+class group_mod(message):
+ subtypes = {}
+
+ @staticmethod
+ def unpack(reader):
+ subtype, = reader.peek('!H', 8)
+ try:
+ subclass = group_mod.subtypes[subtype]
+ except KeyError:
+ raise loxi.ProtocolError("unknown group_mod message subtype %#x" % subtype)
+ return subclass.unpack(reader)
+
+message.subtypes[15] = group_mod
+
+class group_add(group_mod):
version = 2
type = 15
command = 0
def __init__(self, xid=None, group_type=None, group_id=None, buckets=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if group_type != None:
self.group_type = group_type
else:
@@ -4818,6 +4560,7 @@
self.buckets = buckets
else:
self.buckets = []
+ return
def pack(self):
packed = []
@@ -4829,53 +4572,38 @@
packed.append(struct.pack("!B", self.group_type))
packed.append('\x00' * 1)
packed.append(struct.pack("!L", self.group_id))
- packed.append(util.pack_list(self.buckets))
+ packed.append(loxi.generic_util.pack_list(self.buckets))
length = sum([len(x) for x in packed])
packed[2] = struct.pack("!H", length)
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = group_add()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 15)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_command = reader.read("!H")[0]
assert(_command == 0)
obj.group_type = reader.read("!B")[0]
reader.skip(1)
obj.group_id = reader.read("!L")[0]
- obj.buckets = common.unpack_list_bucket(reader)
+ obj.buckets = loxi.generic_util.unpack_list(reader, common.bucket.unpack)
return obj
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.group_type != other.group_type: return False
if self.group_id != other.group_id: return False
if self.buckets != other.buckets: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("group_add {")
with q.group():
@@ -4898,13 +4626,18 @@
q.breakable()
q.text('}')
-class group_delete(Message):
+group_mod.subtypes[0] = group_add
+
+class group_delete(group_mod):
version = 2
type = 15
command = 2
def __init__(self, xid=None, group_type=None, group_id=None, buckets=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if group_type != None:
self.group_type = group_type
else:
@@ -4917,6 +4650,7 @@
self.buckets = buckets
else:
self.buckets = []
+ return
def pack(self):
packed = []
@@ -4928,53 +4662,38 @@
packed.append(struct.pack("!B", self.group_type))
packed.append('\x00' * 1)
packed.append(struct.pack("!L", self.group_id))
- packed.append(util.pack_list(self.buckets))
+ packed.append(loxi.generic_util.pack_list(self.buckets))
length = sum([len(x) for x in packed])
packed[2] = struct.pack("!H", length)
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = group_delete()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 15)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_command = reader.read("!H")[0]
assert(_command == 2)
obj.group_type = reader.read("!B")[0]
reader.skip(1)
obj.group_id = reader.read("!L")[0]
- obj.buckets = common.unpack_list_bucket(reader)
+ obj.buckets = loxi.generic_util.unpack_list(reader, common.bucket.unpack)
return obj
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.group_type != other.group_type: return False
if self.group_id != other.group_id: return False
if self.buckets != other.buckets: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("group_delete {")
with q.group():
@@ -4997,13 +4716,18 @@
q.breakable()
q.text('}')
-class group_desc_stats_reply(Message):
+group_mod.subtypes[2] = group_delete
+
+class group_desc_stats_reply(stats_reply):
version = 2
type = 19
stats_type = 7
def __init__(self, xid=None, flags=None, entries=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if flags != None:
self.flags = flags
else:
@@ -5012,6 +4736,7 @@
self.entries = entries
else:
self.entries = []
+ return
def pack(self):
packed = []
@@ -5022,51 +4747,36 @@
packed.append(struct.pack("!H", self.stats_type))
packed.append(struct.pack("!H", self.flags))
packed.append('\x00' * 4)
- packed.append(util.pack_list(self.entries))
+ packed.append(loxi.generic_util.pack_list(self.entries))
length = sum([len(x) for x in packed])
packed[2] = struct.pack("!H", length)
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = group_desc_stats_reply()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 19)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_stats_type = reader.read("!H")[0]
assert(_stats_type == 7)
obj.flags = reader.read("!H")[0]
reader.skip(4)
- obj.entries = common.unpack_list_group_desc_stats_entry(reader)
+ obj.entries = loxi.generic_util.unpack_list(reader, common.group_desc_stats_entry.unpack)
return obj
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.flags != other.flags: return False
if self.entries != other.entries: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("group_desc_stats_reply {")
with q.group():
@@ -5086,17 +4796,23 @@
q.breakable()
q.text('}')
-class group_desc_stats_request(Message):
+stats_reply.subtypes[7] = group_desc_stats_reply
+
+class group_desc_stats_request(stats_request):
version = 2
type = 18
stats_type = 7
def __init__(self, xid=None, flags=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if flags != None:
self.flags = flags
else:
self.flags = 0
+ return
def pack(self):
packed = []
@@ -5112,18 +4828,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = group_desc_stats_request()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 18)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_stats_type = reader.read("!H")[0]
assert(_stats_type == 7)
@@ -5133,22 +4846,10 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.flags != other.flags: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("group_desc_stats_request {")
with q.group():
@@ -5165,13 +4866,18 @@
q.breakable()
q.text('}')
-class group_mod_failed_error_msg(Message):
+stats_request.subtypes[7] = group_desc_stats_request
+
+class group_mod_failed_error_msg(error_msg):
version = 2
type = 1
err_type = 6
def __init__(self, xid=None, code=None, data=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if code != None:
self.code = code
else:
@@ -5180,6 +4886,7 @@
self.data = data
else:
self.data = ''
+ return
def pack(self):
packed = []
@@ -5195,18 +4902,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = group_mod_failed_error_msg()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 1)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_err_type = reader.read("!H")[0]
assert(_err_type == 6)
@@ -5216,23 +4920,11 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.code != other.code: return False
if self.data != other.data: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("group_mod_failed_error_msg {")
with q.group():
@@ -5252,13 +4944,18 @@
q.breakable()
q.text('}')
-class group_modify(Message):
+error_msg.subtypes[6] = group_mod_failed_error_msg
+
+class group_modify(group_mod):
version = 2
type = 15
command = 1
def __init__(self, xid=None, group_type=None, group_id=None, buckets=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if group_type != None:
self.group_type = group_type
else:
@@ -5271,6 +4968,7 @@
self.buckets = buckets
else:
self.buckets = []
+ return
def pack(self):
packed = []
@@ -5282,53 +4980,38 @@
packed.append(struct.pack("!B", self.group_type))
packed.append('\x00' * 1)
packed.append(struct.pack("!L", self.group_id))
- packed.append(util.pack_list(self.buckets))
+ packed.append(loxi.generic_util.pack_list(self.buckets))
length = sum([len(x) for x in packed])
packed[2] = struct.pack("!H", length)
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = group_modify()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 15)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_command = reader.read("!H")[0]
assert(_command == 1)
obj.group_type = reader.read("!B")[0]
reader.skip(1)
obj.group_id = reader.read("!L")[0]
- obj.buckets = common.unpack_list_bucket(reader)
+ obj.buckets = loxi.generic_util.unpack_list(reader, common.bucket.unpack)
return obj
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.group_type != other.group_type: return False
if self.group_id != other.group_id: return False
if self.buckets != other.buckets: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("group_modify {")
with q.group():
@@ -5351,13 +5034,18 @@
q.breakable()
q.text('}')
-class group_stats_reply(Message):
+group_mod.subtypes[1] = group_modify
+
+class group_stats_reply(stats_reply):
version = 2
type = 19
stats_type = 6
def __init__(self, xid=None, flags=None, entries=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if flags != None:
self.flags = flags
else:
@@ -5366,6 +5054,7 @@
self.entries = entries
else:
self.entries = []
+ return
def pack(self):
packed = []
@@ -5376,51 +5065,36 @@
packed.append(struct.pack("!H", self.stats_type))
packed.append(struct.pack("!H", self.flags))
packed.append('\x00' * 4)
- packed.append(util.pack_list(self.entries))
+ packed.append(loxi.generic_util.pack_list(self.entries))
length = sum([len(x) for x in packed])
packed[2] = struct.pack("!H", length)
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = group_stats_reply()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 19)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_stats_type = reader.read("!H")[0]
assert(_stats_type == 6)
obj.flags = reader.read("!H")[0]
reader.skip(4)
- obj.entries = common.unpack_list_group_stats_entry(reader)
+ obj.entries = loxi.generic_util.unpack_list(reader, common.group_stats_entry.unpack)
return obj
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.flags != other.flags: return False
if self.entries != other.entries: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("group_stats_reply {")
with q.group():
@@ -5440,13 +5114,18 @@
q.breakable()
q.text('}')
-class group_stats_request(Message):
+stats_reply.subtypes[6] = group_stats_reply
+
+class group_stats_request(stats_request):
version = 2
type = 18
stats_type = 6
def __init__(self, xid=None, flags=None, group_id=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if flags != None:
self.flags = flags
else:
@@ -5455,6 +5134,7 @@
self.group_id = group_id
else:
self.group_id = 0
+ return
def pack(self):
packed = []
@@ -5472,18 +5152,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = group_stats_request()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 18)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_stats_type = reader.read("!H")[0]
assert(_stats_type == 6)
@@ -5495,23 +5172,11 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.flags != other.flags: return False
if self.group_id != other.group_id: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("group_stats_request {")
with q.group():
@@ -5531,12 +5196,18 @@
q.breakable()
q.text('}')
-class hello(Message):
+stats_request.subtypes[6] = group_stats_request
+
+class hello(message):
version = 2
type = 0
def __init__(self, xid=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
+ return
def pack(self):
packed = []
@@ -5549,38 +5220,23 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = hello()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 0)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
return obj
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("hello {")
with q.group():
@@ -5594,13 +5250,18 @@
q.breakable()
q.text('}')
-class hello_failed_error_msg(Message):
+message.subtypes[0] = hello
+
+class hello_failed_error_msg(error_msg):
version = 2
type = 1
err_type = 0
def __init__(self, xid=None, code=None, data=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if code != None:
self.code = code
else:
@@ -5609,6 +5270,7 @@
self.data = data
else:
self.data = ''
+ return
def pack(self):
packed = []
@@ -5624,18 +5286,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = hello_failed_error_msg()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 1)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_err_type = reader.read("!H")[0]
assert(_err_type == 0)
@@ -5645,23 +5304,11 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.code != other.code: return False
if self.data != other.data: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("hello_failed_error_msg {")
with q.group():
@@ -5681,12 +5328,31 @@
q.breakable()
q.text('}')
-class packet_in(Message):
+error_msg.subtypes[0] = hello_failed_error_msg
+
+class nicira_header(experimenter):
+ subtypes = {}
+
+ @staticmethod
+ def unpack(reader):
+ subtype, = reader.peek('!L', 12)
+ try:
+ subclass = nicira_header.subtypes[subtype]
+ except KeyError:
+ raise loxi.ProtocolError("unknown nicira_header experimenter message subtype %#x" % subtype)
+ return subclass.unpack(reader)
+
+experimenter.subtypes[8992] = nicira_header
+
+class packet_in(message):
version = 2
type = 10
def __init__(self, xid=None, buffer_id=None, in_port=None, in_phy_port=None, total_len=None, reason=None, table_id=None, data=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if buffer_id != None:
self.buffer_id = buffer_id
else:
@@ -5715,6 +5381,7 @@
self.data = data
else:
self.data = ''
+ return
def pack(self):
packed = []
@@ -5734,18 +5401,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = packet_in()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 10)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
obj.buffer_id = reader.read("!L")[0]
obj.in_port = util.unpack_port_no(reader)
@@ -5758,8 +5422,6 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.buffer_id != other.buffer_id: return False
if self.in_port != other.in_port: return False
@@ -5770,16 +5432,6 @@
if self.data != other.data: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("packet_in {")
with q.group():
@@ -5814,12 +5466,17 @@
q.breakable()
q.text('}')
-class packet_out(Message):
+message.subtypes[10] = packet_in
+
+class packet_out(message):
version = 2
type = 13
def __init__(self, xid=None, buffer_id=None, in_port=None, actions=None, data=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if buffer_id != None:
self.buffer_id = buffer_id
else:
@@ -5836,6 +5493,7 @@
self.data = data
else:
self.data = ''
+ return
def pack(self):
packed = []
@@ -5847,7 +5505,7 @@
packed.append(util.pack_port_no(self.in_port))
packed.append(struct.pack("!H", 0)) # placeholder for actions_len at index 6
packed.append('\x00' * 6)
- packed.append(util.pack_list(self.actions))
+ packed.append(loxi.generic_util.pack_list(self.actions))
packed[6] = struct.pack("!H", len(packed[-1]))
packed.append(self.data)
length = sum([len(x) for x in packed])
@@ -5855,31 +5513,26 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = packet_out()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 13)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
obj.buffer_id = reader.read("!L")[0]
obj.in_port = util.unpack_port_no(reader)
_actions_len = reader.read("!H")[0]
reader.skip(6)
- obj.actions = action.unpack_list(reader.slice(_actions_len))
+ obj.actions = loxi.generic_util.unpack_list(reader.slice(_actions_len), action.action.unpack)
obj.data = str(reader.read_all())
return obj
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.buffer_id != other.buffer_id: return False
if self.in_port != other.in_port: return False
@@ -5887,16 +5540,6 @@
if self.data != other.data: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("packet_out {")
with q.group():
@@ -5922,12 +5565,17 @@
q.breakable()
q.text('}')
-class port_mod(Message):
+message.subtypes[13] = packet_out
+
+class port_mod(message):
version = 2
type = 16
def __init__(self, xid=None, port_no=None, hw_addr=None, config=None, mask=None, advertise=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if port_no != None:
self.port_no = port_no
else:
@@ -5948,6 +5596,7 @@
self.advertise = advertise
else:
self.advertise = 0
+ return
def pack(self):
packed = []
@@ -5968,18 +5617,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = port_mod()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 16)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
obj.port_no = util.unpack_port_no(reader)
reader.skip(4)
@@ -5993,8 +5639,6 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.port_no != other.port_no: return False
if self.hw_addr != other.hw_addr: return False
@@ -6003,16 +5647,6 @@
if self.advertise != other.advertise: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("port_mod {")
with q.group():
@@ -6041,13 +5675,18 @@
q.breakable()
q.text('}')
-class port_mod_failed_error_msg(Message):
+message.subtypes[16] = port_mod
+
+class port_mod_failed_error_msg(error_msg):
version = 2
type = 1
err_type = 7
def __init__(self, xid=None, code=None, data=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if code != None:
self.code = code
else:
@@ -6056,6 +5695,7 @@
self.data = data
else:
self.data = ''
+ return
def pack(self):
packed = []
@@ -6071,18 +5711,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = port_mod_failed_error_msg()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 1)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_err_type = reader.read("!H")[0]
assert(_err_type == 7)
@@ -6092,23 +5729,11 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.code != other.code: return False
if self.data != other.data: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("port_mod_failed_error_msg {")
with q.group():
@@ -6128,13 +5753,18 @@
q.breakable()
q.text('}')
-class port_stats_reply(Message):
+error_msg.subtypes[7] = port_mod_failed_error_msg
+
+class port_stats_reply(stats_reply):
version = 2
type = 19
stats_type = 4
def __init__(self, xid=None, flags=None, entries=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if flags != None:
self.flags = flags
else:
@@ -6143,6 +5773,7 @@
self.entries = entries
else:
self.entries = []
+ return
def pack(self):
packed = []
@@ -6153,24 +5784,21 @@
packed.append(struct.pack("!H", self.stats_type))
packed.append(struct.pack("!H", self.flags))
packed.append('\x00' * 4)
- packed.append(util.pack_list(self.entries))
+ packed.append(loxi.generic_util.pack_list(self.entries))
length = sum([len(x) for x in packed])
packed[2] = struct.pack("!H", length)
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = port_stats_reply()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 19)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_stats_type = reader.read("!H")[0]
assert(_stats_type == 4)
@@ -6181,23 +5809,11 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.flags != other.flags: return False
if self.entries != other.entries: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("port_stats_reply {")
with q.group():
@@ -6217,13 +5833,18 @@
q.breakable()
q.text('}')
-class port_stats_request(Message):
+stats_reply.subtypes[4] = port_stats_reply
+
+class port_stats_request(stats_request):
version = 2
type = 18
stats_type = 4
def __init__(self, xid=None, flags=None, port_no=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if flags != None:
self.flags = flags
else:
@@ -6232,6 +5853,7 @@
self.port_no = port_no
else:
self.port_no = 0
+ return
def pack(self):
packed = []
@@ -6249,18 +5871,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = port_stats_request()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 18)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_stats_type = reader.read("!H")[0]
assert(_stats_type == 4)
@@ -6272,23 +5891,11 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.flags != other.flags: return False
if self.port_no != other.port_no: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("port_stats_request {")
with q.group():
@@ -6308,12 +5915,17 @@
q.breakable()
q.text('}')
-class port_status(Message):
+stats_request.subtypes[4] = port_stats_request
+
+class port_status(message):
version = 2
type = 12
def __init__(self, xid=None, reason=None, desc=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if reason != None:
self.reason = reason
else:
@@ -6322,6 +5934,7 @@
self.desc = desc
else:
self.desc = common.port_desc()
+ return
def pack(self):
packed = []
@@ -6337,18 +5950,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = port_status()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 12)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
obj.reason = reader.read("!B")[0]
reader.skip(7)
@@ -6357,23 +5967,11 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.reason != other.reason: return False
if self.desc != other.desc: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("port_status {")
with q.group():
@@ -6393,12 +5991,17 @@
q.breakable()
q.text('}')
-class queue_get_config_reply(Message):
+message.subtypes[12] = port_status
+
+class queue_get_config_reply(message):
version = 2
type = 23
def __init__(self, xid=None, port=None, queues=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if port != None:
self.port = port
else:
@@ -6407,6 +6010,7 @@
self.queues = queues
else:
self.queues = []
+ return
def pack(self):
packed = []
@@ -6416,49 +6020,34 @@
packed.append(struct.pack("!L", self.xid))
packed.append(util.pack_port_no(self.port))
packed.append('\x00' * 4)
- packed.append(util.pack_list(self.queues))
+ packed.append(loxi.generic_util.pack_list(self.queues))
length = sum([len(x) for x in packed])
packed[2] = struct.pack("!H", length)
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = queue_get_config_reply()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 23)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
obj.port = util.unpack_port_no(reader)
reader.skip(4)
- obj.queues = common.unpack_list_packet_queue(reader)
+ obj.queues = loxi.generic_util.unpack_list(reader, common.packet_queue.unpack)
return obj
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.port != other.port: return False
if self.queues != other.queues: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("queue_get_config_reply {")
with q.group():
@@ -6478,16 +6067,22 @@
q.breakable()
q.text('}')
-class queue_get_config_request(Message):
+message.subtypes[23] = queue_get_config_reply
+
+class queue_get_config_request(message):
version = 2
type = 22
def __init__(self, xid=None, port=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if port != None:
self.port = port
else:
self.port = 0
+ return
def pack(self):
packed = []
@@ -6502,18 +6097,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = queue_get_config_request()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 22)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
obj.port = util.unpack_port_no(reader)
reader.skip(4)
@@ -6521,22 +6113,10 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.port != other.port: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("queue_get_config_request {")
with q.group():
@@ -6553,13 +6133,18 @@
q.breakable()
q.text('}')
-class queue_op_failed_error_msg(Message):
+message.subtypes[22] = queue_get_config_request
+
+class queue_op_failed_error_msg(error_msg):
version = 2
type = 1
err_type = 9
def __init__(self, xid=None, code=None, data=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if code != None:
self.code = code
else:
@@ -6568,6 +6153,7 @@
self.data = data
else:
self.data = ''
+ return
def pack(self):
packed = []
@@ -6583,18 +6169,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = queue_op_failed_error_msg()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 1)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_err_type = reader.read("!H")[0]
assert(_err_type == 9)
@@ -6604,23 +6187,11 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.code != other.code: return False
if self.data != other.data: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("queue_op_failed_error_msg {")
with q.group():
@@ -6640,13 +6211,18 @@
q.breakable()
q.text('}')
-class queue_stats_reply(Message):
+error_msg.subtypes[9] = queue_op_failed_error_msg
+
+class queue_stats_reply(stats_reply):
version = 2
type = 19
stats_type = 5
def __init__(self, xid=None, flags=None, entries=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if flags != None:
self.flags = flags
else:
@@ -6655,6 +6231,7 @@
self.entries = entries
else:
self.entries = []
+ return
def pack(self):
packed = []
@@ -6665,24 +6242,21 @@
packed.append(struct.pack("!H", self.stats_type))
packed.append(struct.pack("!H", self.flags))
packed.append('\x00' * 4)
- packed.append(util.pack_list(self.entries))
+ packed.append(loxi.generic_util.pack_list(self.entries))
length = sum([len(x) for x in packed])
packed[2] = struct.pack("!H", length)
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = queue_stats_reply()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 19)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_stats_type = reader.read("!H")[0]
assert(_stats_type == 5)
@@ -6693,23 +6267,11 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.flags != other.flags: return False
if self.entries != other.entries: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("queue_stats_reply {")
with q.group():
@@ -6729,13 +6291,18 @@
q.breakable()
q.text('}')
-class queue_stats_request(Message):
+stats_reply.subtypes[5] = queue_stats_reply
+
+class queue_stats_request(stats_request):
version = 2
type = 18
stats_type = 5
def __init__(self, xid=None, flags=None, port_no=None, queue_id=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if flags != None:
self.flags = flags
else:
@@ -6748,6 +6315,7 @@
self.queue_id = queue_id
else:
self.queue_id = 0
+ return
def pack(self):
packed = []
@@ -6765,18 +6333,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = queue_stats_request()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 18)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_stats_type = reader.read("!H")[0]
assert(_stats_type == 5)
@@ -6788,24 +6353,12 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.flags != other.flags: return False
if self.port_no != other.port_no: return False
if self.queue_id != other.queue_id: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("queue_stats_request {")
with q.group():
@@ -6828,12 +6381,17 @@
q.breakable()
q.text('}')
-class set_config(Message):
+stats_request.subtypes[5] = queue_stats_request
+
+class set_config(message):
version = 2
type = 9
def __init__(self, xid=None, flags=None, miss_send_len=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if flags != None:
self.flags = flags
else:
@@ -6842,6 +6400,7 @@
self.miss_send_len = miss_send_len
else:
self.miss_send_len = 0
+ return
def pack(self):
packed = []
@@ -6856,18 +6415,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = set_config()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 9)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
obj.flags = reader.read("!H")[0]
obj.miss_send_len = reader.read("!H")[0]
@@ -6875,23 +6431,11 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.flags != other.flags: return False
if self.miss_send_len != other.miss_send_len: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("set_config {")
with q.group():
@@ -6911,13 +6455,18 @@
q.breakable()
q.text('}')
-class switch_config_failed_error_msg(Message):
+message.subtypes[9] = set_config
+
+class switch_config_failed_error_msg(error_msg):
version = 2
type = 1
err_type = 10
def __init__(self, xid=None, code=None, data=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if code != None:
self.code = code
else:
@@ -6926,6 +6475,7 @@
self.data = data
else:
self.data = ''
+ return
def pack(self):
packed = []
@@ -6941,18 +6491,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = switch_config_failed_error_msg()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 1)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_err_type = reader.read("!H")[0]
assert(_err_type == 10)
@@ -6962,23 +6509,11 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.code != other.code: return False
if self.data != other.data: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("switch_config_failed_error_msg {")
with q.group():
@@ -6998,12 +6533,17 @@
q.breakable()
q.text('}')
-class table_mod(Message):
+error_msg.subtypes[10] = switch_config_failed_error_msg
+
+class table_mod(message):
version = 2
type = 17
def __init__(self, xid=None, table_id=None, config=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if table_id != None:
self.table_id = table_id
else:
@@ -7012,6 +6552,7 @@
self.config = config
else:
self.config = 0
+ return
def pack(self):
packed = []
@@ -7027,18 +6568,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = table_mod()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 17)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
obj.table_id = reader.read("!B")[0]
reader.skip(3)
@@ -7047,23 +6585,11 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.table_id != other.table_id: return False
if self.config != other.config: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("table_mod {")
with q.group():
@@ -7083,13 +6609,18 @@
q.breakable()
q.text('}')
-class table_mod_failed_error_msg(Message):
+message.subtypes[17] = table_mod
+
+class table_mod_failed_error_msg(error_msg):
version = 2
type = 1
err_type = 8
def __init__(self, xid=None, code=None, data=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if code != None:
self.code = code
else:
@@ -7098,6 +6629,7 @@
self.data = data
else:
self.data = ''
+ return
def pack(self):
packed = []
@@ -7113,18 +6645,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = table_mod_failed_error_msg()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 1)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_err_type = reader.read("!H")[0]
assert(_err_type == 8)
@@ -7134,23 +6663,11 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.code != other.code: return False
if self.data != other.data: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("table_mod_failed_error_msg {")
with q.group():
@@ -7170,13 +6687,18 @@
q.breakable()
q.text('}')
-class table_stats_reply(Message):
+error_msg.subtypes[8] = table_mod_failed_error_msg
+
+class table_stats_reply(stats_reply):
version = 2
type = 19
stats_type = 3
def __init__(self, xid=None, flags=None, entries=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if flags != None:
self.flags = flags
else:
@@ -7185,6 +6707,7 @@
self.entries = entries
else:
self.entries = []
+ return
def pack(self):
packed = []
@@ -7195,24 +6718,21 @@
packed.append(struct.pack("!H", self.stats_type))
packed.append(struct.pack("!H", self.flags))
packed.append('\x00' * 4)
- packed.append(util.pack_list(self.entries))
+ packed.append(loxi.generic_util.pack_list(self.entries))
length = sum([len(x) for x in packed])
packed[2] = struct.pack("!H", length)
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = table_stats_reply()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 19)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_stats_type = reader.read("!H")[0]
assert(_stats_type == 3)
@@ -7223,23 +6743,11 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.flags != other.flags: return False
if self.entries != other.entries: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("table_stats_reply {")
with q.group():
@@ -7259,17 +6767,23 @@
q.breakable()
q.text('}')
-class table_stats_request(Message):
+stats_reply.subtypes[3] = table_stats_reply
+
+class table_stats_request(stats_request):
version = 2
type = 18
stats_type = 3
def __init__(self, xid=None, flags=None):
- self.xid = xid
+ if xid != None:
+ self.xid = xid
+ else:
+ self.xid = None
if flags != None:
self.flags = flags
else:
self.flags = 0
+ return
def pack(self):
packed = []
@@ -7285,18 +6799,15 @@
return ''.join(packed)
@staticmethod
- def unpack(buf):
- if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message")
+ def unpack(reader):
obj = table_stats_request()
- if type(buf) == loxi.generic_util.OFReader:
- reader = buf
- else:
- reader = loxi.generic_util.OFReader(buf)
_version = reader.read("!B")[0]
assert(_version == 2)
_type = reader.read("!B")[0]
assert(_type == 18)
_length = reader.read("!H")[0]
+ orig_reader = reader
+ reader = orig_reader.slice(_length - (2 + 2))
obj.xid = reader.read("!L")[0]
_stats_type = reader.read("!H")[0]
assert(_stats_type == 3)
@@ -7306,22 +6817,10 @@
def __eq__(self, other):
if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
if self.xid != other.xid: return False
if self.flags != other.flags: return False
return True
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __str__(self):
- return self.show()
-
- def show(self):
- import loxi.pp
- return loxi.pp.pp(self)
-
def pretty_print(self, q):
q.text("table_stats_request {")
with q.group():
@@ -7338,6 +6837,8 @@
q.breakable()
q.text('}')
+stats_request.subtypes[3] = table_stats_request
+
def parse_header(buf):
if len(buf) < 8:
@@ -7350,210 +6851,4 @@
raise loxi.ProtocolError("wrong OpenFlow version (expected %d, got %d)" % (const.OFP_VERSION, msg_ver))
if len(buf) != msg_len:
raise loxi.ProtocolError("incorrect message size")
- if msg_type in parsers:
- return parsers[msg_type](buf)
- else:
- raise loxi.ProtocolError("unexpected message type")
-
-def parse_error(buf):
- if len(buf) < 8 + 2:
- raise loxi.ProtocolError("message too short")
- err_type, = struct.unpack_from("!H", buf, 8)
- if err_type in error_msg_parsers:
- return error_msg_parsers[err_type](buf)
- else:
- raise loxi.ProtocolError("unexpected error type %u" % err_type)
-
-def parse_flow_mod(buf):
- if len(buf) < 25 + 1:
- raise loxi.ProtocolError("message too short")
- # Technically uint16_t for OF 1.0
- cmd, = struct.unpack_from("!B", buf, 25)
- if cmd in flow_mod_parsers:
- return flow_mod_parsers[cmd](buf)
- else:
- raise loxi.ProtocolError("unexpected flow mod cmd %u" % cmd)
-
-def parse_group_mod(buf):
- if len(buf) < 8 + 2:
- raise loxi.ProtocolError("message too short")
- cmd, = struct.unpack_from("!H", buf, 8)
- if cmd in flow_mod_parsers:
- return group_mod_parsers[cmd](buf)
- else:
- raise loxi.ProtocolError("unexpected group mod cmd %u" % cmd)
-
-def parse_stats_reply(buf):
- if len(buf) < 8 + 2:
- raise loxi.ProtocolError("message too short")
- stats_type, = struct.unpack_from("!H", buf, 8)
- if stats_type in stats_reply_parsers:
- return stats_reply_parsers[stats_type](buf)
- else:
- raise loxi.ProtocolError("unexpected stats type %u" % stats_type)
-
-def parse_stats_request(buf):
- if len(buf) < 8 + 2:
- raise loxi.ProtocolError("message too short")
- stats_type, = struct.unpack_from("!H", buf, 8)
- if stats_type in stats_request_parsers:
- return stats_request_parsers[stats_type](buf)
- else:
- raise loxi.ProtocolError("unexpected stats type %u" % stats_type)
-
-def parse_experimenter_stats_request(buf):
- if len(buf) < 24:
- raise loxi.ProtocolError("experimenter stats request message too short")
-
- experimenter, exp_type = struct.unpack_from("!LL", buf, 16)
-
- if experimenter in experimenter_stats_request_parsers and \
- exp_type in experimenter_stats_request_parsers[experimenter]:
- return experimenter_stats_request_parsers[experimenter][exp_type](buf)
- else:
- raise loxi.ProtocolError("unexpected stats request experimenter %#x exp_type %#x" % (experimenter, exp_type))
-
-def parse_experimenter_stats_reply(buf):
- if len(buf) < 24:
- raise loxi.ProtocolError("experimenter stats reply message too short")
-
- experimenter, exp_type = struct.unpack_from("!LL", buf, 16)
-
- if experimenter in experimenter_stats_reply_parsers and \
- exp_type in experimenter_stats_reply_parsers[experimenter]:
- return experimenter_stats_reply_parsers[experimenter][exp_type](buf)
- else:
- raise loxi.ProtocolError("unexpected stats reply experimenter %#x exp_type %#x" % (experimenter, exp_type))
-
-def parse_experimenter(buf):
- if len(buf) < 16:
- raise loxi.ProtocolError("experimenter message too short")
-
- experimenter, = struct.unpack_from("!L", buf, 8)
- if experimenter == 0x005c16c7: # Big Switch Networks
- subtype, = struct.unpack_from("!L", buf, 12)
- elif experimenter == 0x00002320: # Nicira
- subtype, = struct.unpack_from("!L", buf, 12)
- else:
- raise loxi.ProtocolError("unexpected experimenter id %#x" % experimenter)
-
- if subtype in experimenter_parsers[experimenter]:
- return experimenter_parsers[experimenter][subtype](buf)
- else:
- raise loxi.ProtocolError("unexpected experimenter %#x subtype %#x" % (experimenter, subtype))
-
-parsers = {
- const.OFPT_HELLO : hello.unpack,
- const.OFPT_ERROR : parse_error,
- const.OFPT_ECHO_REQUEST : echo_request.unpack,
- const.OFPT_ECHO_REPLY : echo_reply.unpack,
- const.OFPT_EXPERIMENTER : parse_experimenter,
- const.OFPT_FEATURES_REQUEST : features_request.unpack,
- const.OFPT_FEATURES_REPLY : features_reply.unpack,
- const.OFPT_GET_CONFIG_REQUEST : get_config_request.unpack,
- const.OFPT_GET_CONFIG_REPLY : get_config_reply.unpack,
- const.OFPT_SET_CONFIG : set_config.unpack,
- const.OFPT_PACKET_IN : packet_in.unpack,
- const.OFPT_FLOW_REMOVED : flow_removed.unpack,
- const.OFPT_PORT_STATUS : port_status.unpack,
- const.OFPT_PACKET_OUT : packet_out.unpack,
- const.OFPT_FLOW_MOD : parse_flow_mod,
- const.OFPT_GROUP_MOD : parse_group_mod,
- const.OFPT_PORT_MOD : port_mod.unpack,
- const.OFPT_TABLE_MOD : table_mod.unpack,
- const.OFPT_STATS_REQUEST : parse_stats_request,
- const.OFPT_STATS_REPLY : parse_stats_reply,
- const.OFPT_BARRIER_REQUEST : barrier_request.unpack,
- const.OFPT_BARRIER_REPLY : barrier_reply.unpack,
- const.OFPT_QUEUE_GET_CONFIG_REQUEST : queue_get_config_request.unpack,
- const.OFPT_QUEUE_GET_CONFIG_REPLY : queue_get_config_reply.unpack,
-}
-
-error_msg_parsers = {
- const.OFPET_HELLO_FAILED : hello_failed_error_msg.unpack,
- const.OFPET_BAD_REQUEST : bad_request_error_msg.unpack,
- const.OFPET_BAD_ACTION : bad_action_error_msg.unpack,
- const.OFPET_FLOW_MOD_FAILED : flow_mod_failed_error_msg.unpack,
- const.OFPET_PORT_MOD_FAILED : port_mod_failed_error_msg.unpack,
- const.OFPET_QUEUE_OP_FAILED : queue_op_failed_error_msg.unpack,
- const.OFPET_BAD_INSTRUCTION : bad_instruction_error_msg.unpack,
- const.OFPET_BAD_MATCH : bad_match_error_msg.unpack,
- const.OFPET_GROUP_MOD_FAILED : group_mod_failed_error_msg.unpack,
- const.OFPET_TABLE_MOD_FAILED : table_mod_failed_error_msg.unpack,
- const.OFPET_SWITCH_CONFIG_FAILED : switch_config_failed_error_msg.unpack,
-}
-
-flow_mod_parsers = {
- const.OFPFC_ADD : flow_add.unpack,
- const.OFPFC_MODIFY : flow_modify.unpack,
- const.OFPFC_MODIFY_STRICT : flow_modify_strict.unpack,
- const.OFPFC_DELETE : flow_delete.unpack,
- const.OFPFC_DELETE_STRICT : flow_delete_strict.unpack,
-}
-
-group_mod_parsers = {
- const.OFPGC_ADD : group_add.unpack,
- const.OFPGC_MODIFY : group_modify.unpack,
- const.OFPGC_DELETE : group_delete.unpack,
-}
-
-stats_reply_parsers = {
- const.OFPST_DESC : desc_stats_reply.unpack,
- const.OFPST_FLOW : flow_stats_reply.unpack,
- const.OFPST_AGGREGATE : aggregate_stats_reply.unpack,
- const.OFPST_TABLE : table_stats_reply.unpack,
- const.OFPST_PORT : port_stats_reply.unpack,
- const.OFPST_QUEUE : queue_stats_reply.unpack,
- const.OFPST_EXPERIMENTER : parse_experimenter_stats_reply,
- const.OFPST_GROUP : group_stats_reply.unpack,
- const.OFPST_GROUP_DESC : group_desc_stats_reply.unpack,
-}
-
-stats_request_parsers = {
- const.OFPST_DESC : desc_stats_request.unpack,
- const.OFPST_FLOW : flow_stats_request.unpack,
- const.OFPST_AGGREGATE : aggregate_stats_request.unpack,
- const.OFPST_TABLE : table_stats_request.unpack,
- const.OFPST_PORT : port_stats_request.unpack,
- const.OFPST_QUEUE : queue_stats_request.unpack,
- const.OFPST_EXPERIMENTER : parse_experimenter_stats_request,
- const.OFPST_GROUP : group_stats_request.unpack,
- const.OFPST_GROUP_DESC : group_desc_stats_request.unpack,
-}
-
-experimenter_parsers = {
- 6035143 : {
- 22: bsn_bw_clear_data_reply.unpack,
- 21: bsn_bw_clear_data_request.unpack,
- 20: bsn_bw_enable_get_reply.unpack,
- 19: bsn_bw_enable_get_request.unpack,
- 23: bsn_bw_enable_set_reply.unpack,
- 18: bsn_bw_enable_set_request.unpack,
- 10: bsn_get_interfaces_reply.unpack,
- 9: bsn_get_interfaces_request.unpack,
- 5: bsn_get_mirroring_reply.unpack,
- 4: bsn_get_mirroring_request.unpack,
- 34: bsn_pdu_rx_reply.unpack,
- 33: bsn_pdu_rx_request.unpack,
- 35: bsn_pdu_rx_timeout.unpack,
- 32: bsn_pdu_tx_reply.unpack,
- 31: bsn_pdu_tx_request.unpack,
- 3: bsn_set_mirroring.unpack,
- 25: bsn_set_pktin_suppression_reply.unpack,
- 11: bsn_set_pktin_suppression_request.unpack,
- 16: bsn_virtual_port_create_reply.unpack,
- 15: bsn_virtual_port_create_request.unpack,
- 26: bsn_virtual_port_remove_reply.unpack,
- 17: bsn_virtual_port_remove_request.unpack,
- },
-}
-
-experimenter_stats_request_parsers = {
- 0x005c16c7: {
- },
-}
-
-experimenter_stats_reply_parsers = {
- 0x005c16c7: {
- },
-}
+ return message.unpack(loxi.generic_util.OFReader(buf))
diff --git a/src/python/loxi/of11/util.py b/src/python/loxi/of11/util.py
index a29545c..74a8ad2 100644
--- a/src/python/loxi/of11/util.py
+++ b/src/python/loxi/of11/util.py
@@ -5,9 +5,12 @@
# Automatically generated by LOXI from template util.py
# Do not modify
+import struct
import loxi
import const
-import struct
+import common
+import action
+import instruction
def pretty_mac(mac):
return ':'.join(["%02x" % x for x in mac])
@@ -74,9 +77,6 @@
def unpack_match_bmap(reader):
return reader.read("!L")[0]
-def pack_list(values):
- return "".join([x.pack() for x in values])
-
MASK64 = (1 << 64) - 1
def pack_bitmap_128(value):
@@ -96,3 +96,13 @@
i += 1
x >>= 1
return value
+
+def unpack_list_hello_elem(reader):
+ def deserializer(reader):
+ typ, length, = reader.peek('!HH')
+ reader = reader.slice(length)
+ try:
+ return common.hello_elem.unpack(reader)
+ except loxi.ProtocolError:
+ return None
+ return [x for x in loxi.generic_util.unpack_list(reader, deserializer) if x != None]