Merge branch 'pyloxi'
diff --git a/oft b/oft
index d0db9c3..92709ab 100755
--- a/oft
+++ b/oft
@@ -36,6 +36,7 @@
from oftest import config
import oftest.ofutils
import oftest.help_formatter
+import loxi
try:
import scapy.all as scapy
@@ -350,19 +351,12 @@
logging.info("++++++++ " + time.asctime() + " ++++++++")
# Pick an OpenFlow protocol module based on the configured version
-# This will go away once we have a single protocol module that
-# can handle all OpenFlow versions.
-if config["openflow_version"] == "1.0":
- import of10
- sys.modules["ofp"] = of10
-elif config["openflow_version"] == "1.1":
- import of11
- sys.modules["ofp"] = of11
-elif config["openflow_version"] == "1.2":
- import of12
- sys.modules["ofp"] = of12
-else:
- assert(False)
+wire_versions = {
+ "1.0": 1,
+ "1.1": 2,
+ "1.2": 3,
+}
+sys.modules["ofp"] = loxi.protocol(wire_versions[config["openflow_version"]])
# HACK: testutils.py imports controller.py, which needs the ofp module
import oftest.testutils
diff --git a/src/python/loxi/__init__.py b/src/python/loxi/__init__.py
new file mode 100644
index 0000000..9fcc9bf
--- /dev/null
+++ b/src/python/loxi/__init__.py
@@ -0,0 +1,33 @@
+#
+# Copyright 2012, 2013, Big Switch Networks, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+# Automatically generated by LOXI from template toplevel_init.py
+# Do not modify
+
+def protocol(ver):
+ """
+ Import and return the protocol module for the given wire version.
+ """
+ if ver == 1:
+ import of10
+ return of10
+ else:
+ raise ValueError
+
+class ProtocolError(Exception):
+ """
+ Raised when failing to deserialize an invalid OpenFlow message.
+ """
+ pass
diff --git a/src/python/loxi/of10/__init__.py b/src/python/loxi/of10/__init__.py
new file mode 100644
index 0000000..9b3bf53
--- /dev/null
+++ b/src/python/loxi/of10/__init__.py
@@ -0,0 +1,22 @@
+#
+# Copyright 2012, 2013, Big Switch Networks, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+# Automatically generated by LOXI from template init.py
+# Do not modify
+
+import action, common, const, message
+from const import *
+from common import *
+from loxi import ProtocolError
diff --git a/src/python/loxi/of10/action.py b/src/python/loxi/of10/action.py
new file mode 100644
index 0000000..c6129a5
--- /dev/null
+++ b/src/python/loxi/of10/action.py
@@ -0,0 +1,1029 @@
+#
+# Copyright 2012, 2013, Big Switch Networks, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+# Automatically generated by LOXI from template action.py
+# Do not modify
+
+import struct
+import const
+import util
+import loxi
+
+def unpack_list(buf):
+ if len(buf) % 8 != 0: raise loxi.ProtocolError("action list length not a multiple of 8")
+ actions = []
+ offset = 0
+ while offset < len(buf):
+ type, length = struct.unpack_from("!HH", buf, offset)
+ if length == 0: raise loxi.ProtocolError("action length is 0")
+ if length % 8 != 0: raise loxi.ProtocolError("action length not a multiple of 8")
+ if offset + length > len(buf): raise loxi.ProtocolError("action length overruns list length")
+ parser = parsers.get(type)
+ if not parser: raise loxi.ProtocolError("unknown action type %d" % type)
+ actions.append(parser(buffer(buf, offset, length)))
+ offset += length
+ return actions
+
+class Action(object):
+ type = None # override in subclass
+ pass
+
+class bsn_mirror(Action):
+ type = const.OFPAT_VENDOR
+ experimenter = 0x5c16c7
+ subtype = 1
+
+ def __init__(self, dest_port=None, vlan_tag=None, copy_stage=None, pad=None):
+ if dest_port != None:
+ self.dest_port = dest_port
+ else:
+ self.dest_port = 0
+ if vlan_tag != None:
+ self.vlan_tag = vlan_tag
+ else:
+ self.vlan_tag = 0
+ if copy_stage != None:
+ self.copy_stage = copy_stage
+ else:
+ self.copy_stage = 0
+ if pad != None:
+ self.pad = pad
+ else:
+ self.pad = [0,0,0]
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!H", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
+ packed.append(struct.pack("!L", self.experimenter))
+ packed.append(struct.pack("!L", self.subtype))
+ packed.append(struct.pack("!L", self.dest_port))
+ packed.append(struct.pack("!L", self.vlan_tag))
+ packed.append(struct.pack("!B", self.copy_stage))
+ packed.append(struct.pack("!3B", *self.pad))
+ length = sum([len(x) for x in packed])
+ packed[1] = struct.pack("!H", length)
+ return ''.join(packed)
+
+ @staticmethod
+ def unpack(buf):
+ obj = bsn_mirror()
+ type = struct.unpack_from('!H', buf, 0)[0]
+ assert(type == const.OFPAT_VENDOR)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 24: raise loxi.ProtocolError("bsn_mirror length is %d, should be 24" % _length)
+ experimenter = struct.unpack_from('!L', buf, 4)[0]
+ assert(experimenter == 0x5c16c7)
+ subtype = struct.unpack_from('!L', buf, 8)[0]
+ assert(subtype == 1)
+ obj.dest_port = struct.unpack_from('!L', buf, 12)[0]
+ obj.vlan_tag = struct.unpack_from('!L', buf, 16)[0]
+ obj.copy_stage = struct.unpack_from('!B', buf, 20)[0]
+ obj.pad = list(struct.unpack_from('!3B', buf, 21))
+ return obj
+
+ def __eq__(self, other):
+ if type(self) != type(other): return False
+ if self.type != other.type: return False
+ if self.dest_port != other.dest_port: return False
+ if self.vlan_tag != other.vlan_tag: return False
+ if self.copy_stage != other.copy_stage: return False
+ if self.pad != other.pad: 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("dest_port = ");
+ q.text("%#x" % self.dest_port)
+ q.text(","); q.breakable()
+ q.text("vlan_tag = ");
+ q.text("%#x" % self.vlan_tag)
+ q.text(","); q.breakable()
+ q.text("copy_stage = ");
+ q.text("%#x" % self.copy_stage)
+ q.text(","); q.breakable()
+ q.text("pad = ");
+ q.pp(self.pad)
+ q.breakable()
+ q.text('}')
+
+class bsn_set_tunnel_dst(Action):
+ type = const.OFPAT_VENDOR
+ experimenter = 0x5c16c7
+ subtype = 2
+
+ def __init__(self, dst=None):
+ if dst != None:
+ self.dst = dst
+ else:
+ self.dst = 0
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!H", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
+ packed.append(struct.pack("!L", self.experimenter))
+ packed.append(struct.pack("!L", self.subtype))
+ packed.append(struct.pack("!L", self.dst))
+ length = sum([len(x) for x in packed])
+ packed[1] = struct.pack("!H", length)
+ return ''.join(packed)
+
+ @staticmethod
+ def unpack(buf):
+ obj = bsn_set_tunnel_dst()
+ type = struct.unpack_from('!H', buf, 0)[0]
+ assert(type == const.OFPAT_VENDOR)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 16: raise loxi.ProtocolError("bsn_set_tunnel_dst length is %d, should be 16" % _length)
+ experimenter = struct.unpack_from('!L', buf, 4)[0]
+ assert(experimenter == 0x5c16c7)
+ subtype = struct.unpack_from('!L', buf, 8)[0]
+ assert(subtype == 2)
+ obj.dst = struct.unpack_from('!L', buf, 12)[0]
+ return obj
+
+ def __eq__(self, other):
+ if type(self) != type(other): return False
+ if self.type != other.type: return False
+ 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("dst = ");
+ q.text("%#x" % self.dst)
+ q.breakable()
+ q.text('}')
+
+class enqueue(Action):
+ type = const.OFPAT_ENQUEUE
+
+ def __init__(self, port=None, pad=None, queue_id=None):
+ if port != None:
+ self.port = port
+ else:
+ self.port = 0
+ if pad != None:
+ self.pad = pad
+ else:
+ self.pad = [0,0,0,0,0,0]
+ if queue_id != None:
+ self.queue_id = queue_id
+ else:
+ self.queue_id = 0
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!H", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
+ packed.append(struct.pack("!H", self.port))
+ packed.append(struct.pack("!6B", *self.pad))
+ packed.append(struct.pack("!L", self.queue_id))
+ length = sum([len(x) for x in packed])
+ packed[1] = struct.pack("!H", length)
+ return ''.join(packed)
+
+ @staticmethod
+ def unpack(buf):
+ obj = enqueue()
+ type = struct.unpack_from('!H', buf, 0)[0]
+ assert(type == const.OFPAT_ENQUEUE)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 16: raise loxi.ProtocolError("enqueue length is %d, should be 16" % _length)
+ obj.port = struct.unpack_from('!H', buf, 4)[0]
+ obj.pad = list(struct.unpack_from('!6B', buf, 6))
+ obj.queue_id = struct.unpack_from('!L', buf, 12)[0]
+ return obj
+
+ def __eq__(self, other):
+ if type(self) != type(other): return False
+ if self.type != other.type: return False
+ if self.port != other.port: return False
+ if self.pad != other.pad: return False
+ 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("enqueue {")
+ with q.group():
+ with q.indent(2):
+ q.breakable()
+ q.text("port = ");
+ q.text(util.pretty_port(self.port))
+ q.text(","); q.breakable()
+ q.text("pad = ");
+ q.pp(self.pad)
+ q.text(","); q.breakable()
+ q.text("queue_id = ");
+ q.text("%#x" % self.queue_id)
+ q.breakable()
+ q.text('}')
+
+class nicira_dec_ttl(Action):
+ type = const.OFPAT_VENDOR
+ experimenter = 0x2320
+ subtype = 18
+
+ def __init__(self, pad=None, pad2=None):
+ if pad != None:
+ self.pad = pad
+ else:
+ self.pad = 0
+ if pad2 != None:
+ self.pad2 = pad2
+ else:
+ self.pad2 = 0
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!H", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
+ packed.append(struct.pack("!L", self.experimenter))
+ packed.append(struct.pack("!H", self.subtype))
+ packed.append(struct.pack("!H", self.pad))
+ packed.append(struct.pack("!L", self.pad2))
+ length = sum([len(x) for x in packed])
+ packed[1] = struct.pack("!H", length)
+ return ''.join(packed)
+
+ @staticmethod
+ def unpack(buf):
+ obj = nicira_dec_ttl()
+ type = struct.unpack_from('!H', buf, 0)[0]
+ assert(type == const.OFPAT_VENDOR)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 16: raise loxi.ProtocolError("nicira_dec_ttl length is %d, should be 16" % _length)
+ experimenter = struct.unpack_from('!L', buf, 4)[0]
+ assert(experimenter == 0x2320)
+ subtype = struct.unpack_from('!H', buf, 8)[0]
+ assert(subtype == 18)
+ obj.pad = struct.unpack_from('!H', buf, 10)[0]
+ obj.pad2 = struct.unpack_from('!L', buf, 12)[0]
+ return obj
+
+ def __eq__(self, other):
+ if type(self) != type(other): return False
+ if self.type != other.type: return False
+ if self.pad != other.pad: return False
+ if self.pad2 != other.pad2: 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("pad = ");
+ q.text("%#x" % self.pad)
+ q.text(","); q.breakable()
+ q.text("pad2 = ");
+ q.text("%#x" % self.pad2)
+ q.breakable()
+ q.text('}')
+
+class output(Action):
+ type = const.OFPAT_OUTPUT
+
+ def __init__(self, port=None, max_len=None):
+ if port != None:
+ self.port = port
+ else:
+ self.port = 0
+ if max_len != None:
+ self.max_len = max_len
+ else:
+ self.max_len = 0
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!H", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
+ packed.append(struct.pack("!H", self.port))
+ packed.append(struct.pack("!H", self.max_len))
+ length = sum([len(x) for x in packed])
+ packed[1] = struct.pack("!H", length)
+ return ''.join(packed)
+
+ @staticmethod
+ def unpack(buf):
+ obj = output()
+ type = struct.unpack_from('!H', buf, 0)[0]
+ assert(type == const.OFPAT_OUTPUT)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 8: raise loxi.ProtocolError("output length is %d, should be 8" % _length)
+ obj.port = struct.unpack_from('!H', buf, 4)[0]
+ obj.max_len = struct.unpack_from('!H', buf, 6)[0]
+ return obj
+
+ def __eq__(self, other):
+ if type(self) != type(other): return False
+ if self.type != other.type: return False
+ if self.port != other.port: return False
+ 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("port = ");
+ q.text(util.pretty_port(self.port))
+ q.text(","); q.breakable()
+ q.text("max_len = ");
+ q.text("%#x" % self.max_len)
+ q.breakable()
+ q.text('}')
+
+class set_dl_dst(Action):
+ type = const.OFPAT_SET_DL_DST
+
+ def __init__(self, dl_addr=None, pad=None):
+ if dl_addr != None:
+ self.dl_addr = dl_addr
+ else:
+ self.dl_addr = [0,0,0,0,0,0]
+ if pad != None:
+ self.pad = pad
+ else:
+ self.pad = [0,0,0,0,0,0]
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!H", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
+ packed.append(struct.pack("!6B", *self.dl_addr))
+ packed.append(struct.pack("!6B", *self.pad))
+ length = sum([len(x) for x in packed])
+ packed[1] = struct.pack("!H", length)
+ return ''.join(packed)
+
+ @staticmethod
+ def unpack(buf):
+ obj = set_dl_dst()
+ type = struct.unpack_from('!H', buf, 0)[0]
+ assert(type == const.OFPAT_SET_DL_DST)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 16: raise loxi.ProtocolError("set_dl_dst length is %d, should be 16" % _length)
+ obj.dl_addr = list(struct.unpack_from('!6B', buf, 4))
+ obj.pad = list(struct.unpack_from('!6B', buf, 10))
+ return obj
+
+ def __eq__(self, other):
+ if type(self) != type(other): return False
+ if self.type != other.type: return False
+ if self.dl_addr != other.dl_addr: return False
+ if self.pad != other.pad: 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("dl_addr = ");
+ q.text(util.pretty_mac(self.dl_addr))
+ q.text(","); q.breakable()
+ q.text("pad = ");
+ q.pp(self.pad)
+ q.breakable()
+ q.text('}')
+
+class set_dl_src(Action):
+ type = const.OFPAT_SET_DL_SRC
+
+ def __init__(self, dl_addr=None, pad=None):
+ if dl_addr != None:
+ self.dl_addr = dl_addr
+ else:
+ self.dl_addr = [0,0,0,0,0,0]
+ if pad != None:
+ self.pad = pad
+ else:
+ self.pad = [0,0,0,0,0,0]
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!H", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
+ packed.append(struct.pack("!6B", *self.dl_addr))
+ packed.append(struct.pack("!6B", *self.pad))
+ length = sum([len(x) for x in packed])
+ packed[1] = struct.pack("!H", length)
+ return ''.join(packed)
+
+ @staticmethod
+ def unpack(buf):
+ obj = set_dl_src()
+ type = struct.unpack_from('!H', buf, 0)[0]
+ assert(type == const.OFPAT_SET_DL_SRC)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 16: raise loxi.ProtocolError("set_dl_src length is %d, should be 16" % _length)
+ obj.dl_addr = list(struct.unpack_from('!6B', buf, 4))
+ obj.pad = list(struct.unpack_from('!6B', buf, 10))
+ return obj
+
+ def __eq__(self, other):
+ if type(self) != type(other): return False
+ if self.type != other.type: return False
+ if self.dl_addr != other.dl_addr: return False
+ if self.pad != other.pad: 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("dl_addr = ");
+ q.text(util.pretty_mac(self.dl_addr))
+ q.text(","); q.breakable()
+ q.text("pad = ");
+ q.pp(self.pad)
+ q.breakable()
+ q.text('}')
+
+class set_nw_dst(Action):
+ type = const.OFPAT_SET_NW_DST
+
+ def __init__(self, nw_addr=None):
+ if nw_addr != None:
+ self.nw_addr = nw_addr
+ else:
+ self.nw_addr = 0
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!H", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
+ packed.append(struct.pack("!L", self.nw_addr))
+ length = sum([len(x) for x in packed])
+ packed[1] = struct.pack("!H", length)
+ return ''.join(packed)
+
+ @staticmethod
+ def unpack(buf):
+ obj = set_nw_dst()
+ type = struct.unpack_from('!H', buf, 0)[0]
+ assert(type == const.OFPAT_SET_NW_DST)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 8: raise loxi.ProtocolError("set_nw_dst length is %d, should be 8" % _length)
+ obj.nw_addr = struct.unpack_from('!L', buf, 4)[0]
+ return obj
+
+ def __eq__(self, other):
+ if type(self) != type(other): return False
+ if self.type != other.type: return False
+ 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("nw_addr = ");
+ q.text("%#x" % self.nw_addr)
+ q.breakable()
+ q.text('}')
+
+class set_nw_src(Action):
+ type = const.OFPAT_SET_NW_SRC
+
+ def __init__(self, nw_addr=None):
+ if nw_addr != None:
+ self.nw_addr = nw_addr
+ else:
+ self.nw_addr = 0
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!H", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
+ packed.append(struct.pack("!L", self.nw_addr))
+ length = sum([len(x) for x in packed])
+ packed[1] = struct.pack("!H", length)
+ return ''.join(packed)
+
+ @staticmethod
+ def unpack(buf):
+ obj = set_nw_src()
+ type = struct.unpack_from('!H', buf, 0)[0]
+ assert(type == const.OFPAT_SET_NW_SRC)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 8: raise loxi.ProtocolError("set_nw_src length is %d, should be 8" % _length)
+ obj.nw_addr = struct.unpack_from('!L', buf, 4)[0]
+ return obj
+
+ def __eq__(self, other):
+ if type(self) != type(other): return False
+ if self.type != other.type: return False
+ 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("nw_addr = ");
+ q.text("%#x" % self.nw_addr)
+ q.breakable()
+ q.text('}')
+
+class set_nw_tos(Action):
+ type = const.OFPAT_SET_NW_TOS
+
+ def __init__(self, nw_tos=None, pad=None):
+ if nw_tos != None:
+ self.nw_tos = nw_tos
+ else:
+ self.nw_tos = 0
+ if pad != None:
+ self.pad = pad
+ else:
+ self.pad = [0,0,0]
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!H", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
+ packed.append(struct.pack("!B", self.nw_tos))
+ packed.append(struct.pack("!3B", *self.pad))
+ length = sum([len(x) for x in packed])
+ packed[1] = struct.pack("!H", length)
+ return ''.join(packed)
+
+ @staticmethod
+ def unpack(buf):
+ obj = set_nw_tos()
+ type = struct.unpack_from('!H', buf, 0)[0]
+ assert(type == const.OFPAT_SET_NW_TOS)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 8: raise loxi.ProtocolError("set_nw_tos length is %d, should be 8" % _length)
+ obj.nw_tos = struct.unpack_from('!B', buf, 4)[0]
+ obj.pad = list(struct.unpack_from('!3B', buf, 5))
+ return obj
+
+ def __eq__(self, other):
+ if type(self) != type(other): return False
+ if self.type != other.type: return False
+ if self.nw_tos != other.nw_tos: return False
+ if self.pad != other.pad: 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("nw_tos = ");
+ q.text("%#x" % self.nw_tos)
+ q.text(","); q.breakable()
+ q.text("pad = ");
+ q.pp(self.pad)
+ q.breakable()
+ q.text('}')
+
+class set_tp_dst(Action):
+ type = const.OFPAT_SET_TP_DST
+
+ def __init__(self, tp_port=None, pad=None):
+ if tp_port != None:
+ self.tp_port = tp_port
+ else:
+ self.tp_port = 0
+ if pad != None:
+ self.pad = pad
+ else:
+ self.pad = [0,0]
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!H", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
+ packed.append(struct.pack("!H", self.tp_port))
+ packed.append(struct.pack("!2B", *self.pad))
+ length = sum([len(x) for x in packed])
+ packed[1] = struct.pack("!H", length)
+ return ''.join(packed)
+
+ @staticmethod
+ def unpack(buf):
+ obj = set_tp_dst()
+ type = struct.unpack_from('!H', buf, 0)[0]
+ assert(type == const.OFPAT_SET_TP_DST)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 8: raise loxi.ProtocolError("set_tp_dst length is %d, should be 8" % _length)
+ obj.tp_port = struct.unpack_from('!H', buf, 4)[0]
+ obj.pad = list(struct.unpack_from('!2B', buf, 6))
+ return obj
+
+ def __eq__(self, other):
+ if type(self) != type(other): return False
+ if self.type != other.type: return False
+ if self.tp_port != other.tp_port: return False
+ if self.pad != other.pad: 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("tp_port = ");
+ q.text("%#x" % self.tp_port)
+ q.text(","); q.breakable()
+ q.text("pad = ");
+ q.pp(self.pad)
+ q.breakable()
+ q.text('}')
+
+class set_tp_src(Action):
+ type = const.OFPAT_SET_TP_SRC
+
+ def __init__(self, tp_port=None, pad=None):
+ if tp_port != None:
+ self.tp_port = tp_port
+ else:
+ self.tp_port = 0
+ if pad != None:
+ self.pad = pad
+ else:
+ self.pad = [0,0]
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!H", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
+ packed.append(struct.pack("!H", self.tp_port))
+ packed.append(struct.pack("!2B", *self.pad))
+ length = sum([len(x) for x in packed])
+ packed[1] = struct.pack("!H", length)
+ return ''.join(packed)
+
+ @staticmethod
+ def unpack(buf):
+ obj = set_tp_src()
+ type = struct.unpack_from('!H', buf, 0)[0]
+ assert(type == const.OFPAT_SET_TP_SRC)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 8: raise loxi.ProtocolError("set_tp_src length is %d, should be 8" % _length)
+ obj.tp_port = struct.unpack_from('!H', buf, 4)[0]
+ obj.pad = list(struct.unpack_from('!2B', buf, 6))
+ return obj
+
+ def __eq__(self, other):
+ if type(self) != type(other): return False
+ if self.type != other.type: return False
+ if self.tp_port != other.tp_port: return False
+ if self.pad != other.pad: 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("tp_port = ");
+ q.text("%#x" % self.tp_port)
+ q.text(","); q.breakable()
+ q.text("pad = ");
+ q.pp(self.pad)
+ q.breakable()
+ q.text('}')
+
+class set_vlan_pcp(Action):
+ type = const.OFPAT_SET_VLAN_PCP
+
+ def __init__(self, vlan_pcp=None, pad=None):
+ if vlan_pcp != None:
+ self.vlan_pcp = vlan_pcp
+ else:
+ self.vlan_pcp = 0
+ if pad != None:
+ self.pad = pad
+ else:
+ self.pad = [0,0,0]
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!H", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
+ packed.append(struct.pack("!B", self.vlan_pcp))
+ packed.append(struct.pack("!3B", *self.pad))
+ length = sum([len(x) for x in packed])
+ packed[1] = struct.pack("!H", length)
+ return ''.join(packed)
+
+ @staticmethod
+ def unpack(buf):
+ obj = set_vlan_pcp()
+ type = struct.unpack_from('!H', buf, 0)[0]
+ assert(type == const.OFPAT_SET_VLAN_PCP)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 8: raise loxi.ProtocolError("set_vlan_pcp length is %d, should be 8" % _length)
+ obj.vlan_pcp = struct.unpack_from('!B', buf, 4)[0]
+ obj.pad = list(struct.unpack_from('!3B', buf, 5))
+ return obj
+
+ def __eq__(self, other):
+ if type(self) != type(other): return False
+ if self.type != other.type: return False
+ if self.vlan_pcp != other.vlan_pcp: return False
+ if self.pad != other.pad: 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("vlan_pcp = ");
+ q.text("%#x" % self.vlan_pcp)
+ q.text(","); q.breakable()
+ q.text("pad = ");
+ q.pp(self.pad)
+ q.breakable()
+ q.text('}')
+
+class set_vlan_vid(Action):
+ type = const.OFPAT_SET_VLAN_VID
+
+ def __init__(self, vlan_vid=None, pad=None):
+ if vlan_vid != None:
+ self.vlan_vid = vlan_vid
+ else:
+ self.vlan_vid = 0
+ if pad != None:
+ self.pad = pad
+ else:
+ self.pad = [0,0]
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!H", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
+ packed.append(struct.pack("!H", self.vlan_vid))
+ packed.append(struct.pack("!2B", *self.pad))
+ length = sum([len(x) for x in packed])
+ packed[1] = struct.pack("!H", length)
+ return ''.join(packed)
+
+ @staticmethod
+ def unpack(buf):
+ obj = set_vlan_vid()
+ type = struct.unpack_from('!H', buf, 0)[0]
+ assert(type == const.OFPAT_SET_VLAN_VID)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 8: raise loxi.ProtocolError("set_vlan_vid length is %d, should be 8" % _length)
+ obj.vlan_vid = struct.unpack_from('!H', buf, 4)[0]
+ obj.pad = list(struct.unpack_from('!2B', buf, 6))
+ return obj
+
+ def __eq__(self, other):
+ if type(self) != type(other): return False
+ if self.type != other.type: return False
+ if self.vlan_vid != other.vlan_vid: return False
+ if self.pad != other.pad: 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("vlan_vid = ");
+ q.text("%#x" % self.vlan_vid)
+ q.text(","); q.breakable()
+ q.text("pad = ");
+ q.pp(self.pad)
+ q.breakable()
+ q.text('}')
+
+class strip_vlan(Action):
+ type = const.OFPAT_STRIP_VLAN
+
+ def __init__(self, pad=None):
+ if pad != None:
+ self.pad = pad
+ else:
+ self.pad = [0,0,0,0]
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!H", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
+ packed.append(struct.pack("!4B", *self.pad))
+ length = sum([len(x) for x in packed])
+ packed[1] = struct.pack("!H", length)
+ return ''.join(packed)
+
+ @staticmethod
+ def unpack(buf):
+ obj = strip_vlan()
+ type = struct.unpack_from('!H', buf, 0)[0]
+ assert(type == const.OFPAT_STRIP_VLAN)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 8: raise loxi.ProtocolError("strip_vlan length is %d, should be 8" % _length)
+ obj.pad = list(struct.unpack_from('!4B', buf, 4))
+ return obj
+
+ def __eq__(self, other):
+ if type(self) != type(other): return False
+ if self.type != other.type: return False
+ if self.pad != other.pad: 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("strip_vlan {")
+ with q.group():
+ with q.indent(2):
+ q.breakable()
+ q.text("pad = ");
+ q.pp(self.pad)
+ q.breakable()
+ q.text('}')
+
+
+def parse_vendor(buf):
+ if len(buf) < 16:
+ raise loxi.ProtocolError("experimenter action too short")
+
+ experimenter, = struct.unpack_from("!L", buf, 4)
+ if experimenter == 0x005c16c7: # Big Switch Networks
+ subtype, = struct.unpack_from("!L", buf, 8)
+ elif experimenter == 0x00002320: # Nicira
+ subtype, = struct.unpack_from("!H", buf, 8)
+ 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 BSN experimenter subtype %#x" % subtype)
+
+parsers = {
+ const.OFPAT_ENQUEUE : enqueue.unpack,
+ const.OFPAT_OUTPUT : output.unpack,
+ const.OFPAT_SET_DL_DST : set_dl_dst.unpack,
+ const.OFPAT_SET_DL_SRC : set_dl_src.unpack,
+ const.OFPAT_SET_NW_DST : set_nw_dst.unpack,
+ const.OFPAT_SET_NW_SRC : set_nw_src.unpack,
+ const.OFPAT_SET_NW_TOS : set_nw_tos.unpack,
+ const.OFPAT_SET_TP_DST : set_tp_dst.unpack,
+ const.OFPAT_SET_TP_SRC : set_tp_src.unpack,
+ const.OFPAT_SET_VLAN_PCP : set_vlan_pcp.unpack,
+ const.OFPAT_SET_VLAN_VID : set_vlan_vid.unpack,
+ const.OFPAT_STRIP_VLAN : strip_vlan.unpack,
+ const.OFPAT_VENDOR : parse_vendor,
+}
+
+experimenter_parsers = {
+ 0x2320 : {
+ 18: nicira_dec_ttl.unpack,
+ },
+ 0x5c16c7 : {
+ 1: bsn_mirror.unpack,
+ 2: bsn_set_tunnel_dst.unpack,
+ },
+}
diff --git a/src/python/loxi/of10/common.py b/src/python/loxi/of10/common.py
new file mode 100644
index 0000000..07c41d0
--- /dev/null
+++ b/src/python/loxi/of10/common.py
@@ -0,0 +1,1136 @@
+#
+# Copyright 2012, 2013, Big Switch Networks, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+# Automatically generated by LOXI from template common.py
+# Do not modify
+
+import sys
+import struct
+import action
+import const
+import util
+
+# HACK make this module visible as 'common' to simplify code generation
+common = sys.modules[__name__]
+
+def unpack_list_flow_stats_entry(buf):
+ entries = []
+ offset = 0
+ while offset < len(buf):
+ length, = struct.unpack_from("!H", buf, offset)
+ if length == 0: raise loxi.ProtocolError("entry length is 0")
+ if offset + length > len(buf): raise loxi.ProtocolError("entry length overruns list length")
+ entries.append(flow_stats_entry.unpack(buffer(buf, offset, length)))
+ offset += length
+ return entries
+
+def unpack_list_queue_prop(buf):
+ entries = []
+ offset = 0
+ while offset < len(buf):
+ type, length, = struct.unpack_from("!HH", buf, offset)
+ if length == 0: raise loxi.ProtocolError("entry length is 0")
+ if offset + length > len(buf): raise loxi.ProtocolError("entry length overruns list length")
+ if type == const.OFPQT_MIN_RATE:
+ entry = queue_prop_min_rate.unpack(buffer(buf, offset, length))
+ else:
+ raise loxi.ProtocolError("unknown queue prop %d" % type)
+ entries.append(entry)
+ offset += length
+ return entries
+
+def unpack_list_packet_queue(buf):
+ entries = []
+ offset = 0
+ while offset < len(buf):
+ _, length, = struct.unpack_from("!LH", buf, offset)
+ if length == 0: raise loxi.ProtocolError("entry length is 0")
+ if offset + length > len(buf): raise loxi.ProtocolError("entry length overruns list length")
+ entries.append(packet_queue.unpack(buffer(buf, offset, length)))
+ offset += length
+ return entries
+
+class bsn_interface(object):
+
+ def __init__(self, hw_addr=None, pad=None, name=None, ipv4_addr=None, ipv4_netmask=None):
+ if hw_addr != None:
+ self.hw_addr = hw_addr
+ else:
+ self.hw_addr = [0,0,0,0,0,0]
+ if pad != None:
+ self.pad = pad
+ else:
+ self.pad = 0
+ if name != None:
+ self.name = name
+ else:
+ self.name = ""
+ if ipv4_addr != None:
+ self.ipv4_addr = ipv4_addr
+ else:
+ self.ipv4_addr = 0
+ if ipv4_netmask != None:
+ self.ipv4_netmask = ipv4_netmask
+ else:
+ self.ipv4_netmask = 0
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!6B", *self.hw_addr))
+ packed.append(struct.pack("!H", self.pad))
+ packed.append(struct.pack("!16s", self.name))
+ packed.append(struct.pack("!L", self.ipv4_addr))
+ packed.append(struct.pack("!L", self.ipv4_netmask))
+ return ''.join(packed)
+
+ @staticmethod
+ def unpack(buf):
+ assert(len(buf) >= 32) # Should be verified by caller
+ obj = bsn_interface()
+ obj.hw_addr = list(struct.unpack_from('!6B', buf, 0))
+ obj.pad = struct.unpack_from('!H', buf, 6)[0]
+ obj.name = str(buffer(buf, 8, 16)).rstrip("\x00")
+ obj.ipv4_addr = struct.unpack_from('!L', buf, 24)[0]
+ obj.ipv4_netmask = struct.unpack_from('!L', buf, 28)[0]
+ return obj
+
+ def __eq__(self, other):
+ if type(self) != type(other): return False
+ if self.hw_addr != other.hw_addr: return False
+ if self.pad != other.pad: return False
+ if self.name != other.name: return False
+ if self.ipv4_addr != other.ipv4_addr: return False
+ 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("hw_addr = ");
+ q.text(util.pretty_mac(self.hw_addr))
+ q.text(","); q.breakable()
+ q.text("pad = ");
+ q.text("%#x" % self.pad)
+ q.text(","); q.breakable()
+ q.text("name = ");
+ q.pp(self.name)
+ q.text(","); q.breakable()
+ q.text("ipv4_addr = ");
+ q.text(util.pretty_ipv4(self.ipv4_addr))
+ q.text(","); q.breakable()
+ q.text("ipv4_netmask = ");
+ q.text(util.pretty_ipv4(self.ipv4_netmask))
+ q.breakable()
+ q.text('}')
+
+class flow_stats_entry(object):
+
+ def __init__(self, table_id=None, pad=None, match=None, duration_sec=None, duration_nsec=None, priority=None, idle_timeout=None, hard_timeout=None, pad2=None, cookie=None, packet_count=None, byte_count=None, actions=None):
+ if table_id != None:
+ self.table_id = table_id
+ else:
+ self.table_id = 0
+ if pad != None:
+ self.pad = pad
+ else:
+ self.pad = 0
+ if match != None:
+ self.match = match
+ else:
+ self.match = common.match()
+ if duration_sec != None:
+ self.duration_sec = duration_sec
+ else:
+ self.duration_sec = 0
+ if duration_nsec != None:
+ self.duration_nsec = duration_nsec
+ else:
+ self.duration_nsec = 0
+ if priority != None:
+ self.priority = priority
+ else:
+ self.priority = 0
+ if idle_timeout != None:
+ self.idle_timeout = idle_timeout
+ else:
+ self.idle_timeout = 0
+ if hard_timeout != None:
+ self.hard_timeout = hard_timeout
+ else:
+ self.hard_timeout = 0
+ if pad2 != None:
+ self.pad2 = pad2
+ else:
+ self.pad2 = [0,0,0,0,0,0]
+ if cookie != None:
+ self.cookie = cookie
+ else:
+ self.cookie = 0
+ if packet_count != None:
+ self.packet_count = packet_count
+ else:
+ self.packet_count = 0
+ if byte_count != None:
+ self.byte_count = byte_count
+ else:
+ self.byte_count = 0
+ if actions != None:
+ self.actions = actions
+ else:
+ self.actions = []
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
+ packed.append(struct.pack("!B", self.table_id))
+ packed.append(struct.pack("!B", self.pad))
+ packed.append(self.match.pack())
+ packed.append(struct.pack("!L", self.duration_sec))
+ packed.append(struct.pack("!L", self.duration_nsec))
+ packed.append(struct.pack("!H", self.priority))
+ packed.append(struct.pack("!H", self.idle_timeout))
+ packed.append(struct.pack("!H", self.hard_timeout))
+ packed.append(struct.pack("!6B", *self.pad2))
+ packed.append(struct.pack("!Q", self.cookie))
+ packed.append(struct.pack("!Q", self.packet_count))
+ packed.append(struct.pack("!Q", self.byte_count))
+ packed.append("".join([x.pack() for x in self.actions]))
+ length = sum([len(x) for x in packed])
+ packed[0] = struct.pack("!H", length)
+ return ''.join(packed)
+
+ @staticmethod
+ def unpack(buf):
+ assert(len(buf) >= 88) # Should be verified by caller
+ obj = flow_stats_entry()
+ _length = struct.unpack_from('!H', buf, 0)[0]
+ assert(_length == len(buf))
+ if _length < 88: raise loxi.ProtocolError("flow_stats_entry length is %d, should be at least 88" % _length)
+ obj.table_id = struct.unpack_from('!B', buf, 2)[0]
+ obj.pad = struct.unpack_from('!B', buf, 3)[0]
+ obj.match = common.match.unpack(buffer(buf, 4))
+ obj.duration_sec = struct.unpack_from('!L', buf, 44)[0]
+ obj.duration_nsec = struct.unpack_from('!L', buf, 48)[0]
+ obj.priority = struct.unpack_from('!H', buf, 52)[0]
+ obj.idle_timeout = struct.unpack_from('!H', buf, 54)[0]
+ obj.hard_timeout = struct.unpack_from('!H', buf, 56)[0]
+ obj.pad2 = list(struct.unpack_from('!6B', buf, 58))
+ obj.cookie = struct.unpack_from('!Q', buf, 64)[0]
+ obj.packet_count = struct.unpack_from('!Q', buf, 72)[0]
+ obj.byte_count = struct.unpack_from('!Q', buf, 80)[0]
+ obj.actions = action.unpack_list(buffer(buf, 88))
+ return obj
+
+ def __eq__(self, other):
+ if type(self) != type(other): return False
+ if self.table_id != other.table_id: return False
+ if self.pad != other.pad: return False
+ if self.match != other.match: return False
+ if self.duration_sec != other.duration_sec: return False
+ if self.duration_nsec != other.duration_nsec: return False
+ if self.priority != other.priority: return False
+ if self.idle_timeout != other.idle_timeout: return False
+ if self.hard_timeout != other.hard_timeout: return False
+ if self.pad2 != other.pad2: return False
+ if self.cookie != other.cookie: return False
+ if self.packet_count != other.packet_count: return False
+ if self.byte_count != other.byte_count: return False
+ 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("flow_stats_entry {")
+ with q.group():
+ with q.indent(2):
+ q.breakable()
+ q.text("table_id = ");
+ q.text("%#x" % self.table_id)
+ q.text(","); q.breakable()
+ q.text("pad = ");
+ q.text("%#x" % self.pad)
+ q.text(","); q.breakable()
+ q.text("match = ");
+ q.pp(self.match)
+ q.text(","); q.breakable()
+ q.text("duration_sec = ");
+ q.text("%#x" % self.duration_sec)
+ q.text(","); q.breakable()
+ q.text("duration_nsec = ");
+ q.text("%#x" % self.duration_nsec)
+ q.text(","); q.breakable()
+ q.text("priority = ");
+ q.text("%#x" % self.priority)
+ q.text(","); q.breakable()
+ q.text("idle_timeout = ");
+ q.text("%#x" % self.idle_timeout)
+ q.text(","); q.breakable()
+ q.text("hard_timeout = ");
+ q.text("%#x" % self.hard_timeout)
+ q.text(","); q.breakable()
+ q.text("pad2 = ");
+ q.pp(self.pad2)
+ q.text(","); q.breakable()
+ q.text("cookie = ");
+ q.text("%#x" % self.cookie)
+ q.text(","); q.breakable()
+ q.text("packet_count = ");
+ q.text("%#x" % self.packet_count)
+ q.text(","); q.breakable()
+ q.text("byte_count = ");
+ q.text("%#x" % self.byte_count)
+ q.text(","); q.breakable()
+ q.text("actions = ");
+ q.pp(self.actions)
+ q.breakable()
+ q.text('}')
+
+class match_v1(object):
+
+ def __init__(self, wildcards=None, in_port=None, eth_src=None, eth_dst=None, vlan_vid=None, vlan_pcp=None, pad1=None, eth_type=None, ip_dscp=None, ip_proto=None, pad2=None, ipv4_src=None, ipv4_dst=None, tcp_src=None, tcp_dst=None):
+ if wildcards != None:
+ self.wildcards = wildcards
+ else:
+ self.wildcards = const.OFPFW_ALL
+ if in_port != None:
+ self.in_port = in_port
+ else:
+ self.in_port = 0
+ if eth_src != None:
+ self.eth_src = eth_src
+ else:
+ self.eth_src = [0,0,0,0,0,0]
+ if eth_dst != None:
+ self.eth_dst = eth_dst
+ else:
+ self.eth_dst = [0,0,0,0,0,0]
+ if vlan_vid != None:
+ self.vlan_vid = vlan_vid
+ else:
+ self.vlan_vid = 0
+ if vlan_pcp != None:
+ self.vlan_pcp = vlan_pcp
+ else:
+ self.vlan_pcp = 0
+ if pad1 != None:
+ self.pad1 = pad1
+ else:
+ self.pad1 = 0
+ if eth_type != None:
+ self.eth_type = eth_type
+ else:
+ self.eth_type = 0
+ if ip_dscp != None:
+ self.ip_dscp = ip_dscp
+ else:
+ self.ip_dscp = 0
+ if ip_proto != None:
+ self.ip_proto = ip_proto
+ else:
+ self.ip_proto = 0
+ if pad2 != None:
+ self.pad2 = pad2
+ else:
+ self.pad2 = [0,0]
+ if ipv4_src != None:
+ self.ipv4_src = ipv4_src
+ else:
+ self.ipv4_src = 0
+ if ipv4_dst != None:
+ self.ipv4_dst = ipv4_dst
+ else:
+ self.ipv4_dst = 0
+ if tcp_src != None:
+ self.tcp_src = tcp_src
+ else:
+ self.tcp_src = 0
+ if tcp_dst != None:
+ self.tcp_dst = tcp_dst
+ else:
+ self.tcp_dst = 0
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!L", self.wildcards))
+ packed.append(struct.pack("!H", self.in_port))
+ packed.append(struct.pack("!6B", *self.eth_src))
+ packed.append(struct.pack("!6B", *self.eth_dst))
+ packed.append(struct.pack("!H", self.vlan_vid))
+ packed.append(struct.pack("!B", self.vlan_pcp))
+ packed.append(struct.pack("!B", self.pad1))
+ packed.append(struct.pack("!H", self.eth_type))
+ packed.append(struct.pack("!B", self.ip_dscp))
+ packed.append(struct.pack("!B", self.ip_proto))
+ packed.append(struct.pack("!2B", *self.pad2))
+ packed.append(struct.pack("!L", self.ipv4_src))
+ packed.append(struct.pack("!L", self.ipv4_dst))
+ packed.append(struct.pack("!H", self.tcp_src))
+ packed.append(struct.pack("!H", self.tcp_dst))
+ return ''.join(packed)
+
+ @staticmethod
+ def unpack(buf):
+ assert(len(buf) >= 40) # Should be verified by caller
+ obj = match_v1()
+ obj.wildcards = struct.unpack_from('!L', buf, 0)[0]
+ obj.in_port = struct.unpack_from('!H', buf, 4)[0]
+ obj.eth_src = list(struct.unpack_from('!6B', buf, 6))
+ obj.eth_dst = list(struct.unpack_from('!6B', buf, 12))
+ obj.vlan_vid = struct.unpack_from('!H', buf, 18)[0]
+ obj.vlan_pcp = struct.unpack_from('!B', buf, 20)[0]
+ obj.pad1 = struct.unpack_from('!B', buf, 21)[0]
+ obj.eth_type = struct.unpack_from('!H', buf, 22)[0]
+ obj.ip_dscp = struct.unpack_from('!B', buf, 24)[0]
+ obj.ip_proto = struct.unpack_from('!B', buf, 25)[0]
+ obj.pad2 = list(struct.unpack_from('!2B', buf, 26))
+ obj.ipv4_src = struct.unpack_from('!L', buf, 28)[0]
+ obj.ipv4_dst = struct.unpack_from('!L', buf, 32)[0]
+ obj.tcp_src = struct.unpack_from('!H', buf, 36)[0]
+ obj.tcp_dst = struct.unpack_from('!H', buf, 38)[0]
+ return obj
+
+ def __eq__(self, other):
+ if type(self) != type(other): return False
+ if self.wildcards != other.wildcards: return False
+ if self.in_port != other.in_port: return False
+ if self.eth_src != other.eth_src: return False
+ if self.eth_dst != other.eth_dst: return False
+ if self.vlan_vid != other.vlan_vid: return False
+ if self.vlan_pcp != other.vlan_pcp: return False
+ if self.pad1 != other.pad1: return False
+ if self.eth_type != other.eth_type: return False
+ if self.ip_dscp != other.ip_dscp: return False
+ if self.ip_proto != other.ip_proto: return False
+ if self.pad2 != other.pad2: return False
+ if self.ipv4_src != other.ipv4_src: return False
+ if self.ipv4_dst != other.ipv4_dst: return False
+ if self.tcp_src != other.tcp_src: return False
+ if self.tcp_dst != other.tcp_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("match_v1 {")
+ with q.group():
+ with q.indent(2):
+ q.breakable()
+ q.text("wildcards = ");
+ q.text(util.pretty_wildcards(self.wildcards))
+ q.text(","); q.breakable()
+ q.text("in_port = ");
+ q.text(util.pretty_port(self.in_port))
+ q.text(","); q.breakable()
+ q.text("eth_src = ");
+ q.text(util.pretty_mac(self.eth_src))
+ q.text(","); q.breakable()
+ q.text("eth_dst = ");
+ q.text(util.pretty_mac(self.eth_dst))
+ q.text(","); q.breakable()
+ q.text("vlan_vid = ");
+ q.text("%#x" % self.vlan_vid)
+ q.text(","); q.breakable()
+ q.text("vlan_pcp = ");
+ q.text("%#x" % self.vlan_pcp)
+ q.text(","); q.breakable()
+ q.text("pad1 = ");
+ q.text("%#x" % self.pad1)
+ q.text(","); q.breakable()
+ q.text("eth_type = ");
+ q.text("%#x" % self.eth_type)
+ q.text(","); q.breakable()
+ q.text("ip_dscp = ");
+ q.text("%#x" % self.ip_dscp)
+ q.text(","); q.breakable()
+ q.text("ip_proto = ");
+ q.text("%#x" % self.ip_proto)
+ q.text(","); q.breakable()
+ q.text("pad2 = ");
+ q.pp(self.pad2)
+ q.text(","); q.breakable()
+ q.text("ipv4_src = ");
+ q.text(util.pretty_ipv4(self.ipv4_src))
+ q.text(","); q.breakable()
+ q.text("ipv4_dst = ");
+ q.text(util.pretty_ipv4(self.ipv4_dst))
+ q.text(","); q.breakable()
+ q.text("tcp_src = ");
+ q.text("%#x" % self.tcp_src)
+ q.text(","); q.breakable()
+ q.text("tcp_dst = ");
+ q.text("%#x" % self.tcp_dst)
+ q.breakable()
+ q.text('}')
+
+match = match_v1
+
+class packet_queue(object):
+
+ def __init__(self, queue_id=None, pad=None, properties=None):
+ if queue_id != None:
+ self.queue_id = queue_id
+ else:
+ self.queue_id = 0
+ if pad != None:
+ self.pad = pad
+ else:
+ self.pad = [0,0]
+ if properties != None:
+ self.properties = properties
+ else:
+ self.properties = []
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!L", self.queue_id))
+ packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
+ packed.append(struct.pack("!2B", *self.pad))
+ packed.append("".join([x.pack() for x in self.properties]))
+ length = sum([len(x) for x in packed])
+ packed[1] = struct.pack("!H", length)
+ return ''.join(packed)
+
+ @staticmethod
+ def unpack(buf):
+ assert(len(buf) >= 8) # Should be verified by caller
+ obj = packet_queue()
+ obj.queue_id = struct.unpack_from('!L', buf, 0)[0]
+ _length = struct.unpack_from('!H', buf, 4)[0]
+ assert(_length == len(buf))
+ if _length < 8: raise loxi.ProtocolError("packet_queue length is %d, should be at least 8" % _length)
+ obj.pad = list(struct.unpack_from('!2B', buf, 6))
+ obj.properties = common.unpack_list_queue_prop(buffer(buf, 8))
+ return obj
+
+ def __eq__(self, other):
+ if type(self) != type(other): return False
+ if self.queue_id != other.queue_id: return False
+ if self.pad != other.pad: return False
+ 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("queue_id = ");
+ q.text("%#x" % self.queue_id)
+ q.text(","); q.breakable()
+ q.text("pad = ");
+ q.pp(self.pad)
+ q.text(","); q.breakable()
+ q.text("properties = ");
+ q.pp(self.properties)
+ q.breakable()
+ q.text('}')
+
+class port_desc(object):
+
+ def __init__(self, port_no=None, hw_addr=None, name=None, config=None, state=None, curr=None, advertised=None, supported=None, peer=None):
+ if port_no != None:
+ self.port_no = port_no
+ else:
+ self.port_no = 0
+ if hw_addr != None:
+ self.hw_addr = hw_addr
+ else:
+ self.hw_addr = [0,0,0,0,0,0]
+ if name != None:
+ self.name = name
+ else:
+ self.name = ""
+ if config != None:
+ self.config = config
+ else:
+ self.config = 0
+ if state != None:
+ self.state = state
+ else:
+ self.state = 0
+ if curr != None:
+ self.curr = curr
+ else:
+ self.curr = 0
+ if advertised != None:
+ self.advertised = advertised
+ else:
+ self.advertised = 0
+ if supported != None:
+ self.supported = supported
+ else:
+ self.supported = 0
+ if peer != None:
+ self.peer = peer
+ else:
+ self.peer = 0
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!H", self.port_no))
+ packed.append(struct.pack("!6B", *self.hw_addr))
+ packed.append(struct.pack("!16s", self.name))
+ packed.append(struct.pack("!L", self.config))
+ packed.append(struct.pack("!L", self.state))
+ packed.append(struct.pack("!L", self.curr))
+ packed.append(struct.pack("!L", self.advertised))
+ packed.append(struct.pack("!L", self.supported))
+ packed.append(struct.pack("!L", self.peer))
+ return ''.join(packed)
+
+ @staticmethod
+ def unpack(buf):
+ assert(len(buf) >= 48) # Should be verified by caller
+ obj = port_desc()
+ obj.port_no = struct.unpack_from('!H', buf, 0)[0]
+ obj.hw_addr = list(struct.unpack_from('!6B', buf, 2))
+ obj.name = str(buffer(buf, 8, 16)).rstrip("\x00")
+ obj.config = struct.unpack_from('!L', buf, 24)[0]
+ obj.state = struct.unpack_from('!L', buf, 28)[0]
+ obj.curr = struct.unpack_from('!L', buf, 32)[0]
+ obj.advertised = struct.unpack_from('!L', buf, 36)[0]
+ obj.supported = struct.unpack_from('!L', buf, 40)[0]
+ obj.peer = struct.unpack_from('!L', buf, 44)[0]
+ return obj
+
+ def __eq__(self, other):
+ if type(self) != type(other): return False
+ if self.port_no != other.port_no: return False
+ if self.hw_addr != other.hw_addr: return False
+ if self.name != other.name: return False
+ if self.config != other.config: return False
+ if self.state != other.state: return False
+ if self.curr != other.curr: return False
+ if self.advertised != other.advertised: return False
+ if self.supported != other.supported: return False
+ if self.peer != other.peer: 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("port_no = ");
+ q.text(util.pretty_port(self.port_no))
+ q.text(","); q.breakable()
+ q.text("hw_addr = ");
+ q.text(util.pretty_mac(self.hw_addr))
+ q.text(","); q.breakable()
+ q.text("name = ");
+ q.pp(self.name)
+ q.text(","); q.breakable()
+ q.text("config = ");
+ q.text("%#x" % self.config)
+ q.text(","); q.breakable()
+ q.text("state = ");
+ q.text("%#x" % self.state)
+ q.text(","); q.breakable()
+ q.text("curr = ");
+ q.text("%#x" % self.curr)
+ q.text(","); q.breakable()
+ q.text("advertised = ");
+ q.text("%#x" % self.advertised)
+ q.text(","); q.breakable()
+ q.text("supported = ");
+ q.text("%#x" % self.supported)
+ q.text(","); q.breakable()
+ q.text("peer = ");
+ q.text("%#x" % self.peer)
+ q.breakable()
+ q.text('}')
+
+class port_stats_entry(object):
+
+ def __init__(self, port_no=None, pad=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:
+ self.port_no = port_no
+ else:
+ self.port_no = 0
+ if pad != None:
+ self.pad = pad
+ else:
+ self.pad = [0,0,0,0,0,0]
+ if rx_packets != None:
+ self.rx_packets = rx_packets
+ else:
+ self.rx_packets = 0
+ if tx_packets != None:
+ self.tx_packets = tx_packets
+ else:
+ self.tx_packets = 0
+ if rx_bytes != None:
+ self.rx_bytes = rx_bytes
+ else:
+ self.rx_bytes = 0
+ if tx_bytes != None:
+ self.tx_bytes = tx_bytes
+ else:
+ self.tx_bytes = 0
+ if rx_dropped != None:
+ self.rx_dropped = rx_dropped
+ else:
+ self.rx_dropped = 0
+ if tx_dropped != None:
+ self.tx_dropped = tx_dropped
+ else:
+ self.tx_dropped = 0
+ if rx_errors != None:
+ self.rx_errors = rx_errors
+ else:
+ self.rx_errors = 0
+ if tx_errors != None:
+ self.tx_errors = tx_errors
+ else:
+ self.tx_errors = 0
+ if rx_frame_err != None:
+ self.rx_frame_err = rx_frame_err
+ else:
+ self.rx_frame_err = 0
+ if rx_over_err != None:
+ self.rx_over_err = rx_over_err
+ else:
+ self.rx_over_err = 0
+ if rx_crc_err != None:
+ self.rx_crc_err = rx_crc_err
+ else:
+ self.rx_crc_err = 0
+ if collisions != None:
+ self.collisions = collisions
+ else:
+ self.collisions = 0
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!H", self.port_no))
+ packed.append(struct.pack("!6B", *self.pad))
+ packed.append(struct.pack("!Q", self.rx_packets))
+ packed.append(struct.pack("!Q", self.tx_packets))
+ packed.append(struct.pack("!Q", self.rx_bytes))
+ packed.append(struct.pack("!Q", self.tx_bytes))
+ packed.append(struct.pack("!Q", self.rx_dropped))
+ packed.append(struct.pack("!Q", self.tx_dropped))
+ packed.append(struct.pack("!Q", self.rx_errors))
+ packed.append(struct.pack("!Q", self.tx_errors))
+ packed.append(struct.pack("!Q", self.rx_frame_err))
+ packed.append(struct.pack("!Q", self.rx_over_err))
+ packed.append(struct.pack("!Q", self.rx_crc_err))
+ packed.append(struct.pack("!Q", self.collisions))
+ return ''.join(packed)
+
+ @staticmethod
+ def unpack(buf):
+ assert(len(buf) >= 104) # Should be verified by caller
+ obj = port_stats_entry()
+ obj.port_no = struct.unpack_from('!H', buf, 0)[0]
+ obj.pad = list(struct.unpack_from('!6B', buf, 2))
+ obj.rx_packets = struct.unpack_from('!Q', buf, 8)[0]
+ obj.tx_packets = struct.unpack_from('!Q', buf, 16)[0]
+ obj.rx_bytes = struct.unpack_from('!Q', buf, 24)[0]
+ obj.tx_bytes = struct.unpack_from('!Q', buf, 32)[0]
+ obj.rx_dropped = struct.unpack_from('!Q', buf, 40)[0]
+ obj.tx_dropped = struct.unpack_from('!Q', buf, 48)[0]
+ obj.rx_errors = struct.unpack_from('!Q', buf, 56)[0]
+ obj.tx_errors = struct.unpack_from('!Q', buf, 64)[0]
+ obj.rx_frame_err = struct.unpack_from('!Q', buf, 72)[0]
+ obj.rx_over_err = struct.unpack_from('!Q', buf, 80)[0]
+ obj.rx_crc_err = struct.unpack_from('!Q', buf, 88)[0]
+ obj.collisions = struct.unpack_from('!Q', buf, 96)[0]
+ return obj
+
+ def __eq__(self, other):
+ if type(self) != type(other): return False
+ if self.port_no != other.port_no: return False
+ if self.pad != other.pad: return False
+ if self.rx_packets != other.rx_packets: return False
+ if self.tx_packets != other.tx_packets: return False
+ if self.rx_bytes != other.rx_bytes: return False
+ if self.tx_bytes != other.tx_bytes: return False
+ if self.rx_dropped != other.rx_dropped: return False
+ if self.tx_dropped != other.tx_dropped: return False
+ if self.rx_errors != other.rx_errors: return False
+ if self.tx_errors != other.tx_errors: return False
+ if self.rx_frame_err != other.rx_frame_err: return False
+ if self.rx_over_err != other.rx_over_err: return False
+ if self.rx_crc_err != other.rx_crc_err: return False
+ 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("port_no = ");
+ q.text(util.pretty_port(self.port_no))
+ q.text(","); q.breakable()
+ q.text("pad = ");
+ q.pp(self.pad)
+ q.text(","); q.breakable()
+ q.text("rx_packets = ");
+ q.text("%#x" % self.rx_packets)
+ q.text(","); q.breakable()
+ q.text("tx_packets = ");
+ q.text("%#x" % self.tx_packets)
+ q.text(","); q.breakable()
+ q.text("rx_bytes = ");
+ q.text("%#x" % self.rx_bytes)
+ q.text(","); q.breakable()
+ q.text("tx_bytes = ");
+ q.text("%#x" % self.tx_bytes)
+ q.text(","); q.breakable()
+ q.text("rx_dropped = ");
+ q.text("%#x" % self.rx_dropped)
+ q.text(","); q.breakable()
+ q.text("tx_dropped = ");
+ q.text("%#x" % self.tx_dropped)
+ q.text(","); q.breakable()
+ q.text("rx_errors = ");
+ q.text("%#x" % self.rx_errors)
+ q.text(","); q.breakable()
+ q.text("tx_errors = ");
+ q.text("%#x" % self.tx_errors)
+ q.text(","); q.breakable()
+ q.text("rx_frame_err = ");
+ q.text("%#x" % self.rx_frame_err)
+ q.text(","); q.breakable()
+ q.text("rx_over_err = ");
+ q.text("%#x" % self.rx_over_err)
+ q.text(","); q.breakable()
+ q.text("rx_crc_err = ");
+ q.text("%#x" % self.rx_crc_err)
+ q.text(","); q.breakable()
+ q.text("collisions = ");
+ q.text("%#x" % self.collisions)
+ q.breakable()
+ q.text('}')
+
+class queue_prop_min_rate(object):
+ type = const.OFPQT_MIN_RATE
+
+ def __init__(self, pad=None, rate=None, pad2=None):
+ if pad != None:
+ self.pad = pad
+ else:
+ self.pad = [0,0,0,0]
+ if rate != None:
+ self.rate = rate
+ else:
+ self.rate = 0
+ if pad2 != None:
+ self.pad2 = pad2
+ else:
+ self.pad2 = [0,0,0,0,0,0]
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!H", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
+ packed.append(struct.pack("!4B", *self.pad))
+ packed.append(struct.pack("!H", self.rate))
+ packed.append(struct.pack("!6B", *self.pad2))
+ length = sum([len(x) for x in packed])
+ packed[1] = struct.pack("!H", length)
+ return ''.join(packed)
+
+ @staticmethod
+ def unpack(buf):
+ assert(len(buf) >= 16) # Should be verified by caller
+ obj = queue_prop_min_rate()
+ type = struct.unpack_from('!H', buf, 0)[0]
+ assert(type == const.OFPQT_MIN_RATE)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 16: raise loxi.ProtocolError("queue_prop_min_rate length is %d, should be 16" % _length)
+ obj.pad = list(struct.unpack_from('!4B', buf, 4))
+ obj.rate = struct.unpack_from('!H', buf, 8)[0]
+ obj.pad2 = list(struct.unpack_from('!6B', buf, 10))
+ return obj
+
+ def __eq__(self, other):
+ if type(self) != type(other): return False
+ if self.pad != other.pad: return False
+ if self.rate != other.rate: return False
+ if self.pad2 != other.pad2: 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("pad = ");
+ q.pp(self.pad)
+ q.text(","); q.breakable()
+ q.text("rate = ");
+ q.text("%#x" % self.rate)
+ q.text(","); q.breakable()
+ q.text("pad2 = ");
+ q.pp(self.pad2)
+ q.breakable()
+ q.text('}')
+
+class queue_stats_entry(object):
+
+ def __init__(self, port_no=None, pad=None, queue_id=None, tx_bytes=None, tx_packets=None, tx_errors=None):
+ if port_no != None:
+ self.port_no = port_no
+ else:
+ self.port_no = 0
+ if pad != None:
+ self.pad = pad
+ else:
+ self.pad = [0,0]
+ if queue_id != None:
+ self.queue_id = queue_id
+ else:
+ self.queue_id = 0
+ if tx_bytes != None:
+ self.tx_bytes = tx_bytes
+ else:
+ self.tx_bytes = 0
+ if tx_packets != None:
+ self.tx_packets = tx_packets
+ else:
+ self.tx_packets = 0
+ if tx_errors != None:
+ self.tx_errors = tx_errors
+ else:
+ self.tx_errors = 0
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!H", self.port_no))
+ packed.append(struct.pack("!2B", *self.pad))
+ packed.append(struct.pack("!L", self.queue_id))
+ packed.append(struct.pack("!Q", self.tx_bytes))
+ packed.append(struct.pack("!Q", self.tx_packets))
+ packed.append(struct.pack("!Q", self.tx_errors))
+ return ''.join(packed)
+
+ @staticmethod
+ def unpack(buf):
+ assert(len(buf) >= 32) # Should be verified by caller
+ obj = queue_stats_entry()
+ obj.port_no = struct.unpack_from('!H', buf, 0)[0]
+ obj.pad = list(struct.unpack_from('!2B', buf, 2))
+ obj.queue_id = struct.unpack_from('!L', buf, 4)[0]
+ obj.tx_bytes = struct.unpack_from('!Q', buf, 8)[0]
+ obj.tx_packets = struct.unpack_from('!Q', buf, 16)[0]
+ obj.tx_errors = struct.unpack_from('!Q', buf, 24)[0]
+ return obj
+
+ def __eq__(self, other):
+ if type(self) != type(other): return False
+ if self.port_no != other.port_no: return False
+ if self.pad != other.pad: return False
+ if self.queue_id != other.queue_id: return False
+ if self.tx_bytes != other.tx_bytes: return False
+ if self.tx_packets != other.tx_packets: return False
+ 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("port_no = ");
+ q.text(util.pretty_port(self.port_no))
+ q.text(","); q.breakable()
+ q.text("pad = ");
+ q.pp(self.pad)
+ q.text(","); q.breakable()
+ q.text("queue_id = ");
+ q.text("%#x" % self.queue_id)
+ q.text(","); q.breakable()
+ q.text("tx_bytes = ");
+ q.text("%#x" % self.tx_bytes)
+ q.text(","); q.breakable()
+ q.text("tx_packets = ");
+ q.text("%#x" % self.tx_packets)
+ q.text(","); q.breakable()
+ q.text("tx_errors = ");
+ q.text("%#x" % self.tx_errors)
+ q.breakable()
+ q.text('}')
+
+class table_stats_entry(object):
+
+ def __init__(self, table_id=None, pad=None, name=None, wildcards=None, max_entries=None, active_count=None, lookup_count=None, matched_count=None):
+ if table_id != None:
+ self.table_id = table_id
+ else:
+ self.table_id = 0
+ if pad != None:
+ self.pad = pad
+ else:
+ self.pad = [0,0,0]
+ if name != None:
+ self.name = name
+ else:
+ self.name = ""
+ if wildcards != None:
+ self.wildcards = wildcards
+ else:
+ self.wildcards = const.OFPFW_ALL
+ if max_entries != None:
+ self.max_entries = max_entries
+ else:
+ self.max_entries = 0
+ if active_count != None:
+ self.active_count = active_count
+ else:
+ self.active_count = 0
+ if lookup_count != None:
+ self.lookup_count = lookup_count
+ else:
+ self.lookup_count = 0
+ if matched_count != None:
+ self.matched_count = matched_count
+ else:
+ self.matched_count = 0
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.table_id))
+ packed.append(struct.pack("!3B", *self.pad))
+ packed.append(struct.pack("!32s", self.name))
+ packed.append(struct.pack("!L", self.wildcards))
+ packed.append(struct.pack("!L", self.max_entries))
+ packed.append(struct.pack("!L", self.active_count))
+ packed.append(struct.pack("!Q", self.lookup_count))
+ packed.append(struct.pack("!Q", self.matched_count))
+ return ''.join(packed)
+
+ @staticmethod
+ def unpack(buf):
+ assert(len(buf) >= 64) # Should be verified by caller
+ obj = table_stats_entry()
+ obj.table_id = struct.unpack_from('!B', buf, 0)[0]
+ obj.pad = list(struct.unpack_from('!3B', buf, 1))
+ obj.name = str(buffer(buf, 4, 32)).rstrip("\x00")
+ obj.wildcards = struct.unpack_from('!L', buf, 36)[0]
+ obj.max_entries = struct.unpack_from('!L', buf, 40)[0]
+ obj.active_count = struct.unpack_from('!L', buf, 44)[0]
+ obj.lookup_count = struct.unpack_from('!Q', buf, 48)[0]
+ obj.matched_count = struct.unpack_from('!Q', buf, 56)[0]
+ return obj
+
+ def __eq__(self, other):
+ if type(self) != type(other): return False
+ if self.table_id != other.table_id: return False
+ if self.pad != other.pad: return False
+ if self.name != other.name: return False
+ if self.wildcards != other.wildcards: return False
+ if self.max_entries != other.max_entries: return False
+ if self.active_count != other.active_count: return False
+ if self.lookup_count != other.lookup_count: return False
+ 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("table_id = ");
+ q.text("%#x" % self.table_id)
+ q.text(","); q.breakable()
+ q.text("pad = ");
+ q.pp(self.pad)
+ q.text(","); q.breakable()
+ q.text("name = ");
+ q.pp(self.name)
+ q.text(","); q.breakable()
+ q.text("wildcards = ");
+ q.text(util.pretty_wildcards(self.wildcards))
+ q.text(","); q.breakable()
+ q.text("max_entries = ");
+ q.text("%#x" % self.max_entries)
+ q.text(","); q.breakable()
+ q.text("active_count = ");
+ q.text("%#x" % self.active_count)
+ q.text(","); q.breakable()
+ q.text("lookup_count = ");
+ q.text("%#x" % self.lookup_count)
+ q.text(","); q.breakable()
+ q.text("matched_count = ");
+ q.text("%#x" % self.matched_count)
+ q.breakable()
+ q.text('}')
+
diff --git a/src/python/loxi/of10/const.py b/src/python/loxi/of10/const.py
new file mode 100644
index 0000000..e269071
--- /dev/null
+++ b/src/python/loxi/of10/const.py
@@ -0,0 +1,476 @@
+#
+# Copyright 2012, 2013, Big Switch Networks, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+# Automatically generated by LOXI from template const.py
+# Do not modify
+
+OFP_VERSION = 1
+
+# Identifiers from group macro_definitions
+OFP_FLOW_PERMANENT = 0
+OFP_ETH_ALEN = 6
+OFP_MAX_PORT_NAME_LEN = 16
+OFP_MAX_TABLE_NAME_LEN = 32
+SERIAL_NUM_LEN = 32
+OFPFW_ICMP_TYPE = (1 << 6)
+OFPFW_ICMP_CODE = (1 << 7)
+OFP_DEFAULT_MISS_SEND_LEN = 128
+DESC_STR_LEN = 256
+OFP_DL_TYPE_NOT_ETH_TYPE = 0x05ff
+OFP_DL_TYPE_ETH2_CUTOFF = 0x0600
+OFP_TCP_PORT = 6633
+OFP_SSL_PORT = 6633
+OFP_DEFAULT_PRIORITY = 0x8000
+OFPQ_MIN_RATE_UNCFG = 0xffff
+OFP_VLAN_NONE = 0xffff
+OFPQ_ALL = 0xffffffff
+
+# Identifiers from group ofp_action_type
+OFPAT_OUTPUT = 0
+OFPAT_SET_VLAN_VID = 1
+OFPAT_SET_VLAN_PCP = 2
+OFPAT_STRIP_VLAN = 3
+OFPAT_SET_DL_SRC = 4
+OFPAT_SET_DL_DST = 5
+OFPAT_SET_NW_SRC = 6
+OFPAT_SET_NW_DST = 7
+OFPAT_SET_NW_TOS = 8
+OFPAT_SET_TP_SRC = 9
+OFPAT_SET_TP_DST = 10
+OFPAT_ENQUEUE = 11
+OFPAT_VENDOR = 0xffff
+
+ofp_action_type_map = {
+ 0: 'OFPAT_OUTPUT',
+ 1: 'OFPAT_SET_VLAN_VID',
+ 2: 'OFPAT_SET_VLAN_PCP',
+ 3: 'OFPAT_STRIP_VLAN',
+ 4: 'OFPAT_SET_DL_SRC',
+ 5: 'OFPAT_SET_DL_DST',
+ 6: 'OFPAT_SET_NW_SRC',
+ 7: 'OFPAT_SET_NW_DST',
+ 8: 'OFPAT_SET_NW_TOS',
+ 9: 'OFPAT_SET_TP_SRC',
+ 10: 'OFPAT_SET_TP_DST',
+ 11: 'OFPAT_ENQUEUE',
+ 0xffff: 'OFPAT_VENDOR',
+}
+
+# Identifiers from group ofp_bad_action_code
+OFPBAC_BAD_TYPE = 0
+OFPBAC_BAD_LEN = 1
+OFPBAC_BAD_VENDOR = 2
+OFPBAC_BAD_VENDOR_TYPE = 3
+OFPBAC_BAD_OUT_PORT = 4
+OFPBAC_BAD_ARGUMENT = 5
+OFPBAC_EPERM = 6
+OFPBAC_TOO_MANY = 7
+OFPBAC_BAD_QUEUE = 8
+
+ofp_bad_action_code_map = {
+ 0: 'OFPBAC_BAD_TYPE',
+ 1: 'OFPBAC_BAD_LEN',
+ 2: 'OFPBAC_BAD_VENDOR',
+ 3: 'OFPBAC_BAD_VENDOR_TYPE',
+ 4: 'OFPBAC_BAD_OUT_PORT',
+ 5: 'OFPBAC_BAD_ARGUMENT',
+ 6: 'OFPBAC_EPERM',
+ 7: 'OFPBAC_TOO_MANY',
+ 8: 'OFPBAC_BAD_QUEUE',
+}
+
+# Identifiers from group ofp_bad_request_code
+OFPBRC_BAD_VERSION = 0
+OFPBRC_BAD_TYPE = 1
+OFPBRC_BAD_STAT = 2
+OFPBRC_BAD_VENDOR = 3
+OFPBRC_BAD_SUBTYPE = 4
+OFPBRC_EPERM = 5
+OFPBRC_BAD_LEN = 6
+OFPBRC_BUFFER_EMPTY = 7
+OFPBRC_BUFFER_UNKNOWN = 8
+
+ofp_bad_request_code_map = {
+ 0: 'OFPBRC_BAD_VERSION',
+ 1: 'OFPBRC_BAD_TYPE',
+ 2: 'OFPBRC_BAD_STAT',
+ 3: 'OFPBRC_BAD_VENDOR',
+ 4: 'OFPBRC_BAD_SUBTYPE',
+ 5: 'OFPBRC_EPERM',
+ 6: 'OFPBRC_BAD_LEN',
+ 7: 'OFPBRC_BUFFER_EMPTY',
+ 8: 'OFPBRC_BUFFER_UNKNOWN',
+}
+
+# Identifiers from group ofp_capabilities
+OFPC_FLOW_STATS = 1 << 0
+OFPC_TABLE_STATS = 1 << 1
+OFPC_PORT_STATS = 1 << 2
+OFPC_STP = 1 << 3
+OFPC_RESERVED = 1 << 4
+OFPC_IP_REASM = 1 << 5
+OFPC_QUEUE_STATS = 1 << 6
+OFPC_ARP_MATCH_IP = 1 << 7
+
+ofp_capabilities_map = {
+ 1 << 0: 'OFPC_FLOW_STATS',
+ 1 << 1: 'OFPC_TABLE_STATS',
+ 1 << 2: 'OFPC_PORT_STATS',
+ 1 << 3: 'OFPC_STP',
+ 1 << 4: 'OFPC_RESERVED',
+ 1 << 5: 'OFPC_IP_REASM',
+ 1 << 6: 'OFPC_QUEUE_STATS',
+ 1 << 7: 'OFPC_ARP_MATCH_IP',
+}
+
+# Identifiers from group ofp_config_flags
+OFPC_FRAG_NORMAL = 0
+OFPC_FRAG_DROP = 1
+OFPC_FRAG_REASM = 2
+OFPC_FRAG_MASK = 3
+
+ofp_config_flags_map = {
+ 0: 'OFPC_FRAG_NORMAL',
+ 1: 'OFPC_FRAG_DROP',
+ 2: 'OFPC_FRAG_REASM',
+ 3: 'OFPC_FRAG_MASK',
+}
+
+# Identifiers from group ofp_error_type
+OFPET_HELLO_FAILED = 0
+OFPET_BAD_REQUEST = 1
+OFPET_BAD_ACTION = 2
+OFPET_FLOW_MOD_FAILED = 3
+OFPET_PORT_MOD_FAILED = 4
+OFPET_QUEUE_OP_FAILED = 5
+
+ofp_error_type_map = {
+ 0: 'OFPET_HELLO_FAILED',
+ 1: 'OFPET_BAD_REQUEST',
+ 2: 'OFPET_BAD_ACTION',
+ 3: 'OFPET_FLOW_MOD_FAILED',
+ 4: 'OFPET_PORT_MOD_FAILED',
+ 5: 'OFPET_QUEUE_OP_FAILED',
+}
+
+# Identifiers from group ofp_flow_mod_command
+OFPFC_ADD = 0
+OFPFC_MODIFY = 1
+OFPFC_MODIFY_STRICT = 2
+OFPFC_DELETE = 3
+OFPFC_DELETE_STRICT = 4
+
+ofp_flow_mod_command_map = {
+ 0: 'OFPFC_ADD',
+ 1: 'OFPFC_MODIFY',
+ 2: 'OFPFC_MODIFY_STRICT',
+ 3: 'OFPFC_DELETE',
+ 4: 'OFPFC_DELETE_STRICT',
+}
+
+# Identifiers from group ofp_flow_mod_failed_code
+OFPFMFC_ALL_TABLES_FULL = 0
+OFPFMFC_OVERLAP = 1
+OFPFMFC_EPERM = 2
+OFPFMFC_BAD_EMERG_TIMEOUT = 3
+OFPFMFC_BAD_COMMAND = 4
+OFPFMFC_UNSUPPORTED = 5
+
+ofp_flow_mod_failed_code_map = {
+ 0: 'OFPFMFC_ALL_TABLES_FULL',
+ 1: 'OFPFMFC_OVERLAP',
+ 2: 'OFPFMFC_EPERM',
+ 3: 'OFPFMFC_BAD_EMERG_TIMEOUT',
+ 4: 'OFPFMFC_BAD_COMMAND',
+ 5: 'OFPFMFC_UNSUPPORTED',
+}
+
+# Identifiers from group ofp_flow_mod_flags
+OFPFF_SEND_FLOW_REM = 1 << 0
+OFPFF_CHECK_OVERLAP = 1 << 1
+OFPFF_EMERG = 1 << 2
+
+ofp_flow_mod_flags_map = {
+ 1 << 0: 'OFPFF_SEND_FLOW_REM',
+ 1 << 1: 'OFPFF_CHECK_OVERLAP',
+ 1 << 2: 'OFPFF_EMERG',
+}
+
+# Identifiers from group ofp_flow_removed_reason
+OFPRR_IDLE_TIMEOUT = 0
+OFPRR_HARD_TIMEOUT = 1
+OFPRR_DELETE = 2
+
+ofp_flow_removed_reason_map = {
+ 0: 'OFPRR_IDLE_TIMEOUT',
+ 1: 'OFPRR_HARD_TIMEOUT',
+ 2: 'OFPRR_DELETE',
+}
+
+# Identifiers from group ofp_flow_wildcards
+OFPFW_IN_PORT = 1 << 0
+OFPFW_DL_VLAN = 1 << 1
+OFPFW_DL_SRC = 1 << 2
+OFPFW_NW_DST_BITS = 6
+OFPFW_NW_SRC_BITS = 6
+OFPFW_NW_SRC_SHIFT = 8
+OFPFW_DL_DST = 1 << 3
+OFPFW_NW_DST_SHIFT = 14
+OFPFW_DL_TYPE = 1 << 4
+OFPFW_NW_PROTO = 1 << 5
+OFPFW_TP_SRC = 1 << 6
+OFPFW_TP_DST = 1 << 7
+OFPFW_NW_SRC_ALL = 32 << (8)
+OFPFW_NW_SRC_MASK = ((1 << (6)) - 1) << (8)
+OFPFW_NW_DST_ALL = 32 << (14)
+OFPFW_NW_DST_MASK = ((1 << (6)) - 1) << (14)
+OFPFW_DL_VLAN_PCP = 1 << 20
+OFPFW_NW_TOS = 1 << 21
+OFPFW_ALL = ((1 << 22) - 1)
+
+ofp_flow_wildcards_map = {
+ 1 << 0: 'OFPFW_IN_PORT',
+ 1 << 1: 'OFPFW_DL_VLAN',
+ 1 << 2: 'OFPFW_DL_SRC',
+ 1 << 3: 'OFPFW_DL_DST',
+ 1 << 4: 'OFPFW_DL_TYPE',
+ 1 << 5: 'OFPFW_NW_PROTO',
+ 1 << 6: 'OFPFW_TP_SRC',
+ 1 << 7: 'OFPFW_TP_DST',
+ 1 << 20: 'OFPFW_DL_VLAN_PCP',
+ 1 << 21: 'OFPFW_NW_TOS',
+}
+
+# Identifiers from group ofp_hello_failed_code
+OFPHFC_INCOMPATIBLE = 0
+OFPHFC_EPERM = 1
+
+ofp_hello_failed_code_map = {
+ 0: 'OFPHFC_INCOMPATIBLE',
+ 1: 'OFPHFC_EPERM',
+}
+
+# Identifiers from group ofp_packet_in_reason
+OFPR_NO_MATCH = 0
+OFPR_ACTION = 1
+
+ofp_packet_in_reason_map = {
+ 0: 'OFPR_NO_MATCH',
+ 1: 'OFPR_ACTION',
+}
+
+# Identifiers from group ofp_port
+OFPP_MAX = 0xff00
+OFPP_IN_PORT = 0xfff8
+OFPP_TABLE = 0xfff9
+OFPP_NORMAL = 0xfffa
+OFPP_FLOOD = 0xfffb
+OFPP_ALL = 0xfffc
+OFPP_CONTROLLER = 0xfffd
+OFPP_LOCAL = 0xfffe
+OFPP_NONE = 0xffff
+
+ofp_port_map = {
+ 0xff00: 'OFPP_MAX',
+ 0xfff8: 'OFPP_IN_PORT',
+ 0xfff9: 'OFPP_TABLE',
+ 0xfffa: 'OFPP_NORMAL',
+ 0xfffb: 'OFPP_FLOOD',
+ 0xfffc: 'OFPP_ALL',
+ 0xfffd: 'OFPP_CONTROLLER',
+ 0xfffe: 'OFPP_LOCAL',
+ 0xffff: 'OFPP_NONE',
+}
+
+# Identifiers from group ofp_port_config
+OFPPC_PORT_DOWN = 1 << 0
+OFPPC_NO_STP = 1 << 1
+OFPPC_NO_RECV = 1 << 2
+OFPPC_NO_RECV_STP = 1 << 3
+OFPPC_NO_FLOOD = 1 << 4
+OFPPC_NO_FWD = 1 << 5
+OFPPC_NO_PACKET_IN = 1 << 6
+
+ofp_port_config_map = {
+ 1 << 0: 'OFPPC_PORT_DOWN',
+ 1 << 1: 'OFPPC_NO_STP',
+ 1 << 2: 'OFPPC_NO_RECV',
+ 1 << 3: 'OFPPC_NO_RECV_STP',
+ 1 << 4: 'OFPPC_NO_FLOOD',
+ 1 << 5: 'OFPPC_NO_FWD',
+ 1 << 6: 'OFPPC_NO_PACKET_IN',
+}
+
+# Identifiers from group ofp_port_features
+OFPPF_10MB_HD = 1 << 0
+OFPPF_10MB_FD = 1 << 1
+OFPPF_100MB_HD = 1 << 2
+OFPPF_100MB_FD = 1 << 3
+OFPPF_1GB_HD = 1 << 4
+OFPPF_1GB_FD = 1 << 5
+OFPPF_10GB_FD = 1 << 6
+OFPPF_COPPER = 1 << 7
+OFPPF_FIBER = 1 << 8
+OFPPF_AUTONEG = 1 << 9
+OFPPF_PAUSE = 1 << 10
+OFPPF_PAUSE_ASYM = 1 << 11
+
+ofp_port_features_map = {
+ 1 << 0: 'OFPPF_10MB_HD',
+ 1 << 1: 'OFPPF_10MB_FD',
+ 1 << 2: 'OFPPF_100MB_HD',
+ 1 << 3: 'OFPPF_100MB_FD',
+ 1 << 4: 'OFPPF_1GB_HD',
+ 1 << 5: 'OFPPF_1GB_FD',
+ 1 << 6: 'OFPPF_10GB_FD',
+ 1 << 7: 'OFPPF_COPPER',
+ 1 << 8: 'OFPPF_FIBER',
+ 1 << 9: 'OFPPF_AUTONEG',
+ 1 << 10: 'OFPPF_PAUSE',
+ 1 << 11: 'OFPPF_PAUSE_ASYM',
+}
+
+# Identifiers from group ofp_port_mod_failed_code
+OFPPMFC_BAD_PORT = 0
+OFPPMFC_BAD_HW_ADDR = 1
+
+ofp_port_mod_failed_code_map = {
+ 0: 'OFPPMFC_BAD_PORT',
+ 1: 'OFPPMFC_BAD_HW_ADDR',
+}
+
+# Identifiers from group ofp_port_reason
+OFPPR_ADD = 0
+OFPPR_DELETE = 1
+OFPPR_MODIFY = 2
+
+ofp_port_reason_map = {
+ 0: 'OFPPR_ADD',
+ 1: 'OFPPR_DELETE',
+ 2: 'OFPPR_MODIFY',
+}
+
+# Identifiers from group ofp_port_state
+OFPPS_STP_LISTEN = 0 << 8
+OFPPS_LINK_DOWN = 1 << 0
+OFPPS_STP_LEARN = 1 << 8
+OFPPS_STP_FORWARD = 2 << 8
+OFPPS_STP_BLOCK = 3 << 8
+OFPPS_STP_MASK = 3 << 8
+
+ofp_port_state_map = {
+ 0 << 8: 'OFPPS_STP_LISTEN',
+ 1 << 0: 'OFPPS_LINK_DOWN',
+ 1 << 8: 'OFPPS_STP_LEARN',
+ 2 << 8: 'OFPPS_STP_FORWARD',
+ 3 << 8: 'OFPPS_STP_BLOCK',
+ 3 << 8: 'OFPPS_STP_MASK',
+}
+
+# Identifiers from group ofp_queue_op_failed_code
+OFPQOFC_BAD_PORT = 0
+OFPQOFC_BAD_QUEUE = 1
+OFPQOFC_EPERM = 2
+
+ofp_queue_op_failed_code_map = {
+ 0: 'OFPQOFC_BAD_PORT',
+ 1: 'OFPQOFC_BAD_QUEUE',
+ 2: 'OFPQOFC_EPERM',
+}
+
+# Identifiers from group ofp_queue_properties
+OFPQT_NONE = 0
+OFPQT_MIN_RATE = 1
+
+ofp_queue_properties_map = {
+ 0: 'OFPQT_NONE',
+ 1: 'OFPQT_MIN_RATE',
+}
+
+# Identifiers from group ofp_stats_reply_flags
+OFPSF_REPLY_MORE = 1 << 0
+
+ofp_stats_reply_flags_map = {
+ 1 << 0: 'OFPSF_REPLY_MORE',
+}
+
+# Identifiers from group ofp_stats_types
+OFPST_DESC = 0
+OFPST_FLOW = 1
+OFPST_AGGREGATE = 2
+OFPST_TABLE = 3
+OFPST_PORT = 4
+OFPST_QUEUE = 5
+OFPST_VENDOR = 0xffff
+
+ofp_stats_types_map = {
+ 0: 'OFPST_DESC',
+ 1: 'OFPST_FLOW',
+ 2: 'OFPST_AGGREGATE',
+ 3: 'OFPST_TABLE',
+ 4: 'OFPST_PORT',
+ 5: 'OFPST_QUEUE',
+ 0xffff: 'OFPST_VENDOR',
+}
+
+# Identifiers from group ofp_type
+OFPT_HELLO = 0
+OFPT_ERROR = 1
+OFPT_ECHO_REQUEST = 2
+OFPT_ECHO_REPLY = 3
+OFPT_VENDOR = 4
+OFPT_FEATURES_REQUEST = 5
+OFPT_FEATURES_REPLY = 6
+OFPT_GET_CONFIG_REQUEST = 7
+OFPT_GET_CONFIG_REPLY = 8
+OFPT_SET_CONFIG = 9
+OFPT_PACKET_IN = 10
+OFPT_FLOW_REMOVED = 11
+OFPT_PORT_STATUS = 12
+OFPT_PACKET_OUT = 13
+OFPT_FLOW_MOD = 14
+OFPT_PORT_MOD = 15
+OFPT_STATS_REQUEST = 16
+OFPT_STATS_REPLY = 17
+OFPT_BARRIER_REQUEST = 18
+OFPT_BARRIER_REPLY = 19
+OFPT_QUEUE_GET_CONFIG_REQUEST = 20
+OFPT_QUEUE_GET_CONFIG_REPLY = 21
+
+ofp_type_map = {
+ 0: 'OFPT_HELLO',
+ 1: 'OFPT_ERROR',
+ 2: 'OFPT_ECHO_REQUEST',
+ 3: 'OFPT_ECHO_REPLY',
+ 4: 'OFPT_VENDOR',
+ 5: 'OFPT_FEATURES_REQUEST',
+ 6: 'OFPT_FEATURES_REPLY',
+ 7: 'OFPT_GET_CONFIG_REQUEST',
+ 8: 'OFPT_GET_CONFIG_REPLY',
+ 9: 'OFPT_SET_CONFIG',
+ 10: 'OFPT_PACKET_IN',
+ 11: 'OFPT_FLOW_REMOVED',
+ 12: 'OFPT_PORT_STATUS',
+ 13: 'OFPT_PACKET_OUT',
+ 14: 'OFPT_FLOW_MOD',
+ 15: 'OFPT_PORT_MOD',
+ 16: 'OFPT_STATS_REQUEST',
+ 17: 'OFPT_STATS_REPLY',
+ 18: 'OFPT_BARRIER_REQUEST',
+ 19: 'OFPT_BARRIER_REPLY',
+ 20: 'OFPT_QUEUE_GET_CONFIG_REQUEST',
+ 21: 'OFPT_QUEUE_GET_CONFIG_REPLY',
+}
+
diff --git a/src/python/loxi/of10/message.py b/src/python/loxi/of10/message.py
new file mode 100644
index 0000000..d80dac3
--- /dev/null
+++ b/src/python/loxi/of10/message.py
@@ -0,0 +1,5098 @@
+#
+# Copyright 2012, 2013, Big Switch Networks, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+# Automatically generated by LOXI from template message.py
+# Do not modify
+
+import struct
+import loxi
+import const
+import common
+import action # for unpack_list
+import util
+
+class Message(object):
+ version = const.OFP_VERSION
+ type = None # override in subclass
+ xid = None
+
+class aggregate_stats_reply(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_STATS_REPLY
+ stats_type = const.OFPST_AGGREGATE
+
+ def __init__(self, xid=None, flags=None, packet_count=None, byte_count=None, flow_count=None, pad=None):
+ self.xid = xid
+ if flags != None:
+ self.flags = flags
+ else:
+ self.flags = 0
+ if packet_count != None:
+ self.packet_count = packet_count
+ else:
+ self.packet_count = 0
+ if byte_count != None:
+ self.byte_count = byte_count
+ else:
+ self.byte_count = 0
+ if flow_count != None:
+ self.flow_count = flow_count
+ else:
+ self.flow_count = 0
+ if pad != None:
+ self.pad = pad
+ else:
+ self.pad = [0,0,0,0]
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(struct.pack("!H", self.stats_type))
+ packed.append(struct.pack("!H", self.flags))
+ packed.append(struct.pack("!Q", self.packet_count))
+ packed.append(struct.pack("!Q", self.byte_count))
+ packed.append(struct.pack("!L", self.flow_count))
+ packed.append(struct.pack("!4B", *self.pad))
+ 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")
+ obj = aggregate_stats_reply()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_STATS_REPLY)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 36: raise loxi.ProtocolError("aggregate_stats_reply length is %d, should be 36" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ stats_type = struct.unpack_from('!H', buf, 8)[0]
+ assert(stats_type == const.OFPST_AGGREGATE)
+ obj.flags = struct.unpack_from('!H', buf, 10)[0]
+ obj.packet_count = struct.unpack_from('!Q', buf, 12)[0]
+ obj.byte_count = struct.unpack_from('!Q', buf, 20)[0]
+ obj.flow_count = struct.unpack_from('!L', buf, 28)[0]
+ obj.pad = list(struct.unpack_from('!4B', buf, 32))
+ 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.packet_count != other.packet_count: return False
+ if self.byte_count != other.byte_count: return False
+ if self.flow_count != other.flow_count: return False
+ if self.pad != other.pad: 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("flags = ");
+ q.text("%#x" % self.flags)
+ q.text(","); q.breakable()
+ q.text("packet_count = ");
+ q.text("%#x" % self.packet_count)
+ q.text(","); q.breakable()
+ q.text("byte_count = ");
+ q.text("%#x" % self.byte_count)
+ q.text(","); q.breakable()
+ q.text("flow_count = ");
+ q.text("%#x" % self.flow_count)
+ q.text(","); q.breakable()
+ q.text("pad = ");
+ q.pp(self.pad)
+ q.breakable()
+ q.text('}')
+
+class aggregate_stats_request(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_STATS_REQUEST
+ stats_type = const.OFPST_AGGREGATE
+
+ def __init__(self, xid=None, flags=None, match=None, table_id=None, pad=None, out_port=None):
+ self.xid = xid
+ if flags != None:
+ self.flags = flags
+ else:
+ self.flags = 0
+ if match != None:
+ self.match = match
+ else:
+ self.match = common.match()
+ if table_id != None:
+ self.table_id = table_id
+ else:
+ self.table_id = 0
+ if pad != None:
+ self.pad = pad
+ else:
+ self.pad = 0
+ if out_port != None:
+ self.out_port = out_port
+ else:
+ self.out_port = 0
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(struct.pack("!H", self.stats_type))
+ packed.append(struct.pack("!H", self.flags))
+ packed.append(self.match.pack())
+ packed.append(struct.pack("!B", self.table_id))
+ packed.append(struct.pack("!B", self.pad))
+ packed.append(struct.pack("!H", self.out_port))
+ 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")
+ obj = aggregate_stats_request()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_STATS_REQUEST)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 56: raise loxi.ProtocolError("aggregate_stats_request length is %d, should be 56" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ stats_type = struct.unpack_from('!H', buf, 8)[0]
+ assert(stats_type == const.OFPST_AGGREGATE)
+ obj.flags = struct.unpack_from('!H', buf, 10)[0]
+ obj.match = common.match.unpack(buffer(buf, 12))
+ obj.table_id = struct.unpack_from('!B', buf, 52)[0]
+ obj.pad = struct.unpack_from('!B', buf, 53)[0]
+ obj.out_port = struct.unpack_from('!H', buf, 54)[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
+ if self.flags != other.flags: return False
+ if self.match != other.match: return False
+ if self.table_id != other.table_id: return False
+ if self.pad != other.pad: return False
+ if self.out_port != other.out_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("aggregate_stats_request {")
+ with q.group():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("flags = ");
+ q.text("%#x" % self.flags)
+ q.text(","); q.breakable()
+ q.text("match = ");
+ q.pp(self.match)
+ q.text(","); q.breakable()
+ q.text("table_id = ");
+ q.text("%#x" % self.table_id)
+ q.text(","); q.breakable()
+ q.text("pad = ");
+ q.text("%#x" % self.pad)
+ q.text(","); q.breakable()
+ q.text("out_port = ");
+ q.text(util.pretty_port(self.out_port))
+ q.breakable()
+ q.text('}')
+
+class barrier_reply(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_BARRIER_REPLY
+
+ def __init__(self, xid=None):
+ self.xid = xid
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ 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")
+ obj = barrier_reply()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_BARRIER_REPLY)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 8: raise loxi.ProtocolError("barrier_reply length is %d, should be 8" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[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():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.breakable()
+ q.text('}')
+
+class barrier_request(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_BARRIER_REQUEST
+
+ def __init__(self, xid=None):
+ self.xid = xid
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ 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")
+ obj = barrier_request()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_BARRIER_REQUEST)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 8: raise loxi.ProtocolError("barrier_request length is %d, should be 8" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[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():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.breakable()
+ q.text('}')
+
+class bsn_get_interfaces_reply(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_VENDOR
+ experimenter = 0x5c16c7
+ subtype = 10
+
+ def __init__(self, xid=None, interfaces=None):
+ self.xid = xid
+ if interfaces != None:
+ self.interfaces = interfaces
+ else:
+ self.interfaces = []
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(struct.pack("!L", self.experimenter))
+ packed.append(struct.pack("!L", self.subtype))
+ packed.append("".join([x.pack() for x in 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")
+ obj = bsn_get_interfaces_reply()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_VENDOR)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length < 16: raise loxi.ProtocolError("bsn_get_interfaces_reply length is %d, should be at least 16" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ experimenter = struct.unpack_from('!L', buf, 8)[0]
+ assert(experimenter == 0x5c16c7)
+ subtype = struct.unpack_from('!L', buf, 12)[0]
+ assert(subtype == 10)
+ obj.interfaces = util.unpack_array(common.bsn_interface.unpack, 32, buffer(buf, 16))
+ 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.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():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("interfaces = ");
+ q.pp(self.interfaces)
+ q.breakable()
+ q.text('}')
+
+class bsn_get_interfaces_request(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_VENDOR
+ experimenter = 0x5c16c7
+ subtype = 9
+
+ def __init__(self, xid=None):
+ self.xid = xid
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(struct.pack("!L", self.experimenter))
+ packed.append(struct.pack("!L", self.subtype))
+ 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")
+ obj = bsn_get_interfaces_request()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_VENDOR)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 16: raise loxi.ProtocolError("bsn_get_interfaces_request length is %d, should be 16" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ experimenter = struct.unpack_from('!L', buf, 8)[0]
+ assert(experimenter == 0x5c16c7)
+ subtype = struct.unpack_from('!L', buf, 12)[0]
+ assert(subtype == 9)
+ 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("bsn_get_interfaces_request {")
+ with q.group():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.breakable()
+ q.text('}')
+
+class bsn_get_ip_mask_reply(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_VENDOR
+ experimenter = 0x5c16c7
+ subtype = 2
+
+ def __init__(self, xid=None, index=None, pad=None, mask=None):
+ self.xid = xid
+ if index != None:
+ self.index = index
+ else:
+ self.index = 0
+ if pad != None:
+ self.pad = pad
+ else:
+ self.pad = [0,0,0]
+ if mask != None:
+ self.mask = mask
+ else:
+ self.mask = 0
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(struct.pack("!L", self.experimenter))
+ packed.append(struct.pack("!L", self.subtype))
+ packed.append(struct.pack("!B", self.index))
+ packed.append(struct.pack("!3B", *self.pad))
+ packed.append(struct.pack("!L", self.mask))
+ 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")
+ obj = bsn_get_ip_mask_reply()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_VENDOR)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 24: raise loxi.ProtocolError("bsn_get_ip_mask_reply length is %d, should be 24" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ experimenter = struct.unpack_from('!L', buf, 8)[0]
+ assert(experimenter == 0x5c16c7)
+ subtype = struct.unpack_from('!L', buf, 12)[0]
+ assert(subtype == 2)
+ obj.index = struct.unpack_from('!B', buf, 16)[0]
+ obj.pad = list(struct.unpack_from('!3B', buf, 17))
+ obj.mask = struct.unpack_from('!L', buf, 20)[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
+ if self.index != other.index: return False
+ if self.pad != other.pad: return False
+ if self.mask != other.mask: 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_ip_mask_reply {")
+ with q.group():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("index = ");
+ q.text("%#x" % self.index)
+ q.text(","); q.breakable()
+ q.text("pad = ");
+ q.pp(self.pad)
+ q.text(","); q.breakable()
+ q.text("mask = ");
+ q.text("%#x" % self.mask)
+ q.breakable()
+ q.text('}')
+
+class bsn_get_ip_mask_request(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_VENDOR
+ experimenter = 0x5c16c7
+ subtype = 1
+
+ def __init__(self, xid=None, index=None, pad=None):
+ self.xid = xid
+ if index != None:
+ self.index = index
+ else:
+ self.index = 0
+ if pad != None:
+ self.pad = pad
+ else:
+ self.pad = [0,0,0,0,0,0,0]
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(struct.pack("!L", self.experimenter))
+ packed.append(struct.pack("!L", self.subtype))
+ packed.append(struct.pack("!B", self.index))
+ packed.append(struct.pack("!7B", *self.pad))
+ 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")
+ obj = bsn_get_ip_mask_request()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_VENDOR)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 24: raise loxi.ProtocolError("bsn_get_ip_mask_request length is %d, should be 24" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ experimenter = struct.unpack_from('!L', buf, 8)[0]
+ assert(experimenter == 0x5c16c7)
+ subtype = struct.unpack_from('!L', buf, 12)[0]
+ assert(subtype == 1)
+ obj.index = struct.unpack_from('!B', buf, 16)[0]
+ obj.pad = list(struct.unpack_from('!7B', buf, 17))
+ 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.index != other.index: return False
+ if self.pad != other.pad: 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_ip_mask_request {")
+ with q.group():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("index = ");
+ q.text("%#x" % self.index)
+ q.text(","); q.breakable()
+ q.text("pad = ");
+ q.pp(self.pad)
+ q.breakable()
+ q.text('}')
+
+class bsn_get_mirroring_reply(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_VENDOR
+ experimenter = 0x5c16c7
+ subtype = 5
+
+ def __init__(self, xid=None, report_mirror_ports=None, pad=None):
+ self.xid = xid
+ if report_mirror_ports != None:
+ self.report_mirror_ports = report_mirror_ports
+ else:
+ self.report_mirror_ports = 0
+ if pad != None:
+ self.pad = pad
+ else:
+ self.pad = [0,0,0]
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(struct.pack("!L", self.experimenter))
+ packed.append(struct.pack("!L", self.subtype))
+ packed.append(struct.pack("!B", self.report_mirror_ports))
+ packed.append(struct.pack("!3B", *self.pad))
+ 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")
+ obj = bsn_get_mirroring_reply()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_VENDOR)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 20: raise loxi.ProtocolError("bsn_get_mirroring_reply length is %d, should be 20" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ experimenter = struct.unpack_from('!L', buf, 8)[0]
+ assert(experimenter == 0x5c16c7)
+ subtype = struct.unpack_from('!L', buf, 12)[0]
+ assert(subtype == 5)
+ obj.report_mirror_ports = struct.unpack_from('!B', buf, 16)[0]
+ obj.pad = list(struct.unpack_from('!3B', buf, 17))
+ 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.report_mirror_ports != other.report_mirror_ports: return False
+ if self.pad != other.pad: 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("report_mirror_ports = ");
+ q.text("%#x" % self.report_mirror_ports)
+ q.text(","); q.breakable()
+ q.text("pad = ");
+ q.pp(self.pad)
+ q.breakable()
+ q.text('}')
+
+class bsn_get_mirroring_request(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_VENDOR
+ experimenter = 0x5c16c7
+ subtype = 4
+
+ def __init__(self, xid=None, report_mirror_ports=None, pad=None):
+ self.xid = xid
+ if report_mirror_ports != None:
+ self.report_mirror_ports = report_mirror_ports
+ else:
+ self.report_mirror_ports = 0
+ if pad != None:
+ self.pad = pad
+ else:
+ self.pad = [0,0,0]
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(struct.pack("!L", self.experimenter))
+ packed.append(struct.pack("!L", self.subtype))
+ packed.append(struct.pack("!B", self.report_mirror_ports))
+ packed.append(struct.pack("!3B", *self.pad))
+ 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")
+ obj = bsn_get_mirroring_request()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_VENDOR)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 20: raise loxi.ProtocolError("bsn_get_mirroring_request length is %d, should be 20" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ experimenter = struct.unpack_from('!L', buf, 8)[0]
+ assert(experimenter == 0x5c16c7)
+ subtype = struct.unpack_from('!L', buf, 12)[0]
+ assert(subtype == 4)
+ obj.report_mirror_ports = struct.unpack_from('!B', buf, 16)[0]
+ obj.pad = list(struct.unpack_from('!3B', buf, 17))
+ 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.report_mirror_ports != other.report_mirror_ports: return False
+ if self.pad != other.pad: 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("report_mirror_ports = ");
+ q.text("%#x" % self.report_mirror_ports)
+ q.text(","); q.breakable()
+ q.text("pad = ");
+ q.pp(self.pad)
+ q.breakable()
+ q.text('}')
+
+class bsn_set_ip_mask(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_VENDOR
+ experimenter = 0x5c16c7
+ subtype = 0
+
+ def __init__(self, xid=None, index=None, pad=None, mask=None):
+ self.xid = xid
+ if index != None:
+ self.index = index
+ else:
+ self.index = 0
+ if pad != None:
+ self.pad = pad
+ else:
+ self.pad = [0,0,0]
+ if mask != None:
+ self.mask = mask
+ else:
+ self.mask = 0
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(struct.pack("!L", self.experimenter))
+ packed.append(struct.pack("!L", self.subtype))
+ packed.append(struct.pack("!B", self.index))
+ packed.append(struct.pack("!3B", *self.pad))
+ packed.append(struct.pack("!L", self.mask))
+ 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")
+ obj = bsn_set_ip_mask()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_VENDOR)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 24: raise loxi.ProtocolError("bsn_set_ip_mask length is %d, should be 24" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ experimenter = struct.unpack_from('!L', buf, 8)[0]
+ assert(experimenter == 0x5c16c7)
+ subtype = struct.unpack_from('!L', buf, 12)[0]
+ assert(subtype == 0)
+ obj.index = struct.unpack_from('!B', buf, 16)[0]
+ obj.pad = list(struct.unpack_from('!3B', buf, 17))
+ obj.mask = struct.unpack_from('!L', buf, 20)[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
+ if self.index != other.index: return False
+ if self.pad != other.pad: return False
+ if self.mask != other.mask: 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_ip_mask {")
+ with q.group():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("index = ");
+ q.text("%#x" % self.index)
+ q.text(","); q.breakable()
+ q.text("pad = ");
+ q.pp(self.pad)
+ q.text(","); q.breakable()
+ q.text("mask = ");
+ q.text("%#x" % self.mask)
+ q.breakable()
+ q.text('}')
+
+class bsn_set_mirroring(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_VENDOR
+ experimenter = 0x5c16c7
+ subtype = 3
+
+ def __init__(self, xid=None, report_mirror_ports=None, pad=None):
+ self.xid = xid
+ if report_mirror_ports != None:
+ self.report_mirror_ports = report_mirror_ports
+ else:
+ self.report_mirror_ports = 0
+ if pad != None:
+ self.pad = pad
+ else:
+ self.pad = [0,0,0]
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(struct.pack("!L", self.experimenter))
+ packed.append(struct.pack("!L", self.subtype))
+ packed.append(struct.pack("!B", self.report_mirror_ports))
+ packed.append(struct.pack("!3B", *self.pad))
+ 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")
+ obj = bsn_set_mirroring()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_VENDOR)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 20: raise loxi.ProtocolError("bsn_set_mirroring length is %d, should be 20" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ experimenter = struct.unpack_from('!L', buf, 8)[0]
+ assert(experimenter == 0x5c16c7)
+ subtype = struct.unpack_from('!L', buf, 12)[0]
+ assert(subtype == 3)
+ obj.report_mirror_ports = struct.unpack_from('!B', buf, 16)[0]
+ obj.pad = list(struct.unpack_from('!3B', buf, 17))
+ 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.report_mirror_ports != other.report_mirror_ports: return False
+ if self.pad != other.pad: 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("report_mirror_ports = ");
+ q.text("%#x" % self.report_mirror_ports)
+ q.text(","); q.breakable()
+ q.text("pad = ");
+ q.pp(self.pad)
+ q.breakable()
+ q.text('}')
+
+class bsn_shell_command(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_VENDOR
+ experimenter = 0x5c16c7
+ subtype = 6
+
+ def __init__(self, xid=None, service=None, data=None):
+ self.xid = xid
+ if service != None:
+ self.service = service
+ else:
+ self.service = 0
+ if data != None:
+ self.data = data
+ else:
+ self.data = ""
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(struct.pack("!L", self.experimenter))
+ packed.append(struct.pack("!L", self.subtype))
+ packed.append(struct.pack("!L", self.service))
+ packed.append(self.data)
+ 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")
+ obj = bsn_shell_command()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_VENDOR)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length < 20: raise loxi.ProtocolError("bsn_shell_command length is %d, should be at least 20" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ experimenter = struct.unpack_from('!L', buf, 8)[0]
+ assert(experimenter == 0x5c16c7)
+ subtype = struct.unpack_from('!L', buf, 12)[0]
+ assert(subtype == 6)
+ obj.service = struct.unpack_from('!L', buf, 16)[0]
+ obj.data = buf[20:]
+ 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.service != other.service: 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("bsn_shell_command {")
+ with q.group():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("service = ");
+ q.text("%#x" % self.service)
+ q.text(","); q.breakable()
+ q.text("data = ");
+ q.pp(self.data)
+ q.breakable()
+ q.text('}')
+
+class bsn_shell_output(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_VENDOR
+ experimenter = 0x5c16c7
+ subtype = 7
+
+ def __init__(self, xid=None, data=None):
+ self.xid = xid
+ if data != None:
+ self.data = data
+ else:
+ self.data = ""
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(struct.pack("!L", self.experimenter))
+ packed.append(struct.pack("!L", self.subtype))
+ packed.append(self.data)
+ 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")
+ obj = bsn_shell_output()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_VENDOR)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length < 16: raise loxi.ProtocolError("bsn_shell_output length is %d, should be at least 16" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ experimenter = struct.unpack_from('!L', buf, 8)[0]
+ assert(experimenter == 0x5c16c7)
+ subtype = struct.unpack_from('!L', buf, 12)[0]
+ assert(subtype == 7)
+ obj.data = buf[16:]
+ 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("bsn_shell_output {")
+ with q.group():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("data = ");
+ q.pp(self.data)
+ q.breakable()
+ q.text('}')
+
+class bsn_shell_status(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_VENDOR
+ experimenter = 0x5c16c7
+ subtype = 8
+
+ def __init__(self, xid=None, status=None):
+ self.xid = xid
+ if status != None:
+ self.status = status
+ else:
+ self.status = 0
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(struct.pack("!L", self.experimenter))
+ packed.append(struct.pack("!L", self.subtype))
+ packed.append(struct.pack("!L", self.status))
+ 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")
+ obj = bsn_shell_status()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_VENDOR)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 20: raise loxi.ProtocolError("bsn_shell_status length is %d, should be 20" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ experimenter = struct.unpack_from('!L', buf, 8)[0]
+ assert(experimenter == 0x5c16c7)
+ subtype = struct.unpack_from('!L', buf, 12)[0]
+ assert(subtype == 8)
+ obj.status = struct.unpack_from('!L', buf, 16)[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
+ 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_shell_status {")
+ with q.group():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("status = ");
+ q.text("%#x" % self.status)
+ q.breakable()
+ q.text('}')
+
+class desc_stats_reply(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_STATS_REPLY
+ stats_type = const.OFPST_DESC
+
+ 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 flags != None:
+ self.flags = flags
+ else:
+ self.flags = 0
+ if mfr_desc != None:
+ self.mfr_desc = mfr_desc
+ else:
+ self.mfr_desc = ""
+ if hw_desc != None:
+ self.hw_desc = hw_desc
+ else:
+ self.hw_desc = ""
+ if sw_desc != None:
+ self.sw_desc = sw_desc
+ else:
+ self.sw_desc = ""
+ if serial_num != None:
+ self.serial_num = serial_num
+ else:
+ self.serial_num = ""
+ if dp_desc != None:
+ self.dp_desc = dp_desc
+ else:
+ self.dp_desc = ""
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(struct.pack("!H", self.stats_type))
+ packed.append(struct.pack("!H", self.flags))
+ packed.append(struct.pack("!256s", self.mfr_desc))
+ packed.append(struct.pack("!256s", self.hw_desc))
+ packed.append(struct.pack("!256s", self.sw_desc))
+ packed.append(struct.pack("!32s", self.serial_num))
+ packed.append(struct.pack("!256s", self.dp_desc))
+ 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")
+ obj = desc_stats_reply()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_STATS_REPLY)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 1068: raise loxi.ProtocolError("desc_stats_reply length is %d, should be 1068" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ stats_type = struct.unpack_from('!H', buf, 8)[0]
+ assert(stats_type == const.OFPST_DESC)
+ obj.flags = struct.unpack_from('!H', buf, 10)[0]
+ obj.mfr_desc = str(buffer(buf, 12, 256)).rstrip("\x00")
+ obj.hw_desc = str(buffer(buf, 268, 256)).rstrip("\x00")
+ obj.sw_desc = str(buffer(buf, 524, 256)).rstrip("\x00")
+ obj.serial_num = str(buffer(buf, 780, 32)).rstrip("\x00")
+ obj.dp_desc = str(buffer(buf, 812, 256)).rstrip("\x00")
+ 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.mfr_desc != other.mfr_desc: return False
+ if self.hw_desc != other.hw_desc: return False
+ if self.sw_desc != other.sw_desc: return False
+ if self.serial_num != other.serial_num: return False
+ 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("flags = ");
+ q.text("%#x" % self.flags)
+ q.text(","); q.breakable()
+ q.text("mfr_desc = ");
+ q.pp(self.mfr_desc)
+ q.text(","); q.breakable()
+ q.text("hw_desc = ");
+ q.pp(self.hw_desc)
+ q.text(","); q.breakable()
+ q.text("sw_desc = ");
+ q.pp(self.sw_desc)
+ q.text(","); q.breakable()
+ q.text("serial_num = ");
+ q.pp(self.serial_num)
+ q.text(","); q.breakable()
+ q.text("dp_desc = ");
+ q.pp(self.dp_desc)
+ q.breakable()
+ q.text('}')
+
+class desc_stats_request(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_STATS_REQUEST
+ stats_type = const.OFPST_DESC
+
+ def __init__(self, xid=None, flags=None):
+ self.xid = xid
+ if flags != None:
+ self.flags = flags
+ else:
+ self.flags = 0
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(struct.pack("!H", self.stats_type))
+ packed.append(struct.pack("!H", self.flags))
+ 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")
+ obj = desc_stats_request()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_STATS_REQUEST)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 12: raise loxi.ProtocolError("desc_stats_request length is %d, should be 12" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ stats_type = struct.unpack_from('!H', buf, 8)[0]
+ assert(stats_type == const.OFPST_DESC)
+ obj.flags = struct.unpack_from('!H', buf, 10)[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
+ 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("flags = ");
+ q.text("%#x" % self.flags)
+ q.breakable()
+ q.text('}')
+
+class echo_reply(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_ECHO_REPLY
+
+ def __init__(self, xid=None, data=None):
+ self.xid = xid
+ if data != None:
+ self.data = data
+ else:
+ self.data = ""
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(self.data)
+ 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")
+ obj = echo_reply()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_ECHO_REPLY)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length < 8: raise loxi.ProtocolError("echo_reply length is %d, should be at least 8" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ obj.data = buf[8:]
+ 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("data = ");
+ q.pp(self.data)
+ q.breakable()
+ q.text('}')
+
+class echo_request(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_ECHO_REQUEST
+
+ def __init__(self, xid=None, data=None):
+ self.xid = xid
+ if data != None:
+ self.data = data
+ else:
+ self.data = ""
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(self.data)
+ 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")
+ obj = echo_request()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_ECHO_REQUEST)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length < 8: raise loxi.ProtocolError("echo_request length is %d, should be at least 8" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ obj.data = buf[8:]
+ 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("data = ");
+ q.pp(self.data)
+ q.breakable()
+ q.text('}')
+
+class error_msg(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_ERROR
+
+ def __init__(self, xid=None, err_type=None, code=None, data=None):
+ self.xid = xid
+ if err_type != None:
+ self.err_type = err_type
+ else:
+ self.err_type = 0
+ if code != None:
+ self.code = code
+ else:
+ self.code = 0
+ if data != None:
+ self.data = data
+ else:
+ self.data = ""
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(struct.pack("!H", self.err_type))
+ packed.append(struct.pack("!H", self.code))
+ packed.append(self.data)
+ 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")
+ obj = error_msg()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_ERROR)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length < 12: raise loxi.ProtocolError("error_msg length is %d, should be at least 12" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ obj.err_type = struct.unpack_from('!H', buf, 8)[0]
+ obj.code = struct.unpack_from('!H', buf, 10)[0]
+ obj.data = buf[12:]
+ 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.err_type != other.err_type: 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("error_msg {")
+ with q.group():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("err_type = ");
+ q.text("%#x" % self.err_type)
+ q.text(","); q.breakable()
+ q.text("code = ");
+ q.text("%#x" % self.code)
+ q.text(","); q.breakable()
+ q.text("data = ");
+ q.pp(self.data)
+ q.breakable()
+ q.text('}')
+
+class experimenter_stats_reply(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_STATS_REPLY
+ stats_type = const.OFPST_VENDOR
+
+ def __init__(self, xid=None, flags=None, experimenter=None, data=None):
+ self.xid = xid
+ if flags != None:
+ self.flags = flags
+ else:
+ self.flags = 0
+ if experimenter != None:
+ self.experimenter = experimenter
+ else:
+ self.experimenter = 0
+ if data != None:
+ self.data = data
+ else:
+ self.data = ""
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(struct.pack("!H", self.stats_type))
+ packed.append(struct.pack("!H", self.flags))
+ packed.append(struct.pack("!L", self.experimenter))
+ packed.append(self.data)
+ 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")
+ obj = experimenter_stats_reply()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_STATS_REPLY)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length < 16: raise loxi.ProtocolError("experimenter_stats_reply length is %d, should be at least 16" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ stats_type = struct.unpack_from('!H', buf, 8)[0]
+ assert(stats_type == const.OFPST_VENDOR)
+ obj.flags = struct.unpack_from('!H', buf, 10)[0]
+ obj.experimenter = struct.unpack_from('!L', buf, 12)[0]
+ obj.data = buf[16:]
+ 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.experimenter != other.experimenter: 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("experimenter_stats_reply {")
+ with q.group():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("flags = ");
+ q.text("%#x" % self.flags)
+ q.text(","); q.breakable()
+ q.text("experimenter = ");
+ q.text("%#x" % self.experimenter)
+ q.text(","); q.breakable()
+ q.text("data = ");
+ q.pp(self.data)
+ q.breakable()
+ q.text('}')
+
+class experimenter_stats_request(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_STATS_REQUEST
+ stats_type = const.OFPST_VENDOR
+
+ def __init__(self, xid=None, flags=None, experimenter=None, data=None):
+ self.xid = xid
+ if flags != None:
+ self.flags = flags
+ else:
+ self.flags = 0
+ if experimenter != None:
+ self.experimenter = experimenter
+ else:
+ self.experimenter = 0
+ if data != None:
+ self.data = data
+ else:
+ self.data = ""
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(struct.pack("!H", self.stats_type))
+ packed.append(struct.pack("!H", self.flags))
+ packed.append(struct.pack("!L", self.experimenter))
+ packed.append(self.data)
+ 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")
+ obj = experimenter_stats_request()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_STATS_REQUEST)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length < 16: raise loxi.ProtocolError("experimenter_stats_request length is %d, should be at least 16" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ stats_type = struct.unpack_from('!H', buf, 8)[0]
+ assert(stats_type == const.OFPST_VENDOR)
+ obj.flags = struct.unpack_from('!H', buf, 10)[0]
+ obj.experimenter = struct.unpack_from('!L', buf, 12)[0]
+ obj.data = buf[16:]
+ 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.experimenter != other.experimenter: 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("experimenter_stats_request {")
+ with q.group():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("flags = ");
+ q.text("%#x" % self.flags)
+ q.text(","); q.breakable()
+ q.text("experimenter = ");
+ q.text("%#x" % self.experimenter)
+ q.text(","); q.breakable()
+ q.text("data = ");
+ q.pp(self.data)
+ q.breakable()
+ q.text('}')
+
+class features_reply(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_FEATURES_REPLY
+
+ def __init__(self, xid=None, datapath_id=None, n_buffers=None, n_tables=None, pad=None, capabilities=None, actions=None, ports=None):
+ self.xid = xid
+ if datapath_id != None:
+ self.datapath_id = datapath_id
+ else:
+ self.datapath_id = 0
+ if n_buffers != None:
+ self.n_buffers = n_buffers
+ else:
+ self.n_buffers = 0
+ if n_tables != None:
+ self.n_tables = n_tables
+ else:
+ self.n_tables = 0
+ if pad != None:
+ self.pad = pad
+ else:
+ self.pad = [0,0,0]
+ if capabilities != None:
+ self.capabilities = capabilities
+ else:
+ self.capabilities = 0
+ if actions != None:
+ self.actions = actions
+ else:
+ self.actions = 0
+ if ports != None:
+ self.ports = ports
+ else:
+ self.ports = []
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(struct.pack("!Q", self.datapath_id))
+ packed.append(struct.pack("!L", self.n_buffers))
+ packed.append(struct.pack("!B", self.n_tables))
+ packed.append(struct.pack("!3B", *self.pad))
+ packed.append(struct.pack("!L", self.capabilities))
+ packed.append(struct.pack("!L", self.actions))
+ packed.append("".join([x.pack() for x in 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")
+ obj = features_reply()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_FEATURES_REPLY)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length < 32: raise loxi.ProtocolError("features_reply length is %d, should be at least 32" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ obj.datapath_id = struct.unpack_from('!Q', buf, 8)[0]
+ obj.n_buffers = struct.unpack_from('!L', buf, 16)[0]
+ obj.n_tables = struct.unpack_from('!B', buf, 20)[0]
+ obj.pad = list(struct.unpack_from('!3B', buf, 21))
+ obj.capabilities = struct.unpack_from('!L', buf, 24)[0]
+ obj.actions = struct.unpack_from('!L', buf, 28)[0]
+ obj.ports = util.unpack_array(common.port_desc.unpack, 48, buffer(buf, 32))
+ 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.datapath_id != other.datapath_id: return False
+ if self.n_buffers != other.n_buffers: return False
+ if self.n_tables != other.n_tables: return False
+ if self.pad != other.pad: return False
+ if self.capabilities != other.capabilities: return False
+ if self.actions != other.actions: return False
+ 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("datapath_id = ");
+ q.text("%#x" % self.datapath_id)
+ q.text(","); q.breakable()
+ q.text("n_buffers = ");
+ q.text("%#x" % self.n_buffers)
+ q.text(","); q.breakable()
+ q.text("n_tables = ");
+ q.text("%#x" % self.n_tables)
+ q.text(","); q.breakable()
+ q.text("pad = ");
+ q.pp(self.pad)
+ q.text(","); q.breakable()
+ q.text("capabilities = ");
+ q.text("%#x" % self.capabilities)
+ q.text(","); q.breakable()
+ q.text("actions = ");
+ q.text("%#x" % self.actions)
+ q.text(","); q.breakable()
+ q.text("ports = ");
+ q.pp(self.ports)
+ q.breakable()
+ q.text('}')
+
+class features_request(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_FEATURES_REQUEST
+
+ def __init__(self, xid=None):
+ self.xid = xid
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ 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")
+ obj = features_request()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_FEATURES_REQUEST)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 8: raise loxi.ProtocolError("features_request length is %d, should be 8" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[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():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.breakable()
+ q.text('}')
+
+class flow_add(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_FLOW_MOD
+ _command = const.OFPFC_ADD
+
+ def __init__(self, xid=None, match=None, cookie=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, flags=None, actions=None):
+ self.xid = xid
+ if match != None:
+ self.match = match
+ else:
+ self.match = common.match()
+ if cookie != None:
+ self.cookie = cookie
+ else:
+ self.cookie = 0
+ if idle_timeout != None:
+ self.idle_timeout = idle_timeout
+ else:
+ self.idle_timeout = 0
+ if hard_timeout != None:
+ self.hard_timeout = hard_timeout
+ else:
+ self.hard_timeout = 0
+ if priority != None:
+ self.priority = priority
+ else:
+ self.priority = 0
+ if buffer_id != None:
+ self.buffer_id = buffer_id
+ else:
+ self.buffer_id = 0
+ if out_port != None:
+ self.out_port = out_port
+ else:
+ self.out_port = 0
+ if flags != None:
+ self.flags = flags
+ else:
+ self.flags = 0
+ if actions != None:
+ self.actions = actions
+ else:
+ self.actions = []
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(self.match.pack())
+ packed.append(struct.pack("!Q", self.cookie))
+ packed.append(struct.pack("!H", self._command))
+ packed.append(struct.pack("!H", self.idle_timeout))
+ packed.append(struct.pack("!H", self.hard_timeout))
+ packed.append(struct.pack("!H", self.priority))
+ packed.append(struct.pack("!L", self.buffer_id))
+ packed.append(struct.pack("!H", self.out_port))
+ packed.append(struct.pack("!H", self.flags))
+ packed.append("".join([x.pack() for x in self.actions]))
+ 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")
+ obj = flow_add()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_FLOW_MOD)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length < 72: raise loxi.ProtocolError("flow_add length is %d, should be at least 72" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ obj.match = common.match.unpack(buffer(buf, 8))
+ obj.cookie = struct.unpack_from('!Q', buf, 48)[0]
+ _command = struct.unpack_from('!H', buf, 56)[0]
+ assert(_command == const.OFPFC_ADD)
+ obj.idle_timeout = struct.unpack_from('!H', buf, 58)[0]
+ obj.hard_timeout = struct.unpack_from('!H', buf, 60)[0]
+ obj.priority = struct.unpack_from('!H', buf, 62)[0]
+ obj.buffer_id = struct.unpack_from('!L', buf, 64)[0]
+ obj.out_port = struct.unpack_from('!H', buf, 68)[0]
+ obj.flags = struct.unpack_from('!H', buf, 70)[0]
+ obj.actions = action.unpack_list(buffer(buf, 72))
+ 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.match != other.match: return False
+ if self.cookie != other.cookie: return False
+ if self.idle_timeout != other.idle_timeout: return False
+ if self.hard_timeout != other.hard_timeout: return False
+ if self.priority != other.priority: return False
+ if self.buffer_id != other.buffer_id: return False
+ if self.out_port != other.out_port: return False
+ if self.flags != other.flags: return False
+ if self.actions != other.actions: 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("match = ");
+ q.pp(self.match)
+ q.text(","); q.breakable()
+ q.text("cookie = ");
+ q.text("%#x" % self.cookie)
+ q.text(","); q.breakable()
+ q.text("idle_timeout = ");
+ q.text("%#x" % self.idle_timeout)
+ q.text(","); q.breakable()
+ q.text("hard_timeout = ");
+ q.text("%#x" % self.hard_timeout)
+ q.text(","); q.breakable()
+ q.text("priority = ");
+ q.text("%#x" % self.priority)
+ q.text(","); q.breakable()
+ q.text("buffer_id = ");
+ q.text("%#x" % self.buffer_id)
+ q.text(","); q.breakable()
+ q.text("out_port = ");
+ q.text(util.pretty_port(self.out_port))
+ q.text(","); q.breakable()
+ q.text("flags = ");
+ q.text("%#x" % self.flags)
+ q.text(","); q.breakable()
+ q.text("actions = ");
+ q.pp(self.actions)
+ q.breakable()
+ q.text('}')
+
+class flow_delete(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_FLOW_MOD
+ _command = const.OFPFC_DELETE
+
+ def __init__(self, xid=None, match=None, cookie=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, flags=None, actions=None):
+ self.xid = xid
+ if match != None:
+ self.match = match
+ else:
+ self.match = common.match()
+ if cookie != None:
+ self.cookie = cookie
+ else:
+ self.cookie = 0
+ if idle_timeout != None:
+ self.idle_timeout = idle_timeout
+ else:
+ self.idle_timeout = 0
+ if hard_timeout != None:
+ self.hard_timeout = hard_timeout
+ else:
+ self.hard_timeout = 0
+ if priority != None:
+ self.priority = priority
+ else:
+ self.priority = 0
+ if buffer_id != None:
+ self.buffer_id = buffer_id
+ else:
+ self.buffer_id = 0
+ if out_port != None:
+ self.out_port = out_port
+ else:
+ self.out_port = 0
+ if flags != None:
+ self.flags = flags
+ else:
+ self.flags = 0
+ if actions != None:
+ self.actions = actions
+ else:
+ self.actions = []
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(self.match.pack())
+ packed.append(struct.pack("!Q", self.cookie))
+ packed.append(struct.pack("!H", self._command))
+ packed.append(struct.pack("!H", self.idle_timeout))
+ packed.append(struct.pack("!H", self.hard_timeout))
+ packed.append(struct.pack("!H", self.priority))
+ packed.append(struct.pack("!L", self.buffer_id))
+ packed.append(struct.pack("!H", self.out_port))
+ packed.append(struct.pack("!H", self.flags))
+ packed.append("".join([x.pack() for x in self.actions]))
+ 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")
+ obj = flow_delete()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_FLOW_MOD)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length < 72: raise loxi.ProtocolError("flow_delete length is %d, should be at least 72" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ obj.match = common.match.unpack(buffer(buf, 8))
+ obj.cookie = struct.unpack_from('!Q', buf, 48)[0]
+ _command = struct.unpack_from('!H', buf, 56)[0]
+ assert(_command == const.OFPFC_DELETE)
+ obj.idle_timeout = struct.unpack_from('!H', buf, 58)[0]
+ obj.hard_timeout = struct.unpack_from('!H', buf, 60)[0]
+ obj.priority = struct.unpack_from('!H', buf, 62)[0]
+ obj.buffer_id = struct.unpack_from('!L', buf, 64)[0]
+ obj.out_port = struct.unpack_from('!H', buf, 68)[0]
+ obj.flags = struct.unpack_from('!H', buf, 70)[0]
+ obj.actions = action.unpack_list(buffer(buf, 72))
+ 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.match != other.match: return False
+ if self.cookie != other.cookie: return False
+ if self.idle_timeout != other.idle_timeout: return False
+ if self.hard_timeout != other.hard_timeout: return False
+ if self.priority != other.priority: return False
+ if self.buffer_id != other.buffer_id: return False
+ if self.out_port != other.out_port: return False
+ if self.flags != other.flags: return False
+ if self.actions != other.actions: 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("match = ");
+ q.pp(self.match)
+ q.text(","); q.breakable()
+ q.text("cookie = ");
+ q.text("%#x" % self.cookie)
+ q.text(","); q.breakable()
+ q.text("idle_timeout = ");
+ q.text("%#x" % self.idle_timeout)
+ q.text(","); q.breakable()
+ q.text("hard_timeout = ");
+ q.text("%#x" % self.hard_timeout)
+ q.text(","); q.breakable()
+ q.text("priority = ");
+ q.text("%#x" % self.priority)
+ q.text(","); q.breakable()
+ q.text("buffer_id = ");
+ q.text("%#x" % self.buffer_id)
+ q.text(","); q.breakable()
+ q.text("out_port = ");
+ q.text(util.pretty_port(self.out_port))
+ q.text(","); q.breakable()
+ q.text("flags = ");
+ q.text("%#x" % self.flags)
+ q.text(","); q.breakable()
+ q.text("actions = ");
+ q.pp(self.actions)
+ q.breakable()
+ q.text('}')
+
+class flow_delete_strict(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_FLOW_MOD
+ _command = const.OFPFC_DELETE_STRICT
+
+ def __init__(self, xid=None, match=None, cookie=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, flags=None, actions=None):
+ self.xid = xid
+ if match != None:
+ self.match = match
+ else:
+ self.match = common.match()
+ if cookie != None:
+ self.cookie = cookie
+ else:
+ self.cookie = 0
+ if idle_timeout != None:
+ self.idle_timeout = idle_timeout
+ else:
+ self.idle_timeout = 0
+ if hard_timeout != None:
+ self.hard_timeout = hard_timeout
+ else:
+ self.hard_timeout = 0
+ if priority != None:
+ self.priority = priority
+ else:
+ self.priority = 0
+ if buffer_id != None:
+ self.buffer_id = buffer_id
+ else:
+ self.buffer_id = 0
+ if out_port != None:
+ self.out_port = out_port
+ else:
+ self.out_port = 0
+ if flags != None:
+ self.flags = flags
+ else:
+ self.flags = 0
+ if actions != None:
+ self.actions = actions
+ else:
+ self.actions = []
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(self.match.pack())
+ packed.append(struct.pack("!Q", self.cookie))
+ packed.append(struct.pack("!H", self._command))
+ packed.append(struct.pack("!H", self.idle_timeout))
+ packed.append(struct.pack("!H", self.hard_timeout))
+ packed.append(struct.pack("!H", self.priority))
+ packed.append(struct.pack("!L", self.buffer_id))
+ packed.append(struct.pack("!H", self.out_port))
+ packed.append(struct.pack("!H", self.flags))
+ packed.append("".join([x.pack() for x in self.actions]))
+ 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")
+ obj = flow_delete_strict()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_FLOW_MOD)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length < 72: raise loxi.ProtocolError("flow_delete_strict length is %d, should be at least 72" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ obj.match = common.match.unpack(buffer(buf, 8))
+ obj.cookie = struct.unpack_from('!Q', buf, 48)[0]
+ _command = struct.unpack_from('!H', buf, 56)[0]
+ assert(_command == const.OFPFC_DELETE_STRICT)
+ obj.idle_timeout = struct.unpack_from('!H', buf, 58)[0]
+ obj.hard_timeout = struct.unpack_from('!H', buf, 60)[0]
+ obj.priority = struct.unpack_from('!H', buf, 62)[0]
+ obj.buffer_id = struct.unpack_from('!L', buf, 64)[0]
+ obj.out_port = struct.unpack_from('!H', buf, 68)[0]
+ obj.flags = struct.unpack_from('!H', buf, 70)[0]
+ obj.actions = action.unpack_list(buffer(buf, 72))
+ 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.match != other.match: return False
+ if self.cookie != other.cookie: return False
+ if self.idle_timeout != other.idle_timeout: return False
+ if self.hard_timeout != other.hard_timeout: return False
+ if self.priority != other.priority: return False
+ if self.buffer_id != other.buffer_id: return False
+ if self.out_port != other.out_port: return False
+ if self.flags != other.flags: return False
+ if self.actions != other.actions: 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("match = ");
+ q.pp(self.match)
+ q.text(","); q.breakable()
+ q.text("cookie = ");
+ q.text("%#x" % self.cookie)
+ q.text(","); q.breakable()
+ q.text("idle_timeout = ");
+ q.text("%#x" % self.idle_timeout)
+ q.text(","); q.breakable()
+ q.text("hard_timeout = ");
+ q.text("%#x" % self.hard_timeout)
+ q.text(","); q.breakable()
+ q.text("priority = ");
+ q.text("%#x" % self.priority)
+ q.text(","); q.breakable()
+ q.text("buffer_id = ");
+ q.text("%#x" % self.buffer_id)
+ q.text(","); q.breakable()
+ q.text("out_port = ");
+ q.text(util.pretty_port(self.out_port))
+ q.text(","); q.breakable()
+ q.text("flags = ");
+ q.text("%#x" % self.flags)
+ q.text(","); q.breakable()
+ q.text("actions = ");
+ q.pp(self.actions)
+ q.breakable()
+ q.text('}')
+
+class flow_modify(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_FLOW_MOD
+ _command = const.OFPFC_MODIFY
+
+ def __init__(self, xid=None, match=None, cookie=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, flags=None, actions=None):
+ self.xid = xid
+ if match != None:
+ self.match = match
+ else:
+ self.match = common.match()
+ if cookie != None:
+ self.cookie = cookie
+ else:
+ self.cookie = 0
+ if idle_timeout != None:
+ self.idle_timeout = idle_timeout
+ else:
+ self.idle_timeout = 0
+ if hard_timeout != None:
+ self.hard_timeout = hard_timeout
+ else:
+ self.hard_timeout = 0
+ if priority != None:
+ self.priority = priority
+ else:
+ self.priority = 0
+ if buffer_id != None:
+ self.buffer_id = buffer_id
+ else:
+ self.buffer_id = 0
+ if out_port != None:
+ self.out_port = out_port
+ else:
+ self.out_port = 0
+ if flags != None:
+ self.flags = flags
+ else:
+ self.flags = 0
+ if actions != None:
+ self.actions = actions
+ else:
+ self.actions = []
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(self.match.pack())
+ packed.append(struct.pack("!Q", self.cookie))
+ packed.append(struct.pack("!H", self._command))
+ packed.append(struct.pack("!H", self.idle_timeout))
+ packed.append(struct.pack("!H", self.hard_timeout))
+ packed.append(struct.pack("!H", self.priority))
+ packed.append(struct.pack("!L", self.buffer_id))
+ packed.append(struct.pack("!H", self.out_port))
+ packed.append(struct.pack("!H", self.flags))
+ packed.append("".join([x.pack() for x in self.actions]))
+ 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")
+ obj = flow_modify()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_FLOW_MOD)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length < 72: raise loxi.ProtocolError("flow_modify length is %d, should be at least 72" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ obj.match = common.match.unpack(buffer(buf, 8))
+ obj.cookie = struct.unpack_from('!Q', buf, 48)[0]
+ _command = struct.unpack_from('!H', buf, 56)[0]
+ assert(_command == const.OFPFC_MODIFY)
+ obj.idle_timeout = struct.unpack_from('!H', buf, 58)[0]
+ obj.hard_timeout = struct.unpack_from('!H', buf, 60)[0]
+ obj.priority = struct.unpack_from('!H', buf, 62)[0]
+ obj.buffer_id = struct.unpack_from('!L', buf, 64)[0]
+ obj.out_port = struct.unpack_from('!H', buf, 68)[0]
+ obj.flags = struct.unpack_from('!H', buf, 70)[0]
+ obj.actions = action.unpack_list(buffer(buf, 72))
+ 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.match != other.match: return False
+ if self.cookie != other.cookie: return False
+ if self.idle_timeout != other.idle_timeout: return False
+ if self.hard_timeout != other.hard_timeout: return False
+ if self.priority != other.priority: return False
+ if self.buffer_id != other.buffer_id: return False
+ if self.out_port != other.out_port: return False
+ if self.flags != other.flags: return False
+ if self.actions != other.actions: 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("match = ");
+ q.pp(self.match)
+ q.text(","); q.breakable()
+ q.text("cookie = ");
+ q.text("%#x" % self.cookie)
+ q.text(","); q.breakable()
+ q.text("idle_timeout = ");
+ q.text("%#x" % self.idle_timeout)
+ q.text(","); q.breakable()
+ q.text("hard_timeout = ");
+ q.text("%#x" % self.hard_timeout)
+ q.text(","); q.breakable()
+ q.text("priority = ");
+ q.text("%#x" % self.priority)
+ q.text(","); q.breakable()
+ q.text("buffer_id = ");
+ q.text("%#x" % self.buffer_id)
+ q.text(","); q.breakable()
+ q.text("out_port = ");
+ q.text(util.pretty_port(self.out_port))
+ q.text(","); q.breakable()
+ q.text("flags = ");
+ q.text("%#x" % self.flags)
+ q.text(","); q.breakable()
+ q.text("actions = ");
+ q.pp(self.actions)
+ q.breakable()
+ q.text('}')
+
+class flow_modify_strict(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_FLOW_MOD
+ _command = const.OFPFC_MODIFY_STRICT
+
+ def __init__(self, xid=None, match=None, cookie=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, flags=None, actions=None):
+ self.xid = xid
+ if match != None:
+ self.match = match
+ else:
+ self.match = common.match()
+ if cookie != None:
+ self.cookie = cookie
+ else:
+ self.cookie = 0
+ if idle_timeout != None:
+ self.idle_timeout = idle_timeout
+ else:
+ self.idle_timeout = 0
+ if hard_timeout != None:
+ self.hard_timeout = hard_timeout
+ else:
+ self.hard_timeout = 0
+ if priority != None:
+ self.priority = priority
+ else:
+ self.priority = 0
+ if buffer_id != None:
+ self.buffer_id = buffer_id
+ else:
+ self.buffer_id = 0
+ if out_port != None:
+ self.out_port = out_port
+ else:
+ self.out_port = 0
+ if flags != None:
+ self.flags = flags
+ else:
+ self.flags = 0
+ if actions != None:
+ self.actions = actions
+ else:
+ self.actions = []
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(self.match.pack())
+ packed.append(struct.pack("!Q", self.cookie))
+ packed.append(struct.pack("!H", self._command))
+ packed.append(struct.pack("!H", self.idle_timeout))
+ packed.append(struct.pack("!H", self.hard_timeout))
+ packed.append(struct.pack("!H", self.priority))
+ packed.append(struct.pack("!L", self.buffer_id))
+ packed.append(struct.pack("!H", self.out_port))
+ packed.append(struct.pack("!H", self.flags))
+ packed.append("".join([x.pack() for x in self.actions]))
+ 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")
+ obj = flow_modify_strict()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_FLOW_MOD)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length < 72: raise loxi.ProtocolError("flow_modify_strict length is %d, should be at least 72" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ obj.match = common.match.unpack(buffer(buf, 8))
+ obj.cookie = struct.unpack_from('!Q', buf, 48)[0]
+ _command = struct.unpack_from('!H', buf, 56)[0]
+ assert(_command == const.OFPFC_MODIFY_STRICT)
+ obj.idle_timeout = struct.unpack_from('!H', buf, 58)[0]
+ obj.hard_timeout = struct.unpack_from('!H', buf, 60)[0]
+ obj.priority = struct.unpack_from('!H', buf, 62)[0]
+ obj.buffer_id = struct.unpack_from('!L', buf, 64)[0]
+ obj.out_port = struct.unpack_from('!H', buf, 68)[0]
+ obj.flags = struct.unpack_from('!H', buf, 70)[0]
+ obj.actions = action.unpack_list(buffer(buf, 72))
+ 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.match != other.match: return False
+ if self.cookie != other.cookie: return False
+ if self.idle_timeout != other.idle_timeout: return False
+ if self.hard_timeout != other.hard_timeout: return False
+ if self.priority != other.priority: return False
+ if self.buffer_id != other.buffer_id: return False
+ if self.out_port != other.out_port: return False
+ if self.flags != other.flags: return False
+ if self.actions != other.actions: 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("match = ");
+ q.pp(self.match)
+ q.text(","); q.breakable()
+ q.text("cookie = ");
+ q.text("%#x" % self.cookie)
+ q.text(","); q.breakable()
+ q.text("idle_timeout = ");
+ q.text("%#x" % self.idle_timeout)
+ q.text(","); q.breakable()
+ q.text("hard_timeout = ");
+ q.text("%#x" % self.hard_timeout)
+ q.text(","); q.breakable()
+ q.text("priority = ");
+ q.text("%#x" % self.priority)
+ q.text(","); q.breakable()
+ q.text("buffer_id = ");
+ q.text("%#x" % self.buffer_id)
+ q.text(","); q.breakable()
+ q.text("out_port = ");
+ q.text(util.pretty_port(self.out_port))
+ q.text(","); q.breakable()
+ q.text("flags = ");
+ q.text("%#x" % self.flags)
+ q.text(","); q.breakable()
+ q.text("actions = ");
+ q.pp(self.actions)
+ q.breakable()
+ q.text('}')
+
+class flow_removed(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_FLOW_REMOVED
+
+ def __init__(self, xid=None, match=None, cookie=None, priority=None, reason=None, pad=None, duration_sec=None, duration_nsec=None, idle_timeout=None, pad2=None, packet_count=None, byte_count=None):
+ self.xid = xid
+ if match != None:
+ self.match = match
+ else:
+ self.match = common.match()
+ if cookie != None:
+ self.cookie = cookie
+ else:
+ self.cookie = 0
+ if priority != None:
+ self.priority = priority
+ else:
+ self.priority = 0
+ if reason != None:
+ self.reason = reason
+ else:
+ self.reason = 0
+ if pad != None:
+ self.pad = pad
+ else:
+ self.pad = 0
+ if duration_sec != None:
+ self.duration_sec = duration_sec
+ else:
+ self.duration_sec = 0
+ if duration_nsec != None:
+ self.duration_nsec = duration_nsec
+ else:
+ self.duration_nsec = 0
+ if idle_timeout != None:
+ self.idle_timeout = idle_timeout
+ else:
+ self.idle_timeout = 0
+ if pad2 != None:
+ self.pad2 = pad2
+ else:
+ self.pad2 = [0,0]
+ if packet_count != None:
+ self.packet_count = packet_count
+ else:
+ self.packet_count = 0
+ if byte_count != None:
+ self.byte_count = byte_count
+ else:
+ self.byte_count = 0
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(self.match.pack())
+ packed.append(struct.pack("!Q", self.cookie))
+ packed.append(struct.pack("!H", self.priority))
+ packed.append(struct.pack("!B", self.reason))
+ packed.append(struct.pack("!B", self.pad))
+ packed.append(struct.pack("!L", self.duration_sec))
+ packed.append(struct.pack("!L", self.duration_nsec))
+ packed.append(struct.pack("!H", self.idle_timeout))
+ packed.append(struct.pack("!2B", *self.pad2))
+ packed.append(struct.pack("!Q", self.packet_count))
+ packed.append(struct.pack("!Q", self.byte_count))
+ 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")
+ obj = flow_removed()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_FLOW_REMOVED)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 88: raise loxi.ProtocolError("flow_removed length is %d, should be 88" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ obj.match = common.match.unpack(buffer(buf, 8))
+ obj.cookie = struct.unpack_from('!Q', buf, 48)[0]
+ obj.priority = struct.unpack_from('!H', buf, 56)[0]
+ obj.reason = struct.unpack_from('!B', buf, 58)[0]
+ obj.pad = struct.unpack_from('!B', buf, 59)[0]
+ obj.duration_sec = struct.unpack_from('!L', buf, 60)[0]
+ obj.duration_nsec = struct.unpack_from('!L', buf, 64)[0]
+ obj.idle_timeout = struct.unpack_from('!H', buf, 68)[0]
+ obj.pad2 = list(struct.unpack_from('!2B', buf, 70))
+ obj.packet_count = struct.unpack_from('!Q', buf, 72)[0]
+ obj.byte_count = struct.unpack_from('!Q', buf, 80)[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
+ if self.match != other.match: return False
+ if self.cookie != other.cookie: return False
+ if self.priority != other.priority: return False
+ if self.reason != other.reason: return False
+ if self.pad != other.pad: return False
+ if self.duration_sec != other.duration_sec: return False
+ if self.duration_nsec != other.duration_nsec: return False
+ if self.idle_timeout != other.idle_timeout: return False
+ if self.pad2 != other.pad2: return False
+ if self.packet_count != other.packet_count: return False
+ if self.byte_count != other.byte_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("flow_removed {")
+ with q.group():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("match = ");
+ q.pp(self.match)
+ q.text(","); q.breakable()
+ q.text("cookie = ");
+ q.text("%#x" % self.cookie)
+ q.text(","); q.breakable()
+ q.text("priority = ");
+ q.text("%#x" % self.priority)
+ q.text(","); q.breakable()
+ q.text("reason = ");
+ q.text("%#x" % self.reason)
+ q.text(","); q.breakable()
+ q.text("pad = ");
+ q.text("%#x" % self.pad)
+ q.text(","); q.breakable()
+ q.text("duration_sec = ");
+ q.text("%#x" % self.duration_sec)
+ q.text(","); q.breakable()
+ q.text("duration_nsec = ");
+ q.text("%#x" % self.duration_nsec)
+ q.text(","); q.breakable()
+ q.text("idle_timeout = ");
+ q.text("%#x" % self.idle_timeout)
+ q.text(","); q.breakable()
+ q.text("pad2 = ");
+ q.pp(self.pad2)
+ q.text(","); q.breakable()
+ q.text("packet_count = ");
+ q.text("%#x" % self.packet_count)
+ q.text(","); q.breakable()
+ q.text("byte_count = ");
+ q.text("%#x" % self.byte_count)
+ q.breakable()
+ q.text('}')
+
+class flow_stats_reply(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_STATS_REPLY
+ stats_type = const.OFPST_FLOW
+
+ def __init__(self, xid=None, flags=None, entries=None):
+ self.xid = xid
+ if flags != None:
+ self.flags = flags
+ else:
+ self.flags = 0
+ if entries != None:
+ self.entries = entries
+ else:
+ self.entries = []
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(struct.pack("!H", self.stats_type))
+ packed.append(struct.pack("!H", self.flags))
+ packed.append("".join([x.pack() for x in 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")
+ obj = flow_stats_reply()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_STATS_REPLY)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length < 12: raise loxi.ProtocolError("flow_stats_reply length is %d, should be at least 12" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ stats_type = struct.unpack_from('!H', buf, 8)[0]
+ assert(stats_type == const.OFPST_FLOW)
+ obj.flags = struct.unpack_from('!H', buf, 10)[0]
+ obj.entries = common.unpack_list_flow_stats_entry(buffer(buf, 12))
+ 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("flags = ");
+ q.text("%#x" % self.flags)
+ q.text(","); q.breakable()
+ q.text("entries = ");
+ q.pp(self.entries)
+ q.breakable()
+ q.text('}')
+
+class flow_stats_request(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_STATS_REQUEST
+ stats_type = const.OFPST_FLOW
+
+ def __init__(self, xid=None, flags=None, match=None, table_id=None, pad=None, out_port=None):
+ self.xid = xid
+ if flags != None:
+ self.flags = flags
+ else:
+ self.flags = 0
+ if match != None:
+ self.match = match
+ else:
+ self.match = common.match()
+ if table_id != None:
+ self.table_id = table_id
+ else:
+ self.table_id = 0
+ if pad != None:
+ self.pad = pad
+ else:
+ self.pad = 0
+ if out_port != None:
+ self.out_port = out_port
+ else:
+ self.out_port = 0
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(struct.pack("!H", self.stats_type))
+ packed.append(struct.pack("!H", self.flags))
+ packed.append(self.match.pack())
+ packed.append(struct.pack("!B", self.table_id))
+ packed.append(struct.pack("!B", self.pad))
+ packed.append(struct.pack("!H", self.out_port))
+ 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")
+ obj = flow_stats_request()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_STATS_REQUEST)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 56: raise loxi.ProtocolError("flow_stats_request length is %d, should be 56" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ stats_type = struct.unpack_from('!H', buf, 8)[0]
+ assert(stats_type == const.OFPST_FLOW)
+ obj.flags = struct.unpack_from('!H', buf, 10)[0]
+ obj.match = common.match.unpack(buffer(buf, 12))
+ obj.table_id = struct.unpack_from('!B', buf, 52)[0]
+ obj.pad = struct.unpack_from('!B', buf, 53)[0]
+ obj.out_port = struct.unpack_from('!H', buf, 54)[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
+ if self.flags != other.flags: return False
+ if self.match != other.match: return False
+ if self.table_id != other.table_id: return False
+ if self.pad != other.pad: return False
+ if self.out_port != other.out_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("flow_stats_request {")
+ with q.group():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("flags = ");
+ q.text("%#x" % self.flags)
+ q.text(","); q.breakable()
+ q.text("match = ");
+ q.pp(self.match)
+ q.text(","); q.breakable()
+ q.text("table_id = ");
+ q.text("%#x" % self.table_id)
+ q.text(","); q.breakable()
+ q.text("pad = ");
+ q.text("%#x" % self.pad)
+ q.text(","); q.breakable()
+ q.text("out_port = ");
+ q.text(util.pretty_port(self.out_port))
+ q.breakable()
+ q.text('}')
+
+class get_config_reply(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_GET_CONFIG_REPLY
+
+ def __init__(self, xid=None, flags=None, miss_send_len=None):
+ self.xid = xid
+ if flags != None:
+ self.flags = flags
+ else:
+ self.flags = 0
+ if miss_send_len != None:
+ self.miss_send_len = miss_send_len
+ else:
+ self.miss_send_len = 0
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(struct.pack("!H", self.flags))
+ packed.append(struct.pack("!H", self.miss_send_len))
+ 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")
+ obj = get_config_reply()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_GET_CONFIG_REPLY)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 12: raise loxi.ProtocolError("get_config_reply length is %d, should be 12" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ obj.flags = struct.unpack_from('!H', buf, 8)[0]
+ obj.miss_send_len = struct.unpack_from('!H', buf, 10)[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
+ 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("flags = ");
+ q.text("%#x" % self.flags)
+ q.text(","); q.breakable()
+ q.text("miss_send_len = ");
+ q.text("%#x" % self.miss_send_len)
+ q.breakable()
+ q.text('}')
+
+class get_config_request(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_GET_CONFIG_REQUEST
+
+ def __init__(self, xid=None):
+ self.xid = xid
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ 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")
+ obj = get_config_request()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_GET_CONFIG_REQUEST)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 8: raise loxi.ProtocolError("get_config_request length is %d, should be 8" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[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():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.breakable()
+ q.text('}')
+
+class hello(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_HELLO
+
+ def __init__(self, xid=None):
+ self.xid = xid
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ 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")
+ obj = hello()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_HELLO)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 8: raise loxi.ProtocolError("hello length is %d, should be 8" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[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():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.breakable()
+ q.text('}')
+
+class nicira_controller_role_reply(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_VENDOR
+ experimenter = 0x2320
+ subtype = 11
+
+ def __init__(self, xid=None, role=None):
+ self.xid = xid
+ if role != None:
+ self.role = role
+ else:
+ self.role = 0
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(struct.pack("!L", self.experimenter))
+ packed.append(struct.pack("!L", self.subtype))
+ packed.append(struct.pack("!L", self.role))
+ 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")
+ obj = nicira_controller_role_reply()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_VENDOR)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 20: raise loxi.ProtocolError("nicira_controller_role_reply length is %d, should be 20" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ experimenter = struct.unpack_from('!L', buf, 8)[0]
+ assert(experimenter == 0x2320)
+ subtype = struct.unpack_from('!L', buf, 12)[0]
+ assert(subtype == 11)
+ obj.role = struct.unpack_from('!L', buf, 16)[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
+ if self.role != other.role: 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("nicira_controller_role_reply {")
+ with q.group():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("role = ");
+ q.text("%#x" % self.role)
+ q.breakable()
+ q.text('}')
+
+class nicira_controller_role_request(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_VENDOR
+ experimenter = 0x2320
+ subtype = 10
+
+ def __init__(self, xid=None, role=None):
+ self.xid = xid
+ if role != None:
+ self.role = role
+ else:
+ self.role = 0
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(struct.pack("!L", self.experimenter))
+ packed.append(struct.pack("!L", self.subtype))
+ packed.append(struct.pack("!L", self.role))
+ 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")
+ obj = nicira_controller_role_request()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_VENDOR)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 20: raise loxi.ProtocolError("nicira_controller_role_request length is %d, should be 20" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ experimenter = struct.unpack_from('!L', buf, 8)[0]
+ assert(experimenter == 0x2320)
+ subtype = struct.unpack_from('!L', buf, 12)[0]
+ assert(subtype == 10)
+ obj.role = struct.unpack_from('!L', buf, 16)[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
+ if self.role != other.role: 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("nicira_controller_role_request {")
+ with q.group():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("role = ");
+ q.text("%#x" % self.role)
+ q.breakable()
+ q.text('}')
+
+class packet_in(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_PACKET_IN
+
+ def __init__(self, xid=None, buffer_id=None, total_len=None, in_port=None, reason=None, pad=None, data=None):
+ self.xid = xid
+ if buffer_id != None:
+ self.buffer_id = buffer_id
+ else:
+ self.buffer_id = 0
+ if total_len != None:
+ self.total_len = total_len
+ else:
+ self.total_len = 0
+ if in_port != None:
+ self.in_port = in_port
+ else:
+ self.in_port = 0
+ if reason != None:
+ self.reason = reason
+ else:
+ self.reason = 0
+ if pad != None:
+ self.pad = pad
+ else:
+ self.pad = 0
+ if data != None:
+ self.data = data
+ else:
+ self.data = ""
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(struct.pack("!L", self.buffer_id))
+ packed.append(struct.pack("!H", self.total_len))
+ packed.append(struct.pack("!H", self.in_port))
+ packed.append(struct.pack("!B", self.reason))
+ packed.append(struct.pack("!B", self.pad))
+ packed.append(self.data)
+ 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")
+ obj = packet_in()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_PACKET_IN)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length < 18: raise loxi.ProtocolError("packet_in length is %d, should be at least 18" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ obj.buffer_id = struct.unpack_from('!L', buf, 8)[0]
+ obj.total_len = struct.unpack_from('!H', buf, 12)[0]
+ obj.in_port = struct.unpack_from('!H', buf, 14)[0]
+ obj.reason = struct.unpack_from('!B', buf, 16)[0]
+ obj.pad = struct.unpack_from('!B', buf, 17)[0]
+ obj.data = buf[18:]
+ 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.total_len != other.total_len: return False
+ if self.in_port != other.in_port: return False
+ if self.reason != other.reason: return False
+ if self.pad != other.pad: 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("packet_in {")
+ with q.group():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("buffer_id = ");
+ q.text("%#x" % self.buffer_id)
+ q.text(","); q.breakable()
+ q.text("total_len = ");
+ q.text("%#x" % self.total_len)
+ q.text(","); q.breakable()
+ q.text("in_port = ");
+ q.text(util.pretty_port(self.in_port))
+ q.text(","); q.breakable()
+ q.text("reason = ");
+ q.text("%#x" % self.reason)
+ q.text(","); q.breakable()
+ q.text("pad = ");
+ q.text("%#x" % self.pad)
+ q.text(","); q.breakable()
+ q.text("data = ");
+ q.pp(self.data)
+ q.breakable()
+ q.text('}')
+
+class packet_out(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_PACKET_OUT
+
+ def __init__(self, xid=None, buffer_id=None, in_port=None, actions=None, data=None):
+ self.xid = xid
+ if buffer_id != None:
+ self.buffer_id = buffer_id
+ else:
+ self.buffer_id = 0
+ if in_port != None:
+ self.in_port = in_port
+ else:
+ self.in_port = 0
+ if actions != None:
+ self.actions = actions
+ else:
+ self.actions = []
+ if data != None:
+ self.data = data
+ else:
+ self.data = ""
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 3
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(struct.pack("!L", self.buffer_id))
+ packed.append(struct.pack("!H", self.in_port))
+ packed_actions = "".join([x.pack() for x in self.actions])
+ packed.append(struct.pack("!H", len(packed_actions)))
+ packed.append(packed_actions)
+ packed.append(self.data)
+ 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")
+ obj = packet_out()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_PACKET_OUT)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length < 16: raise loxi.ProtocolError("packet_out length is %d, should be at least 16" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ obj.buffer_id = struct.unpack_from('!L', buf, 8)[0]
+ obj.in_port = struct.unpack_from('!H', buf, 12)[0]
+ actions_len = struct.unpack_from('!H', buf, 14)[0]
+ obj.actions = action.unpack_list(buffer(buf, 16, actions_len))
+ obj.data = str(buffer(buf, 16+actions_len))
+ 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
+ if self.actions != other.actions: 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("packet_out {")
+ with q.group():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("buffer_id = ");
+ q.text("%#x" % self.buffer_id)
+ q.text(","); q.breakable()
+ q.text("in_port = ");
+ q.text(util.pretty_port(self.in_port))
+ q.text(","); q.breakable()
+ q.text("actions = ");
+ q.pp(self.actions)
+ q.text(","); q.breakable()
+ q.text("data = ");
+ q.pp(self.data)
+ q.breakable()
+ q.text('}')
+
+class port_mod(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_PORT_MOD
+
+ def __init__(self, xid=None, port_no=None, hw_addr=None, config=None, mask=None, advertise=None, pad=None):
+ self.xid = xid
+ if port_no != None:
+ self.port_no = port_no
+ else:
+ self.port_no = 0
+ if hw_addr != None:
+ self.hw_addr = hw_addr
+ else:
+ self.hw_addr = [0,0,0,0,0,0]
+ if config != None:
+ self.config = config
+ else:
+ self.config = 0
+ if mask != None:
+ self.mask = mask
+ else:
+ self.mask = 0
+ if advertise != None:
+ self.advertise = advertise
+ else:
+ self.advertise = 0
+ if pad != None:
+ self.pad = pad
+ else:
+ self.pad = [0,0,0,0]
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(struct.pack("!H", self.port_no))
+ packed.append(struct.pack("!6B", *self.hw_addr))
+ packed.append(struct.pack("!L", self.config))
+ packed.append(struct.pack("!L", self.mask))
+ packed.append(struct.pack("!L", self.advertise))
+ packed.append(struct.pack("!4B", *self.pad))
+ 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")
+ obj = port_mod()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_PORT_MOD)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 32: raise loxi.ProtocolError("port_mod length is %d, should be 32" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ obj.port_no = struct.unpack_from('!H', buf, 8)[0]
+ obj.hw_addr = list(struct.unpack_from('!6B', buf, 10))
+ obj.config = struct.unpack_from('!L', buf, 16)[0]
+ obj.mask = struct.unpack_from('!L', buf, 20)[0]
+ obj.advertise = struct.unpack_from('!L', buf, 24)[0]
+ obj.pad = list(struct.unpack_from('!4B', buf, 28))
+ 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_no != other.port_no: return False
+ if self.hw_addr != other.hw_addr: return False
+ if self.config != other.config: return False
+ if self.mask != other.mask: return False
+ if self.advertise != other.advertise: return False
+ if self.pad != other.pad: 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("port_no = ");
+ q.text(util.pretty_port(self.port_no))
+ q.text(","); q.breakable()
+ q.text("hw_addr = ");
+ q.text(util.pretty_mac(self.hw_addr))
+ q.text(","); q.breakable()
+ q.text("config = ");
+ q.text("%#x" % self.config)
+ q.text(","); q.breakable()
+ q.text("mask = ");
+ q.text("%#x" % self.mask)
+ q.text(","); q.breakable()
+ q.text("advertise = ");
+ q.text("%#x" % self.advertise)
+ q.text(","); q.breakable()
+ q.text("pad = ");
+ q.pp(self.pad)
+ q.breakable()
+ q.text('}')
+
+class port_stats_reply(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_STATS_REPLY
+ stats_type = const.OFPST_PORT
+
+ def __init__(self, xid=None, flags=None, entries=None):
+ self.xid = xid
+ if flags != None:
+ self.flags = flags
+ else:
+ self.flags = 0
+ if entries != None:
+ self.entries = entries
+ else:
+ self.entries = []
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(struct.pack("!H", self.stats_type))
+ packed.append(struct.pack("!H", self.flags))
+ packed.append("".join([x.pack() for x in 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")
+ obj = port_stats_reply()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_STATS_REPLY)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length < 12: raise loxi.ProtocolError("port_stats_reply length is %d, should be at least 12" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ stats_type = struct.unpack_from('!H', buf, 8)[0]
+ assert(stats_type == const.OFPST_PORT)
+ obj.flags = struct.unpack_from('!H', buf, 10)[0]
+ obj.entries = util.unpack_array(common.port_stats_entry.unpack, 104, buffer(buf, 12))
+ 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("port_stats_reply {")
+ with q.group():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("flags = ");
+ q.text("%#x" % self.flags)
+ q.text(","); q.breakable()
+ q.text("entries = ");
+ q.pp(self.entries)
+ q.breakable()
+ q.text('}')
+
+class port_stats_request(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_STATS_REQUEST
+ stats_type = const.OFPST_PORT
+
+ def __init__(self, xid=None, flags=None, port_no=None, pad=None):
+ self.xid = xid
+ if flags != None:
+ self.flags = flags
+ else:
+ self.flags = 0
+ if port_no != None:
+ self.port_no = port_no
+ else:
+ self.port_no = 0
+ if pad != None:
+ self.pad = pad
+ else:
+ self.pad = [0,0,0,0,0,0]
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(struct.pack("!H", self.stats_type))
+ packed.append(struct.pack("!H", self.flags))
+ packed.append(struct.pack("!H", self.port_no))
+ packed.append(struct.pack("!6B", *self.pad))
+ 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")
+ obj = port_stats_request()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_STATS_REQUEST)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 20: raise loxi.ProtocolError("port_stats_request length is %d, should be 20" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ stats_type = struct.unpack_from('!H', buf, 8)[0]
+ assert(stats_type == const.OFPST_PORT)
+ obj.flags = struct.unpack_from('!H', buf, 10)[0]
+ obj.port_no = struct.unpack_from('!H', buf, 12)[0]
+ obj.pad = list(struct.unpack_from('!6B', buf, 14))
+ 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.port_no != other.port_no: return False
+ if self.pad != other.pad: 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("flags = ");
+ q.text("%#x" % self.flags)
+ q.text(","); q.breakable()
+ q.text("port_no = ");
+ q.text(util.pretty_port(self.port_no))
+ q.text(","); q.breakable()
+ q.text("pad = ");
+ q.pp(self.pad)
+ q.breakable()
+ q.text('}')
+
+class port_status(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_PORT_STATUS
+
+ def __init__(self, xid=None, reason=None, pad=None, desc=None):
+ self.xid = xid
+ if reason != None:
+ self.reason = reason
+ else:
+ self.reason = 0
+ if pad != None:
+ self.pad = pad
+ else:
+ self.pad = [0,0,0,0,0,0,0]
+ if desc != None:
+ self.desc = desc
+ else:
+ self.desc = common.port_desc()
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(struct.pack("!B", self.reason))
+ packed.append(struct.pack("!7B", *self.pad))
+ packed.append(self.desc.pack())
+ 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")
+ obj = port_status()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_PORT_STATUS)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 64: raise loxi.ProtocolError("port_status length is %d, should be 64" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ obj.reason = struct.unpack_from('!B', buf, 8)[0]
+ obj.pad = list(struct.unpack_from('!7B', buf, 9))
+ obj.desc = common.port_desc.unpack(buffer(buf, 16))
+ 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.reason != other.reason: return False
+ if self.pad != other.pad: 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("reason = ");
+ q.text("%#x" % self.reason)
+ q.text(","); q.breakable()
+ q.text("pad = ");
+ q.pp(self.pad)
+ q.text(","); q.breakable()
+ q.text("desc = ");
+ q.pp(self.desc)
+ q.breakable()
+ q.text('}')
+
+class queue_get_config_reply(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_QUEUE_GET_CONFIG_REPLY
+
+ def __init__(self, xid=None, port=None, pad=None, queues=None):
+ self.xid = xid
+ if port != None:
+ self.port = port
+ else:
+ self.port = 0
+ if pad != None:
+ self.pad = pad
+ else:
+ self.pad = [0,0,0,0,0,0]
+ if queues != None:
+ self.queues = queues
+ else:
+ self.queues = []
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(struct.pack("!H", self.port))
+ packed.append(struct.pack("!6B", *self.pad))
+ packed.append("".join([x.pack() for x in 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")
+ obj = queue_get_config_reply()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_QUEUE_GET_CONFIG_REPLY)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length < 16: raise loxi.ProtocolError("queue_get_config_reply length is %d, should be at least 16" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ obj.port = struct.unpack_from('!H', buf, 8)[0]
+ obj.pad = list(struct.unpack_from('!6B', buf, 10))
+ obj.queues = common.unpack_list_packet_queue(buffer(buf, 16))
+ 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.pad != other.pad: 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("port = ");
+ q.text(util.pretty_port(self.port))
+ q.text(","); q.breakable()
+ q.text("pad = ");
+ q.pp(self.pad)
+ q.text(","); q.breakable()
+ q.text("queues = ");
+ q.pp(self.queues)
+ q.breakable()
+ q.text('}')
+
+class queue_get_config_request(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_QUEUE_GET_CONFIG_REQUEST
+
+ def __init__(self, xid=None, port=None, pad=None):
+ self.xid = xid
+ if port != None:
+ self.port = port
+ else:
+ self.port = 0
+ if pad != None:
+ self.pad = pad
+ else:
+ self.pad = [0,0]
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(struct.pack("!H", self.port))
+ packed.append(struct.pack("!2B", *self.pad))
+ 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")
+ obj = queue_get_config_request()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_QUEUE_GET_CONFIG_REQUEST)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 12: raise loxi.ProtocolError("queue_get_config_request length is %d, should be 12" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ obj.port = struct.unpack_from('!H', buf, 8)[0]
+ obj.pad = list(struct.unpack_from('!2B', buf, 10))
+ 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.pad != other.pad: 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("port = ");
+ q.text(util.pretty_port(self.port))
+ q.text(","); q.breakable()
+ q.text("pad = ");
+ q.pp(self.pad)
+ q.breakable()
+ q.text('}')
+
+class queue_stats_reply(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_STATS_REPLY
+ stats_type = const.OFPST_QUEUE
+
+ def __init__(self, xid=None, flags=None, entries=None):
+ self.xid = xid
+ if flags != None:
+ self.flags = flags
+ else:
+ self.flags = 0
+ if entries != None:
+ self.entries = entries
+ else:
+ self.entries = []
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(struct.pack("!H", self.stats_type))
+ packed.append(struct.pack("!H", self.flags))
+ packed.append("".join([x.pack() for x in 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")
+ obj = queue_stats_reply()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_STATS_REPLY)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length < 12: raise loxi.ProtocolError("queue_stats_reply length is %d, should be at least 12" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ stats_type = struct.unpack_from('!H', buf, 8)[0]
+ assert(stats_type == const.OFPST_QUEUE)
+ obj.flags = struct.unpack_from('!H', buf, 10)[0]
+ obj.entries = util.unpack_array(common.queue_stats_entry.unpack, 32, buffer(buf, 12))
+ 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("queue_stats_reply {")
+ with q.group():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("flags = ");
+ q.text("%#x" % self.flags)
+ q.text(","); q.breakable()
+ q.text("entries = ");
+ q.pp(self.entries)
+ q.breakable()
+ q.text('}')
+
+class queue_stats_request(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_STATS_REQUEST
+ stats_type = const.OFPST_QUEUE
+
+ def __init__(self, xid=None, flags=None, port_no=None, pad=None, queue_id=None):
+ self.xid = xid
+ if flags != None:
+ self.flags = flags
+ else:
+ self.flags = 0
+ if port_no != None:
+ self.port_no = port_no
+ else:
+ self.port_no = 0
+ if pad != None:
+ self.pad = pad
+ else:
+ self.pad = [0,0]
+ if queue_id != None:
+ self.queue_id = queue_id
+ else:
+ self.queue_id = 0
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(struct.pack("!H", self.stats_type))
+ packed.append(struct.pack("!H", self.flags))
+ packed.append(struct.pack("!H", self.port_no))
+ packed.append(struct.pack("!2B", *self.pad))
+ packed.append(struct.pack("!L", self.queue_id))
+ 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")
+ obj = queue_stats_request()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_STATS_REQUEST)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 20: raise loxi.ProtocolError("queue_stats_request length is %d, should be 20" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ stats_type = struct.unpack_from('!H', buf, 8)[0]
+ assert(stats_type == const.OFPST_QUEUE)
+ obj.flags = struct.unpack_from('!H', buf, 10)[0]
+ obj.port_no = struct.unpack_from('!H', buf, 12)[0]
+ obj.pad = list(struct.unpack_from('!2B', buf, 14))
+ obj.queue_id = struct.unpack_from('!L', buf, 16)[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
+ if self.flags != other.flags: return False
+ if self.port_no != other.port_no: return False
+ if self.pad != other.pad: 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("flags = ");
+ q.text("%#x" % self.flags)
+ q.text(","); q.breakable()
+ q.text("port_no = ");
+ q.text(util.pretty_port(self.port_no))
+ q.text(","); q.breakable()
+ q.text("pad = ");
+ q.pp(self.pad)
+ q.text(","); q.breakable()
+ q.text("queue_id = ");
+ q.text("%#x" % self.queue_id)
+ q.breakable()
+ q.text('}')
+
+class set_config(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_SET_CONFIG
+
+ def __init__(self, xid=None, flags=None, miss_send_len=None):
+ self.xid = xid
+ if flags != None:
+ self.flags = flags
+ else:
+ self.flags = 0
+ if miss_send_len != None:
+ self.miss_send_len = miss_send_len
+ else:
+ self.miss_send_len = 0
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(struct.pack("!H", self.flags))
+ packed.append(struct.pack("!H", self.miss_send_len))
+ 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")
+ obj = set_config()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_SET_CONFIG)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 12: raise loxi.ProtocolError("set_config length is %d, should be 12" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ obj.flags = struct.unpack_from('!H', buf, 8)[0]
+ obj.miss_send_len = struct.unpack_from('!H', buf, 10)[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
+ 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("flags = ");
+ q.text("%#x" % self.flags)
+ q.text(","); q.breakable()
+ q.text("miss_send_len = ");
+ q.text("%#x" % self.miss_send_len)
+ q.breakable()
+ q.text('}')
+
+class table_mod(Message):
+ version = const.OFP_VERSION
+ type = 22
+
+ def __init__(self, xid=None, table_id=None, pad=None, config=None):
+ self.xid = xid
+ if table_id != None:
+ self.table_id = table_id
+ else:
+ self.table_id = 0
+ if pad != None:
+ self.pad = pad
+ else:
+ self.pad = [0,0,0]
+ if config != None:
+ self.config = config
+ else:
+ self.config = 0
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(struct.pack("!B", self.table_id))
+ packed.append(struct.pack("!3B", *self.pad))
+ packed.append(struct.pack("!L", self.config))
+ 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")
+ obj = table_mod()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == 22)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 16: raise loxi.ProtocolError("table_mod length is %d, should be 16" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ obj.table_id = struct.unpack_from('!B', buf, 8)[0]
+ obj.pad = list(struct.unpack_from('!3B', buf, 9))
+ obj.config = struct.unpack_from('!L', buf, 12)[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
+ if self.table_id != other.table_id: return False
+ if self.pad != other.pad: 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("table_id = ");
+ q.text("%#x" % self.table_id)
+ q.text(","); q.breakable()
+ q.text("pad = ");
+ q.pp(self.pad)
+ q.text(","); q.breakable()
+ q.text("config = ");
+ q.text("%#x" % self.config)
+ q.breakable()
+ q.text('}')
+
+class table_stats_reply(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_STATS_REPLY
+ stats_type = const.OFPST_TABLE
+
+ def __init__(self, xid=None, flags=None, entries=None):
+ self.xid = xid
+ if flags != None:
+ self.flags = flags
+ else:
+ self.flags = 0
+ if entries != None:
+ self.entries = entries
+ else:
+ self.entries = []
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(struct.pack("!H", self.stats_type))
+ packed.append(struct.pack("!H", self.flags))
+ packed.append("".join([x.pack() for x in 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")
+ obj = table_stats_reply()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_STATS_REPLY)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length < 12: raise loxi.ProtocolError("table_stats_reply length is %d, should be at least 12" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ stats_type = struct.unpack_from('!H', buf, 8)[0]
+ assert(stats_type == const.OFPST_TABLE)
+ obj.flags = struct.unpack_from('!H', buf, 10)[0]
+ obj.entries = util.unpack_array(common.table_stats_entry.unpack, 64, buffer(buf, 12))
+ 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("table_stats_reply {")
+ with q.group():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("flags = ");
+ q.text("%#x" % self.flags)
+ q.text(","); q.breakable()
+ q.text("entries = ");
+ q.pp(self.entries)
+ q.breakable()
+ q.text('}')
+
+class table_stats_request(Message):
+ version = const.OFP_VERSION
+ type = const.OFPT_STATS_REQUEST
+ stats_type = const.OFPST_TABLE
+
+ def __init__(self, xid=None, flags=None):
+ self.xid = xid
+ if flags != None:
+ self.flags = flags
+ else:
+ self.flags = 0
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ packed.append(struct.pack("!H", self.stats_type))
+ packed.append(struct.pack("!H", self.flags))
+ 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")
+ obj = table_stats_request()
+ version = struct.unpack_from('!B', buf, 0)[0]
+ assert(version == const.OFP_VERSION)
+ type = struct.unpack_from('!B', buf, 1)[0]
+ assert(type == const.OFPT_STATS_REQUEST)
+ _length = struct.unpack_from('!H', buf, 2)[0]
+ assert(_length == len(buf))
+ if _length != 12: raise loxi.ProtocolError("table_stats_request length is %d, should be 12" % _length)
+ obj.xid = struct.unpack_from('!L', buf, 4)[0]
+ stats_type = struct.unpack_from('!H', buf, 8)[0]
+ assert(stats_type == const.OFPST_TABLE)
+ obj.flags = struct.unpack_from('!H', buf, 10)[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
+ 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():
+ with q.indent(2):
+ q.breakable()
+ q.text("xid = ");
+ if self.xid != None:
+ q.text("%#x" % self.xid)
+ else:
+ q.text('None')
+ q.text(","); q.breakable()
+ q.text("flags = ");
+ q.text("%#x" % self.flags)
+ q.breakable()
+ q.text('}')
+
+
+def parse_header(buf):
+ if len(buf) < 8:
+ raise loxi.ProtocolError("too short to be an OpenFlow message")
+ return struct.unpack_from("!BBHL", buf)
+
+def parse_message(buf):
+ msg_ver, msg_type, msg_len, msg_xid = parse_header(buf)
+ if msg_ver != const.OFP_VERSION and msg_type != ofp.OFPT_HELLO:
+ raise loxi.ProtocolError("wrong OpenFlow version")
+ 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_flow_mod(buf):
+ if len(buf) < 56 + 2:
+ raise loxi.ProtocolError("message too short")
+ cmd, = struct.unpack_from("!H", buf, 56)
+ if cmd in flow_mod_parsers:
+ return flow_mod_parsers[cmd](buf)
+ else:
+ raise loxi.ProtocolError("unexpected flow 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_vendor(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 = {
+ 22 : table_mod.unpack,
+ const.OFPT_BARRIER_REPLY : barrier_reply.unpack,
+ const.OFPT_BARRIER_REQUEST : barrier_request.unpack,
+ const.OFPT_ECHO_REPLY : echo_reply.unpack,
+ const.OFPT_ECHO_REQUEST : echo_request.unpack,
+ const.OFPT_ERROR : error_msg.unpack,
+ const.OFPT_FEATURES_REPLY : features_reply.unpack,
+ const.OFPT_FEATURES_REQUEST : features_request.unpack,
+ const.OFPT_FLOW_MOD : parse_flow_mod,
+ const.OFPT_FLOW_REMOVED : flow_removed.unpack,
+ const.OFPT_GET_CONFIG_REPLY : get_config_reply.unpack,
+ const.OFPT_GET_CONFIG_REQUEST : get_config_request.unpack,
+ const.OFPT_HELLO : hello.unpack,
+ const.OFPT_PACKET_IN : packet_in.unpack,
+ const.OFPT_PACKET_OUT : packet_out.unpack,
+ const.OFPT_PORT_MOD : port_mod.unpack,
+ const.OFPT_PORT_STATUS : port_status.unpack,
+ const.OFPT_QUEUE_GET_CONFIG_REPLY : queue_get_config_reply.unpack,
+ const.OFPT_QUEUE_GET_CONFIG_REQUEST : queue_get_config_request.unpack,
+ const.OFPT_SET_CONFIG : set_config.unpack,
+ const.OFPT_STATS_REPLY : parse_stats_reply,
+ const.OFPT_STATS_REQUEST : parse_stats_request,
+ const.OFPT_VENDOR : parse_vendor,
+}
+
+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,
+}
+
+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_VENDOR : experimenter_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_VENDOR : experimenter_stats_request.unpack,
+}
+
+experimenter_parsers = {
+ 0x2320 : {
+ 11: nicira_controller_role_reply.unpack,
+ 10: nicira_controller_role_request.unpack,
+ },
+ 0x5c16c7 : {
+ 10: bsn_get_interfaces_reply.unpack,
+ 9: bsn_get_interfaces_request.unpack,
+ 2: bsn_get_ip_mask_reply.unpack,
+ 1: bsn_get_ip_mask_request.unpack,
+ 5: bsn_get_mirroring_reply.unpack,
+ 4: bsn_get_mirroring_request.unpack,
+ 0: bsn_set_ip_mask.unpack,
+ 3: bsn_set_mirroring.unpack,
+ 6: bsn_shell_command.unpack,
+ 7: bsn_shell_output.unpack,
+ 8: bsn_shell_status.unpack,
+ },
+}
diff --git a/src/python/loxi/of10/util.py b/src/python/loxi/of10/util.py
new file mode 100644
index 0000000..713d5cb
--- /dev/null
+++ b/src/python/loxi/of10/util.py
@@ -0,0 +1,64 @@
+#
+# Copyright 2012, 2013, Big Switch Networks, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+# Automatically generated by LOXI from template util.py
+# Do not modify
+
+import loxi
+import const
+
+def unpack_array(deserializer, element_size, buf):
+ """
+ Deserialize an array of fixed length elements.
+ The deserializer function should take a buffer and return the new object.
+ """
+ if len(buf) % element_size != 0: raise loxi.ProtocolError("invalid array length")
+ n = len(buf) / element_size
+ return [deserializer(buffer(buf, i*element_size, element_size)) for i in range(n)]
+
+def pretty_mac(mac):
+ return ':'.join(["%02x" % x for x in mac])
+
+def pretty_ipv4(v):
+ return "%d.%d.%d.%d" % ((v >> 24) & 0xFF, (v >> 16) & 0xFF, (v >> 8) & 0xFF, v & 0xFF)
+
+def pretty_flags(v, flag_names):
+ set_flags = []
+ for flag_name in flag_names:
+ flag_value = getattr(const, flag_name)
+ if v & flag_value == flag_value:
+ set_flags.append(flag_name)
+ elif v & flag_value:
+ set_flags.append('%s&%#x' % (flag_name, v & flag_value))
+ v &= ~flag_value
+ if v:
+ set_flags.append("%#x" % v)
+ return '|'.join(set_flags) or '0'
+
+def pretty_wildcards(v):
+ if v == const.OFPFW_ALL:
+ return 'OFPFW_ALL'
+ flag_names = ['OFPFW_IN_PORT', 'OFPFW_DL_VLAN', 'OFPFW_DL_SRC', 'OFPFW_DL_DST',
+ 'OFPFW_DL_TYPE', 'OFPFW_NW_PROTO', 'OFPFW_TP_SRC', 'OFPFW_TP_DST',
+ 'OFPFW_NW_SRC_MASK', 'OFPFW_NW_DST_MASK', 'OFPFW_DL_VLAN_PCP',
+ 'OFPFW_NW_TOS']
+ return pretty_flags(v, flag_names)
+
+def pretty_port(v):
+ named_ports = [(k,v2) for (k,v2) in const.__dict__.iteritems() if k.startswith('OFPP_')]
+ for (k, v2) in named_ports:
+ if v == v2:
+ return k
+ return v
diff --git a/src/python/loxi/pp.py b/src/python/loxi/pp.py
new file mode 100644
index 0000000..852215d
--- /dev/null
+++ b/src/python/loxi/pp.py
@@ -0,0 +1,248 @@
+"""
+pp - port of Ruby's PP library
+Also based on Lindig, C., & GbR, G. D. (2000). Strictly Pretty.
+
+Example usage:
+>>> import pp.pp as pp
+>>> print pp([[1, 2], [3, 4]], maxwidth=15)
+[
+ [ 1, 2 ],
+ [ 3, 4 ]
+]
+"""
+import unittest
+from contextlib import contextmanager
+
+def pp(obj, maxwidth=79):
+ """
+ Pretty-print the given object.
+ """
+ ctx = PrettyPrinter(maxwidth=maxwidth)
+ ctx.pp(obj)
+ return str(ctx)
+
+
+## Pretty-printers for builtin classes
+
+def pretty_print_list(pp, obj):
+ with pp.group():
+ pp.text('[')
+ with pp.indent(2):
+ for v in obj:
+ if not pp.first(): pp.text(',')
+ pp.breakable()
+ pp.pp(v)
+ pp.breakable()
+ pp.text(']')
+
+def pretty_print_dict(pp, obj):
+ with pp.group():
+ pp.text('{')
+ with pp.indent(2):
+ for (k, v) in sorted(obj.items()):
+ if not pp.first(): pp.text(',')
+ pp.breakable()
+ pp.pp(k)
+ pp.text(': ')
+ pp.pp(v)
+ pp.breakable()
+ pp.text('}')
+
+pretty_printers = {
+ list: pretty_print_list,
+ dict: pretty_print_dict,
+}
+
+
+## Implementation
+
+class PrettyPrinter(object):
+ def __init__(self, maxwidth):
+ self.maxwidth = maxwidth
+ self.cur_indent = 0
+ self.root_group = Group()
+ self.group_stack = [self.root_group]
+
+ def current_group(self):
+ return self.group_stack[-1]
+
+ def text(self, s):
+ self.current_group().append(str(s))
+
+ def breakable(self, sep=' '):
+ self.current_group().append(Breakable(sep, self.cur_indent))
+
+ def first(self):
+ return self.current_group().first()
+
+ @contextmanager
+ def indent(self, n):
+ self.cur_indent += n
+ yield
+ self.cur_indent -= n
+
+ @contextmanager
+ def group(self):
+ self.group_stack.append(Group())
+ yield
+ new_group = self.group_stack.pop()
+ self.current_group().append(new_group)
+
+ def pp(self, obj):
+ if hasattr(obj, "pretty_print"):
+ obj.pretty_print(self)
+ elif type(obj) in pretty_printers:
+ pretty_printers[type(obj)](self, obj)
+ else:
+ self.text(repr(obj))
+
+ def __str__(self):
+ return self.root_group.render(0, self.maxwidth)
+
+class Group(object):
+ __slots__ = ["fragments", "length", "_first"]
+
+ def __init__(self):
+ self.fragments = []
+ self.length = 0
+ self._first = True
+
+ def append(self, x):
+ self.fragments.append(x)
+ self.length += len(x)
+
+ def first(self):
+ if self._first:
+ self._first = False
+ return True
+ return False
+
+ def __len__(self):
+ return self.length
+
+ def render(self, curwidth, maxwidth):
+ dobreak = len(self) > (maxwidth - curwidth)
+
+ a = []
+ for x in self.fragments:
+ if isinstance(x, Breakable):
+ if dobreak:
+ a.append('\n')
+ a.append(' ' * x.indent)
+ curwidth = 0
+ else:
+ a.append(x.sep)
+ elif isinstance(x, Group):
+ a.append(x.render(curwidth, maxwidth))
+ else:
+ a.append(x)
+ curwidth += len(a[-1])
+ return ''.join(a)
+
+class Breakable(object):
+ __slots__ = ["sep", "indent"]
+
+ def __init__(self, sep, indent):
+ self.sep = sep
+ self.indent = indent
+
+ def __len__(self):
+ return len(self.sep)
+
+
+## Tests
+
+class TestPP(unittest.TestCase):
+ def test_scalars(self):
+ self.assertEquals(pp(1), "1")
+ self.assertEquals(pp("foo"), "'foo'")
+
+ def test_hash(self):
+ expected = """{ 1: 'a', 'b': 2 }"""
+ self.assertEquals(pp(eval(expected)), expected)
+ expected = """\
+{
+ 1: 'a',
+ 'b': 2
+}"""
+ self.assertEquals(pp(eval(expected), maxwidth=0), expected)
+
+ def test_array(self):
+ expected = """[ 1, 'a', 2 ]"""
+ self.assertEquals(pp(eval(expected)), expected)
+ expected = """\
+[
+ 1,
+ 'a',
+ 2
+]"""
+ self.assertEquals(pp(eval(expected), maxwidth=0), expected)
+
+ def test_nested(self):
+ expected = """[ [ 1, 2 ], [ 3, 4 ] ]"""
+ self.assertEquals(pp(eval(expected)), expected)
+ expected = """\
+[
+ [
+ 1,
+ 2
+ ],
+ [
+ 3,
+ 4
+ ]
+]"""
+ self.assertEquals(pp(eval(expected), maxwidth=0), expected)
+
+ def test_breaking(self):
+ expected = """\
+[
+ [ 1, 2 ],
+ 'abcdefghijklmnopqrstuvwxyz'
+]"""
+ self.assertEquals(pp(eval(expected), maxwidth=24), expected)
+ expected = """\
+[
+ [ 'abcd', 2 ],
+ [ '0123456789' ],
+ [
+ '0123456789',
+ 'abcdefghij'
+ ],
+ [ 'abcdefghijklmnop' ],
+ [
+ 'abcdefghijklmnopq'
+ ],
+ { 'k': 'v' },
+ {
+ 1: [ 2, [ 3, 4 ] ],
+ 'foo': 'abcdefghijklmnop'
+ }
+]"""
+ self.assertEquals(pp(eval(expected), maxwidth=24), expected)
+ expected = """\
+[
+ [ 1, 2 ],
+ [ 3, 4 ]
+]"""
+ self.assertEquals(pp(eval(expected), maxwidth=15), expected)
+
+ # This is an edge case where our simpler algorithm breaks down.
+ @unittest.expectedFailure
+ def test_greedy_breaking(self):
+ expected = """\
+abc def
+ghijklmnopqrstuvwxyz\
+"""
+ pp = PrettyPrinter(maxwidth=8)
+ pp.text("abc")
+ with pp.group():
+ pp.breakable()
+ pp.text("def")
+ with pp.group():
+ pp.breakable()
+ pp.text("ghijklmnopqrstuvwxyz")
+ self.assertEquals(str(pp), expected)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/src/python/of10/__init__.py b/src/python/of10/__init__.py
deleted file mode 100644
index 2810be8..0000000
--- a/src/python/of10/__init__.py
+++ /dev/null
@@ -1,16 +0,0 @@
-"""
-Python OpenFlow 1.0 library
-
-Most of the files in this package are automatically generated by tools/munger.
-They are checked in to simplify running OFTest.
-"""
-
-__all__ = ["action_list", "action", "cstruct", "error", "message", "parse"]
-
-# Allow accessing constants through the top-level module
-from cstruct import *
-
-# Allow accessing submodules without additional imports
-import action
-import message
-import parse
diff --git a/src/python/of10/action.py b/src/python/of10/action.py
deleted file mode 100644
index c478c62..0000000
--- a/src/python/of10/action.py
+++ /dev/null
@@ -1,372 +0,0 @@
-
-# Python OpenFlow action wrapper classes
-
-from cstruct import *
-
-
-
-class vendor(ofp_action_vendor_header):
- """
- Wrapper class for vendor action object
-
- Data members inherited from ofp_action_vendor_header:
- @arg type
- @arg len
- @arg vendor
-
- """
- def __init__(self, **kwargs):
- ofp_action_vendor_header.__init__(self)
- self.type = OFPAT_VENDOR
- self.len = self.__len__()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- def show(self, prefix=''):
- outstr = prefix + "action_vendor\n"
- outstr += ofp_action_vendor_header.show(self, prefix)
- return outstr
-
-action_vendor = vendor # for backwards compatibility
-
-
-class set_tp_dst(ofp_action_tp_port):
- """
- Wrapper class for set_tp_dst action object
-
- Data members inherited from ofp_action_tp_port:
- @arg type
- @arg len
- @arg tp_port
-
- """
- def __init__(self, **kwargs):
- ofp_action_tp_port.__init__(self)
- self.type = OFPAT_SET_TP_DST
- self.len = self.__len__()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- def show(self, prefix=''):
- outstr = prefix + "action_set_tp_dst\n"
- outstr += ofp_action_tp_port.show(self, prefix)
- return outstr
-
-action_set_tp_dst = set_tp_dst # for backwards compatibility
-
-
-class set_vlan_pcp(ofp_action_vlan_pcp):
- """
- Wrapper class for set_vlan_pcp action object
-
- Data members inherited from ofp_action_vlan_pcp:
- @arg type
- @arg len
- @arg vlan_pcp
-
- """
- def __init__(self, **kwargs):
- ofp_action_vlan_pcp.__init__(self)
- self.type = OFPAT_SET_VLAN_PCP
- self.len = self.__len__()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- def show(self, prefix=''):
- outstr = prefix + "action_set_vlan_pcp\n"
- outstr += ofp_action_vlan_pcp.show(self, prefix)
- return outstr
-
-action_set_vlan_pcp = set_vlan_pcp # for backwards compatibility
-
-
-class enqueue(ofp_action_enqueue):
- """
- Wrapper class for enqueue action object
-
- Data members inherited from ofp_action_enqueue:
- @arg type
- @arg len
- @arg port
- @arg queue_id
-
- """
- def __init__(self, **kwargs):
- ofp_action_enqueue.__init__(self)
- self.type = OFPAT_ENQUEUE
- self.len = self.__len__()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- def show(self, prefix=''):
- outstr = prefix + "action_enqueue\n"
- outstr += ofp_action_enqueue.show(self, prefix)
- return outstr
-
-action_enqueue = enqueue # for backwards compatibility
-
-
-class set_tp_src(ofp_action_tp_port):
- """
- Wrapper class for set_tp_src action object
-
- Data members inherited from ofp_action_tp_port:
- @arg type
- @arg len
- @arg tp_port
-
- """
- def __init__(self, **kwargs):
- ofp_action_tp_port.__init__(self)
- self.type = OFPAT_SET_TP_SRC
- self.len = self.__len__()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- def show(self, prefix=''):
- outstr = prefix + "action_set_tp_src\n"
- outstr += ofp_action_tp_port.show(self, prefix)
- return outstr
-
-action_set_tp_src = set_tp_src # for backwards compatibility
-
-
-class set_nw_tos(ofp_action_nw_tos):
- """
- Wrapper class for set_nw_tos action object
-
- Data members inherited from ofp_action_nw_tos:
- @arg type
- @arg len
- @arg nw_tos
-
- """
- def __init__(self, **kwargs):
- ofp_action_nw_tos.__init__(self)
- self.type = OFPAT_SET_NW_TOS
- self.len = self.__len__()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- def show(self, prefix=''):
- outstr = prefix + "action_set_nw_tos\n"
- outstr += ofp_action_nw_tos.show(self, prefix)
- return outstr
-
-action_set_nw_tos = set_nw_tos # for backwards compatibility
-
-
-class set_nw_dst(ofp_action_nw_addr):
- """
- Wrapper class for set_nw_dst action object
-
- Data members inherited from ofp_action_nw_addr:
- @arg type
- @arg len
- @arg nw_addr
-
- """
- def __init__(self, **kwargs):
- ofp_action_nw_addr.__init__(self)
- self.type = OFPAT_SET_NW_DST
- self.len = self.__len__()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- def show(self, prefix=''):
- outstr = prefix + "action_set_nw_dst\n"
- outstr += ofp_action_nw_addr.show(self, prefix)
- return outstr
-
-action_set_nw_dst = set_nw_dst # for backwards compatibility
-
-
-class strip_vlan(ofp_action_header):
- """
- Wrapper class for strip_vlan action object
-
- Data members inherited from ofp_action_header:
- @arg type
- @arg len
-
- """
- def __init__(self, **kwargs):
- ofp_action_header.__init__(self)
- self.type = OFPAT_STRIP_VLAN
- self.len = self.__len__()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- def show(self, prefix=''):
- outstr = prefix + "action_strip_vlan\n"
- outstr += ofp_action_header.show(self, prefix)
- return outstr
-
-action_strip_vlan = strip_vlan # for backwards compatibility
-
-
-class set_dl_dst(ofp_action_dl_addr):
- """
- Wrapper class for set_dl_dst action object
-
- Data members inherited from ofp_action_dl_addr:
- @arg type
- @arg len
- @arg dl_addr
-
- """
- def __init__(self, **kwargs):
- ofp_action_dl_addr.__init__(self)
- self.type = OFPAT_SET_DL_DST
- self.len = self.__len__()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- def show(self, prefix=''):
- outstr = prefix + "action_set_dl_dst\n"
- outstr += ofp_action_dl_addr.show(self, prefix)
- return outstr
-
-action_set_dl_dst = set_dl_dst # for backwards compatibility
-
-
-class set_nw_src(ofp_action_nw_addr):
- """
- Wrapper class for set_nw_src action object
-
- Data members inherited from ofp_action_nw_addr:
- @arg type
- @arg len
- @arg nw_addr
-
- """
- def __init__(self, **kwargs):
- ofp_action_nw_addr.__init__(self)
- self.type = OFPAT_SET_NW_SRC
- self.len = self.__len__()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- def show(self, prefix=''):
- outstr = prefix + "action_set_nw_src\n"
- outstr += ofp_action_nw_addr.show(self, prefix)
- return outstr
-
-action_set_nw_src = set_nw_src # for backwards compatibility
-
-
-class set_vlan_vid(ofp_action_vlan_vid):
- """
- Wrapper class for set_vlan_vid action object
-
- Data members inherited from ofp_action_vlan_vid:
- @arg type
- @arg len
- @arg vlan_vid
-
- """
- def __init__(self, **kwargs):
- ofp_action_vlan_vid.__init__(self)
- self.type = OFPAT_SET_VLAN_VID
- self.len = self.__len__()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- def show(self, prefix=''):
- outstr = prefix + "action_set_vlan_vid\n"
- outstr += ofp_action_vlan_vid.show(self, prefix)
- return outstr
-
-action_set_vlan_vid = set_vlan_vid # for backwards compatibility
-
-
-class set_dl_src(ofp_action_dl_addr):
- """
- Wrapper class for set_dl_src action object
-
- Data members inherited from ofp_action_dl_addr:
- @arg type
- @arg len
- @arg dl_addr
-
- """
- def __init__(self, **kwargs):
- ofp_action_dl_addr.__init__(self)
- self.type = OFPAT_SET_DL_SRC
- self.len = self.__len__()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- def show(self, prefix=''):
- outstr = prefix + "action_set_dl_src\n"
- outstr += ofp_action_dl_addr.show(self, prefix)
- return outstr
-
-action_set_dl_src = set_dl_src # for backwards compatibility
-
-
-class output(ofp_action_output):
- """
- Wrapper class for output action object
-
- Data members inherited from ofp_action_output:
- @arg type
- @arg len
- @arg port
- @arg max_len
-
- """
- def __init__(self, **kwargs):
- ofp_action_output.__init__(self)
- self.type = OFPAT_OUTPUT
- self.len = self.__len__()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- def show(self, prefix=''):
- outstr = prefix + "action_output\n"
- outstr += ofp_action_output.show(self, prefix)
- return outstr
-
-action_output = output # for backwards compatibility
-
-action_class_list = (
- action_vendor,
- action_set_tp_dst,
- action_set_vlan_pcp,
- action_enqueue,
- action_set_tp_src,
- action_set_nw_tos,
- action_set_nw_dst,
- action_strip_vlan,
- action_set_dl_dst,
- action_set_nw_src,
- action_set_vlan_vid,
- action_set_dl_src,
- action_output)
diff --git a/src/python/of10/action_list.py b/src/python/of10/action_list.py
deleted file mode 100644
index fbbddea..0000000
--- a/src/python/of10/action_list.py
+++ /dev/null
@@ -1,189 +0,0 @@
-"""
-OpenFlow actions list class
-"""
-
-from action import *
-from cstruct import ofp_header
-import copy
-
-# # Map OFP action identifiers to the actual structures used on the wire
-# action_object_map = {
-# OFPAT_OUTPUT : ofp_action_output,
-# OFPAT_SET_VLAN_VID : ofp_action_vlan_vid,
-# OFPAT_SET_VLAN_PCP : ofp_action_vlan_pcp,
-# OFPAT_STRIP_VLAN : ofp_action_header,
-# OFPAT_SET_DL_SRC : ofp_action_dl_addr,
-# OFPAT_SET_DL_DST : ofp_action_dl_addr,
-# OFPAT_SET_NW_SRC : ofp_action_nw_addr,
-# OFPAT_SET_NW_DST : ofp_action_nw_addr,
-# OFPAT_SET_NW_TOS : ofp_action_nw_tos,
-# OFPAT_SET_TP_SRC : ofp_action_tp_port,
-# OFPAT_SET_TP_DST : ofp_action_tp_port,
-# OFPAT_ENQUEUE : ofp_action_enqueue
-# }
-
-action_object_map = {
- OFPAT_OUTPUT : action_output,
- OFPAT_SET_VLAN_VID : action_set_vlan_vid,
- OFPAT_SET_VLAN_PCP : action_set_vlan_pcp,
- OFPAT_STRIP_VLAN : action_strip_vlan,
- OFPAT_SET_DL_SRC : action_set_dl_src,
- OFPAT_SET_DL_DST : action_set_dl_dst,
- OFPAT_SET_NW_SRC : action_set_nw_src,
- OFPAT_SET_NW_DST : action_set_nw_dst,
- OFPAT_SET_NW_TOS : action_set_nw_tos,
- OFPAT_SET_TP_SRC : action_set_tp_src,
- OFPAT_SET_TP_DST : action_set_tp_dst,
- OFPAT_ENQUEUE : action_enqueue,
- OFPAT_VENDOR : action_vendor
-}
-
-class action_list(object):
- """
- Maintain a list of actions
-
- Data members:
- @arg actions: An array of action objects such as action_output, etc.
-
- Methods:
- @arg pack: Pack the structure into a string
- @arg unpack: Unpack a string to objects, with proper typing
- @arg add: Add an action to the list; you can directly access
- the action member, but add will validate that the added object
- is an action.
-
- """
-
- def __init__(self, actions=None):
- if actions == None:
- actions = []
- self.actions = actions
-
- def pack(self):
- """
- Pack a list of actions
-
- Returns the packed string
- """
-
- packed = ""
- for act in self.actions:
- packed += act.pack()
- return packed
-
- def unpack(self, binary_string, bytes=None):
- """
- Unpack a list of actions
-
- Unpack actions from a binary string, creating an array
- of objects of the appropriate type
-
- @param binary_string The string to be unpacked
-
- @param bytes The total length of the action list in bytes.
- Ignored if decode is True. If None and decode is false, the
- list is assumed to extend through the entire string.
-
- @return The remainder of binary_string that was not parsed
-
- """
- if bytes == None:
- bytes = len(binary_string)
- bytes_done = 0
- count = 0
- cur_string = binary_string
- while bytes_done < bytes:
- hdr = ofp_action_header()
- hdr.unpack(cur_string)
- if hdr.len < OFP_ACTION_HEADER_BYTES:
- print "ERROR: Action too short"
- break
- if not hdr.type in action_object_map.keys():
- print "WARNING: Skipping unknown action ", hdr.type, hdr.len
- else:
- self.actions.append(action_object_map[hdr.type]())
- self.actions[count].unpack(cur_string)
- count += 1
- cur_string = cur_string[hdr.len:]
- bytes_done += hdr.len
- return cur_string
-
- def add(self, action):
- """
- Add an action to an action list
-
- @param action The action to add
-
- """
- if not isinstance(action, action_class_list):
- raise ValueError("%s is not an action" % type(action))
- self.actions.append(copy.deepcopy(action))
- return True # for backwards compatibility
-
- def remove_type(self, type):
- """
- Remove the first action on the list of the given type
-
- @param type The type of action to search
-
- @return The object removed, if any; otherwise None
-
- """
- for index in xrange(len(self.actions)):
- if self.actions[index].type == type:
- return self.actions.pop(index)
- return None
-
- def find_type(self, type):
- """
- Find the first action on the list of the given type
-
- @param type The type of action to search
-
- @return The object with the matching type if any; otherwise None
-
- """
- for index in xrange(len(self.actions)):
- if self.actions[index].type == type:
- return self.actions[index]
- return None
-
- def extend(self, other):
- """
- Add the actions in other to this list
-
- @param other An object of type action_list whose
- entries are to be merged into this list
-
- @return True if successful. If not successful, the list
- may have been modified.
-
- @todo Check if this is proper deep copy or not
-
- """
- for act in other.actions:
- self.add(act)
- return True # for backwards compatibility
-
- def __len__(self):
- length = 0
- for act in self.actions:
- length += act.__len__()
- return length
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- if self.actions != other.actions: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- outstr = prefix + "Action List with " + str(len(self.actions)) + \
- " actions\n"
- count = 0
- for obj in self.actions:
- count += 1
- outstr += prefix + " Action " + str(count) + ": \n"
- outstr += obj.show(prefix + ' ')
- return outstr
diff --git a/src/python/of10/class_maps.py b/src/python/of10/class_maps.py
deleted file mode 100644
index 19600e6..0000000
--- a/src/python/of10/class_maps.py
+++ /dev/null
@@ -1,249 +0,0 @@
-
-# Class to array member map
-class_to_members_map = {
- 'ofp_phy_port' : [
- 'port_no',
- 'hw_addr',
- 'name',
- 'config',
- 'state',
- 'curr',
- 'advertised',
- 'supported',
- 'peer'
- ],
- 'ofp_aggregate_stats_reply' : [
- 'packet_count',
- 'byte_count',
- 'flow_count'
- ],
- 'ofp_table_stats' : [
- 'table_id',
- 'name',
- 'wildcards',
- 'max_entries',
- 'active_count',
- 'lookup_count',
- 'matched_count'
- ],
- 'ofp_flow_removed' : [
- 'match',
- 'cookie',
- 'priority',
- 'reason',
- 'duration_sec',
- 'duration_nsec',
- 'idle_timeout',
- 'packet_count',
- 'byte_count'
- ],
- 'ofp_port_stats' : [
- 'port_no',
- 'rx_packets',
- 'tx_packets',
- 'rx_bytes',
- 'tx_bytes',
- 'rx_dropped',
- 'tx_dropped',
- 'rx_errors',
- 'tx_errors',
- 'rx_frame_err',
- 'rx_over_err',
- 'rx_crc_err',
- 'collisions'
- ],
- 'ofp_queue_stats' : [
- 'port_no',
- 'queue_id',
- 'tx_bytes',
- 'tx_packets',
- 'tx_errors'
- ],
- 'ofp_action_tp_port' : [
- 'type',
- 'len',
- 'tp_port'
- ],
- 'ofp_port_stats_request' : [
- 'port_no'
- ],
- 'ofp_stats_request' : [
- 'type',
- 'flags'
- ],
- 'ofp_aggregate_stats_request' : [
- 'match',
- 'table_id',
- 'out_port'
- ],
- 'ofp_port_status' : [
- 'reason',
- 'desc'
- ],
- 'ofp_action_header' : [
- 'type',
- 'len'
- ],
- 'ofp_port_mod' : [
- 'port_no',
- 'hw_addr',
- 'config',
- 'mask',
- 'advertise'
- ],
- 'ofp_action_vlan_vid' : [
- 'type',
- 'len',
- 'vlan_vid'
- ],
- 'ofp_action_output' : [
- 'type',
- 'len',
- 'port',
- 'max_len'
- ],
- 'ofp_switch_config' : [
- 'flags',
- 'miss_send_len'
- ],
- 'ofp_action_nw_tos' : [
- 'type',
- 'len',
- 'nw_tos'
- ],
- 'ofp_queue_get_config_reply' : [
- 'port'
- ],
- 'ofp_packet_in' : [
- 'buffer_id',
- 'total_len',
- 'in_port',
- 'reason'
- ],
- 'ofp_flow_stats' : [
- 'length',
- 'table_id',
- 'match',
- 'duration_sec',
- 'duration_nsec',
- 'priority',
- 'idle_timeout',
- 'hard_timeout',
- 'cookie',
- 'packet_count',
- 'byte_count'
- ],
- 'ofp_flow_stats_request' : [
- 'match',
- 'table_id',
- 'out_port'
- ],
- 'ofp_action_vendor_header' : [
- 'type',
- 'len',
- 'vendor'
- ],
- 'ofp_stats_reply' : [
- 'type',
- 'flags'
- ],
- 'ofp_queue_stats_request' : [
- 'port_no',
- 'queue_id'
- ],
- 'ofp_desc_stats' : [
- 'mfr_desc',
- 'hw_desc',
- 'sw_desc',
- 'serial_num',
- 'dp_desc'
- ],
- 'ofp_queue_get_config_request' : [
- 'port'
- ],
- 'ofp_packet_queue' : [
- 'queue_id',
- 'len'
- ],
- 'ofp_action_dl_addr' : [
- 'type',
- 'len',
- 'dl_addr'
- ],
- 'ofp_queue_prop_header' : [
- 'property',
- 'len'
- ],
- 'ofp_queue_prop_min_rate' : [
- 'prop_header',
- 'rate'
- ],
- 'ofp_action_enqueue' : [
- 'type',
- 'len',
- 'port',
- 'queue_id'
- ],
- 'ofp_switch_features' : [
- 'datapath_id',
- 'n_buffers',
- 'n_tables',
- 'capabilities',
- 'actions'
- ],
- 'ofp_match' : [
- 'wildcards',
- 'in_port',
- 'dl_src',
- 'dl_dst',
- 'dl_vlan',
- 'dl_vlan_pcp',
- 'dl_type',
- 'nw_tos',
- 'nw_proto',
- 'nw_src',
- 'nw_dst',
- 'tp_src',
- 'tp_dst'
- ],
- 'ofp_header' : [
- 'version',
- 'type',
- 'length',
- 'xid'
- ],
- 'ofp_vendor_header' : [
- 'vendor'
- ],
- 'ofp_packet_out' : [
- 'buffer_id',
- 'in_port',
- 'actions_len'
- ],
- 'ofp_action_nw_addr' : [
- 'type',
- 'len',
- 'nw_addr'
- ],
- 'ofp_action_vlan_pcp' : [
- 'type',
- 'len',
- 'vlan_pcp'
- ],
- 'ofp_flow_mod' : [
- 'match',
- 'cookie',
- 'command',
- 'idle_timeout',
- 'hard_timeout',
- 'priority',
- 'buffer_id',
- 'out_port',
- 'flags'
- ],
- 'ofp_error_msg' : [
- 'type',
- 'code'
- ],
- '_ignore' : []
-}
diff --git a/src/python/of10/cstruct.py b/src/python/of10/cstruct.py
deleted file mode 100644
index a41e115..0000000
--- a/src/python/of10/cstruct.py
+++ /dev/null
@@ -1,4021 +0,0 @@
-import struct
-
-# Structure definitions
-class ofp_phy_port:
- """Automatically generated Python class for ofp_phy_port
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.port_no = 0
- self.hw_addr= [0,0,0,0,0,0]
- self.name= ""
- self.config = 0
- self.state = 0
- self.curr = 0
- self.advertised = 0
- self.supported = 0
- self.peer = 0
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.hw_addr, list)):
- return (False, "self.hw_addr is not list as expected.")
- if(len(self.hw_addr) != 6):
- return (False, "self.hw_addr is not of size 6 as expected.")
- if(not isinstance(self.name, str)):
- return (False, "self.name is not string as expected.")
- if(len(self.name) > 16):
- return (False, "self.name is not of size 16 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!H", self.port_no)
- packed += struct.pack("!BBBBBB", self.hw_addr[0], self.hw_addr[1], self.hw_addr[2], self.hw_addr[3], self.hw_addr[4], self.hw_addr[5])
- packed += self.name.ljust(16,'\0')
- packed += struct.pack("!LLLLLL", self.config, self.state, self.curr, self.advertised, self.supported, self.peer)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 48):
- return binaryString
- fmt = '!H'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.port_no,) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBBBB'
- start = 2
- end = start + struct.calcsize(fmt)
- (self.hw_addr[0], self.hw_addr[1], self.hw_addr[2], self.hw_addr[3], self.hw_addr[4], self.hw_addr[5]) = struct.unpack(fmt, binaryString[start:end])
- self.name = binaryString[8:24].replace("\0","")
- fmt = '!LLLLLL'
- start = 24
- end = start + struct.calcsize(fmt)
- (self.config, self.state, self.curr, self.advertised, self.supported, self.peer) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[48:]
-
- def __len__(self):
- """Return length of message
- """
- l = 48
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.port_no != other.port_no: return False
- if self.hw_addr != other.hw_addr: return False
- if self.name != other.name: return False
- if self.config != other.config: return False
- if self.state != other.state: return False
- if self.curr != other.curr: return False
- if self.advertised != other.advertised: return False
- if self.supported != other.supported: return False
- if self.peer != other.peer: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'port_no: ' + str(self.port_no) + '\n'
- outstr += prefix + 'hw_addr: ' + str(self.hw_addr) + '\n'
- outstr += prefix + 'name: ' + str(self.name) + '\n'
- outstr += prefix + 'config: ' + str(self.config) + '\n'
- outstr += prefix + 'state: ' + str(self.state) + '\n'
- outstr += prefix + 'curr: ' + str(self.curr) + '\n'
- outstr += prefix + 'advertised: ' + str(self.advertised) + '\n'
- outstr += prefix + 'supported: ' + str(self.supported) + '\n'
- outstr += prefix + 'peer: ' + str(self.peer) + '\n'
- return outstr
-
-
-class ofp_aggregate_stats_reply:
- """Automatically generated Python class for ofp_aggregate_stats_reply
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.packet_count = 0
- self.byte_count = 0
- self.flow_count = 0
- self.pad= [0,0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 4):
- return (False, "self.pad is not of size 4 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!QQL", self.packet_count, self.byte_count, self.flow_count)
- packed += struct.pack("!BBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 24):
- return binaryString
- fmt = '!QQL'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.packet_count, self.byte_count, self.flow_count) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 20
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[24:]
-
- def __len__(self):
- """Return length of message
- """
- l = 24
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.packet_count != other.packet_count: return False
- if self.byte_count != other.byte_count: return False
- if self.flow_count != other.flow_count: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'packet_count: ' + str(self.packet_count) + '\n'
- outstr += prefix + 'byte_count: ' + str(self.byte_count) + '\n'
- outstr += prefix + 'flow_count: ' + str(self.flow_count) + '\n'
- return outstr
-
-
-class ofp_table_stats:
- """Automatically generated Python class for ofp_table_stats
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.table_id = 0
- self.pad= [0,0,0]
- self.name= ""
- self.wildcards = 0
- self.max_entries = 0
- self.active_count = 0
- self.lookup_count = 0
- self.matched_count = 0
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 3):
- return (False, "self.pad is not of size 3 as expected.")
- if(not isinstance(self.name, str)):
- return (False, "self.name is not string as expected.")
- if(len(self.name) > 32):
- return (False, "self.name is not of size 32 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!B", self.table_id)
- packed += struct.pack("!BBB", self.pad[0], self.pad[1], self.pad[2])
- packed += self.name.ljust(32,'\0')
- packed += struct.pack("!LLLQQ", self.wildcards, self.max_entries, self.active_count, self.lookup_count, self.matched_count)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 64):
- return binaryString
- fmt = '!B'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.table_id,) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBB'
- start = 1
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2]) = struct.unpack(fmt, binaryString[start:end])
- self.name = binaryString[4:36].replace("\0","")
- fmt = '!LLLQQ'
- start = 36
- end = start + struct.calcsize(fmt)
- (self.wildcards, self.max_entries, self.active_count, self.lookup_count, self.matched_count) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[64:]
-
- def __len__(self):
- """Return length of message
- """
- l = 64
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.table_id != other.table_id: return False
- if self.pad != other.pad: return False
- if self.name != other.name: return False
- if self.wildcards != other.wildcards: return False
- if self.max_entries != other.max_entries: return False
- if self.active_count != other.active_count: return False
- if self.lookup_count != other.lookup_count: return False
- if self.matched_count != other.matched_count: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'table_id: ' + str(self.table_id) + '\n'
- outstr += prefix + 'name: ' + str(self.name) + '\n'
- outstr += prefix + 'wildcards: ' + str(self.wildcards) + '\n'
- outstr += prefix + 'max_entries: ' + str(self.max_entries) + '\n'
- outstr += prefix + 'active_count: ' + str(self.active_count) + '\n'
- outstr += prefix + 'lookup_count: ' + str(self.lookup_count) + '\n'
- outstr += prefix + 'matched_count: ' + str(self.matched_count) + '\n'
- return outstr
-
-
-class ofp_flow_removed:
- """Automatically generated Python class for ofp_flow_removed
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.match = ofp_match()
- self.cookie = 0
- self.priority = 0
- self.reason = 0
- self.pad = 0
- self.duration_sec = 0
- self.duration_nsec = 0
- self.idle_timeout = 0
- self.pad2= [0,0]
- self.packet_count = 0
- self.byte_count = 0
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.match, ofp_match)):
- return (False, "self.match is not class ofp_match as expected.")
- if(not isinstance(self.pad2, list)):
- return (False, "self.pad2 is not list as expected.")
- if(len(self.pad2) != 2):
- return (False, "self.pad2 is not of size 2 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += self.match.pack()
- packed += struct.pack("!QHBBLLH", self.cookie, self.priority, self.reason, self.pad, self.duration_sec, self.duration_nsec, self.idle_timeout)
- packed += struct.pack("!BB", self.pad2[0], self.pad2[1])
- packed += struct.pack("!QQ", self.packet_count, self.byte_count)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 80):
- return binaryString
- self.match.unpack(binaryString[0:])
- fmt = '!QHBBLLH'
- start = 40
- end = start + struct.calcsize(fmt)
- (self.cookie, self.priority, self.reason, self.pad, self.duration_sec, self.duration_nsec, self.idle_timeout) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BB'
- start = 62
- end = start + struct.calcsize(fmt)
- (self.pad2[0], self.pad2[1]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!QQ'
- start = 64
- end = start + struct.calcsize(fmt)
- (self.packet_count, self.byte_count) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[80:]
-
- def __len__(self):
- """Return length of message
- """
- l = 80
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.match != other.match: return False
- if self.cookie != other.cookie: return False
- if self.priority != other.priority: return False
- if self.reason != other.reason: return False
- if self.pad != other.pad: return False
- if self.duration_sec != other.duration_sec: return False
- if self.duration_nsec != other.duration_nsec: return False
- if self.idle_timeout != other.idle_timeout: return False
- if self.pad2 != other.pad2: return False
- if self.packet_count != other.packet_count: return False
- if self.byte_count != other.byte_count: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'match: \n'
- outstr += self.match.show(prefix + ' ')
- outstr += prefix + 'cookie: ' + str(self.cookie) + '\n'
- outstr += prefix + 'priority: ' + str(self.priority) + '\n'
- outstr += prefix + 'reason: ' + str(self.reason) + '\n'
- outstr += prefix + 'duration_sec: ' + str(self.duration_sec) + '\n'
- outstr += prefix + 'duration_nsec: ' + str(self.duration_nsec) + '\n'
- outstr += prefix + 'idle_timeout: ' + str(self.idle_timeout) + '\n'
- outstr += prefix + 'packet_count: ' + str(self.packet_count) + '\n'
- outstr += prefix + 'byte_count: ' + str(self.byte_count) + '\n'
- return outstr
-
-
-class ofp_port_stats:
- """Automatically generated Python class for ofp_port_stats
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.port_no = 0
- self.pad= [0,0,0,0,0,0]
- self.rx_packets = 0
- self.tx_packets = 0
- self.rx_bytes = 0
- self.tx_bytes = 0
- self.rx_dropped = 0
- self.tx_dropped = 0
- self.rx_errors = 0
- self.tx_errors = 0
- self.rx_frame_err = 0
- self.rx_over_err = 0
- self.rx_crc_err = 0
- self.collisions = 0
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 6):
- return (False, "self.pad is not of size 6 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!H", self.port_no)
- packed += struct.pack("!BBBBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3], self.pad[4], self.pad[5])
- packed += struct.pack("!QQQQQQQQQQQQ", self.rx_packets, self.tx_packets, self.rx_bytes, self.tx_bytes, self.rx_dropped, self.tx_dropped, self.rx_errors, self.tx_errors, self.rx_frame_err, self.rx_over_err, self.rx_crc_err, self.collisions)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 104):
- return binaryString
- fmt = '!H'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.port_no,) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBBBB'
- start = 2
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3], self.pad[4], self.pad[5]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!QQQQQQQQQQQQ'
- start = 8
- end = start + struct.calcsize(fmt)
- (self.rx_packets, self.tx_packets, self.rx_bytes, self.tx_bytes, self.rx_dropped, self.tx_dropped, self.rx_errors, self.tx_errors, self.rx_frame_err, self.rx_over_err, self.rx_crc_err, self.collisions) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[104:]
-
- def __len__(self):
- """Return length of message
- """
- l = 104
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.port_no != other.port_no: return False
- if self.pad != other.pad: return False
- if self.rx_packets != other.rx_packets: return False
- if self.tx_packets != other.tx_packets: return False
- if self.rx_bytes != other.rx_bytes: return False
- if self.tx_bytes != other.tx_bytes: return False
- if self.rx_dropped != other.rx_dropped: return False
- if self.tx_dropped != other.tx_dropped: return False
- if self.rx_errors != other.rx_errors: return False
- if self.tx_errors != other.tx_errors: return False
- if self.rx_frame_err != other.rx_frame_err: return False
- if self.rx_over_err != other.rx_over_err: return False
- if self.rx_crc_err != other.rx_crc_err: return False
- if self.collisions != other.collisions: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'port_no: ' + str(self.port_no) + '\n'
- outstr += prefix + 'rx_packets: ' + str(self.rx_packets) + '\n'
- outstr += prefix + 'tx_packets: ' + str(self.tx_packets) + '\n'
- outstr += prefix + 'rx_bytes: ' + str(self.rx_bytes) + '\n'
- outstr += prefix + 'tx_bytes: ' + str(self.tx_bytes) + '\n'
- outstr += prefix + 'rx_dropped: ' + str(self.rx_dropped) + '\n'
- outstr += prefix + 'tx_dropped: ' + str(self.tx_dropped) + '\n'
- outstr += prefix + 'rx_errors: ' + str(self.rx_errors) + '\n'
- outstr += prefix + 'tx_errors: ' + str(self.tx_errors) + '\n'
- outstr += prefix + 'rx_frame_err: ' + str(self.rx_frame_err) + '\n'
- outstr += prefix + 'rx_over_err: ' + str(self.rx_over_err) + '\n'
- outstr += prefix + 'rx_crc_err: ' + str(self.rx_crc_err) + '\n'
- outstr += prefix + 'collisions: ' + str(self.collisions) + '\n'
- return outstr
-
-
-class ofp_queue_stats:
- """Automatically generated Python class for ofp_queue_stats
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.port_no = 0
- self.pad= [0,0]
- self.queue_id = 0
- self.tx_bytes = 0
- self.tx_packets = 0
- self.tx_errors = 0
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 2):
- return (False, "self.pad is not of size 2 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!H", self.port_no)
- packed += struct.pack("!BB", self.pad[0], self.pad[1])
- packed += struct.pack("!LQQQ", self.queue_id, self.tx_bytes, self.tx_packets, self.tx_errors)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 32):
- return binaryString
- fmt = '!H'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.port_no,) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BB'
- start = 2
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!LQQQ'
- start = 4
- end = start + struct.calcsize(fmt)
- (self.queue_id, self.tx_bytes, self.tx_packets, self.tx_errors) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[32:]
-
- def __len__(self):
- """Return length of message
- """
- l = 32
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.port_no != other.port_no: return False
- if self.pad != other.pad: return False
- if self.queue_id != other.queue_id: return False
- if self.tx_bytes != other.tx_bytes: return False
- if self.tx_packets != other.tx_packets: return False
- if self.tx_errors != other.tx_errors: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'port_no: ' + str(self.port_no) + '\n'
- outstr += prefix + 'queue_id: ' + str(self.queue_id) + '\n'
- outstr += prefix + 'tx_bytes: ' + str(self.tx_bytes) + '\n'
- outstr += prefix + 'tx_packets: ' + str(self.tx_packets) + '\n'
- outstr += prefix + 'tx_errors: ' + str(self.tx_errors) + '\n'
- return outstr
-
-
-class ofp_action_tp_port:
- """Automatically generated Python class for ofp_action_tp_port
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.tp_port = 0
- self.pad= [0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 2):
- return (False, "self.pad is not of size 2 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HHH", self.type, self.len, self.tp_port)
- packed += struct.pack("!BB", self.pad[0], self.pad[1])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HHH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len, self.tp_port) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BB'
- start = 6
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.tp_port != other.tp_port: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- outstr += prefix + 'tp_port: ' + str(self.tp_port) + '\n'
- return outstr
-
-
-class ofp_port_stats_request:
- """Automatically generated Python class for ofp_port_stats_request
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.port_no = 0
- self.pad= [0,0,0,0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 6):
- return (False, "self.pad is not of size 6 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!H", self.port_no)
- packed += struct.pack("!BBBBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3], self.pad[4], self.pad[5])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!H'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.port_no,) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBBBB'
- start = 2
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3], self.pad[4], self.pad[5]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.port_no != other.port_no: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'port_no: ' + str(self.port_no) + '\n'
- return outstr
-
-
-class ofp_stats_request:
- """Automatically generated Python class for ofp_stats_request
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.flags = 0
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HH", self.type, self.flags)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 4):
- return binaryString
- fmt = '!HH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.flags) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[4:]
-
- def __len__(self):
- """Return length of message
- """
- l = 4
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.flags != other.flags: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'flags: ' + str(self.flags) + '\n'
- return outstr
-
-
-class ofp_hello:
- """Automatically generated Python class for ofp_hello
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 0):
- return binaryString
- return binaryString[0:]
-
- def __len__(self):
- """Return length of message
- """
- l = 0
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- return outstr
-
-
-class ofp_aggregate_stats_request:
- """Automatically generated Python class for ofp_aggregate_stats_request
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.match = ofp_match()
- self.table_id = 0
- self.pad = 0
- self.out_port = 0
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.match, ofp_match)):
- return (False, "self.match is not class ofp_match as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += self.match.pack()
- packed += struct.pack("!BBH", self.table_id, self.pad, self.out_port)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 44):
- return binaryString
- self.match.unpack(binaryString[0:])
- fmt = '!BBH'
- start = 40
- end = start + struct.calcsize(fmt)
- (self.table_id, self.pad, self.out_port) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[44:]
-
- def __len__(self):
- """Return length of message
- """
- l = 44
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.match != other.match: return False
- if self.table_id != other.table_id: return False
- if self.pad != other.pad: return False
- if self.out_port != other.out_port: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'match: \n'
- outstr += self.match.show(prefix + ' ')
- outstr += prefix + 'table_id: ' + str(self.table_id) + '\n'
- outstr += prefix + 'out_port: ' + str(self.out_port) + '\n'
- return outstr
-
-
-class ofp_port_status:
- """Automatically generated Python class for ofp_port_status
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.reason = 0
- self.pad= [0,0,0,0,0,0,0]
- self.desc = ofp_phy_port()
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 7):
- return (False, "self.pad is not of size 7 as expected.")
- if(not isinstance(self.desc, ofp_phy_port)):
- return (False, "self.desc is not class ofp_phy_port as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!B", self.reason)
- packed += struct.pack("!BBBBBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3], self.pad[4], self.pad[5], self.pad[6])
- packed += self.desc.pack()
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 56):
- return binaryString
- fmt = '!B'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.reason,) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBBBBB'
- start = 1
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3], self.pad[4], self.pad[5], self.pad[6]) = struct.unpack(fmt, binaryString[start:end])
- self.desc.unpack(binaryString[8:])
- return binaryString[56:]
-
- def __len__(self):
- """Return length of message
- """
- l = 56
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.reason != other.reason: return False
- if self.pad != other.pad: return False
- if self.desc != other.desc: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'reason: ' + str(self.reason) + '\n'
- outstr += prefix + 'desc: \n'
- outstr += self.desc.show(prefix + ' ')
- return outstr
-
-
-class ofp_action_header:
- """Automatically generated Python class for ofp_action_header
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.pad= [0,0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 4):
- return (False, "self.pad is not of size 4 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HH", self.type, self.len)
- packed += struct.pack("!BBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 4
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- return outstr
-
-
-class ofp_port_mod:
- """Automatically generated Python class for ofp_port_mod
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.port_no = 0
- self.hw_addr= [0,0,0,0,0,0]
- self.config = 0
- self.mask = 0
- self.advertise = 0
- self.pad= [0,0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.hw_addr, list)):
- return (False, "self.hw_addr is not list as expected.")
- if(len(self.hw_addr) != 6):
- return (False, "self.hw_addr is not of size 6 as expected.")
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 4):
- return (False, "self.pad is not of size 4 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!H", self.port_no)
- packed += struct.pack("!BBBBBB", self.hw_addr[0], self.hw_addr[1], self.hw_addr[2], self.hw_addr[3], self.hw_addr[4], self.hw_addr[5])
- packed += struct.pack("!LLL", self.config, self.mask, self.advertise)
- packed += struct.pack("!BBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 24):
- return binaryString
- fmt = '!H'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.port_no,) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBBBB'
- start = 2
- end = start + struct.calcsize(fmt)
- (self.hw_addr[0], self.hw_addr[1], self.hw_addr[2], self.hw_addr[3], self.hw_addr[4], self.hw_addr[5]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!LLL'
- start = 8
- end = start + struct.calcsize(fmt)
- (self.config, self.mask, self.advertise) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 20
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[24:]
-
- def __len__(self):
- """Return length of message
- """
- l = 24
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.port_no != other.port_no: return False
- if self.hw_addr != other.hw_addr: return False
- if self.config != other.config: return False
- if self.mask != other.mask: return False
- if self.advertise != other.advertise: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'port_no: ' + str(self.port_no) + '\n'
- outstr += prefix + 'hw_addr: ' + str(self.hw_addr) + '\n'
- outstr += prefix + 'config: ' + str(self.config) + '\n'
- outstr += prefix + 'mask: ' + str(self.mask) + '\n'
- outstr += prefix + 'advertise: ' + str(self.advertise) + '\n'
- return outstr
-
-
-class ofp_action_vlan_vid:
- """Automatically generated Python class for ofp_action_vlan_vid
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.vlan_vid = 0
- self.pad= [0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 2):
- return (False, "self.pad is not of size 2 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HHH", self.type, self.len, self.vlan_vid)
- packed += struct.pack("!BB", self.pad[0], self.pad[1])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HHH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len, self.vlan_vid) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BB'
- start = 6
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.vlan_vid != other.vlan_vid: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- outstr += prefix + 'vlan_vid: ' + str(self.vlan_vid) + '\n'
- return outstr
-
-
-class ofp_action_output:
- """Automatically generated Python class for ofp_action_output
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.port = 0
- self.max_len = 0
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HHHH", self.type, self.len, self.port, self.max_len)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HHHH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len, self.port, self.max_len) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.port != other.port: return False
- if self.max_len != other.max_len: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- outstr += prefix + 'port: ' + str(self.port) + '\n'
- outstr += prefix + 'max_len: ' + str(self.max_len) + '\n'
- return outstr
-
-
-class ofp_switch_config:
- """Automatically generated Python class for ofp_switch_config
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.flags = 0
- self.miss_send_len = 128
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HH", self.flags, self.miss_send_len)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 4):
- return binaryString
- fmt = '!HH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.flags, self.miss_send_len) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[4:]
-
- def __len__(self):
- """Return length of message
- """
- l = 4
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): 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 show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'flags: ' + str(self.flags) + '\n'
- outstr += prefix + 'miss_send_len: ' + str(self.miss_send_len) + '\n'
- return outstr
-
-
-class ofp_action_nw_tos:
- """Automatically generated Python class for ofp_action_nw_tos
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.nw_tos = 0
- self.pad= [0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 3):
- return (False, "self.pad is not of size 3 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HHB", self.type, self.len, self.nw_tos)
- packed += struct.pack("!BBB", self.pad[0], self.pad[1], self.pad[2])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HHB'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len, self.nw_tos) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBB'
- start = 5
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.nw_tos != other.nw_tos: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- outstr += prefix + 'nw_tos: ' + str(self.nw_tos) + '\n'
- return outstr
-
-
-class ofp_queue_get_config_reply:
- """Automatically generated Python class for ofp_queue_get_config_reply
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.port = 0
- self.pad= [0,0,0,0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 6):
- return (False, "self.pad is not of size 6 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!H", self.port)
- packed += struct.pack("!BBBBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3], self.pad[4], self.pad[5])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!H'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.port,) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBBBB'
- start = 2
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3], self.pad[4], self.pad[5]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.port != other.port: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'port: ' + str(self.port) + '\n'
- return outstr
-
-
-class ofp_packet_in:
- """Automatically generated Python class for ofp_packet_in
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.buffer_id = 0
- self.total_len = 0
- self.in_port = 0
- self.reason = 0
- self.pad = 0
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!LHHBB", self.buffer_id, self.total_len, self.in_port, self.reason, self.pad)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 10):
- return binaryString
- fmt = '!LHHBB'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.buffer_id, self.total_len, self.in_port, self.reason, self.pad) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[10:]
-
- def __len__(self):
- """Return length of message
- """
- l = 10
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.buffer_id != other.buffer_id: return False
- if self.total_len != other.total_len: return False
- if self.in_port != other.in_port: return False
- if self.reason != other.reason: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'buffer_id: ' + str(self.buffer_id) + '\n'
- outstr += prefix + 'total_len: ' + str(self.total_len) + '\n'
- outstr += prefix + 'in_port: ' + str(self.in_port) + '\n'
- outstr += prefix + 'reason: ' + str(self.reason) + '\n'
- return outstr
-
-
-class ofp_flow_stats:
- """Automatically generated Python class for ofp_flow_stats
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.length = 0
- self.table_id = 0
- self.pad = 0
- self.match = ofp_match()
- self.duration_sec = 0
- self.duration_nsec = 0
- self.priority = 0x8000
- self.idle_timeout = 0
- self.hard_timeout = 0
- self.pad2= [0,0,0,0,0,0]
- self.cookie = 0
- self.packet_count = 0
- self.byte_count = 0
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.match, ofp_match)):
- return (False, "self.match is not class ofp_match as expected.")
- if(not isinstance(self.pad2, list)):
- return (False, "self.pad2 is not list as expected.")
- if(len(self.pad2) != 6):
- return (False, "self.pad2 is not of size 6 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HBB", self.length, self.table_id, self.pad)
- packed += self.match.pack()
- packed += struct.pack("!LLHHH", self.duration_sec, self.duration_nsec, self.priority, self.idle_timeout, self.hard_timeout)
- packed += struct.pack("!BBBBBB", self.pad2[0], self.pad2[1], self.pad2[2], self.pad2[3], self.pad2[4], self.pad2[5])
- packed += struct.pack("!QQQ", self.cookie, self.packet_count, self.byte_count)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 88):
- return binaryString
- fmt = '!HBB'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.length, self.table_id, self.pad) = struct.unpack(fmt, binaryString[start:end])
- self.match.unpack(binaryString[4:])
- fmt = '!LLHHH'
- start = 44
- end = start + struct.calcsize(fmt)
- (self.duration_sec, self.duration_nsec, self.priority, self.idle_timeout, self.hard_timeout) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBBBB'
- start = 58
- end = start + struct.calcsize(fmt)
- (self.pad2[0], self.pad2[1], self.pad2[2], self.pad2[3], self.pad2[4], self.pad2[5]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!QQQ'
- start = 64
- end = start + struct.calcsize(fmt)
- (self.cookie, self.packet_count, self.byte_count) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[88:]
-
- def __len__(self):
- """Return length of message
- """
- l = 88
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.length != other.length: return False
- if self.table_id != other.table_id: return False
- if self.pad != other.pad: return False
- if self.match != other.match: return False
- if self.duration_sec != other.duration_sec: return False
- if self.duration_nsec != other.duration_nsec: return False
- if self.priority != other.priority: return False
- if self.idle_timeout != other.idle_timeout: return False
- if self.hard_timeout != other.hard_timeout: return False
- if self.pad2 != other.pad2: return False
- if self.cookie != other.cookie: return False
- if self.packet_count != other.packet_count: return False
- if self.byte_count != other.byte_count: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'length: ' + str(self.length) + '\n'
- outstr += prefix + 'table_id: ' + str(self.table_id) + '\n'
- outstr += prefix + 'match: \n'
- outstr += self.match.show(prefix + ' ')
- outstr += prefix + 'duration_sec: ' + str(self.duration_sec) + '\n'
- outstr += prefix + 'duration_nsec: ' + str(self.duration_nsec) + '\n'
- outstr += prefix + 'priority: ' + str(self.priority) + '\n'
- outstr += prefix + 'idle_timeout: ' + str(self.idle_timeout) + '\n'
- outstr += prefix + 'hard_timeout: ' + str(self.hard_timeout) + '\n'
- outstr += prefix + 'cookie: ' + str(self.cookie) + '\n'
- outstr += prefix + 'packet_count: ' + str(self.packet_count) + '\n'
- outstr += prefix + 'byte_count: ' + str(self.byte_count) + '\n'
- return outstr
-
-
-class ofp_flow_stats_request:
- """Automatically generated Python class for ofp_flow_stats_request
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.match = ofp_match()
- self.table_id = 0
- self.pad = 0
- self.out_port = 0
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.match, ofp_match)):
- return (False, "self.match is not class ofp_match as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += self.match.pack()
- packed += struct.pack("!BBH", self.table_id, self.pad, self.out_port)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 44):
- return binaryString
- self.match.unpack(binaryString[0:])
- fmt = '!BBH'
- start = 40
- end = start + struct.calcsize(fmt)
- (self.table_id, self.pad, self.out_port) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[44:]
-
- def __len__(self):
- """Return length of message
- """
- l = 44
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.match != other.match: return False
- if self.table_id != other.table_id: return False
- if self.pad != other.pad: return False
- if self.out_port != other.out_port: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'match: \n'
- outstr += self.match.show(prefix + ' ')
- outstr += prefix + 'table_id: ' + str(self.table_id) + '\n'
- outstr += prefix + 'out_port: ' + str(self.out_port) + '\n'
- return outstr
-
-
-class ofp_action_vendor_header:
- """Automatically generated Python class for ofp_action_vendor_header
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.vendor = 0
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HHL", self.type, self.len, self.vendor)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HHL'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len, self.vendor) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.vendor != other.vendor: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- outstr += prefix + 'vendor: ' + str(self.vendor) + '\n'
- return outstr
-
-
-class ofp_stats_reply:
- """Automatically generated Python class for ofp_stats_reply
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.flags = 0
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HH", self.type, self.flags)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 4):
- return binaryString
- fmt = '!HH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.flags) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[4:]
-
- def __len__(self):
- """Return length of message
- """
- l = 4
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.flags != other.flags: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'flags: ' + str(self.flags) + '\n'
- return outstr
-
-
-class ofp_queue_stats_request:
- """Automatically generated Python class for ofp_queue_stats_request
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.port_no = 0
- self.pad= [0,0]
- self.queue_id = 0
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 2):
- return (False, "self.pad is not of size 2 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!H", self.port_no)
- packed += struct.pack("!BB", self.pad[0], self.pad[1])
- packed += struct.pack("!L", self.queue_id)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!H'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.port_no,) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BB'
- start = 2
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!L'
- start = 4
- end = start + struct.calcsize(fmt)
- (self.queue_id,) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.port_no != other.port_no: return False
- if self.pad != other.pad: return False
- if self.queue_id != other.queue_id: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'port_no: ' + str(self.port_no) + '\n'
- outstr += prefix + 'queue_id: ' + str(self.queue_id) + '\n'
- return outstr
-
-
-class ofp_desc_stats:
- """Automatically generated Python class for ofp_desc_stats
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.mfr_desc= ""
- self.hw_desc= ""
- self.sw_desc= ""
- self.serial_num= ""
- self.dp_desc= ""
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.mfr_desc, str)):
- return (False, "self.mfr_desc is not string as expected.")
- if(len(self.mfr_desc) > 256):
- return (False, "self.mfr_desc is not of size 256 as expected.")
- if(not isinstance(self.hw_desc, str)):
- return (False, "self.hw_desc is not string as expected.")
- if(len(self.hw_desc) > 256):
- return (False, "self.hw_desc is not of size 256 as expected.")
- if(not isinstance(self.sw_desc, str)):
- return (False, "self.sw_desc is not string as expected.")
- if(len(self.sw_desc) > 256):
- return (False, "self.sw_desc is not of size 256 as expected.")
- if(not isinstance(self.serial_num, str)):
- return (False, "self.serial_num is not string as expected.")
- if(len(self.serial_num) > 32):
- return (False, "self.serial_num is not of size 32 as expected.")
- if(not isinstance(self.dp_desc, str)):
- return (False, "self.dp_desc is not string as expected.")
- if(len(self.dp_desc) > 256):
- return (False, "self.dp_desc is not of size 256 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += self.mfr_desc.ljust(256,'\0')
- packed += self.hw_desc.ljust(256,'\0')
- packed += self.sw_desc.ljust(256,'\0')
- packed += self.serial_num.ljust(32,'\0')
- packed += self.dp_desc.ljust(256,'\0')
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 1056):
- return binaryString
- self.mfr_desc = binaryString[0:256].replace("\0","")
- self.hw_desc = binaryString[256:512].replace("\0","")
- self.sw_desc = binaryString[512:768].replace("\0","")
- self.serial_num = binaryString[768:800].replace("\0","")
- self.dp_desc = binaryString[800:1056].replace("\0","")
- return binaryString[1056:]
-
- def __len__(self):
- """Return length of message
- """
- l = 1056
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.mfr_desc != other.mfr_desc: return False
- if self.hw_desc != other.hw_desc: return False
- if self.sw_desc != other.sw_desc: return False
- if self.serial_num != other.serial_num: return False
- if self.dp_desc != other.dp_desc: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'mfr_desc: ' + str(self.mfr_desc) + '\n'
- outstr += prefix + 'hw_desc: ' + str(self.hw_desc) + '\n'
- outstr += prefix + 'sw_desc: ' + str(self.sw_desc) + '\n'
- outstr += prefix + 'serial_num: ' + str(self.serial_num) + '\n'
- outstr += prefix + 'dp_desc: ' + str(self.dp_desc) + '\n'
- return outstr
-
-
-class ofp_queue_get_config_request:
- """Automatically generated Python class for ofp_queue_get_config_request
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.port = 0
- self.pad= [0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 2):
- return (False, "self.pad is not of size 2 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!H", self.port)
- packed += struct.pack("!BB", self.pad[0], self.pad[1])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 4):
- return binaryString
- fmt = '!H'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.port,) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BB'
- start = 2
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[4:]
-
- def __len__(self):
- """Return length of message
- """
- l = 4
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.port != other.port: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'port: ' + str(self.port) + '\n'
- return outstr
-
-
-class ofp_packet_queue:
- """Automatically generated Python class for ofp_packet_queue
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.queue_id = 0
- self.len = 0
- self.pad= [0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 2):
- return (False, "self.pad is not of size 2 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!LH", self.queue_id, self.len)
- packed += struct.pack("!BB", self.pad[0], self.pad[1])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!LH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.queue_id, self.len) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BB'
- start = 6
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.queue_id != other.queue_id: return False
- if self.len != other.len: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'queue_id: ' + str(self.queue_id) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- return outstr
-
-
-class ofp_action_dl_addr:
- """Automatically generated Python class for ofp_action_dl_addr
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.dl_addr= [0,0,0,0,0,0]
- self.pad= [0,0,0,0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.dl_addr, list)):
- return (False, "self.dl_addr is not list as expected.")
- if(len(self.dl_addr) != 6):
- return (False, "self.dl_addr is not of size 6 as expected.")
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 6):
- return (False, "self.pad is not of size 6 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HH", self.type, self.len)
- packed += struct.pack("!BBBBBB", self.dl_addr[0], self.dl_addr[1], self.dl_addr[2], self.dl_addr[3], self.dl_addr[4], self.dl_addr[5])
- packed += struct.pack("!BBBBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3], self.pad[4], self.pad[5])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 16):
- return binaryString
- fmt = '!HH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBBBB'
- start = 4
- end = start + struct.calcsize(fmt)
- (self.dl_addr[0], self.dl_addr[1], self.dl_addr[2], self.dl_addr[3], self.dl_addr[4], self.dl_addr[5]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBBBB'
- start = 10
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3], self.pad[4], self.pad[5]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[16:]
-
- def __len__(self):
- """Return length of message
- """
- l = 16
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.dl_addr != other.dl_addr: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- outstr += prefix + 'dl_addr: ' + str(self.dl_addr) + '\n'
- return outstr
-
-
-class ofp_queue_prop_header:
- """Automatically generated Python class for ofp_queue_prop_header
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.property = 0
- self.len = 0
- self.pad= [0,0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 4):
- return (False, "self.pad is not of size 4 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HH", self.property, self.len)
- packed += struct.pack("!BBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.property, self.len) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 4
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.property != other.property: return False
- if self.len != other.len: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'property: ' + str(self.property) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- return outstr
-
-
-class ofp_queue_prop_min_rate:
- """Automatically generated Python class for ofp_queue_prop_min_rate
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.prop_header = ofp_queue_prop_header()
- self.rate = 0
- self.pad= [0,0,0,0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.prop_header, ofp_queue_prop_header)):
- return (False, "self.prop_header is not class ofp_queue_prop_header as expected.")
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 6):
- return (False, "self.pad is not of size 6 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += self.prop_header.pack()
- packed += struct.pack("!H", self.rate)
- packed += struct.pack("!BBBBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3], self.pad[4], self.pad[5])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 16):
- return binaryString
- self.prop_header.unpack(binaryString[0:])
- fmt = '!H'
- start = 8
- end = start + struct.calcsize(fmt)
- (self.rate,) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBBBB'
- start = 10
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3], self.pad[4], self.pad[5]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[16:]
-
- def __len__(self):
- """Return length of message
- """
- l = 16
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.prop_header != other.prop_header: return False
- if self.rate != other.rate: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'prop_header: \n'
- outstr += self.prop_header.show(prefix + ' ')
- outstr += prefix + 'rate: ' + str(self.rate) + '\n'
- return outstr
-
-
-class ofp_action_enqueue:
- """Automatically generated Python class for ofp_action_enqueue
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.port = 0
- self.pad= [0,0,0,0,0,0]
- self.queue_id = 0
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 6):
- return (False, "self.pad is not of size 6 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HHH", self.type, self.len, self.port)
- packed += struct.pack("!BBBBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3], self.pad[4], self.pad[5])
- packed += struct.pack("!L", self.queue_id)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 16):
- return binaryString
- fmt = '!HHH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len, self.port) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBBBB'
- start = 6
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3], self.pad[4], self.pad[5]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!L'
- start = 12
- end = start + struct.calcsize(fmt)
- (self.queue_id,) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[16:]
-
- def __len__(self):
- """Return length of message
- """
- l = 16
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.port != other.port: return False
- if self.pad != other.pad: return False
- if self.queue_id != other.queue_id: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- outstr += prefix + 'port: ' + str(self.port) + '\n'
- outstr += prefix + 'queue_id: ' + str(self.queue_id) + '\n'
- return outstr
-
-
-class ofp_switch_features:
- """Automatically generated Python class for ofp_switch_features
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.datapath_id = 0
- self.n_buffers = 0
- self.n_tables = 0
- self.pad= [0,0,0]
- self.capabilities = 0
- self.actions = 0
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 3):
- return (False, "self.pad is not of size 3 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!QLB", self.datapath_id, self.n_buffers, self.n_tables)
- packed += struct.pack("!BBB", self.pad[0], self.pad[1], self.pad[2])
- packed += struct.pack("!LL", self.capabilities, self.actions)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 24):
- return binaryString
- fmt = '!QLB'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.datapath_id, self.n_buffers, self.n_tables) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBB'
- start = 13
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!LL'
- start = 16
- end = start + struct.calcsize(fmt)
- (self.capabilities, self.actions) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[24:]
-
- def __len__(self):
- """Return length of message
- """
- l = 24
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.datapath_id != other.datapath_id: return False
- if self.n_buffers != other.n_buffers: return False
- if self.n_tables != other.n_tables: return False
- if self.pad != other.pad: return False
- if self.capabilities != other.capabilities: return False
- if self.actions != other.actions: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'datapath_id: ' + str(self.datapath_id) + '\n'
- outstr += prefix + 'n_buffers: ' + str(self.n_buffers) + '\n'
- outstr += prefix + 'n_tables: ' + str(self.n_tables) + '\n'
- outstr += prefix + 'capabilities: ' + str(self.capabilities) + '\n'
- outstr += prefix + 'actions: ' + str(self.actions) + '\n'
- return outstr
-
-
-class ofp_match:
- """Automatically generated Python class for ofp_match
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.wildcards = 0
- self.in_port = 0
- self.dl_src= [0,0,0,0,0,0]
- self.dl_dst= [0,0,0,0,0,0]
- self.dl_vlan = 0
- self.dl_vlan_pcp = 0
- self.pad1 = 0
- self.dl_type = 0
- self.nw_tos = 0
- self.nw_proto = 0
- self.pad2= [0,0]
- self.nw_src = 0
- self.nw_dst = 0
- self.tp_src = 0
- self.tp_dst = 0
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.dl_src, list)):
- return (False, "self.dl_src is not list as expected.")
- if(len(self.dl_src) != 6):
- return (False, "self.dl_src is not of size 6 as expected.")
- if(not isinstance(self.dl_dst, list)):
- return (False, "self.dl_dst is not list as expected.")
- if(len(self.dl_dst) != 6):
- return (False, "self.dl_dst is not of size 6 as expected.")
- if(not isinstance(self.pad2, list)):
- return (False, "self.pad2 is not list as expected.")
- if(len(self.pad2) != 2):
- return (False, "self.pad2 is not of size 2 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!LH", self.wildcards, self.in_port)
- packed += struct.pack("!BBBBBB", self.dl_src[0], self.dl_src[1], self.dl_src[2], self.dl_src[3], self.dl_src[4], self.dl_src[5])
- packed += struct.pack("!BBBBBB", self.dl_dst[0], self.dl_dst[1], self.dl_dst[2], self.dl_dst[3], self.dl_dst[4], self.dl_dst[5])
- packed += struct.pack("!HBBHBB", self.dl_vlan, self.dl_vlan_pcp, self.pad1, self.dl_type, self.nw_tos, self.nw_proto)
- packed += struct.pack("!BB", self.pad2[0], self.pad2[1])
- packed += struct.pack("!LLHH", self.nw_src, self.nw_dst, self.tp_src, self.tp_dst)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 40):
- return binaryString
- fmt = '!LH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.wildcards, self.in_port) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBBBB'
- start = 6
- end = start + struct.calcsize(fmt)
- (self.dl_src[0], self.dl_src[1], self.dl_src[2], self.dl_src[3], self.dl_src[4], self.dl_src[5]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBBBB'
- start = 12
- end = start + struct.calcsize(fmt)
- (self.dl_dst[0], self.dl_dst[1], self.dl_dst[2], self.dl_dst[3], self.dl_dst[4], self.dl_dst[5]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!HBBHBB'
- start = 18
- end = start + struct.calcsize(fmt)
- (self.dl_vlan, self.dl_vlan_pcp, self.pad1, self.dl_type, self.nw_tos, self.nw_proto) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BB'
- start = 26
- end = start + struct.calcsize(fmt)
- (self.pad2[0], self.pad2[1]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!LLHH'
- start = 28
- end = start + struct.calcsize(fmt)
- (self.nw_src, self.nw_dst, self.tp_src, self.tp_dst) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[40:]
-
- def __len__(self):
- """Return length of message
- """
- l = 40
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.wildcards != other.wildcards: return False
- if self.in_port != other.in_port: return False
- if self.dl_src != other.dl_src: return False
- if self.dl_dst != other.dl_dst: return False
- if self.dl_vlan != other.dl_vlan: return False
- if self.dl_vlan_pcp != other.dl_vlan_pcp: return False
- if self.pad1 != other.pad1: return False
- if self.dl_type != other.dl_type: return False
- if self.nw_tos != other.nw_tos: return False
- if self.nw_proto != other.nw_proto: return False
- if self.pad2 != other.pad2: return False
- if self.nw_src != other.nw_src: return False
- if self.nw_dst != other.nw_dst: return False
- if self.tp_src != other.tp_src: return False
- if self.tp_dst != other.tp_dst: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'wildcards: ' + str(self.wildcards) + '\n'
- outstr += prefix + 'in_port: ' + str(self.in_port) + '\n'
- outstr += prefix + 'dl_src: ' + str(self.dl_src) + '\n'
- outstr += prefix + 'dl_dst: ' + str(self.dl_dst) + '\n'
- outstr += prefix + 'dl_vlan: ' + str(self.dl_vlan) + '\n'
- outstr += prefix + 'dl_vlan_pcp: ' + str(self.dl_vlan_pcp) + '\n'
- outstr += prefix + 'dl_type: ' + str(self.dl_type) + '\n'
- outstr += prefix + 'nw_tos: ' + str(self.nw_tos) + '\n'
- outstr += prefix + 'nw_proto: ' + str(self.nw_proto) + '\n'
- outstr += prefix + 'nw_src: ' + str(self.nw_src) + '\n'
- outstr += prefix + 'nw_dst: ' + str(self.nw_dst) + '\n'
- outstr += prefix + 'tp_src: ' + str(self.tp_src) + '\n'
- outstr += prefix + 'tp_dst: ' + str(self.tp_dst) + '\n'
- return outstr
-
-
-class ofp_header:
- """Automatically generated Python class for ofp_header
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.version = 0x01
- self.type = 0
- self.length = 0
- self.xid = 0
-
- def __assert(self):
- """Sanity check
- """
- if (not (self.type in ofp_type_map.keys())):
- return (False, "type must have values from ofp_type_map.keys()")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!BBHL", self.version, self.type, self.length, self.xid)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!BBHL'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.version, self.type, self.length, self.xid) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
- if self.length != other.length: return False
- if self.xid != other.xid: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'version: ' + str(self.version) + '\n'
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'length: ' + str(self.length) + '\n'
- outstr += prefix + 'xid: ' + str(self.xid) + '\n'
- return outstr
-
-
-class ofp_vendor_header:
- """Automatically generated Python class for ofp_vendor_header
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.vendor = 0
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!L", self.vendor)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 4):
- return binaryString
- fmt = '!L'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.vendor,) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[4:]
-
- def __len__(self):
- """Return length of message
- """
- l = 4
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.vendor != other.vendor: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'vendor: ' + str(self.vendor) + '\n'
- return outstr
-
-
-class ofp_packet_out:
- """Automatically generated Python class for ofp_packet_out
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.buffer_id = 4294967295
- self.in_port = 0
- self.actions_len = 0
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!LHH", self.buffer_id, self.in_port, self.actions_len)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!LHH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.buffer_id, self.in_port, self.actions_len) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.buffer_id != other.buffer_id: return False
- if self.in_port != other.in_port: return False
- if self.actions_len != other.actions_len: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'buffer_id: ' + str(self.buffer_id) + '\n'
- outstr += prefix + 'in_port: ' + str(self.in_port) + '\n'
- outstr += prefix + 'actions_len: ' + str(self.actions_len) + '\n'
- return outstr
-
-
-class ofp_action_nw_addr:
- """Automatically generated Python class for ofp_action_nw_addr
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.nw_addr = 0
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HHL", self.type, self.len, self.nw_addr)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HHL'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len, self.nw_addr) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.nw_addr != other.nw_addr: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- outstr += prefix + 'nw_addr: ' + str(self.nw_addr) + '\n'
- return outstr
-
-
-class ofp_action_vlan_pcp:
- """Automatically generated Python class for ofp_action_vlan_pcp
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.vlan_pcp = 0
- self.pad= [0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 3):
- return (False, "self.pad is not of size 3 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HHB", self.type, self.len, self.vlan_pcp)
- packed += struct.pack("!BBB", self.pad[0], self.pad[1], self.pad[2])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HHB'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len, self.vlan_pcp) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBB'
- start = 5
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.vlan_pcp != other.vlan_pcp: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- outstr += prefix + 'vlan_pcp: ' + str(self.vlan_pcp) + '\n'
- return outstr
-
-
-class ofp_flow_mod:
- """Automatically generated Python class for ofp_flow_mod
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.match = ofp_match()
- self.cookie = 0
- self.command = 0
- self.idle_timeout = 0
- self.hard_timeout = 0
- self.priority = 0x8000
- self.buffer_id = 0
- self.out_port = 0
- self.flags = 0
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.match, ofp_match)):
- return (False, "self.match is not class ofp_match as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += self.match.pack()
- packed += struct.pack("!QHHHHLHH", self.cookie, self.command, self.idle_timeout, self.hard_timeout, self.priority, self.buffer_id, self.out_port, self.flags)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 64):
- return binaryString
- self.match.unpack(binaryString[0:])
- fmt = '!QHHHHLHH'
- start = 40
- end = start + struct.calcsize(fmt)
- (self.cookie, self.command, self.idle_timeout, self.hard_timeout, self.priority, self.buffer_id, self.out_port, self.flags) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[64:]
-
- def __len__(self):
- """Return length of message
- """
- l = 64
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.match != other.match: return False
- if self.cookie != other.cookie: return False
- if self.command != other.command: return False
- if self.idle_timeout != other.idle_timeout: return False
- if self.hard_timeout != other.hard_timeout: return False
- if self.priority != other.priority: return False
- if self.buffer_id != other.buffer_id: return False
- if self.out_port != other.out_port: return False
- if self.flags != other.flags: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'match: \n'
- outstr += self.match.show(prefix + ' ')
- outstr += prefix + 'cookie: ' + str(self.cookie) + '\n'
- outstr += prefix + 'command: ' + str(self.command) + '\n'
- outstr += prefix + 'idle_timeout: ' + str(self.idle_timeout) + '\n'
- outstr += prefix + 'hard_timeout: ' + str(self.hard_timeout) + '\n'
- outstr += prefix + 'priority: ' + str(self.priority) + '\n'
- outstr += prefix + 'buffer_id: ' + str(self.buffer_id) + '\n'
- outstr += prefix + 'out_port: ' + str(self.out_port) + '\n'
- outstr += prefix + 'flags: ' + str(self.flags) + '\n'
- return outstr
-
-
-class ofp_error_msg:
- """Automatically generated Python class for ofp_error_msg
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.code = 0
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HH", self.type, self.code)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 4):
- return binaryString
- fmt = '!HH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.code) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[4:]
-
- def __len__(self):
- """Return length of message
- """
- l = 4
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.code != other.code: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'code: ' + str(self.code) + '\n'
- return outstr
-
-
-# Enumerated type definitions
-ofp_error_type = ['OFPET_HELLO_FAILED', 'OFPET_BAD_REQUEST', 'OFPET_BAD_ACTION', 'OFPET_FLOW_MOD_FAILED', 'OFPET_PORT_MOD_FAILED', 'OFPET_QUEUE_OP_FAILED']
-OFPET_HELLO_FAILED = 0
-OFPET_BAD_REQUEST = 1
-OFPET_BAD_ACTION = 2
-OFPET_FLOW_MOD_FAILED = 3
-OFPET_PORT_MOD_FAILED = 4
-OFPET_QUEUE_OP_FAILED = 5
-ofp_error_type_map = {
- 0 : 'OFPET_HELLO_FAILED',
- 1 : 'OFPET_BAD_REQUEST',
- 2 : 'OFPET_BAD_ACTION',
- 3 : 'OFPET_FLOW_MOD_FAILED',
- 4 : 'OFPET_PORT_MOD_FAILED',
- 5 : 'OFPET_QUEUE_OP_FAILED'
-}
-
-ofp_flow_mod_flags = ['OFPFF_SEND_FLOW_REM', 'OFPFF_CHECK_OVERLAP', 'OFPFF_EMERG']
-OFPFF_SEND_FLOW_REM = 1
-OFPFF_CHECK_OVERLAP = 2
-OFPFF_EMERG = 4
-ofp_flow_mod_flags_map = {
- 1 : 'OFPFF_SEND_FLOW_REM',
- 2 : 'OFPFF_CHECK_OVERLAP',
- 4 : 'OFPFF_EMERG'
-}
-
-ofp_stats_reply_flags = ['OFPSF_REPLY_MORE']
-OFPSF_REPLY_MORE = 1
-ofp_stats_reply_flags_map = {
- 1 : 'OFPSF_REPLY_MORE'
-}
-
-ofp_flow_mod_failed_code = ['OFPFMFC_ALL_TABLES_FULL', 'OFPFMFC_OVERLAP', 'OFPFMFC_EPERM', 'OFPFMFC_BAD_EMERG_TIMEOUT', 'OFPFMFC_BAD_COMMAND', 'OFPFMFC_UNSUPPORTED']
-OFPFMFC_ALL_TABLES_FULL = 0
-OFPFMFC_OVERLAP = 1
-OFPFMFC_EPERM = 2
-OFPFMFC_BAD_EMERG_TIMEOUT = 3
-OFPFMFC_BAD_COMMAND = 4
-OFPFMFC_UNSUPPORTED = 5
-ofp_flow_mod_failed_code_map = {
- 0 : 'OFPFMFC_ALL_TABLES_FULL',
- 1 : 'OFPFMFC_OVERLAP',
- 2 : 'OFPFMFC_EPERM',
- 3 : 'OFPFMFC_BAD_EMERG_TIMEOUT',
- 4 : 'OFPFMFC_BAD_COMMAND',
- 5 : 'OFPFMFC_UNSUPPORTED'
-}
-
-ofp_port_config = ['OFPPC_PORT_DOWN', 'OFPPC_NO_STP', 'OFPPC_NO_RECV', 'OFPPC_NO_RECV_STP', 'OFPPC_NO_FLOOD', 'OFPPC_NO_FWD', 'OFPPC_NO_PACKET_IN']
-OFPPC_PORT_DOWN = 1
-OFPPC_NO_STP = 2
-OFPPC_NO_RECV = 4
-OFPPC_NO_RECV_STP = 8
-OFPPC_NO_FLOOD = 16
-OFPPC_NO_FWD = 32
-OFPPC_NO_PACKET_IN = 64
-ofp_port_config_map = {
- 1 : 'OFPPC_PORT_DOWN',
- 2 : 'OFPPC_NO_STP',
- 4 : 'OFPPC_NO_RECV',
- 8 : 'OFPPC_NO_RECV_STP',
- 16 : 'OFPPC_NO_FLOOD',
- 32 : 'OFPPC_NO_FWD',
- 64 : 'OFPPC_NO_PACKET_IN'
-}
-
-ofp_port_state = ['OFPPS_LINK_DOWN', 'OFPPS_STP_LISTEN', 'OFPPS_STP_LEARN', 'OFPPS_STP_FORWARD', 'OFPPS_STP_BLOCK', 'OFPPS_STP_MASK']
-OFPPS_LINK_DOWN = 1
-OFPPS_STP_LISTEN = 0
-OFPPS_STP_LEARN = 256
-OFPPS_STP_FORWARD = 512
-OFPPS_STP_BLOCK = 768
-OFPPS_STP_MASK = 768
-ofp_port_state_map = {
- 1 : 'OFPPS_LINK_DOWN',
- 0 : 'OFPPS_STP_LISTEN',
- 256 : 'OFPPS_STP_LEARN',
- 512 : 'OFPPS_STP_FORWARD',
- 768 : 'OFPPS_STP_BLOCK',
- 768 : 'OFPPS_STP_MASK'
-}
-
-ofp_config_flags = ['OFPC_FRAG_NORMAL', 'OFPC_FRAG_DROP', 'OFPC_FRAG_REASM', 'OFPC_FRAG_MASK']
-OFPC_FRAG_NORMAL = 0
-OFPC_FRAG_DROP = 1
-OFPC_FRAG_REASM = 2
-OFPC_FRAG_MASK = 3
-ofp_config_flags_map = {
- 0 : 'OFPC_FRAG_NORMAL',
- 1 : 'OFPC_FRAG_DROP',
- 2 : 'OFPC_FRAG_REASM',
- 3 : 'OFPC_FRAG_MASK'
-}
-
-ofp_hello_failed_code = ['OFPHFC_INCOMPATIBLE', 'OFPHFC_EPERM']
-OFPHFC_INCOMPATIBLE = 0
-OFPHFC_EPERM = 1
-ofp_hello_failed_code_map = {
- 0 : 'OFPHFC_INCOMPATIBLE',
- 1 : 'OFPHFC_EPERM'
-}
-
-ofp_capabilities = ['OFPC_FLOW_STATS', 'OFPC_TABLE_STATS', 'OFPC_PORT_STATS', 'OFPC_STP', 'OFPC_RESERVED', 'OFPC_IP_REASM', 'OFPC_QUEUE_STATS', 'OFPC_ARP_MATCH_IP']
-OFPC_FLOW_STATS = 1
-OFPC_TABLE_STATS = 2
-OFPC_PORT_STATS = 4
-OFPC_STP = 8
-OFPC_RESERVED = 16
-OFPC_IP_REASM = 32
-OFPC_QUEUE_STATS = 64
-OFPC_ARP_MATCH_IP = 128
-ofp_capabilities_map = {
- 1 : 'OFPC_FLOW_STATS',
- 2 : 'OFPC_TABLE_STATS',
- 4 : 'OFPC_PORT_STATS',
- 8 : 'OFPC_STP',
- 16 : 'OFPC_RESERVED',
- 32 : 'OFPC_IP_REASM',
- 64 : 'OFPC_QUEUE_STATS',
- 128 : 'OFPC_ARP_MATCH_IP'
-}
-
-ofp_flow_removed_reason = ['OFPRR_IDLE_TIMEOUT', 'OFPRR_HARD_TIMEOUT', 'OFPRR_DELETE']
-OFPRR_IDLE_TIMEOUT = 0
-OFPRR_HARD_TIMEOUT = 1
-OFPRR_DELETE = 2
-ofp_flow_removed_reason_map = {
- 0 : 'OFPRR_IDLE_TIMEOUT',
- 1 : 'OFPRR_HARD_TIMEOUT',
- 2 : 'OFPRR_DELETE'
-}
-
-ofp_queue_properties = ['OFPQT_NONE', 'OFPQT_MIN_RATE']
-OFPQT_NONE = 0
-OFPQT_MIN_RATE = 0
-ofp_queue_properties_map = {
- 0 : 'OFPQT_NONE',
- 0 : 'OFPQT_MIN_RATE'
-}
-
-ofp_flow_wildcards = ['OFPFW_IN_PORT', 'OFPFW_DL_VLAN', 'OFPFW_DL_SRC', 'OFPFW_DL_DST', 'OFPFW_DL_TYPE', 'OFPFW_NW_PROTO', 'OFPFW_TP_SRC', 'OFPFW_TP_DST', 'OFPFW_NW_SRC_SHIFT', 'OFPFW_NW_SRC_BITS', 'OFPFW_NW_SRC_MASK', 'OFPFW_NW_SRC_ALL', 'OFPFW_NW_DST_SHIFT', 'OFPFW_NW_DST_BITS', 'OFPFW_NW_DST_MASK', 'OFPFW_NW_DST_ALL', 'OFPFW_DL_VLAN_PCP', 'OFPFW_NW_TOS', 'OFPFW_ALL']
-OFPFW_IN_PORT = 1
-OFPFW_DL_VLAN = 2
-OFPFW_DL_SRC = 4
-OFPFW_DL_DST = 8
-OFPFW_DL_TYPE = 16
-OFPFW_NW_PROTO = 32
-OFPFW_TP_SRC = 64
-OFPFW_TP_DST = 128
-OFPFW_NW_SRC_SHIFT = 8
-OFPFW_NW_SRC_BITS = 6
-OFPFW_NW_SRC_MASK = 16128
-OFPFW_NW_SRC_ALL = 8192
-OFPFW_NW_DST_SHIFT = 14
-OFPFW_NW_DST_BITS = 6
-OFPFW_NW_DST_MASK = 1032192
-OFPFW_NW_DST_ALL = 524288
-OFPFW_DL_VLAN_PCP = 1048576
-OFPFW_NW_TOS = 2097152
-OFPFW_ALL = 4194303
-ofp_flow_wildcards_map = {
- 1 : 'OFPFW_IN_PORT',
- 2 : 'OFPFW_DL_VLAN',
- 4 : 'OFPFW_DL_SRC',
- 8 : 'OFPFW_DL_DST',
- 16 : 'OFPFW_DL_TYPE',
- 32 : 'OFPFW_NW_PROTO',
- 64 : 'OFPFW_TP_SRC',
- 128 : 'OFPFW_TP_DST',
- 8 : 'OFPFW_NW_SRC_SHIFT',
- 6 : 'OFPFW_NW_SRC_BITS',
- 16128 : 'OFPFW_NW_SRC_MASK',
- 8192 : 'OFPFW_NW_SRC_ALL',
- 14 : 'OFPFW_NW_DST_SHIFT',
- 6 : 'OFPFW_NW_DST_BITS',
- 1032192 : 'OFPFW_NW_DST_MASK',
- 524288 : 'OFPFW_NW_DST_ALL',
- 1048576 : 'OFPFW_DL_VLAN_PCP',
- 2097152 : 'OFPFW_NW_TOS',
- 4194303 : 'OFPFW_ALL'
-}
-
-ofp_port_reason = ['OFPPR_ADD', 'OFPPR_DELETE', 'OFPPR_MODIFY']
-OFPPR_ADD = 0
-OFPPR_DELETE = 1
-OFPPR_MODIFY = 2
-ofp_port_reason_map = {
- 0 : 'OFPPR_ADD',
- 1 : 'OFPPR_DELETE',
- 2 : 'OFPPR_MODIFY'
-}
-
-ofp_action_type = ['OFPAT_OUTPUT', 'OFPAT_SET_VLAN_VID', 'OFPAT_SET_VLAN_PCP', 'OFPAT_STRIP_VLAN', 'OFPAT_SET_DL_SRC', 'OFPAT_SET_DL_DST', 'OFPAT_SET_NW_SRC', 'OFPAT_SET_NW_DST', 'OFPAT_SET_NW_TOS', 'OFPAT_SET_TP_SRC', 'OFPAT_SET_TP_DST', 'OFPAT_ENQUEUE', 'OFPAT_VENDOR']
-OFPAT_OUTPUT = 0
-OFPAT_SET_VLAN_VID = 1
-OFPAT_SET_VLAN_PCP = 2
-OFPAT_STRIP_VLAN = 3
-OFPAT_SET_DL_SRC = 4
-OFPAT_SET_DL_DST = 5
-OFPAT_SET_NW_SRC = 6
-OFPAT_SET_NW_DST = 7
-OFPAT_SET_NW_TOS = 8
-OFPAT_SET_TP_SRC = 9
-OFPAT_SET_TP_DST = 10
-OFPAT_ENQUEUE = 11
-OFPAT_VENDOR = 65535
-ofp_action_type_map = {
- 0 : 'OFPAT_OUTPUT',
- 1 : 'OFPAT_SET_VLAN_VID',
- 2 : 'OFPAT_SET_VLAN_PCP',
- 3 : 'OFPAT_STRIP_VLAN',
- 4 : 'OFPAT_SET_DL_SRC',
- 5 : 'OFPAT_SET_DL_DST',
- 6 : 'OFPAT_SET_NW_SRC',
- 7 : 'OFPAT_SET_NW_DST',
- 8 : 'OFPAT_SET_NW_TOS',
- 9 : 'OFPAT_SET_TP_SRC',
- 10 : 'OFPAT_SET_TP_DST',
- 11 : 'OFPAT_ENQUEUE',
- 65535 : 'OFPAT_VENDOR'
-}
-
-ofp_flow_mod_command = ['OFPFC_ADD', 'OFPFC_MODIFY', 'OFPFC_MODIFY_STRICT', 'OFPFC_DELETE', 'OFPFC_DELETE_STRICT']
-OFPFC_ADD = 0
-OFPFC_MODIFY = 1
-OFPFC_MODIFY_STRICT = 2
-OFPFC_DELETE = 3
-OFPFC_DELETE_STRICT = 4
-ofp_flow_mod_command_map = {
- 0 : 'OFPFC_ADD',
- 1 : 'OFPFC_MODIFY',
- 2 : 'OFPFC_MODIFY_STRICT',
- 3 : 'OFPFC_DELETE',
- 4 : 'OFPFC_DELETE_STRICT'
-}
-
-ofp_queue_op_failed_code = ['OFPQOFC_BAD_PORT', 'OFPQOFC_BAD_QUEUE', 'OFPQOFC_EPERM']
-OFPQOFC_BAD_PORT = 0
-OFPQOFC_BAD_QUEUE = 1
-OFPQOFC_EPERM = 2
-ofp_queue_op_failed_code_map = {
- 0 : 'OFPQOFC_BAD_PORT',
- 1 : 'OFPQOFC_BAD_QUEUE',
- 2 : 'OFPQOFC_EPERM'
-}
-
-ofp_port = ['OFPP_MAX', 'OFPP_IN_PORT', 'OFPP_TABLE', 'OFPP_NORMAL', 'OFPP_FLOOD', 'OFPP_ALL', 'OFPP_CONTROLLER', 'OFPP_LOCAL', 'OFPP_NONE']
-OFPP_MAX = 65280
-OFPP_IN_PORT = 65528
-OFPP_TABLE = 65529
-OFPP_NORMAL = 65530
-OFPP_FLOOD = 65531
-OFPP_ALL = 65532
-OFPP_CONTROLLER = 65533
-OFPP_LOCAL = 65534
-OFPP_NONE = 65535
-ofp_port_map = {
- 65280 : 'OFPP_MAX',
- 65528 : 'OFPP_IN_PORT',
- 65529 : 'OFPP_TABLE',
- 65530 : 'OFPP_NORMAL',
- 65531 : 'OFPP_FLOOD',
- 65532 : 'OFPP_ALL',
- 65533 : 'OFPP_CONTROLLER',
- 65534 : 'OFPP_LOCAL',
- 65535 : 'OFPP_NONE'
-}
-
-ofp_bad_action_code = ['OFPBAC_BAD_TYPE', 'OFPBAC_BAD_LEN', 'OFPBAC_BAD_VENDOR', 'OFPBAC_BAD_VENDOR_TYPE', 'OFPBAC_BAD_OUT_PORT', 'OFPBAC_BAD_ARGUMENT', 'OFPBAC_EPERM', 'OFPBAC_TOO_MANY', 'OFPBAC_BAD_QUEUE']
-OFPBAC_BAD_TYPE = 0
-OFPBAC_BAD_LEN = 1
-OFPBAC_BAD_VENDOR = 2
-OFPBAC_BAD_VENDOR_TYPE = 3
-OFPBAC_BAD_OUT_PORT = 4
-OFPBAC_BAD_ARGUMENT = 5
-OFPBAC_EPERM = 6
-OFPBAC_TOO_MANY = 7
-OFPBAC_BAD_QUEUE = 8
-ofp_bad_action_code_map = {
- 0 : 'OFPBAC_BAD_TYPE',
- 1 : 'OFPBAC_BAD_LEN',
- 2 : 'OFPBAC_BAD_VENDOR',
- 3 : 'OFPBAC_BAD_VENDOR_TYPE',
- 4 : 'OFPBAC_BAD_OUT_PORT',
- 5 : 'OFPBAC_BAD_ARGUMENT',
- 6 : 'OFPBAC_EPERM',
- 7 : 'OFPBAC_TOO_MANY',
- 8 : 'OFPBAC_BAD_QUEUE'
-}
-
-ofp_bad_request_code = ['OFPBRC_BAD_VERSION', 'OFPBRC_BAD_TYPE', 'OFPBRC_BAD_STAT', 'OFPBRC_BAD_VENDOR', 'OFPBRC_BAD_SUBTYPE', 'OFPBRC_EPERM', 'OFPBRC_BAD_LEN', 'OFPBRC_BUFFER_EMPTY', 'OFPBRC_BUFFER_UNKNOWN']
-OFPBRC_BAD_VERSION = 0
-OFPBRC_BAD_TYPE = 1
-OFPBRC_BAD_STAT = 2
-OFPBRC_BAD_VENDOR = 3
-OFPBRC_BAD_SUBTYPE = 4
-OFPBRC_EPERM = 5
-OFPBRC_BAD_LEN = 6
-OFPBRC_BUFFER_EMPTY = 7
-OFPBRC_BUFFER_UNKNOWN = 8
-ofp_bad_request_code_map = {
- 0 : 'OFPBRC_BAD_VERSION',
- 1 : 'OFPBRC_BAD_TYPE',
- 2 : 'OFPBRC_BAD_STAT',
- 3 : 'OFPBRC_BAD_VENDOR',
- 4 : 'OFPBRC_BAD_SUBTYPE',
- 5 : 'OFPBRC_EPERM',
- 6 : 'OFPBRC_BAD_LEN',
- 7 : 'OFPBRC_BUFFER_EMPTY',
- 8 : 'OFPBRC_BUFFER_UNKNOWN'
-}
-
-ofp_port_features = ['OFPPF_10MB_HD', 'OFPPF_10MB_FD', 'OFPPF_100MB_HD', 'OFPPF_100MB_FD', 'OFPPF_1GB_HD', 'OFPPF_1GB_FD', 'OFPPF_10GB_FD', 'OFPPF_COPPER', 'OFPPF_FIBER', 'OFPPF_AUTONEG', 'OFPPF_PAUSE', 'OFPPF_PAUSE_ASYM']
-OFPPF_10MB_HD = 1
-OFPPF_10MB_FD = 2
-OFPPF_100MB_HD = 4
-OFPPF_100MB_FD = 8
-OFPPF_1GB_HD = 16
-OFPPF_1GB_FD = 32
-OFPPF_10GB_FD = 64
-OFPPF_COPPER = 128
-OFPPF_FIBER = 256
-OFPPF_AUTONEG = 512
-OFPPF_PAUSE = 1024
-OFPPF_PAUSE_ASYM = 2048
-ofp_port_features_map = {
- 1 : 'OFPPF_10MB_HD',
- 2 : 'OFPPF_10MB_FD',
- 4 : 'OFPPF_100MB_HD',
- 8 : 'OFPPF_100MB_FD',
- 16 : 'OFPPF_1GB_HD',
- 32 : 'OFPPF_1GB_FD',
- 64 : 'OFPPF_10GB_FD',
- 128 : 'OFPPF_COPPER',
- 256 : 'OFPPF_FIBER',
- 512 : 'OFPPF_AUTONEG',
- 1024 : 'OFPPF_PAUSE',
- 2048 : 'OFPPF_PAUSE_ASYM'
-}
-
-ofp_type = ['OFPT_HELLO', 'OFPT_ERROR', 'OFPT_ECHO_REQUEST', 'OFPT_ECHO_REPLY', 'OFPT_VENDOR', 'OFPT_FEATURES_REQUEST', 'OFPT_FEATURES_REPLY', 'OFPT_GET_CONFIG_REQUEST', 'OFPT_GET_CONFIG_REPLY', 'OFPT_SET_CONFIG', 'OFPT_PACKET_IN', 'OFPT_FLOW_REMOVED', 'OFPT_PORT_STATUS', 'OFPT_PACKET_OUT', 'OFPT_FLOW_MOD', 'OFPT_PORT_MOD', 'OFPT_STATS_REQUEST', 'OFPT_STATS_REPLY', 'OFPT_BARRIER_REQUEST', 'OFPT_BARRIER_REPLY', 'OFPT_QUEUE_GET_CONFIG_REQUEST', 'OFPT_QUEUE_GET_CONFIG_REPLY']
-OFPT_HELLO = 0
-OFPT_ERROR = 1
-OFPT_ECHO_REQUEST = 2
-OFPT_ECHO_REPLY = 3
-OFPT_VENDOR = 4
-OFPT_FEATURES_REQUEST = 5
-OFPT_FEATURES_REPLY = 6
-OFPT_GET_CONFIG_REQUEST = 7
-OFPT_GET_CONFIG_REPLY = 8
-OFPT_SET_CONFIG = 9
-OFPT_PACKET_IN = 10
-OFPT_FLOW_REMOVED = 11
-OFPT_PORT_STATUS = 12
-OFPT_PACKET_OUT = 13
-OFPT_FLOW_MOD = 14
-OFPT_PORT_MOD = 15
-OFPT_STATS_REQUEST = 16
-OFPT_STATS_REPLY = 17
-OFPT_BARRIER_REQUEST = 18
-OFPT_BARRIER_REPLY = 19
-OFPT_QUEUE_GET_CONFIG_REQUEST = 20
-OFPT_QUEUE_GET_CONFIG_REPLY = 21
-ofp_type_map = {
- 0 : 'OFPT_HELLO',
- 1 : 'OFPT_ERROR',
- 2 : 'OFPT_ECHO_REQUEST',
- 3 : 'OFPT_ECHO_REPLY',
- 4 : 'OFPT_VENDOR',
- 5 : 'OFPT_FEATURES_REQUEST',
- 6 : 'OFPT_FEATURES_REPLY',
- 7 : 'OFPT_GET_CONFIG_REQUEST',
- 8 : 'OFPT_GET_CONFIG_REPLY',
- 9 : 'OFPT_SET_CONFIG',
- 10 : 'OFPT_PACKET_IN',
- 11 : 'OFPT_FLOW_REMOVED',
- 12 : 'OFPT_PORT_STATUS',
- 13 : 'OFPT_PACKET_OUT',
- 14 : 'OFPT_FLOW_MOD',
- 15 : 'OFPT_PORT_MOD',
- 16 : 'OFPT_STATS_REQUEST',
- 17 : 'OFPT_STATS_REPLY',
- 18 : 'OFPT_BARRIER_REQUEST',
- 19 : 'OFPT_BARRIER_REPLY',
- 20 : 'OFPT_QUEUE_GET_CONFIG_REQUEST',
- 21 : 'OFPT_QUEUE_GET_CONFIG_REPLY'
-}
-
-ofp_packet_in_reason = ['OFPR_NO_MATCH', 'OFPR_ACTION']
-OFPR_NO_MATCH = 0
-OFPR_ACTION = 1
-ofp_packet_in_reason_map = {
- 0 : 'OFPR_NO_MATCH',
- 1 : 'OFPR_ACTION'
-}
-
-ofp_stats_types = ['OFPST_DESC', 'OFPST_FLOW', 'OFPST_AGGREGATE', 'OFPST_TABLE', 'OFPST_PORT', 'OFPST_QUEUE', 'OFPST_VENDOR']
-OFPST_DESC = 0
-OFPST_FLOW = 1
-OFPST_AGGREGATE = 2
-OFPST_TABLE = 3
-OFPST_PORT = 4
-OFPST_QUEUE = 5
-OFPST_VENDOR = 65535
-ofp_stats_types_map = {
- 0 : 'OFPST_DESC',
- 1 : 'OFPST_FLOW',
- 2 : 'OFPST_AGGREGATE',
- 3 : 'OFPST_TABLE',
- 4 : 'OFPST_PORT',
- 5 : 'OFPST_QUEUE',
- 65535 : 'OFPST_VENDOR'
-}
-
-ofp_port_mod_failed_code = ['OFPPMFC_BAD_PORT', 'OFPPMFC_BAD_HW_ADDR']
-OFPPMFC_BAD_PORT = 0
-OFPPMFC_BAD_HW_ADDR = 1
-ofp_port_mod_failed_code_map = {
- 0 : 'OFPPMFC_BAD_PORT',
- 1 : 'OFPPMFC_BAD_HW_ADDR'
-}
-
-# Values from macro definitions
-OFP_FLOW_PERMANENT = 0
-OFP_DL_TYPE_ETH2_CUTOFF = 0x0600
-DESC_STR_LEN = 256
-OFPFW_ICMP_CODE = OFPFW_TP_DST
-OFPQ_MIN_RATE_UNCFG = 0xffff
-OFP_VERSION = 0x01
-OFP_MAX_TABLE_NAME_LEN = 32
-OFP_DL_TYPE_NOT_ETH_TYPE = 0x05ff
-OFP_DEFAULT_MISS_SEND_LEN = 128
-OFP_MAX_PORT_NAME_LEN = 16
-OFP_SSL_PORT = 6633
-OFPFW_ICMP_TYPE = OFPFW_TP_SRC
-OFP_TCP_PORT = 6633
-SERIAL_NUM_LEN = 32
-OFP_DEFAULT_PRIORITY = 0x8000
-OFP_ETH_ALEN = 6
-OFP_VLAN_NONE = 0xffff
-OFPQ_ALL = 0xffffffff
-
-# Basic structure size definitions.
-# Does not include ofp_header members.
-# Does not include variable length arrays.
-OFP_ACTION_DL_ADDR_BYTES = 16
-OFP_ACTION_ENQUEUE_BYTES = 16
-OFP_ACTION_HEADER_BYTES = 8
-OFP_ACTION_NW_ADDR_BYTES = 8
-OFP_ACTION_NW_TOS_BYTES = 8
-OFP_ACTION_OUTPUT_BYTES = 8
-OFP_ACTION_TP_PORT_BYTES = 8
-OFP_ACTION_VENDOR_HEADER_BYTES = 8
-OFP_ACTION_VLAN_PCP_BYTES = 8
-OFP_ACTION_VLAN_VID_BYTES = 8
-OFP_AGGREGATE_STATS_REPLY_BYTES = 24
-OFP_AGGREGATE_STATS_REQUEST_BYTES = 44
-OFP_DESC_STATS_BYTES = 1056
-OFP_ERROR_MSG_BYTES = 4
-OFP_FLOW_MOD_BYTES = 64
-OFP_FLOW_REMOVED_BYTES = 80
-OFP_FLOW_STATS_BYTES = 88
-OFP_FLOW_STATS_REQUEST_BYTES = 44
-OFP_HEADER_BYTES = 8
-OFP_HELLO_BYTES = 0
-OFP_MATCH_BYTES = 40
-OFP_PACKET_IN_BYTES = 10
-OFP_PACKET_OUT_BYTES = 8
-OFP_PACKET_QUEUE_BYTES = 8
-OFP_PHY_PORT_BYTES = 48
-OFP_PORT_MOD_BYTES = 24
-OFP_PORT_STATS_BYTES = 104
-OFP_PORT_STATS_REQUEST_BYTES = 8
-OFP_PORT_STATUS_BYTES = 56
-OFP_QUEUE_GET_CONFIG_REPLY_BYTES = 8
-OFP_QUEUE_GET_CONFIG_REQUEST_BYTES = 4
-OFP_QUEUE_PROP_HEADER_BYTES = 8
-OFP_QUEUE_PROP_MIN_RATE_BYTES = 16
-OFP_QUEUE_STATS_BYTES = 32
-OFP_QUEUE_STATS_REQUEST_BYTES = 8
-OFP_STATS_REPLY_BYTES = 4
-OFP_STATS_REQUEST_BYTES = 4
-OFP_SWITCH_CONFIG_BYTES = 4
-OFP_SWITCH_FEATURES_BYTES = 24
-OFP_TABLE_STATS_BYTES = 64
-OFP_VENDOR_HEADER_BYTES = 4
-
diff --git a/src/python/of10/error.py b/src/python/of10/error.py
deleted file mode 100644
index c69b70d..0000000
--- a/src/python/of10/error.py
+++ /dev/null
@@ -1,306 +0,0 @@
-
-# Python OpenFlow error wrapper classes
-
-from cstruct import *
-
-
-
-class hello_failed_error_msg(ofp_error_msg):
- """
- Wrapper class for hello_failed error message class
-
- Data members inherited from ofp_error_msg:
- @arg type
- @arg code
- @arg data: Binary string following message members
-
- """
- def __init__(self):
- ofp_error_msg.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_ERROR
- self.type = OFPET_HELLO_FAILED
- self.data = ""
-
- def pack(self, assertstruct=True):
- self.header.length = self.__len__()
- packed = self.header.pack()
- packed += ofp_error_msg.pack(self)
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_error_msg.unpack(self, binary_string)
- self.data = binary_string
- return ""
-
- def __len__(self):
- return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
-
- def show(self, prefix=''):
- outstr = prefix + "hello_failed_error_msg\m"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_error_msg.show(self, prefix + ' ')
- outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
- ##@todo Consider trying to parse the string
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_error_msg.__eq__(self, other) and
- self.data == other.data)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class bad_request_error_msg(ofp_error_msg):
- """
- Wrapper class for bad_request error message class
-
- Data members inherited from ofp_error_msg:
- @arg type
- @arg code
- @arg data: Binary string following message members
-
- """
- def __init__(self):
- ofp_error_msg.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_ERROR
- self.type = OFPET_BAD_REQUEST
- self.data = ""
-
- def pack(self, assertstruct=True):
- self.header.length = self.__len__()
- packed = self.header.pack()
- packed += ofp_error_msg.pack(self)
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_error_msg.unpack(self, binary_string)
- self.data = binary_string
- return ""
-
- def __len__(self):
- return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
-
- def show(self, prefix=''):
- outstr = prefix + "bad_request_error_msg\m"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_error_msg.show(self, prefix + ' ')
- outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
- ##@todo Consider trying to parse the string
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_error_msg.__eq__(self, other) and
- self.data == other.data)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class bad_action_error_msg(ofp_error_msg):
- """
- Wrapper class for bad_action error message class
-
- Data members inherited from ofp_error_msg:
- @arg type
- @arg code
- @arg data: Binary string following message members
-
- """
- def __init__(self):
- ofp_error_msg.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_ERROR
- self.type = OFPET_BAD_ACTION
- self.data = ""
-
- def pack(self, assertstruct=True):
- self.header.length = self.__len__()
- packed = self.header.pack()
- packed += ofp_error_msg.pack(self)
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_error_msg.unpack(self, binary_string)
- self.data = binary_string
- return ""
-
- def __len__(self):
- return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
-
- def show(self, prefix=''):
- outstr = prefix + "bad_action_error_msg\m"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_error_msg.show(self, prefix + ' ')
- outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
- ##@todo Consider trying to parse the string
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_error_msg.__eq__(self, other) and
- self.data == other.data)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class flow_mod_failed_error_msg(ofp_error_msg):
- """
- Wrapper class for flow_mod_failed error message class
-
- Data members inherited from ofp_error_msg:
- @arg type
- @arg code
- @arg data: Binary string following message members
-
- """
- def __init__(self):
- ofp_error_msg.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_ERROR
- self.type = OFPET_FLOW_MOD_FAILED
- self.data = ""
-
- def pack(self, assertstruct=True):
- self.header.length = self.__len__()
- packed = self.header.pack()
- packed += ofp_error_msg.pack(self)
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_error_msg.unpack(self, binary_string)
- self.data = binary_string
- return ""
-
- def __len__(self):
- return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
-
- def show(self, prefix=''):
- outstr = prefix + "flow_mod_failed_error_msg\m"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_error_msg.show(self, prefix + ' ')
- outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
- ##@todo Consider trying to parse the string
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_error_msg.__eq__(self, other) and
- self.data == other.data)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class port_mod_failed_error_msg(ofp_error_msg):
- """
- Wrapper class for port_mod_failed error message class
-
- Data members inherited from ofp_error_msg:
- @arg type
- @arg code
- @arg data: Binary string following message members
-
- """
- def __init__(self):
- ofp_error_msg.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_ERROR
- self.type = OFPET_PORT_MOD_FAILED
- self.data = ""
-
- def pack(self, assertstruct=True):
- self.header.length = self.__len__()
- packed = self.header.pack()
- packed += ofp_error_msg.pack(self)
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_error_msg.unpack(self, binary_string)
- self.data = binary_string
- return ""
-
- def __len__(self):
- return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
-
- def show(self, prefix=''):
- outstr = prefix + "port_mod_failed_error_msg\m"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_error_msg.show(self, prefix + ' ')
- outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
- ##@todo Consider trying to parse the string
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_error_msg.__eq__(self, other) and
- self.data == other.data)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class queue_op_failed_error_msg(ofp_error_msg):
- """
- Wrapper class for queue_op_failed error message class
-
- Data members inherited from ofp_error_msg:
- @arg type
- @arg code
- @arg data: Binary string following message members
-
- """
- def __init__(self):
- ofp_error_msg.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_ERROR
- self.type = OFPET_QUEUE_OP_FAILED
- self.data = ""
-
- def pack(self, assertstruct=True):
- self.header.length = self.__len__()
- packed = self.header.pack()
- packed += ofp_error_msg.pack(self)
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_error_msg.unpack(self, binary_string)
- self.data = binary_string
- return ""
-
- def __len__(self):
- return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
-
- def show(self, prefix=''):
- outstr = prefix + "queue_op_failed_error_msg\m"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_error_msg.show(self, prefix + ' ')
- outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
- ##@todo Consider trying to parse the string
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_error_msg.__eq__(self, other) and
- self.data == other.data)
-
- def __ne__(self, other): return not self.__eq__(other)
-
diff --git a/src/python/of10/message.py b/src/python/of10/message.py
deleted file mode 100644
index bf0064e..0000000
--- a/src/python/of10/message.py
+++ /dev/null
@@ -1,3373 +0,0 @@
-
-# Python OpenFlow message wrapper classes
-
-from cstruct import *
-from action_list import action_list
-from error import *
-
-# Define templates for documentation
-class ofp_template_msg:
- """
- Sample base class for template_msg; normally auto generated
- This class should live in the of_header name space and provides the
- base class for this type of message. It will be wrapped for the
- high level API.
-
- """
- def __init__(self):
- """
- Constructor for base class
-
- """
- self.header = ofp_header()
- # Additional base data members declared here
-
- # Normally will define pack, unpack, __len__ functions
-
-class template_msg(ofp_template_msg):
- """
- Sample class wrapper for template_msg
- This class should live in the of_message name space and provides the
- high level API for an OpenFlow message object. These objects must
- implement the functions indicated in this template.
-
- """
- def __init__(self):
- """
- Constructor
- Must set the header type value appropriately for the message
-
- """
-
- ##@var header
- # OpenFlow message header: length, version, xid, type
- ofp_template_msg.__init__(self)
- self.header = ofp_header()
- # For a real message, will be set to an integer
- self.header.type = "TEMPLATE_MSG_VALUE"
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- pass
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
-
- @return Typically returns the remainder of binary_string that
- was not parsed. May give a warning if that string is non-empty
-
- """
- pass
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- pass
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
- pass
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- pass
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- pass
-
-
-################################################################
-#
-# OpenFlow Message Definitions
-#
-################################################################
-
-class barrier_reply:
- """
- Wrapper class for barrier_reply
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (1)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_BARRIER_REPLY=19)
-
-
- """
-
- def __init__(self, **kwargs):
- self.header = ofp_header()
- self.header.type = OFPT_BARRIER_REPLY
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'barrier_reply (OFPT_BARRIER_REPLY)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class barrier_request:
- """
- Wrapper class for barrier_request
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (1)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_BARRIER_REQUEST=18)
-
-
- """
-
- def __init__(self, **kwargs):
- self.header = ofp_header()
- self.header.type = OFPT_BARRIER_REQUEST
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'barrier_request (OFPT_BARRIER_REQUEST)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class echo_reply:
- """
- Wrapper class for echo_reply
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (1)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_ECHO_REPLY=3)
-
- @arg data: Binary string following message members
-
- """
-
- def __init__(self, **kwargs):
- self.header = ofp_header()
- self.header.type = OFPT_ECHO_REPLY
- self.data = ""
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- self.data = binary_string
- binary_string = ''
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += len(self.data)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'echo_reply (OFPT_ECHO_REPLY)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += prefix + 'data is of length ' + str(len(self.data)) + '\n'
- ##@todo Fix this circular reference
- # if len(self.data) > 0:
- # obj = of_message_parse(self.data)
- # if obj != None:
- # outstr += obj.show(prefix)
- # else:
- # outstr += prefix + "Unable to parse data\n"
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if self.data != other.data: return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class echo_request:
- """
- Wrapper class for echo_request
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (1)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_ECHO_REQUEST=2)
-
- @arg data: Binary string following message members
-
- """
-
- def __init__(self, **kwargs):
- self.header = ofp_header()
- self.header.type = OFPT_ECHO_REQUEST
- self.data = ""
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- self.data = binary_string
- binary_string = ''
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += len(self.data)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'echo_request (OFPT_ECHO_REQUEST)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += prefix + 'data is of length ' + str(len(self.data)) + '\n'
- ##@todo Fix this circular reference
- # if len(self.data) > 0:
- # obj = of_message_parse(self.data)
- # if obj != None:
- # outstr += obj.show(prefix)
- # else:
- # outstr += prefix + "Unable to parse data\n"
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if self.data != other.data: return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class error(ofp_error_msg):
- """
- Wrapper class for error
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (1)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_ERROR=1)
-
- Data members inherited from ofp_error_msg:
- @arg type
- @arg code
- @arg data: Binary string following message members
-
- """
-
- def __init__(self, **kwargs):
- ofp_error_msg.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_ERROR
- self.data = ""
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_error_msg.pack(self)
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_error_msg.unpack(self, binary_string)
- self.data = binary_string
- binary_string = ''
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_error_msg.__len__(self)
- length += len(self.data)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'error (OFPT_ERROR)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_error_msg.show(self, prefix)
- outstr += prefix + 'data is of length ' + str(len(self.data)) + '\n'
- ##@todo Fix this circular reference
- # if len(self.data) > 0:
- # obj = of_message_parse(self.data)
- # if obj != None:
- # outstr += obj.show(prefix)
- # else:
- # outstr += prefix + "Unable to parse data\n"
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_error_msg.__eq__(self, other): return False
- if self.data != other.data: return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class features_reply(ofp_switch_features):
- """
- Wrapper class for features_reply
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (1)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_FEATURES_REPLY=6)
-
- Data members inherited from ofp_switch_features:
- @arg datapath_id
- @arg n_buffers
- @arg n_tables
- @arg capabilities
- @arg actions
- @arg ports: Variable length array of TBD
-
- """
-
- def __init__(self, **kwargs):
- ofp_switch_features.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_FEATURES_REPLY
- self.ports = []
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_switch_features.pack(self)
- for obj in self.ports:
- packed += obj.pack()
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_switch_features.unpack(self, binary_string)
- while len(binary_string) >= OFP_PHY_PORT_BYTES:
- new_port = ofp_phy_port()
- binary_string = new_port.unpack(binary_string)
- self.ports.append(new_port)
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_switch_features.__len__(self)
- for obj in self.ports:
- length += len(obj)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'features_reply (OFPT_FEATURES_REPLY)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_switch_features.show(self, prefix)
- outstr += prefix + "Array ports\n"
- for obj in self.ports:
- outstr += obj.show(prefix + ' ')
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_switch_features.__eq__(self, other): return False
- if self.ports != other.ports: return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class features_request:
- """
- Wrapper class for features_request
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (1)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_FEATURES_REQUEST=5)
-
-
- """
-
- def __init__(self, **kwargs):
- self.header = ofp_header()
- self.header.type = OFPT_FEATURES_REQUEST
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'features_request (OFPT_FEATURES_REQUEST)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class flow_mod(ofp_flow_mod):
- """
- Wrapper class for flow_mod
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (1)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_FLOW_MOD=14)
-
- Data members inherited from ofp_flow_mod:
- @arg match
- @arg cookie
- @arg command
- @arg idle_timeout
- @arg hard_timeout
- @arg priority
- @arg buffer_id
- @arg out_port
- @arg flags
- @arg actions: Object of type action_list
-
- """
-
- def __init__(self, **kwargs):
- ofp_flow_mod.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_FLOW_MOD
- self.actions = []
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- # Coerce keyword arg into list type
- self.actions = action_list(self.actions)
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_flow_mod.pack(self)
- packed += self.actions.pack()
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_flow_mod.unpack(self, binary_string)
- ai_len = self.header.length - (OFP_FLOW_MOD_BYTES + OFP_HEADER_BYTES)
- binary_string = self.actions.unpack(binary_string, bytes=ai_len)
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_flow_mod.__len__(self)
- length += len(self.actions)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'flow_mod (OFPT_FLOW_MOD)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_flow_mod.show(self, prefix)
- outstr += prefix + "List actions\n"
- outstr += self.actions.show(prefix + ' ')
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_flow_mod.__eq__(self, other): return False
- if self.actions != other.actions: return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class flow_removed(ofp_flow_removed):
- """
- Wrapper class for flow_removed
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (1)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_FLOW_REMOVED=11)
-
- Data members inherited from ofp_flow_removed:
- @arg match
- @arg cookie
- @arg priority
- @arg reason
- @arg duration_sec
- @arg duration_nsec
- @arg idle_timeout
- @arg packet_count
- @arg byte_count
-
- """
-
- def __init__(self, **kwargs):
- ofp_flow_removed.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_FLOW_REMOVED
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_flow_removed.pack(self)
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_flow_removed.unpack(self, binary_string)
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_flow_removed.__len__(self)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'flow_removed (OFPT_FLOW_REMOVED)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_flow_removed.show(self, prefix)
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_flow_removed.__eq__(self, other): return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class get_config_reply(ofp_switch_config):
- """
- Wrapper class for get_config_reply
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (1)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_GET_CONFIG_REPLY=8)
-
- Data members inherited from ofp_switch_config:
- @arg flags
- @arg miss_send_len
-
- """
-
- def __init__(self, **kwargs):
- ofp_switch_config.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_GET_CONFIG_REPLY
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_switch_config.pack(self)
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_switch_config.unpack(self, binary_string)
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_switch_config.__len__(self)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'get_config_reply (OFPT_GET_CONFIG_REPLY)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_switch_config.show(self, prefix)
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_switch_config.__eq__(self, other): return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class get_config_request:
- """
- Wrapper class for get_config_request
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (1)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_GET_CONFIG_REQUEST=7)
-
-
- """
-
- def __init__(self, **kwargs):
- self.header = ofp_header()
- self.header.type = OFPT_GET_CONFIG_REQUEST
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'get_config_request (OFPT_GET_CONFIG_REQUEST)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class hello:
- """
- Wrapper class for hello
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (1)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_HELLO=0)
-
- @arg data: Binary string following message members
-
- """
-
- def __init__(self, **kwargs):
- self.header = ofp_header()
- self.header.type = OFPT_HELLO
- self.data = ""
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- self.data = binary_string
- binary_string = ''
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += len(self.data)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'hello (OFPT_HELLO)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += prefix + 'data is of length ' + str(len(self.data)) + '\n'
- ##@todo Fix this circular reference
- # if len(self.data) > 0:
- # obj = of_message_parse(self.data)
- # if obj != None:
- # outstr += obj.show(prefix)
- # else:
- # outstr += prefix + "Unable to parse data\n"
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if self.data != other.data: return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class packet_in(ofp_packet_in):
- """
- Wrapper class for packet_in
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (1)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_PACKET_IN=10)
-
- Data members inherited from ofp_packet_in:
- @arg buffer_id
- @arg total_len
- @arg in_port
- @arg reason
- @arg data: Binary string following message members
-
- """
-
- def __init__(self, **kwargs):
- ofp_packet_in.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_PACKET_IN
- self.data = ""
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_packet_in.pack(self)
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_packet_in.unpack(self, binary_string)
- self.data = binary_string
- binary_string = ''
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_packet_in.__len__(self)
- length += len(self.data)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'packet_in (OFPT_PACKET_IN)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_packet_in.show(self, prefix)
- outstr += prefix + 'data is of length ' + str(len(self.data)) + '\n'
- ##@todo Fix this circular reference
- # if len(self.data) > 0:
- # obj = of_message_parse(self.data)
- # if obj != None:
- # outstr += obj.show(prefix)
- # else:
- # outstr += prefix + "Unable to parse data\n"
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_packet_in.__eq__(self, other): return False
- if self.data != other.data: return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class packet_out(ofp_packet_out):
- """
- Wrapper class for packet_out
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (1)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_PACKET_OUT=13)
-
- Data members inherited from ofp_packet_out:
- @arg buffer_id
- @arg in_port
- @arg actions_len
- @arg actions: Object of type action_list
- @arg data: Binary string following message members
-
- """
-
- def __init__(self, **kwargs):
- ofp_packet_out.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_PACKET_OUT
- self.actions = []
- self.data = ""
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- # Coerce keyword arg into list type
- self.actions = action_list(self.actions)
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- self.actions_len = len(self.actions)
- packed += ofp_packet_out.pack(self)
- packed += self.actions.pack()
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_packet_out.unpack(self, binary_string)
- binary_string = self.actions.unpack(binary_string, bytes=self.actions_len)
- self.data = binary_string
- binary_string = ''
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_packet_out.__len__(self)
- length += len(self.actions)
- length += len(self.data)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'packet_out (OFPT_PACKET_OUT)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_packet_out.show(self, prefix)
- outstr += prefix + "List actions\n"
- outstr += self.actions.show(prefix + ' ')
- outstr += prefix + 'data is of length ' + str(len(self.data)) + '\n'
- ##@todo Fix this circular reference
- # if len(self.data) > 0:
- # obj = of_message_parse(self.data)
- # if obj != None:
- # outstr += obj.show(prefix)
- # else:
- # outstr += prefix + "Unable to parse data\n"
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_packet_out.__eq__(self, other): return False
- if self.data != other.data: return False
- if self.actions != other.actions: return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class port_mod(ofp_port_mod):
- """
- Wrapper class for port_mod
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (1)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_PORT_MOD=15)
-
- Data members inherited from ofp_port_mod:
- @arg port_no
- @arg hw_addr
- @arg config
- @arg mask
- @arg advertise
-
- """
-
- def __init__(self, **kwargs):
- ofp_port_mod.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_PORT_MOD
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_port_mod.pack(self)
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_port_mod.unpack(self, binary_string)
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_port_mod.__len__(self)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'port_mod (OFPT_PORT_MOD)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_port_mod.show(self, prefix)
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_port_mod.__eq__(self, other): return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class port_status(ofp_port_status):
- """
- Wrapper class for port_status
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (1)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_PORT_STATUS=12)
-
- Data members inherited from ofp_port_status:
- @arg reason
- @arg desc
-
- """
-
- def __init__(self, **kwargs):
- ofp_port_status.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_PORT_STATUS
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_port_status.pack(self)
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_port_status.unpack(self, binary_string)
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_port_status.__len__(self)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'port_status (OFPT_PORT_STATUS)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_port_status.show(self, prefix)
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_port_status.__eq__(self, other): return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class queue_get_config_reply(ofp_queue_get_config_reply):
- """
- Wrapper class for queue_get_config_reply
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (1)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_QUEUE_GET_CONFIG_REPLY=21)
-
- Data members inherited from ofp_queue_get_config_reply:
- @arg port
- @arg queues: Variable length array of TBD
-
- """
-
- def __init__(self, **kwargs):
- ofp_queue_get_config_reply.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_QUEUE_GET_CONFIG_REPLY
- self.queues = []
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_queue_get_config_reply.pack(self)
- for obj in self.queues:
- packed += obj.pack()
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_queue_get_config_reply.unpack(self, binary_string)
- for obj in self.queues:
- binary_string = obj.unpack(binary_string)
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_queue_get_config_reply.__len__(self)
- for obj in self.queues:
- length += len(obj)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'queue_get_config_reply (OFPT_QUEUE_GET_CONFIG_REPLY)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_queue_get_config_reply.show(self, prefix)
- outstr += prefix + "Array queues\n"
- for obj in self.queues:
- outstr += obj.show(prefix + ' ')
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_queue_get_config_reply.__eq__(self, other): return False
- if self.queues != other.queues: return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class queue_get_config_request(ofp_queue_get_config_request):
- """
- Wrapper class for queue_get_config_request
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (1)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_QUEUE_GET_CONFIG_REQUEST=20)
-
- Data members inherited from ofp_queue_get_config_request:
- @arg port
-
- """
-
- def __init__(self, **kwargs):
- ofp_queue_get_config_request.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_QUEUE_GET_CONFIG_REQUEST
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_queue_get_config_request.pack(self)
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_queue_get_config_request.unpack(self, binary_string)
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_queue_get_config_request.__len__(self)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'queue_get_config_request (OFPT_QUEUE_GET_CONFIG_REQUEST)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_queue_get_config_request.show(self, prefix)
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_queue_get_config_request.__eq__(self, other): return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class set_config(ofp_switch_config):
- """
- Wrapper class for set_config
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (1)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_SET_CONFIG=9)
-
- Data members inherited from ofp_switch_config:
- @arg flags
- @arg miss_send_len
-
- """
-
- def __init__(self, **kwargs):
- ofp_switch_config.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_SET_CONFIG
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_switch_config.pack(self)
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_switch_config.unpack(self, binary_string)
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_switch_config.__len__(self)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'set_config (OFPT_SET_CONFIG)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_switch_config.show(self, prefix)
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_switch_config.__eq__(self, other): return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class stats_reply(ofp_stats_reply):
- """
- Wrapper class for stats_reply
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (1)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_STATS_REPLY=17)
-
- Data members inherited from ofp_stats_reply:
- @arg type
- @arg flags
-
- """
-
- def __init__(self, **kwargs):
- ofp_stats_reply.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_STATS_REPLY
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_stats_reply.pack(self)
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_stats_reply.unpack(self, binary_string)
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_stats_reply.__len__(self)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'stats_reply (OFPT_STATS_REPLY)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_reply.show(self, prefix)
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_stats_reply.__eq__(self, other): return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class stats_request(ofp_stats_request):
- """
- Wrapper class for stats_request
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (1)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_STATS_REQUEST=16)
-
- Data members inherited from ofp_stats_request:
- @arg type
- @arg flags
-
- """
-
- def __init__(self, **kwargs):
- ofp_stats_request.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_STATS_REQUEST
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_stats_request.pack(self)
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_stats_request.unpack(self, binary_string)
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_stats_request.__len__(self)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'stats_request (OFPT_STATS_REQUEST)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_request.show(self, prefix)
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_stats_request.__eq__(self, other): return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class vendor(ofp_vendor_header):
- """
- Wrapper class for vendor
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (1)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_VENDOR=4)
-
- Data members inherited from ofp_vendor_header:
- @arg vendor
- @arg data: Binary string following message members
-
- """
-
- def __init__(self, **kwargs):
- ofp_vendor_header.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_VENDOR
- self.data = ""
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_vendor_header.pack(self)
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_vendor_header.unpack(self, binary_string)
- self.data = binary_string
- binary_string = ''
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_vendor_header.__len__(self)
- length += len(self.data)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'vendor (OFPT_VENDOR)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_vendor_header.show(self, prefix)
- outstr += prefix + 'data is of length ' + str(len(self.data)) + '\n'
- ##@todo Fix this circular reference
- # if len(self.data) > 0:
- # obj = of_message_parse(self.data)
- # if obj != None:
- # outstr += obj.show(prefix)
- # else:
- # outstr += prefix + "Unable to parse data\n"
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_vendor_header.__eq__(self, other): return False
- if self.data != other.data: return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-
-################################################################
-#
-# Stats request and reply subclass definitions
-#
-################################################################
-
-
-# Stats request bodies for desc and table stats are not defined in the
-# OpenFlow header; We define them here. They are empty classes, really
-
-class ofp_desc_stats_request:
- """
- Forced definition of ofp_desc_stats_request (empty class)
- """
- def __init__(self):
- pass
- def pack(self, assertstruct=True):
- return ""
- def unpack(self, binary_string):
- return binary_string
- def __len__(self):
- return 0
- def show(self, prefix=''):
- return prefix + "ofp_desc_stats_request (empty)\n"
- def __eq__(self, other):
- return type(self) == type(other)
- def __ne__(self, other):
- return type(self) != type(other)
-
-OFP_DESC_STATS_REQUEST_BYTES = 0
-
-class ofp_table_stats_request:
- """
- Forced definition of ofp_table_stats_request (empty class)
- """
- def __init__(self):
- pass
- def pack(self, assertstruct=True):
- return ""
- def unpack(self, binary_string):
- return binary_string
- def __len__(self):
- return 0
- def show(self, prefix=''):
- return prefix + "ofp_table_stats_request (empty)\n"
- def __eq__(self, other):
- return type(self) == type(other)
- def __ne__(self, other):
- return type(self) != type(other)
-
-OFP_TABLE_STATS_REQUEST_BYTES = 0
-
-
-
-# Stats entries define the content of one element in a stats
-# reply for the indicated type; define _entry for consistency
-
-aggregate_stats_entry = ofp_aggregate_stats_reply
-desc_stats_entry = ofp_desc_stats
-port_stats_entry = ofp_port_stats
-queue_stats_entry = ofp_queue_stats
-table_stats_entry = ofp_table_stats
-
-
-#
-# Flow stats entry contains an action list of variable length, so
-# it is done by hand
-#
-
-class flow_stats_entry(ofp_flow_stats):
- """
- Special case flow stats entry to handle action list object
- """
- def __init__(self):
- ofp_flow_stats.__init__(self)
- self.actions = action_list()
-
- def pack(self, assertstruct=True):
- self.length = len(self)
- packed = ofp_flow_stats.pack(self, assertstruct)
- packed += self.actions.pack()
- if len(packed) != self.length:
- print("ERROR: flow_stats_entry pack length not equal",
- self.length, len(packed))
- return packed
-
- def unpack(self, binary_string):
- binary_string = ofp_flow_stats.unpack(self, binary_string)
- ai_len = self.length - OFP_FLOW_STATS_BYTES
- if ai_len < 0:
- print("ERROR: flow_stats_entry unpack length too small",
- self.length)
- binary_string = self.actions.unpack(binary_string, bytes=ai_len)
- return binary_string
-
- def __len__(self):
- return OFP_FLOW_STATS_BYTES + len(self.actions)
-
- def show(self, prefix=''):
- outstr = prefix + "flow_stats_entry\n"
- outstr += ofp_flow_stats.show(self, prefix + ' ')
- outstr += self.actions.show(prefix + ' ')
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (ofp_flow_stats.__eq__(self, other) and
- self.actions == other.actions)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class aggregate_stats_request(ofp_stats_request, ofp_aggregate_stats_request):
- """
- Wrapper class for aggregate stats request message
- """
- def __init__(self, **kwargs):
- self.header = ofp_header()
- ofp_stats_request.__init__(self)
- ofp_aggregate_stats_request.__init__(self)
- self.header.type = OFPT_STATS_REQUEST
- self.type = OFPST_AGGREGATE
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_request.pack(self)
- packed += ofp_aggregate_stats_request.pack(self)
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_request.unpack(self, binary_string)
- binary_string = ofp_aggregate_stats_request.unpack(self, binary_string)
- if len(binary_string) != 0:
- print "ERROR unpacking aggregate: extra data"
- return binary_string
-
- def __len__(self):
- return len(self.header) + OFP_STATS_REQUEST_BYTES + \
- OFP_AGGREGATE_STATS_REQUEST_BYTES
-
- def show(self, prefix=''):
- outstr = prefix + "aggregate_stats_request\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_request.show(self)
- outstr += ofp_aggregate_stats_request.show(self)
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_request.__eq__(self, other) and
- ofp_aggregate_stats_request.__eq__(self, other))
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class aggregate_stats_reply(ofp_stats_reply):
- """
- Wrapper class for aggregate stats reply
- """
- def __init__(self):
- self.header = ofp_header()
- ofp_stats_reply.__init__(self)
- self.header.type = OFPT_STATS_REPLY
- self.type = OFPST_AGGREGATE
- # stats: Array of type aggregate_stats_entry
- self.stats = []
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_reply.pack(self)
- for obj in self.stats:
- packed += obj.pack()
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_reply.unpack(self, binary_string)
- dummy = aggregate_stats_entry()
- while len(binary_string) >= len(dummy):
- obj = aggregate_stats_entry()
- binary_string = obj.unpack(binary_string)
- self.stats.append(obj)
- if len(binary_string) != 0:
- print "ERROR unpacking aggregate stats string: extra bytes"
- return binary_string
-
- def __len__(self):
- length = len(self.header) + OFP_STATS_REPLY_BYTES
- for obj in self.stats:
- length += len(obj)
- return length
-
- def show(self, prefix=''):
- outstr = prefix + "aggregate_stats_reply\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_reply.show(self)
- outstr += prefix + "Stats array of length " + str(len(self.stats)) + '\n'
- for obj in self.stats:
- outstr += obj.show()
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_reply.__eq__(self, other) and
- self.stats == other.stats)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class desc_stats_request(ofp_stats_request, ofp_desc_stats_request):
- """
- Wrapper class for desc stats request message
- """
- def __init__(self, **kwargs):
- self.header = ofp_header()
- ofp_stats_request.__init__(self)
- ofp_desc_stats_request.__init__(self)
- self.header.type = OFPT_STATS_REQUEST
- self.type = OFPST_DESC
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_request.pack(self)
- packed += ofp_desc_stats_request.pack(self)
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_request.unpack(self, binary_string)
- binary_string = ofp_desc_stats_request.unpack(self, binary_string)
- if len(binary_string) != 0:
- print "ERROR unpacking desc: extra data"
- return binary_string
-
- def __len__(self):
- return len(self.header) + OFP_STATS_REQUEST_BYTES + \
- OFP_DESC_STATS_REQUEST_BYTES
-
- def show(self, prefix=''):
- outstr = prefix + "desc_stats_request\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_request.show(self)
- outstr += ofp_desc_stats_request.show(self)
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_request.__eq__(self, other) and
- ofp_desc_stats_request.__eq__(self, other))
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class desc_stats_reply(ofp_stats_reply):
- """
- Wrapper class for desc stats reply
- """
- def __init__(self):
- self.header = ofp_header()
- ofp_stats_reply.__init__(self)
- self.header.type = OFPT_STATS_REPLY
- self.type = OFPST_DESC
- # stats: Array of type desc_stats_entry
- self.stats = []
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_reply.pack(self)
- for obj in self.stats:
- packed += obj.pack()
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_reply.unpack(self, binary_string)
- dummy = desc_stats_entry()
- while len(binary_string) >= len(dummy):
- obj = desc_stats_entry()
- binary_string = obj.unpack(binary_string)
- self.stats.append(obj)
- if len(binary_string) != 0:
- print "ERROR unpacking desc stats string: extra bytes"
- return binary_string
-
- def __len__(self):
- length = len(self.header) + OFP_STATS_REPLY_BYTES
- for obj in self.stats:
- length += len(obj)
- return length
-
- def show(self, prefix=''):
- outstr = prefix + "desc_stats_reply\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_reply.show(self)
- outstr += prefix + "Stats array of length " + str(len(self.stats)) + '\n'
- for obj in self.stats:
- outstr += obj.show()
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_reply.__eq__(self, other) and
- self.stats == other.stats)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class flow_stats_request(ofp_stats_request, ofp_flow_stats_request):
- """
- Wrapper class for flow stats request message
- """
- def __init__(self, **kwargs):
- self.header = ofp_header()
- ofp_stats_request.__init__(self)
- ofp_flow_stats_request.__init__(self)
- self.header.type = OFPT_STATS_REQUEST
- self.type = OFPST_FLOW
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_request.pack(self)
- packed += ofp_flow_stats_request.pack(self)
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_request.unpack(self, binary_string)
- binary_string = ofp_flow_stats_request.unpack(self, binary_string)
- if len(binary_string) != 0:
- print "ERROR unpacking flow: extra data"
- return binary_string
-
- def __len__(self):
- return len(self.header) + OFP_STATS_REQUEST_BYTES + \
- OFP_FLOW_STATS_REQUEST_BYTES
-
- def show(self, prefix=''):
- outstr = prefix + "flow_stats_request\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_request.show(self)
- outstr += ofp_flow_stats_request.show(self)
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_request.__eq__(self, other) and
- ofp_flow_stats_request.__eq__(self, other))
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class flow_stats_reply(ofp_stats_reply):
- """
- Wrapper class for flow stats reply
- """
- def __init__(self):
- self.header = ofp_header()
- ofp_stats_reply.__init__(self)
- self.header.type = OFPT_STATS_REPLY
- self.type = OFPST_FLOW
- # stats: Array of type flow_stats_entry
- self.stats = []
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_reply.pack(self)
- for obj in self.stats:
- packed += obj.pack()
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_reply.unpack(self, binary_string)
- dummy = flow_stats_entry()
- while len(binary_string) >= len(dummy):
- obj = flow_stats_entry()
- binary_string = obj.unpack(binary_string)
- self.stats.append(obj)
- if len(binary_string) != 0:
- print "ERROR unpacking flow stats string: extra bytes"
- return binary_string
-
- def __len__(self):
- length = len(self.header) + OFP_STATS_REPLY_BYTES
- for obj in self.stats:
- length += len(obj)
- return length
-
- def show(self, prefix=''):
- outstr = prefix + "flow_stats_reply\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_reply.show(self)
- outstr += prefix + "Stats array of length " + str(len(self.stats)) + '\n'
- for obj in self.stats:
- outstr += obj.show()
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_reply.__eq__(self, other) and
- self.stats == other.stats)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class port_stats_request(ofp_stats_request, ofp_port_stats_request):
- """
- Wrapper class for port stats request message
- """
- def __init__(self, **kwargs):
- self.header = ofp_header()
- ofp_stats_request.__init__(self)
- ofp_port_stats_request.__init__(self)
- self.header.type = OFPT_STATS_REQUEST
- self.type = OFPST_PORT
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_request.pack(self)
- packed += ofp_port_stats_request.pack(self)
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_request.unpack(self, binary_string)
- binary_string = ofp_port_stats_request.unpack(self, binary_string)
- if len(binary_string) != 0:
- print "ERROR unpacking port: extra data"
- return binary_string
-
- def __len__(self):
- return len(self.header) + OFP_STATS_REQUEST_BYTES + \
- OFP_PORT_STATS_REQUEST_BYTES
-
- def show(self, prefix=''):
- outstr = prefix + "port_stats_request\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_request.show(self)
- outstr += ofp_port_stats_request.show(self)
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_request.__eq__(self, other) and
- ofp_port_stats_request.__eq__(self, other))
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class port_stats_reply(ofp_stats_reply):
- """
- Wrapper class for port stats reply
- """
- def __init__(self):
- self.header = ofp_header()
- ofp_stats_reply.__init__(self)
- self.header.type = OFPT_STATS_REPLY
- self.type = OFPST_PORT
- # stats: Array of type port_stats_entry
- self.stats = []
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_reply.pack(self)
- for obj in self.stats:
- packed += obj.pack()
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_reply.unpack(self, binary_string)
- dummy = port_stats_entry()
- while len(binary_string) >= len(dummy):
- obj = port_stats_entry()
- binary_string = obj.unpack(binary_string)
- self.stats.append(obj)
- if len(binary_string) != 0:
- print "ERROR unpacking port stats string: extra bytes"
- return binary_string
-
- def __len__(self):
- length = len(self.header) + OFP_STATS_REPLY_BYTES
- for obj in self.stats:
- length += len(obj)
- return length
-
- def show(self, prefix=''):
- outstr = prefix + "port_stats_reply\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_reply.show(self)
- outstr += prefix + "Stats array of length " + str(len(self.stats)) + '\n'
- for obj in self.stats:
- outstr += obj.show()
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_reply.__eq__(self, other) and
- self.stats == other.stats)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class queue_stats_request(ofp_stats_request, ofp_queue_stats_request):
- """
- Wrapper class for queue stats request message
- """
- def __init__(self, **kwargs):
- self.header = ofp_header()
- ofp_stats_request.__init__(self)
- ofp_queue_stats_request.__init__(self)
- self.header.type = OFPT_STATS_REQUEST
- self.type = OFPST_QUEUE
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_request.pack(self)
- packed += ofp_queue_stats_request.pack(self)
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_request.unpack(self, binary_string)
- binary_string = ofp_queue_stats_request.unpack(self, binary_string)
- if len(binary_string) != 0:
- print "ERROR unpacking queue: extra data"
- return binary_string
-
- def __len__(self):
- return len(self.header) + OFP_STATS_REQUEST_BYTES + \
- OFP_QUEUE_STATS_REQUEST_BYTES
-
- def show(self, prefix=''):
- outstr = prefix + "queue_stats_request\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_request.show(self)
- outstr += ofp_queue_stats_request.show(self)
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_request.__eq__(self, other) and
- ofp_queue_stats_request.__eq__(self, other))
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class queue_stats_reply(ofp_stats_reply):
- """
- Wrapper class for queue stats reply
- """
- def __init__(self):
- self.header = ofp_header()
- ofp_stats_reply.__init__(self)
- self.header.type = OFPT_STATS_REPLY
- self.type = OFPST_QUEUE
- # stats: Array of type queue_stats_entry
- self.stats = []
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_reply.pack(self)
- for obj in self.stats:
- packed += obj.pack()
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_reply.unpack(self, binary_string)
- dummy = queue_stats_entry()
- while len(binary_string) >= len(dummy):
- obj = queue_stats_entry()
- binary_string = obj.unpack(binary_string)
- self.stats.append(obj)
- if len(binary_string) != 0:
- print "ERROR unpacking queue stats string: extra bytes"
- return binary_string
-
- def __len__(self):
- length = len(self.header) + OFP_STATS_REPLY_BYTES
- for obj in self.stats:
- length += len(obj)
- return length
-
- def show(self, prefix=''):
- outstr = prefix + "queue_stats_reply\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_reply.show(self)
- outstr += prefix + "Stats array of length " + str(len(self.stats)) + '\n'
- for obj in self.stats:
- outstr += obj.show()
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_reply.__eq__(self, other) and
- self.stats == other.stats)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class table_stats_request(ofp_stats_request, ofp_table_stats_request):
- """
- Wrapper class for table stats request message
- """
- def __init__(self, **kwargs):
- self.header = ofp_header()
- ofp_stats_request.__init__(self)
- ofp_table_stats_request.__init__(self)
- self.header.type = OFPT_STATS_REQUEST
- self.type = OFPST_TABLE
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_request.pack(self)
- packed += ofp_table_stats_request.pack(self)
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_request.unpack(self, binary_string)
- binary_string = ofp_table_stats_request.unpack(self, binary_string)
- if len(binary_string) != 0:
- print "ERROR unpacking table: extra data"
- return binary_string
-
- def __len__(self):
- return len(self.header) + OFP_STATS_REQUEST_BYTES + \
- OFP_TABLE_STATS_REQUEST_BYTES
-
- def show(self, prefix=''):
- outstr = prefix + "table_stats_request\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_request.show(self)
- outstr += ofp_table_stats_request.show(self)
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_request.__eq__(self, other) and
- ofp_table_stats_request.__eq__(self, other))
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class table_stats_reply(ofp_stats_reply):
- """
- Wrapper class for table stats reply
- """
- def __init__(self):
- self.header = ofp_header()
- ofp_stats_reply.__init__(self)
- self.header.type = OFPT_STATS_REPLY
- self.type = OFPST_TABLE
- # stats: Array of type table_stats_entry
- self.stats = []
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_reply.pack(self)
- for obj in self.stats:
- packed += obj.pack()
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_reply.unpack(self, binary_string)
- dummy = table_stats_entry()
- while len(binary_string) >= len(dummy):
- obj = table_stats_entry()
- binary_string = obj.unpack(binary_string)
- self.stats.append(obj)
- if len(binary_string) != 0:
- print "ERROR unpacking table stats string: extra bytes"
- return binary_string
-
- def __len__(self):
- length = len(self.header) + OFP_STATS_REPLY_BYTES
- for obj in self.stats:
- length += len(obj)
- return length
-
- def show(self, prefix=''):
- outstr = prefix + "table_stats_reply\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_reply.show(self)
- outstr += prefix + "Stats array of length " + str(len(self.stats)) + '\n'
- for obj in self.stats:
- outstr += obj.show()
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_reply.__eq__(self, other) and
- self.stats == other.stats)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-message_type_list = (
- aggregate_stats_reply,
- aggregate_stats_request,
- bad_action_error_msg,
- bad_request_error_msg,
- barrier_reply,
- barrier_request,
- desc_stats_reply,
- desc_stats_request,
- echo_reply,
- echo_request,
- features_reply,
- features_request,
- flow_mod,
- flow_mod_failed_error_msg,
- flow_removed,
- flow_stats_reply,
- flow_stats_request,
- get_config_reply,
- get_config_request,
- hello,
- hello_failed_error_msg,
- packet_in,
- packet_out,
- port_mod,
- port_mod_failed_error_msg,
- port_stats_reply,
- port_stats_request,
- port_status,
- queue_get_config_reply,
- queue_get_config_request,
- queue_op_failed_error_msg,
- queue_stats_reply,
- queue_stats_request,
- set_config,
- table_stats_reply,
- table_stats_request,
- vendor
- )
-
diff --git a/src/python/of10/parse.py b/src/python/of10/parse.py
deleted file mode 100644
index e56b69a..0000000
--- a/src/python/of10/parse.py
+++ /dev/null
@@ -1,343 +0,0 @@
-"""
-OpenFlow message parsing functions
-"""
-
-import sys
-import logging
-import message
-import error
-import action
-import cstruct
-from action_list import action_list
-try:
- import scapy.all as scapy
-except:
- try:
- import scapy as scapy
- except:
- sys.exit("Need to install scapy for packet parsing")
-
-"""
-of_message.py
-Contains wrapper functions and classes for the of_message namespace
-that are generated by hand. It includes the rest of the wrapper
-function information into the of_message namespace
-"""
-
-parse_logger = logging.getLogger("parse")
-#parse_logger.setLevel(logging.DEBUG)
-
-# These message types are subclassed
-msg_type_subclassed = [
- cstruct.OFPT_STATS_REQUEST,
- cstruct.OFPT_STATS_REPLY,
- cstruct.OFPT_ERROR
-]
-
-# Maps from sub-types to classes
-stats_reply_to_class_map = {
- cstruct.OFPST_DESC : message.desc_stats_reply,
- cstruct.OFPST_AGGREGATE : message.aggregate_stats_reply,
- cstruct.OFPST_FLOW : message.flow_stats_reply,
- cstruct.OFPST_TABLE : message.table_stats_reply,
- cstruct.OFPST_PORT : message.port_stats_reply,
- cstruct.OFPST_QUEUE : message.queue_stats_reply
-}
-
-stats_request_to_class_map = {
- cstruct.OFPST_DESC : message.desc_stats_request,
- cstruct.OFPST_AGGREGATE : message.aggregate_stats_request,
- cstruct.OFPST_FLOW : message.flow_stats_request,
- cstruct.OFPST_TABLE : message.table_stats_request,
- cstruct.OFPST_PORT : message.port_stats_request,
- cstruct.OFPST_QUEUE : message.queue_stats_request
-}
-
-error_to_class_map = {
- cstruct.OFPET_HELLO_FAILED : message.hello_failed_error_msg,
- cstruct.OFPET_BAD_REQUEST : message.bad_request_error_msg,
- cstruct.OFPET_BAD_ACTION : message.bad_action_error_msg,
- cstruct.OFPET_FLOW_MOD_FAILED : message.flow_mod_failed_error_msg,
- cstruct.OFPET_PORT_MOD_FAILED : message.port_mod_failed_error_msg,
- cstruct.OFPET_QUEUE_OP_FAILED : message.queue_op_failed_error_msg
-}
-
-# Map from header type value to the underlieing message class
-msg_type_to_class_map = {
- cstruct.OFPT_HELLO : message.hello,
- cstruct.OFPT_ERROR : message.error,
- cstruct.OFPT_ECHO_REQUEST : message.echo_request,
- cstruct.OFPT_ECHO_REPLY : message.echo_reply,
- cstruct.OFPT_VENDOR : message.vendor,
- cstruct.OFPT_FEATURES_REQUEST : message.features_request,
- cstruct.OFPT_FEATURES_REPLY : message.features_reply,
- cstruct.OFPT_GET_CONFIG_REQUEST : message.get_config_request,
- cstruct.OFPT_GET_CONFIG_REPLY : message.get_config_reply,
- cstruct.OFPT_SET_CONFIG : message.set_config,
- cstruct.OFPT_PACKET_IN : message.packet_in,
- cstruct.OFPT_FLOW_REMOVED : message.flow_removed,
- cstruct.OFPT_PORT_STATUS : message.port_status,
- cstruct.OFPT_PACKET_OUT : message.packet_out,
- cstruct.OFPT_FLOW_MOD : message.flow_mod,
- cstruct.OFPT_PORT_MOD : message.port_mod,
- cstruct.OFPT_STATS_REQUEST : message.stats_request,
- cstruct.OFPT_STATS_REPLY : message.stats_reply,
- cstruct.OFPT_BARRIER_REQUEST : message.barrier_request,
- cstruct.OFPT_BARRIER_REPLY : message.barrier_reply,
- cstruct.OFPT_QUEUE_GET_CONFIG_REQUEST : message.queue_get_config_request,
- cstruct.OFPT_QUEUE_GET_CONFIG_REPLY : message.queue_get_config_reply
-}
-
-def _of_message_to_object(binary_string):
- """
- Map a binary string to the corresponding class.
-
- Appropriately resolves subclasses
- """
- hdr = message.ofp_header()
- hdr.unpack(binary_string)
- # FIXME: Add error detection
- if not hdr.type in msg_type_subclassed:
- return msg_type_to_class_map[hdr.type]()
- if hdr.type == cstruct.OFPT_STATS_REQUEST:
- sub_hdr = message.ofp_stats_request()
- sub_hdr.unpack(binary_string[cstruct.OFP_HEADER_BYTES:])
- try:
- obj = stats_request_to_class_map[sub_hdr.type]()
- except KeyError:
- obj = None
- return obj
- elif hdr.type == cstruct.OFPT_STATS_REPLY:
- sub_hdr = message.ofp_stats_reply()
- sub_hdr.unpack(binary_string[cstruct.OFP_HEADER_BYTES:])
- try:
- obj = stats_reply_to_class_map[sub_hdr.type]()
- except KeyError:
- obj = None
- return obj
- elif hdr.type == cstruct.OFPT_ERROR:
- sub_hdr = message.ofp_error_msg()
- sub_hdr.unpack(binary_string[cstruct.OFP_HEADER_BYTES:])
- return error_to_class_map[sub_hdr.type]()
- else:
- parse_logger.error("Cannot parse pkt to message")
- return None
-
-def of_message_parse(binary_string, raw=False):
- """
- Parse an OpenFlow packet
-
- Parses a raw OpenFlow packet into a Python class, with class
- members fully populated.
-
- @param binary_string The packet (string) to be parsed
- @param raw If true, interpret the packet as an L2 packet. Not
- yet supported.
- @return An object of some message class or None if fails
- Note that any data beyond that parsed is not returned
-
- """
-
- if raw:
- parse_logger.error("raw packet message parsing not supported")
- return None
-
- obj = _of_message_to_object(binary_string)
- if obj:
- obj.unpack(binary_string)
- return obj
-
-
-def of_header_parse(binary_string, raw=False):
- """
- Parse only the header from an OpenFlow packet
-
- Parses the header from a raw OpenFlow packet into a
- an ofp_header Python class.
-
- @param binary_string The packet (string) to be parsed
- @param raw If true, interpret the packet as an L2 packet. Not
- yet supported.
- @return An ofp_header object
-
- """
-
- if raw:
- parse_logger.error("raw packet message parsing not supported")
- return None
-
- hdr = message.ofp_header()
- hdr.unpack(binary_string)
-
- return hdr
-
-map_wc_field_to_match_member = {
- 'OFPFW_DL_VLAN' : 'dl_vlan',
- 'OFPFW_DL_SRC' : 'dl_src',
- 'OFPFW_DL_DST' : 'dl_dst',
- 'OFPFW_DL_TYPE' : 'dl_type',
- 'OFPFW_NW_PROTO' : 'nw_proto',
- 'OFPFW_TP_SRC' : 'tp_src',
- 'OFPFW_TP_DST' : 'tp_dst',
- 'OFPFW_NW_SRC_SHIFT' : 'nw_src_shift',
- 'OFPFW_NW_SRC_BITS' : 'nw_src_bits',
- 'OFPFW_NW_SRC_MASK' : 'nw_src_mask',
- 'OFPFW_NW_SRC_ALL' : 'nw_src_all',
- 'OFPFW_NW_DST_SHIFT' : 'nw_dst_shift',
- 'OFPFW_NW_DST_BITS' : 'nw_dst_bits',
- 'OFPFW_NW_DST_MASK' : 'nw_dst_mask',
- 'OFPFW_NW_DST_ALL' : 'nw_dst_all',
- 'OFPFW_DL_VLAN_PCP' : 'dl_vlan_pcp',
- 'OFPFW_NW_TOS' : 'nw_tos'
-}
-
-
-def parse_mac(mac_str):
- """
- Parse a MAC address
-
- Parse a MAC address ':' separated string of hex digits to an
- array of integer values. '00:d0:05:5d:24:00' => [0, 208, 5, 93, 36, 0]
- @param mac_str The string to convert
- @return Array of 6 integer values
- """
- return map(lambda val: int(val, 16), mac_str.split(":"))
-
-def parse_ip(ip_str):
- """
- Parse an IP address
-
- Parse an IP address '.' separated string of decimal digits to an
- host ordered integer. '172.24.74.77' =>
- @param ip_str The string to convert
- @return Integer value
- """
- array = map(lambda val: int(val), ip_str.split("."))
- val = 0
- for a in array:
- val <<= 8
- val += a
- return val
-
-def packet_type_classify(ether):
- try:
- dot1q = ether[scapy.Dot1Q]
- except:
- dot1q = None
-
- try:
- ip = ether[scapy.IP]
- except:
- ip = None
-
- try:
- tcp = ether[scapy.TCP]
- except:
- tcp = None
-
- try:
- udp = ether[scapy.UDP]
- except:
- udp = None
-
- try:
- icmp = ether[scapy.ICMP]
- except:
- icmp = None
-
- try:
- arp = ether[scapy.ARP]
- except:
- arp = None
- return (dot1q, ip, tcp, udp, icmp, arp)
-
-def packet_to_flow_match(packet, pkt_format="L2"):
- """
- Create a flow match that matches packet with the given wildcards
-
- @param packet The packet to use as a flow template
- @param pkt_format Currently only L2 is supported. Will indicate the
- overall packet type for parsing
- @return An ofp_match object if successful. None if format is not
- recognized. The wildcards of the match will be cleared for the
- values extracted from the packet.
-
- @todo check min length of packet
- @todo Check if packet is other than L2 format
- @todo Implement ICMP and ARP fields
- """
-
- #@todo check min length of packet
- if pkt_format.upper() != "L2":
- parse_logger.error("Only L2 supported for packet_to_flow")
- return None
-
- if type(packet) == type(""):
- ether = scapy.Ether(packet)
- else:
- ether = packet
-
- # For now, assume ether IP packet and ignore wildcards
- try:
- (dot1q, ip, tcp, udp, icmp, arp) = packet_type_classify(ether)
- except:
- parse_logger.error("packet_to_flow_match: Classify error")
- return None
-
- match = cstruct.ofp_match()
- match.wildcards = cstruct.OFPFW_ALL
- #@todo Check if packet is other than L2 format
- match.dl_dst = parse_mac(ether.dst)
- match.wildcards &= ~cstruct.OFPFW_DL_DST
- match.dl_src = parse_mac(ether.src)
- match.wildcards &= ~cstruct.OFPFW_DL_SRC
- match.dl_type = ether.type
- match.wildcards &= ~cstruct.OFPFW_DL_TYPE
-
- if dot1q:
- match.dl_vlan = dot1q.vlan
- match.dl_vlan_pcp = dot1q.prio
- match.dl_type = dot1q.type
- else:
- match.dl_vlan = cstruct.OFP_VLAN_NONE
- match.dl_vlan_pcp = 0
- match.wildcards &= ~cstruct.OFPFW_DL_VLAN
- match.wildcards &= ~cstruct.OFPFW_DL_VLAN_PCP
-
- if ip:
- match.nw_src = parse_ip(ip.src)
- match.wildcards &= ~cstruct.OFPFW_NW_SRC_MASK
- match.nw_dst = parse_ip(ip.dst)
- match.wildcards &= ~cstruct.OFPFW_NW_DST_MASK
- match.nw_tos = ip.tos
- match.wildcards &= ~cstruct.OFPFW_NW_TOS
-
- if tcp:
- match.nw_proto = 6
- match.wildcards &= ~cstruct.OFPFW_NW_PROTO
- elif not tcp and udp:
- tcp = udp
- match.nw_proto = 17
- match.wildcards &= ~cstruct.OFPFW_NW_PROTO
-
- if tcp:
- match.tp_src = tcp.sport
- match.wildcards &= ~cstruct.OFPFW_TP_SRC
- match.tp_dst = tcp.dport
- match.wildcards &= ~cstruct.OFPFW_TP_DST
-
- if icmp:
- match.nw_proto = 1
- match.tp_src = icmp.type
- match.tp_dst = icmp.code
- match.wildcards &= ~cstruct.OFPFW_NW_PROTO
-
- if arp:
- match.nw_proto = arp.op
- match.wildcards &= ~cstruct.OFPFW_NW_PROTO
- match.nw_src = parse_ip(arp.psrc)
- match.wildcards &= ~cstruct.OFPFW_NW_SRC_MASK
- match.nw_dst = parse_ip(arp.pdst)
- match.wildcards &= ~cstruct.OFPFW_NW_DST_MASK
-
- return match
diff --git a/src/python/of11/__init__.py b/src/python/of11/__init__.py
deleted file mode 100644
index c4407ee..0000000
--- a/src/python/of11/__init__.py
+++ /dev/null
@@ -1,8 +0,0 @@
-"""
-Python OpenFlow 1.0 library
-
-Most of the files in this package are automatically generated by tools/munger.
-They are checked in to simplify running OFTest.
-"""
-
-__all__ = ["action_list", "action", "cstruct", "error", "message", "parse"]
diff --git a/src/python/of11/action.py b/src/python/of11/action.py
deleted file mode 100644
index 447cd17..0000000
--- a/src/python/of11/action.py
+++ /dev/null
@@ -1,550 +0,0 @@
-
-# Python OpenFlow action wrapper classes
-
-from cstruct import *
-
-
-
-class action_set_nw_src(ofp_action_nw_addr):
- """
- Wrapper class for set_nw_src action object
-
- Data members inherited from ofp_action_nw_addr:
- @arg type
- @arg len
- @arg nw_addr
-
- """
- def __init__(self):
- ofp_action_nw_addr.__init__(self)
- self.type = OFPAT_SET_NW_SRC
- self.len = self.__len__()
- def show(self, prefix=''):
- outstr = prefix + "action_set_nw_src\n"
- outstr += ofp_action_nw_addr.show(self, prefix)
- return outstr
-
-
-class action_set_mpls_tc(ofp_action_mpls_tc):
- """
- Wrapper class for set_mpls_tc action object
-
- Data members inherited from ofp_action_mpls_tc:
- @arg type
- @arg len
- @arg mpls_tc
-
- """
- def __init__(self):
- ofp_action_mpls_tc.__init__(self)
- self.type = OFPAT_SET_MPLS_TC
- self.len = self.__len__()
- def show(self, prefix=''):
- outstr = prefix + "action_set_mpls_tc\n"
- outstr += ofp_action_mpls_tc.show(self, prefix)
- return outstr
-
-
-class action_set_nw_tos(ofp_action_nw_tos):
- """
- Wrapper class for set_nw_tos action object
-
- Data members inherited from ofp_action_nw_tos:
- @arg type
- @arg len
- @arg nw_tos
-
- """
- def __init__(self):
- ofp_action_nw_tos.__init__(self)
- self.type = OFPAT_SET_NW_TOS
- self.len = self.__len__()
- def show(self, prefix=''):
- outstr = prefix + "action_set_nw_tos\n"
- outstr += ofp_action_nw_tos.show(self, prefix)
- return outstr
-
-
-class action_dec_mpls_ttl(ofp_action_header):
- """
- Wrapper class for dec_mpls_ttl action object
-
- Data members inherited from ofp_action_header:
- @arg type
- @arg len
-
- """
- def __init__(self):
- ofp_action_header.__init__(self)
- self.type = OFPAT_DEC_MPLS_TTL
- self.len = self.__len__()
- def show(self, prefix=''):
- outstr = prefix + "action_dec_mpls_ttl\n"
- outstr += ofp_action_header.show(self, prefix)
- return outstr
-
-
-class action_set_nw_dst(ofp_action_nw_addr):
- """
- Wrapper class for set_nw_dst action object
-
- Data members inherited from ofp_action_nw_addr:
- @arg type
- @arg len
- @arg nw_addr
-
- """
- def __init__(self):
- ofp_action_nw_addr.__init__(self)
- self.type = OFPAT_SET_NW_DST
- self.len = self.__len__()
- def show(self, prefix=''):
- outstr = prefix + "action_set_nw_dst\n"
- outstr += ofp_action_nw_addr.show(self, prefix)
- return outstr
-
-
-class action_set_mpls_label(ofp_action_mpls_label):
- """
- Wrapper class for set_mpls_label action object
-
- Data members inherited from ofp_action_mpls_label:
- @arg type
- @arg len
- @arg mpls_label
-
- """
- def __init__(self):
- ofp_action_mpls_label.__init__(self)
- self.type = OFPAT_SET_MPLS_LABEL
- self.len = self.__len__()
- def show(self, prefix=''):
- outstr = prefix + "action_set_mpls_label\n"
- outstr += ofp_action_mpls_label.show(self, prefix)
- return outstr
-
-
-class action_group(ofp_action_group):
- """
- Wrapper class for group action object
-
- Data members inherited from ofp_action_group:
- @arg type
- @arg len
- @arg group_id
-
- """
- def __init__(self):
- ofp_action_group.__init__(self)
- self.type = OFPAT_GROUP
- self.len = self.__len__()
- def show(self, prefix=''):
- outstr = prefix + "action_group\n"
- outstr += ofp_action_group.show(self, prefix)
- return outstr
-
-
-class action_copy_ttl_out(ofp_action_header):
- """
- Wrapper class for copy_ttl_out action object
-
- Data members inherited from ofp_action_header:
- @arg type
- @arg len
-
- """
- def __init__(self):
- ofp_action_header.__init__(self)
- self.type = OFPAT_COPY_TTL_OUT
- self.len = self.__len__()
- def show(self, prefix=''):
- outstr = prefix + "action_copy_ttl_out\n"
- outstr += ofp_action_header.show(self, prefix)
- return outstr
-
-
-class action_set_vlan_vid(ofp_action_vlan_vid):
- """
- Wrapper class for set_vlan_vid action object
-
- Data members inherited from ofp_action_vlan_vid:
- @arg type
- @arg len
- @arg vlan_vid
-
- """
- def __init__(self):
- ofp_action_vlan_vid.__init__(self)
- self.type = OFPAT_SET_VLAN_VID
- self.len = self.__len__()
- def show(self, prefix=''):
- outstr = prefix + "action_set_vlan_vid\n"
- outstr += ofp_action_vlan_vid.show(self, prefix)
- return outstr
-
-
-class action_set_mpls_ttl(ofp_action_mpls_ttl):
- """
- Wrapper class for set_mpls_ttl action object
-
- Data members inherited from ofp_action_mpls_ttl:
- @arg type
- @arg len
- @arg mpls_ttl
-
- """
- def __init__(self):
- ofp_action_mpls_ttl.__init__(self)
- self.type = OFPAT_SET_MPLS_TTL
- self.len = self.__len__()
- def show(self, prefix=''):
- outstr = prefix + "action_set_mpls_ttl\n"
- outstr += ofp_action_mpls_ttl.show(self, prefix)
- return outstr
-
-
-class action_pop_vlan(ofp_action_header):
- """
- Wrapper class for pop_vlan action object
-
- Data members inherited from ofp_action_header:
- @arg type
- @arg len
-
- """
- def __init__(self):
- ofp_action_header.__init__(self)
- self.type = OFPAT_POP_VLAN
- self.len = self.__len__()
- def show(self, prefix=''):
- outstr = prefix + "action_pop_vlan\n"
- outstr += ofp_action_header.show(self, prefix)
- return outstr
-
-
-class action_set_tp_dst(ofp_action_tp_port):
- """
- Wrapper class for set_tp_dst action object
-
- Data members inherited from ofp_action_tp_port:
- @arg type
- @arg len
- @arg tp_port
-
- """
- def __init__(self):
- ofp_action_tp_port.__init__(self)
- self.type = OFPAT_SET_TP_DST
- self.len = self.__len__()
- def show(self, prefix=''):
- outstr = prefix + "action_set_tp_dst\n"
- outstr += ofp_action_tp_port.show(self, prefix)
- return outstr
-
-
-class action_pop_mpls(ofp_action_pop_mpls):
- """
- Wrapper class for pop_mpls action object
-
- Data members inherited from ofp_action_pop_mpls:
- @arg type
- @arg len
- @arg ethertype
-
- """
- def __init__(self):
- ofp_action_pop_mpls.__init__(self)
- self.type = OFPAT_POP_MPLS
- self.len = self.__len__()
- def show(self, prefix=''):
- outstr = prefix + "action_pop_mpls\n"
- outstr += ofp_action_pop_mpls.show(self, prefix)
- return outstr
-
-
-class action_push_vlan(ofp_action_push):
- """
- Wrapper class for push_vlan action object
-
- Data members inherited from ofp_action_push:
- @arg type
- @arg len
- @arg ethertype
-
- """
- def __init__(self):
- ofp_action_push.__init__(self)
- self.type = OFPAT_PUSH_VLAN
- self.len = self.__len__()
- def show(self, prefix=''):
- outstr = prefix + "action_push_vlan\n"
- outstr += ofp_action_push.show(self, prefix)
- return outstr
-
-
-class action_set_vlan_pcp(ofp_action_vlan_pcp):
- """
- Wrapper class for set_vlan_pcp action object
-
- Data members inherited from ofp_action_vlan_pcp:
- @arg type
- @arg len
- @arg vlan_pcp
-
- """
- def __init__(self):
- ofp_action_vlan_pcp.__init__(self)
- self.type = OFPAT_SET_VLAN_PCP
- self.len = self.__len__()
- def show(self, prefix=''):
- outstr = prefix + "action_set_vlan_pcp\n"
- outstr += ofp_action_vlan_pcp.show(self, prefix)
- return outstr
-
-
-class action_set_tp_src(ofp_action_tp_port):
- """
- Wrapper class for set_tp_src action object
-
- Data members inherited from ofp_action_tp_port:
- @arg type
- @arg len
- @arg tp_port
-
- """
- def __init__(self):
- ofp_action_tp_port.__init__(self)
- self.type = OFPAT_SET_TP_SRC
- self.len = self.__len__()
- def show(self, prefix=''):
- outstr = prefix + "action_set_tp_src\n"
- outstr += ofp_action_tp_port.show(self, prefix)
- return outstr
-
-
-class action_experimenter(ofp_action_experimenter_header):
- """
- Wrapper class for experimenter action object
-
- Data members inherited from ofp_action_experimenter_header:
- @arg type
- @arg len
- @arg experimenter
-
- """
- def __init__(self):
- ofp_action_experimenter_header.__init__(self)
- self.type = OFPAT_EXPERIMENTER
- self.len = self.__len__()
- def show(self, prefix=''):
- outstr = prefix + "action_experimenter\n"
- outstr += ofp_action_experimenter_header.show(self, prefix)
- return outstr
-
-
-class action_set_nw_ttl(ofp_action_nw_ttl):
- """
- Wrapper class for set_nw_ttl action object
-
- Data members inherited from ofp_action_nw_ttl:
- @arg type
- @arg len
- @arg nw_ttl
-
- """
- def __init__(self):
- ofp_action_nw_ttl.__init__(self)
- self.type = OFPAT_SET_NW_TTL
- self.len = self.__len__()
- def show(self, prefix=''):
- outstr = prefix + "action_set_nw_ttl\n"
- outstr += ofp_action_nw_ttl.show(self, prefix)
- return outstr
-
-
-class action_copy_ttl_in(ofp_action_header):
- """
- Wrapper class for copy_ttl_in action object
-
- Data members inherited from ofp_action_header:
- @arg type
- @arg len
-
- """
- def __init__(self):
- ofp_action_header.__init__(self)
- self.type = OFPAT_COPY_TTL_IN
- self.len = self.__len__()
- def show(self, prefix=''):
- outstr = prefix + "action_copy_ttl_in\n"
- outstr += ofp_action_header.show(self, prefix)
- return outstr
-
-
-class action_set_nw_ecn(ofp_action_nw_ecn):
- """
- Wrapper class for set_nw_ecn action object
-
- Data members inherited from ofp_action_nw_ecn:
- @arg type
- @arg len
- @arg nw_ecn
-
- """
- def __init__(self):
- ofp_action_nw_ecn.__init__(self)
- self.type = OFPAT_SET_NW_ECN
- self.len = self.__len__()
- def show(self, prefix=''):
- outstr = prefix + "action_set_nw_ecn\n"
- outstr += ofp_action_nw_ecn.show(self, prefix)
- return outstr
-
-
-class action_set_dl_dst(ofp_action_dl_addr):
- """
- Wrapper class for set_dl_dst action object
-
- Data members inherited from ofp_action_dl_addr:
- @arg type
- @arg len
- @arg dl_addr
-
- """
- def __init__(self):
- ofp_action_dl_addr.__init__(self)
- self.type = OFPAT_SET_DL_DST
- self.len = self.__len__()
- def show(self, prefix=''):
- outstr = prefix + "action_set_dl_dst\n"
- outstr += ofp_action_dl_addr.show(self, prefix)
- return outstr
-
-
-class action_push_mpls(ofp_action_push):
- """
- Wrapper class for push_mpls action object
-
- Data members inherited from ofp_action_push:
- @arg type
- @arg len
- @arg ethertype
-
- """
- def __init__(self):
- ofp_action_push.__init__(self)
- self.type = OFPAT_PUSH_MPLS
- self.len = self.__len__()
- def show(self, prefix=''):
- outstr = prefix + "action_push_mpls\n"
- outstr += ofp_action_push.show(self, prefix)
- return outstr
-
-
-class action_dec_nw_ttl(ofp_action_header):
- """
- Wrapper class for dec_nw_ttl action object
-
- Data members inherited from ofp_action_header:
- @arg type
- @arg len
-
- """
- def __init__(self):
- ofp_action_header.__init__(self)
- self.type = OFPAT_DEC_NW_TTL
- self.len = self.__len__()
- def show(self, prefix=''):
- outstr = prefix + "action_dec_nw_ttl\n"
- outstr += ofp_action_header.show(self, prefix)
- return outstr
-
-
-class action_set_dl_src(ofp_action_dl_addr):
- """
- Wrapper class for set_dl_src action object
-
- Data members inherited from ofp_action_dl_addr:
- @arg type
- @arg len
- @arg dl_addr
-
- """
- def __init__(self):
- ofp_action_dl_addr.__init__(self)
- self.type = OFPAT_SET_DL_SRC
- self.len = self.__len__()
- def show(self, prefix=''):
- outstr = prefix + "action_set_dl_src\n"
- outstr += ofp_action_dl_addr.show(self, prefix)
- return outstr
-
-
-class action_set_queue(ofp_action_set_queue):
- """
- Wrapper class for set_queue action object
-
- Data members inherited from ofp_action_set_queue:
- @arg type
- @arg len
- @arg queue_id
-
- """
- def __init__(self):
- ofp_action_set_queue.__init__(self)
- self.type = OFPAT_SET_QUEUE
- self.len = self.__len__()
- def show(self, prefix=''):
- outstr = prefix + "action_set_queue\n"
- outstr += ofp_action_set_queue.show(self, prefix)
- return outstr
-
-
-class action_output(ofp_action_output):
- """
- Wrapper class for output action object
-
- Data members inherited from ofp_action_output:
- @arg type
- @arg len
- @arg port
- @arg max_len
-
- """
- def __init__(self):
- ofp_action_output.__init__(self)
- self.type = OFPAT_OUTPUT
- self.len = self.__len__()
- def show(self, prefix=''):
- outstr = prefix + "action_output\n"
- outstr += ofp_action_output.show(self, prefix)
- return outstr
-
-action_class_list = (
- action_copy_ttl_in,
- action_copy_ttl_out,
- action_dec_mpls_ttl,
- action_dec_nw_ttl,
- action_experimenter,
- action_group,
- action_output,
- action_pop_mpls,
- action_pop_vlan,
- action_push_mpls,
- action_push_vlan,
- action_set_dl_dst,
- action_set_dl_src,
- action_set_mpls_label,
- action_set_mpls_tc,
- action_set_mpls_ttl,
- action_set_nw_dst,
- action_set_nw_ecn,
- action_set_nw_src,
- action_set_nw_tos,
- action_set_nw_ttl,
- action_set_queue,
- action_set_tp_dst,
- action_set_tp_src,
- action_set_vlan_pcp,
- action_set_vlan_vid)
-
diff --git a/src/python/of11/action_list.py b/src/python/of11/action_list.py
deleted file mode 100644
index 878050b..0000000
--- a/src/python/of11/action_list.py
+++ /dev/null
@@ -1,97 +0,0 @@
-"""
-OpenFlow action, instruction and bucket list classes
-"""
-
-from action import *
-from cstruct import ofp_header
-from base_list import ofp_base_list
-import copy
-
-action_object_map = {
- OFPAT_OUTPUT : action_output,
- OFPAT_SET_VLAN_VID : action_set_vlan_vid,
- OFPAT_SET_VLAN_PCP : action_set_vlan_pcp,
- OFPAT_SET_DL_SRC : action_set_dl_src,
- OFPAT_SET_DL_DST : action_set_dl_dst,
- OFPAT_SET_NW_SRC : action_set_nw_src,
- OFPAT_SET_NW_DST : action_set_nw_dst,
- OFPAT_SET_NW_TOS : action_set_nw_tos,
- OFPAT_SET_NW_ECN : action_set_nw_ecn,
- OFPAT_SET_TP_SRC : action_set_tp_src,
- OFPAT_SET_TP_DST : action_set_tp_dst,
- OFPAT_COPY_TTL_OUT : action_copy_ttl_out,
- OFPAT_COPY_TTL_IN : action_copy_ttl_in,
- OFPAT_SET_MPLS_LABEL : action_set_mpls_label,
- OFPAT_SET_MPLS_TC : action_set_mpls_tc,
- OFPAT_SET_MPLS_TTL : action_set_mpls_ttl,
- OFPAT_DEC_MPLS_TTL : action_dec_mpls_ttl,
- OFPAT_PUSH_VLAN : action_push_vlan,
- OFPAT_POP_VLAN : action_pop_vlan,
- OFPAT_PUSH_MPLS : action_push_mpls,
- OFPAT_POP_MPLS : action_pop_mpls,
- OFPAT_SET_QUEUE : action_set_queue,
- OFPAT_GROUP : action_group,
- OFPAT_SET_NW_TTL : action_set_nw_ttl,
- OFPAT_DEC_NW_TTL : action_dec_nw_ttl,
- OFPAT_EXPERIMENTER : action_experimenter
-}
-
-class action_list(ofp_base_list):
- """
- Maintain a list of actions
-
- Data members:
- @arg actions: An array of action objects such as action_output, etc.
-
- Methods:
- @arg pack: Pack the structure into a string
- @arg unpack: Unpack a string to objects, with proper typing
- @arg add: Add an action to the list; you can directly access
- the action member, but add will validate that the added object
- is an action.
-
- """
-
- def __init__(self):
- ofp_base_list.__init__(self)
- self.actions = self.items
- self.name = "action"
- self.class_list = action_class_list
-
- def unpack(self, binary_string, bytes=None):
- """
- Unpack a list of actions
-
- Unpack actions from a binary string, creating an array
- of objects of the appropriate type
-
- @param binary_string The string to be unpacked
-
- @param bytes The total length of the action list in bytes.
- Ignored if decode is True. If None and decode is false, the
- list is assumed to extend through the entire string.
-
- @return The remainder of binary_string that was not parsed
-
- """
- if bytes == None:
- bytes = len(binary_string)
- bytes_done = 0
- count = 0
- cur_string = binary_string
- while bytes_done < bytes:
- hdr = ofp_action_header()
- hdr.unpack(cur_string)
- if hdr.len < OFP_ACTION_HEADER_BYTES:
- print "ERROR: Action too short"
- break
- if not hdr.type in action_object_map.keys():
- print "WARNING: Skipping unknown action ", hdr.type, hdr.len
- else:
- self.actions.append(action_object_map[hdr.type]())
- self.actions[count].unpack(cur_string)
- count += 1
- cur_string = cur_string[hdr.len:]
- bytes_done += hdr.len
- return cur_string
-
diff --git a/src/python/of11/base_list.py b/src/python/of11/base_list.py
deleted file mode 100644
index 938c68e..0000000
--- a/src/python/of11/base_list.py
+++ /dev/null
@@ -1,158 +0,0 @@
-
-"""
-Base list class for inheritance.
-Most of the list stuff is common; unpacking is the only thing that
-is left pure virtual.
-"""
-
-import copy
-
-class ofp_base_list(object):
- """
- Container type to maintain a list of ofp objects
-
- Data members:
- @arg items An array of objects
- @arg class_list A tuple of classes that may be added to the list;
- If None, no checking is done
- @arg name The name to use when displaying the list
-
- Methods:
- @arg pack Pack the structure into a string
- @arg unpack Unpack a string to objects, with proper typing
- @arg add Add an item to the list; you can directly access
- the item member, but add will validate that the added object
- is of the right type.
- @arg extend Add the items for another list to this list
-
- """
-
- def __init__(self):
- self.items = []
- self.class_list = None
- self.name = "unspecified"
-
- def pack(self):
- """
- Pack a list of items
-
- Returns the packed string
- """
- packed = ""
- for obj in self.items:
- packed += obj.pack()
- return packed
-
- def unpack(self, binary_string, bytes=None):
- """
- Pure virtual function for a list of items
-
- Unpack items from a binary string, creating an array
- of objects of the appropriate type
-
- @param binary_string The string to be unpacked
-
- @param bytes The total length of the list in bytes.
- Ignored if decode is True. If None and decode is false, the
- list is assumed to extend through the entire string.
-
- @return The remainder of binary_string that was not parsed
- """
- pass
-
- def add(self, item):
- """
- Add an item to a list
-
- @param item The item to add
- @return True if successful, False if not proper type object
-
- """
-
- # Note that the second arg of isinstance can be a list which
- # checks that the type of item is in the list
- if (self.class_list is not None) and \
- not isinstance(item, tuple(self.class_list)):
- return False
-
- tmp = copy.deepcopy(item)
- self.items.append(tmp)
- return True
-
- def remove_type(self, target):
- """
- Remove the first item on the list of the given type
-
- @param target The type of item to search
-
- @return The object removed, if any; otherwise None
-
- """
- for index in xrange(len(self.items)):
- if self.items[index].type == target:
- return self.items.pop(index)
- return None
-
- def find_type(self, target):
- """
- Find the first item on the list of the given type
-
- @param target The type of item to search
-
- @return The object with the matching type if any; otherwise None
-
- """
- for index in xrange(len(self.items)):
- if self.items[index].type == target:
- return self.items[index]
- return None
-
- def extend(self, other):
- """
- Add the items in other to this list
-
- @param other An object of the same type of list whose
- entries are to be merged into this list
-
- @return True if successful. If not successful, the list
- may have been modified.
-
- @todo Check if this is proper deep copy or not
-
- """
- for act in other.items:
- if not self.add(act):
- return False
- return True
-
- def __len__(self):
- """
- Length of the list packed as a string
- """
- length = 0
- for item in self.items:
- length += item.__len__()
- return length
-
- def __eq__(self, other):
- if type(self) != type(other):
- return False
- if self.items != other.items:
- return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- # Methods to make class iterable
- def __iter__(self):
- return self.items.__iter__()
-
- def show(self, prefix=''):
- outstr = prefix + self.name + "list with " + str(len(self.items)) + \
- " items\n"
- count = 0
- for obj in self.items:
- count += 1
- outstr += prefix + " " + self.name + " " + str(count) + ": \n"
- outstr += obj.show(prefix + ' ')
- return outstr
diff --git a/src/python/of11/bucket.py b/src/python/of11/bucket.py
deleted file mode 100644
index 64caed1..0000000
--- a/src/python/of11/bucket.py
+++ /dev/null
@@ -1,42 +0,0 @@
-
-# Python OpenFlow bucket wrapper class
-
-from cstruct import ofp_bucket
-from action_list import action_list
-
-
-
-class bucket(ofp_bucket):
- """
- Wrapper class for bucket object
-
- Data members inherited from ofp_bucket:
- @arg len
- @arg weight
- @arg watch_port
- @arg watch_group
-
- """
- def __init__(self):
- ofp_bucket.__init__(self)
- self.actions = action_list()
- self.type = None
- self.len = self.__len__()
- def show(self, prefix=''):
- outstr = prefix + "bucket\n"
- outstr += ofp_bucket.show(self, prefix)
- outstr += self.actions.show()
- return outstr
- def unpack(self, binary_string):
- binary_string = ofp_bucket.unpack(self, binary_string)
- self.actions = action_list()
- return self.actions.unpack(binary_string)
- def pack(self):
- self.len = len(self)
- packed = ""
- packed += ofp_bucket.pack(self)
- packed += self.actions.pack()
- return packed
- def __len__(self):
- return ofp_bucket.__len__(self) + self.actions.__len__()
-
diff --git a/src/python/of11/bucket_list.py b/src/python/of11/bucket_list.py
deleted file mode 100644
index 33d9472..0000000
--- a/src/python/of11/bucket_list.py
+++ /dev/null
@@ -1,52 +0,0 @@
-
-from base_list import ofp_base_list
-from bucket import bucket
-
-class bucket_list(ofp_base_list):
- """
- Maintain a list of instructions
-
- Data members:
- @arg instructions An array of instructions such as write_actions
-
- Methods:
- @arg pack: Pack the structure into a string
- @arg unpack: Unpack a string to objects, with proper typing
- @arg add: Add an action to the list; you can directly access
- the action member, but add will validate that the added object
- is an action.
-
- """
-
- def __init__(self):
- ofp_base_list.__init__(self)
- self.buckets = self.items
- self.name = "buckets"
- self.class_list = (bucket,)
-
- def unpack(self, binary_string, bytes=None):
- """
- Unpack a list of buckets
-
- Unpack buckets from a binary string, creating an array
- of objects of the appropriate type
-
- @param binary_string The string to be unpacked
-
- @param bytes The total length of the instruction list in bytes.
- Ignored if decode is True. If bytes is None and decode is false, the
- list is assumed to extend through the entire string.
-
- @return The remainder of binary_string that was not parsed
-
- """
- if bytes == None:
- bytes = len(binary_string)
- bytes_done = 0
- cur_string = binary_string
- while bytes_done < bytes:
- b = bucket()
- cur_string = b.unpack(cur_string)
- self.buckets.append(b)
- bytes_done += len(b)
- return cur_string
diff --git a/src/python/of11/class_maps.py b/src/python/of11/class_maps.py
deleted file mode 100644
index 50ff188..0000000
--- a/src/python/of11/class_maps.py
+++ /dev/null
@@ -1,375 +0,0 @@
-
-# Class to array member map
-class_to_members_map = {
- 'ofp_action_mpls_tc' : [
- 'type',
- 'len',
- 'mpls_tc'
- ],
- 'ofp_aggregate_stats_reply' : [
- 'packet_count',
- 'byte_count',
- 'flow_count'
- ],
- 'ofp_action_set_queue' : [
- 'type',
- 'len',
- 'queue_id'
- ],
- 'ofp_table_stats' : [
- 'table_id',
- 'name',
- 'wildcards',
- 'match',
- 'instructions',
- 'write_actions',
- 'apply_actions',
- 'config',
- 'max_entries',
- 'active_count',
- 'lookup_count',
- 'matched_count'
- ],
- 'ofp_table_mod' : [
- 'table_id',
- 'config'
- ],
- 'ofp_flow_removed' : [
- 'cookie',
- 'priority',
- 'reason',
- 'table_id',
- 'duration_sec',
- 'duration_nsec',
- 'idle_timeout',
- 'packet_count',
- 'byte_count',
- 'match'
- ],
- 'ofp_instruction_actions' : [
- 'type',
- 'len'
- ],
- 'ofp_queue_stats' : [
- 'port_no',
- 'queue_id',
- 'tx_bytes',
- 'tx_packets',
- 'tx_errors'
- ],
- 'ofp_action_tp_port' : [
- 'type',
- 'len',
- 'tp_port'
- ],
- 'ofp_action_nw_ecn' : [
- 'type',
- 'len',
- 'nw_ecn'
- ],
- 'ofp_group_mod' : [
- 'command',
- 'type',
- 'group_id'
- ],
- 'ofp_port_stats_request' : [
- 'port_no'
- ],
- 'ofp_stats_request' : [
- 'type',
- 'flags'
- ],
- 'ofp_instruction' : [
- 'type',
- 'len'
- ],
- 'ofp_group_stats_request' : [
- 'group_id'
- ],
- 'ofp_experimenter_header' : [
- 'experimenter'
- ],
- 'ofp_aggregate_stats_request' : [
- 'table_id',
- 'out_port',
- 'out_group',
- 'cookie',
- 'cookie_mask',
- 'match'
- ],
- 'ofp_queue_get_config_request' : [
- 'port'
- ],
- 'ofp_instruction_experimenter' : [
- 'type',
- 'len',
- 'experimenter'
- ],
- 'ofp_action_nw_ttl' : [
- 'type',
- 'len',
- 'nw_ttl'
- ],
- 'ofp_port_status' : [
- 'reason',
- 'desc'
- ],
- 'ofp_action_header' : [
- 'type',
- 'len'
- ],
- 'ofp_port_mod' : [
- 'port_no',
- 'hw_addr',
- 'config',
- 'mask',
- 'advertise'
- ],
- 'ofp_action_vlan_vid' : [
- 'type',
- 'len',
- 'vlan_vid'
- ],
- 'ofp_action_output' : [
- 'type',
- 'len',
- 'port',
- 'max_len'
- ],
- 'ofp_switch_config' : [
- 'flags',
- 'miss_send_len'
- ],
- 'ofp_action_nw_tos' : [
- 'type',
- 'len',
- 'nw_tos'
- ],
- 'ofp_action_experimenter_header' : [
- 'type',
- 'len',
- 'experimenter'
- ],
- 'ofp_queue_get_config_reply' : [
- 'port'
- ],
- 'ofp_queue_prop_header' : [
- 'property',
- 'len'
- ],
- 'ofp_packet_in' : [
- 'buffer_id',
- 'in_port',
- 'in_phy_port',
- 'total_len',
- 'reason',
- 'table_id'
- ],
- 'ofp_instruction_write_metadata' : [
- 'type',
- 'len',
- 'metadata',
- 'metadata_mask'
- ],
- 'ofp_flow_stats' : [
- 'length',
- 'table_id',
- 'duration_sec',
- 'duration_nsec',
- 'priority',
- 'idle_timeout',
- 'hard_timeout',
- 'cookie',
- 'packet_count',
- 'byte_count',
- 'match'
- ],
- 'ofp_action_mpls_label' : [
- 'type',
- 'len',
- 'mpls_label'
- ],
- 'ofp_flow_stats_request' : [
- 'table_id',
- 'out_port',
- 'out_group',
- 'cookie',
- 'cookie_mask',
- 'match'
- ],
- 'ofp_header' : [
- 'version',
- 'type',
- 'length',
- 'xid'
- ],
- 'ofp_stats_reply' : [
- 'type',
- 'flags'
- ],
- 'ofp_queue_stats_request' : [
- 'port_no',
- 'queue_id'
- ],
- 'ofp_desc_stats' : [
- 'mfr_desc',
- 'hw_desc',
- 'sw_desc',
- 'serial_num',
- 'dp_desc'
- ],
- 'ofp_match' : [
- 'type',
- 'length',
- 'in_port',
- 'wildcards',
- 'dl_src',
- 'dl_src_mask',
- 'dl_dst',
- 'dl_dst_mask',
- 'dl_vlan',
- 'dl_vlan_pcp',
- 'dl_type',
- 'nw_tos',
- 'nw_proto',
- 'nw_src',
- 'nw_src_mask',
- 'nw_dst',
- 'nw_dst_mask',
- 'tp_src',
- 'tp_dst',
- 'mpls_label',
- 'mpls_tc',
- 'metadata',
- 'metadata_mask'
- ],
- 'ofp_port_stats' : [
- 'port_no',
- 'rx_packets',
- 'tx_packets',
- 'rx_bytes',
- 'tx_bytes',
- 'rx_dropped',
- 'tx_dropped',
- 'rx_errors',
- 'tx_errors',
- 'rx_frame_err',
- 'rx_over_err',
- 'rx_crc_err',
- 'collisions'
- ],
- 'ofp_packet_queue' : [
- 'queue_id',
- 'len'
- ],
- 'ofp_port' : [
- 'port_no',
- 'hw_addr',
- 'name',
- 'config',
- 'state',
- 'curr',
- 'advertised',
- 'supported',
- 'peer',
- 'curr_speed',
- 'max_speed'
- ],
- 'ofp_action_dl_addr' : [
- 'type',
- 'len',
- 'dl_addr'
- ],
- 'ofp_bucket_counter' : [
- 'packet_count',
- 'byte_count'
- ],
- 'ofp_queue_prop_min_rate' : [
- 'prop_header',
- 'rate'
- ],
- 'ofp_bucket' : [
- 'len',
- 'weight',
- 'watch_port',
- 'watch_group'
- ],
- 'ofp_switch_features' : [
- 'datapath_id',
- 'n_buffers',
- 'n_tables',
- 'capabilities',
- 'reserved'
- ],
- 'ofp_action_pop_mpls' : [
- 'type',
- 'len',
- 'ethertype'
- ],
- 'ofp_flow_mod' : [
- 'cookie',
- 'cookie_mask',
- 'table_id',
- 'command',
- 'idle_timeout',
- 'hard_timeout',
- 'priority',
- 'buffer_id',
- 'out_port',
- 'out_group',
- 'flags',
- 'match'
- ],
- 'ofp_packet_out' : [
- 'buffer_id',
- 'in_port',
- 'actions_len'
- ],
- 'ofp_instruction_goto_table' : [
- 'type',
- 'len',
- 'table_id'
- ],
- 'ofp_action_nw_addr' : [
- 'type',
- 'len',
- 'nw_addr'
- ],
- 'ofp_action_group' : [
- 'type',
- 'len',
- 'group_id'
- ],
- 'ofp_group_stats' : [
- 'length',
- 'group_id',
- 'ref_count',
- 'packet_count',
- 'byte_count'
- ],
- 'ofp_action_vlan_pcp' : [
- 'type',
- 'len',
- 'vlan_pcp'
- ],
- 'ofp_action_push' : [
- 'type',
- 'len',
- 'ethertype'
- ],
- 'ofp_group_desc_stats' : [
- 'length',
- 'type',
- 'group_id'
- ],
- 'ofp_error_msg' : [
- 'type',
- 'code'
- ],
- 'ofp_action_mpls_ttl' : [
- 'type',
- 'len',
- 'mpls_ttl'
- ],
- '_ignore' : []
-}
diff --git a/src/python/of11/cstruct.py b/src/python/of11/cstruct.py
deleted file mode 100644
index 1db5f00..0000000
--- a/src/python/of11/cstruct.py
+++ /dev/null
@@ -1,6043 +0,0 @@
-import struct
-
-# Structure definitions
-class ofp_action_mpls_tc(object):
- """Automatically generated Python class for ofp_action_mpls_tc
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.mpls_tc = 0
- self.pad= [0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 3):
- return (False, "self.pad is not of size 3 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HHB", self.type, self.len, self.mpls_tc)
- packed += struct.pack("!BBB", self.pad[0], self.pad[1], self.pad[2])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HHB'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len, self.mpls_tc) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBB'
- start = 5
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.mpls_tc != other.mpls_tc: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- outstr += prefix + 'mpls_tc: ' + str(self.mpls_tc) + '\n'
- return outstr
-
-
-class ofp_aggregate_stats_reply(object):
- """Automatically generated Python class for ofp_aggregate_stats_reply
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.packet_count = 0
- self.byte_count = 0
- self.flow_count = 0
- self.pad= [0,0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 4):
- return (False, "self.pad is not of size 4 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!QQL", self.packet_count, self.byte_count, self.flow_count)
- packed += struct.pack("!BBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 24):
- return binaryString
- fmt = '!QQL'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.packet_count, self.byte_count, self.flow_count) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 20
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[24:]
-
- def __len__(self):
- """Return length of message
- """
- l = 24
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.packet_count != other.packet_count: return False
- if self.byte_count != other.byte_count: return False
- if self.flow_count != other.flow_count: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'packet_count: ' + str(self.packet_count) + '\n'
- outstr += prefix + 'byte_count: ' + str(self.byte_count) + '\n'
- outstr += prefix + 'flow_count: ' + str(self.flow_count) + '\n'
- return outstr
-
-
-class ofp_action_set_queue(object):
- """Automatically generated Python class for ofp_action_set_queue
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.queue_id = 0
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HHL", self.type, self.len, self.queue_id)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HHL'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len, self.queue_id) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.queue_id != other.queue_id: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- outstr += prefix + 'queue_id: ' + str(self.queue_id) + '\n'
- return outstr
-
-
-class ofp_table_stats(object):
- """Automatically generated Python class for ofp_table_stats
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.table_id = 0
- self.pad= [0,0,0,0,0,0,0]
- self.name= ""
- self.wildcards = 0
- self.match = 0
- self.instructions = 0
- self.write_actions = 0
- self.apply_actions = 0
- self.config = 0
- self.max_entries = 0
- self.active_count = 0
- self.lookup_count = 0
- self.matched_count = 0
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 7):
- return (False, "self.pad is not of size 7 as expected.")
- if(not isinstance(self.name, str)):
- return (False, "self.name is not string as expected.")
- if(len(self.name) > 32):
- return (False, "self.name is not of size 32 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!B", self.table_id)
- packed += struct.pack("!BBBBBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3], self.pad[4], self.pad[5], self.pad[6])
- packed += self.name.ljust(32,'\0')
- packed += struct.pack("!LLLLLLLLQQ", self.wildcards, self.match, self.instructions, self.write_actions, self.apply_actions, self.config, self.max_entries, self.active_count, self.lookup_count, self.matched_count)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 88):
- return binaryString
- fmt = '!B'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.table_id,) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBBBBB'
- start = 1
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3], self.pad[4], self.pad[5], self.pad[6]) = struct.unpack(fmt, binaryString[start:end])
- self.name = binaryString[8:40].replace("\0","")
- fmt = '!LLLLLLLLQQ'
- start = 40
- end = start + struct.calcsize(fmt)
- (self.wildcards, self.match, self.instructions, self.write_actions, self.apply_actions, self.config, self.max_entries, self.active_count, self.lookup_count, self.matched_count) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[88:]
-
- def __len__(self):
- """Return length of message
- """
- l = 88
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.table_id != other.table_id: return False
- if self.pad != other.pad: return False
- if self.name != other.name: return False
- if self.wildcards != other.wildcards: return False
- if self.match != other.match: return False
- if self.instructions != other.instructions: return False
- if self.write_actions != other.write_actions: return False
- if self.apply_actions != other.apply_actions: return False
- if self.config != other.config: return False
- if self.max_entries != other.max_entries: return False
- if self.active_count != other.active_count: return False
- if self.lookup_count != other.lookup_count: return False
- if self.matched_count != other.matched_count: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'table_id: ' + str(self.table_id) + '\n'
- outstr += prefix + 'name: ' + str(self.name) + '\n'
- outstr += prefix + 'wildcards: ' + str(self.wildcards) + '\n'
- outstr += prefix + 'match: ' + str(self.match) + '\n'
- outstr += prefix + 'instructions: ' + str(self.instructions) + '\n'
- outstr += prefix + 'write_actions: ' + str(self.write_actions) + '\n'
- outstr += prefix + 'apply_actions: ' + str(self.apply_actions) + '\n'
- outstr += prefix + 'config: ' + str(self.config) + '\n'
- outstr += prefix + 'max_entries: ' + str(self.max_entries) + '\n'
- outstr += prefix + 'active_count: ' + str(self.active_count) + '\n'
- outstr += prefix + 'lookup_count: ' + str(self.lookup_count) + '\n'
- outstr += prefix + 'matched_count: ' + str(self.matched_count) + '\n'
- return outstr
-
-
-class ofp_table_mod(object):
- """Automatically generated Python class for ofp_table_mod
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.table_id = 0
- self.pad= [0,0,0]
- self.config = 0
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 3):
- return (False, "self.pad is not of size 3 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!B", self.table_id)
- packed += struct.pack("!BBB", self.pad[0], self.pad[1], self.pad[2])
- packed += struct.pack("!L", self.config)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!B'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.table_id,) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBB'
- start = 1
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!L'
- start = 4
- end = start + struct.calcsize(fmt)
- (self.config,) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.table_id != other.table_id: return False
- if self.pad != other.pad: return False
- if self.config != other.config: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'table_id: ' + str(self.table_id) + '\n'
- outstr += prefix + 'config: ' + str(self.config) + '\n'
- return outstr
-
-
-class ofp_flow_removed(object):
- """Automatically generated Python class for ofp_flow_removed
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.cookie = 0
- self.priority = 0
- self.reason = 0
- self.table_id = 0
- self.duration_sec = 0
- self.duration_nsec = 0
- self.idle_timeout = 0
- self.pad2= [0,0]
- self.packet_count = 0
- self.byte_count = 0
- self.match = ofp_match()
- self.match.length = OFP_MATCH_BYTES
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad2, list)):
- return (False, "self.pad2 is not list as expected.")
- if(len(self.pad2) != 2):
- return (False, "self.pad2 is not of size 2 as expected.")
- if(not isinstance(self.match, ofp_match)):
- return (False, "self.match is not class ofp_match as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!QHBBLLH", self.cookie, self.priority, self.reason, self.table_id, self.duration_sec, self.duration_nsec, self.idle_timeout)
- packed += struct.pack("!BB", self.pad2[0], self.pad2[1])
- packed += struct.pack("!QQ", self.packet_count, self.byte_count)
- packed += self.match.pack()
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 128):
- return binaryString
- fmt = '!QHBBLLH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.cookie, self.priority, self.reason, self.table_id, self.duration_sec, self.duration_nsec, self.idle_timeout) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BB'
- start = 22
- end = start + struct.calcsize(fmt)
- (self.pad2[0], self.pad2[1]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!QQ'
- start = 24
- end = start + struct.calcsize(fmt)
- (self.packet_count, self.byte_count) = struct.unpack(fmt, binaryString[start:end])
- self.match.unpack(binaryString[40:])
- return binaryString[128:]
-
- def __len__(self):
- """Return length of message
- """
- l = 128
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.cookie != other.cookie: return False
- if self.priority != other.priority: return False
- if self.reason != other.reason: return False
- if self.table_id != other.table_id: return False
- if self.duration_sec != other.duration_sec: return False
- if self.duration_nsec != other.duration_nsec: return False
- if self.idle_timeout != other.idle_timeout: return False
- if self.pad2 != other.pad2: return False
- if self.packet_count != other.packet_count: return False
- if self.byte_count != other.byte_count: return False
- if self.match != other.match: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'cookie: ' + str(self.cookie) + '\n'
- outstr += prefix + 'priority: ' + str(self.priority) + '\n'
- outstr += prefix + 'reason: ' + str(self.reason) + '\n'
- outstr += prefix + 'table_id: ' + str(self.table_id) + '\n'
- outstr += prefix + 'duration_sec: ' + str(self.duration_sec) + '\n'
- outstr += prefix + 'duration_nsec: ' + str(self.duration_nsec) + '\n'
- outstr += prefix + 'idle_timeout: ' + str(self.idle_timeout) + '\n'
- outstr += prefix + 'packet_count: ' + str(self.packet_count) + '\n'
- outstr += prefix + 'byte_count: ' + str(self.byte_count) + '\n'
- outstr += prefix + 'match: \n'
- outstr += self.match.show(prefix + ' ')
- return outstr
-
-
-class ofp_instruction_actions(object):
- """Automatically generated Python class for ofp_instruction_actions
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.pad= [0,0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 4):
- return (False, "self.pad is not of size 4 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HH", self.type, self.len)
- packed += struct.pack("!BBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 4
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- return outstr
-
-
-class ofp_queue_stats(object):
- """Automatically generated Python class for ofp_queue_stats
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.port_no = 0
- self.queue_id = 0
- self.tx_bytes = 0
- self.tx_packets = 0
- self.tx_errors = 0
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!LLQQQ", self.port_no, self.queue_id, self.tx_bytes, self.tx_packets, self.tx_errors)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 32):
- return binaryString
- fmt = '!LLQQQ'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.port_no, self.queue_id, self.tx_bytes, self.tx_packets, self.tx_errors) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[32:]
-
- def __len__(self):
- """Return length of message
- """
- l = 32
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.port_no != other.port_no: return False
- if self.queue_id != other.queue_id: return False
- if self.tx_bytes != other.tx_bytes: return False
- if self.tx_packets != other.tx_packets: return False
- if self.tx_errors != other.tx_errors: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'port_no: ' + str(self.port_no) + '\n'
- outstr += prefix + 'queue_id: ' + str(self.queue_id) + '\n'
- outstr += prefix + 'tx_bytes: ' + str(self.tx_bytes) + '\n'
- outstr += prefix + 'tx_packets: ' + str(self.tx_packets) + '\n'
- outstr += prefix + 'tx_errors: ' + str(self.tx_errors) + '\n'
- return outstr
-
-
-class ofp_action_tp_port(object):
- """Automatically generated Python class for ofp_action_tp_port
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.tp_port = 0
- self.pad= [0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 2):
- return (False, "self.pad is not of size 2 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HHH", self.type, self.len, self.tp_port)
- packed += struct.pack("!BB", self.pad[0], self.pad[1])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HHH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len, self.tp_port) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BB'
- start = 6
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.tp_port != other.tp_port: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- outstr += prefix + 'tp_port: ' + str(self.tp_port) + '\n'
- return outstr
-
-
-class ofp_action_nw_ecn(object):
- """Automatically generated Python class for ofp_action_nw_ecn
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.nw_ecn = 0
- self.pad= [0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 3):
- return (False, "self.pad is not of size 3 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HHB", self.type, self.len, self.nw_ecn)
- packed += struct.pack("!BBB", self.pad[0], self.pad[1], self.pad[2])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HHB'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len, self.nw_ecn) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBB'
- start = 5
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.nw_ecn != other.nw_ecn: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- outstr += prefix + 'nw_ecn: ' + str(self.nw_ecn) + '\n'
- return outstr
-
-
-class ofp_group_mod(object):
- """Automatically generated Python class for ofp_group_mod
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.command = 0
- self.type = 0
- self.pad = 0
- self.group_id = 0
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HBBL", self.command, self.type, self.pad, self.group_id)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HBBL'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.command, self.type, self.pad, self.group_id) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.command != other.command: return False
- if self.type != other.type: return False
- if self.pad != other.pad: return False
- if self.group_id != other.group_id: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'command: ' + str(self.command) + '\n'
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'group_id: ' + str(self.group_id) + '\n'
- return outstr
-
-
-class ofp_port_stats_request(object):
- """Automatically generated Python class for ofp_port_stats_request
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.port_no = 0
- self.pad= [0,0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 4):
- return (False, "self.pad is not of size 4 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!L", self.port_no)
- packed += struct.pack("!BBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!L'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.port_no,) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 4
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.port_no != other.port_no: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'port_no: ' + str(self.port_no) + '\n'
- return outstr
-
-
-class ofp_stats_request(object):
- """Automatically generated Python class for ofp_stats_request
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.flags = 0
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HH", self.type, self.flags)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 4):
- return binaryString
- fmt = '!HH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.flags) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[4:]
-
- def __len__(self):
- """Return length of message
- """
- l = 4
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.flags != other.flags: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'flags: ' + str(self.flags) + '\n'
- return outstr
-
-
-class ofp_instruction(object):
- """Automatically generated Python class for ofp_instruction
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.pad= [0,0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 4):
- return (False, "self.pad is not of size 4 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HH", self.type, self.len)
- packed += struct.pack("!BBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 4
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- return outstr
-
-
-class ofp_hello(object):
- """Automatically generated Python class for ofp_hello
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 0):
- return binaryString
- return binaryString[0:]
-
- def __len__(self):
- """Return length of message
- """
- l = 0
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- return outstr
-
-
-class ofp_group_stats_request(object):
- """Automatically generated Python class for ofp_group_stats_request
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.group_id = 0
- self.pad= [0,0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 4):
- return (False, "self.pad is not of size 4 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!L", self.group_id)
- packed += struct.pack("!BBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!L'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.group_id,) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 4
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.group_id != other.group_id: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'group_id: ' + str(self.group_id) + '\n'
- return outstr
-
-
-class ofp_experimenter_header(object):
- """Automatically generated Python class for ofp_experimenter_header
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.experimenter = 0
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!L", self.experimenter)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 4):
- return binaryString
- fmt = '!L'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.experimenter,) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[4:]
-
- def __len__(self):
- """Return length of message
- """
- l = 4
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.experimenter != other.experimenter: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'experimenter: ' + str(self.experimenter) + '\n'
- return outstr
-
-
-class ofp_aggregate_stats_request(object):
- """Automatically generated Python class for ofp_aggregate_stats_request
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.table_id = 0
- self.pad= [0,0,0]
- self.out_port = 0
- self.out_group = 0
- self.pad2= [0,0,0,0]
- self.cookie = 0
- self.cookie_mask = 0
- self.match = ofp_match()
- self.match.length = OFP_MATCH_BYTES
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 3):
- return (False, "self.pad is not of size 3 as expected.")
- if(not isinstance(self.pad2, list)):
- return (False, "self.pad2 is not list as expected.")
- if(len(self.pad2) != 4):
- return (False, "self.pad2 is not of size 4 as expected.")
- if(not isinstance(self.match, ofp_match)):
- return (False, "self.match is not class ofp_match as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!B", self.table_id)
- packed += struct.pack("!BBB", self.pad[0], self.pad[1], self.pad[2])
- packed += struct.pack("!LL", self.out_port, self.out_group)
- packed += struct.pack("!BBBB", self.pad2[0], self.pad2[1], self.pad2[2], self.pad2[3])
- packed += struct.pack("!QQ", self.cookie, self.cookie_mask)
- packed += self.match.pack()
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 120):
- return binaryString
- fmt = '!B'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.table_id,) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBB'
- start = 1
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!LL'
- start = 4
- end = start + struct.calcsize(fmt)
- (self.out_port, self.out_group) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 12
- end = start + struct.calcsize(fmt)
- (self.pad2[0], self.pad2[1], self.pad2[2], self.pad2[3]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!QQ'
- start = 16
- end = start + struct.calcsize(fmt)
- (self.cookie, self.cookie_mask) = struct.unpack(fmt, binaryString[start:end])
- self.match.unpack(binaryString[32:])
- return binaryString[120:]
-
- def __len__(self):
- """Return length of message
- """
- l = 120
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.table_id != other.table_id: return False
- if self.pad != other.pad: return False
- if self.out_port != other.out_port: return False
- if self.out_group != other.out_group: return False
- if self.pad2 != other.pad2: return False
- if self.cookie != other.cookie: return False
- if self.cookie_mask != other.cookie_mask: return False
- if self.match != other.match: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'table_id: ' + str(self.table_id) + '\n'
- outstr += prefix + 'out_port: ' + str(self.out_port) + '\n'
- outstr += prefix + 'out_group: ' + str(self.out_group) + '\n'
- outstr += prefix + 'cookie: ' + str(self.cookie) + '\n'
- outstr += prefix + 'cookie_mask: ' + str(self.cookie_mask) + '\n'
- outstr += prefix + 'match: \n'
- outstr += self.match.show(prefix + ' ')
- return outstr
-
-
-class ofp_queue_get_config_request(object):
- """Automatically generated Python class for ofp_queue_get_config_request
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.port = 0
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!L", self.port)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 4):
- return binaryString
- fmt = '!L'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.port,) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[4:]
-
- def __len__(self):
- """Return length of message
- """
- l = 4
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.port != other.port: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'port: ' + str(self.port) + '\n'
- return outstr
-
-
-class ofp_instruction_experimenter(object):
- """Automatically generated Python class for ofp_instruction_experimenter
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.experimenter = 0
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HHL", self.type, self.len, self.experimenter)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HHL'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len, self.experimenter) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.experimenter != other.experimenter: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- outstr += prefix + 'experimenter: ' + str(self.experimenter) + '\n'
- return outstr
-
-
-class ofp_action_nw_ttl(object):
- """Automatically generated Python class for ofp_action_nw_ttl
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.nw_ttl = 0
- self.pad= [0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 3):
- return (False, "self.pad is not of size 3 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HHB", self.type, self.len, self.nw_ttl)
- packed += struct.pack("!BBB", self.pad[0], self.pad[1], self.pad[2])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HHB'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len, self.nw_ttl) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBB'
- start = 5
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.nw_ttl != other.nw_ttl: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- outstr += prefix + 'nw_ttl: ' + str(self.nw_ttl) + '\n'
- return outstr
-
-
-class ofp_port_status(object):
- """Automatically generated Python class for ofp_port_status
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.reason = 0
- self.pad= [0,0,0,0,0,0,0]
- self.desc = ofp_port()
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 7):
- return (False, "self.pad is not of size 7 as expected.")
- if(not isinstance(self.desc, ofp_port)):
- return (False, "self.desc is not class ofp_port as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!B", self.reason)
- packed += struct.pack("!BBBBBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3], self.pad[4], self.pad[5], self.pad[6])
- packed += self.desc.pack()
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 72):
- return binaryString
- fmt = '!B'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.reason,) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBBBBB'
- start = 1
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3], self.pad[4], self.pad[5], self.pad[6]) = struct.unpack(fmt, binaryString[start:end])
- self.desc.unpack(binaryString[8:])
- return binaryString[72:]
-
- def __len__(self):
- """Return length of message
- """
- l = 72
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.reason != other.reason: return False
- if self.pad != other.pad: return False
- if self.desc != other.desc: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'reason: ' + str(self.reason) + '\n'
- outstr += prefix + 'desc: \n'
- outstr += self.desc.show(prefix + ' ')
- return outstr
-
-
-class ofp_action_header(object):
- """Automatically generated Python class for ofp_action_header
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.pad= [0,0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 4):
- return (False, "self.pad is not of size 4 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HH", self.type, self.len)
- packed += struct.pack("!BBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 4
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- return outstr
-
-
-class ofp_port_mod(object):
- """Automatically generated Python class for ofp_port_mod
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.port_no = 0
- self.pad= [0,0,0,0]
- self.hw_addr= [0,0,0,0,0,0]
- self.pad2= [0,0]
- self.config = 0
- self.mask = 0
- self.advertise = 0
- self.pad3= [0,0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 4):
- return (False, "self.pad is not of size 4 as expected.")
- if(not isinstance(self.hw_addr, list)):
- return (False, "self.hw_addr is not list as expected.")
- if(len(self.hw_addr) != 6):
- return (False, "self.hw_addr is not of size 6 as expected.")
- if(not isinstance(self.pad2, list)):
- return (False, "self.pad2 is not list as expected.")
- if(len(self.pad2) != 2):
- return (False, "self.pad2 is not of size 2 as expected.")
- if(not isinstance(self.pad3, list)):
- return (False, "self.pad3 is not list as expected.")
- if(len(self.pad3) != 4):
- return (False, "self.pad3 is not of size 4 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!L", self.port_no)
- packed += struct.pack("!BBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3])
- packed += struct.pack("!BBBBBB", self.hw_addr[0], self.hw_addr[1], self.hw_addr[2], self.hw_addr[3], self.hw_addr[4], self.hw_addr[5])
- packed += struct.pack("!BB", self.pad2[0], self.pad2[1])
- packed += struct.pack("!LLL", self.config, self.mask, self.advertise)
- packed += struct.pack("!BBBB", self.pad3[0], self.pad3[1], self.pad3[2], self.pad3[3])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 32):
- return binaryString
- fmt = '!L'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.port_no,) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 4
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBBBB'
- start = 8
- end = start + struct.calcsize(fmt)
- (self.hw_addr[0], self.hw_addr[1], self.hw_addr[2], self.hw_addr[3], self.hw_addr[4], self.hw_addr[5]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BB'
- start = 14
- end = start + struct.calcsize(fmt)
- (self.pad2[0], self.pad2[1]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!LLL'
- start = 16
- end = start + struct.calcsize(fmt)
- (self.config, self.mask, self.advertise) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 28
- end = start + struct.calcsize(fmt)
- (self.pad3[0], self.pad3[1], self.pad3[2], self.pad3[3]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[32:]
-
- def __len__(self):
- """Return length of message
- """
- l = 32
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.port_no != other.port_no: return False
- if self.pad != other.pad: return False
- if self.hw_addr != other.hw_addr: return False
- if self.pad2 != other.pad2: return False
- if self.config != other.config: return False
- if self.mask != other.mask: return False
- if self.advertise != other.advertise: return False
- if self.pad3 != other.pad3: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'port_no: ' + str(self.port_no) + '\n'
- outstr += prefix + 'hw_addr: ' + str(self.hw_addr) + '\n'
- outstr += prefix + 'config: ' + str(self.config) + '\n'
- outstr += prefix + 'mask: ' + str(self.mask) + '\n'
- outstr += prefix + 'advertise: ' + str(self.advertise) + '\n'
- return outstr
-
-
-class ofp_action_vlan_vid(object):
- """Automatically generated Python class for ofp_action_vlan_vid
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.vlan_vid = 0
- self.pad= [0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 2):
- return (False, "self.pad is not of size 2 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HHH", self.type, self.len, self.vlan_vid)
- packed += struct.pack("!BB", self.pad[0], self.pad[1])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HHH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len, self.vlan_vid) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BB'
- start = 6
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.vlan_vid != other.vlan_vid: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- outstr += prefix + 'vlan_vid: ' + str(self.vlan_vid) + '\n'
- return outstr
-
-
-class ofp_action_output(object):
- """Automatically generated Python class for ofp_action_output
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.port = 0
- self.max_len = 0
- self.pad= [0,0,0,0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 6):
- return (False, "self.pad is not of size 6 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HHLH", self.type, self.len, self.port, self.max_len)
- packed += struct.pack("!BBBBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3], self.pad[4], self.pad[5])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 16):
- return binaryString
- fmt = '!HHLH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len, self.port, self.max_len) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBBBB'
- start = 10
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3], self.pad[4], self.pad[5]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[16:]
-
- def __len__(self):
- """Return length of message
- """
- l = 16
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.port != other.port: return False
- if self.max_len != other.max_len: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- outstr += prefix + 'port: ' + str(self.port) + '\n'
- outstr += prefix + 'max_len: ' + str(self.max_len) + '\n'
- return outstr
-
-
-class ofp_switch_config(object):
- """Automatically generated Python class for ofp_switch_config
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.flags = 0
- self.miss_send_len = 128
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HH", self.flags, self.miss_send_len)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 4):
- return binaryString
- fmt = '!HH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.flags, self.miss_send_len) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[4:]
-
- def __len__(self):
- """Return length of message
- """
- l = 4
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): 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 show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'flags: ' + str(self.flags) + '\n'
- outstr += prefix + 'miss_send_len: ' + str(self.miss_send_len) + '\n'
- return outstr
-
-
-class ofp_action_nw_tos(object):
- """Automatically generated Python class for ofp_action_nw_tos
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.nw_tos = 0
- self.pad= [0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 3):
- return (False, "self.pad is not of size 3 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HHB", self.type, self.len, self.nw_tos)
- packed += struct.pack("!BBB", self.pad[0], self.pad[1], self.pad[2])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HHB'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len, self.nw_tos) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBB'
- start = 5
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.nw_tos != other.nw_tos: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- outstr += prefix + 'nw_tos: ' + str(self.nw_tos) + '\n'
- return outstr
-
-
-class ofp_action_experimenter_header(object):
- """Automatically generated Python class for ofp_action_experimenter_header
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.experimenter = 0
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HHL", self.type, self.len, self.experimenter)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HHL'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len, self.experimenter) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.experimenter != other.experimenter: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- outstr += prefix + 'experimenter: ' + str(self.experimenter) + '\n'
- return outstr
-
-
-class ofp_queue_get_config_reply(object):
- """Automatically generated Python class for ofp_queue_get_config_reply
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.port = 0
- self.pad= [0,0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 4):
- return (False, "self.pad is not of size 4 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!L", self.port)
- packed += struct.pack("!BBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!L'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.port,) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 4
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.port != other.port: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'port: ' + str(self.port) + '\n'
- return outstr
-
-
-class ofp_queue_prop_header(object):
- """Automatically generated Python class for ofp_queue_prop_header
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.property = 0
- self.len = 0
- self.pad= [0,0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 4):
- return (False, "self.pad is not of size 4 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HH", self.property, self.len)
- packed += struct.pack("!BBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.property, self.len) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 4
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.property != other.property: return False
- if self.len != other.len: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'property: ' + str(self.property) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- return outstr
-
-
-class ofp_packet_in(object):
- """Automatically generated Python class for ofp_packet_in
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.buffer_id = 0
- self.in_port = 0
- self.in_phy_port = 0
- self.total_len = 0
- self.reason = 0
- self.table_id = 0
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!LLLHBB", self.buffer_id, self.in_port, self.in_phy_port, self.total_len, self.reason, self.table_id)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 16):
- return binaryString
- fmt = '!LLLHBB'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.buffer_id, self.in_port, self.in_phy_port, self.total_len, self.reason, self.table_id) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[16:]
-
- def __len__(self):
- """Return length of message
- """
- l = 16
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.buffer_id != other.buffer_id: return False
- if self.in_port != other.in_port: return False
- if self.in_phy_port != other.in_phy_port: return False
- if self.total_len != other.total_len: return False
- if self.reason != other.reason: return False
- if self.table_id != other.table_id: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'buffer_id: ' + str(self.buffer_id) + '\n'
- outstr += prefix + 'in_port: ' + str(self.in_port) + '\n'
- outstr += prefix + 'in_phy_port: ' + str(self.in_phy_port) + '\n'
- outstr += prefix + 'total_len: ' + str(self.total_len) + '\n'
- outstr += prefix + 'reason: ' + str(self.reason) + '\n'
- outstr += prefix + 'table_id: ' + str(self.table_id) + '\n'
- return outstr
-
-
-class ofp_instruction_write_metadata(object):
- """Automatically generated Python class for ofp_instruction_write_metadata
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.pad= [0,0,0,0]
- self.metadata = 0
- self.metadata_mask = 0
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 4):
- return (False, "self.pad is not of size 4 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HH", self.type, self.len)
- packed += struct.pack("!BBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3])
- packed += struct.pack("!QQ", self.metadata, self.metadata_mask)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 24):
- return binaryString
- fmt = '!HH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 4
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!QQ'
- start = 8
- end = start + struct.calcsize(fmt)
- (self.metadata, self.metadata_mask) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[24:]
-
- def __len__(self):
- """Return length of message
- """
- l = 24
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.pad != other.pad: return False
- if self.metadata != other.metadata: return False
- if self.metadata_mask != other.metadata_mask: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- outstr += prefix + 'metadata: ' + str(self.metadata) + '\n'
- outstr += prefix + 'metadata_mask: ' + str(self.metadata_mask) + '\n'
- return outstr
-
-
-class ofp_flow_stats(object):
- """Automatically generated Python class for ofp_flow_stats
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.length = 0
- self.table_id = 0
- self.pad = 0
- self.duration_sec = 0
- self.duration_nsec = 0
- self.priority = 0x8000
- self.idle_timeout = 0
- self.hard_timeout = 0
- self.pad2= [0,0,0,0,0,0]
- self.cookie = 0
- self.packet_count = 0
- self.byte_count = 0
- self.match = ofp_match()
- self.match.length = OFP_MATCH_BYTES
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad2, list)):
- return (False, "self.pad2 is not list as expected.")
- if(len(self.pad2) != 6):
- return (False, "self.pad2 is not of size 6 as expected.")
- if(not isinstance(self.match, ofp_match)):
- return (False, "self.match is not class ofp_match as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HBBLLHHH", self.length, self.table_id, self.pad, self.duration_sec, self.duration_nsec, self.priority, self.idle_timeout, self.hard_timeout)
- packed += struct.pack("!BBBBBB", self.pad2[0], self.pad2[1], self.pad2[2], self.pad2[3], self.pad2[4], self.pad2[5])
- packed += struct.pack("!QQQ", self.cookie, self.packet_count, self.byte_count)
- packed += self.match.pack()
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 136):
- return binaryString
- fmt = '!HBBLLHHH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.length, self.table_id, self.pad, self.duration_sec, self.duration_nsec, self.priority, self.idle_timeout, self.hard_timeout) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBBBB'
- start = 18
- end = start + struct.calcsize(fmt)
- (self.pad2[0], self.pad2[1], self.pad2[2], self.pad2[3], self.pad2[4], self.pad2[5]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!QQQ'
- start = 24
- end = start + struct.calcsize(fmt)
- (self.cookie, self.packet_count, self.byte_count) = struct.unpack(fmt, binaryString[start:end])
- self.match.unpack(binaryString[48:])
- return binaryString[136:]
-
- def __len__(self):
- """Return length of message
- """
- l = 136
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.length != other.length: return False
- if self.table_id != other.table_id: return False
- if self.pad != other.pad: return False
- if self.duration_sec != other.duration_sec: return False
- if self.duration_nsec != other.duration_nsec: return False
- if self.priority != other.priority: return False
- if self.idle_timeout != other.idle_timeout: return False
- if self.hard_timeout != other.hard_timeout: return False
- if self.pad2 != other.pad2: return False
- if self.cookie != other.cookie: return False
- if self.packet_count != other.packet_count: return False
- if self.byte_count != other.byte_count: return False
- if self.match != other.match: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'length: ' + str(self.length) + '\n'
- outstr += prefix + 'table_id: ' + str(self.table_id) + '\n'
- outstr += prefix + 'duration_sec: ' + str(self.duration_sec) + '\n'
- outstr += prefix + 'duration_nsec: ' + str(self.duration_nsec) + '\n'
- outstr += prefix + 'priority: ' + str(self.priority) + '\n'
- outstr += prefix + 'idle_timeout: ' + str(self.idle_timeout) + '\n'
- outstr += prefix + 'hard_timeout: ' + str(self.hard_timeout) + '\n'
- outstr += prefix + 'cookie: ' + str(self.cookie) + '\n'
- outstr += prefix + 'packet_count: ' + str(self.packet_count) + '\n'
- outstr += prefix + 'byte_count: ' + str(self.byte_count) + '\n'
- outstr += prefix + 'match: \n'
- outstr += self.match.show(prefix + ' ')
- return outstr
-
-
-class ofp_action_mpls_label(object):
- """Automatically generated Python class for ofp_action_mpls_label
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.mpls_label = 0
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HHL", self.type, self.len, self.mpls_label)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HHL'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len, self.mpls_label) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.mpls_label != other.mpls_label: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- outstr += prefix + 'mpls_label: ' + str(self.mpls_label) + '\n'
- return outstr
-
-
-class ofp_flow_stats_request(object):
- """Automatically generated Python class for ofp_flow_stats_request
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.table_id = 0
- self.pad= [0,0,0]
- self.out_port = 0
- self.out_group = 0
- self.pad2= [0,0,0,0]
- self.cookie = 0
- self.cookie_mask = 0
- self.match = ofp_match()
- self.match.length = OFP_MATCH_BYTES
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 3):
- return (False, "self.pad is not of size 3 as expected.")
- if(not isinstance(self.pad2, list)):
- return (False, "self.pad2 is not list as expected.")
- if(len(self.pad2) != 4):
- return (False, "self.pad2 is not of size 4 as expected.")
- if(not isinstance(self.match, ofp_match)):
- return (False, "self.match is not class ofp_match as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!B", self.table_id)
- packed += struct.pack("!BBB", self.pad[0], self.pad[1], self.pad[2])
- packed += struct.pack("!LL", self.out_port, self.out_group)
- packed += struct.pack("!BBBB", self.pad2[0], self.pad2[1], self.pad2[2], self.pad2[3])
- packed += struct.pack("!QQ", self.cookie, self.cookie_mask)
- packed += self.match.pack()
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 120):
- return binaryString
- fmt = '!B'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.table_id,) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBB'
- start = 1
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!LL'
- start = 4
- end = start + struct.calcsize(fmt)
- (self.out_port, self.out_group) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 12
- end = start + struct.calcsize(fmt)
- (self.pad2[0], self.pad2[1], self.pad2[2], self.pad2[3]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!QQ'
- start = 16
- end = start + struct.calcsize(fmt)
- (self.cookie, self.cookie_mask) = struct.unpack(fmt, binaryString[start:end])
- self.match.unpack(binaryString[32:])
- return binaryString[120:]
-
- def __len__(self):
- """Return length of message
- """
- l = 120
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.table_id != other.table_id: return False
- if self.pad != other.pad: return False
- if self.out_port != other.out_port: return False
- if self.out_group != other.out_group: return False
- if self.pad2 != other.pad2: return False
- if self.cookie != other.cookie: return False
- if self.cookie_mask != other.cookie_mask: return False
- if self.match != other.match: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'table_id: ' + str(self.table_id) + '\n'
- outstr += prefix + 'out_port: ' + str(self.out_port) + '\n'
- outstr += prefix + 'out_group: ' + str(self.out_group) + '\n'
- outstr += prefix + 'cookie: ' + str(self.cookie) + '\n'
- outstr += prefix + 'cookie_mask: ' + str(self.cookie_mask) + '\n'
- outstr += prefix + 'match: \n'
- outstr += self.match.show(prefix + ' ')
- return outstr
-
-
-class ofp_header(object):
- """Automatically generated Python class for ofp_header
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.version = 0x02
- self.type = 0
- self.length = 0
- self.xid = 0
-
- def __assert(self):
- """Sanity check
- """
- if (not (self.type in ofp_type_map.keys())):
- return (False, "type must have values from ofp_type_map.keys()")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!BBHL", self.version, self.type, self.length, self.xid)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!BBHL'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.version, self.type, self.length, self.xid) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
- if self.length != other.length: return False
- if self.xid != other.xid: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'version: ' + str(self.version) + '\n'
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'length: ' + str(self.length) + '\n'
- outstr += prefix + 'xid: ' + str(self.xid) + '\n'
- return outstr
-
-
-class ofp_stats_reply(object):
- """Automatically generated Python class for ofp_stats_reply
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.flags = 0
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HH", self.type, self.flags)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 4):
- return binaryString
- fmt = '!HH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.flags) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[4:]
-
- def __len__(self):
- """Return length of message
- """
- l = 4
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.flags != other.flags: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'flags: ' + str(self.flags) + '\n'
- return outstr
-
-
-class ofp_queue_stats_request(object):
- """Automatically generated Python class for ofp_queue_stats_request
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.port_no = 0
- self.queue_id = 0
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!LL", self.port_no, self.queue_id)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!LL'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.port_no, self.queue_id) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): 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 show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'port_no: ' + str(self.port_no) + '\n'
- outstr += prefix + 'queue_id: ' + str(self.queue_id) + '\n'
- return outstr
-
-
-class ofp_desc_stats(object):
- """Automatically generated Python class for ofp_desc_stats
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.mfr_desc= ""
- self.hw_desc= ""
- self.sw_desc= ""
- self.serial_num= ""
- self.dp_desc= ""
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.mfr_desc, str)):
- return (False, "self.mfr_desc is not string as expected.")
- if(len(self.mfr_desc) > 256):
- return (False, "self.mfr_desc is not of size 256 as expected.")
- if(not isinstance(self.hw_desc, str)):
- return (False, "self.hw_desc is not string as expected.")
- if(len(self.hw_desc) > 256):
- return (False, "self.hw_desc is not of size 256 as expected.")
- if(not isinstance(self.sw_desc, str)):
- return (False, "self.sw_desc is not string as expected.")
- if(len(self.sw_desc) > 256):
- return (False, "self.sw_desc is not of size 256 as expected.")
- if(not isinstance(self.serial_num, str)):
- return (False, "self.serial_num is not string as expected.")
- if(len(self.serial_num) > 32):
- return (False, "self.serial_num is not of size 32 as expected.")
- if(not isinstance(self.dp_desc, str)):
- return (False, "self.dp_desc is not string as expected.")
- if(len(self.dp_desc) > 256):
- return (False, "self.dp_desc is not of size 256 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += self.mfr_desc.ljust(256,'\0')
- packed += self.hw_desc.ljust(256,'\0')
- packed += self.sw_desc.ljust(256,'\0')
- packed += self.serial_num.ljust(32,'\0')
- packed += self.dp_desc.ljust(256,'\0')
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 1056):
- return binaryString
- self.mfr_desc = binaryString[0:256].replace("\0","")
- self.hw_desc = binaryString[256:512].replace("\0","")
- self.sw_desc = binaryString[512:768].replace("\0","")
- self.serial_num = binaryString[768:800].replace("\0","")
- self.dp_desc = binaryString[800:1056].replace("\0","")
- return binaryString[1056:]
-
- def __len__(self):
- """Return length of message
- """
- l = 1056
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.mfr_desc != other.mfr_desc: return False
- if self.hw_desc != other.hw_desc: return False
- if self.sw_desc != other.sw_desc: return False
- if self.serial_num != other.serial_num: return False
- if self.dp_desc != other.dp_desc: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'mfr_desc: ' + str(self.mfr_desc) + '\n'
- outstr += prefix + 'hw_desc: ' + str(self.hw_desc) + '\n'
- outstr += prefix + 'sw_desc: ' + str(self.sw_desc) + '\n'
- outstr += prefix + 'serial_num: ' + str(self.serial_num) + '\n'
- outstr += prefix + 'dp_desc: ' + str(self.dp_desc) + '\n'
- return outstr
-
-
-class ofp_match(object):
- """Automatically generated Python class for ofp_match
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.length = 0
- self.in_port = 0
- self.wildcards = 0
- self.dl_src= [0,0,0,0,0,0]
- self.dl_src_mask= [0,0,0,0,0,0]
- self.dl_dst= [0,0,0,0,0,0]
- self.dl_dst_mask= [0,0,0,0,0,0]
- self.dl_vlan = 0
- self.dl_vlan_pcp = 0
- self.pad1 = 0
- self.dl_type = 0
- self.nw_tos = 0
- self.nw_proto = 0
- self.nw_src = 0
- self.nw_src_mask = 0
- self.nw_dst = 0
- self.nw_dst_mask = 0
- self.tp_src = 0
- self.tp_dst = 0
- self.mpls_label = 0
- self.mpls_tc = 0
- self.pad2= [0,0,0]
- self.metadata = 0
- self.metadata_mask = 0
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.dl_src, list)):
- return (False, "self.dl_src is not list as expected.")
- if(len(self.dl_src) != 6):
- return (False, "self.dl_src is not of size 6 as expected.")
- if(not isinstance(self.dl_src_mask, list)):
- return (False, "self.dl_src_mask is not list as expected.")
- if(len(self.dl_src_mask) != 6):
- return (False, "self.dl_src_mask is not of size 6 as expected.")
- if(not isinstance(self.dl_dst, list)):
- return (False, "self.dl_dst is not list as expected.")
- if(len(self.dl_dst) != 6):
- return (False, "self.dl_dst is not of size 6 as expected.")
- if(not isinstance(self.dl_dst_mask, list)):
- return (False, "self.dl_dst_mask is not list as expected.")
- if(len(self.dl_dst_mask) != 6):
- return (False, "self.dl_dst_mask is not of size 6 as expected.")
- if(not isinstance(self.pad2, list)):
- return (False, "self.pad2 is not list as expected.")
- if(len(self.pad2) != 3):
- return (False, "self.pad2 is not of size 3 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HHLL", self.type, self.length, self.in_port, self.wildcards)
- packed += struct.pack("!BBBBBB", self.dl_src[0], self.dl_src[1], self.dl_src[2], self.dl_src[3], self.dl_src[4], self.dl_src[5])
- packed += struct.pack("!BBBBBB", self.dl_src_mask[0], self.dl_src_mask[1], self.dl_src_mask[2], self.dl_src_mask[3], self.dl_src_mask[4], self.dl_src_mask[5])
- packed += struct.pack("!BBBBBB", self.dl_dst[0], self.dl_dst[1], self.dl_dst[2], self.dl_dst[3], self.dl_dst[4], self.dl_dst[5])
- packed += struct.pack("!BBBBBB", self.dl_dst_mask[0], self.dl_dst_mask[1], self.dl_dst_mask[2], self.dl_dst_mask[3], self.dl_dst_mask[4], self.dl_dst_mask[5])
- packed += struct.pack("!HBBHBBLLLLHHLB", self.dl_vlan, self.dl_vlan_pcp, self.pad1, self.dl_type, self.nw_tos, self.nw_proto, self.nw_src, self.nw_src_mask, self.nw_dst, self.nw_dst_mask, self.tp_src, self.tp_dst, self.mpls_label, self.mpls_tc)
- packed += struct.pack("!BBB", self.pad2[0], self.pad2[1], self.pad2[2])
- packed += struct.pack("!QQ", self.metadata, self.metadata_mask)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 88):
- return binaryString
- fmt = '!HHLL'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.length, self.in_port, self.wildcards) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBBBB'
- start = 12
- end = start + struct.calcsize(fmt)
- (self.dl_src[0], self.dl_src[1], self.dl_src[2], self.dl_src[3], self.dl_src[4], self.dl_src[5]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBBBB'
- start = 18
- end = start + struct.calcsize(fmt)
- (self.dl_src_mask[0], self.dl_src_mask[1], self.dl_src_mask[2], self.dl_src_mask[3], self.dl_src_mask[4], self.dl_src_mask[5]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBBBB'
- start = 24
- end = start + struct.calcsize(fmt)
- (self.dl_dst[0], self.dl_dst[1], self.dl_dst[2], self.dl_dst[3], self.dl_dst[4], self.dl_dst[5]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBBBB'
- start = 30
- end = start + struct.calcsize(fmt)
- (self.dl_dst_mask[0], self.dl_dst_mask[1], self.dl_dst_mask[2], self.dl_dst_mask[3], self.dl_dst_mask[4], self.dl_dst_mask[5]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!HBBHBBLLLLHHLB'
- start = 36
- end = start + struct.calcsize(fmt)
- (self.dl_vlan, self.dl_vlan_pcp, self.pad1, self.dl_type, self.nw_tos, self.nw_proto, self.nw_src, self.nw_src_mask, self.nw_dst, self.nw_dst_mask, self.tp_src, self.tp_dst, self.mpls_label, self.mpls_tc) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBB'
- start = 69
- end = start + struct.calcsize(fmt)
- (self.pad2[0], self.pad2[1], self.pad2[2]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!QQ'
- start = 72
- end = start + struct.calcsize(fmt)
- (self.metadata, self.metadata_mask) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[88:]
-
- def __len__(self):
- """Return length of message
- """
- l = 88
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.length != other.length: return False
- if self.in_port != other.in_port: return False
- if self.wildcards != other.wildcards: return False
- if self.dl_src != other.dl_src: return False
- if self.dl_src_mask != other.dl_src_mask: return False
- if self.dl_dst != other.dl_dst: return False
- if self.dl_dst_mask != other.dl_dst_mask: return False
- if self.dl_vlan != other.dl_vlan: return False
- if self.dl_vlan_pcp != other.dl_vlan_pcp: return False
- if self.pad1 != other.pad1: return False
- if self.dl_type != other.dl_type: return False
- if self.nw_tos != other.nw_tos: return False
- if self.nw_proto != other.nw_proto: return False
- if self.nw_src != other.nw_src: return False
- if self.nw_src_mask != other.nw_src_mask: return False
- if self.nw_dst != other.nw_dst: return False
- if self.nw_dst_mask != other.nw_dst_mask: return False
- if self.tp_src != other.tp_src: return False
- if self.tp_dst != other.tp_dst: return False
- if self.mpls_label != other.mpls_label: return False
- if self.mpls_tc != other.mpls_tc: return False
- if self.pad2 != other.pad2: return False
- if self.metadata != other.metadata: return False
- if self.metadata_mask != other.metadata_mask: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'length: ' + str(self.length) + '\n'
- outstr += prefix + 'in_port: ' + str(self.in_port) + '\n'
- outstr += prefix + 'wildcards: ' + str(self.wildcards) + '\n'
- outstr += prefix + 'dl_src: ' + str(self.dl_src) + '\n'
- outstr += prefix + 'dl_src_mask: ' + str(self.dl_src_mask) + '\n'
- outstr += prefix + 'dl_dst: ' + str(self.dl_dst) + '\n'
- outstr += prefix + 'dl_dst_mask: ' + str(self.dl_dst_mask) + '\n'
- outstr += prefix + 'dl_vlan: ' + str(self.dl_vlan) + '\n'
- outstr += prefix + 'dl_vlan_pcp: ' + str(self.dl_vlan_pcp) + '\n'
- outstr += prefix + 'dl_type: ' + str(self.dl_type) + '\n'
- outstr += prefix + 'nw_tos: ' + str(self.nw_tos) + '\n'
- outstr += prefix + 'nw_proto: ' + str(self.nw_proto) + '\n'
- outstr += prefix + 'nw_src: ' + str(self.nw_src) + '\n'
- outstr += prefix + 'nw_src_mask: ' + str(self.nw_src_mask) + '\n'
- outstr += prefix + 'nw_dst: ' + str(self.nw_dst) + '\n'
- outstr += prefix + 'nw_dst_mask: ' + str(self.nw_dst_mask) + '\n'
- outstr += prefix + 'tp_src: ' + str(self.tp_src) + '\n'
- outstr += prefix + 'tp_dst: ' + str(self.tp_dst) + '\n'
- outstr += prefix + 'mpls_label: ' + str(self.mpls_label) + '\n'
- outstr += prefix + 'mpls_tc: ' + str(self.mpls_tc) + '\n'
- outstr += prefix + 'metadata: ' + str(self.metadata) + '\n'
- outstr += prefix + 'metadata_mask: ' + str(self.metadata_mask) + '\n'
- return outstr
-
-
-class ofp_port_stats(object):
- """Automatically generated Python class for ofp_port_stats
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.port_no = 0
- self.pad= [0,0,0,0]
- self.rx_packets = 0
- self.tx_packets = 0
- self.rx_bytes = 0
- self.tx_bytes = 0
- self.rx_dropped = 0
- self.tx_dropped = 0
- self.rx_errors = 0
- self.tx_errors = 0
- self.rx_frame_err = 0
- self.rx_over_err = 0
- self.rx_crc_err = 0
- self.collisions = 0
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 4):
- return (False, "self.pad is not of size 4 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!L", self.port_no)
- packed += struct.pack("!BBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3])
- packed += struct.pack("!QQQQQQQQQQQQ", self.rx_packets, self.tx_packets, self.rx_bytes, self.tx_bytes, self.rx_dropped, self.tx_dropped, self.rx_errors, self.tx_errors, self.rx_frame_err, self.rx_over_err, self.rx_crc_err, self.collisions)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 104):
- return binaryString
- fmt = '!L'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.port_no,) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 4
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!QQQQQQQQQQQQ'
- start = 8
- end = start + struct.calcsize(fmt)
- (self.rx_packets, self.tx_packets, self.rx_bytes, self.tx_bytes, self.rx_dropped, self.tx_dropped, self.rx_errors, self.tx_errors, self.rx_frame_err, self.rx_over_err, self.rx_crc_err, self.collisions) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[104:]
-
- def __len__(self):
- """Return length of message
- """
- l = 104
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.port_no != other.port_no: return False
- if self.pad != other.pad: return False
- if self.rx_packets != other.rx_packets: return False
- if self.tx_packets != other.tx_packets: return False
- if self.rx_bytes != other.rx_bytes: return False
- if self.tx_bytes != other.tx_bytes: return False
- if self.rx_dropped != other.rx_dropped: return False
- if self.tx_dropped != other.tx_dropped: return False
- if self.rx_errors != other.rx_errors: return False
- if self.tx_errors != other.tx_errors: return False
- if self.rx_frame_err != other.rx_frame_err: return False
- if self.rx_over_err != other.rx_over_err: return False
- if self.rx_crc_err != other.rx_crc_err: return False
- if self.collisions != other.collisions: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'port_no: ' + str(self.port_no) + '\n'
- outstr += prefix + 'rx_packets: ' + str(self.rx_packets) + '\n'
- outstr += prefix + 'tx_packets: ' + str(self.tx_packets) + '\n'
- outstr += prefix + 'rx_bytes: ' + str(self.rx_bytes) + '\n'
- outstr += prefix + 'tx_bytes: ' + str(self.tx_bytes) + '\n'
- outstr += prefix + 'rx_dropped: ' + str(self.rx_dropped) + '\n'
- outstr += prefix + 'tx_dropped: ' + str(self.tx_dropped) + '\n'
- outstr += prefix + 'rx_errors: ' + str(self.rx_errors) + '\n'
- outstr += prefix + 'tx_errors: ' + str(self.tx_errors) + '\n'
- outstr += prefix + 'rx_frame_err: ' + str(self.rx_frame_err) + '\n'
- outstr += prefix + 'rx_over_err: ' + str(self.rx_over_err) + '\n'
- outstr += prefix + 'rx_crc_err: ' + str(self.rx_crc_err) + '\n'
- outstr += prefix + 'collisions: ' + str(self.collisions) + '\n'
- return outstr
-
-
-class ofp_packet_queue(object):
- """Automatically generated Python class for ofp_packet_queue
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.queue_id = 0
- self.len = 0
- self.pad= [0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 2):
- return (False, "self.pad is not of size 2 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!LH", self.queue_id, self.len)
- packed += struct.pack("!BB", self.pad[0], self.pad[1])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!LH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.queue_id, self.len) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BB'
- start = 6
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.queue_id != other.queue_id: return False
- if self.len != other.len: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'queue_id: ' + str(self.queue_id) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- return outstr
-
-
-class ofp_port(object):
- """Automatically generated Python class for ofp_port
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.port_no = 0
- self.pad= [0,0,0,0]
- self.hw_addr= [0,0,0,0,0,0]
- self.pad2= [0,0]
- self.name= ""
- self.config = 0
- self.state = 0
- self.curr = 0
- self.advertised = 0
- self.supported = 0
- self.peer = 0
- self.curr_speed = 0
- self.max_speed = 0
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 4):
- return (False, "self.pad is not of size 4 as expected.")
- if(not isinstance(self.hw_addr, list)):
- return (False, "self.hw_addr is not list as expected.")
- if(len(self.hw_addr) != 6):
- return (False, "self.hw_addr is not of size 6 as expected.")
- if(not isinstance(self.pad2, list)):
- return (False, "self.pad2 is not list as expected.")
- if(len(self.pad2) != 2):
- return (False, "self.pad2 is not of size 2 as expected.")
- if(not isinstance(self.name, str)):
- return (False, "self.name is not string as expected.")
- if(len(self.name) > 16):
- return (False, "self.name is not of size 16 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!L", self.port_no)
- packed += struct.pack("!BBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3])
- packed += struct.pack("!BBBBBB", self.hw_addr[0], self.hw_addr[1], self.hw_addr[2], self.hw_addr[3], self.hw_addr[4], self.hw_addr[5])
- packed += struct.pack("!BB", self.pad2[0], self.pad2[1])
- packed += self.name.ljust(16,'\0')
- packed += struct.pack("!LLLLLLLL", self.config, self.state, self.curr, self.advertised, self.supported, self.peer, self.curr_speed, self.max_speed)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 64):
- return binaryString
- fmt = '!L'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.port_no,) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 4
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBBBB'
- start = 8
- end = start + struct.calcsize(fmt)
- (self.hw_addr[0], self.hw_addr[1], self.hw_addr[2], self.hw_addr[3], self.hw_addr[4], self.hw_addr[5]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BB'
- start = 14
- end = start + struct.calcsize(fmt)
- (self.pad2[0], self.pad2[1]) = struct.unpack(fmt, binaryString[start:end])
- self.name = binaryString[16:32].replace("\0","")
- fmt = '!LLLLLLLL'
- start = 32
- end = start + struct.calcsize(fmt)
- (self.config, self.state, self.curr, self.advertised, self.supported, self.peer, self.curr_speed, self.max_speed) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[64:]
-
- def __len__(self):
- """Return length of message
- """
- l = 64
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.port_no != other.port_no: return False
- if self.pad != other.pad: return False
- if self.hw_addr != other.hw_addr: return False
- if self.pad2 != other.pad2: return False
- if self.name != other.name: return False
- if self.config != other.config: return False
- if self.state != other.state: return False
- if self.curr != other.curr: return False
- if self.advertised != other.advertised: return False
- if self.supported != other.supported: return False
- if self.peer != other.peer: return False
- if self.curr_speed != other.curr_speed: return False
- if self.max_speed != other.max_speed: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'port_no: ' + str(self.port_no) + '\n'
- outstr += prefix + 'hw_addr: ' + str(self.hw_addr) + '\n'
- outstr += prefix + 'name: ' + str(self.name) + '\n'
- outstr += prefix + 'config: ' + str(self.config) + '\n'
- outstr += prefix + 'state: ' + str(self.state) + '\n'
- outstr += prefix + 'curr: ' + str(self.curr) + '\n'
- outstr += prefix + 'advertised: ' + str(self.advertised) + '\n'
- outstr += prefix + 'supported: ' + str(self.supported) + '\n'
- outstr += prefix + 'peer: ' + str(self.peer) + '\n'
- outstr += prefix + 'curr_speed: ' + str(self.curr_speed) + '\n'
- outstr += prefix + 'max_speed: ' + str(self.max_speed) + '\n'
- return outstr
-
-
-class ofp_action_dl_addr(object):
- """Automatically generated Python class for ofp_action_dl_addr
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.dl_addr= [0,0,0,0,0,0]
- self.pad= [0,0,0,0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.dl_addr, list)):
- return (False, "self.dl_addr is not list as expected.")
- if(len(self.dl_addr) != 6):
- return (False, "self.dl_addr is not of size 6 as expected.")
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 6):
- return (False, "self.pad is not of size 6 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HH", self.type, self.len)
- packed += struct.pack("!BBBBBB", self.dl_addr[0], self.dl_addr[1], self.dl_addr[2], self.dl_addr[3], self.dl_addr[4], self.dl_addr[5])
- packed += struct.pack("!BBBBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3], self.pad[4], self.pad[5])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 16):
- return binaryString
- fmt = '!HH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBBBB'
- start = 4
- end = start + struct.calcsize(fmt)
- (self.dl_addr[0], self.dl_addr[1], self.dl_addr[2], self.dl_addr[3], self.dl_addr[4], self.dl_addr[5]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBBBB'
- start = 10
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3], self.pad[4], self.pad[5]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[16:]
-
- def __len__(self):
- """Return length of message
- """
- l = 16
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.dl_addr != other.dl_addr: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- outstr += prefix + 'dl_addr: ' + str(self.dl_addr) + '\n'
- return outstr
-
-
-class ofp_bucket_counter(object):
- """Automatically generated Python class for ofp_bucket_counter
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.packet_count = 0
- self.byte_count = 0
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!QQ", self.packet_count, self.byte_count)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 16):
- return binaryString
- fmt = '!QQ'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.packet_count, self.byte_count) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[16:]
-
- def __len__(self):
- """Return length of message
- """
- l = 16
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.packet_count != other.packet_count: return False
- if self.byte_count != other.byte_count: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'packet_count: ' + str(self.packet_count) + '\n'
- outstr += prefix + 'byte_count: ' + str(self.byte_count) + '\n'
- return outstr
-
-
-class ofp_queue_prop_min_rate(object):
- """Automatically generated Python class for ofp_queue_prop_min_rate
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.prop_header = ofp_queue_prop_header()
- self.rate = 0
- self.pad= [0,0,0,0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.prop_header, ofp_queue_prop_header)):
- return (False, "self.prop_header is not class ofp_queue_prop_header as expected.")
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 6):
- return (False, "self.pad is not of size 6 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += self.prop_header.pack()
- packed += struct.pack("!H", self.rate)
- packed += struct.pack("!BBBBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3], self.pad[4], self.pad[5])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 16):
- return binaryString
- self.prop_header.unpack(binaryString[0:])
- fmt = '!H'
- start = 8
- end = start + struct.calcsize(fmt)
- (self.rate,) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBBBB'
- start = 10
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3], self.pad[4], self.pad[5]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[16:]
-
- def __len__(self):
- """Return length of message
- """
- l = 16
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.prop_header != other.prop_header: return False
- if self.rate != other.rate: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'prop_header: \n'
- outstr += self.prop_header.show(prefix + ' ')
- outstr += prefix + 'rate: ' + str(self.rate) + '\n'
- return outstr
-
-
-class ofp_bucket(object):
- """Automatically generated Python class for ofp_bucket
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.len = 0
- self.weight = 0
- self.watch_port = 0
- self.watch_group = 0
- self.pad= [0,0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 4):
- return (False, "self.pad is not of size 4 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HHLL", self.len, self.weight, self.watch_port, self.watch_group)
- packed += struct.pack("!BBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 16):
- return binaryString
- fmt = '!HHLL'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.len, self.weight, self.watch_port, self.watch_group) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 12
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[16:]
-
- def __len__(self):
- """Return length of message
- """
- l = 16
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.len != other.len: return False
- if self.weight != other.weight: return False
- if self.watch_port != other.watch_port: return False
- if self.watch_group != other.watch_group: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- outstr += prefix + 'weight: ' + str(self.weight) + '\n'
- outstr += prefix + 'watch_port: ' + str(self.watch_port) + '\n'
- outstr += prefix + 'watch_group: ' + str(self.watch_group) + '\n'
- return outstr
-
-
-class ofp_switch_features(object):
- """Automatically generated Python class for ofp_switch_features
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.datapath_id = 0
- self.n_buffers = 0
- self.n_tables = 0
- self.pad= [0,0,0]
- self.capabilities = 0
- self.reserved = 0
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 3):
- return (False, "self.pad is not of size 3 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!QLB", self.datapath_id, self.n_buffers, self.n_tables)
- packed += struct.pack("!BBB", self.pad[0], self.pad[1], self.pad[2])
- packed += struct.pack("!LL", self.capabilities, self.reserved)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 24):
- return binaryString
- fmt = '!QLB'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.datapath_id, self.n_buffers, self.n_tables) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBB'
- start = 13
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!LL'
- start = 16
- end = start + struct.calcsize(fmt)
- (self.capabilities, self.reserved) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[24:]
-
- def __len__(self):
- """Return length of message
- """
- l = 24
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.datapath_id != other.datapath_id: return False
- if self.n_buffers != other.n_buffers: return False
- if self.n_tables != other.n_tables: return False
- if self.pad != other.pad: return False
- if self.capabilities != other.capabilities: return False
- if self.reserved != other.reserved: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'datapath_id: ' + str(self.datapath_id) + '\n'
- outstr += prefix + 'n_buffers: ' + str(self.n_buffers) + '\n'
- outstr += prefix + 'n_tables: ' + str(self.n_tables) + '\n'
- outstr += prefix + 'capabilities: ' + str(self.capabilities) + '\n'
- outstr += prefix + 'reserved: ' + str(self.reserved) + '\n'
- return outstr
-
-
-class ofp_action_pop_mpls(object):
- """Automatically generated Python class for ofp_action_pop_mpls
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.ethertype = 0
- self.pad= [0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 2):
- return (False, "self.pad is not of size 2 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HHH", self.type, self.len, self.ethertype)
- packed += struct.pack("!BB", self.pad[0], self.pad[1])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HHH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len, self.ethertype) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BB'
- start = 6
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.ethertype != other.ethertype: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- outstr += prefix + 'ethertype: ' + str(self.ethertype) + '\n'
- return outstr
-
-
-class ofp_flow_mod(object):
- """Automatically generated Python class for ofp_flow_mod
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.cookie = 0
- self.cookie_mask = 0
- self.table_id = 0
- self.command = 0
- self.idle_timeout = 0
- self.hard_timeout = 0
- self.priority = 0x8000
- self.buffer_id = 0
- self.out_port = 0
- self.out_group = 0
- self.flags = 0
- self.pad= [0,0]
- self.match = ofp_match()
- self.match.length = OFP_MATCH_BYTES
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 2):
- return (False, "self.pad is not of size 2 as expected.")
- if(not isinstance(self.match, ofp_match)):
- return (False, "self.match is not class ofp_match as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!QQBBHHHLLLH", self.cookie, self.cookie_mask, self.table_id, self.command, self.idle_timeout, self.hard_timeout, self.priority, self.buffer_id, self.out_port, self.out_group, self.flags)
- packed += struct.pack("!BB", self.pad[0], self.pad[1])
- packed += self.match.pack()
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 128):
- return binaryString
- fmt = '!QQBBHHHLLLH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.cookie, self.cookie_mask, self.table_id, self.command, self.idle_timeout, self.hard_timeout, self.priority, self.buffer_id, self.out_port, self.out_group, self.flags) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BB'
- start = 38
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1]) = struct.unpack(fmt, binaryString[start:end])
- self.match.unpack(binaryString[40:])
- return binaryString[128:]
-
- def __len__(self):
- """Return length of message
- """
- l = 128
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.cookie != other.cookie: return False
- if self.cookie_mask != other.cookie_mask: return False
- if self.table_id != other.table_id: return False
- if self.command != other.command: return False
- if self.idle_timeout != other.idle_timeout: return False
- if self.hard_timeout != other.hard_timeout: return False
- if self.priority != other.priority: return False
- if self.buffer_id != other.buffer_id: return False
- if self.out_port != other.out_port: return False
- if self.out_group != other.out_group: return False
- if self.flags != other.flags: return False
- if self.pad != other.pad: return False
- if self.match != other.match: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'cookie: ' + str(self.cookie) + '\n'
- outstr += prefix + 'cookie_mask: ' + str(self.cookie_mask) + '\n'
- outstr += prefix + 'table_id: ' + str(self.table_id) + '\n'
- outstr += prefix + 'command: ' + str(self.command) + '\n'
- outstr += prefix + 'idle_timeout: ' + str(self.idle_timeout) + '\n'
- outstr += prefix + 'hard_timeout: ' + str(self.hard_timeout) + '\n'
- outstr += prefix + 'priority: ' + str(self.priority) + '\n'
- outstr += prefix + 'buffer_id: ' + str(self.buffer_id) + '\n'
- outstr += prefix + 'out_port: ' + str(self.out_port) + '\n'
- outstr += prefix + 'out_group: ' + str(self.out_group) + '\n'
- outstr += prefix + 'flags: ' + str(self.flags) + '\n'
- outstr += prefix + 'match: \n'
- outstr += self.match.show(prefix + ' ')
- return outstr
-
-
-class ofp_packet_out(object):
- """Automatically generated Python class for ofp_packet_out
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.buffer_id = 4294967295
- self.in_port = 0
- self.actions_len = 0
- self.pad= [0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 2):
- return (False, "self.pad is not of size 2 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!LLH", self.buffer_id, self.in_port, self.actions_len)
- packed += struct.pack("!BB", self.pad[0], self.pad[1])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 12):
- return binaryString
- fmt = '!LLH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.buffer_id, self.in_port, self.actions_len) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BB'
- start = 10
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[12:]
-
- def __len__(self):
- """Return length of message
- """
- l = 12
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.buffer_id != other.buffer_id: return False
- if self.in_port != other.in_port: return False
- if self.actions_len != other.actions_len: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'buffer_id: ' + str(self.buffer_id) + '\n'
- outstr += prefix + 'in_port: ' + str(self.in_port) + '\n'
- outstr += prefix + 'actions_len: ' + str(self.actions_len) + '\n'
- return outstr
-
-
-class ofp_instruction_goto_table(object):
- """Automatically generated Python class for ofp_instruction_goto_table
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.table_id = 0
- self.pad= [0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 3):
- return (False, "self.pad is not of size 3 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HHB", self.type, self.len, self.table_id)
- packed += struct.pack("!BBB", self.pad[0], self.pad[1], self.pad[2])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HHB'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len, self.table_id) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBB'
- start = 5
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.table_id != other.table_id: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- outstr += prefix + 'table_id: ' + str(self.table_id) + '\n'
- return outstr
-
-
-class ofp_action_nw_addr(object):
- """Automatically generated Python class for ofp_action_nw_addr
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.nw_addr = 0
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HHL", self.type, self.len, self.nw_addr)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HHL'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len, self.nw_addr) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.nw_addr != other.nw_addr: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- outstr += prefix + 'nw_addr: ' + str(self.nw_addr) + '\n'
- return outstr
-
-
-class ofp_action_group(object):
- """Automatically generated Python class for ofp_action_group
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.group_id = 0
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HHL", self.type, self.len, self.group_id)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HHL'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len, self.group_id) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.group_id != other.group_id: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- outstr += prefix + 'group_id: ' + str(self.group_id) + '\n'
- return outstr
-
-
-class ofp_group_stats(object):
- """Automatically generated Python class for ofp_group_stats
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.length = 0
- self.pad= [0,0]
- self.group_id = 0
- self.ref_count = 0
- self.pad2= [0,0,0,0]
- self.packet_count = 0
- self.byte_count = 0
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 2):
- return (False, "self.pad is not of size 2 as expected.")
- if(not isinstance(self.pad2, list)):
- return (False, "self.pad2 is not list as expected.")
- if(len(self.pad2) != 4):
- return (False, "self.pad2 is not of size 4 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!H", self.length)
- packed += struct.pack("!BB", self.pad[0], self.pad[1])
- packed += struct.pack("!LL", self.group_id, self.ref_count)
- packed += struct.pack("!BBBB", self.pad2[0], self.pad2[1], self.pad2[2], self.pad2[3])
- packed += struct.pack("!QQ", self.packet_count, self.byte_count)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 32):
- return binaryString
- fmt = '!H'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.length,) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BB'
- start = 2
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!LL'
- start = 4
- end = start + struct.calcsize(fmt)
- (self.group_id, self.ref_count) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 12
- end = start + struct.calcsize(fmt)
- (self.pad2[0], self.pad2[1], self.pad2[2], self.pad2[3]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!QQ'
- start = 16
- end = start + struct.calcsize(fmt)
- (self.packet_count, self.byte_count) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[32:]
-
- def __len__(self):
- """Return length of message
- """
- l = 32
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.length != other.length: return False
- if self.pad != other.pad: return False
- if self.group_id != other.group_id: return False
- if self.ref_count != other.ref_count: return False
- if self.pad2 != other.pad2: return False
- if self.packet_count != other.packet_count: return False
- if self.byte_count != other.byte_count: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'length: ' + str(self.length) + '\n'
- outstr += prefix + 'group_id: ' + str(self.group_id) + '\n'
- outstr += prefix + 'ref_count: ' + str(self.ref_count) + '\n'
- outstr += prefix + 'packet_count: ' + str(self.packet_count) + '\n'
- outstr += prefix + 'byte_count: ' + str(self.byte_count) + '\n'
- return outstr
-
-
-class ofp_action_vlan_pcp(object):
- """Automatically generated Python class for ofp_action_vlan_pcp
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.vlan_pcp = 0
- self.pad= [0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 3):
- return (False, "self.pad is not of size 3 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HHB", self.type, self.len, self.vlan_pcp)
- packed += struct.pack("!BBB", self.pad[0], self.pad[1], self.pad[2])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HHB'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len, self.vlan_pcp) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBB'
- start = 5
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.vlan_pcp != other.vlan_pcp: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- outstr += prefix + 'vlan_pcp: ' + str(self.vlan_pcp) + '\n'
- return outstr
-
-
-class ofp_action_push(object):
- """Automatically generated Python class for ofp_action_push
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.ethertype = 0
- self.pad= [0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 2):
- return (False, "self.pad is not of size 2 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HHH", self.type, self.len, self.ethertype)
- packed += struct.pack("!BB", self.pad[0], self.pad[1])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HHH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len, self.ethertype) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BB'
- start = 6
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.ethertype != other.ethertype: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- outstr += prefix + 'ethertype: ' + str(self.ethertype) + '\n'
- return outstr
-
-
-class ofp_group_desc_stats(object):
- """Automatically generated Python class for ofp_group_desc_stats
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.length = 0
- self.type = 0
- self.pad = 0
- self.group_id = 0
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HBBL", self.length, self.type, self.pad, self.group_id)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HBBL'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.length, self.type, self.pad, self.group_id) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.length != other.length: return False
- if self.type != other.type: return False
- if self.pad != other.pad: return False
- if self.group_id != other.group_id: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'length: ' + str(self.length) + '\n'
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'group_id: ' + str(self.group_id) + '\n'
- return outstr
-
-
-class ofp_error_msg(object):
- """Automatically generated Python class for ofp_error_msg
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.code = 0
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HH", self.type, self.code)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 4):
- return binaryString
- fmt = '!HH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.code) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[4:]
-
- def __len__(self):
- """Return length of message
- """
- l = 4
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.code != other.code: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'code: ' + str(self.code) + '\n'
- return outstr
-
-
-class ofp_action_mpls_ttl(object):
- """Automatically generated Python class for ofp_action_mpls_ttl
-
- Date 2013-01-06
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.mpls_ttl = 0
- self.pad= [0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 3):
- return (False, "self.pad is not of size 3 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HHB", self.type, self.len, self.mpls_ttl)
- packed += struct.pack("!BBB", self.pad[0], self.pad[1], self.pad[2])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HHB'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len, self.mpls_ttl) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBB'
- start = 5
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.mpls_ttl != other.mpls_ttl: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- outstr += prefix + 'mpls_ttl: ' + str(self.mpls_ttl) + '\n'
- return outstr
-
-
-# Enumerated type definitions
-ofp_error_type = ['OFPET_HELLO_FAILED', 'OFPET_BAD_REQUEST', 'OFPET_BAD_ACTION', 'OFPET_FLOW_MOD_FAILED', 'OFPET_GROUP_MOD_FAILED', 'OFPET_PORT_MOD_FAILED', 'OFPET_TABLE_MOD_FAILED', 'OFPET_QUEUE_OP_FAILED', 'OFPET_SWITCH_CONFIG_FAILED']
-OFPET_HELLO_FAILED = 0
-OFPET_BAD_REQUEST = 1
-OFPET_BAD_ACTION = 2
-OFPET_FLOW_MOD_FAILED = 3
-OFPET_GROUP_MOD_FAILED = 4
-OFPET_PORT_MOD_FAILED = 5
-OFPET_TABLE_MOD_FAILED = 6
-OFPET_QUEUE_OP_FAILED = 7
-OFPET_SWITCH_CONFIG_FAILED = 8
-ofp_error_type_map = {
- 0 : 'OFPET_HELLO_FAILED',
- 1 : 'OFPET_BAD_REQUEST',
- 2 : 'OFPET_BAD_ACTION',
- 3 : 'OFPET_FLOW_MOD_FAILED',
- 4 : 'OFPET_GROUP_MOD_FAILED',
- 5 : 'OFPET_PORT_MOD_FAILED',
- 6 : 'OFPET_TABLE_MOD_FAILED',
- 7 : 'OFPET_QUEUE_OP_FAILED',
- 8 : 'OFPET_SWITCH_CONFIG_FAILED'
-}
-
-ofp_flow_mod_flags = ['OFPFF_SEND_FLOW_REM', 'OFPFF_CHECK_OVERLAP']
-OFPFF_SEND_FLOW_REM = 1
-OFPFF_CHECK_OVERLAP = 2
-ofp_flow_mod_flags_map = {
- 1 : 'OFPFF_SEND_FLOW_REM',
- 2 : 'OFPFF_CHECK_OVERLAP'
-}
-
-ofp_stats_reply_flags = ['OFPSF_REPLY_MORE']
-OFPSF_REPLY_MORE = 1
-ofp_stats_reply_flags_map = {
- 1 : 'OFPSF_REPLY_MORE'
-}
-
-ofp_port_no = ['OFPP_MAX', 'OFPP_IN_PORT', 'OFPP_TABLE', 'OFPP_NORMAL', 'OFPP_FLOOD', 'OFPP_ALL', 'OFPP_CONTROLLER', 'OFPP_LOCAL', 'OFPP_ANY']
-OFPP_MAX = 4294967040
-OFPP_IN_PORT = 4294967288
-OFPP_TABLE = 4294967289
-OFPP_NORMAL = 4294967290
-OFPP_FLOOD = 4294967291
-OFPP_ALL = 4294967292
-OFPP_CONTROLLER = 4294967293
-OFPP_LOCAL = 4294967294
-OFPP_ANY = 4294967295
-ofp_port_no_map = {
- 4294967040 : 'OFPP_MAX',
- 4294967288 : 'OFPP_IN_PORT',
- 4294967289 : 'OFPP_TABLE',
- 4294967290 : 'OFPP_NORMAL',
- 4294967291 : 'OFPP_FLOOD',
- 4294967292 : 'OFPP_ALL',
- 4294967293 : 'OFPP_CONTROLLER',
- 4294967294 : 'OFPP_LOCAL',
- 4294967295 : 'OFPP_ANY'
-}
-
-ofp_flow_match_fields = ['OFPFMF_IN_PORT', 'OFPFMF_DL_VLAN', 'OFPFMF_DL_VLAN_PCP', 'OFPFMF_DL_TYPE', 'OFPFMF_NW_TOS', 'OFPFMF_NW_PROTO', 'OFPFMF_TP_SRC', 'OFPFMF_TP_DST', 'OFPFMF_MPLS_LABEL', 'OFPFMF_MPLS_TC', 'OFPFMF_TYPE', 'OFPFMF_DL_SRC', 'OFPFMF_DL_DST', 'OFPFMF_NW_SRC', 'OFPFMF_NW_DST', 'OFPFMF_METADATA']
-OFPFMF_IN_PORT = 1
-OFPFMF_DL_VLAN = 2
-OFPFMF_DL_VLAN_PCP = 4
-OFPFMF_DL_TYPE = 8
-OFPFMF_NW_TOS = 16
-OFPFMF_NW_PROTO = 32
-OFPFMF_TP_SRC = 64
-OFPFMF_TP_DST = 128
-OFPFMF_MPLS_LABEL = 256
-OFPFMF_MPLS_TC = 512
-OFPFMF_TYPE = 1024
-OFPFMF_DL_SRC = 2048
-OFPFMF_DL_DST = 4096
-OFPFMF_NW_SRC = 8192
-OFPFMF_NW_DST = 16384
-OFPFMF_METADATA = 32768
-ofp_flow_match_fields_map = {
- 1 : 'OFPFMF_IN_PORT',
- 2 : 'OFPFMF_DL_VLAN',
- 4 : 'OFPFMF_DL_VLAN_PCP',
- 8 : 'OFPFMF_DL_TYPE',
- 16 : 'OFPFMF_NW_TOS',
- 32 : 'OFPFMF_NW_PROTO',
- 64 : 'OFPFMF_TP_SRC',
- 128 : 'OFPFMF_TP_DST',
- 256 : 'OFPFMF_MPLS_LABEL',
- 512 : 'OFPFMF_MPLS_TC',
- 1024 : 'OFPFMF_TYPE',
- 2048 : 'OFPFMF_DL_SRC',
- 4096 : 'OFPFMF_DL_DST',
- 8192 : 'OFPFMF_NW_SRC',
- 16384 : 'OFPFMF_NW_DST',
- 32768 : 'OFPFMF_METADATA'
-}
-
-ofp_bad_request_code = ['OFPBRC_BAD_VERSION', 'OFPBRC_BAD_TYPE', 'OFPBRC_BAD_STAT', 'OFPBRC_BAD_EXPERIMENTER', 'OFPBRC_BAD_SUBTYPE', 'OFPBRC_EPERM', 'OFPBRC_BAD_LEN', 'OFPBRC_BUFFER_EMPTY', 'OFPBRC_BUFFER_UNKNOWN', 'OFPBRC_BAD_TABLE_ID']
-OFPBRC_BAD_VERSION = 0
-OFPBRC_BAD_TYPE = 1
-OFPBRC_BAD_STAT = 2
-OFPBRC_BAD_EXPERIMENTER = 3
-OFPBRC_BAD_SUBTYPE = 4
-OFPBRC_EPERM = 5
-OFPBRC_BAD_LEN = 6
-OFPBRC_BUFFER_EMPTY = 7
-OFPBRC_BUFFER_UNKNOWN = 8
-OFPBRC_BAD_TABLE_ID = 9
-ofp_bad_request_code_map = {
- 0 : 'OFPBRC_BAD_VERSION',
- 1 : 'OFPBRC_BAD_TYPE',
- 2 : 'OFPBRC_BAD_STAT',
- 3 : 'OFPBRC_BAD_EXPERIMENTER',
- 4 : 'OFPBRC_BAD_SUBTYPE',
- 5 : 'OFPBRC_EPERM',
- 6 : 'OFPBRC_BAD_LEN',
- 7 : 'OFPBRC_BUFFER_EMPTY',
- 8 : 'OFPBRC_BUFFER_UNKNOWN',
- 9 : 'OFPBRC_BAD_TABLE_ID'
-}
-
-ofp_port_config = ['OFPPC_PORT_DOWN', 'OFPPC_NO_RECV', 'OFPPC_NO_FWD', 'OFPPC_NO_PACKET_IN']
-OFPPC_PORT_DOWN = 1
-OFPPC_NO_RECV = 4
-OFPPC_NO_FWD = 32
-OFPPC_NO_PACKET_IN = 64
-ofp_port_config_map = {
- 1 : 'OFPPC_PORT_DOWN',
- 4 : 'OFPPC_NO_RECV',
- 32 : 'OFPPC_NO_FWD',
- 64 : 'OFPPC_NO_PACKET_IN'
-}
-
-ofp_port_state = ['OFPPS_LINK_DOWN', 'OFPPS_BLOCKED', 'OFPPS_LIVE']
-OFPPS_LINK_DOWN = 1
-OFPPS_BLOCKED = 2
-OFPPS_LIVE = 4
-ofp_port_state_map = {
- 1 : 'OFPPS_LINK_DOWN',
- 2 : 'OFPPS_BLOCKED',
- 4 : 'OFPPS_LIVE'
-}
-
-ofp_config_flags = ['OFPC_FRAG_NORMAL', 'OFPC_FRAG_DROP', 'OFPC_FRAG_REASM', 'OFPC_FRAG_MASK', 'OFPC_INVALID_TTL_TO_CONTROLLER']
-OFPC_FRAG_NORMAL = 0
-OFPC_FRAG_DROP = 1
-OFPC_FRAG_REASM = 2
-OFPC_FRAG_MASK = 3
-OFPC_INVALID_TTL_TO_CONTROLLER = 4
-ofp_config_flags_map = {
- 0 : 'OFPC_FRAG_NORMAL',
- 1 : 'OFPC_FRAG_DROP',
- 2 : 'OFPC_FRAG_REASM',
- 3 : 'OFPC_FRAG_MASK',
- 4 : 'OFPC_INVALID_TTL_TO_CONTROLLER'
-}
-
-ofp_switch_config_failed_code = ['OFPSCFC_BAD_FLAGS', 'OFPSCFC_BAD_LEN']
-OFPSCFC_BAD_FLAGS = 0
-OFPSCFC_BAD_LEN = 1
-ofp_switch_config_failed_code_map = {
- 0 : 'OFPSCFC_BAD_FLAGS',
- 1 : 'OFPSCFC_BAD_LEN'
-}
-
-ofp_hello_failed_code = ['OFPHFC_INCOMPATIBLE', 'OFPHFC_EPERM']
-OFPHFC_INCOMPATIBLE = 0
-OFPHFC_EPERM = 1
-ofp_hello_failed_code_map = {
- 0 : 'OFPHFC_INCOMPATIBLE',
- 1 : 'OFPHFC_EPERM'
-}
-
-ofp_capabilities = ['OFPC_FLOW_STATS', 'OFPC_TABLE_STATS', 'OFPC_PORT_STATS', 'OFPC_GROUP_STATS', 'OFPC_IP_REASM', 'OFPC_QUEUE_STATS', 'OFPC_ARP_MATCH_IP']
-OFPC_FLOW_STATS = 1
-OFPC_TABLE_STATS = 2
-OFPC_PORT_STATS = 4
-OFPC_GROUP_STATS = 8
-OFPC_IP_REASM = 32
-OFPC_QUEUE_STATS = 64
-OFPC_ARP_MATCH_IP = 128
-ofp_capabilities_map = {
- 1 : 'OFPC_FLOW_STATS',
- 2 : 'OFPC_TABLE_STATS',
- 4 : 'OFPC_PORT_STATS',
- 8 : 'OFPC_GROUP_STATS',
- 32 : 'OFPC_IP_REASM',
- 64 : 'OFPC_QUEUE_STATS',
- 128 : 'OFPC_ARP_MATCH_IP'
-}
-
-ofp_flow_removed_reason = ['OFPRR_IDLE_TIMEOUT', 'OFPRR_HARD_TIMEOUT', 'OFPRR_DELETE', 'OFPRR_GROUP_DELETE']
-OFPRR_IDLE_TIMEOUT = 0
-OFPRR_HARD_TIMEOUT = 1
-OFPRR_DELETE = 2
-OFPRR_GROUP_DELETE = 3
-ofp_flow_removed_reason_map = {
- 0 : 'OFPRR_IDLE_TIMEOUT',
- 1 : 'OFPRR_HARD_TIMEOUT',
- 2 : 'OFPRR_DELETE',
- 3 : 'OFPRR_GROUP_DELETE'
-}
-
-ofp_table_mod_failed_code = ['OFPTMFC_BAD_TABLE', 'OFPTMFC_BAD_CONFIG']
-OFPTMFC_BAD_TABLE = 0
-OFPTMFC_BAD_CONFIG = 1
-ofp_table_mod_failed_code_map = {
- 0 : 'OFPTMFC_BAD_TABLE',
- 1 : 'OFPTMFC_BAD_CONFIG'
-}
-
-ofp_queue_properties = ['OFPQT_NONE', 'OFPQT_MIN_RATE']
-OFPQT_NONE = 0
-OFPQT_MIN_RATE = 0
-ofp_queue_properties_map = {
- 0 : 'OFPQT_NONE',
- 0 : 'OFPQT_MIN_RATE'
-}
-
-ofp_flow_wildcards = ['OFPFW_IN_PORT', 'OFPFW_DL_VLAN', 'OFPFW_DL_VLAN_PCP', 'OFPFW_DL_TYPE', 'OFPFW_NW_TOS', 'OFPFW_NW_PROTO', 'OFPFW_TP_SRC', 'OFPFW_TP_DST', 'OFPFW_MPLS_LABEL', 'OFPFW_MPLS_TC', 'OFPFW_ALL']
-OFPFW_IN_PORT = 1
-OFPFW_DL_VLAN = 2
-OFPFW_DL_VLAN_PCP = 4
-OFPFW_DL_TYPE = 8
-OFPFW_NW_TOS = 16
-OFPFW_NW_PROTO = 32
-OFPFW_TP_SRC = 64
-OFPFW_TP_DST = 128
-OFPFW_MPLS_LABEL = 256
-OFPFW_MPLS_TC = 512
-OFPFW_ALL = 1023
-ofp_flow_wildcards_map = {
- 1 : 'OFPFW_IN_PORT',
- 2 : 'OFPFW_DL_VLAN',
- 4 : 'OFPFW_DL_VLAN_PCP',
- 8 : 'OFPFW_DL_TYPE',
- 16 : 'OFPFW_NW_TOS',
- 32 : 'OFPFW_NW_PROTO',
- 64 : 'OFPFW_TP_SRC',
- 128 : 'OFPFW_TP_DST',
- 256 : 'OFPFW_MPLS_LABEL',
- 512 : 'OFPFW_MPLS_TC',
- 1023 : 'OFPFW_ALL'
-}
-
-ofp_group = ['OFPG_MAX', 'OFPG_ALL', 'OFPG_ANY']
-OFPG_MAX = 4294967040
-OFPG_ALL = 4294967292
-OFPG_ANY = 4294967295
-ofp_group_map = {
- 4294967040 : 'OFPG_MAX',
- 4294967292 : 'OFPG_ALL',
- 4294967295 : 'OFPG_ANY'
-}
-
-ofp_port_reason = ['OFPPR_ADD', 'OFPPR_DELETE', 'OFPPR_MODIFY']
-OFPPR_ADD = 0
-OFPPR_DELETE = 1
-OFPPR_MODIFY = 2
-ofp_port_reason_map = {
- 0 : 'OFPPR_ADD',
- 1 : 'OFPPR_DELETE',
- 2 : 'OFPPR_MODIFY'
-}
-
-ofp_table_config = ['OFPTC_TABLE_MISS_CONTROLLER', 'OFPTC_TABLE_MISS_CONTINUE', 'OFPTC_TABLE_MISS_DROP', 'OFPTC_TABLE_MISS_MASK']
-OFPTC_TABLE_MISS_CONTROLLER = 0
-OFPTC_TABLE_MISS_CONTINUE = 1
-OFPTC_TABLE_MISS_DROP = 2
-OFPTC_TABLE_MISS_MASK = 3
-ofp_table_config_map = {
- 0 : 'OFPTC_TABLE_MISS_CONTROLLER',
- 1 : 'OFPTC_TABLE_MISS_CONTINUE',
- 2 : 'OFPTC_TABLE_MISS_DROP',
- 3 : 'OFPTC_TABLE_MISS_MASK'
-}
-
-ofp_action_type = ['OFPAT_OUTPUT', 'OFPAT_SET_VLAN_VID', 'OFPAT_SET_VLAN_PCP', 'OFPAT_SET_DL_SRC', 'OFPAT_SET_DL_DST', 'OFPAT_SET_NW_SRC', 'OFPAT_SET_NW_DST', 'OFPAT_SET_NW_TOS', 'OFPAT_SET_NW_ECN', 'OFPAT_SET_TP_SRC', 'OFPAT_SET_TP_DST', 'OFPAT_COPY_TTL_OUT', 'OFPAT_COPY_TTL_IN', 'OFPAT_SET_MPLS_LABEL', 'OFPAT_SET_MPLS_TC', 'OFPAT_SET_MPLS_TTL', 'OFPAT_DEC_MPLS_TTL', 'OFPAT_PUSH_VLAN', 'OFPAT_POP_VLAN', 'OFPAT_PUSH_MPLS', 'OFPAT_POP_MPLS', 'OFPAT_SET_QUEUE', 'OFPAT_GROUP', 'OFPAT_SET_NW_TTL', 'OFPAT_DEC_NW_TTL', 'OFPAT_EXPERIMENTER']
-OFPAT_OUTPUT = 0
-OFPAT_SET_VLAN_VID = 1
-OFPAT_SET_VLAN_PCP = 2
-OFPAT_SET_DL_SRC = 3
-OFPAT_SET_DL_DST = 4
-OFPAT_SET_NW_SRC = 5
-OFPAT_SET_NW_DST = 6
-OFPAT_SET_NW_TOS = 7
-OFPAT_SET_NW_ECN = 8
-OFPAT_SET_TP_SRC = 9
-OFPAT_SET_TP_DST = 10
-OFPAT_COPY_TTL_OUT = 11
-OFPAT_COPY_TTL_IN = 12
-OFPAT_SET_MPLS_LABEL = 13
-OFPAT_SET_MPLS_TC = 14
-OFPAT_SET_MPLS_TTL = 15
-OFPAT_DEC_MPLS_TTL = 16
-OFPAT_PUSH_VLAN = 17
-OFPAT_POP_VLAN = 18
-OFPAT_PUSH_MPLS = 19
-OFPAT_POP_MPLS = 20
-OFPAT_SET_QUEUE = 21
-OFPAT_GROUP = 22
-OFPAT_SET_NW_TTL = 23
-OFPAT_DEC_NW_TTL = 24
-OFPAT_EXPERIMENTER = 65535
-ofp_action_type_map = {
- 0 : 'OFPAT_OUTPUT',
- 1 : 'OFPAT_SET_VLAN_VID',
- 2 : 'OFPAT_SET_VLAN_PCP',
- 3 : 'OFPAT_SET_DL_SRC',
- 4 : 'OFPAT_SET_DL_DST',
- 5 : 'OFPAT_SET_NW_SRC',
- 6 : 'OFPAT_SET_NW_DST',
- 7 : 'OFPAT_SET_NW_TOS',
- 8 : 'OFPAT_SET_NW_ECN',
- 9 : 'OFPAT_SET_TP_SRC',
- 10 : 'OFPAT_SET_TP_DST',
- 11 : 'OFPAT_COPY_TTL_OUT',
- 12 : 'OFPAT_COPY_TTL_IN',
- 13 : 'OFPAT_SET_MPLS_LABEL',
- 14 : 'OFPAT_SET_MPLS_TC',
- 15 : 'OFPAT_SET_MPLS_TTL',
- 16 : 'OFPAT_DEC_MPLS_TTL',
- 17 : 'OFPAT_PUSH_VLAN',
- 18 : 'OFPAT_POP_VLAN',
- 19 : 'OFPAT_PUSH_MPLS',
- 20 : 'OFPAT_POP_MPLS',
- 21 : 'OFPAT_SET_QUEUE',
- 22 : 'OFPAT_GROUP',
- 23 : 'OFPAT_SET_NW_TTL',
- 24 : 'OFPAT_DEC_NW_TTL',
- 65535 : 'OFPAT_EXPERIMENTER'
-}
-
-ofp_flow_mod_command = ['OFPFC_ADD', 'OFPFC_MODIFY', 'OFPFC_MODIFY_STRICT', 'OFPFC_DELETE', 'OFPFC_DELETE_STRICT']
-OFPFC_ADD = 0
-OFPFC_MODIFY = 1
-OFPFC_MODIFY_STRICT = 2
-OFPFC_DELETE = 3
-OFPFC_DELETE_STRICT = 4
-ofp_flow_mod_command_map = {
- 0 : 'OFPFC_ADD',
- 1 : 'OFPFC_MODIFY',
- 2 : 'OFPFC_MODIFY_STRICT',
- 3 : 'OFPFC_DELETE',
- 4 : 'OFPFC_DELETE_STRICT'
-}
-
-ofp_queue_op_failed_code = ['OFPQOFC_BAD_PORT', 'OFPQOFC_BAD_QUEUE', 'OFPQOFC_EPERM']
-OFPQOFC_BAD_PORT = 0
-OFPQOFC_BAD_QUEUE = 1
-OFPQOFC_EPERM = 2
-ofp_queue_op_failed_code_map = {
- 0 : 'OFPQOFC_BAD_PORT',
- 1 : 'OFPQOFC_BAD_QUEUE',
- 2 : 'OFPQOFC_EPERM'
-}
-
-ofp_match_type = ['OFPMT_STANDARD']
-OFPMT_STANDARD = 0
-ofp_match_type_map = {
- 0 : 'OFPMT_STANDARD'
-}
-
-ofp_vlan_id = ['OFPVID_ANY', 'OFPVID_NONE']
-OFPVID_ANY = 65534
-OFPVID_NONE = 65535
-ofp_vlan_id_map = {
- 65534 : 'OFPVID_ANY',
- 65535 : 'OFPVID_NONE'
-}
-
-ofp_group_mod_failed_code = ['OFPGMFC_GROUP_EXISTS', 'OFPGMFC_INVALID_GROUP', 'OFPGMFC_WEIGHT_UNSUPPORTED', 'OFPGMFC_OUT_OF_GROUPS', 'OFPGMFC_OUT_OF_BUCKETS', 'OFPGMFC_CHAINING_UNSUPPORTED', 'OFPGMFC_WATCH_UNSUPPORTED', 'OFPGMFC_LOOP', 'OFPGMFC_UNKNOWN_GROUP']
-OFPGMFC_GROUP_EXISTS = 0
-OFPGMFC_INVALID_GROUP = 1
-OFPGMFC_WEIGHT_UNSUPPORTED = 2
-OFPGMFC_OUT_OF_GROUPS = 3
-OFPGMFC_OUT_OF_BUCKETS = 4
-OFPGMFC_CHAINING_UNSUPPORTED = 5
-OFPGMFC_WATCH_UNSUPPORTED = 6
-OFPGMFC_LOOP = 7
-OFPGMFC_UNKNOWN_GROUP = 8
-ofp_group_mod_failed_code_map = {
- 0 : 'OFPGMFC_GROUP_EXISTS',
- 1 : 'OFPGMFC_INVALID_GROUP',
- 2 : 'OFPGMFC_WEIGHT_UNSUPPORTED',
- 3 : 'OFPGMFC_OUT_OF_GROUPS',
- 4 : 'OFPGMFC_OUT_OF_BUCKETS',
- 5 : 'OFPGMFC_CHAINING_UNSUPPORTED',
- 6 : 'OFPGMFC_WATCH_UNSUPPORTED',
- 7 : 'OFPGMFC_LOOP',
- 8 : 'OFPGMFC_UNKNOWN_GROUP'
-}
-
-ofp_group_type = ['OFPGT_ALL', 'OFPGT_SELECT', 'OFPGT_INDIRECT', 'OFPGT_FF']
-OFPGT_ALL = 0
-OFPGT_SELECT = 1
-OFPGT_INDIRECT = 2
-OFPGT_FF = 3
-ofp_group_type_map = {
- 0 : 'OFPGT_ALL',
- 1 : 'OFPGT_SELECT',
- 2 : 'OFPGT_INDIRECT',
- 3 : 'OFPGT_FF'
-}
-
-ofp_instruction_type = ['OFPIT_GOTO_TABLE', 'OFPIT_WRITE_METADATA', 'OFPIT_WRITE_ACTIONS', 'OFPIT_APPLY_ACTIONS', 'OFPIT_CLEAR_ACTIONS', 'OFPIT_EXPERIMENTER']
-OFPIT_GOTO_TABLE = 1
-OFPIT_WRITE_METADATA = 2
-OFPIT_WRITE_ACTIONS = 3
-OFPIT_APPLY_ACTIONS = 4
-OFPIT_CLEAR_ACTIONS = 5
-OFPIT_EXPERIMENTER = 65535
-ofp_instruction_type_map = {
- 1 : 'OFPIT_GOTO_TABLE',
- 2 : 'OFPIT_WRITE_METADATA',
- 3 : 'OFPIT_WRITE_ACTIONS',
- 4 : 'OFPIT_APPLY_ACTIONS',
- 5 : 'OFPIT_CLEAR_ACTIONS',
- 65535 : 'OFPIT_EXPERIMENTER'
-}
-
-ofp_bad_action_code = ['OFPBAC_BAD_TYPE', 'OFPBAC_BAD_LEN', 'OFPBAC_BAD_EXPERIMENTER', 'OFPBAC_BAD_EXPERIMENTER_TYPE', 'OFPBAC_BAD_OUT_PORT', 'OFPBAC_BAD_ARGUMENT', 'OFPBAC_EPERM', 'OFPBAC_TOO_MANY', 'OFPBAC_BAD_QUEUE', 'OFPBAC_BAD_OUT_GROUP', 'OFPBAC_MATCH_INCONSISTENT', 'OFPBAC_UNSUPPORTED_ORDER']
-OFPBAC_BAD_TYPE = 0
-OFPBAC_BAD_LEN = 1
-OFPBAC_BAD_EXPERIMENTER = 2
-OFPBAC_BAD_EXPERIMENTER_TYPE = 3
-OFPBAC_BAD_OUT_PORT = 4
-OFPBAC_BAD_ARGUMENT = 5
-OFPBAC_EPERM = 6
-OFPBAC_TOO_MANY = 7
-OFPBAC_BAD_QUEUE = 8
-OFPBAC_BAD_OUT_GROUP = 9
-OFPBAC_MATCH_INCONSISTENT = 10
-OFPBAC_UNSUPPORTED_ORDER = 11
-ofp_bad_action_code_map = {
- 0 : 'OFPBAC_BAD_TYPE',
- 1 : 'OFPBAC_BAD_LEN',
- 2 : 'OFPBAC_BAD_EXPERIMENTER',
- 3 : 'OFPBAC_BAD_EXPERIMENTER_TYPE',
- 4 : 'OFPBAC_BAD_OUT_PORT',
- 5 : 'OFPBAC_BAD_ARGUMENT',
- 6 : 'OFPBAC_EPERM',
- 7 : 'OFPBAC_TOO_MANY',
- 8 : 'OFPBAC_BAD_QUEUE',
- 9 : 'OFPBAC_BAD_OUT_GROUP',
- 10 : 'OFPBAC_MATCH_INCONSISTENT',
- 11 : 'OFPBAC_UNSUPPORTED_ORDER'
-}
-
-ofp_flow_mod_failed_code = ['OFPFMFC_UNKNOWN', 'OFPFMFC_TABLE_FULL', 'OFPFMFC_BAD_TABLE_ID', 'OFPFMFC_OVERLAP', 'OFPFMFC_EPERM', 'OFPFMFC_BAD_TIMEOUT', 'OFPFMFC_BAD_COMMAND', 'OFPFMFC_BAD_INSTRUCTION', 'OFPFMFC_BAD_MATCH', 'OFPFMFC_BAD_MATCH_TYPE', 'OFPFMFC_BAD_TAG', 'OFPFMFC_BAD_DL_ADDR_MASK', 'OFPFMFC_BAD_NW_ADDR_MASK']
-OFPFMFC_UNKNOWN = 0
-OFPFMFC_TABLE_FULL = 1
-OFPFMFC_BAD_TABLE_ID = 2
-OFPFMFC_OVERLAP = 3
-OFPFMFC_EPERM = 4
-OFPFMFC_BAD_TIMEOUT = 5
-OFPFMFC_BAD_COMMAND = 6
-OFPFMFC_BAD_INSTRUCTION = 7
-OFPFMFC_BAD_MATCH = 8
-OFPFMFC_BAD_MATCH_TYPE = 9
-OFPFMFC_BAD_TAG = 10
-OFPFMFC_BAD_DL_ADDR_MASK = 11
-OFPFMFC_BAD_NW_ADDR_MASK = 12
-ofp_flow_mod_failed_code_map = {
- 0 : 'OFPFMFC_UNKNOWN',
- 1 : 'OFPFMFC_TABLE_FULL',
- 2 : 'OFPFMFC_BAD_TABLE_ID',
- 3 : 'OFPFMFC_OVERLAP',
- 4 : 'OFPFMFC_EPERM',
- 5 : 'OFPFMFC_BAD_TIMEOUT',
- 6 : 'OFPFMFC_BAD_COMMAND',
- 7 : 'OFPFMFC_BAD_INSTRUCTION',
- 8 : 'OFPFMFC_BAD_MATCH',
- 9 : 'OFPFMFC_BAD_MATCH_TYPE',
- 10 : 'OFPFMFC_BAD_TAG',
- 11 : 'OFPFMFC_BAD_DL_ADDR_MASK',
- 12 : 'OFPFMFC_BAD_NW_ADDR_MASK'
-}
-
-ofp_port_mod_failed_code = ['OFPPMFC_BAD_PORT', 'OFPPMFC_BAD_HW_ADDR', 'OFPPMFC_BAD_CONFIG', 'OFPPMFC_BAD_ADVERTISE']
-OFPPMFC_BAD_PORT = 0
-OFPPMFC_BAD_HW_ADDR = 1
-OFPPMFC_BAD_CONFIG = 2
-OFPPMFC_BAD_ADVERTISE = 3
-ofp_port_mod_failed_code_map = {
- 0 : 'OFPPMFC_BAD_PORT',
- 1 : 'OFPPMFC_BAD_HW_ADDR',
- 2 : 'OFPPMFC_BAD_CONFIG',
- 3 : 'OFPPMFC_BAD_ADVERTISE'
-}
-
-ofp_type = ['OFPT_HELLO', 'OFPT_ERROR', 'OFPT_ECHO_REQUEST', 'OFPT_ECHO_REPLY', 'OFPT_EXPERIMENTER', 'OFPT_FEATURES_REQUEST', 'OFPT_FEATURES_REPLY', 'OFPT_GET_CONFIG_REQUEST', 'OFPT_GET_CONFIG_REPLY', 'OFPT_SET_CONFIG', 'OFPT_PACKET_IN', 'OFPT_FLOW_REMOVED', 'OFPT_PORT_STATUS', 'OFPT_PACKET_OUT', 'OFPT_FLOW_MOD', 'OFPT_GROUP_MOD', 'OFPT_PORT_MOD', 'OFPT_TABLE_MOD', 'OFPT_STATS_REQUEST', 'OFPT_STATS_REPLY', 'OFPT_BARRIER_REQUEST', 'OFPT_BARRIER_REPLY', 'OFPT_QUEUE_GET_CONFIG_REQUEST', 'OFPT_QUEUE_GET_CONFIG_REPLY']
-OFPT_HELLO = 0
-OFPT_ERROR = 1
-OFPT_ECHO_REQUEST = 2
-OFPT_ECHO_REPLY = 3
-OFPT_EXPERIMENTER = 4
-OFPT_FEATURES_REQUEST = 5
-OFPT_FEATURES_REPLY = 6
-OFPT_GET_CONFIG_REQUEST = 7
-OFPT_GET_CONFIG_REPLY = 8
-OFPT_SET_CONFIG = 9
-OFPT_PACKET_IN = 10
-OFPT_FLOW_REMOVED = 11
-OFPT_PORT_STATUS = 12
-OFPT_PACKET_OUT = 13
-OFPT_FLOW_MOD = 14
-OFPT_GROUP_MOD = 15
-OFPT_PORT_MOD = 16
-OFPT_TABLE_MOD = 17
-OFPT_STATS_REQUEST = 18
-OFPT_STATS_REPLY = 19
-OFPT_BARRIER_REQUEST = 20
-OFPT_BARRIER_REPLY = 21
-OFPT_QUEUE_GET_CONFIG_REQUEST = 22
-OFPT_QUEUE_GET_CONFIG_REPLY = 23
-ofp_type_map = {
- 0 : 'OFPT_HELLO',
- 1 : 'OFPT_ERROR',
- 2 : 'OFPT_ECHO_REQUEST',
- 3 : 'OFPT_ECHO_REPLY',
- 4 : 'OFPT_EXPERIMENTER',
- 5 : 'OFPT_FEATURES_REQUEST',
- 6 : 'OFPT_FEATURES_REPLY',
- 7 : 'OFPT_GET_CONFIG_REQUEST',
- 8 : 'OFPT_GET_CONFIG_REPLY',
- 9 : 'OFPT_SET_CONFIG',
- 10 : 'OFPT_PACKET_IN',
- 11 : 'OFPT_FLOW_REMOVED',
- 12 : 'OFPT_PORT_STATUS',
- 13 : 'OFPT_PACKET_OUT',
- 14 : 'OFPT_FLOW_MOD',
- 15 : 'OFPT_GROUP_MOD',
- 16 : 'OFPT_PORT_MOD',
- 17 : 'OFPT_TABLE_MOD',
- 18 : 'OFPT_STATS_REQUEST',
- 19 : 'OFPT_STATS_REPLY',
- 20 : 'OFPT_BARRIER_REQUEST',
- 21 : 'OFPT_BARRIER_REPLY',
- 22 : 'OFPT_QUEUE_GET_CONFIG_REQUEST',
- 23 : 'OFPT_QUEUE_GET_CONFIG_REPLY'
-}
-
-ofp_packet_in_reason = ['OFPR_NO_MATCH', 'OFPR_ACTION']
-OFPR_NO_MATCH = 0
-OFPR_ACTION = 1
-ofp_packet_in_reason_map = {
- 0 : 'OFPR_NO_MATCH',
- 1 : 'OFPR_ACTION'
-}
-
-ofp_stats_types = ['OFPST_DESC', 'OFPST_FLOW', 'OFPST_AGGREGATE', 'OFPST_TABLE', 'OFPST_PORT', 'OFPST_QUEUE', 'OFPST_GROUP', 'OFPST_GROUP_DESC', 'OFPST_EXPERIMENTER']
-OFPST_DESC = 0
-OFPST_FLOW = 1
-OFPST_AGGREGATE = 2
-OFPST_TABLE = 3
-OFPST_PORT = 4
-OFPST_QUEUE = 5
-OFPST_GROUP = 6
-OFPST_GROUP_DESC = 7
-OFPST_EXPERIMENTER = 65535
-ofp_stats_types_map = {
- 0 : 'OFPST_DESC',
- 1 : 'OFPST_FLOW',
- 2 : 'OFPST_AGGREGATE',
- 3 : 'OFPST_TABLE',
- 4 : 'OFPST_PORT',
- 5 : 'OFPST_QUEUE',
- 6 : 'OFPST_GROUP',
- 7 : 'OFPST_GROUP_DESC',
- 65535 : 'OFPST_EXPERIMENTER'
-}
-
-ofp_group_mod_command = ['OFPGC_ADD', 'OFPGC_MODIFY', 'OFPGC_DELETE']
-OFPGC_ADD = 0
-OFPGC_MODIFY = 1
-OFPGC_DELETE = 2
-ofp_group_mod_command_map = {
- 0 : 'OFPGC_ADD',
- 1 : 'OFPGC_MODIFY',
- 2 : 'OFPGC_DELETE'
-}
-
-ofp_port_features = ['OFPPF_10MB_HD', 'OFPPF_10MB_FD', 'OFPPF_100MB_HD', 'OFPPF_100MB_FD', 'OFPPF_1GB_HD', 'OFPPF_1GB_FD', 'OFPPF_10GB_FD', 'OFPPF_40GB_FD', 'OFPPF_100GB_FD', 'OFPPF_1TB_FD', 'OFPPF_LUDICROUS', 'OFPPF_COPPER', 'OFPPF_FIBER', 'OFPPF_AUTONEG', 'OFPPF_PAUSE', 'OFPPF_PAUSE_ASYM']
-OFPPF_10MB_HD = 1
-OFPPF_10MB_FD = 2
-OFPPF_100MB_HD = 4
-OFPPF_100MB_FD = 8
-OFPPF_1GB_HD = 16
-OFPPF_1GB_FD = 32
-OFPPF_10GB_FD = 64
-OFPPF_40GB_FD = 128
-OFPPF_100GB_FD = 256
-OFPPF_1TB_FD = 512
-OFPPF_LUDICROUS = 1024
-OFPPF_COPPER = 2048
-OFPPF_FIBER = 4096
-OFPPF_AUTONEG = 8192
-OFPPF_PAUSE = 16384
-OFPPF_PAUSE_ASYM = 32768
-ofp_port_features_map = {
- 1 : 'OFPPF_10MB_HD',
- 2 : 'OFPPF_10MB_FD',
- 4 : 'OFPPF_100MB_HD',
- 8 : 'OFPPF_100MB_FD',
- 16 : 'OFPPF_1GB_HD',
- 32 : 'OFPPF_1GB_FD',
- 64 : 'OFPPF_10GB_FD',
- 128 : 'OFPPF_40GB_FD',
- 256 : 'OFPPF_100GB_FD',
- 512 : 'OFPPF_1TB_FD',
- 1024 : 'OFPPF_LUDICROUS',
- 2048 : 'OFPPF_COPPER',
- 4096 : 'OFPPF_FIBER',
- 8192 : 'OFPPF_AUTONEG',
- 16384 : 'OFPPF_PAUSE',
- 32768 : 'OFPPF_PAUSE_ASYM'
-}
-
-ofp_mpls_label = ['OFPML_ANY', 'OFPML_NONE']
-OFPML_ANY = 16777214
-OFPML_NONE = 16777215
-ofp_mpls_label_map = {
- 16777214 : 'OFPML_ANY',
- 16777215 : 'OFPML_NONE'
-}
-
-# Values from macro definitions
-OFP_FLOW_PERMANENT = 0
-OFP_DL_TYPE_ETH2_CUTOFF = 0x0600
-DESC_STR_LEN = 256
-OFPFW_ICMP_CODE = OFPFW_TP_DST
-OFPQ_MIN_RATE_UNCFG = 0xffff
-OFP_VERSION = 0x02
-OFP_MAX_TABLE_NAME_LEN = 32
-OFP_DL_TYPE_NOT_ETH_TYPE = 0x05ff
-OFP_DEFAULT_MISS_SEND_LEN = 128
-OFP_MAX_PORT_NAME_LEN = 16
-OFP_SSL_PORT = 6633
-OFPMT_STANDARD_LENGTH = 88
-OFPFW_ICMP_TYPE = OFPFW_TP_SRC
-OFP_TCP_PORT = 6633
-SERIAL_NUM_LEN = 32
-OFP_DEFAULT_PRIORITY = 0x8000
-OFP_ETH_ALEN = 6
-OFP_VLAN_NONE = OFPVID_NONE
-OFPQ_ALL = 0xffffffff
-
-# Basic structure size definitions.
-# Does not include ofp_header members.
-# Does not include variable length arrays.
-OFP_ACTION_DL_ADDR_BYTES = 16
-OFP_ACTION_EXPERIMENTER_HEADER_BYTES = 8
-OFP_ACTION_GROUP_BYTES = 8
-OFP_ACTION_HEADER_BYTES = 8
-OFP_ACTION_MPLS_LABEL_BYTES = 8
-OFP_ACTION_MPLS_TC_BYTES = 8
-OFP_ACTION_MPLS_TTL_BYTES = 8
-OFP_ACTION_NW_ADDR_BYTES = 8
-OFP_ACTION_NW_ECN_BYTES = 8
-OFP_ACTION_NW_TOS_BYTES = 8
-OFP_ACTION_NW_TTL_BYTES = 8
-OFP_ACTION_OUTPUT_BYTES = 16
-OFP_ACTION_POP_MPLS_BYTES = 8
-OFP_ACTION_PUSH_BYTES = 8
-OFP_ACTION_SET_QUEUE_BYTES = 8
-OFP_ACTION_TP_PORT_BYTES = 8
-OFP_ACTION_VLAN_PCP_BYTES = 8
-OFP_ACTION_VLAN_VID_BYTES = 8
-OFP_AGGREGATE_STATS_REPLY_BYTES = 24
-OFP_AGGREGATE_STATS_REQUEST_BYTES = 120
-OFP_BUCKET_BYTES = 16
-OFP_BUCKET_COUNTER_BYTES = 16
-OFP_DESC_STATS_BYTES = 1056
-OFP_ERROR_MSG_BYTES = 4
-OFP_EXPERIMENTER_HEADER_BYTES = 4
-OFP_FLOW_MOD_BYTES = 128
-OFP_FLOW_REMOVED_BYTES = 128
-OFP_FLOW_STATS_BYTES = 136
-OFP_FLOW_STATS_REQUEST_BYTES = 120
-OFP_GROUP_DESC_STATS_BYTES = 8
-OFP_GROUP_MOD_BYTES = 8
-OFP_GROUP_STATS_BYTES = 32
-OFP_GROUP_STATS_REQUEST_BYTES = 8
-OFP_HEADER_BYTES = 8
-OFP_HELLO_BYTES = 0
-OFP_INSTRUCTION_BYTES = 8
-OFP_INSTRUCTION_ACTIONS_BYTES = 8
-OFP_INSTRUCTION_EXPERIMENTER_BYTES = 8
-OFP_INSTRUCTION_GOTO_TABLE_BYTES = 8
-OFP_INSTRUCTION_WRITE_METADATA_BYTES = 24
-OFP_MATCH_BYTES = 88
-OFP_PACKET_IN_BYTES = 16
-OFP_PACKET_OUT_BYTES = 12
-OFP_PACKET_QUEUE_BYTES = 8
-OFP_PORT_BYTES = 64
-OFP_PORT_MOD_BYTES = 32
-OFP_PORT_STATS_BYTES = 104
-OFP_PORT_STATS_REQUEST_BYTES = 8
-OFP_PORT_STATUS_BYTES = 72
-OFP_QUEUE_GET_CONFIG_REPLY_BYTES = 8
-OFP_QUEUE_GET_CONFIG_REQUEST_BYTES = 4
-OFP_QUEUE_PROP_HEADER_BYTES = 8
-OFP_QUEUE_PROP_MIN_RATE_BYTES = 16
-OFP_QUEUE_STATS_BYTES = 32
-OFP_QUEUE_STATS_REQUEST_BYTES = 8
-OFP_STATS_REPLY_BYTES = 4
-OFP_STATS_REQUEST_BYTES = 4
-OFP_SWITCH_CONFIG_BYTES = 4
-OFP_SWITCH_FEATURES_BYTES = 24
-OFP_TABLE_MOD_BYTES = 8
-OFP_TABLE_STATS_BYTES = 88
-
diff --git a/src/python/of11/error.py b/src/python/of11/error.py
deleted file mode 100644
index 3ea74f4..0000000
--- a/src/python/of11/error.py
+++ /dev/null
@@ -1,456 +0,0 @@
-
-# Python OpenFlow error wrapper classes
-
-from cstruct import *
-
-
-
-class hello_failed_error_msg(ofp_error_msg):
- """
- Wrapper class for hello_failed error message class
-
- Data members inherited from ofp_error_msg:
- @arg type
- @arg code
- @arg data: Binary string following message members
-
- """
- def __init__(self):
- ofp_error_msg.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_ERROR
- self.type = OFPET_HELLO_FAILED
- self.data = ""
-
- def pack(self, assertstruct=True):
- self.header.length = self.__len__()
- packed = self.header.pack()
- packed += ofp_error_msg.pack(self)
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_error_msg.unpack(self, binary_string)
- self.data = binary_string
- return ""
-
- def __len__(self):
- return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
-
- def show(self, prefix=''):
- outstr = prefix + "hello_failed_error_msg\m"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_error_msg.show(self, prefix + ' ')
- outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
- ##@todo Consider trying to parse the string
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_error_msg.__eq__(self, other) and
- self.data == other.data)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class bad_request_error_msg(ofp_error_msg):
- """
- Wrapper class for bad_request error message class
-
- Data members inherited from ofp_error_msg:
- @arg type
- @arg code
- @arg data: Binary string following message members
-
- """
- def __init__(self):
- ofp_error_msg.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_ERROR
- self.type = OFPET_BAD_REQUEST
- self.data = ""
-
- def pack(self, assertstruct=True):
- self.header.length = self.__len__()
- packed = self.header.pack()
- packed += ofp_error_msg.pack(self)
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_error_msg.unpack(self, binary_string)
- self.data = binary_string
- return ""
-
- def __len__(self):
- return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
-
- def show(self, prefix=''):
- outstr = prefix + "bad_request_error_msg\m"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_error_msg.show(self, prefix + ' ')
- outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
- ##@todo Consider trying to parse the string
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_error_msg.__eq__(self, other) and
- self.data == other.data)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class bad_action_error_msg(ofp_error_msg):
- """
- Wrapper class for bad_action error message class
-
- Data members inherited from ofp_error_msg:
- @arg type
- @arg code
- @arg data: Binary string following message members
-
- """
- def __init__(self):
- ofp_error_msg.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_ERROR
- self.type = OFPET_BAD_ACTION
- self.data = ""
-
- def pack(self, assertstruct=True):
- self.header.length = self.__len__()
- packed = self.header.pack()
- packed += ofp_error_msg.pack(self)
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_error_msg.unpack(self, binary_string)
- self.data = binary_string
- return ""
-
- def __len__(self):
- return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
-
- def show(self, prefix=''):
- outstr = prefix + "bad_action_error_msg\m"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_error_msg.show(self, prefix + ' ')
- outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
- ##@todo Consider trying to parse the string
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_error_msg.__eq__(self, other) and
- self.data == other.data)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class flow_mod_failed_error_msg(ofp_error_msg):
- """
- Wrapper class for flow_mod_failed error message class
-
- Data members inherited from ofp_error_msg:
- @arg type
- @arg code
- @arg data: Binary string following message members
-
- """
- def __init__(self):
- ofp_error_msg.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_ERROR
- self.type = OFPET_FLOW_MOD_FAILED
- self.data = ""
-
- def pack(self, assertstruct=True):
- self.header.length = self.__len__()
- packed = self.header.pack()
- packed += ofp_error_msg.pack(self)
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_error_msg.unpack(self, binary_string)
- self.data = binary_string
- return ""
-
- def __len__(self):
- return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
-
- def show(self, prefix=''):
- outstr = prefix + "flow_mod_failed_error_msg\m"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_error_msg.show(self, prefix + ' ')
- outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
- ##@todo Consider trying to parse the string
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_error_msg.__eq__(self, other) and
- self.data == other.data)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class group_mod_failed_error_msg(ofp_error_msg):
- """
- Wrapper class for group_mod_failed error message class
-
- Data members inherited from ofp_error_msg:
- @arg type
- @arg code
- @arg data: Binary string following message members
-
- """
- def __init__(self):
- ofp_error_msg.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_ERROR
- self.type = OFPET_GROUP_MOD_FAILED
- self.data = ""
-
- def pack(self, assertstruct=True):
- self.header.length = self.__len__()
- packed = self.header.pack()
- packed += ofp_error_msg.pack(self)
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_error_msg.unpack(self, binary_string)
- self.data = binary_string
- return ""
-
- def __len__(self):
- return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
-
- def show(self, prefix=''):
- outstr = prefix + "group_mod_failed_error_msg\m"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_error_msg.show(self, prefix + ' ')
- outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
- ##@todo Consider trying to parse the string
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_error_msg.__eq__(self, other) and
- self.data == other.data)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class port_mod_failed_error_msg(ofp_error_msg):
- """
- Wrapper class for port_mod_failed error message class
-
- Data members inherited from ofp_error_msg:
- @arg type
- @arg code
- @arg data: Binary string following message members
-
- """
- def __init__(self):
- ofp_error_msg.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_ERROR
- self.type = OFPET_PORT_MOD_FAILED
- self.data = ""
-
- def pack(self, assertstruct=True):
- self.header.length = self.__len__()
- packed = self.header.pack()
- packed += ofp_error_msg.pack(self)
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_error_msg.unpack(self, binary_string)
- self.data = binary_string
- return ""
-
- def __len__(self):
- return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
-
- def show(self, prefix=''):
- outstr = prefix + "port_mod_failed_error_msg\m"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_error_msg.show(self, prefix + ' ')
- outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
- ##@todo Consider trying to parse the string
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_error_msg.__eq__(self, other) and
- self.data == other.data)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class table_mod_failed_error_msg(ofp_error_msg):
- """
- Wrapper class for table_mod_failed error message class
-
- Data members inherited from ofp_error_msg:
- @arg type
- @arg code
- @arg data: Binary string following message members
-
- """
- def __init__(self):
- ofp_error_msg.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_ERROR
- self.type = OFPET_TABLE_MOD_FAILED
- self.data = ""
-
- def pack(self, assertstruct=True):
- self.header.length = self.__len__()
- packed = self.header.pack()
- packed += ofp_error_msg.pack(self)
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_error_msg.unpack(self, binary_string)
- self.data = binary_string
- return ""
-
- def __len__(self):
- return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
-
- def show(self, prefix=''):
- outstr = prefix + "table_mod_failed_error_msg\m"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_error_msg.show(self, prefix + ' ')
- outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
- ##@todo Consider trying to parse the string
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_error_msg.__eq__(self, other) and
- self.data == other.data)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class queue_op_failed_error_msg(ofp_error_msg):
- """
- Wrapper class for queue_op_failed error message class
-
- Data members inherited from ofp_error_msg:
- @arg type
- @arg code
- @arg data: Binary string following message members
-
- """
- def __init__(self):
- ofp_error_msg.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_ERROR
- self.type = OFPET_QUEUE_OP_FAILED
- self.data = ""
-
- def pack(self, assertstruct=True):
- self.header.length = self.__len__()
- packed = self.header.pack()
- packed += ofp_error_msg.pack(self)
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_error_msg.unpack(self, binary_string)
- self.data = binary_string
- return ""
-
- def __len__(self):
- return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
-
- def show(self, prefix=''):
- outstr = prefix + "queue_op_failed_error_msg\m"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_error_msg.show(self, prefix + ' ')
- outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
- ##@todo Consider trying to parse the string
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_error_msg.__eq__(self, other) and
- self.data == other.data)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class switch_config_failed_error_msg(ofp_error_msg):
- """
- Wrapper class for switch_config_failed error message class
-
- Data members inherited from ofp_error_msg:
- @arg type
- @arg code
- @arg data: Binary string following message members
-
- """
- def __init__(self):
- ofp_error_msg.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_ERROR
- self.type = OFPET_SWITCH_CONFIG_FAILED
- self.data = ""
-
- def pack(self, assertstruct=True):
- self.header.length = self.__len__()
- packed = self.header.pack()
- packed += ofp_error_msg.pack(self)
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_error_msg.unpack(self, binary_string)
- self.data = binary_string
- return ""
-
- def __len__(self):
- return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
-
- def show(self, prefix=''):
- outstr = prefix + "switch_config_failed_error_msg\m"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_error_msg.show(self, prefix + ' ')
- outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
- ##@todo Consider trying to parse the string
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_error_msg.__eq__(self, other) and
- self.data == other.data)
-
- def __ne__(self, other): return not self.__eq__(other)
-
diff --git a/src/python/of11/instruction.py b/src/python/of11/instruction.py
deleted file mode 100644
index ce323c2..0000000
--- a/src/python/of11/instruction.py
+++ /dev/null
@@ -1,164 +0,0 @@
-
-# Python OpenFlow instruction wrapper classes
-
-from cstruct import *
-from action_list import action_list
-
-
-
-class instruction_goto_table(ofp_instruction_goto_table):
- """
- Wrapper class for goto_table instruction object
-
- Data members inherited from ofp_instruction_goto_table:
- @arg type
- @arg len
- @arg table_id
-
- """
- def __init__(self):
- ofp_instruction_goto_table.__init__(self)
- self.type = OFPIT_GOTO_TABLE
- self.len = self.__len__()
- def show(self, prefix=''):
- outstr = prefix + "instruction_goto_table\n"
- outstr += ofp_instruction_goto_table.show(self, prefix)
- return outstr
-
-
-class instruction_write_actions(ofp_instruction_actions):
- """
- Wrapper class for write_actions instruction object
-
- Data members inherited from ofp_instruction_actions:
- @arg type
- @arg len
-
- """
- def __init__(self):
- ofp_instruction_actions.__init__(self)
- self.type = OFPIT_WRITE_ACTIONS
- self.actions = action_list()
- self.len = self.__len__()
- def show(self, prefix=''):
- outstr = prefix + "instruction_write_actions\n"
- outstr += ofp_instruction_actions.show(self, prefix)
- outstr += self.actions.show(prefix)
- return outstr
- def unpack(self, binary_string):
- binary_string = ofp_instruction_actions.unpack(self, binary_string)
- bytes = self.len - OFP_INSTRUCTION_ACTIONS_BYTES
- self.actions = action_list()
- binary_string = self.actions.unpack(binary_string, bytes=bytes)
- return binary_string
- def pack(self):
- self.len = self.__len__()
- packed = ""
- packed += ofp_instruction_actions.pack(self)
- packed += self.actions.pack()
- return packed
- def __len__(self):
- return ofp_instruction_actions.__len__(self) + self.actions.__len__()
-
-
-class instruction_apply_actions(ofp_instruction_actions):
- """
- Wrapper class for apply_actions instruction object
-
- Data members inherited from ofp_instruction_actions:
- @arg type
- @arg len
-
- """
- def __init__(self):
- ofp_instruction_actions.__init__(self)
- self.type = OFPIT_APPLY_ACTIONS
- self.actions = action_list()
- self.len = self.__len__()
- def show(self, prefix=''):
- outstr = prefix + "instruction_apply_actions\n"
- outstr += ofp_instruction_actions.show(self, prefix)
- outstr += self.actions.show(prefix)
- return outstr
- def unpack(self, binary_string):
- binary_string = ofp_instruction_actions.unpack(self, binary_string)
- bytes = self.len - OFP_INSTRUCTION_ACTIONS_BYTES
- self.actions = action_list()
- binary_string = self.actions.unpack(binary_string, bytes=bytes)
- return binary_string
- def pack(self):
- self.len = self.__len__()
- packed = ""
- packed += ofp_instruction_actions.pack(self)
- packed += self.actions.pack()
- return packed
- def __len__(self):
- return ofp_instruction_actions.__len__(self) + self.actions.__len__()
-
-
-class instruction_experimenter(ofp_instruction_experimenter):
- """
- Wrapper class for experimenter instruction object
-
- Data members inherited from ofp_instruction_experimenter:
- @arg type
- @arg len
- @arg experimenter
-
- """
- def __init__(self):
- ofp_instruction_experimenter.__init__(self)
- self.type = OFPIT_EXPERIMENTER
- self.len = self.__len__()
- def show(self, prefix=''):
- outstr = prefix + "instruction_experimenter\n"
- outstr += ofp_instruction_experimenter.show(self, prefix)
- return outstr
-
-
-class instruction_write_metadata(ofp_instruction_write_metadata):
- """
- Wrapper class for write_metadata instruction object
-
- Data members inherited from ofp_instruction_write_metadata:
- @arg type
- @arg len
- @arg metadata
- @arg metadata_mask
-
- """
- def __init__(self):
- ofp_instruction_write_metadata.__init__(self)
- self.type = OFPIT_WRITE_METADATA
- self.len = self.__len__()
- def show(self, prefix=''):
- outstr = prefix + "instruction_write_metadata\n"
- outstr += ofp_instruction_write_metadata.show(self, prefix)
- return outstr
-
-
-class instruction_clear_actions(ofp_instruction):
- """
- Wrapper class for clear_actions instruction object
-
- Data members inherited from ofp_instruction:
- @arg type
- @arg len
-
- """
- def __init__(self):
- ofp_instruction.__init__(self)
- self.type = OFPIT_CLEAR_ACTIONS
- self.len = self.__len__()
- def show(self, prefix=''):
- outstr = prefix + "instruction_clear_actions\n"
- outstr += ofp_instruction.show(self, prefix)
- return outstr
-
-instruction_class_list = (
- instruction_apply_actions,
- instruction_clear_actions,
- instruction_experimenter,
- instruction_goto_table,
- instruction_write_actions,
- instruction_write_metadata)
diff --git a/src/python/of11/instruction_list.py b/src/python/of11/instruction_list.py
deleted file mode 100644
index bce8cc7..0000000
--- a/src/python/of11/instruction_list.py
+++ /dev/null
@@ -1,97 +0,0 @@
-"""
-OpenFlow instruction list class
-"""
-
-import action
-import instruction
-from action_list import action_list
-from base_list import ofp_base_list
-from cstruct import ofp_header
-import unittest
-
-# Instruction list
-
-instruction_object_map = {
- action.OFPIT_GOTO_TABLE : instruction.instruction_goto_table,
- action.OFPIT_WRITE_METADATA : instruction.instruction_write_metadata,
- action.OFPIT_WRITE_ACTIONS : instruction.instruction_write_actions,
- action.OFPIT_APPLY_ACTIONS : instruction.instruction_apply_actions,
- action.OFPIT_CLEAR_ACTIONS : instruction.instruction_clear_actions,
- action.OFPIT_EXPERIMENTER : instruction.instruction_experimenter
-}
-
-class instruction_list(ofp_base_list):
- """
- Maintain a list of instructions
-
- Data members:
- @arg instructions An array of instructions such as write_actions
-
- Methods:
- @arg pack: Pack the structure into a string
- @arg unpack: Unpack a string to objects, with proper typing
- @arg add: Add an action to the list; you can directly access
- the action member, but add will validate that the added object
- is an action.
-
- """
-
- def __init__(self):
- ofp_base_list.__init__(self)
- self.instructions = self.items
- self.name = "instruction"
- self.class_list = instruction.instruction_class_list
-
- def unpack(self, binary_string, bytes=None):
- """
- Unpack a list of instructions
-
- Unpack instructions from a binary string, creating an array
- of objects of the appropriate type
-
- @param binary_string The string to be unpacked
-
- @param bytes The total length of the instruction list in bytes.
- Ignored if decode is True. If bytes is None and decode is false, the
- list is assumed to extend through the entire string.
-
- @return The remainder of binary_string that was not parsed
-
- """
- if bytes == None:
- bytes = len(binary_string)
- bytes_done = 0
- count = 0
- cur_string = binary_string
- while bytes_done < bytes:
- hdr = instruction.ofp_instruction()
- hdr.unpack(cur_string)
- if hdr.len < action.OFP_ACTION_HEADER_BYTES:
- print "ERROR: Action too short"
- break
- if not hdr.type in instruction_object_map.keys():
- print "WARNING: Skipping unknown action ", hdr.type, hdr.len
- else:
- self.instructions.append(instruction_object_map[hdr.type]())
- self.instructions[count].unpack(cur_string)
- count += 1
- cur_string = cur_string[hdr.len:]
- bytes_done += hdr.len
- return cur_string
-
-class Instruction_List_Test(unittest.TestCase):
- def runTest(self):
- # instructions header is 8 bytes
- l = instruction_list()
- act = action.action_output()
- act.port = 7
- inst = instruction.instruction_apply_actions()
- self.assertTrue(inst.actions.add(act))
- self.assertTrue(l.add(inst))
- pkt = l.pack()
- # 24 == 8 (list header) + (apply header) 8 + (output action) 8
- self.assertEqual(len(pkt),24)
-
- l = instruction_list()
- self.assertTrue(l.add(instruction.instruction_goto_table()))
-
diff --git a/src/python/of11/message.py b/src/python/of11/message.py
deleted file mode 100644
index a26da63..0000000
--- a/src/python/of11/message.py
+++ /dev/null
@@ -1,3692 +0,0 @@
-
-# Python OpenFlow message wrapper classes
-
-from cstruct import *
-from action_list import action_list
-from instruction_list import instruction_list
-from bucket_list import bucket_list
-from error import *
-
-# Define templates for documentation
-class ofp_template_msg(object):
- """
- Sample base class for template_msg; normally auto generated
- This class should live in the of_header name space and provides the
- base class for this type of message. It will be wrapped for the
- high level API.
-
- """
- def __init__(self):
- """
- Constructor for base class
-
- """
- self.header = ofp_header()
- # Additional base data members declared here
-
- # Normally will define pack, unpack, __len__ functions
-
-class template_msg(ofp_template_msg):
- """
- Sample class wrapper for template_msg
- This class should live in the of_message name space and provides the
- high level API for an OpenFlow message object. These objects must
- implement the functions indicated in this template.
-
- """
- def __init__(self):
- """
- Constructor
- Must set the header type value appropriately for the message
-
- """
-
- ##@var header
- # OpenFlow message header: length, version, xid, type
- ofp_template_msg.__init__(self)
- self.header = ofp_header()
- # For a real message, will be set to an integer
- self.header.type = "TEMPLATE_MSG_VALUE"
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- pass
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
-
- @return Typically returns the remainder of binary_string that
- was not parsed. May give a warning if that string is non-empty
-
- """
- pass
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- pass
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
- pass
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- pass
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- pass
-
-
-################################################################
-#
-# OpenFlow Message Definitions
-#
-################################################################
-
-class barrier_reply(object):
- """
- Wrapper class for barrier_reply
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (2)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_BARRIER_REPLY=21)
-
-
- """
-
- def __init__(self):
- self.header = ofp_header()
- self.header.type = OFPT_BARRIER_REPLY
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'barrier_reply (OFPT_BARRIER_REPLY)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class barrier_request(object):
- """
- Wrapper class for barrier_request
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (2)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_BARRIER_REQUEST=20)
-
-
- """
-
- def __init__(self):
- self.header = ofp_header()
- self.header.type = OFPT_BARRIER_REQUEST
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'barrier_request (OFPT_BARRIER_REQUEST)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class echo_reply(object):
- """
- Wrapper class for echo_reply
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (2)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_ECHO_REPLY=3)
-
- @arg data: Binary string following message members
-
- """
-
- def __init__(self):
- self.header = ofp_header()
- self.header.type = OFPT_ECHO_REPLY
- self.data = ""
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- self.data = binary_string
- binary_string = ''
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += len(self.data)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'echo_reply (OFPT_ECHO_REPLY)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += prefix + 'data is of length ' + str(len(self.data)) + '\n'
- ##@todo Fix this circular reference
- # if len(self.data) > 0:
- # obj = of_message_parse(self.data)
- # if obj != None:
- # outstr += obj.show(prefix)
- # else:
- # outstr += prefix + "Unable to parse data\n"
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if self.data != other.data: return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class echo_request(object):
- """
- Wrapper class for echo_request
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (2)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_ECHO_REQUEST=2)
-
- @arg data: Binary string following message members
-
- """
-
- def __init__(self):
- self.header = ofp_header()
- self.header.type = OFPT_ECHO_REQUEST
- self.data = ""
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- self.data = binary_string
- binary_string = ''
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += len(self.data)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'echo_request (OFPT_ECHO_REQUEST)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += prefix + 'data is of length ' + str(len(self.data)) + '\n'
- ##@todo Fix this circular reference
- # if len(self.data) > 0:
- # obj = of_message_parse(self.data)
- # if obj != None:
- # outstr += obj.show(prefix)
- # else:
- # outstr += prefix + "Unable to parse data\n"
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if self.data != other.data: return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class error(ofp_error_msg):
- """
- Wrapper class for error
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (2)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_ERROR=1)
-
- Data members inherited from ofp_error_msg:
- @arg type
- @arg code
- @arg data: Binary string following message members
-
- """
-
- def __init__(self):
- ofp_error_msg.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_ERROR
- self.data = ""
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_error_msg.pack(self)
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_error_msg.unpack(self, binary_string)
- self.data = binary_string
- binary_string = ''
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_error_msg.__len__(self)
- length += len(self.data)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'error (OFPT_ERROR)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_error_msg.show(self, prefix)
- outstr += prefix + 'data is of length ' + str(len(self.data)) + '\n'
- ##@todo Fix this circular reference
- # if len(self.data) > 0:
- # obj = of_message_parse(self.data)
- # if obj != None:
- # outstr += obj.show(prefix)
- # else:
- # outstr += prefix + "Unable to parse data\n"
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_error_msg.__eq__(self, other): return False
- if self.data != other.data: return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class experimenter(ofp_experimenter_header):
- """
- Wrapper class for experimenter
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (2)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_EXPERIMENTER=4)
-
- Data members inherited from ofp_experimenter_header:
- @arg experimenter
- @arg data: Binary string following message members
-
- """
-
- def __init__(self):
- ofp_experimenter_header.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_EXPERIMENTER
- self.data = ""
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_experimenter_header.pack(self)
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_experimenter_header.unpack(self, binary_string)
- self.data = binary_string
- binary_string = ''
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_experimenter_header.__len__(self)
- length += len(self.data)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'experimenter (OFPT_EXPERIMENTER)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_experimenter_header.show(self, prefix)
- outstr += prefix + 'data is of length ' + str(len(self.data)) + '\n'
- ##@todo Fix this circular reference
- # if len(self.data) > 0:
- # obj = of_message_parse(self.data)
- # if obj != None:
- # outstr += obj.show(prefix)
- # else:
- # outstr += prefix + "Unable to parse data\n"
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_experimenter_header.__eq__(self, other): return False
- if self.data != other.data: return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class features_reply(ofp_switch_features):
- """
- Wrapper class for features_reply
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (2)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_FEATURES_REPLY=6)
-
- Data members inherited from ofp_switch_features:
- @arg datapath_id
- @arg n_buffers
- @arg n_tables
- @arg capabilities
- @arg reserved
- @arg ports: Variable length array of TBD
-
- """
-
- def __init__(self):
- ofp_switch_features.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_FEATURES_REPLY
- self.ports = []
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_switch_features.pack(self)
- for obj in self.ports:
- packed += obj.pack()
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_switch_features.unpack(self, binary_string)
- while len(binary_string) >= OFP_PORT_BYTES:
- new_port = ofp_port()
- binary_string = new_port.unpack(binary_string)
- self.ports.append(new_port)
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_switch_features.__len__(self)
- for obj in self.ports:
- length += len(obj)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'features_reply (OFPT_FEATURES_REPLY)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_switch_features.show(self, prefix)
- outstr += prefix + "Array ports\n"
- for obj in self.ports:
- outstr += obj.show(prefix + ' ')
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_switch_features.__eq__(self, other): return False
- if self.ports != other.ports: return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class features_request(object):
- """
- Wrapper class for features_request
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (2)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_FEATURES_REQUEST=5)
-
-
- """
-
- def __init__(self):
- self.header = ofp_header()
- self.header.type = OFPT_FEATURES_REQUEST
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'features_request (OFPT_FEATURES_REQUEST)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class flow_mod(ofp_flow_mod):
- """
- Wrapper class for flow_mod
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (2)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_FLOW_MOD=14)
-
- Data members inherited from ofp_flow_mod:
- @arg cookie
- @arg cookie_mask
- @arg table_id
- @arg command
- @arg idle_timeout
- @arg hard_timeout
- @arg priority
- @arg buffer_id
- @arg out_port
- @arg out_group
- @arg flags
- @arg match
- @arg instructions: Object of type instruction_list
-
- """
-
- def __init__(self):
- ofp_flow_mod.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_FLOW_MOD
- self.instructions = instruction_list()
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_flow_mod.pack(self)
- packed += self.instructions.pack()
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_flow_mod.unpack(self, binary_string)
- ai_len = self.header.length - (OFP_FLOW_MOD_BYTES + OFP_HEADER_BYTES)
- binary_string = self.instructions.unpack(binary_string, bytes=ai_len)
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_flow_mod.__len__(self)
- length += len(self.instructions)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'flow_mod (OFPT_FLOW_MOD)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_flow_mod.show(self, prefix)
- outstr += prefix + "List instructions\n"
- outstr += self.instructions.show(prefix + ' ')
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_flow_mod.__eq__(self, other): return False
- if self.instructions != other.instructions: return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class flow_removed(ofp_flow_removed):
- """
- Wrapper class for flow_removed
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (2)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_FLOW_REMOVED=11)
-
- Data members inherited from ofp_flow_removed:
- @arg cookie
- @arg priority
- @arg reason
- @arg table_id
- @arg duration_sec
- @arg duration_nsec
- @arg idle_timeout
- @arg packet_count
- @arg byte_count
- @arg match
-
- """
-
- def __init__(self):
- ofp_flow_removed.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_FLOW_REMOVED
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_flow_removed.pack(self)
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_flow_removed.unpack(self, binary_string)
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_flow_removed.__len__(self)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'flow_removed (OFPT_FLOW_REMOVED)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_flow_removed.show(self, prefix)
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_flow_removed.__eq__(self, other): return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class get_config_reply(ofp_switch_config):
- """
- Wrapper class for get_config_reply
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (2)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_GET_CONFIG_REPLY=8)
-
- Data members inherited from ofp_switch_config:
- @arg flags
- @arg miss_send_len
-
- """
-
- def __init__(self):
- ofp_switch_config.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_GET_CONFIG_REPLY
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_switch_config.pack(self)
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_switch_config.unpack(self, binary_string)
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_switch_config.__len__(self)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'get_config_reply (OFPT_GET_CONFIG_REPLY)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_switch_config.show(self, prefix)
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_switch_config.__eq__(self, other): return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class get_config_request(object):
- """
- Wrapper class for get_config_request
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (2)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_GET_CONFIG_REQUEST=7)
-
-
- """
-
- def __init__(self):
- self.header = ofp_header()
- self.header.type = OFPT_GET_CONFIG_REQUEST
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'get_config_request (OFPT_GET_CONFIG_REQUEST)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class group_mod(ofp_group_mod):
- """
- Wrapper class for group_mod
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (2)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_GROUP_MOD=15)
-
- Data members inherited from ofp_group_mod:
- @arg command
- @arg type
- @arg group_id
- @arg buckets: Object of type bucket_list
-
- """
-
- def __init__(self):
- ofp_group_mod.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_GROUP_MOD
- self.buckets = bucket_list()
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_group_mod.pack(self)
- packed += self.buckets.pack()
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_group_mod.unpack(self, binary_string)
- binary_string = self.buckets.unpack(binary_string)
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_group_mod.__len__(self)
- length += len(self.buckets)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'group_mod (OFPT_GROUP_MOD)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_group_mod.show(self, prefix)
- outstr += prefix + "List buckets\n"
- outstr += self.buckets.show(prefix + ' ')
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_group_mod.__eq__(self, other): return False
- if self.buckets != other.buckets: return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class hello(object):
- """
- Wrapper class for hello
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (2)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_HELLO=0)
-
- @arg data: Binary string following message members
-
- """
-
- def __init__(self):
- self.header = ofp_header()
- self.header.type = OFPT_HELLO
- self.data = ""
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- self.data = binary_string
- binary_string = ''
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += len(self.data)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'hello (OFPT_HELLO)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += prefix + 'data is of length ' + str(len(self.data)) + '\n'
- ##@todo Fix this circular reference
- # if len(self.data) > 0:
- # obj = of_message_parse(self.data)
- # if obj != None:
- # outstr += obj.show(prefix)
- # else:
- # outstr += prefix + "Unable to parse data\n"
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if self.data != other.data: return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class packet_in(ofp_packet_in):
- """
- Wrapper class for packet_in
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (2)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_PACKET_IN=10)
-
- Data members inherited from ofp_packet_in:
- @arg buffer_id
- @arg in_port
- @arg in_phy_port
- @arg total_len
- @arg reason
- @arg table_id
- @arg data: Binary string following message members
-
- """
-
- def __init__(self):
- ofp_packet_in.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_PACKET_IN
- self.data = ""
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_packet_in.pack(self)
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_packet_in.unpack(self, binary_string)
- self.data = binary_string
- binary_string = ''
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_packet_in.__len__(self)
- length += len(self.data)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'packet_in (OFPT_PACKET_IN)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_packet_in.show(self, prefix)
- outstr += prefix + 'data is of length ' + str(len(self.data)) + '\n'
- ##@todo Fix this circular reference
- # if len(self.data) > 0:
- # obj = of_message_parse(self.data)
- # if obj != None:
- # outstr += obj.show(prefix)
- # else:
- # outstr += prefix + "Unable to parse data\n"
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_packet_in.__eq__(self, other): return False
- if self.data != other.data: return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class packet_out(ofp_packet_out):
- """
- Wrapper class for packet_out
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (2)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_PACKET_OUT=13)
-
- Data members inherited from ofp_packet_out:
- @arg buffer_id
- @arg in_port
- @arg actions_len
- @arg actions: Object of type action_list
- @arg data: Binary string following message members
-
- """
-
- def __init__(self):
- ofp_packet_out.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_PACKET_OUT
- self.actions = action_list()
- self.data = ""
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- self.actions_len = len(self.actions)
- packed += ofp_packet_out.pack(self)
- packed += self.actions.pack()
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_packet_out.unpack(self, binary_string)
- binary_string = self.actions.unpack(binary_string, bytes=self.actions_len)
- self.data = binary_string
- binary_string = ''
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_packet_out.__len__(self)
- length += len(self.actions)
- length += len(self.data)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'packet_out (OFPT_PACKET_OUT)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_packet_out.show(self, prefix)
- outstr += prefix + "List actions\n"
- outstr += self.actions.show(prefix + ' ')
- outstr += prefix + 'data is of length ' + str(len(self.data)) + '\n'
- ##@todo Fix this circular reference
- # if len(self.data) > 0:
- # obj = of_message_parse(self.data)
- # if obj != None:
- # outstr += obj.show(prefix)
- # else:
- # outstr += prefix + "Unable to parse data\n"
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_packet_out.__eq__(self, other): return False
- if self.data != other.data: return False
- if self.actions != other.actions: return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class port_mod(ofp_port_mod):
- """
- Wrapper class for port_mod
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (2)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_PORT_MOD=16)
-
- Data members inherited from ofp_port_mod:
- @arg port_no
- @arg hw_addr
- @arg config
- @arg mask
- @arg advertise
-
- """
-
- def __init__(self):
- ofp_port_mod.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_PORT_MOD
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_port_mod.pack(self)
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_port_mod.unpack(self, binary_string)
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_port_mod.__len__(self)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'port_mod (OFPT_PORT_MOD)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_port_mod.show(self, prefix)
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_port_mod.__eq__(self, other): return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class port_status(ofp_port_status):
- """
- Wrapper class for port_status
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (2)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_PORT_STATUS=12)
-
- Data members inherited from ofp_port_status:
- @arg reason
- @arg desc
-
- """
-
- def __init__(self):
- ofp_port_status.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_PORT_STATUS
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_port_status.pack(self)
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_port_status.unpack(self, binary_string)
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_port_status.__len__(self)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'port_status (OFPT_PORT_STATUS)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_port_status.show(self, prefix)
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_port_status.__eq__(self, other): return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class queue_get_config_reply(ofp_queue_get_config_reply):
- """
- Wrapper class for queue_get_config_reply
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (2)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_QUEUE_GET_CONFIG_REPLY=23)
-
- Data members inherited from ofp_queue_get_config_reply:
- @arg port
- @arg queues: Variable length array of TBD
-
- """
-
- def __init__(self):
- ofp_queue_get_config_reply.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_QUEUE_GET_CONFIG_REPLY
- self.queues = []
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_queue_get_config_reply.pack(self)
- for obj in self.queues:
- packed += obj.pack()
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_queue_get_config_reply.unpack(self, binary_string)
- for obj in self.queues:
- binary_string = obj.unpack(binary_string)
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_queue_get_config_reply.__len__(self)
- for obj in self.queues:
- length += len(obj)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'queue_get_config_reply (OFPT_QUEUE_GET_CONFIG_REPLY)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_queue_get_config_reply.show(self, prefix)
- outstr += prefix + "Array queues\n"
- for obj in self.queues:
- outstr += obj.show(prefix + ' ')
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_queue_get_config_reply.__eq__(self, other): return False
- if self.queues != other.queues: return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class queue_get_config_request(ofp_queue_get_config_request):
- """
- Wrapper class for queue_get_config_request
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (2)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_QUEUE_GET_CONFIG_REQUEST=22)
-
- Data members inherited from ofp_queue_get_config_request:
- @arg port
-
- """
-
- def __init__(self):
- ofp_queue_get_config_request.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_QUEUE_GET_CONFIG_REQUEST
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_queue_get_config_request.pack(self)
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_queue_get_config_request.unpack(self, binary_string)
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_queue_get_config_request.__len__(self)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'queue_get_config_request (OFPT_QUEUE_GET_CONFIG_REQUEST)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_queue_get_config_request.show(self, prefix)
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_queue_get_config_request.__eq__(self, other): return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class set_config(ofp_switch_config):
- """
- Wrapper class for set_config
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (2)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_SET_CONFIG=9)
-
- Data members inherited from ofp_switch_config:
- @arg flags
- @arg miss_send_len
-
- """
-
- def __init__(self):
- ofp_switch_config.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_SET_CONFIG
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_switch_config.pack(self)
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_switch_config.unpack(self, binary_string)
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_switch_config.__len__(self)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'set_config (OFPT_SET_CONFIG)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_switch_config.show(self, prefix)
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_switch_config.__eq__(self, other): return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class stats_reply(ofp_stats_reply):
- """
- Wrapper class for stats_reply
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (2)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_STATS_REPLY=19)
-
- Data members inherited from ofp_stats_reply:
- @arg type
- @arg flags
-
- """
-
- def __init__(self):
- ofp_stats_reply.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_STATS_REPLY
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_stats_reply.pack(self)
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_stats_reply.unpack(self, binary_string)
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_stats_reply.__len__(self)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'stats_reply (OFPT_STATS_REPLY)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_reply.show(self, prefix)
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_stats_reply.__eq__(self, other): return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class stats_request(ofp_stats_request):
- """
- Wrapper class for stats_request
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (2)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_STATS_REQUEST=18)
-
- Data members inherited from ofp_stats_request:
- @arg type
- @arg flags
-
- """
-
- def __init__(self):
- ofp_stats_request.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_STATS_REQUEST
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_stats_request.pack(self)
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_stats_request.unpack(self, binary_string)
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_stats_request.__len__(self)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'stats_request (OFPT_STATS_REQUEST)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_request.show(self, prefix)
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_stats_request.__eq__(self, other): return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class table_mod(ofp_table_mod):
- """
- Wrapper class for table_mod
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (2)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_TABLE_MOD=17)
-
- Data members inherited from ofp_table_mod:
- @arg table_id
- @arg config
-
- """
-
- def __init__(self):
- ofp_table_mod.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_TABLE_MOD
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_table_mod.pack(self)
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_table_mod.unpack(self, binary_string)
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_table_mod.__len__(self)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'table_mod (OFPT_TABLE_MOD)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_table_mod.show(self, prefix)
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_table_mod.__eq__(self, other): return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-
-################################################################
-#
-# Stats request and reply subclass definitions
-#
-################################################################
-
-
-# Stats request bodies for desc and table stats are not defined in the
-# OpenFlow header; We define them here. They are empty classes, really
-
-class ofp_desc_stats_request(object):
- """
- Forced definition of ofp_desc_stats_request (empty class)
- """
- def __init__(self):
- pass
- def pack(self, assertstruct=True):
- return ""
- def unpack(self, binary_string):
- return binary_string
- def __len__(self):
- return 0
- def show(self, prefix=''):
- return prefix + "ofp_desc_stats_request (empty)\n"
- def __eq__(self, other):
- return type(self) == type(other)
- def __ne__(self, other):
- return type(self) != type(other)
-
-OFP_DESC_STATS_REQUEST_BYTES = 0
-
-class ofp_table_stats_request(object):
- """
- Forced definition of ofp_table_stats_request (empty class)
- """
- def __init__(self):
- pass
- def pack(self, assertstruct=True):
- return ""
- def unpack(self, binary_string):
- return binary_string
- def __len__(self):
- return 0
- def show(self, prefix=''):
- return prefix + "ofp_table_stats_request (empty)\n"
- def __eq__(self, other):
- return type(self) == type(other)
- def __ne__(self, other):
- return type(self) != type(other)
-
-OFP_TABLE_STATS_REQUEST_BYTES = 0
-
-class ofp_group_desc_stats_request(object):
- """
- Forced definition of ofp_group_desc_stats_request (empty class)
- """
- def __init__(self):
- pass
- def pack(self, assertstruct=True):
- return ""
- def unpack(self, binary_string):
- return binary_string
- def __len__(self):
- return 0
- def show(self, prefix=''):
- return prefix + "ofp_group_desc_stats_request (empty)\n"
- def __eq__(self, other):
- return type(self) == type(other)
- def __ne__(self, other):
- return type(self) != type(other)
-
-OFP_GROUP_DESC_STATS_REQUEST_BYTES = 0
-
-
-
-# Stats entries define the content of one element in a stats
-# reply for the indicated type; define _entry for consistency
-
-aggregate_stats_entry = ofp_aggregate_stats_reply
-desc_stats_entry = ofp_desc_stats
-port_stats_entry = ofp_port_stats
-queue_stats_entry = ofp_queue_stats
-table_stats_entry = ofp_table_stats
-group_stats_entry = ofp_group_stats
-group_desc_stats_entry = ofp_group_desc_stats
-
-
-#
-# Flow stats entry contains an action list of variable length, so
-# it is done by hand
-#
-
-class flow_stats_entry(ofp_flow_stats):
- """
- Special case flow stats entry to handle action list object
- """
- def __init__(self):
- ofp_flow_stats.__init__(self)
- self.instructions = instruction_list()
-
- def pack(self, assertstruct=True):
- self.length = len(self)
- packed = ofp_flow_stats.pack(self, assertstruct)
- packed += self.instructions.pack()
- if len(packed) != self.length:
- print("ERROR: flow_stats_entry pack length not equal",
- self.length, len(packed))
- return packed
-
- def unpack(self, binary_string):
- binary_string = ofp_flow_stats.unpack(self, binary_string)
- ai_len = self.length - OFP_FLOW_STATS_BYTES
- if ai_len < 0:
- print("ERROR: flow_stats_entry unpack length too small",
- self.length)
- binary_string = self.instructions.unpack(binary_string, bytes=ai_len)
- return binary_string
-
- def __len__(self):
- return OFP_FLOW_STATS_BYTES + len(self.instructions)
-
- def show(self, prefix=''):
- outstr = prefix + "flow_stats_entry\n"
- outstr += ofp_flow_stats.show(self, prefix + ' ')
- outstr += self.instructions.show(prefix + ' ')
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (ofp_flow_stats.__eq__(self, other) and
- self.instructions == other.instructions)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class aggregate_stats_request(ofp_stats_request, ofp_aggregate_stats_request):
- """
- Wrapper class for aggregate stats request message
- """
- def __init__(self):
- self.header = ofp_header()
- ofp_stats_request.__init__(self)
- ofp_aggregate_stats_request.__init__(self)
- self.header.type = OFPT_STATS_REQUEST
- self.type = OFPST_AGGREGATE
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_request.pack(self)
- packed += ofp_aggregate_stats_request.pack(self)
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_request.unpack(self, binary_string)
- binary_string = ofp_aggregate_stats_request.unpack(self, binary_string)
- if len(binary_string) != 0:
- print "ERROR unpacking aggregate: extra data"
- return binary_string
-
- def __len__(self):
- return len(self.header) + OFP_STATS_REQUEST_BYTES + \
- OFP_AGGREGATE_STATS_REQUEST_BYTES
-
- def show(self, prefix=''):
- outstr = prefix + "aggregate_stats_request\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_request.show(self)
- outstr += ofp_aggregate_stats_request.show(self)
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_request.__eq__(self, other) and
- ofp_aggregate_stats_request.__eq__(self, other))
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class aggregate_stats_reply(ofp_stats_reply):
- """
- Wrapper class for aggregate stats reply
- """
- def __init__(self):
- self.header = ofp_header()
- ofp_stats_reply.__init__(self)
- self.header.type = OFPT_STATS_REPLY
- self.type = OFPST_AGGREGATE
- # stats: Array of type aggregate_stats_entry
- self.stats = []
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_reply.pack(self)
- for obj in self.stats:
- packed += obj.pack()
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_reply.unpack(self, binary_string)
- dummy = aggregate_stats_entry()
- while len(binary_string) >= len(dummy):
- obj = aggregate_stats_entry()
- binary_string = obj.unpack(binary_string)
- self.stats.append(obj)
- if len(binary_string) != 0:
- print "ERROR unpacking aggregate stats string: extra bytes"
- return binary_string
-
- def __len__(self):
- length = len(self.header) + OFP_STATS_REPLY_BYTES
- for obj in self.stats:
- length += len(obj)
- return length
-
- def show(self, prefix=''):
- outstr = prefix + "aggregate_stats_reply\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_reply.show(self)
- outstr += prefix + "Stats array of length " + str(len(self.stats)) + '\n'
- for obj in self.stats:
- outstr += obj.show()
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_reply.__eq__(self, other) and
- self.stats == other.stats)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class desc_stats_request(ofp_stats_request, ofp_desc_stats_request):
- """
- Wrapper class for desc stats request message
- """
- def __init__(self):
- self.header = ofp_header()
- ofp_stats_request.__init__(self)
- ofp_desc_stats_request.__init__(self)
- self.header.type = OFPT_STATS_REQUEST
- self.type = OFPST_DESC
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_request.pack(self)
- packed += ofp_desc_stats_request.pack(self)
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_request.unpack(self, binary_string)
- binary_string = ofp_desc_stats_request.unpack(self, binary_string)
- if len(binary_string) != 0:
- print "ERROR unpacking desc: extra data"
- return binary_string
-
- def __len__(self):
- return len(self.header) + OFP_STATS_REQUEST_BYTES + \
- OFP_DESC_STATS_REQUEST_BYTES
-
- def show(self, prefix=''):
- outstr = prefix + "desc_stats_request\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_request.show(self)
- outstr += ofp_desc_stats_request.show(self)
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_request.__eq__(self, other) and
- ofp_desc_stats_request.__eq__(self, other))
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class desc_stats_reply(ofp_stats_reply):
- """
- Wrapper class for desc stats reply
- """
- def __init__(self):
- self.header = ofp_header()
- ofp_stats_reply.__init__(self)
- self.header.type = OFPT_STATS_REPLY
- self.type = OFPST_DESC
- # stats: Array of type desc_stats_entry
- self.stats = []
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_reply.pack(self)
- for obj in self.stats:
- packed += obj.pack()
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_reply.unpack(self, binary_string)
- dummy = desc_stats_entry()
- while len(binary_string) >= len(dummy):
- obj = desc_stats_entry()
- binary_string = obj.unpack(binary_string)
- self.stats.append(obj)
- if len(binary_string) != 0:
- print "ERROR unpacking desc stats string: extra bytes"
- return binary_string
-
- def __len__(self):
- length = len(self.header) + OFP_STATS_REPLY_BYTES
- for obj in self.stats:
- length += len(obj)
- return length
-
- def show(self, prefix=''):
- outstr = prefix + "desc_stats_reply\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_reply.show(self)
- outstr += prefix + "Stats array of length " + str(len(self.stats)) + '\n'
- for obj in self.stats:
- outstr += obj.show()
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_reply.__eq__(self, other) and
- self.stats == other.stats)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class flow_stats_request(ofp_stats_request, ofp_flow_stats_request):
- """
- Wrapper class for flow stats request message
- """
- def __init__(self):
- self.header = ofp_header()
- ofp_stats_request.__init__(self)
- ofp_flow_stats_request.__init__(self)
- self.header.type = OFPT_STATS_REQUEST
- self.type = OFPST_FLOW
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_request.pack(self)
- packed += ofp_flow_stats_request.pack(self)
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_request.unpack(self, binary_string)
- binary_string = ofp_flow_stats_request.unpack(self, binary_string)
- if len(binary_string) != 0:
- print "ERROR unpacking flow: extra data"
- return binary_string
-
- def __len__(self):
- return len(self.header) + OFP_STATS_REQUEST_BYTES + \
- OFP_FLOW_STATS_REQUEST_BYTES
-
- def show(self, prefix=''):
- outstr = prefix + "flow_stats_request\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_request.show(self)
- outstr += ofp_flow_stats_request.show(self)
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_request.__eq__(self, other) and
- ofp_flow_stats_request.__eq__(self, other))
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class flow_stats_reply(ofp_stats_reply):
- """
- Wrapper class for flow stats reply
- """
- def __init__(self):
- self.header = ofp_header()
- ofp_stats_reply.__init__(self)
- self.header.type = OFPT_STATS_REPLY
- self.type = OFPST_FLOW
- # stats: Array of type flow_stats_entry
- self.stats = []
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_reply.pack(self)
- for obj in self.stats:
- packed += obj.pack()
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_reply.unpack(self, binary_string)
- dummy = flow_stats_entry()
- while len(binary_string) >= len(dummy):
- obj = flow_stats_entry()
- binary_string = obj.unpack(binary_string)
- self.stats.append(obj)
- if len(binary_string) != 0:
- print "ERROR unpacking flow stats string: extra bytes"
- return binary_string
-
- def __len__(self):
- length = len(self.header) + OFP_STATS_REPLY_BYTES
- for obj in self.stats:
- length += len(obj)
- return length
-
- def show(self, prefix=''):
- outstr = prefix + "flow_stats_reply\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_reply.show(self)
- outstr += prefix + "Stats array of length " + str(len(self.stats)) + '\n'
- for obj in self.stats:
- outstr += obj.show()
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_reply.__eq__(self, other) and
- self.stats == other.stats)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class port_stats_request(ofp_stats_request, ofp_port_stats_request):
- """
- Wrapper class for port stats request message
- """
- def __init__(self):
- self.header = ofp_header()
- ofp_stats_request.__init__(self)
- ofp_port_stats_request.__init__(self)
- self.header.type = OFPT_STATS_REQUEST
- self.type = OFPST_PORT
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_request.pack(self)
- packed += ofp_port_stats_request.pack(self)
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_request.unpack(self, binary_string)
- binary_string = ofp_port_stats_request.unpack(self, binary_string)
- if len(binary_string) != 0:
- print "ERROR unpacking port: extra data"
- return binary_string
-
- def __len__(self):
- return len(self.header) + OFP_STATS_REQUEST_BYTES + \
- OFP_PORT_STATS_REQUEST_BYTES
-
- def show(self, prefix=''):
- outstr = prefix + "port_stats_request\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_request.show(self)
- outstr += ofp_port_stats_request.show(self)
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_request.__eq__(self, other) and
- ofp_port_stats_request.__eq__(self, other))
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class port_stats_reply(ofp_stats_reply):
- """
- Wrapper class for port stats reply
- """
- def __init__(self):
- self.header = ofp_header()
- ofp_stats_reply.__init__(self)
- self.header.type = OFPT_STATS_REPLY
- self.type = OFPST_PORT
- # stats: Array of type port_stats_entry
- self.stats = []
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_reply.pack(self)
- for obj in self.stats:
- packed += obj.pack()
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_reply.unpack(self, binary_string)
- dummy = port_stats_entry()
- while len(binary_string) >= len(dummy):
- obj = port_stats_entry()
- binary_string = obj.unpack(binary_string)
- self.stats.append(obj)
- if len(binary_string) != 0:
- print "ERROR unpacking port stats string: extra bytes"
- return binary_string
-
- def __len__(self):
- length = len(self.header) + OFP_STATS_REPLY_BYTES
- for obj in self.stats:
- length += len(obj)
- return length
-
- def show(self, prefix=''):
- outstr = prefix + "port_stats_reply\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_reply.show(self)
- outstr += prefix + "Stats array of length " + str(len(self.stats)) + '\n'
- for obj in self.stats:
- outstr += obj.show()
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_reply.__eq__(self, other) and
- self.stats == other.stats)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class queue_stats_request(ofp_stats_request, ofp_queue_stats_request):
- """
- Wrapper class for queue stats request message
- """
- def __init__(self):
- self.header = ofp_header()
- ofp_stats_request.__init__(self)
- ofp_queue_stats_request.__init__(self)
- self.header.type = OFPT_STATS_REQUEST
- self.type = OFPST_QUEUE
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_request.pack(self)
- packed += ofp_queue_stats_request.pack(self)
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_request.unpack(self, binary_string)
- binary_string = ofp_queue_stats_request.unpack(self, binary_string)
- if len(binary_string) != 0:
- print "ERROR unpacking queue: extra data"
- return binary_string
-
- def __len__(self):
- return len(self.header) + OFP_STATS_REQUEST_BYTES + \
- OFP_QUEUE_STATS_REQUEST_BYTES
-
- def show(self, prefix=''):
- outstr = prefix + "queue_stats_request\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_request.show(self)
- outstr += ofp_queue_stats_request.show(self)
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_request.__eq__(self, other) and
- ofp_queue_stats_request.__eq__(self, other))
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class queue_stats_reply(ofp_stats_reply):
- """
- Wrapper class for queue stats reply
- """
- def __init__(self):
- self.header = ofp_header()
- ofp_stats_reply.__init__(self)
- self.header.type = OFPT_STATS_REPLY
- self.type = OFPST_QUEUE
- # stats: Array of type queue_stats_entry
- self.stats = []
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_reply.pack(self)
- for obj in self.stats:
- packed += obj.pack()
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_reply.unpack(self, binary_string)
- dummy = queue_stats_entry()
- while len(binary_string) >= len(dummy):
- obj = queue_stats_entry()
- binary_string = obj.unpack(binary_string)
- self.stats.append(obj)
- if len(binary_string) != 0:
- print "ERROR unpacking queue stats string: extra bytes"
- return binary_string
-
- def __len__(self):
- length = len(self.header) + OFP_STATS_REPLY_BYTES
- for obj in self.stats:
- length += len(obj)
- return length
-
- def show(self, prefix=''):
- outstr = prefix + "queue_stats_reply\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_reply.show(self)
- outstr += prefix + "Stats array of length " + str(len(self.stats)) + '\n'
- for obj in self.stats:
- outstr += obj.show()
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_reply.__eq__(self, other) and
- self.stats == other.stats)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class group_stats_request(ofp_stats_request, ofp_group_stats_request):
- """
- Wrapper class for group stats request message
- """
- def __init__(self):
- self.header = ofp_header()
- ofp_stats_request.__init__(self)
- ofp_group_stats_request.__init__(self)
- self.header.type = OFPT_STATS_REQUEST
- self.type = OFPST_GROUP
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_request.pack(self)
- packed += ofp_group_stats_request.pack(self)
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_request.unpack(self, binary_string)
- binary_string = ofp_group_stats_request.unpack(self, binary_string)
- if len(binary_string) != 0:
- print "ERROR unpacking group: extra data"
- return binary_string
-
- def __len__(self):
- return len(self.header) + OFP_STATS_REQUEST_BYTES + \
- OFP_GROUP_STATS_REQUEST_BYTES
-
- def show(self, prefix=''):
- outstr = prefix + "group_stats_request\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_request.show(self)
- outstr += ofp_group_stats_request.show(self)
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_request.__eq__(self, other) and
- ofp_group_stats_request.__eq__(self, other))
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class group_stats_reply(ofp_stats_reply):
- """
- Wrapper class for group stats reply
- """
- def __init__(self):
- self.header = ofp_header()
- ofp_stats_reply.__init__(self)
- self.header.type = OFPT_STATS_REPLY
- self.type = OFPST_GROUP
- # stats: Array of type group_stats_entry
- self.stats = []
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_reply.pack(self)
- for obj in self.stats:
- packed += obj.pack()
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_reply.unpack(self, binary_string)
- dummy = group_stats_entry()
- while len(binary_string) >= len(dummy):
- obj = group_stats_entry()
- binary_string = obj.unpack(binary_string)
- self.stats.append(obj)
- if len(binary_string) != 0:
- print "ERROR unpacking group stats string: extra bytes"
- return binary_string
-
- def __len__(self):
- length = len(self.header) + OFP_STATS_REPLY_BYTES
- for obj in self.stats:
- length += len(obj)
- return length
-
- def show(self, prefix=''):
- outstr = prefix + "group_stats_reply\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_reply.show(self)
- outstr += prefix + "Stats array of length " + str(len(self.stats)) + '\n'
- for obj in self.stats:
- outstr += obj.show()
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_reply.__eq__(self, other) and
- self.stats == other.stats)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class group_desc_stats_request(ofp_stats_request, ofp_group_desc_stats_request):
- """
- Wrapper class for group_desc stats request message
- """
- def __init__(self):
- self.header = ofp_header()
- ofp_stats_request.__init__(self)
- ofp_group_desc_stats_request.__init__(self)
- self.header.type = OFPT_STATS_REQUEST
- self.type = OFPST_GROUP_DESC
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_request.pack(self)
- packed += ofp_group_desc_stats_request.pack(self)
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_request.unpack(self, binary_string)
- binary_string = ofp_group_desc_stats_request.unpack(self, binary_string)
- if len(binary_string) != 0:
- print "ERROR unpacking group_desc: extra data"
- return binary_string
-
- def __len__(self):
- return len(self.header) + OFP_STATS_REQUEST_BYTES + \
- OFP_GROUP_DESC_STATS_REQUEST_BYTES
-
- def show(self, prefix=''):
- outstr = prefix + "group_desc_stats_request\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_request.show(self)
- outstr += ofp_group_desc_stats_request.show(self)
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_request.__eq__(self, other) and
- ofp_group_desc_stats_request.__eq__(self, other))
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class group_desc_stats_reply(ofp_stats_reply):
- """
- Wrapper class for group_desc stats reply
- """
- def __init__(self):
- self.header = ofp_header()
- ofp_stats_reply.__init__(self)
- self.header.type = OFPT_STATS_REPLY
- self.type = OFPST_GROUP_DESC
- # stats: Array of type group_desc_stats_entry
- self.stats = []
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_reply.pack(self)
- for obj in self.stats:
- packed += obj.pack()
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_reply.unpack(self, binary_string)
- dummy = group_desc_stats_entry()
- while len(binary_string) >= len(dummy):
- obj = group_desc_stats_entry()
- binary_string = obj.unpack(binary_string)
- self.stats.append(obj)
- if len(binary_string) != 0:
- print "ERROR unpacking group_desc stats string: extra bytes"
- return binary_string
-
- def __len__(self):
- length = len(self.header) + OFP_STATS_REPLY_BYTES
- for obj in self.stats:
- length += len(obj)
- return length
-
- def show(self, prefix=''):
- outstr = prefix + "group_desc_stats_reply\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_reply.show(self)
- outstr += prefix + "Stats array of length " + str(len(self.stats)) + '\n'
- for obj in self.stats:
- outstr += obj.show()
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_reply.__eq__(self, other) and
- self.stats == other.stats)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class table_stats_request(ofp_stats_request, ofp_table_stats_request):
- """
- Wrapper class for table stats request message
- """
- def __init__(self):
- self.header = ofp_header()
- ofp_stats_request.__init__(self)
- ofp_table_stats_request.__init__(self)
- self.header.type = OFPT_STATS_REQUEST
- self.type = OFPST_TABLE
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_request.pack(self)
- packed += ofp_table_stats_request.pack(self)
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_request.unpack(self, binary_string)
- binary_string = ofp_table_stats_request.unpack(self, binary_string)
- if len(binary_string) != 0:
- print "ERROR unpacking table: extra data"
- return binary_string
-
- def __len__(self):
- return len(self.header) + OFP_STATS_REQUEST_BYTES + \
- OFP_TABLE_STATS_REQUEST_BYTES
-
- def show(self, prefix=''):
- outstr = prefix + "table_stats_request\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_request.show(self)
- outstr += ofp_table_stats_request.show(self)
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_request.__eq__(self, other) and
- ofp_table_stats_request.__eq__(self, other))
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class table_stats_reply(ofp_stats_reply):
- """
- Wrapper class for table stats reply
- """
- def __init__(self):
- self.header = ofp_header()
- ofp_stats_reply.__init__(self)
- self.header.type = OFPT_STATS_REPLY
- self.type = OFPST_TABLE
- # stats: Array of type table_stats_entry
- self.stats = []
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_reply.pack(self)
- for obj in self.stats:
- packed += obj.pack()
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_reply.unpack(self, binary_string)
- dummy = table_stats_entry()
- while len(binary_string) >= len(dummy):
- obj = table_stats_entry()
- binary_string = obj.unpack(binary_string)
- self.stats.append(obj)
- if len(binary_string) != 0:
- print "ERROR unpacking table stats string: extra bytes"
- return binary_string
-
- def __len__(self):
- length = len(self.header) + OFP_STATS_REPLY_BYTES
- for obj in self.stats:
- length += len(obj)
- return length
-
- def show(self, prefix=''):
- outstr = prefix + "table_stats_reply\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_reply.show(self)
- outstr += prefix + "Stats array of length " + str(len(self.stats)) + '\n'
- for obj in self.stats:
- outstr += obj.show()
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_reply.__eq__(self, other) and
- self.stats == other.stats)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-# @todo Add buckets to group and group_desc stats obejcts"
-message_type_list = (
- aggregate_stats_reply,
- aggregate_stats_request,
- bad_action_error_msg,
- bad_request_error_msg,
- barrier_reply,
- barrier_request,
- desc_stats_reply,
- desc_stats_request,
- echo_reply,
- echo_request,
- error,
- experimenter,
- features_reply,
- features_request,
- flow_mod,
- flow_mod_failed_error_msg,
- flow_removed,
- flow_stats_reply,
- flow_stats_request,
- get_config_reply,
- get_config_request,
- group_desc_stats_request,
- group_desc_stats_reply,
- group_stats_request,
- group_stats_reply,
- group_mod,
- group_mod_failed_error_msg,
- hello,
- hello_failed_error_msg,
- packet_in,
- packet_out,
- port_mod,
- port_mod_failed_error_msg,
- port_stats_reply,
- port_stats_request,
- port_status,
- queue_get_config_reply,
- queue_get_config_request,
- queue_op_failed_error_msg,
- queue_stats_reply,
- queue_stats_request,
- set_config,
- switch_config_failed_error_msg,
- table_mod,
- table_mod_failed_error_msg,
- table_stats_reply,
- table_stats_request,
- )
-
diff --git a/src/python/of11/message_unittests.py b/src/python/of11/message_unittests.py
deleted file mode 100755
index 04b8679..0000000
--- a/src/python/of11/message_unittests.py
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/usr/bin/python
-
-import unittest
-import message
-import action
-import instruction
-import cstruct as ofp
-
-class flow_stats_pack(unittest.TestCase):
- def runTest(self):
- msg = message.flow_stats_entry()
- match = ofp.ofp_match()
- match.wildcards &= ~ofp.OFPFW_IN_PORT
- act = action.action_output()
- act.port = 3
- msg.match = match
- pkt = msg.pack()
- self.assertEqual(len(pkt), 136)
- inst = instruction.instruction_apply_actions()
- self.assertTrue(inst.actions.add(act), "Could not add action")
- self.assertTrue(msg.instructions.add(inst), "Could not add instructions")
- #self.assertTrue(msg.actions.add(act), "Could not add action")
- pkt = msg.pack()
- # 160 = 136 for flow_stats_entry and 24 for instruction_list
- self.assertEqual(len(pkt), 160)
- rep = message.flow_stats_reply()
- self.assertEqual(len(rep.pack()),12)
- rep.stats.append(msg)
- self.assertEqual(len(rep.pack()),172)
-
-
-
-class match_pack(unittest.TestCase):
- def runTest(self):
- match = ofp.ofp_match()
- self.assertEqual(len(match.pack()), 88)
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/src/python/of11/parse.py b/src/python/of11/parse.py
deleted file mode 100644
index dfe24c6..0000000
--- a/src/python/of11/parse.py
+++ /dev/null
@@ -1,231 +0,0 @@
-"""
-OpenFlow message parsing functions
-"""
-
-import logging
-import message
-import cstruct as ofp
-
-"""
-of_message.py
-Contains wrapper functions and classes for the of_message namespace
-that are generated by hand. It includes the rest of the wrapper
-function information into the of_message namespace
-"""
-
-parse_logger = logging.getLogger("parse")
-#parse_logger.setLevel(logging.DEBUG)
-
-# These message types are subclassed
-msg_type_subclassed = [
- ofp.OFPT_STATS_REQUEST,
- ofp.OFPT_STATS_REPLY,
- ofp.OFPT_ERROR
-]
-
-# Maps from sub-types to classes
-stats_reply_to_class_map = {
- ofp.OFPST_DESC : message.desc_stats_reply,
- ofp.OFPST_AGGREGATE : message.aggregate_stats_reply,
- ofp.OFPST_FLOW : message.flow_stats_reply,
- ofp.OFPST_TABLE : message.table_stats_reply,
- ofp.OFPST_PORT : message.port_stats_reply,
- ofp.OFPST_QUEUE : message.queue_stats_reply
-}
-
-stats_request_to_class_map = {
- ofp.OFPST_DESC : message.desc_stats_request,
- ofp.OFPST_AGGREGATE : message.aggregate_stats_request,
- ofp.OFPST_FLOW : message.flow_stats_request,
- ofp.OFPST_TABLE : message.table_stats_request,
- ofp.OFPST_PORT : message.port_stats_request,
- ofp.OFPST_QUEUE : message.queue_stats_request
-}
-
-error_to_class_map = {
- ofp.OFPET_HELLO_FAILED : message.hello_failed_error_msg,
- ofp.OFPET_BAD_REQUEST : message.bad_request_error_msg,
- ofp.OFPET_BAD_ACTION : message.bad_action_error_msg,
- ofp.OFPET_FLOW_MOD_FAILED : message.flow_mod_failed_error_msg,
- ofp.OFPET_PORT_MOD_FAILED : message.port_mod_failed_error_msg,
- ofp.OFPET_QUEUE_OP_FAILED : message.queue_op_failed_error_msg,
- ofp.OFPET_TABLE_MOD_FAILED : message.table_mod_failed_error_msg,
- ofp.OFPET_QUEUE_OP_FAILED : message.queue_op_failed_error_msg,
- ofp.OFPET_SWITCH_CONFIG_FAILED : message.switch_config_failed_error_msg
-}
-
-# Map from header type value to the underlieing message class
-msg_type_to_class_map = {
- ofp.OFPT_HELLO : message.hello,
- ofp.OFPT_ERROR : message.error,
- ofp.OFPT_ECHO_REQUEST : message.echo_request,
- ofp.OFPT_ECHO_REPLY : message.echo_reply,
- ofp.OFPT_EXPERIMENTER : message.experimenter,
- ofp.OFPT_FEATURES_REQUEST : message.features_request,
- ofp.OFPT_FEATURES_REPLY : message.features_reply,
- ofp.OFPT_GET_CONFIG_REQUEST : message.get_config_request,
- ofp.OFPT_GET_CONFIG_REPLY : message.get_config_reply,
- ofp.OFPT_SET_CONFIG : message.set_config,
- ofp.OFPT_PACKET_IN : message.packet_in,
- ofp.OFPT_FLOW_REMOVED : message.flow_removed,
- ofp.OFPT_PORT_STATUS : message.port_status,
- ofp.OFPT_PACKET_OUT : message.packet_out,
- ofp.OFPT_FLOW_MOD : message.flow_mod,
- ofp.OFPT_PORT_MOD : message.port_mod,
- ofp.OFPT_TABLE_MOD : message.table_mod,
- ofp.OFPT_STATS_REQUEST : message.stats_request,
- ofp.OFPT_STATS_REPLY : message.stats_reply,
- ofp.OFPT_BARRIER_REQUEST : message.barrier_request,
- ofp.OFPT_BARRIER_REPLY : message.barrier_reply,
- ofp.OFPT_QUEUE_GET_CONFIG_REQUEST : message.queue_get_config_request,
- ofp.OFPT_QUEUE_GET_CONFIG_REPLY : message.queue_get_config_reply,
-}
-
-def _of_message_to_object(binary_string):
- """
- Map a binary string to the corresponding class.
-
- Appropriately resolves subclasses
- """
- hdr = ofp.ofp_header()
- hdr.unpack(binary_string)
- # FIXME: Add error detection
- if not hdr.type in msg_type_subclassed:
- return msg_type_to_class_map[hdr.type]()
- if hdr.type == ofp.OFPT_STATS_REQUEST:
- sub_hdr = ofp.ofp_stats_request()
- sub_hdr.unpack(binary_string[ofp.OFP_HEADER_BYTES:])
- try:
- obj = stats_request_to_class_map[sub_hdr.type]()
- except LookupError:
- obj = None
- return obj
- elif hdr.type == ofp.OFPT_STATS_REPLY:
- sub_hdr = ofp.ofp_stats_reply()
- sub_hdr.unpack(binary_string[ofp.OFP_HEADER_BYTES:])
- try:
- obj = stats_reply_to_class_map[sub_hdr.type]()
- except LookupError:
- obj = None
- return obj
- elif hdr.type == ofp.OFPT_ERROR:
- sub_hdr = ofp.ofp_error_msg()
- sub_hdr.unpack(binary_string[ofp.OFP_HEADER_BYTES:])
- return error_to_class_map[sub_hdr.type]()
- else:
- parse_logger.error("Cannot parse pkt to message")
- return None
-
-def of_message_parse(binary_string, raw=False):
- """
- Parse an OpenFlow packet
-
- Parses a raw OpenFlow packet into a Python class, with class
- members fully populated.
-
- @param binary_string The packet (string) to be parsed
- @param raw If true, interpret the packet as an L2 packet. Not
- yet supported.
- @return An object of some message class or None if fails
- Note that any data beyond that parsed is not returned
-
- """
-
- if raw:
- parse_logger.error("raw packet message parsing not supported")
- return None
-
- obj = _of_message_to_object(binary_string)
- if obj:
- obj.unpack(binary_string)
- return obj
-
-
-def of_header_parse(binary_string, raw=False):
- """
- Parse only the header from an OpenFlow packet
-
- Parses the header from a raw OpenFlow packet into a
- an ofp_header Python class.
-
- @param binary_string The packet (string) to be parsed
- @param raw If true, interpret the packet as an L2 packet. Not
- yet supported.
- @return An ofp_header object
-
- """
-
- if raw:
- parse_logger.error("raw packet message parsing not supported")
- return None
-
- hdr = ofp.ofp_header()
- hdr.unpack(binary_string)
-
- return hdr
-
-map_wc_field_to_match_member = {
- 'OFPFW_DL_VLAN' : 'dl_vlan',
- 'OFPFW_DL_SRC' : 'dl_src',
- 'OFPFW_DL_DST' : 'dl_dst',
- 'OFPFW_DL_TYPE' : 'dl_type',
- 'OFPFW_NW_PROTO' : 'nw_proto',
- 'OFPFW_TP_SRC' : 'tp_src',
- 'OFPFW_TP_DST' : 'tp_dst',
- 'OFPFW_NW_SRC_SHIFT' : 'nw_src_shift',
- 'OFPFW_NW_SRC_BITS' : 'nw_src_bits',
- 'OFPFW_NW_SRC_MASK' : 'nw_src_mask',
- 'OFPFW_NW_SRC_ALL' : 'nw_src_all',
- 'OFPFW_NW_DST_SHIFT' : 'nw_dst_shift',
- 'OFPFW_NW_DST_BITS' : 'nw_dst_bits',
- 'OFPFW_NW_DST_MASK' : 'nw_dst_mask',
- 'OFPFW_NW_DST_ALL' : 'nw_dst_all',
- 'OFPFW_DL_VLAN_PCP' : 'dl_vlan_pcp',
- 'OFPFW_NW_TOS' : 'nw_tos'
-}
-
-
-def parse_mac(mac_str):
- """
- Parse a MAC address
-
- Parse a MAC address ':' separated string of hex digits to an
- array of integer values. '00:d0:05:5d:24:00' => [0, 208, 5, 93, 36, 0]
- @param mac_str The string to convert
- @return Array of 6 integer values
- """
- return map(lambda val:eval("0x" + val), mac_str.split(":"))
-
-def parse_ip(ip_str):
- """
- Parse an IP address
-
- Parse an IP address '.' separated string of decimal digits to an
- host ordered integer. '172.24.74.77' =>
- @param ip_str The string to convert
- @return Integer value
- """
- array = map(lambda val:eval(val),ip_str.split("."))
- val = 0
- for a in array:
- val <<= 8
- val += a
- return val
-
-def packet_to_flow_match(packet):
- """
- Create a flow match that matches packet with the given wildcards
-
- @param packet The packet to use as a flow template
- @param pkt_format Currently only L2 is supported. Will indicate the
- overall packet type for parsing
- @return An ofp_match object if successful. None if format is not
- recognized. The wildcards of the match will be cleared for the
- values extracted from the packet.
-
- @todo check min length of packet
- @todo Check if packet is other than L2 format
- @todo Implement ICMP and ARP fields
- """
-
- return packet.parse()
diff --git a/src/python/of12/__init__.py b/src/python/of12/__init__.py
deleted file mode 100644
index 36dd8fa..0000000
--- a/src/python/of12/__init__.py
+++ /dev/null
@@ -1,10 +0,0 @@
-# Allow accessing constants through the top-level module
-from cstruct import *
-
-# Allow accessing submodules without additional imports
-import action
-import bucket
-import instruction
-import match
-import message
-import parse
diff --git a/src/python/of12/action.py b/src/python/of12/action.py
deleted file mode 100644
index 059e390..0000000
--- a/src/python/of12/action.py
+++ /dev/null
@@ -1,427 +0,0 @@
-
-# Python OpenFlow action wrapper classes
-
-from cstruct import *
-from match import roundup
-from match_list import match_list
-
-class pop_mpls(ofp_action_pop_mpls):
- """
- Wrapper class for pop_mpls action object
-
- Data members inherited from ofp_action_pop_mpls:
- @arg type
- @arg len
- @arg ethertype
-
- """
- def __init__(self, **kwargs):
- ofp_action_pop_mpls.__init__(self)
- self.type = OFPAT_POP_MPLS
- self.len = self.__len__()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- def show(self, prefix=''):
- outstr = prefix + "action_pop_mpls\n"
- outstr += ofp_action_pop_mpls.show(self, prefix)
- return outstr
-
-
-class push_vlan(ofp_action_push):
- """
- Wrapper class for push_vlan action object
-
- Data members inherited from ofp_action_push:
- @arg type
- @arg len
- @arg ethertype
-
- """
- def __init__(self, **kwargs):
- ofp_action_push.__init__(self)
- self.type = OFPAT_PUSH_VLAN
- self.len = self.__len__()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- def show(self, prefix=''):
- outstr = prefix + "action_push_vlan\n"
- outstr += ofp_action_push.show(self, prefix)
- return outstr
-
-
-class experimenter(ofp_action_experimenter_header):
- """
- Wrapper class for experimenter action object
-
- Data members inherited from ofp_action_experimenter_header:
- @arg type
- @arg len
- @arg experimenter
-
- """
- def __init__(self, **kwargs):
- ofp_action_experimenter_header.__init__(self)
- self.type = OFPAT_EXPERIMENTER
- self.len = self.__len__()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- def show(self, prefix=''):
- outstr = prefix + "action_experimenter\n"
- outstr += ofp_action_experimenter_header.show(self, prefix)
- return outstr
-
-
-class dec_mpls_ttl(ofp_action_header):
- """
- Wrapper class for dec_mpls_ttl action object
-
- Data members inherited from ofp_action_header:
- @arg type
- @arg len
-
- """
- def __init__(self, **kwargs):
- ofp_action_header.__init__(self)
- self.type = OFPAT_DEC_MPLS_TTL
- self.len = self.__len__()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- def show(self, prefix=''):
- outstr = prefix + "action_dec_mpls_ttl\n"
- outstr += ofp_action_header.show(self, prefix)
- return outstr
-
-
-class set_nw_ttl(ofp_action_nw_ttl):
- """
- Wrapper class for set_nw_ttl action object
-
- Data members inherited from ofp_action_nw_ttl:
- @arg type
- @arg len
- @arg nw_ttl
-
- """
- def __init__(self, **kwargs):
- ofp_action_nw_ttl.__init__(self)
- self.type = OFPAT_SET_NW_TTL
- self.len = self.__len__()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- def show(self, prefix=''):
- outstr = prefix + "action_set_nw_ttl\n"
- outstr += ofp_action_nw_ttl.show(self, prefix)
- return outstr
-
-
-class copy_ttl_in(ofp_action_header):
- """
- Wrapper class for copy_ttl_in action object
-
- Data members inherited from ofp_action_header:
- @arg type
- @arg len
-
- """
- def __init__(self, **kwargs):
- ofp_action_header.__init__(self)
- self.type = OFPAT_COPY_TTL_IN
- self.len = self.__len__()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- def show(self, prefix=''):
- outstr = prefix + "action_copy_ttl_in\n"
- outstr += ofp_action_header.show(self, prefix)
- return outstr
-
-
-class group(ofp_action_group):
- """
- Wrapper class for group action object
-
- Data members inherited from ofp_action_group:
- @arg type
- @arg len
- @arg group_id
-
- """
- def __init__(self, **kwargs):
- ofp_action_group.__init__(self)
- self.type = OFPAT_GROUP
- self.len = self.__len__()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- def show(self, prefix=''):
- outstr = prefix + "action_group\n"
- outstr += ofp_action_group.show(self, prefix)
- return outstr
- def __len__(self):
- return roundup(4 + 4,8)
-
-
-class set_queue(ofp_action_set_queue):
- """
- Wrapper class for set_queue action object
-
- Data members inherited from ofp_action_set_queue:
- @arg type
- @arg len
- @arg queue_id
-
- """
- def __init__(self, **kwargs):
- ofp_action_set_queue.__init__(self)
- self.type = OFPAT_SET_QUEUE
- self.len = self.__len__()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- def show(self, prefix=''):
- outstr = prefix + "action_set_queue\n"
- outstr += ofp_action_set_queue.show(self, prefix)
- return outstr
-
-
-class push_mpls(ofp_action_push):
- """
- Wrapper class for push_mpls action object
-
- Data members inherited from ofp_action_push:
- @arg type
- @arg len
- @arg ethertype
-
- """
- def __init__(self, **kwargs):
- ofp_action_push.__init__(self)
- self.type = OFPAT_PUSH_MPLS
- self.len = self.__len__()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- def show(self, prefix=''):
- outstr = prefix + "action_push_mpls\n"
- outstr += ofp_action_push.show(self, prefix)
- return outstr
-
-
-class copy_ttl_out(ofp_action_header):
- """
- Wrapper class for copy_ttl_out action object
-
- Data members inherited from ofp_action_header:
- @arg type
- @arg len
-
- """
- def __init__(self, **kwargs):
- ofp_action_header.__init__(self)
- self.type = OFPAT_COPY_TTL_OUT
- self.len = self.__len__()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- def show(self, prefix=''):
- outstr = prefix + "action_copy_ttl_out\n"
- outstr += ofp_action_header.show(self, prefix)
- return outstr
-
-
-class set_field(ofp_action_set_field):
- """
- Wrapper class for set_field action object
-
- Data members inherited from ofp_action_set_field:
- @arg type
- @arg len
- @arg field
-
- """
- def __init__(self, **kwargs):
- ofp_action_set_field.__init__(self)
- self.type = OFPAT_SET_FIELD
- self.len = self.__len__()
- self.field = match_list()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
- def pack(self):
- packed = ""
- if len(self.field) <= 4:
- packed += ofp_action_set_field.pack()
- else:
- self.len = len(self)
- packed += struct.pack("!HH", self.type, self.len)
- packed += self.field.pack()
- padding_size = roundup(len(self.field) -4,8) - (len(self.field) -4)
- if padding_size:
- padding = [0] * padding_size
- packed += struct.pack("!" + str(padding_size) + "B", *padding)
- return packed
-
- def unpack(self, binary_string):
- if len(binary_string) <= 8:
- binary_string = ofp_action_set_field.unpack(self)
- else:
- (self.type, self.len) = struct.unpack("!HH", binary_string[0:4])
- binary_string = binary_string[4:]
- binary_string = self.field.unpack(binary_string, bytes = self.len - 4)
- padding_size = roundup(len(self.field) -4,8) - (len(self.field) -4)
- if padding_size:
- binary_string = binary_string[padding_size:]
- return binary_string
-
- def show(self, prefix=''):
- outstr = prefix + "action_set_field\n"
- outstr += ofp_action_set_field.show(self, prefix)
- return outstr
-
- def __len__(self):
- return roundup(4 + len(self.field),8)
-
-
-class set_mpls_ttl(ofp_action_mpls_ttl):
- """
- Wrapper class for set_mpls_ttl action object
-
- Data members inherited from ofp_action_mpls_ttl:
- @arg type
- @arg len
- @arg mpls_ttl
-
- """
- def __init__(self, **kwargs):
- ofp_action_mpls_ttl.__init__(self)
- self.type = OFPAT_SET_MPLS_TTL
- self.len = self.__len__()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- def show(self, prefix=''):
- outstr = prefix + "action_set_mpls_ttl\n"
- outstr += ofp_action_mpls_ttl.show(self, prefix)
- return outstr
-
-
-class pop_vlan(ofp_action_header):
- """
- Wrapper class for pop_vlan action object
-
- Data members inherited from ofp_action_header:
- @arg type
- @arg len
-
- """
- def __init__(self, **kwargs):
- ofp_action_header.__init__(self)
- self.type = OFPAT_POP_VLAN
- self.len = self.__len__()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- def show(self, prefix=''):
- outstr = prefix + "action_pop_vlan\n"
- outstr += ofp_action_header.show(self, prefix)
- return outstr
-
-
-class dec_nw_ttl(ofp_action_header):
- """
- Wrapper class for dec_nw_ttl action object
-
- Data members inherited from ofp_action_header:
- @arg type
- @arg len
-
- """
- def __init__(self, **kwargs):
- ofp_action_header.__init__(self)
- self.type = OFPAT_DEC_NW_TTL
- self.len = self.__len__()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- def show(self, prefix=''):
- outstr = prefix + "action_dec_nw_ttl\n"
- outstr += ofp_action_header.show(self, prefix)
- return outstr
-
-
-class output(ofp_action_output):
- """
- Wrapper class for output action object
-
- Data members inherited from ofp_action_output:
- @arg type
- @arg len
- @arg port
- @arg max_len
-
- """
- def __init__(self, **kwargs):
- ofp_action_output.__init__(self)
- self.type = OFPAT_OUTPUT
- self.len = self.__len__()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- def show(self, prefix=''):
- outstr = prefix + "action_output\n"
- outstr += ofp_action_output.show(self, prefix)
- return outstr
-
-action_class_list = (
- copy_ttl_in,
- copy_ttl_out,
- dec_mpls_ttl,
- dec_nw_ttl,
- experimenter,
- group,
- output,
- pop_mpls,
- pop_vlan,
- push_mpls,
- push_vlan,
- set_field,
- set_mpls_ttl,
- set_nw_ttl,
- set_queue)
-
diff --git a/src/python/of12/action_list.py b/src/python/of12/action_list.py
deleted file mode 100644
index 78341e2..0000000
--- a/src/python/of12/action_list.py
+++ /dev/null
@@ -1,88 +0,0 @@
-"""
-OpenFlow action, instruction and bucket list classes
-"""
-
-from action import *
-from cstruct import ofp_header
-from base_list import ofp_base_list
-import copy
-
-action_object_map = {
- OFPAT_OUTPUT : output,
- OFPAT_SET_FIELD : set_field,
- OFPAT_COPY_TTL_OUT : copy_ttl_out,
- OFPAT_COPY_TTL_IN : copy_ttl_in,
- OFPAT_SET_MPLS_TTL : set_mpls_ttl,
- OFPAT_DEC_MPLS_TTL : dec_mpls_ttl,
- OFPAT_PUSH_VLAN : push_vlan,
- OFPAT_POP_VLAN : pop_vlan,
- OFPAT_PUSH_MPLS : push_mpls,
- OFPAT_POP_MPLS : pop_mpls,
- OFPAT_SET_QUEUE : set_queue,
- OFPAT_GROUP : group,
- OFPAT_SET_NW_TTL : set_nw_ttl,
- OFPAT_DEC_NW_TTL : dec_nw_ttl,
- OFPAT_EXPERIMENTER : experimenter
-}
-
-class action_list(ofp_base_list):
- """
- Maintain a list of actions
-
- Data members:
- @arg actions: An array of action objects such as action_output, etc.
-
- Methods:
- @arg pack: Pack the structure into a string
- @arg unpack: Unpack a string to objects, with proper typing
- @arg add: Add an action to the list; you can directly access
- the action member, but add will validate that the added object
- is an action.
-
- """
-
- def __init__(self, actions=None):
- ofp_base_list.__init__(self)
- self.actions = self.items
- if actions:
- self.actions.extend(actions)
- self.name = "action"
- self.class_list = action_class_list
-
- def unpack(self, binary_string, bytes=None):
- """
- Unpack a list of actions
-
- Unpack actions from a binary string, creating an array
- of objects of the appropriate type
-
- @param binary_string The string to be unpacked
-
- @param bytes The total length of the action list in bytes.
- Ignored if decode is True. If None and decode is false, the
- list is assumed to extend through the entire string.
-
- @return The remainder of binary_string that was not parsed
-
- """
- if bytes == None:
- bytes = len(binary_string)
- bytes_done = 0
- count = 0
- cur_string = binary_string
- while bytes_done < bytes:
- hdr = ofp_action_header()
- hdr.unpack(cur_string)
- if hdr.len < OFP_ACTION_HEADER_BYTES:
- print "ERROR: Action too short"
- break
- if not hdr.type in action_object_map.keys():
- print "WARNING: Skipping unknown action ", hdr.type, hdr.len
- else:
- self.actions.append(action_object_map[hdr.type]())
- self.actions[count].unpack(cur_string)
- count += 1
- cur_string = cur_string[hdr.len:]
- bytes_done += hdr.len
- return cur_string
-
diff --git a/src/python/of12/base_list.py b/src/python/of12/base_list.py
deleted file mode 100644
index 938c68e..0000000
--- a/src/python/of12/base_list.py
+++ /dev/null
@@ -1,158 +0,0 @@
-
-"""
-Base list class for inheritance.
-Most of the list stuff is common; unpacking is the only thing that
-is left pure virtual.
-"""
-
-import copy
-
-class ofp_base_list(object):
- """
- Container type to maintain a list of ofp objects
-
- Data members:
- @arg items An array of objects
- @arg class_list A tuple of classes that may be added to the list;
- If None, no checking is done
- @arg name The name to use when displaying the list
-
- Methods:
- @arg pack Pack the structure into a string
- @arg unpack Unpack a string to objects, with proper typing
- @arg add Add an item to the list; you can directly access
- the item member, but add will validate that the added object
- is of the right type.
- @arg extend Add the items for another list to this list
-
- """
-
- def __init__(self):
- self.items = []
- self.class_list = None
- self.name = "unspecified"
-
- def pack(self):
- """
- Pack a list of items
-
- Returns the packed string
- """
- packed = ""
- for obj in self.items:
- packed += obj.pack()
- return packed
-
- def unpack(self, binary_string, bytes=None):
- """
- Pure virtual function for a list of items
-
- Unpack items from a binary string, creating an array
- of objects of the appropriate type
-
- @param binary_string The string to be unpacked
-
- @param bytes The total length of the list in bytes.
- Ignored if decode is True. If None and decode is false, the
- list is assumed to extend through the entire string.
-
- @return The remainder of binary_string that was not parsed
- """
- pass
-
- def add(self, item):
- """
- Add an item to a list
-
- @param item The item to add
- @return True if successful, False if not proper type object
-
- """
-
- # Note that the second arg of isinstance can be a list which
- # checks that the type of item is in the list
- if (self.class_list is not None) and \
- not isinstance(item, tuple(self.class_list)):
- return False
-
- tmp = copy.deepcopy(item)
- self.items.append(tmp)
- return True
-
- def remove_type(self, target):
- """
- Remove the first item on the list of the given type
-
- @param target The type of item to search
-
- @return The object removed, if any; otherwise None
-
- """
- for index in xrange(len(self.items)):
- if self.items[index].type == target:
- return self.items.pop(index)
- return None
-
- def find_type(self, target):
- """
- Find the first item on the list of the given type
-
- @param target The type of item to search
-
- @return The object with the matching type if any; otherwise None
-
- """
- for index in xrange(len(self.items)):
- if self.items[index].type == target:
- return self.items[index]
- return None
-
- def extend(self, other):
- """
- Add the items in other to this list
-
- @param other An object of the same type of list whose
- entries are to be merged into this list
-
- @return True if successful. If not successful, the list
- may have been modified.
-
- @todo Check if this is proper deep copy or not
-
- """
- for act in other.items:
- if not self.add(act):
- return False
- return True
-
- def __len__(self):
- """
- Length of the list packed as a string
- """
- length = 0
- for item in self.items:
- length += item.__len__()
- return length
-
- def __eq__(self, other):
- if type(self) != type(other):
- return False
- if self.items != other.items:
- return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- # Methods to make class iterable
- def __iter__(self):
- return self.items.__iter__()
-
- def show(self, prefix=''):
- outstr = prefix + self.name + "list with " + str(len(self.items)) + \
- " items\n"
- count = 0
- for obj in self.items:
- count += 1
- outstr += prefix + " " + self.name + " " + str(count) + ": \n"
- outstr += obj.show(prefix + ' ')
- return outstr
diff --git a/src/python/of12/bucket.py b/src/python/of12/bucket.py
deleted file mode 100644
index 64caed1..0000000
--- a/src/python/of12/bucket.py
+++ /dev/null
@@ -1,42 +0,0 @@
-
-# Python OpenFlow bucket wrapper class
-
-from cstruct import ofp_bucket
-from action_list import action_list
-
-
-
-class bucket(ofp_bucket):
- """
- Wrapper class for bucket object
-
- Data members inherited from ofp_bucket:
- @arg len
- @arg weight
- @arg watch_port
- @arg watch_group
-
- """
- def __init__(self):
- ofp_bucket.__init__(self)
- self.actions = action_list()
- self.type = None
- self.len = self.__len__()
- def show(self, prefix=''):
- outstr = prefix + "bucket\n"
- outstr += ofp_bucket.show(self, prefix)
- outstr += self.actions.show()
- return outstr
- def unpack(self, binary_string):
- binary_string = ofp_bucket.unpack(self, binary_string)
- self.actions = action_list()
- return self.actions.unpack(binary_string)
- def pack(self):
- self.len = len(self)
- packed = ""
- packed += ofp_bucket.pack(self)
- packed += self.actions.pack()
- return packed
- def __len__(self):
- return ofp_bucket.__len__(self) + self.actions.__len__()
-
diff --git a/src/python/of12/bucket_list.py b/src/python/of12/bucket_list.py
deleted file mode 100644
index 33d9472..0000000
--- a/src/python/of12/bucket_list.py
+++ /dev/null
@@ -1,52 +0,0 @@
-
-from base_list import ofp_base_list
-from bucket import bucket
-
-class bucket_list(ofp_base_list):
- """
- Maintain a list of instructions
-
- Data members:
- @arg instructions An array of instructions such as write_actions
-
- Methods:
- @arg pack: Pack the structure into a string
- @arg unpack: Unpack a string to objects, with proper typing
- @arg add: Add an action to the list; you can directly access
- the action member, but add will validate that the added object
- is an action.
-
- """
-
- def __init__(self):
- ofp_base_list.__init__(self)
- self.buckets = self.items
- self.name = "buckets"
- self.class_list = (bucket,)
-
- def unpack(self, binary_string, bytes=None):
- """
- Unpack a list of buckets
-
- Unpack buckets from a binary string, creating an array
- of objects of the appropriate type
-
- @param binary_string The string to be unpacked
-
- @param bytes The total length of the instruction list in bytes.
- Ignored if decode is True. If bytes is None and decode is false, the
- list is assumed to extend through the entire string.
-
- @return The remainder of binary_string that was not parsed
-
- """
- if bytes == None:
- bytes = len(binary_string)
- bytes_done = 0
- cur_string = binary_string
- while bytes_done < bytes:
- b = bucket()
- cur_string = b.unpack(cur_string)
- self.buckets.append(b)
- bytes_done += len(b)
- return cur_string
diff --git a/src/python/of12/class_maps.py b/src/python/of12/class_maps.py
deleted file mode 100644
index cd60deb..0000000
--- a/src/python/of12/class_maps.py
+++ /dev/null
@@ -1,346 +0,0 @@
-
-# Class to array member map
-class_to_members_map = {
- 'ofp_aggregate_stats_reply' : [
- 'packet_count',
- 'byte_count',
- 'flow_count'
- ],
- 'ofp_role_request' : [
- 'role',
- 'generation_id'
- ],
- 'ofp_table_stats' : [
- 'table_id',
- 'name',
- 'match',
- 'wildcards',
- 'write_actions',
- 'apply_actions',
- 'write_setfields',
- 'apply_setfields',
- 'metadata_match',
- 'metadata_write',
- 'instructions',
- 'config',
- 'max_entries',
- 'active_count',
- 'lookup_count',
- 'matched_count'
- ],
- 'ofp_table_mod' : [
- 'table_id',
- 'config'
- ],
- 'ofp_group_stats' : [
- 'length',
- 'group_id',
- 'ref_count',
- 'packet_count',
- 'byte_count'
- ],
- 'ofp_instruction_actions' : [
- 'type',
- 'len'
- ],
- 'ofp_queue_stats' : [
- 'port_no',
- 'queue_id',
- 'tx_bytes',
- 'tx_packets',
- 'tx_errors'
- ],
- 'ofp_packet_in' : [
- 'buffer_id',
- 'total_len',
- 'reason',
- 'table_id',
- 'match'
- ],
- 'ofp_error_experimenter_msg' : [
- 'type',
- 'exp_type',
- 'experimenter'
- ],
- 'ofp_bucket_counter' : [
- 'packet_count',
- 'byte_count'
- ],
- 'ofp_port_stats_request' : [
- 'port_no'
- ],
- 'ofp_stats_request' : [
- 'type',
- 'flags'
- ],
- 'ofp_instruction' : [
- 'type',
- 'len'
- ],
- 'ofp_group_stats_request' : [
- 'group_id'
- ],
- 'ofp_experimenter_header' : [
- 'experimenter',
- 'exp_type'
- ],
- 'ofp_aggregate_stats_request' : [
- 'table_id',
- 'out_port',
- 'out_group',
- 'cookie',
- 'cookie_mask',
- 'match'
- ],
- 'ofp_queue_get_config_request' : [
- 'port'
- ],
- 'ofp_action_nw_ttl' : [
- 'type',
- 'len',
- 'nw_ttl'
- ],
- 'ofp_port_status' : [
- 'reason',
- 'desc'
- ],
- 'ofp_action_header' : [
- 'type',
- 'len'
- ],
- 'ofp_port_mod' : [
- 'port_no',
- 'hw_addr',
- 'config',
- 'mask',
- 'advertise'
- ],
- 'ofp_action_output' : [
- 'type',
- 'len',
- 'port',
- 'max_len'
- ],
- 'ofp_switch_config' : [
- 'flags',
- 'miss_send_len'
- ],
- 'ofp_queue_prop_experimenter' : [
- 'prop_header',
- 'experimenter'
- ],
- 'ofp_instruction_write_metadata' : [
- 'type',
- 'len',
- 'metadata',
- 'metadata_mask'
- ],
- 'ofp_action_experimenter_header' : [
- 'type',
- 'len',
- 'experimenter'
- ],
- 'ofp_queue_get_config_reply' : [
- 'port'
- ],
- 'ofp_oxm_experimenter_header' : [
- 'oxm_header',
- 'experimenter'
- ],
- 'ofp_action_set_queue' : [
- 'type',
- 'len',
- 'queue_id'
- ],
- 'ofp_action_set_field' : [
- 'type',
- 'len',
- 'field'
- ],
- 'ofp_flow_stats' : [
- 'length',
- 'table_id',
- 'duration_sec',
- 'duration_nsec',
- 'priority',
- 'idle_timeout',
- 'hard_timeout',
- 'cookie',
- 'packet_count',
- 'byte_count',
- 'match'
- ],
- 'ofp_flow_removed' : [
- 'cookie',
- 'priority',
- 'reason',
- 'table_id',
- 'duration_sec',
- 'duration_nsec',
- 'idle_timeout',
- 'hard_timeout',
- 'packet_count',
- 'byte_count',
- 'match'
- ],
- 'ofp_queue_prop_min_rate' : [
- 'prop_header',
- 'rate'
- ],
- 'ofp_header' : [
- 'version',
- 'type',
- 'length',
- 'xid'
- ],
- 'ofp_stats_reply' : [
- 'type',
- 'flags'
- ],
- 'ofp_queue_stats_request' : [
- 'port_no',
- 'queue_id'
- ],
- 'ofp_group_features_stats' : [
- 'types',
- 'capabilities',
- 'max_groups',
- 'actions'
- ],
- 'ofp_group_mod' : [
- 'command',
- 'type',
- 'group_id'
- ],
- 'ofp_port_stats' : [
- 'port_no',
- 'rx_packets',
- 'tx_packets',
- 'rx_bytes',
- 'tx_bytes',
- 'rx_dropped',
- 'tx_dropped',
- 'rx_errors',
- 'tx_errors',
- 'rx_frame_err',
- 'rx_over_err',
- 'rx_crc_err',
- 'collisions'
- ],
- 'ofp_packet_queue' : [
- 'queue_id',
- 'port',
- 'len'
- ],
- 'ofp_port' : [
- 'port_no',
- 'hw_addr',
- 'name',
- 'config',
- 'state',
- 'curr',
- 'advertised',
- 'supported',
- 'peer',
- 'curr_speed',
- 'max_speed'
- ],
- 'ofp_switch_features' : [
- 'datapath_id',
- 'n_buffers',
- 'n_tables',
- 'capabilities',
- 'reserved'
- ],
- 'ofp_queue_prop_header' : [
- 'property',
- 'len'
- ],
- 'ofp_flow_stats_request' : [
- 'table_id',
- 'out_port',
- 'out_group',
- 'cookie',
- 'cookie_mask',
- 'match'
- ],
- 'ofp_bucket' : [
- 'len',
- 'weight',
- 'watch_port',
- 'watch_group'
- ],
- 'ofp_action_pop_mpls' : [
- 'type',
- 'len',
- 'ethertype'
- ],
- 'ofp_match' : [
- 'type',
- 'length'
- ],
- 'ofp_flow_mod' : [
- 'cookie',
- 'cookie_mask',
- 'table_id',
- 'command',
- 'idle_timeout',
- 'hard_timeout',
- 'priority',
- 'buffer_id',
- 'out_port',
- 'out_group',
- 'flags',
- 'match'
- ],
- 'ofp_packet_out' : [
- 'buffer_id',
- 'in_port',
- 'actions_len'
- ],
- 'ofp_instruction_goto_table' : [
- 'type',
- 'len',
- 'table_id'
- ],
- 'ofp_queue_prop_max_rate' : [
- 'prop_header',
- 'rate'
- ],
- 'ofp_experimenter_stats_header' : [
- 'experimenter',
- 'exp_type'
- ],
- 'ofp_action_group' : [
- 'type',
- 'len',
- 'group_id'
- ],
- 'ofp_desc_stats' : [
- 'mfr_desc',
- 'hw_desc',
- 'sw_desc',
- 'serial_num',
- 'dp_desc'
- ],
- 'ofp_action_push' : [
- 'type',
- 'len',
- 'ethertype'
- ],
- 'ofp_group_desc_stats' : [
- 'length',
- 'type',
- 'group_id'
- ],
- 'ofp_error_msg' : [
- 'type',
- 'code'
- ],
- 'ofp_action_mpls_ttl' : [
- 'type',
- 'len',
- 'mpls_ttl'
- ],
- '_ignore' : []
-}
diff --git a/src/python/of12/cstruct.py b/src/python/of12/cstruct.py
deleted file mode 100644
index 06f9ac9..0000000
--- a/src/python/of12/cstruct.py
+++ /dev/null
@@ -1,5922 +0,0 @@
-import struct
-
-# Structure definitions
-class ofp_hello(object):
- """Automatically generated Python class for ofp_hello
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 0):
- return binaryString
- return binaryString[0:]
-
- def __len__(self):
- """Return length of message
- """
- l = 0
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- return outstr
-
-
-class ofp_aggregate_stats_reply(object):
- """Automatically generated Python class for ofp_aggregate_stats_reply
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.packet_count = 0
- self.byte_count = 0
- self.flow_count = 0
- self.pad= [0,0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 4):
- return (False, "self.pad is not of size 4 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!QQL", self.packet_count, self.byte_count, self.flow_count)
- packed += struct.pack("!BBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 24):
- return binaryString
- fmt = '!QQL'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.packet_count, self.byte_count, self.flow_count) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 20
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[24:]
-
- def __len__(self):
- """Return length of message
- """
- l = 24
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.packet_count != other.packet_count: return False
- if self.byte_count != other.byte_count: return False
- if self.flow_count != other.flow_count: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'packet_count: ' + str(self.packet_count) + '\n'
- outstr += prefix + 'byte_count: ' + str(self.byte_count) + '\n'
- outstr += prefix + 'flow_count: ' + str(self.flow_count) + '\n'
- return outstr
-
-
-class ofp_role_request(object):
- """Automatically generated Python class for ofp_role_request
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.role = 0
- self.pad= [0,0,0,0]
- self.generation_id = 0
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 4):
- return (False, "self.pad is not of size 4 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!L", self.role)
- packed += struct.pack("!BBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3])
- packed += struct.pack("!Q", self.generation_id)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 16):
- return binaryString
- fmt = '!L'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.role,) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 4
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!Q'
- start = 8
- end = start + struct.calcsize(fmt)
- (self.generation_id,) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[16:]
-
- def __len__(self):
- """Return length of message
- """
- l = 16
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.role != other.role: return False
- if self.pad != other.pad: return False
- if self.generation_id != other.generation_id: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'role: ' + str(self.role) + '\n'
- outstr += prefix + 'generation_id: ' + str(self.generation_id) + '\n'
- return outstr
-
-
-class ofp_table_stats(object):
- """Automatically generated Python class for ofp_table_stats
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.table_id = 0
- self.pad= [0,0,0,0,0,0,0]
- self.name= ""
- self.match = 0
- self.wildcards = 0
- self.write_actions = 0
- self.apply_actions = 0
- self.write_setfields = 0
- self.apply_setfields = 0
- self.metadata_match = 0
- self.metadata_write = 0
- self.instructions = 0
- self.config = 0
- self.max_entries = 0
- self.active_count = 0
- self.lookup_count = 0
- self.matched_count = 0
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 7):
- return (False, "self.pad is not of size 7 as expected.")
- if(not isinstance(self.name, str)):
- return (False, "self.name is not string as expected.")
- if(len(self.name) > 32):
- return (False, "self.name is not of size 32 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!B", self.table_id)
- packed += struct.pack("!BBBBBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3], self.pad[4], self.pad[5], self.pad[6])
- packed += self.name.ljust(32,'\0')
- packed += struct.pack("!QQLLQQQQLLLLQQ", self.match, self.wildcards, self.write_actions, self.apply_actions, self.write_setfields, self.apply_setfields, self.metadata_match, self.metadata_write, self.instructions, self.config, self.max_entries, self.active_count, self.lookup_count, self.matched_count)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 128):
- return binaryString
- fmt = '!B'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.table_id,) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBBBBB'
- start = 1
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3], self.pad[4], self.pad[5], self.pad[6]) = struct.unpack(fmt, binaryString[start:end])
- self.name = binaryString[8:40].replace("\0","")
- fmt = '!QQLLQQQQLLLLQQ'
- start = 40
- end = start + struct.calcsize(fmt)
- (self.match, self.wildcards, self.write_actions, self.apply_actions, self.write_setfields, self.apply_setfields, self.metadata_match, self.metadata_write, self.instructions, self.config, self.max_entries, self.active_count, self.lookup_count, self.matched_count) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[128:]
-
- def __len__(self):
- """Return length of message
- """
- l = 128
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.table_id != other.table_id: return False
- if self.pad != other.pad: return False
- if self.name != other.name: return False
- if self.match != other.match: return False
- if self.wildcards != other.wildcards: return False
- if self.write_actions != other.write_actions: return False
- if self.apply_actions != other.apply_actions: return False
- if self.write_setfields != other.write_setfields: return False
- if self.apply_setfields != other.apply_setfields: return False
- if self.metadata_write != other.metadata_match: return False
- if self.metadata_write != other.metadata_write: return False
- if self.instructions != other.instructions: return False
- if self.config != other.config: return False
- if self.max_entries != other.max_entries: return False
- if self.active_count != other.active_count: return False
- if self.lookup_count != other.lookup_count: return False
- if self.matched_count != other.matched_count: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'table_id: ' + str(self.table_id) + '\n'
- outstr += prefix + 'name: ' + str(self.name) + '\n'
- outstr += prefix + 'match: ' + str(self.match) + '\n'
- outstr += prefix + 'wildcards: ' + str(self.wildcards) + '\n'
- outstr += prefix + 'write_actions: ' + str(self.write_actions) + '\n'
- outstr += prefix + 'apply_actions: ' + str(self.apply_actions) + '\n'
- outstr += prefix + 'write_setfields: ' + str(self.write_setfields) + '\n'
- outstr += prefix + 'apply_setfields: ' + str(self.apply_setfields) + '\n'
- outstr += prefix + 'metadata_match: ' + str(self.metadata_match) + '\n'
- outstr += prefix + 'metadata_write: ' + str(self.metadata_write) + '\n'
- outstr += prefix + 'instructions: ' + str(self.instructions) + '\n'
- outstr += prefix + 'config: ' + str(self.config) + '\n'
- outstr += prefix + 'max_entries: ' + str(self.max_entries) + '\n'
- outstr += prefix + 'active_count: ' + str(self.active_count) + '\n'
- outstr += prefix + 'lookup_count: ' + str(self.lookup_count) + '\n'
- outstr += prefix + 'matched_count: ' + str(self.matched_count) + '\n'
- return outstr
-
-
-class ofp_table_mod(object):
- """Automatically generated Python class for ofp_table_mod
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.table_id = 0
- self.pad= [0,0,0]
- self.config = 0
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 3):
- return (False, "self.pad is not of size 3 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!B", self.table_id)
- packed += struct.pack("!BBB", self.pad[0], self.pad[1], self.pad[2])
- packed += struct.pack("!L", self.config)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!B'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.table_id,) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBB'
- start = 1
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!L'
- start = 4
- end = start + struct.calcsize(fmt)
- (self.config,) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.table_id != other.table_id: return False
- if self.pad != other.pad: return False
- if self.config != other.config: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'table_id: ' + str(self.table_id) + '\n'
- outstr += prefix + 'config: ' + str(self.config) + '\n'
- return outstr
-
-
-class ofp_group_stats(object):
- """Automatically generated Python class for ofp_group_stats
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.length = 0
- self.pad= [0,0]
- self.group_id = 0
- self.ref_count = 0
- self.pad2= [0,0,0,0]
- self.packet_count = 0
- self.byte_count = 0
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 2):
- return (False, "self.pad is not of size 2 as expected.")
- if(not isinstance(self.pad2, list)):
- return (False, "self.pad2 is not list as expected.")
- if(len(self.pad2) != 4):
- return (False, "self.pad2 is not of size 4 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!H", self.length)
- packed += struct.pack("!BB", self.pad[0], self.pad[1])
- packed += struct.pack("!LL", self.group_id, self.ref_count)
- packed += struct.pack("!BBBB", self.pad2[0], self.pad2[1], self.pad2[2], self.pad2[3])
- packed += struct.pack("!QQ", self.packet_count, self.byte_count)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 32):
- return binaryString
- fmt = '!H'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.length,) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BB'
- start = 2
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!LL'
- start = 4
- end = start + struct.calcsize(fmt)
- (self.group_id, self.ref_count) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 12
- end = start + struct.calcsize(fmt)
- (self.pad2[0], self.pad2[1], self.pad2[2], self.pad2[3]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!QQ'
- start = 16
- end = start + struct.calcsize(fmt)
- (self.packet_count, self.byte_count) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[32:]
-
- def __len__(self):
- """Return length of message
- """
- l = 32
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.length != other.length: return False
- if self.pad != other.pad: return False
- if self.group_id != other.group_id: return False
- if self.ref_count != other.ref_count: return False
- if self.pad2 != other.pad2: return False
- if self.packet_count != other.packet_count: return False
- if self.byte_count != other.byte_count: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'length: ' + str(self.length) + '\n'
- outstr += prefix + 'group_id: ' + str(self.group_id) + '\n'
- outstr += prefix + 'ref_count: ' + str(self.ref_count) + '\n'
- outstr += prefix + 'packet_count: ' + str(self.packet_count) + '\n'
- outstr += prefix + 'byte_count: ' + str(self.byte_count) + '\n'
- return outstr
-
-
-class ofp_instruction_actions(object):
- """Automatically generated Python class for ofp_instruction_actions
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.pad= [0,0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 4):
- return (False, "self.pad is not of size 4 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HH", self.type, self.len)
- packed += struct.pack("!BBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 4
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- return outstr
-
-
-class ofp_queue_stats(object):
- """Automatically generated Python class for ofp_queue_stats
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.port_no = 0
- self.queue_id = 0
- self.tx_bytes = 0
- self.tx_packets = 0
- self.tx_errors = 0
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!LLQQQ", self.port_no, self.queue_id, self.tx_bytes, self.tx_packets, self.tx_errors)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 32):
- return binaryString
- fmt = '!LLQQQ'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.port_no, self.queue_id, self.tx_bytes, self.tx_packets, self.tx_errors) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[32:]
-
- def __len__(self):
- """Return length of message
- """
- l = 32
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.port_no != other.port_no: return False
- if self.queue_id != other.queue_id: return False
- if self.tx_bytes != other.tx_bytes: return False
- if self.tx_packets != other.tx_packets: return False
- if self.tx_errors != other.tx_errors: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'port_no: ' + str(self.port_no) + '\n'
- outstr += prefix + 'queue_id: ' + str(self.queue_id) + '\n'
- outstr += prefix + 'tx_bytes: ' + str(self.tx_bytes) + '\n'
- outstr += prefix + 'tx_packets: ' + str(self.tx_packets) + '\n'
- outstr += prefix + 'tx_errors: ' + str(self.tx_errors) + '\n'
- return outstr
-
-
-class ofp_packet_in(object):
- """Automatically generated Python class for ofp_packet_in
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.buffer_id = 0
- self.total_len = 0
- self.reason = 0
- self.table_id = 0
- self.match = ofp_match()
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.match, ofp_match)):
- return (False, "self.match is not class ofp_match as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!LHBB", self.buffer_id, self.total_len, self.reason, self.table_id)
- packed += self.match.pack()
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 12):
- return binaryString
- fmt = '!LHBB'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.buffer_id, self.total_len, self.reason, self.table_id) = struct.unpack(fmt, binaryString[start:end])
- self.match.unpack(binaryString[8:])
- return binaryString[12:]
-
- def __len__(self):
- """Return length of message
- """
- l = 12
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.buffer_id != other.buffer_id: return False
- if self.total_len != other.total_len: return False
- if self.reason != other.reason: return False
- if self.table_id != other.table_id: return False
- if self.match != other.match: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'buffer_id: ' + str(self.buffer_id) + '\n'
- outstr += prefix + 'total_len: ' + str(self.total_len) + '\n'
- outstr += prefix + 'reason: ' + str(self.reason) + '\n'
- outstr += prefix + 'table_id: ' + str(self.table_id) + '\n'
- outstr += prefix + 'match: \n'
- outstr += self.match.show(prefix + ' ')
- return outstr
-
-
-class ofp_error_experimenter_msg(object):
- """Automatically generated Python class for ofp_error_experimenter_msg
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.exp_type = 0
- self.experimenter = 0
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HHL", self.type, self.exp_type, self.experimenter)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HHL'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.exp_type, self.experimenter) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.exp_type != other.exp_type: return False
- if self.experimenter != other.experimenter: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'exp_type: ' + str(self.exp_type) + '\n'
- outstr += prefix + 'experimenter: ' + str(self.experimenter) + '\n'
- return outstr
-
-
-class ofp_bucket_counter(object):
- """Automatically generated Python class for ofp_bucket_counter
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.packet_count = 0
- self.byte_count = 0
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!QQ", self.packet_count, self.byte_count)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 16):
- return binaryString
- fmt = '!QQ'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.packet_count, self.byte_count) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[16:]
-
- def __len__(self):
- """Return length of message
- """
- l = 16
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.packet_count != other.packet_count: return False
- if self.byte_count != other.byte_count: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'packet_count: ' + str(self.packet_count) + '\n'
- outstr += prefix + 'byte_count: ' + str(self.byte_count) + '\n'
- return outstr
-
-
-class ofp_port_stats_request(object):
- """Automatically generated Python class for ofp_port_stats_request
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.port_no = 0
- self.pad= [0,0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 4):
- return (False, "self.pad is not of size 4 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!L", self.port_no)
- packed += struct.pack("!BBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!L'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.port_no,) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 4
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.port_no != other.port_no: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'port_no: ' + str(self.port_no) + '\n'
- return outstr
-
-
-class ofp_stats_request(object):
- """Automatically generated Python class for ofp_stats_request
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.flags = 0
- self.pad= [0,0,0,0]
-
- def __assert(self):
- """Sanity check
- """
-
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 4):
- return (False, "self.pad is not of size 4 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HH", self.type, self.flags)
- packed += struct.pack("!BBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.flags) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 4
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.flags != other.flags: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'flags: ' + str(self.flags) + '\n'
- return outstr
-
-
-class ofp_instruction(object):
- """Automatically generated Python class for ofp_instruction
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.pad= [0,0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 4):
- return (False, "self.pad is not of size 4 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HH", self.type, self.len)
- packed += struct.pack("!BBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 4
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- return outstr
-
-
-class ofp_group_stats_request(object):
- """Automatically generated Python class for ofp_group_stats_request
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.group_id = 0
- self.pad= [0,0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 4):
- return (False, "self.pad is not of size 4 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!L", self.group_id)
- packed += struct.pack("!BBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!L'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.group_id,) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 4
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.group_id != other.group_id: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'group_id: ' + str(self.group_id) + '\n'
- return outstr
-
-
-class ofp_experimenter_header(object):
- """Automatically generated Python class for ofp_experimenter_header
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.experimenter = 0
- self.exp_type = 0
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!LL", self.experimenter, self.exp_type)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!LL'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.experimenter, self.exp_type) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.experimenter != other.experimenter: return False
- if self.exp_type != other.exp_type: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'experimenter: ' + str(self.experimenter) + '\n'
- outstr += prefix + 'exp_type: ' + str(self.exp_type) + '\n'
- return outstr
-
-
-class ofp_aggregate_stats_request(object):
- """Automatically generated Python class for ofp_aggregate_stats_request
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.table_id = 0
- self.pad_asr= [0,0,0]
- self.out_port = 0
- self.out_group = 0
- self.pad_asr2= [0,0,0,0]
- self.cookie = 0
- self.cookie_mask = 0
- self.match = ofp_match()
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad_asr, list)):
- return (False, "self.pad_asr is not list as expected.")
- if(len(self.pad_asr) != 3):
- return (False, "self.pad_asr is not of size 3 as expected.")
- if(not isinstance(self.pad_asr2, list)):
- return (False, "self.pad_asr2 is not list as expected.")
- if(len(self.pad_asr2) != 4):
- return (False, "self.pad_asr2 is not of size 4 as expected.")
- if(not isinstance(self.match, ofp_match)):
- return (False, "self.match is not class ofp_match as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!B", self.table_id)
- packed += struct.pack("!BBB", self.pad_asr[0], self.pad_asr[1], self.pad_asr[2])
- packed += struct.pack("!LL", self.out_port, self.out_group)
- packed += struct.pack("!BBBB", self.pad_asr2[0], self.pad_asr2[1], self.pad_asr2[2], self.pad_asr2[3])
- packed += struct.pack("!QQ", self.cookie, self.cookie_mask)
- packed += self.match.pack()
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 36):
- return binaryString
- fmt = '!B'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.table_id,) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBB'
- start = 1
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad_asr[1], self.pad_asr[2]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!LL'
- start = 4
- end = start + struct.calcsize(fmt)
- (self.out_port, self.out_group) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 12
- end = start + struct.calcsize(fmt)
- (self.pad2[0], self.pad_asr2[1], self.pad_asr2[2], self.pad_asr2[3]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!QQ'
- start = 16
- end = start + struct.calcsize(fmt)
- (self.cookie, self.cookie_mask) = struct.unpack(fmt, binaryString[start:end])
- self.match.unpack(binaryString[32:])
- return binaryString[36:]
-
- def __len__(self):
- """Return length of message
- """
- l = 36
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.table_id != other.table_id: return False
- if self.pad != other.pad: return False
- if self.out_port != other.out_port: return False
- if self.out_group != other.out_group: return False
- if self.pad2 != other.pad2: return False
- if self.cookie != other.cookie: return False
- if self.cookie_mask != other.cookie_mask: return False
- if self.match != other.match: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'table_id: ' + str(self.table_id) + '\n'
- outstr += prefix + 'out_port: ' + str(self.out_port) + '\n'
- outstr += prefix + 'out_group: ' + str(self.out_group) + '\n'
- outstr += prefix + 'cookie: ' + str(self.cookie) + '\n'
- outstr += prefix + 'cookie_mask: ' + str(self.cookie_mask) + '\n'
- outstr += prefix + 'match: \n'
- outstr += self.match.show(prefix + ' ')
- return outstr
-
-
-class ofp_queue_get_config_request(object):
- """Automatically generated Python class for ofp_queue_get_config_request
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.port = 0
- self.pad= [0,0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 4):
- return (False, "self.pad is not of size 4 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!L", self.port)
- packed += struct.pack("!BBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!L'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.port,) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 4
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.port != other.port: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'port: ' + str(self.port) + '\n'
- return outstr
-
-
-class ofp_action_nw_ttl(object):
- """Automatically generated Python class for ofp_action_nw_ttl
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.nw_ttl = 0
- self.pad= [0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 3):
- return (False, "self.pad is not of size 3 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HHB", self.type, self.len, self.nw_ttl)
- packed += struct.pack("!BBB", self.pad[0], self.pad[1], self.pad[2])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HHB'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len, self.nw_ttl) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBB'
- start = 5
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.nw_ttl != other.nw_ttl: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- outstr += prefix + 'nw_ttl: ' + str(self.nw_ttl) + '\n'
- return outstr
-
-
-class ofp_port_status(object):
- """Automatically generated Python class for ofp_port_status
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.reason = 0
- self.pad= [0,0,0,0,0,0,0]
- self.desc = ofp_port()
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 7):
- return (False, "self.pad is not of size 7 as expected.")
- if(not isinstance(self.desc, ofp_port)):
- return (False, "self.desc is not class ofp_port as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!B", self.reason)
- packed += struct.pack("!BBBBBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3], self.pad[4], self.pad[5], self.pad[6])
- packed += self.desc.pack()
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 72):
- return binaryString
- fmt = '!B'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.reason,) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBBBBB'
- start = 1
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3], self.pad[4], self.pad[5], self.pad[6]) = struct.unpack(fmt, binaryString[start:end])
- self.desc.unpack(binaryString[8:])
- return binaryString[72:]
-
- def __len__(self):
- """Return length of message
- """
- l = 72
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.reason != other.reason: return False
- if self.pad != other.pad: return False
- if self.desc != other.desc: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'reason: ' + str(self.reason) + '\n'
- outstr += prefix + 'desc: \n'
- outstr += self.desc.show(prefix + ' ')
- return outstr
-
-
-class ofp_action_header(object):
- """Automatically generated Python class for ofp_action_header
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.pad= [0,0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 4):
- return (False, "self.pad is not of size 4 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HH", self.type, self.len)
- packed += struct.pack("!BBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 4
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- return outstr
-
-
-class ofp_port_mod(object):
- """Automatically generated Python class for ofp_port_mod
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.port_no = 0
- self.pad= [0,0,0,0]
- self.hw_addr= [0,0,0,0,0,0]
- self.pad2= [0,0]
- self.config = 0
- self.mask = 0
- self.advertise = 0
- self.pad3= [0,0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 4):
- return (False, "self.pad is not of size 4 as expected.")
- if(not isinstance(self.hw_addr, list)):
- return (False, "self.hw_addr is not list as expected.")
- if(len(self.hw_addr) != 6):
- return (False, "self.hw_addr is not of size 6 as expected.")
- if(not isinstance(self.pad2, list)):
- return (False, "self.pad2 is not list as expected.")
- if(len(self.pad2) != 2):
- return (False, "self.pad2 is not of size 2 as expected.")
- if(not isinstance(self.pad3, list)):
- return (False, "self.pad3 is not list as expected.")
- if(len(self.pad3) != 4):
- return (False, "self.pad3 is not of size 4 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!L", self.port_no)
- packed += struct.pack("!BBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3])
- packed += struct.pack("!BBBBBB", self.hw_addr[0], self.hw_addr[1], self.hw_addr[2], self.hw_addr[3], self.hw_addr[4], self.hw_addr[5])
- packed += struct.pack("!BB", self.pad2[0], self.pad2[1])
- packed += struct.pack("!LLL", self.config, self.mask, self.advertise)
- packed += struct.pack("!BBBB", self.pad3[0], self.pad3[1], self.pad3[2], self.pad3[3])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 32):
- return binaryString
- fmt = '!L'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.port_no,) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 4
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBBBB'
- start = 8
- end = start + struct.calcsize(fmt)
- (self.hw_addr[0], self.hw_addr[1], self.hw_addr[2], self.hw_addr[3], self.hw_addr[4], self.hw_addr[5]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BB'
- start = 14
- end = start + struct.calcsize(fmt)
- (self.pad2[0], self.pad2[1]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!LLL'
- start = 16
- end = start + struct.calcsize(fmt)
- (self.config, self.mask, self.advertise) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 28
- end = start + struct.calcsize(fmt)
- (self.pad3[0], self.pad3[1], self.pad3[2], self.pad3[3]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[32:]
-
- def __len__(self):
- """Return length of message
- """
- l = 32
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.port_no != other.port_no: return False
- if self.pad != other.pad: return False
- if self.hw_addr != other.hw_addr: return False
- if self.pad2 != other.pad2: return False
- if self.config != other.config: return False
- if self.mask != other.mask: return False
- if self.advertise != other.advertise: return False
- if self.pad3 != other.pad3: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'port_no: ' + str(self.port_no) + '\n'
- outstr += prefix + 'hw_addr: ' + str(self.hw_addr) + '\n'
- outstr += prefix + 'config: ' + str(self.config) + '\n'
- outstr += prefix + 'mask: ' + str(self.mask) + '\n'
- outstr += prefix + 'advertise: ' + str(self.advertise) + '\n'
- return outstr
-
-
-class ofp_action_output(object):
- """Automatically generated Python class for ofp_action_output
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.port = 0
- self.max_len = 0
- self.pad= [0,0,0,0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 6):
- return (False, "self.pad is not of size 6 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HHLH", self.type, self.len, self.port, self.max_len)
- packed += struct.pack("!BBBBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3], self.pad[4], self.pad[5])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 16):
- return binaryString
- fmt = '!HHLH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len, self.port, self.max_len) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBBBB'
- start = 10
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3], self.pad[4], self.pad[5]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[16:]
-
- def __len__(self):
- """Return length of message
- """
- l = 16
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.port != other.port: return False
- if self.max_len != other.max_len: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- outstr += prefix + 'port: ' + str(self.port) + '\n'
- outstr += prefix + 'max_len: ' + str(self.max_len) + '\n'
- return outstr
-
-
-class ofp_switch_config(object):
- """Automatically generated Python class for ofp_switch_config
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.flags = 0
- self.miss_send_len = 128
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HH", self.flags, self.miss_send_len)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 4):
- return binaryString
- fmt = '!HH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.flags, self.miss_send_len) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[4:]
-
- def __len__(self):
- """Return length of message
- """
- l = 4
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): 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 show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'flags: ' + str(self.flags) + '\n'
- outstr += prefix + 'miss_send_len: ' + str(self.miss_send_len) + '\n'
- return outstr
-
-
-class ofp_queue_prop_experimenter(object):
- """Automatically generated Python class for ofp_queue_prop_experimenter
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.prop_header = ofp_queue_prop_header()
- self.experimenter = 0
- self.pad= [0,0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.prop_header, ofp_queue_prop_header)):
- return (False, "self.prop_header is not class ofp_queue_prop_header as expected.")
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 4):
- return (False, "self.pad is not of size 4 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += self.prop_header.pack()
- packed += struct.pack("!L", self.experimenter)
- packed += struct.pack("!BBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 16):
- return binaryString
- self.prop_header.unpack(binaryString[0:])
- fmt = '!L'
- start = 8
- end = start + struct.calcsize(fmt)
- (self.experimenter,) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 12
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[16:]
-
- def __len__(self):
- """Return length of message
- """
- l = 16
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.prop_header != other.prop_header: return False
- if self.experimenter != other.experimenter: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'prop_header: \n'
- outstr += self.prop_header.show(prefix + ' ')
- outstr += prefix + 'experimenter: ' + str(self.experimenter) + '\n'
- return outstr
-
-
-class ofp_instruction_write_metadata(object):
- """Automatically generated Python class for ofp_instruction_write_metadata
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.pad= [0,0,0,0]
- self.metadata = 0
- self.metadata_mask = 0
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 4):
- return (False, "self.pad is not of size 4 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HH", self.type, self.len)
- packed += struct.pack("!BBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3])
- packed += struct.pack("!QQ", self.metadata, self.metadata_mask)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 24):
- return binaryString
- fmt = '!HH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 4
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!QQ'
- start = 8
- end = start + struct.calcsize(fmt)
- (self.metadata, self.metadata_mask) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[24:]
-
- def __len__(self):
- """Return length of message
- """
- l = 24
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.pad != other.pad: return False
- if self.metadata != other.metadata: return False
- if self.metadata_mask != other.metadata_mask: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- outstr += prefix + 'metadata: ' + str(self.metadata) + '\n'
- outstr += prefix + 'metadata_mask: ' + str(self.metadata_mask) + '\n'
- return outstr
-
-
-class ofp_action_experimenter_header(object):
- """Automatically generated Python class for ofp_action_experimenter_header
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.experimenter = 0
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HHL", self.type, self.len, self.experimenter)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HHL'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len, self.experimenter) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.experimenter != other.experimenter: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- outstr += prefix + 'experimenter: ' + str(self.experimenter) + '\n'
- return outstr
-
-
-class ofp_queue_get_config_reply(object):
- """Automatically generated Python class for ofp_queue_get_config_reply
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.port = 0
- self.pad= [0,0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 4):
- return (False, "self.pad is not of size 4 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!L", self.port)
- packed += struct.pack("!BBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!L'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.port,) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 4
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.port != other.port: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'port: ' + str(self.port) + '\n'
- return outstr
-
-
-class ofp_oxm_experimenter_header(object):
- """Automatically generated Python class for ofp_oxm_experimenter_header
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.oxm_header = 0
- self.experimenter = 0
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!LL", self.oxm_header, self.experimenter)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!LL'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.oxm_header, self.experimenter) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.oxm_header != other.oxm_header: return False
- if self.experimenter != other.experimenter: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'oxm_header: ' + str(self.oxm_header) + '\n'
- outstr += prefix + 'experimenter: ' + str(self.experimenter) + '\n'
- return outstr
-
-
-class ofp_action_set_queue(object):
- """Automatically generated Python class for ofp_action_set_queue
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.queue_id = 0
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HHL", self.type, self.len, self.queue_id)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HHL'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len, self.queue_id) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.queue_id != other.queue_id: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- outstr += prefix + 'queue_id: ' + str(self.queue_id) + '\n'
- return outstr
-
-
-class ofp_action_set_field(object):
- """Automatically generated Python class for ofp_action_set_field
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.field= [0,0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.field, list)):
- return (False, "self.field is not list as expected.")
- if(len(self.field) != 4):
- return (False, "self.field is not of size 4 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HH", self.type, self.len)
- packed += struct.pack("!BBBB", self.field[0], self.field[1], self.field[2], self.field[3])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 4
- end = start + struct.calcsize(fmt)
- (self.field[0], self.field[1], self.field[2], self.field[3]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.field != other.field: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- outstr += prefix + 'field: ' + str(self.field) + '\n'
- return outstr
-
-
-class ofp_flow_stats(object):
- """Automatically generated Python class for ofp_flow_stats
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.length = 0
- self.table_id = 0
- self.pad = 0
- self.duration_sec = 0
- self.duration_nsec = 0
- self.priority = 0x8000
- self.idle_timeout = 0
- self.hard_timeout = 0
- self.pad2= [0,0,0,0,0,0]
- self.cookie = 0
- self.packet_count = 0
- self.byte_count = 0
- self.match = ofp_match()
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad2, list)):
- return (False, "self.pad2 is not list as expected.")
- if(len(self.pad2) != 6):
- return (False, "self.pad2 is not of size 6 as expected.")
- if(not isinstance(self.match, ofp_match)):
- return (False, "self.match is not class ofp_match as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HBBLLHHH", self.length, self.table_id, self.pad, self.duration_sec, self.duration_nsec, self.priority, self.idle_timeout, self.hard_timeout)
- packed += struct.pack("!BBBBBB", self.pad2[0], self.pad2[1], self.pad2[2], self.pad2[3], self.pad2[4], self.pad2[5])
- packed += struct.pack("!QQQ", self.cookie, self.packet_count, self.byte_count)
- packed += self.match.pack()
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 52):
- return binaryString
- fmt = '!HBBLLHHH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.length, self.table_id, self.pad, self.duration_sec, self.duration_nsec, self.priority, self.idle_timeout, self.hard_timeout) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBBBB'
- start = 18
- end = start + struct.calcsize(fmt)
- (self.pad2[0], self.pad2[1], self.pad2[2], self.pad2[3], self.pad2[4], self.pad2[5]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!QQQ'
- start = 24
- end = start + struct.calcsize(fmt)
- (self.cookie, self.packet_count, self.byte_count) = struct.unpack(fmt, binaryString[start:end])
- self.match.unpack(binaryString[48:])
- return binaryString[52:]
-
- def __len__(self):
- """Return length of message
- """
- l = 52
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.length != other.length: return False
- if self.table_id != other.table_id: return False
- if self.pad != other.pad: return False
- if self.duration_sec != other.duration_sec: return False
- if self.duration_nsec != other.duration_nsec: return False
- if self.priority != other.priority: return False
- if self.idle_timeout != other.idle_timeout: return False
- if self.hard_timeout != other.hard_timeout: return False
- if self.pad2 != other.pad2: return False
- if self.cookie != other.cookie: return False
- if self.packet_count != other.packet_count: return False
- if self.byte_count != other.byte_count: return False
- if self.match != other.match: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'length: ' + str(self.length) + '\n'
- outstr += prefix + 'table_id: ' + str(self.table_id) + '\n'
- outstr += prefix + 'duration_sec: ' + str(self.duration_sec) + '\n'
- outstr += prefix + 'duration_nsec: ' + str(self.duration_nsec) + '\n'
- outstr += prefix + 'priority: ' + str(self.priority) + '\n'
- outstr += prefix + 'idle_timeout: ' + str(self.idle_timeout) + '\n'
- outstr += prefix + 'hard_timeout: ' + str(self.hard_timeout) + '\n'
- outstr += prefix + 'cookie: ' + str(self.cookie) + '\n'
- outstr += prefix + 'packet_count: ' + str(self.packet_count) + '\n'
- outstr += prefix + 'byte_count: ' + str(self.byte_count) + '\n'
- outstr += prefix + 'match: \n'
- outstr += self.match.show(prefix + ' ')
- return outstr
-
-
-class ofp_flow_removed(object):
- """Automatically generated Python class for ofp_flow_removed
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.cookie = 0
- self.priority = 0
- self.reason = 0
- self.table_id = 0
- self.duration_sec = 0
- self.duration_nsec = 0
- self.idle_timeout = 0
- self.hard_timeout = 0
- self.packet_count = 0
- self.byte_count = 0
- self.match = ofp_match()
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.match, ofp_match)):
- return (False, "self.match is not class ofp_match as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!QHBBLLHHQQ", self.cookie, self.priority, self.reason, self.table_id, self.duration_sec, self.duration_nsec, self.idle_timeout, self.hard_timeout, self.packet_count, self.byte_count)
- packed += self.match.pack()
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 44):
- return binaryString
- fmt = '!QHBBLLHHQQ'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.cookie, self.priority, self.reason, self.table_id, self.duration_sec, self.duration_nsec, self.idle_timeout, self.hard_timeout, self.packet_count, self.byte_count) = struct.unpack(fmt, binaryString[start:end])
- self.match.unpack(binaryString[40:])
- return binaryString[44:]
-
- def __len__(self):
- """Return length of message
- """
- l = 44
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.cookie != other.cookie: return False
- if self.priority != other.priority: return False
- if self.reason != other.reason: return False
- if self.table_id != other.table_id: return False
- if self.duration_sec != other.duration_sec: return False
- if self.duration_nsec != other.duration_nsec: return False
- if self.idle_timeout != other.idle_timeout: return False
- if self.hard_timeout != other.hard_timeout: return False
- if self.packet_count != other.packet_count: return False
- if self.byte_count != other.byte_count: return False
- if self.match != other.match: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'cookie: ' + str(self.cookie) + '\n'
- outstr += prefix + 'priority: ' + str(self.priority) + '\n'
- outstr += prefix + 'reason: ' + str(self.reason) + '\n'
- outstr += prefix + 'table_id: ' + str(self.table_id) + '\n'
- outstr += prefix + 'duration_sec: ' + str(self.duration_sec) + '\n'
- outstr += prefix + 'duration_nsec: ' + str(self.duration_nsec) + '\n'
- outstr += prefix + 'idle_timeout: ' + str(self.idle_timeout) + '\n'
- outstr += prefix + 'hard_timeout: ' + str(self.hard_timeout) + '\n'
- outstr += prefix + 'packet_count: ' + str(self.packet_count) + '\n'
- outstr += prefix + 'byte_count: ' + str(self.byte_count) + '\n'
- outstr += prefix + 'match: \n'
- outstr += self.match.show(prefix + ' ')
- return outstr
-
-
-class ofp_queue_prop_min_rate(object):
- """Automatically generated Python class for ofp_queue_prop_min_rate
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.prop_header = ofp_queue_prop_header()
- self.rate = 0
- self.pad= [0,0,0,0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.prop_header, ofp_queue_prop_header)):
- return (False, "self.prop_header is not class ofp_queue_prop_header as expected.")
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 6):
- return (False, "self.pad is not of size 6 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += self.prop_header.pack()
- packed += struct.pack("!H", self.rate)
- packed += struct.pack("!BBBBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3], self.pad[4], self.pad[5])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 16):
- return binaryString
- self.prop_header.unpack(binaryString[0:])
- fmt = '!H'
- start = 8
- end = start + struct.calcsize(fmt)
- (self.rate,) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBBBB'
- start = 10
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3], self.pad[4], self.pad[5]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[16:]
-
- def __len__(self):
- """Return length of message
- """
- l = 16
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.prop_header != other.prop_header: return False
- if self.rate != other.rate: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'prop_header: \n'
- outstr += self.prop_header.show(prefix + ' ')
- outstr += prefix + 'rate: ' + str(self.rate) + '\n'
- return outstr
-
-
-class ofp_header(object):
- """Automatically generated Python class for ofp_header
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.version = 0x03
- self.type = 0
- self.length = 0
- self.xid = 0
-
- def __assert(self):
- """Sanity check
- """
- if (not (self.type in ofp_type_map.keys())):
- return (False, "type must have values from ofp_type_map.keys()")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!BBHL", self.version, self.type, self.length, self.xid)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!BBHL'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.version, self.type, self.length, self.xid) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.version != other.version: return False
- if self.type != other.type: return False
- if self.length != other.length: return False
- if self.xid != other.xid: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'version: ' + str(self.version) + '\n'
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'length: ' + str(self.length) + '\n'
- outstr += prefix + 'xid: ' + str(self.xid) + '\n'
- return outstr
-
-
-class ofp_stats_reply(object):
- """Automatically generated Python class for ofp_stats_reply
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.flags = 0
- self.pad= [0,0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 4):
- return (False, "self.pad is not of size 4 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HH", self.type, self.flags)
- packed += struct.pack("!BBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.flags) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 4
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.flags != other.flags: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'flags: ' + str(self.flags) + '\n'
- return outstr
-
-
-class ofp_queue_stats_request(object):
- """Automatically generated Python class for ofp_queue_stats_request
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.port_no = 0
- self.queue_id = 0
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!LL", self.port_no, self.queue_id)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!LL'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.port_no, self.queue_id) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): 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 show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'port_no: ' + str(self.port_no) + '\n'
- outstr += prefix + 'queue_id: ' + str(self.queue_id) + '\n'
- return outstr
-
-
-class ofp_group_features_stats(object):
- """Automatically generated Python class for ofp_group_features_stats
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.types = 0
- self.capabilities = 0
- self.max_groups= [0,0,0,0]
- self.actions= [0,0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.max_groups, list)):
- return (False, "self.max_groups is not list as expected.")
- if(len(self.max_groups) != 4):
- return (False, "self.max_groups is not of size 4 as expected.")
- if(not isinstance(self.actions, list)):
- return (False, "self.actions is not list as expected.")
- if(len(self.actions) != 4):
- return (False, "self.actions is not of size 4 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!LL", self.types, self.capabilities)
- packed += struct.pack("!LLLL", self.max_groups[0], self.max_groups[1], self.max_groups[2], self.max_groups[3])
- packed += struct.pack("!LLLL", self.actions[0], self.actions[1], self.actions[2], self.actions[3])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 40):
- return binaryString
- fmt = '!LL'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.types, self.capabilities) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!LLLL'
- start = 8
- end = start + struct.calcsize(fmt)
- (self.max_groups[0], self.max_groups[1], self.max_groups[2], self.max_groups[3]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!LLLL'
- start = 24
- end = start + struct.calcsize(fmt)
- (self.actions[0], self.actions[1], self.actions[2], self.actions[3]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[40:]
-
- def __len__(self):
- """Return length of message
- """
- l = 40
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.types != other.types: return False
- if self.capabilities != other.capabilities: return False
- if self.max_groups != other.max_groups: return False
- if self.actions != other.actions: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'types: ' + str(self.types) + '\n'
- outstr += prefix + 'capabilities: ' + str(self.capabilities) + '\n'
- outstr += prefix + 'max_groups: ' + str(self.max_groups) + '\n'
- outstr += prefix + 'actions: ' + str(self.actions) + '\n'
- return outstr
-
-
-class ofp_group_mod(object):
- """Automatically generated Python class for ofp_group_mod
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.command = 0
- self.type = 0
- self.pad = 0
- self.group_id = 0
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HBBL", self.command, self.type, self.pad, self.group_id)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HBBL'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.command, self.type, self.pad, self.group_id) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.command != other.command: return False
- if self.type != other.type: return False
- if self.pad != other.pad: return False
- if self.group_id != other.group_id: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'command: ' + str(self.command) + '\n'
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'group_id: ' + str(self.group_id) + '\n'
- return outstr
-
-
-class ofp_port_stats(object):
- """Automatically generated Python class for ofp_port_stats
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.port_no = 0
- self.pad= [0,0,0,0]
- self.rx_packets = 0
- self.tx_packets = 0
- self.rx_bytes = 0
- self.tx_bytes = 0
- self.rx_dropped = 0
- self.tx_dropped = 0
- self.rx_errors = 0
- self.tx_errors = 0
- self.rx_frame_err = 0
- self.rx_over_err = 0
- self.rx_crc_err = 0
- self.collisions = 0
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 4):
- return (False, "self.pad is not of size 4 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!L", self.port_no)
- packed += struct.pack("!BBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3])
- packed += struct.pack("!QQQQQQQQQQQQ", self.rx_packets, self.tx_packets, self.rx_bytes, self.tx_bytes, self.rx_dropped, self.tx_dropped, self.rx_errors, self.tx_errors, self.rx_frame_err, self.rx_over_err, self.rx_crc_err, self.collisions)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 104):
- return binaryString
- fmt = '!L'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.port_no,) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 4
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!QQQQQQQQQQQQ'
- start = 8
- end = start + struct.calcsize(fmt)
- (self.rx_packets, self.tx_packets, self.rx_bytes, self.tx_bytes, self.rx_dropped, self.tx_dropped, self.rx_errors, self.tx_errors, self.rx_frame_err, self.rx_over_err, self.rx_crc_err, self.collisions) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[104:]
-
- def __len__(self):
- """Return length of message
- """
- l = 104
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.port_no != other.port_no: return False
- if self.pad != other.pad: return False
- if self.rx_packets != other.rx_packets: return False
- if self.tx_packets != other.tx_packets: return False
- if self.rx_bytes != other.rx_bytes: return False
- if self.tx_bytes != other.tx_bytes: return False
- if self.rx_dropped != other.rx_dropped: return False
- if self.tx_dropped != other.tx_dropped: return False
- if self.rx_errors != other.rx_errors: return False
- if self.tx_errors != other.tx_errors: return False
- if self.rx_frame_err != other.rx_frame_err: return False
- if self.rx_over_err != other.rx_over_err: return False
- if self.rx_crc_err != other.rx_crc_err: return False
- if self.collisions != other.collisions: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'port_no: ' + str(self.port_no) + '\n'
- outstr += prefix + 'rx_packets: ' + str(self.rx_packets) + '\n'
- outstr += prefix + 'tx_packets: ' + str(self.tx_packets) + '\n'
- outstr += prefix + 'rx_bytes: ' + str(self.rx_bytes) + '\n'
- outstr += prefix + 'tx_bytes: ' + str(self.tx_bytes) + '\n'
- outstr += prefix + 'rx_dropped: ' + str(self.rx_dropped) + '\n'
- outstr += prefix + 'tx_dropped: ' + str(self.tx_dropped) + '\n'
- outstr += prefix + 'rx_errors: ' + str(self.rx_errors) + '\n'
- outstr += prefix + 'tx_errors: ' + str(self.tx_errors) + '\n'
- outstr += prefix + 'rx_frame_err: ' + str(self.rx_frame_err) + '\n'
- outstr += prefix + 'rx_over_err: ' + str(self.rx_over_err) + '\n'
- outstr += prefix + 'rx_crc_err: ' + str(self.rx_crc_err) + '\n'
- outstr += prefix + 'collisions: ' + str(self.collisions) + '\n'
- return outstr
-
-
-class ofp_packet_queue(object):
- """Automatically generated Python class for ofp_packet_queue
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.queue_id = 0
- self.port = 0
- self.len = 0
- self.pad= [0,0,0,0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 6):
- return (False, "self.pad is not of size 6 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!LLH", self.queue_id, self.port, self.len)
- packed += struct.pack("!BBBBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3], self.pad[4], self.pad[5])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 16):
- return binaryString
- fmt = '!LLH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.queue_id, self.port, self.len) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBBBB'
- start = 10
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3], self.pad[4], self.pad[5]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[16:]
-
- def __len__(self):
- """Return length of message
- """
- l = 16
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.queue_id != other.queue_id: return False
- if self.port != other.port: return False
- if self.len != other.len: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'queue_id: ' + str(self.queue_id) + '\n'
- outstr += prefix + 'port: ' + str(self.port) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- return outstr
-
-
-class ofp_port(object):
- """Automatically generated Python class for ofp_port
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.port_no = 0
- self.pad= [0,0,0,0]
- self.hw_addr= [0,0,0,0,0,0]
- self.pad2= [0,0]
- self.name= ""
- self.config = 0
- self.state = 0
- self.curr = 0
- self.advertised = 0
- self.supported = 0
- self.peer = 0
- self.curr_speed = 0
- self.max_speed = 0
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 4):
- return (False, "self.pad is not of size 4 as expected.")
- if(not isinstance(self.hw_addr, list)):
- return (False, "self.hw_addr is not list as expected.")
- if(len(self.hw_addr) != 6):
- return (False, "self.hw_addr is not of size 6 as expected.")
- if(not isinstance(self.pad2, list)):
- return (False, "self.pad2 is not list as expected.")
- if(len(self.pad2) != 2):
- return (False, "self.pad2 is not of size 2 as expected.")
- if(not isinstance(self.name, str)):
- return (False, "self.name is not string as expected.")
- if(len(self.name) > 16):
- return (False, "self.name is not of size 16 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!L", self.port_no)
- packed += struct.pack("!BBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3])
- packed += struct.pack("!BBBBBB", self.hw_addr[0], self.hw_addr[1], self.hw_addr[2], self.hw_addr[3], self.hw_addr[4], self.hw_addr[5])
- packed += struct.pack("!BB", self.pad2[0], self.pad2[1])
- packed += self.name.ljust(16,'\0')
- packed += struct.pack("!LLLLLLLL", self.config, self.state, self.curr, self.advertised, self.supported, self.peer, self.curr_speed, self.max_speed)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 64):
- return binaryString
- fmt = '!L'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.port_no,) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 4
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBBBB'
- start = 8
- end = start + struct.calcsize(fmt)
- (self.hw_addr[0], self.hw_addr[1], self.hw_addr[2], self.hw_addr[3], self.hw_addr[4], self.hw_addr[5]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BB'
- start = 14
- end = start + struct.calcsize(fmt)
- (self.pad2[0], self.pad2[1]) = struct.unpack(fmt, binaryString[start:end])
- self.name = binaryString[16:32].replace("\0","")
- fmt = '!LLLLLLLL'
- start = 32
- end = start + struct.calcsize(fmt)
- (self.config, self.state, self.curr, self.advertised, self.supported, self.peer, self.curr_speed, self.max_speed) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[64:]
-
- def __len__(self):
- """Return length of message
- """
- l = 64
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.port_no != other.port_no: return False
- if self.pad != other.pad: return False
- if self.hw_addr != other.hw_addr: return False
- if self.pad2 != other.pad2: return False
- if self.name != other.name: return False
- if self.config != other.config: return False
- if self.state != other.state: return False
- if self.curr != other.curr: return False
- if self.advertised != other.advertised: return False
- if self.supported != other.supported: return False
- if self.peer != other.peer: return False
- if self.curr_speed != other.curr_speed: return False
- if self.max_speed != other.max_speed: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'port_no: ' + str(self.port_no) + '\n'
- outstr += prefix + 'hw_addr: ' + str(self.hw_addr) + '\n'
- outstr += prefix + 'name: ' + str(self.name) + '\n'
- outstr += prefix + 'config: ' + str(self.config) + '\n'
- outstr += prefix + 'state: ' + str(self.state) + '\n'
- outstr += prefix + 'curr: ' + str(self.curr) + '\n'
- outstr += prefix + 'advertised: ' + str(self.advertised) + '\n'
- outstr += prefix + 'supported: ' + str(self.supported) + '\n'
- outstr += prefix + 'peer: ' + str(self.peer) + '\n'
- outstr += prefix + 'curr_speed: ' + str(self.curr_speed) + '\n'
- outstr += prefix + 'max_speed: ' + str(self.max_speed) + '\n'
- return outstr
-
-
-class ofp_switch_features(object):
- """Automatically generated Python class for ofp_switch_features
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.datapath_id = 0
- self.n_buffers = 0
- self.n_tables = 0
- self.pad= [0,0,0]
- self.capabilities = 0
- self.reserved = 0
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 3):
- return (False, "self.pad is not of size 3 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!QLB", self.datapath_id, self.n_buffers, self.n_tables)
- packed += struct.pack("!BBB", self.pad[0], self.pad[1], self.pad[2])
- packed += struct.pack("!LL", self.capabilities, self.reserved)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 24):
- return binaryString
- fmt = '!QLB'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.datapath_id, self.n_buffers, self.n_tables) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBB'
- start = 13
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!LL'
- start = 16
- end = start + struct.calcsize(fmt)
- (self.capabilities, self.reserved) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[24:]
-
- def __len__(self):
- """Return length of message
- """
- l = 24
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.datapath_id != other.datapath_id: return False
- if self.n_buffers != other.n_buffers: return False
- if self.n_tables != other.n_tables: return False
- if self.pad != other.pad: return False
- if self.capabilities != other.capabilities: return False
- if self.reserved != other.reserved: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'datapath_id: ' + str(self.datapath_id) + '\n'
- outstr += prefix + 'n_buffers: ' + str(self.n_buffers) + '\n'
- outstr += prefix + 'n_tables: ' + str(self.n_tables) + '\n'
- outstr += prefix + 'capabilities: ' + str(self.capabilities) + '\n'
- outstr += prefix + 'reserved: ' + str(self.reserved) + '\n'
- return outstr
-
-
-class ofp_queue_prop_header(object):
- """Automatically generated Python class for ofp_queue_prop_header
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.property = 0
- self.len = 0
- self.pad= [0,0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 4):
- return (False, "self.pad is not of size 4 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HH", self.property, self.len)
- packed += struct.pack("!BBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.property, self.len) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 4
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.property != other.property: return False
- if self.len != other.len: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'property: ' + str(self.property) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- return outstr
-
-
-class ofp_flow_stats_request(object):
- """Automatically generated Python class for ofp_flow_stats_request
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.table_id = 0
- self.pad_fstat= [0,0,0]
- self.out_port = 0
- self.out_group = 0
- self.pad_fstat2= [0,0,0,0]
- self.cookie = 0
- self.cookie_mask = 0
- self.match = ofp_match()
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad_fstat is not list as expected.")
- if(len(self.pad_fstat) != 3):
- return (False, "self.pad_fstat is not of size 3 as expected.")
- if(not isinstance(self.pad_fstat2, list)):
- return (False, "self.pad_fstat2 is not list as expected.")
- if(len(self.pad_fstat2) != 4):
- return (False, "self.pad_ftsat2 is not of size 4 as expected.")
- if(not isinstance(self.match, ofp_match)):
- return (False, "self.match is not class ofp_match as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!B", self.table_id)
- packed += struct.pack("!BBB", self.pad_fstat[0], self.pad_fstat[1], self.pad_fstat[2])
- packed += struct.pack("!LL", self.out_port, self.out_group)
- packed += struct.pack("!BBBB", self.pad_fstat2[0], self.pad_fstat2[1], self.pad_fstat2[2], self.pad_fstat2[3])
- packed += struct.pack("!QQ", self.cookie, self.cookie_mask)
- packed += self.match.pack()
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 36):
- return binaryString
- fmt = '!B'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.table_id,) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBB'
- start = 1
- end = start + struct.calcsize(fmt)
- (self.pad_fstat[0], self.pad_fstat[1], self.pad_fstat[2]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!LL'
- start = 4
- end = start + struct.calcsize(fmt)
- (self.out_port, self.out_group) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 12
- end = start + struct.calcsize(fmt)
- (self.pad_fstat2[0], self.pad_fstat2[1], self.pad_fstat2[2], self.pad_fstat2[3]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!QQ'
- start = 16
- end = start + struct.calcsize(fmt)
- (self.cookie, self.cookie_mask) = struct.unpack(fmt, binaryString[start:end])
- self.match.unpack(binaryString[32:])
- return binaryString[36:]
-
- def __len__(self):
- """Return length of message
- """
- l = 36
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.table_id != other.table_id: return False
- if self.pad_fstat != other.pad_fstat: return False
- if self.out_port != other.out_port: return False
- if self.out_group != other.out_group: return False
- if self.pad_fstat2 != other.pad_fstat2: return False
- if self.cookie != other.cookie: return False
- if self.cookie_mask != other.cookie_mask: return False
- if self.match != other.match: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'table_id: ' + str(self.table_id) + '\n'
- outstr += prefix + 'out_port: ' + str(self.out_port) + '\n'
- outstr += prefix + 'out_group: ' + str(self.out_group) + '\n'
- outstr += prefix + 'cookie: ' + str(self.cookie) + '\n'
- outstr += prefix + 'cookie_mask: ' + str(self.cookie_mask) + '\n'
- outstr += prefix + 'match: \n'
- outstr += self.match.show(prefix + ' ')
- return outstr
-
-
-class ofp_bucket(object):
- """Automatically generated Python class for ofp_bucket
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.len = 0
- self.weight = 0
- self.watch_port = 0
- self.watch_group = 0
- self.pad= [0,0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 4):
- return (False, "self.pad is not of size 4 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HHLL", self.len, self.weight, self.watch_port, self.watch_group)
- packed += struct.pack("!BBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 16):
- return binaryString
- fmt = '!HHLL'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.len, self.weight, self.watch_port, self.watch_group) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 12
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[16:]
-
- def __len__(self):
- """Return length of message
- """
- l = 16
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.len != other.len: return False
- if self.weight != other.weight: return False
- if self.watch_port != other.watch_port: return False
- if self.watch_group != other.watch_group: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- outstr += prefix + 'weight: ' + str(self.weight) + '\n'
- outstr += prefix + 'watch_port: ' + str(self.watch_port) + '\n'
- outstr += prefix + 'watch_group: ' + str(self.watch_group) + '\n'
- return outstr
-
-
-class ofp_action_pop_mpls(object):
- """Automatically generated Python class for ofp_action_pop_mpls
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.ethertype = 0
- self.pad= [0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 2):
- return (False, "self.pad is not of size 2 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HHH", self.type, self.len, self.ethertype)
- packed += struct.pack("!BB", self.pad[0], self.pad[1])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HHH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len, self.ethertype) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BB'
- start = 6
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.ethertype != other.ethertype: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- outstr += prefix + 'ethertype: ' + str(self.ethertype) + '\n'
- return outstr
-
-
-class ofp_match(object):
- """Automatically generated Python class for ofp_match
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = OFPMT_OXM
- #exclude padding bytes
- self.length = OFP_MATCH_BYTES
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HH", self.type, self.length)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 4):
- return binaryString
- fmt = '!HH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.length) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[4:]
-
- def __len__(self):
- """Return length of message
- """
- l = 4
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.length != other.length: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'length: ' + str(self.length) + '\n'
- return outstr
-
-
-class ofp_flow_mod(object):
- """Automatically generated Python class for ofp_flow_mod
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.cookie = 0
- self.cookie_mask = 0
- self.table_id = 0
- self.command = 0
- self.idle_timeout = 0
- self.hard_timeout = 0
- self.priority = 0x8000
- self.buffer_id = 0
- self.out_port = 0
- self.out_group = 0
- self.flags = 0
- self.pad= [0,0]
- self.match = ofp_match()
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 2):
- return (False, "self.pad is not of size 2 as expected.")
- if(not isinstance(self.match, ofp_match)):
- return (False, "self.match is not class ofp_match as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!QQBBHHHLLLH", self.cookie, self.cookie_mask, self.table_id, self.command, self.idle_timeout, self.hard_timeout, self.priority, self.buffer_id, self.out_port, self.out_group, self.flags)
- packed += struct.pack("!BB", self.pad[0], self.pad[1])
- packed += self.match.pack()
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 44):
- return binaryString
- fmt = '!QQBBHHHLLLH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.cookie, self.cookie_mask, self.table_id, self.command, self.idle_timeout, self.hard_timeout, self.priority, self.buffer_id, self.out_port, self.out_group, self.flags) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BB'
- start = 38
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1]) = struct.unpack(fmt, binaryString[start:end])
- self.match.unpack(binaryString[40:])
- return binaryString[44:]
-
- def __len__(self):
- """Return length of message
- """
- l = 44
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.cookie != other.cookie: return False
- if self.cookie_mask != other.cookie_mask: return False
- if self.table_id != other.table_id: return False
- if self.command != other.command: return False
- if self.idle_timeout != other.idle_timeout: return False
- if self.hard_timeout != other.hard_timeout: return False
- if self.priority != other.priority: return False
- if self.buffer_id != other.buffer_id: return False
- if self.out_port != other.out_port: return False
- if self.out_group != other.out_group: return False
- if self.flags != other.flags: return False
- if self.pad != other.pad: return False
- if self.match != other.match: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'cookie: ' + str(self.cookie) + '\n'
- outstr += prefix + 'cookie_mask: ' + str(self.cookie_mask) + '\n'
- outstr += prefix + 'table_id: ' + str(self.table_id) + '\n'
- outstr += prefix + 'command: ' + str(self.command) + '\n'
- outstr += prefix + 'idle_timeout: ' + str(self.idle_timeout) + '\n'
- outstr += prefix + 'hard_timeout: ' + str(self.hard_timeout) + '\n'
- outstr += prefix + 'priority: ' + str(self.priority) + '\n'
- outstr += prefix + 'buffer_id: ' + str(self.buffer_id) + '\n'
- outstr += prefix + 'out_port: ' + str(self.out_port) + '\n'
- outstr += prefix + 'out_group: ' + str(self.out_group) + '\n'
- outstr += prefix + 'flags: ' + str(self.flags) + '\n'
- outstr += prefix + 'match: \n'
- outstr += self.match.show(prefix + ' ')
- return outstr
-
-
-class ofp_packet_out(object):
- """Automatically generated Python class for ofp_packet_out
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.buffer_id = 4294967295
- self.in_port = 0
- self.actions_len = 0
- self.pad= [0,0,0,0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 6):
- return (False, "self.pad is not of size 6 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!LLH", self.buffer_id, self.in_port, self.actions_len)
- packed += struct.pack("!BBBBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3], self.pad[4], self.pad[5])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 16):
- return binaryString
- fmt = '!LLH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.buffer_id, self.in_port, self.actions_len) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBBBB'
- start = 10
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3], self.pad[4], self.pad[5]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[16:]
-
- def __len__(self):
- """Return length of message
- """
- l = 16
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.buffer_id != other.buffer_id: return False
- if self.in_port != other.in_port: return False
- if self.actions_len != other.actions_len: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'buffer_id: ' + str(self.buffer_id) + '\n'
- outstr += prefix + 'in_port: ' + str(self.in_port) + '\n'
- outstr += prefix + 'actions_len: ' + str(self.actions_len) + '\n'
- return outstr
-
-
-class ofp_instruction_goto_table(object):
- """Automatically generated Python class for ofp_instruction_goto_table
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.table_id = 0
- self.pad= [0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 3):
- return (False, "self.pad is not of size 3 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HHB", self.type, self.len, self.table_id)
- packed += struct.pack("!BBB", self.pad[0], self.pad[1], self.pad[2])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HHB'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len, self.table_id) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBB'
- start = 5
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.table_id != other.table_id: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- outstr += prefix + 'table_id: ' + str(self.table_id) + '\n'
- return outstr
-
-
-class ofp_queue_prop_max_rate(object):
- """Automatically generated Python class for ofp_queue_prop_max_rate
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.prop_header = ofp_queue_prop_header()
- self.rate = 0
- self.pad= [0,0,0,0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.prop_header, ofp_queue_prop_header)):
- return (False, "self.prop_header is not class ofp_queue_prop_header as expected.")
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 6):
- return (False, "self.pad is not of size 6 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += self.prop_header.pack()
- packed += struct.pack("!H", self.rate)
- packed += struct.pack("!BBBBBB", self.pad[0], self.pad[1], self.pad[2], self.pad[3], self.pad[4], self.pad[5])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 16):
- return binaryString
- self.prop_header.unpack(binaryString[0:])
- fmt = '!H'
- start = 8
- end = start + struct.calcsize(fmt)
- (self.rate,) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBBBB'
- start = 10
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3], self.pad[4], self.pad[5]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[16:]
-
- def __len__(self):
- """Return length of message
- """
- l = 16
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.prop_header != other.prop_header: return False
- if self.rate != other.rate: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'prop_header: \n'
- outstr += self.prop_header.show(prefix + ' ')
- outstr += prefix + 'rate: ' + str(self.rate) + '\n'
- return outstr
-
-
-class ofp_experimenter_stats_header(object):
- """Automatically generated Python class for ofp_experimenter_stats_header
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.experimenter = 0
- self.exp_type = 0
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!LL", self.experimenter, self.exp_type)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!LL'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.experimenter, self.exp_type) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.experimenter != other.experimenter: return False
- if self.exp_type != other.exp_type: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'experimenter: ' + str(self.experimenter) + '\n'
- outstr += prefix + 'exp_type: ' + str(self.exp_type) + '\n'
- return outstr
-
-
-class ofp_action_group(object):
- """Automatically generated Python class for ofp_action_group
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.group_id = 0
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HHL", self.type, self.len, self.group_id)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HHL'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len, self.group_id) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.group_id != other.group_id: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- outstr += prefix + 'group_id: ' + str(self.group_id) + '\n'
- return outstr
-
-
-class ofp_desc_stats(object):
- """Automatically generated Python class for ofp_desc_stats
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.mfr_desc= ""
- self.hw_desc= ""
- self.sw_desc= ""
- self.serial_num= ""
- self.dp_desc= ""
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.mfr_desc, str)):
- return (False, "self.mfr_desc is not string as expected.")
- if(len(self.mfr_desc) > 256):
- return (False, "self.mfr_desc is not of size 256 as expected.")
- if(not isinstance(self.hw_desc, str)):
- return (False, "self.hw_desc is not string as expected.")
- if(len(self.hw_desc) > 256):
- return (False, "self.hw_desc is not of size 256 as expected.")
- if(not isinstance(self.sw_desc, str)):
- return (False, "self.sw_desc is not string as expected.")
- if(len(self.sw_desc) > 256):
- return (False, "self.sw_desc is not of size 256 as expected.")
- if(not isinstance(self.serial_num, str)):
- return (False, "self.serial_num is not string as expected.")
- if(len(self.serial_num) > 32):
- return (False, "self.serial_num is not of size 32 as expected.")
- if(not isinstance(self.dp_desc, str)):
- return (False, "self.dp_desc is not string as expected.")
- if(len(self.dp_desc) > 256):
- return (False, "self.dp_desc is not of size 256 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += self.mfr_desc.ljust(256,'\0')
- packed += self.hw_desc.ljust(256,'\0')
- packed += self.sw_desc.ljust(256,'\0')
- packed += self.serial_num.ljust(32,'\0')
- packed += self.dp_desc.ljust(256,'\0')
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 1056):
- return binaryString
- self.mfr_desc = binaryString[0:256].replace("\0","")
- self.hw_desc = binaryString[256:512].replace("\0","")
- self.sw_desc = binaryString[512:768].replace("\0","")
- self.serial_num = binaryString[768:800].replace("\0","")
- self.dp_desc = binaryString[800:1056].replace("\0","")
- return binaryString[1056:]
-
- def __len__(self):
- """Return length of message
- """
- l = 1056
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.mfr_desc != other.mfr_desc: return False
- if self.hw_desc != other.hw_desc: return False
- if self.sw_desc != other.sw_desc: return False
- if self.serial_num != other.serial_num: return False
- if self.dp_desc != other.dp_desc: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'mfr_desc: ' + str(self.mfr_desc) + '\n'
- outstr += prefix + 'hw_desc: ' + str(self.hw_desc) + '\n'
- outstr += prefix + 'sw_desc: ' + str(self.sw_desc) + '\n'
- outstr += prefix + 'serial_num: ' + str(self.serial_num) + '\n'
- outstr += prefix + 'dp_desc: ' + str(self.dp_desc) + '\n'
- return outstr
-
-
-class ofp_action_push(object):
- """Automatically generated Python class for ofp_action_push
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.ethertype = 0
- self.pad= [0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 2):
- return (False, "self.pad is not of size 2 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HHH", self.type, self.len, self.ethertype)
- packed += struct.pack("!BB", self.pad[0], self.pad[1])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HHH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len, self.ethertype) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BB'
- start = 6
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.ethertype != other.ethertype: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- outstr += prefix + 'ethertype: ' + str(self.ethertype) + '\n'
- return outstr
-
-
-class ofp_group_desc_stats(object):
- """Automatically generated Python class for ofp_group_desc_stats
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.length = 0
- self.type = 0
- self.pad = 0
- self.group_id = 0
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HBBL", self.length, self.type, self.pad, self.group_id)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HBBL'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.length, self.type, self.pad, self.group_id) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.length != other.length: return False
- if self.type != other.type: return False
- if self.pad != other.pad: return False
- if self.group_id != other.group_id: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'length: ' + str(self.length) + '\n'
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'group_id: ' + str(self.group_id) + '\n'
- return outstr
-
-
-class ofp_error_msg(object):
- """Automatically generated Python class for ofp_error_msg
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.code = 0
-
- def __assert(self):
- """Sanity check
- """
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HH", self.type, self.code)
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 4):
- return binaryString
- fmt = '!HH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.code) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[4:]
-
- def __len__(self):
- """Return length of message
- """
- l = 4
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.code != other.code: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'code: ' + str(self.code) + '\n'
- return outstr
-
-
-class ofp_action_mpls_ttl(object):
- """Automatically generated Python class for ofp_action_mpls_ttl
-
- Date 2012-06-25
- Created by of.pythonize.pythonizer
- Core structure: Messages do not include ofp_header
- Does not include var-length arrays
- """
- def __init__(self):
- """Initialize
- Declare members and default values
- """
- self.type = 0
- self.len = 0
- self.mpls_ttl = 0
- self.pad= [0,0,0]
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.pad, list)):
- return (False, "self.pad is not list as expected.")
- if(len(self.pad) != 3):
- return (False, "self.pad is not of size 3 as expected.")
- return (True, None)
-
- def pack(self, assertstruct=True):
- """Pack message
- Packs empty array used as placeholder
- """
- if(assertstruct):
- if(not self.__assert()[0]):
- return None
- packed = ""
- packed += struct.pack("!HHB", self.type, self.len, self.mpls_ttl)
- packed += struct.pack("!BBB", self.pad[0], self.pad[1], self.pad[2])
- return packed
-
- def unpack(self, binaryString):
- """Unpack message
- Do not unpack empty array used as placeholder
- since they can contain heterogeneous type
- """
- if (len(binaryString) < 8):
- return binaryString
- fmt = '!HHB'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.type, self.len, self.mpls_ttl) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBB'
- start = 5
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[8:]
-
- def __len__(self):
- """Return length of message
- """
- l = 8
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.mpls_ttl != other.mpls_ttl: return False
- if self.pad != other.pad: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, prefix=''):
- """Generate string showing basic members of structure
- """
- outstr = ''
- outstr += prefix + 'type: ' + str(self.type) + '\n'
- outstr += prefix + 'len: ' + str(self.len) + '\n'
- outstr += prefix + 'mpls_ttl: ' + str(self.mpls_ttl) + '\n'
- return outstr
-
-
-# Enumerated type definitions
-ofp_error_type = ['OFPET_HELLO_FAILED', 'OFPET_BAD_REQUEST', 'OFPET_BAD_ACTION', 'OFPET_BAD_INSTRUCTION', 'OFPET_BAD_MATCH', 'OFPET_FLOW_MOD_FAILED', 'OFPET_GROUP_MOD_FAILED', 'OFPET_PORT_MOD_FAILED', 'OFPET_TABLE_MOD_FAILED', 'OFPET_QUEUE_OP_FAILED', 'OFPET_SWITCH_CONFIG_FAILED', 'OFPET_ROLE_REQUEST_FAILED', 'OFPET_EXPERIMENTER']
-OFPET_HELLO_FAILED = 0
-OFPET_BAD_REQUEST = 1
-OFPET_BAD_ACTION = 2
-OFPET_BAD_INSTRUCTION = 3
-OFPET_BAD_MATCH = 4
-OFPET_FLOW_MOD_FAILED = 5
-OFPET_GROUP_MOD_FAILED = 6
-OFPET_PORT_MOD_FAILED = 7
-OFPET_TABLE_MOD_FAILED = 8
-OFPET_QUEUE_OP_FAILED = 9
-OFPET_SWITCH_CONFIG_FAILED = 10
-OFPET_ROLE_REQUEST_FAILED = 11
-OFPET_EXPERIMENTER = 65535
-ofp_error_type_map = {
- 0 : 'OFPET_HELLO_FAILED',
- 1 : 'OFPET_BAD_REQUEST',
- 2 : 'OFPET_BAD_ACTION',
- 3 : 'OFPET_BAD_INSTRUCTION',
- 4 : 'OFPET_BAD_MATCH',
- 5 : 'OFPET_FLOW_MOD_FAILED',
- 6 : 'OFPET_GROUP_MOD_FAILED',
- 7 : 'OFPET_PORT_MOD_FAILED',
- 8 : 'OFPET_TABLE_MOD_FAILED',
- 9 : 'OFPET_QUEUE_OP_FAILED',
- 10 : 'OFPET_SWITCH_CONFIG_FAILED',
- 11 : 'OFPET_ROLE_REQUEST_FAILED',
- 65535 : 'OFPET_EXPERIMENTER'
-}
-
-ofp_flow_mod_flags = ['OFPFF_SEND_FLOW_REM', 'OFPFF_CHECK_OVERLAP', 'OFPFF_RESET_COUNTS']
-OFPFF_SEND_FLOW_REM = 1
-OFPFF_CHECK_OVERLAP = 2
-OFPFF_RESET_COUNTS = 4
-ofp_flow_mod_flags_map = {
- 1 : 'OFPFF_SEND_FLOW_REM',
- 2 : 'OFPFF_CHECK_OVERLAP',
- 4 : 'OFPFF_RESET_COUNTS'
-}
-
-ofp_controller_role = ['OFPCR_ROLE_NOCHANGE', 'OFPCR_ROLE_EQUAL', 'OFPCR_ROLE_MASTER', 'OFPCR_ROLE_SLAVE']
-OFPCR_ROLE_NOCHANGE = 0
-OFPCR_ROLE_EQUAL = 1
-OFPCR_ROLE_MASTER = 2
-OFPCR_ROLE_SLAVE = 3
-ofp_controller_role_map = {
- 0 : 'OFPCR_ROLE_NOCHANGE',
- 1 : 'OFPCR_ROLE_EQUAL',
- 2 : 'OFPCR_ROLE_MASTER',
- 3 : 'OFPCR_ROLE_SLAVE'
-}
-
-ofp_stats_reply_flags = ['OFPSF_REPLY_MORE']
-OFPSF_REPLY_MORE = 1
-ofp_stats_reply_flags_map = {
- 1 : 'OFPSF_REPLY_MORE'
-}
-
-ofp_port_no = ['OFPP_MAX', 'OFPP_IN_PORT', 'OFPP_TABLE', 'OFPP_NORMAL', 'OFPP_FLOOD', 'OFPP_ALL', 'OFPP_CONTROLLER', 'OFPP_LOCAL', 'OFPP_ANY']
-OFPP_MAX = 4294967040
-OFPP_IN_PORT = 4294967288
-OFPP_TABLE = 4294967289
-OFPP_NORMAL = 4294967290
-OFPP_FLOOD = 4294967291
-OFPP_ALL = 4294967292
-OFPP_CONTROLLER = 4294967293
-OFPP_LOCAL = 4294967294
-OFPP_ANY = 4294967295
-ofp_port_no_map = {
- 4294967040 : 'OFPP_MAX',
- 4294967288 : 'OFPP_IN_PORT',
- 4294967289 : 'OFPP_TABLE',
- 4294967290 : 'OFPP_NORMAL',
- 4294967291 : 'OFPP_FLOOD',
- 4294967292 : 'OFPP_ALL',
- 4294967293 : 'OFPP_CONTROLLER',
- 4294967294 : 'OFPP_LOCAL',
- 4294967295 : 'OFPP_ANY'
-}
-
-ofp_bad_request_code = ['OFPBRC_BAD_VERSION', 'OFPBRC_BAD_TYPE', 'OFPBRC_BAD_STAT', 'OFPBRC_BAD_EXPERIMENTER', 'OFPBRC_BAD_EXP_TYPE', 'OFPBRC_EPERM', 'OFPBRC_BAD_LEN', 'OFPBRC_BUFFER_EMPTY', 'OFPBRC_BUFFER_UNKNOWN', 'OFPBRC_BAD_TABLE_ID', 'OFPBRC_IS_SLAVE', 'OFPBRC_BAD_PORT', 'OFPBRC_BAD_PACKET']
-OFPBRC_BAD_VERSION = 0
-OFPBRC_BAD_TYPE = 1
-OFPBRC_BAD_STAT = 2
-OFPBRC_BAD_EXPERIMENTER = 3
-OFPBRC_BAD_EXP_TYPE = 4
-OFPBRC_EPERM = 5
-OFPBRC_BAD_LEN = 6
-OFPBRC_BUFFER_EMPTY = 7
-OFPBRC_BUFFER_UNKNOWN = 8
-OFPBRC_BAD_TABLE_ID = 9
-OFPBRC_IS_SLAVE = 10
-OFPBRC_BAD_PORT = 11
-OFPBRC_BAD_PACKET = 12
-ofp_bad_request_code_map = {
- 0 : 'OFPBRC_BAD_VERSION',
- 1 : 'OFPBRC_BAD_TYPE',
- 2 : 'OFPBRC_BAD_STAT',
- 3 : 'OFPBRC_BAD_EXPERIMENTER',
- 4 : 'OFPBRC_BAD_EXP_TYPE',
- 5 : 'OFPBRC_EPERM',
- 6 : 'OFPBRC_BAD_LEN',
- 7 : 'OFPBRC_BUFFER_EMPTY',
- 8 : 'OFPBRC_BUFFER_UNKNOWN',
- 9 : 'OFPBRC_BAD_TABLE_ID',
- 10 : 'OFPBRC_IS_SLAVE',
- 11 : 'OFPBRC_BAD_PORT',
- 12 : 'OFPBRC_BAD_PACKET'
-}
-
-ofp_bad_instruction_code = ['OFPBIC_UNKNOWN_INST', 'OFPBIC_UNSUP_INST', 'OFPBIC_BAD_TABLE_ID', 'OFPBIC_UNSUP_METADATA', 'OFPBIC_UNSUP_METADATA_MASK', 'OFPBIC_BAD_EXPERIMENTER', 'OFPBIC_BAD_EXP_TYPE', 'OFPBIC_BAD_LEN', 'OFPBIC_EPERM']
-OFPBIC_UNKNOWN_INST = 0
-OFPBIC_UNSUP_INST = 1
-OFPBIC_BAD_TABLE_ID = 2
-OFPBIC_UNSUP_METADATA = 3
-OFPBIC_UNSUP_METADATA_MASK = 4
-OFPBIC_BAD_EXPERIMENTER = 5
-OFPBIC_BAD_EXP_TYPE = 6
-OFPBIC_BAD_LEN = 7
-OFPBIC_EPERM = 8
-ofp_bad_instruction_code_map = {
- 0 : 'OFPBIC_UNKNOWN_INST',
- 1 : 'OFPBIC_UNSUP_INST',
- 2 : 'OFPBIC_BAD_TABLE_ID',
- 3 : 'OFPBIC_UNSUP_METADATA',
- 4 : 'OFPBIC_UNSUP_METADATA_MASK',
- 5 : 'OFPBIC_BAD_EXPERIMENTER',
- 6 : 'OFPBIC_BAD_EXP_TYPE',
- 7 : 'OFPBIC_BAD_LEN',
- 8 : 'OFPBIC_EPERM'
-}
-
-ofp_port_config = ['OFPPC_PORT_DOWN', 'OFPPC_NO_RECV', 'OFPPC_NO_FWD', 'OFPPC_NO_PACKET_IN']
-OFPPC_PORT_DOWN = 1
-OFPPC_NO_RECV = 4
-OFPPC_NO_FWD = 32
-OFPPC_NO_PACKET_IN = 64
-ofp_port_config_map = {
- 1 : 'OFPPC_PORT_DOWN',
- 4 : 'OFPPC_NO_RECV',
- 32 : 'OFPPC_NO_FWD',
- 64 : 'OFPPC_NO_PACKET_IN'
-}
-
-ofp_port_state = ['OFPPS_LINK_DOWN', 'OFPPS_BLOCKED', 'OFPPS_LIVE']
-OFPPS_LINK_DOWN = 1
-OFPPS_BLOCKED = 2
-OFPPS_LIVE = 4
-ofp_port_state_map = {
- 1 : 'OFPPS_LINK_DOWN',
- 2 : 'OFPPS_BLOCKED',
- 4 : 'OFPPS_LIVE'
-}
-
-ofp_config_flags = ['OFPC_FRAG_NORMAL', 'OFPC_FRAG_DROP', 'OFPC_FRAG_REASM', 'OFPC_FRAG_MASK', 'OFPC_INVALID_TTL_TO_CONTROLLER']
-OFPC_FRAG_NORMAL = 0
-OFPC_FRAG_DROP = 1
-OFPC_FRAG_REASM = 2
-OFPC_FRAG_MASK = 3
-OFPC_INVALID_TTL_TO_CONTROLLER = 4
-ofp_config_flags_map = {
- 0 : 'OFPC_FRAG_NORMAL',
- 1 : 'OFPC_FRAG_DROP',
- 2 : 'OFPC_FRAG_REASM',
- 3 : 'OFPC_FRAG_MASK',
- 4 : 'OFPC_INVALID_TTL_TO_CONTROLLER'
-}
-
-ofp_switch_config_failed_code = ['OFPSCFC_BAD_FLAGS', 'OFPSCFC_BAD_LEN', 'OFPQCFC_EPERM']
-OFPSCFC_BAD_FLAGS = 0
-OFPSCFC_BAD_LEN = 1
-OFPQCFC_EPERM = 2
-ofp_switch_config_failed_code_map = {
- 0 : 'OFPSCFC_BAD_FLAGS',
- 1 : 'OFPSCFC_BAD_LEN',
- 2 : 'OFPQCFC_EPERM'
-}
-
-ofp_controller_max_len = ['OFPCML_MAX', 'OFPCML_NO_BUFFER']
-OFPCML_MAX = 65509
-OFPCML_NO_BUFFER = 65535
-ofp_controller_max_len_map = {
- 65509 : 'OFPCML_MAX',
- 65535 : 'OFPCML_NO_BUFFER'
-}
-
-ofp_role_request_failed_code = ['OFPRRFC_STALE', 'OFPRRFC_UNSUP', 'OFPRRFC_BAD_ROLE']
-OFPRRFC_STALE = 0
-OFPRRFC_UNSUP = 1
-OFPRRFC_BAD_ROLE = 2
-ofp_role_request_failed_code_map = {
- 0 : 'OFPRRFC_STALE',
- 1 : 'OFPRRFC_UNSUP',
- 2 : 'OFPRRFC_BAD_ROLE'
-}
-
-ofp_capabilities = ['OFPC_FLOW_STATS', 'OFPC_TABLE_STATS', 'OFPC_PORT_STATS', 'OFPC_GROUP_STATS', 'OFPC_IP_REASM', 'OFPC_QUEUE_STATS', 'OFPC_PORT_BLOCKED']
-OFPC_FLOW_STATS = 1
-OFPC_TABLE_STATS = 2
-OFPC_PORT_STATS = 4
-OFPC_GROUP_STATS = 8
-OFPC_IP_REASM = 32
-OFPC_QUEUE_STATS = 64
-OFPC_PORT_BLOCKED = 256
-ofp_capabilities_map = {
- 1 : 'OFPC_FLOW_STATS',
- 2 : 'OFPC_TABLE_STATS',
- 4 : 'OFPC_PORT_STATS',
- 8 : 'OFPC_GROUP_STATS',
- 32 : 'OFPC_IP_REASM',
- 64 : 'OFPC_QUEUE_STATS',
- 256 : 'OFPC_PORT_BLOCKED'
-}
-
-ofp_bad_match_code = ['OFPBMC_BAD_TYPE', 'OFPBMC_BAD_LEN', 'OFPBMC_BAD_TAG', 'OFPBMC_BAD_DL_ADDR_MASK', 'OFPBMC_BAD_NW_ADDR_MASK', 'OFPBMC_BAD_WILDCARDS', 'OFPBMC_BAD_FIELD', 'OFPBMC_BAD_VALUE', 'OFPBMC_BAD_MASK', 'OFPBMC_BAD_PREREQ', 'OFPBMC_DUP_FIELD', 'OFPBMC_EPERM']
-OFPBMC_BAD_TYPE = 0
-OFPBMC_BAD_LEN = 1
-OFPBMC_BAD_TAG = 2
-OFPBMC_BAD_DL_ADDR_MASK = 3
-OFPBMC_BAD_NW_ADDR_MASK = 4
-OFPBMC_BAD_WILDCARDS = 5
-OFPBMC_BAD_FIELD = 6
-OFPBMC_BAD_VALUE = 7
-OFPBMC_BAD_MASK = 8
-OFPBMC_BAD_PREREQ = 9
-OFPBMC_DUP_FIELD = 10
-OFPBMC_EPERM = 11
-ofp_bad_match_code_map = {
- 0 : 'OFPBMC_BAD_TYPE',
- 1 : 'OFPBMC_BAD_LEN',
- 2 : 'OFPBMC_BAD_TAG',
- 3 : 'OFPBMC_BAD_DL_ADDR_MASK',
- 4 : 'OFPBMC_BAD_NW_ADDR_MASK',
- 5 : 'OFPBMC_BAD_WILDCARDS',
- 6 : 'OFPBMC_BAD_FIELD',
- 7 : 'OFPBMC_BAD_VALUE',
- 8 : 'OFPBMC_BAD_MASK',
- 9 : 'OFPBMC_BAD_PREREQ',
- 10 : 'OFPBMC_DUP_FIELD',
- 11 : 'OFPBMC_EPERM'
-}
-
-ofp_flow_removed_reason = ['OFPRR_IDLE_TIMEOUT', 'OFPRR_HARD_TIMEOUT', 'OFPRR_DELETE', 'OFPRR_GROUP_DELETE']
-OFPRR_IDLE_TIMEOUT = 0
-OFPRR_HARD_TIMEOUT = 1
-OFPRR_DELETE = 2
-OFPRR_GROUP_DELETE = 3
-ofp_flow_removed_reason_map = {
- 0 : 'OFPRR_IDLE_TIMEOUT',
- 1 : 'OFPRR_HARD_TIMEOUT',
- 2 : 'OFPRR_DELETE',
- 3 : 'OFPRR_GROUP_DELETE'
-}
-
-ofp_table_mod_failed_code = ['OFPTMFC_BAD_TABLE', 'OFPTMFC_BAD_CONFIG', 'OFPTMFC_EPERM']
-OFPTMFC_BAD_TABLE = 0
-OFPTMFC_BAD_CONFIG = 1
-OFPTMFC_EPERM = 2
-ofp_table_mod_failed_code_map = {
- 0 : 'OFPTMFC_BAD_TABLE',
- 1 : 'OFPTMFC_BAD_CONFIG',
- 2 : 'OFPTMFC_EPERM'
-}
-
-ofp_queue_properties = ['OFPQT_MIN_RATE', 'OFPQT_MAX_RATE', 'OFPQT_EXPERIMENTER']
-OFPQT_MIN_RATE = 1
-OFPQT_MAX_RATE = 2
-OFPQT_EXPERIMENTER = 65535
-ofp_queue_properties_map = {
- 1 : 'OFPQT_MIN_RATE',
- 2 : 'OFPQT_MAX_RATE',
- 65535 : 'OFPQT_EXPERIMENTER'
-}
-
-ofp_table = ['OFPTT_MAX', 'OFPTT_ALL']
-OFPTT_MAX = 254
-OFPTT_ALL = 255
-ofp_table_map = {
- 254 : 'OFPTT_MAX',
- 255 : 'OFPTT_ALL'
-}
-
-ofp_group = ['OFPG_MAX', 'OFPG_ALL', 'OFPG_ANY']
-OFPG_MAX = 4294967040
-OFPG_ALL = 4294967292
-OFPG_ANY = 4294967295
-ofp_group_map = {
- 4294967040 : 'OFPG_MAX',
- 4294967292 : 'OFPG_ALL',
- 4294967295 : 'OFPG_ANY'
-}
-
-ofp_port_reason = ['OFPPR_ADD', 'OFPPR_DELETE', 'OFPPR_MODIFY']
-OFPPR_ADD = 0
-OFPPR_DELETE = 1
-OFPPR_MODIFY = 2
-ofp_port_reason_map = {
- 0 : 'OFPPR_ADD',
- 1 : 'OFPPR_DELETE',
- 2 : 'OFPPR_MODIFY'
-}
-
-ofp_group_capabilities = ['OFPGFC_SELECT_WEIGHT', 'OFPGFC_SELECT_LIVENESS', 'OFPGFC_CHAINING', 'OFPGFC_CHAINING_CHECKS']
-OFPGFC_SELECT_WEIGHT = 1
-OFPGFC_SELECT_LIVENESS = 2
-OFPGFC_CHAINING = 4
-OFPGFC_CHAINING_CHECKS = 8
-ofp_group_capabilities_map = {
- 1 : 'OFPGFC_SELECT_WEIGHT',
- 2 : 'OFPGFC_SELECT_LIVENESS',
- 4 : 'OFPGFC_CHAINING',
- 8 : 'OFPGFC_CHAINING_CHECKS'
-}
-
-ofp_table_config = ['OFPTC_TABLE_MISS_CONTROLLER', 'OFPTC_TABLE_MISS_CONTINUE', 'OFPTC_TABLE_MISS_DROP', 'OFPTC_TABLE_MISS_MASK']
-OFPTC_TABLE_MISS_CONTROLLER = 0
-OFPTC_TABLE_MISS_CONTINUE = 1
-OFPTC_TABLE_MISS_DROP = 2
-OFPTC_TABLE_MISS_MASK = 3
-ofp_table_config_map = {
- 0 : 'OFPTC_TABLE_MISS_CONTROLLER',
- 1 : 'OFPTC_TABLE_MISS_CONTINUE',
- 2 : 'OFPTC_TABLE_MISS_DROP',
- 3 : 'OFPTC_TABLE_MISS_MASK'
-}
-
-ofp_action_type = ['OFPAT_OUTPUT', 'OFPAT_COPY_TTL_OUT', 'OFPAT_COPY_TTL_IN', 'OFPAT_SET_MPLS_TTL', 'OFPAT_DEC_MPLS_TTL', 'OFPAT_PUSH_VLAN', 'OFPAT_POP_VLAN', 'OFPAT_PUSH_MPLS', 'OFPAT_POP_MPLS', 'OFPAT_SET_QUEUE', 'OFPAT_GROUP', 'OFPAT_SET_NW_TTL', 'OFPAT_DEC_NW_TTL', 'OFPAT_SET_FIELD', 'OFPAT_EXPERIMENTER']
-OFPAT_OUTPUT = 0
-OFPAT_COPY_TTL_OUT = 11
-OFPAT_COPY_TTL_IN = 12
-OFPAT_SET_MPLS_TTL = 15
-OFPAT_DEC_MPLS_TTL = 16
-OFPAT_PUSH_VLAN = 17
-OFPAT_POP_VLAN = 18
-OFPAT_PUSH_MPLS = 19
-OFPAT_POP_MPLS = 20
-OFPAT_SET_QUEUE = 21
-OFPAT_GROUP = 22
-OFPAT_SET_NW_TTL = 23
-OFPAT_DEC_NW_TTL = 24
-OFPAT_SET_FIELD = 25
-OFPAT_EXPERIMENTER = 65535
-ofp_action_type_map = {
- 0 : 'OFPAT_OUTPUT',
- 11 : 'OFPAT_COPY_TTL_OUT',
- 12 : 'OFPAT_COPY_TTL_IN',
- 15 : 'OFPAT_SET_MPLS_TTL',
- 16 : 'OFPAT_DEC_MPLS_TTL',
- 17 : 'OFPAT_PUSH_VLAN',
- 18 : 'OFPAT_POP_VLAN',
- 19 : 'OFPAT_PUSH_MPLS',
- 20 : 'OFPAT_POP_MPLS',
- 21 : 'OFPAT_SET_QUEUE',
- 22 : 'OFPAT_GROUP',
- 23 : 'OFPAT_SET_NW_TTL',
- 24 : 'OFPAT_DEC_NW_TTL',
- 25 : 'OFPAT_SET_FIELD',
- 65535 : 'OFPAT_EXPERIMENTER'
-}
-
-ofp_flow_mod_command = ['OFPFC_ADD', 'OFPFC_MODIFY', 'OFPFC_MODIFY_STRICT', 'OFPFC_DELETE', 'OFPFC_DELETE_STRICT']
-OFPFC_ADD = 0
-OFPFC_MODIFY = 1
-OFPFC_MODIFY_STRICT = 2
-OFPFC_DELETE = 3
-OFPFC_DELETE_STRICT = 4
-ofp_flow_mod_command_map = {
- 0 : 'OFPFC_ADD',
- 1 : 'OFPFC_MODIFY',
- 2 : 'OFPFC_MODIFY_STRICT',
- 3 : 'OFPFC_DELETE',
- 4 : 'OFPFC_DELETE_STRICT'
-}
-
-ofp_queue_op_failed_code = ['OFPQOFC_BAD_PORT', 'OFPQOFC_BAD_QUEUE', 'OFPQOFC_EPERM']
-OFPQOFC_BAD_PORT = 0
-OFPQOFC_BAD_QUEUE = 1
-OFPQOFC_EPERM = 2
-ofp_queue_op_failed_code_map = {
- 0 : 'OFPQOFC_BAD_PORT',
- 1 : 'OFPQOFC_BAD_QUEUE',
- 2 : 'OFPQOFC_EPERM'
-}
-
-ofp_hello_failed_code = ['OFPHFC_INCOMPATIBLE', 'OFPHFC_EPERM']
-OFPHFC_INCOMPATIBLE = 0
-OFPHFC_EPERM = 1
-ofp_hello_failed_code_map = {
- 0 : 'OFPHFC_INCOMPATIBLE',
- 1 : 'OFPHFC_EPERM'
-}
-
-ofp_match_type = ['OFPMT_STANDARD', 'OFPMT_OXM']
-OFPMT_STANDARD = 0
-OFPMT_OXM = 1
-ofp_match_type_map = {
- 0 : 'OFPMT_STANDARD',
- 1 : 'OFPMT_OXM'
-}
-
-ofp_vlan_id = ['OFPVID_PRESENT', 'OFPVID_NONE']
-OFPVID_PRESENT = 4096
-OFPVID_NONE = 0
-ofp_vlan_id_map = {
- 4096 : 'OFPVID_PRESENT',
- 0 : 'OFPVID_NONE'
-}
-
-ofp_oxm_class = ['OFPXMC_NXM_0', 'OFPXMC_NXM_1', 'OFPXMC_OPENFLOW_BASIC', 'OFPXMC_EXPERIMENTER']
-OFPXMC_NXM_0 = 0
-OFPXMC_NXM_1 = 1
-OFPXMC_OPENFLOW_BASIC = 32768
-OFPXMC_EXPERIMENTER = 65535
-ofp_oxm_class_map = {
- 0 : 'OFPXMC_NXM_0',
- 1 : 'OFPXMC_NXM_1',
- 32768 : 'OFPXMC_OPENFLOW_BASIC',
- 65535 : 'OFPXMC_EXPERIMENTER'
-}
-
-ofp_group_type = ['OFPGT_ALL', 'OFPGT_SELECT', 'OFPGT_INDIRECT', 'OFPGT_FF']
-OFPGT_ALL = 0
-OFPGT_SELECT = 1
-OFPGT_INDIRECT = 2
-OFPGT_FF = 3
-ofp_group_type_map = {
- 0 : 'OFPGT_ALL',
- 1 : 'OFPGT_SELECT',
- 2 : 'OFPGT_INDIRECT',
- 3 : 'OFPGT_FF'
-}
-
-ofp_instruction_type = ['OFPIT_GOTO_TABLE', 'OFPIT_WRITE_METADATA', 'OFPIT_WRITE_ACTIONS', 'OFPIT_APPLY_ACTIONS', 'OFPIT_CLEAR_ACTIONS', 'OFPIT_EXPERIMENTER']
-OFPIT_GOTO_TABLE = 1
-OFPIT_WRITE_METADATA = 2
-OFPIT_WRITE_ACTIONS = 3
-OFPIT_APPLY_ACTIONS = 4
-OFPIT_CLEAR_ACTIONS = 5
-OFPIT_EXPERIMENTER = 65535
-ofp_instruction_type_map = {
- 1 : 'OFPIT_GOTO_TABLE',
- 2 : 'OFPIT_WRITE_METADATA',
- 3 : 'OFPIT_WRITE_ACTIONS',
- 4 : 'OFPIT_APPLY_ACTIONS',
- 5 : 'OFPIT_CLEAR_ACTIONS',
- 65535 : 'OFPIT_EXPERIMENTER'
-}
-
-ofp_bad_action_code = ['OFPBAC_BAD_TYPE', 'OFPBAC_BAD_LEN', 'OFPBAC_BAD_EXPERIMENTER', 'OFPBAC_BAD_EXP_TYPE', 'OFPBAC_BAD_OUT_PORT', 'OFPBAC_BAD_ARGUMENT', 'OFPBAC_EPERM', 'OFPBAC_TOO_MANY', 'OFPBAC_BAD_QUEUE', 'OFPBAC_BAD_OUT_GROUP', 'OFPBAC_MATCH_INCONSISTENT', 'OFPBAC_UNSUPPORTED_ORDER', 'OFPBAC_BAD_TAG', 'OFPBAC_BAD_SET_TYPE', 'OFPBAC_BAD_SET_LEN', 'OFPBAC_BAD_SET_ARGUMENT']
-OFPBAC_BAD_TYPE = 0
-OFPBAC_BAD_LEN = 1
-OFPBAC_BAD_EXPERIMENTER = 2
-OFPBAC_BAD_EXP_TYPE = 3
-OFPBAC_BAD_OUT_PORT = 4
-OFPBAC_BAD_ARGUMENT = 5
-OFPBAC_EPERM = 6
-OFPBAC_TOO_MANY = 7
-OFPBAC_BAD_QUEUE = 8
-OFPBAC_BAD_OUT_GROUP = 9
-OFPBAC_MATCH_INCONSISTENT = 10
-OFPBAC_UNSUPPORTED_ORDER = 11
-OFPBAC_BAD_TAG = 12
-OFPBAC_BAD_SET_TYPE = 13
-OFPBAC_BAD_SET_LEN = 14
-OFPBAC_BAD_SET_ARGUMENT = 15
-ofp_bad_action_code_map = {
- 0 : 'OFPBAC_BAD_TYPE',
- 1 : 'OFPBAC_BAD_LEN',
- 2 : 'OFPBAC_BAD_EXPERIMENTER',
- 3 : 'OFPBAC_BAD_EXP_TYPE',
- 4 : 'OFPBAC_BAD_OUT_PORT',
- 5 : 'OFPBAC_BAD_ARGUMENT',
- 6 : 'OFPBAC_EPERM',
- 7 : 'OFPBAC_TOO_MANY',
- 8 : 'OFPBAC_BAD_QUEUE',
- 9 : 'OFPBAC_BAD_OUT_GROUP',
- 10 : 'OFPBAC_MATCH_INCONSISTENT',
- 11 : 'OFPBAC_UNSUPPORTED_ORDER',
- 12 : 'OFPBAC_BAD_TAG',
- 13 : 'OFPBAC_BAD_SET_TYPE',
- 14 : 'OFPBAC_BAD_SET_LEN',
- 15 : 'OFPBAC_BAD_SET_ARGUMENT'
-}
-
-oxm_ofb_match_fields = ['OFPXMT_OFB_IN_PORT', 'OFPXMT_OFB_IN_PHY_PORT', 'OFPXMT_OFB_METADATA', 'OFPXMT_OFB_ETH_DST', 'OFPXMT_OFB_ETH_SRC', 'OFPXMT_OFB_ETH_TYPE', 'OFPXMT_OFB_VLAN_VID', 'OFPXMT_OFB_VLAN_PCP', 'OFPXMT_OFB_IP_DSCP', 'OFPXMT_OFB_IP_ECN', 'OFPXMT_OFB_IP_PROTO', 'OFPXMT_OFB_IPV4_SRC', 'OFPXMT_OFB_IPV4_DST', 'OFPXMT_OFB_TCP_SRC', 'OFPXMT_OFB_TCP_DST', 'OFPXMT_OFB_UDP_SRC', 'OFPXMT_OFB_UDP_DST', 'OFPXMT_OFB_SCTP_SRC', 'OFPXMT_OFB_SCTP_DST', 'OFPXMT_OFB_ICMPV4_TYPE', 'OFPXMT_OFB_ICMPV4_CODE', 'OFPXMT_OFB_ARP_OP', 'OFPXMT_OFB_ARP_SPA', 'OFPXMT_OFB_ARP_TPA', 'OFPXMT_OFB_ARP_SHA', 'OFPXMT_OFB_ARP_THA', 'OFPXMT_OFB_IPV6_SRC', 'OFPXMT_OFB_IPV6_DST', 'OFPXMT_OFB_IPV6_FLABEL', 'OFPXMT_OFB_ICMPV6_TYPE', 'OFPXMT_OFB_ICMPV6_CODE', 'OFPXMT_OFB_IPV6_ND_TARGET', 'OFPXMT_OFB_IPV6_ND_SLL', 'OFPXMT_OFB_IPV6_ND_TLL', 'OFPXMT_OFB_MPLS_LABEL', 'OFPXMT_OFB_MPLS_TC']
-OFPXMT_OFB_IN_PORT = 0
-OFPXMT_OFB_IN_PHY_PORT = 1
-OFPXMT_OFB_METADATA = 2
-OFPXMT_OFB_ETH_DST = 3
-OFPXMT_OFB_ETH_SRC = 4
-OFPXMT_OFB_ETH_TYPE = 5
-OFPXMT_OFB_VLAN_VID = 6
-OFPXMT_OFB_VLAN_PCP = 7
-OFPXMT_OFB_IP_DSCP = 8
-OFPXMT_OFB_IP_ECN = 9
-OFPXMT_OFB_IP_PROTO = 10
-OFPXMT_OFB_IPV4_SRC = 11
-OFPXMT_OFB_IPV4_DST = 12
-OFPXMT_OFB_TCP_SRC = 13
-OFPXMT_OFB_TCP_DST = 14
-OFPXMT_OFB_UDP_SRC = 15
-OFPXMT_OFB_UDP_DST = 16
-OFPXMT_OFB_SCTP_SRC = 17
-OFPXMT_OFB_SCTP_DST = 18
-OFPXMT_OFB_ICMPV4_TYPE = 19
-OFPXMT_OFB_ICMPV4_CODE = 20
-OFPXMT_OFB_ARP_OP = 21
-OFPXMT_OFB_ARP_SPA = 22
-OFPXMT_OFB_ARP_TPA = 23
-OFPXMT_OFB_ARP_SHA = 24
-OFPXMT_OFB_ARP_THA = 25
-OFPXMT_OFB_IPV6_SRC = 26
-OFPXMT_OFB_IPV6_DST = 27
-OFPXMT_OFB_IPV6_FLABEL = 28
-OFPXMT_OFB_ICMPV6_TYPE = 29
-OFPXMT_OFB_ICMPV6_CODE = 30
-OFPXMT_OFB_IPV6_ND_TARGET = 31
-OFPXMT_OFB_IPV6_ND_SLL = 32
-OFPXMT_OFB_IPV6_ND_TLL = 33
-OFPXMT_OFB_MPLS_LABEL = 34
-OFPXMT_OFB_MPLS_TC = 35
-oxm_ofb_match_fields_map = {
- 0 : 'OFPXMT_OFB_IN_PORT',
- 1 : 'OFPXMT_OFB_IN_PHY_PORT',
- 2 : 'OFPXMT_OFB_METADATA',
- 3 : 'OFPXMT_OFB_ETH_DST',
- 4 : 'OFPXMT_OFB_ETH_SRC',
- 5 : 'OFPXMT_OFB_ETH_TYPE',
- 6 : 'OFPXMT_OFB_VLAN_VID',
- 7 : 'OFPXMT_OFB_VLAN_PCP',
- 8 : 'OFPXMT_OFB_IP_DSCP',
- 9 : 'OFPXMT_OFB_IP_ECN',
- 10 : 'OFPXMT_OFB_IP_PROTO',
- 11 : 'OFPXMT_OFB_IPV4_SRC',
- 12 : 'OFPXMT_OFB_IPV4_DST',
- 13 : 'OFPXMT_OFB_TCP_SRC',
- 14 : 'OFPXMT_OFB_TCP_DST',
- 15 : 'OFPXMT_OFB_UDP_SRC',
- 16 : 'OFPXMT_OFB_UDP_DST',
- 17 : 'OFPXMT_OFB_SCTP_SRC',
- 18 : 'OFPXMT_OFB_SCTP_DST',
- 19 : 'OFPXMT_OFB_ICMPV4_TYPE',
- 20 : 'OFPXMT_OFB_ICMPV4_CODE',
- 21 : 'OFPXMT_OFB_ARP_OP',
- 22 : 'OFPXMT_OFB_ARP_SPA',
- 23 : 'OFPXMT_OFB_ARP_TPA',
- 24 : 'OFPXMT_OFB_ARP_SHA',
- 25 : 'OFPXMT_OFB_ARP_THA',
- 26 : 'OFPXMT_OFB_IPV6_SRC',
- 27 : 'OFPXMT_OFB_IPV6_DST',
- 28 : 'OFPXMT_OFB_IPV6_FLABEL',
- 29 : 'OFPXMT_OFB_ICMPV6_TYPE',
- 30 : 'OFPXMT_OFB_ICMPV6_CODE',
- 31 : 'OFPXMT_OFB_IPV6_ND_TARGET',
- 32 : 'OFPXMT_OFB_IPV6_ND_SLL',
- 33 : 'OFPXMT_OFB_IPV6_ND_TLL',
- 34 : 'OFPXMT_OFB_MPLS_LABEL',
- 35 : 'OFPXMT_OFB_MPLS_TC'
-}
-
-ofp_flow_mod_failed_code = ['OFPFMFC_UNKNOWN', 'OFPFMFC_TABLE_FULL', 'OFPFMFC_BAD_TABLE_ID', 'OFPFMFC_OVERLAP', 'OFPFMFC_EPERM', 'OFPFMFC_BAD_TIMEOUT', 'OFPFMFC_BAD_COMMAND', 'OFPFMFC_BAD_FLAGS']
-OFPFMFC_UNKNOWN = 0
-OFPFMFC_TABLE_FULL = 1
-OFPFMFC_BAD_TABLE_ID = 2
-OFPFMFC_OVERLAP = 3
-OFPFMFC_EPERM = 4
-OFPFMFC_BAD_TIMEOUT = 5
-OFPFMFC_BAD_COMMAND = 6
-OFPFMFC_BAD_FLAGS = 7
-ofp_flow_mod_failed_code_map = {
- 0 : 'OFPFMFC_UNKNOWN',
- 1 : 'OFPFMFC_TABLE_FULL',
- 2 : 'OFPFMFC_BAD_TABLE_ID',
- 3 : 'OFPFMFC_OVERLAP',
- 4 : 'OFPFMFC_EPERM',
- 5 : 'OFPFMFC_BAD_TIMEOUT',
- 6 : 'OFPFMFC_BAD_COMMAND',
- 7 : 'OFPFMFC_BAD_FLAGS'
-}
-
-ofp_port_mod_failed_code = ['OFPPMFC_BAD_PORT', 'OFPPMFC_BAD_HW_ADDR', 'OFPPMFC_BAD_CONFIG', 'OFPPMFC_BAD_ADVERTISE', 'OFPPMFC_EPERM']
-OFPPMFC_BAD_PORT = 0
-OFPPMFC_BAD_HW_ADDR = 1
-OFPPMFC_BAD_CONFIG = 2
-OFPPMFC_BAD_ADVERTISE = 3
-OFPPMFC_EPERM = 4
-ofp_port_mod_failed_code_map = {
- 0 : 'OFPPMFC_BAD_PORT',
- 1 : 'OFPPMFC_BAD_HW_ADDR',
- 2 : 'OFPPMFC_BAD_CONFIG',
- 3 : 'OFPPMFC_BAD_ADVERTISE',
- 4 : 'OFPPMFC_EPERM'
-}
-
-ofp_type = ['OFPT_HELLO', 'OFPT_ERROR', 'OFPT_ECHO_REQUEST', 'OFPT_ECHO_REPLY', 'OFPT_EXPERIMENTER', 'OFPT_FEATURES_REQUEST', 'OFPT_FEATURES_REPLY', 'OFPT_GET_CONFIG_REQUEST', 'OFPT_GET_CONFIG_REPLY', 'OFPT_SET_CONFIG', 'OFPT_PACKET_IN', 'OFPT_FLOW_REMOVED', 'OFPT_PORT_STATUS', 'OFPT_PACKET_OUT', 'OFPT_FLOW_MOD', 'OFPT_GROUP_MOD', 'OFPT_PORT_MOD', 'OFPT_TABLE_MOD', 'OFPT_STATS_REQUEST', 'OFPT_STATS_REPLY', 'OFPT_BARRIER_REQUEST', 'OFPT_BARRIER_REPLY', 'OFPT_QUEUE_GET_CONFIG_REQUEST', 'OFPT_QUEUE_GET_CONFIG_REPLY', 'OFPT_ROLE_REQUEST', 'OFPT_ROLE_REPLY']
-OFPT_HELLO = 0
-OFPT_ERROR = 1
-OFPT_ECHO_REQUEST = 2
-OFPT_ECHO_REPLY = 3
-OFPT_EXPERIMENTER = 4
-OFPT_FEATURES_REQUEST = 5
-OFPT_FEATURES_REPLY = 6
-OFPT_GET_CONFIG_REQUEST = 7
-OFPT_GET_CONFIG_REPLY = 8
-OFPT_SET_CONFIG = 9
-OFPT_PACKET_IN = 10
-OFPT_FLOW_REMOVED = 11
-OFPT_PORT_STATUS = 12
-OFPT_PACKET_OUT = 13
-OFPT_FLOW_MOD = 14
-OFPT_GROUP_MOD = 15
-OFPT_PORT_MOD = 16
-OFPT_TABLE_MOD = 17
-OFPT_STATS_REQUEST = 18
-OFPT_STATS_REPLY = 19
-OFPT_BARRIER_REQUEST = 20
-OFPT_BARRIER_REPLY = 21
-OFPT_QUEUE_GET_CONFIG_REQUEST = 22
-OFPT_QUEUE_GET_CONFIG_REPLY = 23
-OFPT_ROLE_REQUEST = 24
-OFPT_ROLE_REPLY = 25
-ofp_type_map = {
- 0 : 'OFPT_HELLO',
- 1 : 'OFPT_ERROR',
- 2 : 'OFPT_ECHO_REQUEST',
- 3 : 'OFPT_ECHO_REPLY',
- 4 : 'OFPT_EXPERIMENTER',
- 5 : 'OFPT_FEATURES_REQUEST',
- 6 : 'OFPT_FEATURES_REPLY',
- 7 : 'OFPT_GET_CONFIG_REQUEST',
- 8 : 'OFPT_GET_CONFIG_REPLY',
- 9 : 'OFPT_SET_CONFIG',
- 10 : 'OFPT_PACKET_IN',
- 11 : 'OFPT_FLOW_REMOVED',
- 12 : 'OFPT_PORT_STATUS',
- 13 : 'OFPT_PACKET_OUT',
- 14 : 'OFPT_FLOW_MOD',
- 15 : 'OFPT_GROUP_MOD',
- 16 : 'OFPT_PORT_MOD',
- 17 : 'OFPT_TABLE_MOD',
- 18 : 'OFPT_STATS_REQUEST',
- 19 : 'OFPT_STATS_REPLY',
- 20 : 'OFPT_BARRIER_REQUEST',
- 21 : 'OFPT_BARRIER_REPLY',
- 22 : 'OFPT_QUEUE_GET_CONFIG_REQUEST',
- 23 : 'OFPT_QUEUE_GET_CONFIG_REPLY',
- 24 : 'OFPT_ROLE_REQUEST',
- 25 : 'OFPT_ROLE_REPLY'
-}
-
-ofp_packet_in_reason = ['OFPR_NO_MATCH', 'OFPR_ACTION', 'OFPR_INVALID_TTL']
-OFPR_NO_MATCH = 0
-OFPR_ACTION = 1
-OFPR_INVALID_TTL = 2
-ofp_packet_in_reason_map = {
- 0 : 'OFPR_NO_MATCH',
- 1 : 'OFPR_ACTION',
- 2 : 'OFPR_INVALID_TTL'
-}
-
-ofp_stats_types = ['OFPST_DESC', 'OFPST_FLOW', 'OFPST_AGGREGATE', 'OFPST_TABLE', 'OFPST_PORT', 'OFPST_QUEUE', 'OFPST_GROUP', 'OFPST_GROUP_DESC', 'OFPST_GROUP_FEATURES', 'OFPST_EXPERIMENTER']
-OFPST_DESC = 0
-OFPST_FLOW = 1
-OFPST_AGGREGATE = 2
-OFPST_TABLE = 3
-OFPST_PORT = 4
-OFPST_QUEUE = 5
-OFPST_GROUP = 6
-OFPST_GROUP_DESC = 7
-OFPST_GROUP_FEATURES = 8
-OFPST_EXPERIMENTER = 65535
-ofp_stats_types_map = {
- 0 : 'OFPST_DESC',
- 1 : 'OFPST_FLOW',
- 2 : 'OFPST_AGGREGATE',
- 3 : 'OFPST_TABLE',
- 4 : 'OFPST_PORT',
- 5 : 'OFPST_QUEUE',
- 6 : 'OFPST_GROUP',
- 7 : 'OFPST_GROUP_DESC',
- 8 : 'OFPST_GROUP_FEATURES',
- 65535 : 'OFPST_EXPERIMENTER'
-}
-
-ofp_group_mod_command = ['OFPGC_ADD', 'OFPGC_MODIFY', 'OFPGC_DELETE']
-OFPGC_ADD = 0
-OFPGC_MODIFY = 1
-OFPGC_DELETE = 2
-ofp_group_mod_command_map = {
- 0 : 'OFPGC_ADD',
- 1 : 'OFPGC_MODIFY',
- 2 : 'OFPGC_DELETE'
-}
-
-ofp_port_features = ['OFPPF_10MB_HD', 'OFPPF_10MB_FD', 'OFPPF_100MB_HD', 'OFPPF_100MB_FD', 'OFPPF_1GB_HD', 'OFPPF_1GB_FD', 'OFPPF_10GB_FD', 'OFPPF_40GB_FD', 'OFPPF_100GB_FD', 'OFPPF_1TB_FD', 'OFPPF_OTHER', 'OFPPF_COPPER', 'OFPPF_FIBER', 'OFPPF_AUTONEG', 'OFPPF_PAUSE', 'OFPPF_PAUSE_ASYM']
-OFPPF_10MB_HD = 1
-OFPPF_10MB_FD = 2
-OFPPF_100MB_HD = 4
-OFPPF_100MB_FD = 8
-OFPPF_1GB_HD = 16
-OFPPF_1GB_FD = 32
-OFPPF_10GB_FD = 64
-OFPPF_40GB_FD = 128
-OFPPF_100GB_FD = 256
-OFPPF_1TB_FD = 512
-OFPPF_OTHER = 1024
-OFPPF_COPPER = 2048
-OFPPF_FIBER = 4096
-OFPPF_AUTONEG = 8192
-OFPPF_PAUSE = 16384
-OFPPF_PAUSE_ASYM = 32768
-ofp_port_features_map = {
- 1 : 'OFPPF_10MB_HD',
- 2 : 'OFPPF_10MB_FD',
- 4 : 'OFPPF_100MB_HD',
- 8 : 'OFPPF_100MB_FD',
- 16 : 'OFPPF_1GB_HD',
- 32 : 'OFPPF_1GB_FD',
- 64 : 'OFPPF_10GB_FD',
- 128 : 'OFPPF_40GB_FD',
- 256 : 'OFPPF_100GB_FD',
- 512 : 'OFPPF_1TB_FD',
- 1024 : 'OFPPF_OTHER',
- 2048 : 'OFPPF_COPPER',
- 4096 : 'OFPPF_FIBER',
- 8192 : 'OFPPF_AUTONEG',
- 16384 : 'OFPPF_PAUSE',
- 32768 : 'OFPPF_PAUSE_ASYM'
-}
-
-ofp_group_mod_failed_code = ['OFPGMFC_GROUP_EXISTS', 'OFPGMFC_INVALID_GROUP', 'OFPGMFC_OUT_OF_GROUPS', 'OFPGMFC_OUT_OF_BUCKETS', 'OFPGMFC_CHAINING_UNSUPPORTED', 'OFPGMFC_WATCH_UNSUPPORTED', 'OFPGMFC_LOOP', 'OFPGMFC_UNKNOWN_GROUP', 'OFPGMFC_CHAINED_GROUP', 'OFPGMFC_BAD_TYPE', 'OFPGMFC_BAD_COMMAND', 'OFPGMFC_BAD_BUCKET', 'OFPGMFC_BAD_WATCH', 'OFPGMFC_EPERM']
-OFPGMFC_GROUP_EXISTS = 0
-OFPGMFC_INVALID_GROUP = 1
-OFPGMFC_OUT_OF_GROUPS = 3
-OFPGMFC_OUT_OF_BUCKETS = 4
-OFPGMFC_CHAINING_UNSUPPORTED = 5
-OFPGMFC_WATCH_UNSUPPORTED = 6
-OFPGMFC_LOOP = 7
-OFPGMFC_UNKNOWN_GROUP = 8
-OFPGMFC_CHAINED_GROUP = 9
-OFPGMFC_BAD_TYPE = 10
-OFPGMFC_BAD_COMMAND = 11
-OFPGMFC_BAD_BUCKET = 12
-OFPGMFC_BAD_WATCH = 13
-OFPGMFC_EPERM = 14
-ofp_group_mod_failed_code_map = {
- 0 : 'OFPGMFC_GROUP_EXISTS',
- 1 : 'OFPGMFC_INVALID_GROUP',
- 3 : 'OFPGMFC_OUT_OF_GROUPS',
- 4 : 'OFPGMFC_OUT_OF_BUCKETS',
- 5 : 'OFPGMFC_CHAINING_UNSUPPORTED',
- 6 : 'OFPGMFC_WATCH_UNSUPPORTED',
- 7 : 'OFPGMFC_LOOP',
- 8 : 'OFPGMFC_UNKNOWN_GROUP',
- 9 : 'OFPGMFC_CHAINED_GROUP',
- 10 : 'OFPGMFC_BAD_TYPE',
- 11 : 'OFPGMFC_BAD_COMMAND',
- 12 : 'OFPGMFC_BAD_BUCKET',
- 13 : 'OFPGMFC_BAD_WATCH',
- 14 : 'OFPGMFC_EPERM'
-}
-
-# Values from macro definitions
-OFP_ETH_ALEN = 6
-OFP_MAX_PORT_NAME_LEN = 16
-OFP_TCP_PORT = 6633
-OFP_FLOW_PERMANENT = 0
-OFPQ_MIN_RATE_UNCFG = 0xffff
-OFPQ_ALL = 0xffffffff
-OFP_VERSION = 0x03
-OFP_MAX_TABLE_NAME_LEN = 32
-OFP_DEFAULT_PRIORITY = 0x8000
-OFP_NO_BUFFER = 0xffffffff
-OFP_SSL_PORT = 6633
-OFP_DEFAULT_MISS_SEND_LEN = 128
-DESC_STR_LEN = 256
-SERIAL_NUM_LEN = 32
-
-# Basic structure size definitions.
-# Does not include ofp_header members.
-# Does not include variable length arrays.
-OFP_ACTION_EXPERIMENTER_HEADER_BYTES = 8
-OFP_ACTION_GROUP_BYTES = 8
-OFP_ACTION_HEADER_BYTES = 8
-OFP_ACTION_MPLS_TTL_BYTES = 8
-OFP_ACTION_NW_TTL_BYTES = 8
-OFP_ACTION_OUTPUT_BYTES = 16
-OFP_ACTION_POP_MPLS_BYTES = 8
-OFP_ACTION_PUSH_BYTES = 8
-OFP_ACTION_SET_FIELD_BYTES = 8
-OFP_ACTION_SET_QUEUE_BYTES = 8
-OFP_AGGREGATE_STATS_REPLY_BYTES = 24
-OFP_AGGREGATE_STATS_REQUEST_BYTES = 36
-OFP_BUCKET_BYTES = 16
-OFP_BUCKET_COUNTER_BYTES = 16
-OFP_DESC_STATS_BYTES = 1056
-OFP_ERROR_EXPERIMENTER_MSG_BYTES = 8
-OFP_ERROR_MSG_BYTES = 4
-OFP_EXPERIMENTER_HEADER_BYTES = 8
-OFP_EXPERIMENTER_STATS_HEADER_BYTES = 8
-OFP_FLOW_MOD_BYTES = 44
-OFP_FLOW_REMOVED_BYTES = 44
-OFP_FLOW_STATS_BYTES = 52
-OFP_FLOW_STATS_REQUEST_BYTES = 36
-OFP_GROUP_DESC_STATS_BYTES = 8
-OFP_GROUP_FEATURES_STATS_BYTES = 40
-OFP_GROUP_MOD_BYTES = 8
-OFP_GROUP_STATS_BYTES = 32
-OFP_GROUP_STATS_REQUEST_BYTES = 8
-OFP_HEADER_BYTES = 8
-OFP_HELLO_BYTES = 0
-OFP_INSTRUCTION_BYTES = 8
-OFP_INSTRUCTION_ACTIONS_BYTES = 8
-OFP_INSTRUCTION_GOTO_TABLE_BYTES = 8
-OFP_INSTRUCTION_WRITE_METADATA_BYTES = 24
-OFP_MATCH_BYTES = 4
-OFP_OXM_EXPERIMENTER_HEADER_BYTES = 8
-OFP_PACKET_IN_BYTES = 12
-OFP_PACKET_OUT_BYTES = 16
-OFP_PACKET_QUEUE_BYTES = 16
-OFP_PORT_BYTES = 64
-OFP_PORT_MOD_BYTES = 32
-OFP_PORT_STATS_BYTES = 104
-OFP_PORT_STATS_REQUEST_BYTES = 8
-OFP_PORT_STATUS_BYTES = 72
-OFP_QUEUE_GET_CONFIG_REPLY_BYTES = 8
-OFP_QUEUE_GET_CONFIG_REQUEST_BYTES = 8
-OFP_QUEUE_PROP_EXPERIMENTER_BYTES = 16
-OFP_QUEUE_PROP_HEADER_BYTES = 8
-OFP_QUEUE_PROP_MAX_RATE_BYTES = 16
-OFP_QUEUE_PROP_MIN_RATE_BYTES = 16
-OFP_QUEUE_STATS_BYTES = 32
-OFP_QUEUE_STATS_REQUEST_BYTES = 8
-OFP_ROLE_REQUEST_BYTES = 16
-OFP_STATS_REPLY_BYTES = 8
-OFP_STATS_REQUEST_BYTES = 8
-OFP_SWITCH_CONFIG_BYTES = 4
-OFP_SWITCH_FEATURES_BYTES = 24
-OFP_TABLE_MOD_BYTES = 8
-OFP_TABLE_STATS_BYTES = 128
-
diff --git a/src/python/of12/error.py b/src/python/of12/error.py
deleted file mode 100644
index 0a1244a..0000000
--- a/src/python/of12/error.py
+++ /dev/null
@@ -1,556 +0,0 @@
-
-# Python OpenFlow error wrapper classes
-
-from cstruct import *
-
-
-
-class hello_failed_error_msg(ofp_error_msg):
- """
- Wrapper class for hello_failed error message class
-
- Data members inherited from ofp_error_msg:
- @arg type
- @arg code
- @arg data: Binary string following message members
-
- """
- def __init__(self):
- ofp_error_msg.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_ERROR
- self.type = OFPET_HELLO_FAILED
- self.data = ""
-
- def pack(self, assertstruct=True):
- self.header.length = self.__len__()
- packed = self.header.pack()
- packed += ofp_error_msg.pack(self)
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_error_msg.unpack(self, binary_string)
- self.data = binary_string
- return ""
-
- def __len__(self):
- return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
-
- def show(self, prefix=''):
- outstr = prefix + "hello_failed_error_msg\m"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_error_msg.show(self, prefix + ' ')
- outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
- ##@todo Consider trying to parse the string
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_error_msg.__eq__(self, other) and
- self.data == other.data)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class bad_request_error_msg(ofp_error_msg):
- """
- Wrapper class for bad_request error message class
-
- Data members inherited from ofp_error_msg:
- @arg type
- @arg code
- @arg data: Binary string following message members
-
- """
- def __init__(self):
- ofp_error_msg.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_ERROR
- self.type = OFPET_BAD_REQUEST
- self.data = ""
-
- def pack(self, assertstruct=True):
- self.header.length = self.__len__()
- packed = self.header.pack()
- packed += ofp_error_msg.pack(self)
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_error_msg.unpack(self, binary_string)
- self.data = binary_string
- return ""
-
- def __len__(self):
- return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
-
- def show(self, prefix=''):
- outstr = prefix + "bad_request_error_msg\m"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_error_msg.show(self, prefix + ' ')
- outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
- ##@todo Consider trying to parse the string
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_error_msg.__eq__(self, other) and
- self.data == other.data)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class bad_action_error_msg(ofp_error_msg):
- """
- Wrapper class for bad_action error message class
-
- Data members inherited from ofp_error_msg:
- @arg type
- @arg code
- @arg data: Binary string following message members
-
- """
- def __init__(self):
- ofp_error_msg.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_ERROR
- self.type = OFPET_BAD_ACTION
- self.data = ""
-
- def pack(self, assertstruct=True):
- self.header.length = self.__len__()
- packed = self.header.pack()
- packed += ofp_error_msg.pack(self)
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_error_msg.unpack(self, binary_string)
- self.data = binary_string
- return ""
-
- def __len__(self):
- return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
-
- def show(self, prefix=''):
- outstr = prefix + "bad_action_error_msg\m"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_error_msg.show(self, prefix + ' ')
- outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
- ##@todo Consider trying to parse the string
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_error_msg.__eq__(self, other) and
- self.data == other.data)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class bad_instruction_error_msg(ofp_error_msg):
- """
- Wrapper class for bad_instruction error message class
-
- Data members inherited from ofp_error_msg:
- @arg type
- @arg code
- @arg data: Binary string following message members
-
- """
- def __init__(self):
- ofp_error_msg.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_ERROR
- self.type = OFPET_BAD_INSTRUCTION
- self.data = ""
-
- def pack(self, assertstruct=True):
- self.header.length = self.__len__()
- packed = self.header.pack()
- packed += ofp_error_msg.pack(self)
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_error_msg.unpack(self, binary_string)
- self.data = binary_string
- return ""
-
- def __len__(self):
- return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
-
- def show(self, prefix=''):
- outstr = prefix + "bad_instruction_error_msg\m"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_error_msg.show(self, prefix + ' ')
- outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
- ##@todo Consider trying to parse the string
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_error_msg.__eq__(self, other) and
- self.data == other.data)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class bad_match_error_msg(ofp_error_msg):
- """
- Wrapper class for bad_match error message class
-
- Data members inherited from ofp_error_msg:
- @arg type
- @arg code
- @arg data: Binary string following message members
-
- """
- def __init__(self):
- ofp_error_msg.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_ERROR
- self.type = OFPET_BAD_MATCH
- self.data = ""
-
- def pack(self, assertstruct=True):
- self.header.length = self.__len__()
- packed = self.header.pack()
- packed += ofp_error_msg.pack(self)
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_error_msg.unpack(self, binary_string)
- self.data = binary_string
- return ""
-
- def __len__(self):
- return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
-
- def show(self, prefix=''):
- outstr = prefix + "bad_match_error_msg\m"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_error_msg.show(self, prefix + ' ')
- outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
- ##@todo Consider trying to parse the string
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_error_msg.__eq__(self, other) and
- self.data == other.data)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class flow_mod_failed_error_msg(ofp_error_msg):
- """
- Wrapper class for flow_mod_failed error message class
-
- Data members inherited from ofp_error_msg:
- @arg type
- @arg code
- @arg data: Binary string following message members
-
- """
- def __init__(self):
- ofp_error_msg.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_ERROR
- self.type = OFPET_FLOW_MOD_FAILED
- self.data = ""
-
- def pack(self, assertstruct=True):
- self.header.length = self.__len__()
- packed = self.header.pack()
- packed += ofp_error_msg.pack(self)
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_error_msg.unpack(self, binary_string)
- self.data = binary_string
- return ""
-
- def __len__(self):
- return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
-
- def show(self, prefix=''):
- outstr = prefix + "flow_mod_failed_error_msg\m"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_error_msg.show(self, prefix + ' ')
- outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
- ##@todo Consider trying to parse the string
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_error_msg.__eq__(self, other) and
- self.data == other.data)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class group_mod_failed_error_msg(ofp_error_msg):
- """
- Wrapper class for group_mod_failed error message class
-
- Data members inherited from ofp_error_msg:
- @arg type
- @arg code
- @arg data: Binary string following message members
-
- """
- def __init__(self):
- ofp_error_msg.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_ERROR
- self.type = OFPET_GROUP_MOD_FAILED
- self.data = ""
-
- def pack(self, assertstruct=True):
- self.header.length = self.__len__()
- packed = self.header.pack()
- packed += ofp_error_msg.pack(self)
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_error_msg.unpack(self, binary_string)
- self.data = binary_string
- return ""
-
- def __len__(self):
- return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
-
- def show(self, prefix=''):
- outstr = prefix + "group_mod_failed_error_msg\m"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_error_msg.show(self, prefix + ' ')
- outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
- ##@todo Consider trying to parse the string
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_error_msg.__eq__(self, other) and
- self.data == other.data)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class port_mod_failed_error_msg(ofp_error_msg):
- """
- Wrapper class for port_mod_failed error message class
-
- Data members inherited from ofp_error_msg:
- @arg type
- @arg code
- @arg data: Binary string following message members
-
- """
- def __init__(self):
- ofp_error_msg.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_ERROR
- self.type = OFPET_PORT_MOD_FAILED
- self.data = ""
-
- def pack(self, assertstruct=True):
- self.header.length = self.__len__()
- packed = self.header.pack()
- packed += ofp_error_msg.pack(self)
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_error_msg.unpack(self, binary_string)
- self.data = binary_string
- return ""
-
- def __len__(self):
- return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
-
- def show(self, prefix=''):
- outstr = prefix + "port_mod_failed_error_msg\m"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_error_msg.show(self, prefix + ' ')
- outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
- ##@todo Consider trying to parse the string
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_error_msg.__eq__(self, other) and
- self.data == other.data)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class table_mod_failed_error_msg(ofp_error_msg):
- """
- Wrapper class for table_mod_failed error message class
-
- Data members inherited from ofp_error_msg:
- @arg type
- @arg code
- @arg data: Binary string following message members
-
- """
- def __init__(self):
- ofp_error_msg.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_ERROR
- self.type = OFPET_TABLE_MOD_FAILED
- self.data = ""
-
- def pack(self, assertstruct=True):
- self.header.length = self.__len__()
- packed = self.header.pack()
- packed += ofp_error_msg.pack(self)
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_error_msg.unpack(self, binary_string)
- self.data = binary_string
- return ""
-
- def __len__(self):
- return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
-
- def show(self, prefix=''):
- outstr = prefix + "table_mod_failed_error_msg\m"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_error_msg.show(self, prefix + ' ')
- outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
- ##@todo Consider trying to parse the string
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_error_msg.__eq__(self, other) and
- self.data == other.data)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class queue_op_failed_error_msg(ofp_error_msg):
- """
- Wrapper class for queue_op_failed error message class
-
- Data members inherited from ofp_error_msg:
- @arg type
- @arg code
- @arg data: Binary string following message members
-
- """
- def __init__(self):
- ofp_error_msg.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_ERROR
- self.type = OFPET_QUEUE_OP_FAILED
- self.data = ""
-
- def pack(self, assertstruct=True):
- self.header.length = self.__len__()
- packed = self.header.pack()
- packed += ofp_error_msg.pack(self)
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_error_msg.unpack(self, binary_string)
- self.data = binary_string
- return ""
-
- def __len__(self):
- return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
-
- def show(self, prefix=''):
- outstr = prefix + "queue_op_failed_error_msg\m"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_error_msg.show(self, prefix + ' ')
- outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
- ##@todo Consider trying to parse the string
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_error_msg.__eq__(self, other) and
- self.data == other.data)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class switch_config_failed_error_msg(ofp_error_msg):
- """
- Wrapper class for switch_config_failed error message class
-
- Data members inherited from ofp_error_msg:
- @arg type
- @arg code
- @arg data: Binary string following message members
-
- """
- def __init__(self):
- ofp_error_msg.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_ERROR
- self.type = OFPET_SWITCH_CONFIG_FAILED
- self.data = ""
-
- def pack(self, assertstruct=True):
- self.header.length = self.__len__()
- packed = self.header.pack()
- packed += ofp_error_msg.pack(self)
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_error_msg.unpack(self, binary_string)
- self.data = binary_string
- return ""
-
- def __len__(self):
- return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
-
- def show(self, prefix=''):
- outstr = prefix + "switch_config_failed_error_msg\m"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_error_msg.show(self, prefix + ' ')
- outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
- ##@todo Consider trying to parse the string
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_error_msg.__eq__(self, other) and
- self.data == other.data)
-
- def __ne__(self, other): return not self.__eq__(other)
-
diff --git a/src/python/of12/instruction.py b/src/python/of12/instruction.py
deleted file mode 100644
index a945525..0000000
--- a/src/python/of12/instruction.py
+++ /dev/null
@@ -1,143 +0,0 @@
-
-# Python OpenFlow instruction wrapper classes
-
-from cstruct import *
-from action_list import action_list
-
-
-
-class instruction_write_metadata(ofp_instruction_write_metadata):
- """
- Wrapper class for write_metadata instruction object
-
- Data members inherited from ofp_instruction_write_metadata:
- @arg type
- @arg len
- @arg metadata
- @arg metadata_mask
-
- """
- def __init__(self):
- ofp_instruction_write_metadata.__init__(self)
- self.type = OFPIT_WRITE_METADATA
- self.len = self.__len__()
- def show(self, prefix=''):
- outstr = prefix + "instruction_write_metadata\n"
- outstr += ofp_instruction_write_metadata.show(self, prefix)
- return outstr
-
-
-class instruction_goto_table(ofp_instruction_goto_table):
- """
- Wrapper class for goto_table instruction object
-
- Data members inherited from ofp_instruction_goto_table:
- @arg type
- @arg len
- @arg table_id
-
- """
- def __init__(self):
- ofp_instruction_goto_table.__init__(self)
- self.type = OFPIT_GOTO_TABLE
- self.len = self.__len__()
- def show(self, prefix=''):
- outstr = prefix + "instruction_goto_table\n"
- outstr += ofp_instruction_goto_table.show(self, prefix)
- return outstr
-
-
-class instruction_write_actions(ofp_instruction_actions):
- """
- Wrapper class for write_actions instruction object
-
- Data members inherited from ofp_instruction_actions:
- @arg type
- @arg len
-
- """
- def __init__(self):
- ofp_instruction_actions.__init__(self)
- self.type = OFPIT_WRITE_ACTIONS
- self.actions = action_list()
- self.len = self.__len__()
- def show(self, prefix=''):
- outstr = prefix + "instruction_write_actions\n"
- outstr += ofp_instruction_actions.show(self, prefix)
- outstr += self.actions.show(prefix)
- return outstr
- def unpack(self, binary_string):
- binary_string = ofp_instruction_actions.unpack(self, binary_string)
- bytes = self.len - OFP_INSTRUCTION_ACTIONS_BYTES
- self.actions = action_list()
- binary_string = self.actions.unpack(binary_string, bytes=bytes)
- return binary_string
- def pack(self):
- self.len = self.__len__()
- packed = ""
- packed += ofp_instruction_actions.pack(self)
- packed += self.actions.pack()
- return packed
- def __len__(self):
- return ofp_instruction_actions.__len__(self) + self.actions.__len__()
-
-
-class instruction_apply_actions(ofp_instruction_actions):
- """
- Wrapper class for apply_actions instruction object
-
- Data members inherited from ofp_instruction_actions:
- @arg type
- @arg len
-
- """
- def __init__(self):
- ofp_instruction_actions.__init__(self)
- self.type = OFPIT_APPLY_ACTIONS
- self.actions = action_list()
- self.len = self.__len__()
- def show(self, prefix=''):
- outstr = prefix + "instruction_apply_actions\n"
- outstr += ofp_instruction_actions.show(self, prefix)
- outstr += self.actions.show(prefix)
- return outstr
- def unpack(self, binary_string):
- binary_string = ofp_instruction_actions.unpack(self, binary_string)
- bytes = self.len - OFP_INSTRUCTION_ACTIONS_BYTES
- self.actions = action_list()
- binary_string = self.actions.unpack(binary_string, bytes=bytes)
- return binary_string
- def pack(self):
- self.len = self.__len__()
- packed = ""
- packed += ofp_instruction_actions.pack(self)
- packed += self.actions.pack()
- return packed
- def __len__(self):
- return ofp_instruction_actions.__len__(self) + self.actions.__len__()
-
-
-class instruction_clear_actions(ofp_instruction):
- """
- Wrapper class for clear_actions instruction object
-
- Data members inherited from ofp_instruction:
- @arg type
- @arg len
-
- """
- def __init__(self):
- ofp_instruction.__init__(self)
- self.type = OFPIT_CLEAR_ACTIONS
- self.len = self.__len__()
- def show(self, prefix=''):
- outstr = prefix + "instruction_clear_actions\n"
- outstr += ofp_instruction.show(self, prefix)
- return outstr
-
-instruction_class_list = (
- instruction_apply_actions,
- instruction_clear_actions,
- instruction_goto_table,
- instruction_write_actions,
- instruction_write_metadata)
diff --git a/src/python/of12/instruction_list.py b/src/python/of12/instruction_list.py
deleted file mode 100644
index 7b03fbf..0000000
--- a/src/python/of12/instruction_list.py
+++ /dev/null
@@ -1,96 +0,0 @@
-"""
-OpenFlow instruction list class
-"""
-
-import action as action
-import instruction as instruction
-from action_list import action_list
-from base_list import ofp_base_list
-from cstruct import ofp_header
-import unittest
-
-# Instruction list
-
-instruction_object_map = {
- action.OFPIT_GOTO_TABLE : instruction.instruction_goto_table,
- action.OFPIT_WRITE_METADATA : instruction.instruction_write_metadata,
- action.OFPIT_WRITE_ACTIONS : instruction.instruction_write_actions,
- action.OFPIT_APPLY_ACTIONS : instruction.instruction_apply_actions,
- action.OFPIT_CLEAR_ACTIONS : instruction.instruction_clear_actions,
-}
-
-class instruction_list(ofp_base_list):
- """
- Maintain a list of instructions
-
- Data members:
- @arg instructions An array of instructions such as write_actions
-
- Methods:
- @arg pack: Pack the structure into a string
- @arg unpack: Unpack a string to objects, with proper typing
- @arg add: Add an action to the list; you can directly access
- the action member, but add will validate that the added object
- is an action.
-
- """
-
- def __init__(self):
- ofp_base_list.__init__(self)
- self.instructions = self.items
- self.name = "instruction"
- self.class_list = instruction.instruction_class_list
-
- def unpack(self, binary_string, bytes=None):
- """
- Unpack a list of instructions
-
- Unpack instructions from a binary string, creating an array
- of objects of the appropriate type
-
- @param binary_string The string to be unpacked
-
- @param bytes The total length of the instruction list in bytes.
- Ignored if decode is True. If bytes is None and decode is false, the
- list is assumed to extend through the entire string.
-
- @return The remainder of binary_string that was not parsed
-
- """
- if bytes == None:
- bytes = len(binary_string)
- bytes_done = 0
- count = 0
- cur_string = binary_string
- while bytes_done < bytes:
- hdr = instruction.ofp_instruction()
- hdr.unpack(cur_string)
- if hdr.len < action.OFP_ACTION_HEADER_BYTES:
- print "ERROR: Action too short"
- break
- if not hdr.type in instruction_object_map.keys():
- print "WARNING: Skipping unknown action ", hdr.type, hdr.len
- else:
- self.instructions.append(instruction_object_map[hdr.type]())
- self.instructions[count].unpack(cur_string)
- count += 1
- cur_string = cur_string[hdr.len:]
- bytes_done += hdr.len
- return cur_string
-
-class Instruction_List_Test(unittest.TestCase):
- def runTest(self):
- # instructions header is 8 bytes
- l = instruction_list()
- act = action.action_output()
- act.port = 7
- inst = instruction.instruction_apply_actions()
- self.assertTrue(inst.actions.add(act))
- self.assertTrue(l.add(inst))
- pkt = l.pack()
- # 24 == 8 (list header) + (apply header) 8 + (output action) 8
- self.assertEqual(len(pkt),24)
-
- l = instruction_list()
- self.assertTrue(l.add(instruction.instruction_goto_table()))
-
diff --git a/src/python/of12/match.py b/src/python/of12/match.py
deleted file mode 100644
index c732467..0000000
--- a/src/python/of12/match.py
+++ /dev/null
@@ -1,893 +0,0 @@
-
-# Python OpenFlow instruction wrapper classes
-
-import struct
-import ipaddr
-import socket
-from cstruct import *
-
-
-class oxm_tlv(object):
- def __init__(self, field, hasmask, length, value, mask=None,
- class_ = 0x8000):
- self.class_ = class_
- self.field = field
- self.hasmask = hasmask
- self.length = length
- self.value = value
- self.mask = mask
-
- def __eq__(self, other):
- return (self.class_ == other.class_ and self.field == other.field
- and self.hasmask == other.hasmask and
- self.length == other.length and self.value == other.value and
- self.mask == self.mask)
-
- def pack(self, assertstruct=True):
-
- packed = ""
- packed += struct.pack("!I", ((self.class_ << 16) | (self.field << 9) |
- (self.hasmask << 8) | self.length))
- if self.length == 1:
- packed += struct.pack("B", self.value)
- if self.hasmask:
- packed += struct.pack("B", self.mask)
- elif self.length == 2 or (self.length == 4 and self.hasmask == True):
- packed += struct.pack("!H", self.value)
- if self.hasmask:
- packed += struct.pack("!H", self.mask)
- elif self.length == 4 or (self.length == 8 and self.hasmask == True):
- packed += struct.pack("!I", self.value)
- if self.hasmask:
- packed += struct.pack("!I", self.mask)
- elif self.length == 6 or self.length == 12:
- packed += struct.pack("!BBBBBB", self.value[0],self.value[1],
- self.value[2],self.value[3],self.value[4],self.value[5])
- if self.hasmask:
- packed += struct.pack("!BBBBBB", self.mask[0],self.mask[1],
- self.mask[2],self.mask[3],self.mask[4],self.mask[5])
- elif self.length == 8 or (self.length == 16 and self.hasmask == True):
- packed += struct.pack("!Q", self.value)
- if self.hasmask:
- packed += struct.pack("!Q", self.mask)
- elif self.length == 16 or self.length == 32:
- packed += self.value.packed
- if self.hasmask:
- packed += self.mask.packed
- return packed
-
- def __len__(self):
- return self.length + 4
-
- def show(self, prefix=''):
- return "\n".join(
-# ("oxm_tlv_class=" + hex(self.class_),
- (prefix + "oxm_tlv_class=" + hex(self.class_),
- prefix + "oxm_tlv_field=" + str(self.field),
- prefix +"oxm_tlv_hasmask=" + str(bool(self.hasmask)),
- prefix +"oxm_tlv_length: " + str(self.length) + "\n",))
-
-
- subclasses = {}
-
- def set_value(self, value):
- self.value = value
-
- def set_hasmask(self, hasmask):
- self.hasmask = hasmask
-
- def set_mask(self, mask):
- self.mask = mask
-
- @staticmethod
- def factory():
- for subclass in oxm_tlv.__subclasses__():
- obj = subclass()
- oxm_tlv.subclasses[obj.field] = subclass
-
- @staticmethod
- def create(field):
- return oxm_tlv.subclasses[field]()
-
-
-
-def roundup (x,y):
- return (((x) + ((y) - 1)) / (y) * (y))
-
-class in_port(oxm_tlv):
- """
- Wrapper class for in_port match object
-
- Data members inherited from oxm_tlv:
- @arg class
- @arg field
- @arg hasmask
- @arg body
-
- """
- def __init__(self, value=None, hasmask=False):
- oxm_tlv.__init__(self, OFPXMT_OFB_IN_PORT , hasmask, 4, value)
- def show(self, prefix=''):
- outstr = prefix + "name = in_port\n"
- outstr += oxm_tlv.show(self, prefix)
- outstr += prefix + "value = " + str(self.value) +"\n"
- return outstr
-
-
-class in_phy_port(oxm_tlv):
- """
- Wrapper class for in_phy_port match object
-
- Data members inherited from oxm_tlv:
- @arg class
- @arg field
- @arg hasmask
- @arg body
-
- """
- def __init__(self, value=None, hasmask=False):
- oxm_tlv.__init__(self,OFPXMT_OFB_IN_PHY_PORT, hasmask, 4, value)
- def show(self, prefix=''):
- outstr = prefix + "name = in_phy_port\n"
- outstr += oxm_tlv.show(self, prefix)
- outstr += prefix + "value = " + str(self.value) +"\n"
- return outstr
-
-
-class metadata(oxm_tlv):
- """
- Wrapper class for metadata match object
-
- Data members inherited from oxm_tlv:
- @arg class
- @arg field
- @arg hasmask
- @arg body
-
- """
- def __init__(self, value=None, mask =None):
- if mask == None:
- oxm_tlv.__init__(self, OFPXMT_OFB_METADATA, False, 8, value)
- else:
- oxm_tlv.__init__(self, OFPXMT_OFB_METADATA, True, 16, value, mask)
- def show(self, prefix=''):
- outstr = prefix + "name = metadata\n"
- outstr += oxm_tlv.show(self, prefix)
- outstr += prefix + "value = " + str(self.value) +"\n"
- return outstr
-
-class eth_dst(oxm_tlv):
- """
- Wrapper class for eth_dst match object
-
- Data members inherited from oxm_tlv:
- @arg class
- @arg field
- @arg hasmask
- @arg body
-
- """
- def __init__(self, value=None, mask=None):
- if mask == None:
- oxm_tlv.__init__(self, OFPXMT_OFB_ETH_DST, False, 6, value)
- else:
- oxm_tlv.__init__(self, OFPXMT_OFB_ETH_DST, True, 12, value, mask)
- def show(self, prefix=''):
- outstr = prefix + "name = eth_dst\n"
- outstr += oxm_tlv.show(self, prefix)
- outstr += prefix + "value = " + ":".join(["%.2x" %x
- for x in self.value]) +"\n"
- return outstr
-
-class eth_src(oxm_tlv):
- """
- Wrapper class for eth_src match object
-
- Data members inherited from oxm_tlv:
- @arg class
- @arg field
- @arg hasmask
- @arg body
-
- """
- def __init__(self, value=None, hasmask=False):
- if not hasmask:
- oxm_tlv.__init__(self, OFPXMT_OFB_ETH_SRC, hasmask, 6, value)
- else:
- oxm_tlv.__init__(self, OFPXMT_OFB_ETH_SRC, hasmask, 12,
- value, mask)
- def show(self, prefix=''):
- outstr = prefix + "name = eth_src\n"
- outstr += oxm_tlv.show(self, prefix)
- outstr += prefix + "value = " + ":".join(["%.2x" %x
- for x in self.value]) +"\n"
- return outstr
-
-class eth_type(oxm_tlv):
- """
- Wrapper class for eth_type match object
-
- Data members inherited from oxm_tlv:
- @arg class
- @arg field
- @arg hasmask
- @arg body
-
- """
- def __init__(self, value=None, hasmask=False):
- oxm_tlv.__init__(self, OFPXMT_OFB_ETH_TYPE, hasmask, 2, value)
- def show(self, prefix=''):
- outstr = prefix + "name = eth_type\n"
- outstr += oxm_tlv.show(self, prefix)
- outstr += prefix + "value = " + hex(self.value) +"\n"
- return outstr
-
-class vlan_vid(oxm_tlv):
- """
- Wrapper class for vlan_vid match object
-
- Data members inherited from oxm_tlv:
- @arg class
- @arg field
- @arg hasmask
- @arg body
-
- """
- def __init__(self, value=None, hasmask=False):
- oxm_tlv.__init__(self, OFPXMT_OFB_VLAN_VID, hasmask, 2, value)
- def show(self, prefix=''):
- outstr = prefix + "name = vlan_vid\n"
- outstr += oxm_tlv.show(self, prefix)
- outstr += prefix + "value = " + str(self.value) +"\n"
- return outstr
-
-class vlan_pcp(oxm_tlv):
- """
- Wrapper class for vlan_pcp match object
-
- Data members inherited from oxm_tlv:
- @arg class
- @arg field
- @arg hasmask
- @arg body
-
- """
- def __init__(self, value=None, hasmask=False):
- oxm_tlv.__init__(self, OFPXMT_OFB_VLAN_PCP, hasmask, 1, value)
- def show(self, prefix=''):
- outstr = prefix + "name = vlan_pcp\n"
- outstr += oxm_tlv.show(self, prefix)
- outstr += prefix + "value = " + str(self.value) +"\n"
- return outstr
-
-class ip_dscp(oxm_tlv):
- """
- Wrapper class for ip_dscp match object
-
- Data members inherited from oxm_tlv:
- @arg class
- @arg field
- @arg hasmask
- @arg body
-
- """
- def __init__(self, value=None, hasmask=False):
- oxm_tlv.__init__(self, OFPXMT_OFB_IP_DSCP, hasmask, 1, value)
- def show(self, prefix=''):
- outstr = prefix + "name = ip_dscp\n"
- outstr += oxm_tlv.show(self, prefix)
- outstr += prefix + "value = " + str(self.value) +"\n"
- return outstr
-
-class ip_ecn(oxm_tlv):
- """
- Wrapper class for ip_dscp match object
-
- Data members inherited from oxm_tlv:
- @arg class
- @arg field
- @arg hasmask
- @arg body
-
- """
- def __init__(self, value=None, hasmask=False):
- oxm_tlv.__init__(self, OFPXMT_OFB_IP_ECN, hasmask, 1, value)
- def show(self, prefix=''):
- outstr = prefix + "name = ip_ecn\n"
- outstr += oxm_tlv.show(self, prefix)
- outstr += prefix + "value = " + str(self.value) +"\n"
- return outstr
-
-class ip_proto(oxm_tlv):
- """
- Wrapper class for ip_proto match object
-
- Data members inherited from oxm_tlv:
- @arg class
- @arg field
- @arg hasmask
- @arg body
-
- """
- def __init__(self, value=None, hasmask=False):
- oxm_tlv.__init__(self, OFPXMT_OFB_IP_PROTO, hasmask, 1, value)
- def show(self, prefix=''):
- outstr = prefix + "name = ip_proto\n"
- outstr += oxm_tlv.show(self, prefix)
- outstr += prefix + "value = " + str(self.value) +"\n"
- return outstr
-
-class ipv4_src(oxm_tlv):
- """
- Wrapper class for ipv4_src match object
-
- Data members inherited from oxm_tlv:
- @arg class
- @arg field
- @arg hasmask
- @arg body
-
- """
- def __init__(self, value=None, hasmask=False):
- if not hasmask:
- oxm_tlv.__init__(self, OFPXMT_OFB_IPV4_SRC, hasmask, 4, value)
- else:
- oxm_tlv.__init__(self, OFPXMT_OFB_IPV4_SRC, hasmask, 4, value, mask)
- def show(self, prefix=''):
- outstr = prefix + "name = ipv4_src\n"
- outstr += oxm_tlv.show(self, prefix)
- #Value can be a long int or a string
- try:
- addr = ipaddr.IPv4Address(self.value)
- except ValueError:
- addr = ipaddr.IPv4Address(int(self.value, 16))
- outstr += prefix + "value = " + str(addr) +"\n"
- return outstr
-
-class ipv4_dst(oxm_tlv):
- """
- Wrapper class for ipv4_dst match object
-
- Data members inherited from oxm_tlv:
- @arg class
- @arg field
- @arg hasmask
- @arg body
-
- """
- def __init__(self, value=None, hasmask=False):
- if not hasmask:
- oxm_tlv.__init__(self, OFPXMT_OFB_IPV4_DST, hasmask, 4, value)
- else:
- oxm_tlv.__init__(self, OFPXMT_OFB_IPV4_DST, hasmask, 4, value, mask)
- def show(self, prefix=''):
- outstr = prefix + "name = ipv4_dst\n"
- outstr += oxm_tlv.show(self, prefix)
- #Value can be a long int or a string
- #try:
- addr = ipaddr.IPv4Address(self.value)
- #except ValueError:
- # addr = ipaddr.IPv4Address(int(self.value, 16))
- outstr += prefix + "value = " + str(addr) +"\n"
- return outstr
-
-class tcp_src(oxm_tlv):
- """
- Wrapper class for tcp_src match object
-
- Data members inherited from oxm_tlv:
- @arg class
- @arg field
- @arg hasmask
- @arg body
-
- """
- def __init__(self, value=None, hasmask=False):
- oxm_tlv.__init__(self, OFPXMT_OFB_TCP_SRC, hasmask, 2, value)
- def show(self, prefix=''):
- outstr = prefix + "name = tcp_src\n"
- outstr += oxm_tlv.show(self, prefix)
- outstr += prefix + "value = " + str(self.value) +"\n"
- return outstr
-
-class tcp_dst(oxm_tlv):
- """
- Wrapper class for tcp_src match object
-
- Data members inherited from oxm_tlv:
- @arg class
- @arg field
- @arg hasmask
- @arg body
-
- """
- def __init__(self, value=None, hasmask=False):
- oxm_tlv.__init__(self, OFPXMT_OFB_TCP_DST, hasmask, 2, value)
- def show(self, prefix=''):
- outstr = prefix + "name = tcp_dst\n"
- outstr += oxm_tlv.show(self, prefix)
- outstr += prefix + "value = " + str(self.value) +"\n"
- return outstr
-
-class udp_src(oxm_tlv):
- """
- Wrapper class for udp_src match object
-
- Data members inherited from oxm_tlv:
- @arg class
- @arg field
- @arg hasmask
- @arg body
-
- """
- def __init__(self, value=None, hasmask=False):
- oxm_tlv.__init__(self, OFPXMT_OFB_UDP_SRC, hasmask, 2, value)
- def show(self, prefix=''):
- outstr = prefix + "name = udp_src\n"
- outstr += oxm_tlv.show(self, prefix)
- outstr += prefix + "value = " + str(self.value) +"\n"
- return outstr
-
-class udp_dst(oxm_tlv):
- """
- Wrapper class for udp_dst match object
-
- Data members inherited from oxm_tlv:
- @arg class
- @arg field
- @arg hasmask
- @arg body
-
- """
- def __init__(self, value=None, hasmask=False):
- oxm_tlv.__init__(self, OFPXMT_OFB_UDP_DST, hasmask, 2, value)
- def show(self, prefix=''):
- outstr = prefix + "name = udp_dst\n"
- outstr += oxm_tlv.show(self, prefix)
- outstr += prefix + "value = " + str(self.value) +"\n"
- return outstr
-
-class sctp_src(oxm_tlv):
- """
- Wrapper class for sctp_src match object
-
- Data members inherited from oxm_tlv:
- @arg class
- @arg field
- @arg hasmask
- @arg body
-
- """
- def __init__(self, value=None, hasmask=False):
- oxm_tlv.__init__(self, OFPXMT_OFB_SCTP_SRC, hasmask, 2, value)
- def show(self, prefix=''):
- outstr = prefix + "name = sctp_src\n"
- outstr += oxm_tlv.show(self, prefix)
- outstr += prefix + "value = " + str(self.value) +"\n"
- return outstr
-
-
-class sctp_dst(oxm_tlv):
- """
- Wrapper class for sctp_dst match object
-
- Data members inherited from oxm_tlv:
- @arg class
- @arg field
- @arg hasmask
- @arg body
-
- """
- def __init__(self, value=None, hasmask=False):
- oxm_tlv.__init__(self, OFPXMT_OFB_SCTP_DST, hasmask, 2, value)
- def show(self, prefix=''):
- outstr = prefix + "name = sctp_dst\n"
- outstr += oxm_tlv.show(self, prefix)
- outstr += prefix + "value = " + str(self.value) +"\n"
- return outstr
-
-class icmpv4_type(oxm_tlv):
- """
- Wrapper class for icmpv4_type match object
-
- Data members inherited from oxm_tlv:
- @arg class
- @arg field
- @arg hasmask
- @arg body
-
- """
- def __init__(self, value=None, hasmask=False):
- oxm_tlv.__init__(self, OFPXMT_OFB_ICMPV4_TYPE, hasmask, 1, value)
- def show(self, prefix=''):
- outstr = prefix + "name = icmpv4_type\n"
- outstr += oxm_tlv.show(self, prefix)
- outstr += prefix + "value = " + str(self.value) +"\n"
- return outstr
-
-class icmpv4_code(oxm_tlv):
- """
- Wrapper class for icmpv4_code match object
-
- Data members inherited from oxm_tlv:
- @arg class
- @arg field
- @arg hasmask
- @arg body
-
- """
- def __init__(self, value=None, hasmask=False):
- oxm_tlv.__init__(self, OFPXMT_OFB_ICMPV4_CODE, hasmask, 1, value)
- def show(self, prefix=''):
- outstr = prefix + "name = icmpv4_code\n"
- outstr += oxm_tlv.show(self, prefix)
- outstr += prefix + "value = " + str(self.value) +"\n"
- return outs
-
-class arp_op(oxm_tlv):
- """
- Wrapper class for arp_op match object
-
- Data members inherited from oxm_tlv:
- @arg class
- @arg field
- @arg hasmask
- @arg body
-
- """
- def __init__(self, value=None, hasmask=False):
- oxm_tlv.__init__(self, OFPXMT_OFB_ARP_OP, hasmask, 2, value)
- def show(self, prefix=''):
- outstr = prefix + "name = arp_op\n"
- outstr += oxm_tlv.show(self, prefix)
- outstr += prefix + "value = " + str(self.value) +"\n"
- return outs
-
-class arp_spa(oxm_tlv):
- """
- Wrapper class for arp_spa match object
-
- Data members inherited from oxm_tlv:
- @arg class
- @arg field
- @arg hasmask
- @arg body
-
- """
- def __init__(self, value=None, hasmask=False):
- if not hasmask:
- oxm_tlv.__init__(self, OFPXMT_OFB_ARP_SPA, hasmask, 4, value)
- else:
- oxm_tlv.__init__(self, OFPXMT_OFB_ARP_SPA, hasmask, 4, value, mask)
- def show(self, prefix=''):
- outstr = prefix + "name = arp_spa\n"
- #Value can be a long int or a string
- try:
- addr = ipaddr.IPv4Address(self.value)
- except ValueError:
- addr = ipaddr.IPv4Address(int(self.value, 16))
- outstr += oxm_tlv.show(self, prefix)
- outstr += prefix + "value = " + str(addr) +"\n"
- return outstr
-
-class arp_tpa(oxm_tlv):
- """
- Wrapper class for arp_tpa match object
-
- Data members inherited from oxm_tlv:
- @arg class
- @arg field
- @arg hasmask
- @arg body
-
- """
- def __init__(self, value=None, hasmask=False):
- if not hasmask:
- oxm_tlv.__init__(self, OFPXMT_OFB_ARP_TPA, hasmask, 4, value)
- else:
- oxm_tlv.__init__(self, OFPXMT_OFB_ARP_TPA, hasmask, 4, value, mask)
- def show(self, prefix=''):
- outstr = prefix + "name = arp_tpa\n"
- #Value can be a long int or a string
- try:
- addr = ipaddr.IPv4Address(self.value)
- except ValueError:
- addr = ipaddr.IPv4Address(int(self.value, 16))
- outstr += oxm_tlv.show(self, prefix)
- outstr += prefix + "value = " + ":".join(["%.2x" %x
- for x in self.value]) +"\n"
- return outstr
-
-
-class arp_sha(oxm_tlv):
- """
- Wrapper class for arp_sha match object
-
- Data members inherited from oxm_tlv:
- @arg class
- @arg field
- @arg hasmask
- @arg body
-
- """
- def __init__(self, value=None, hasmask=False):
- if not hasmask:
- oxm_tlv.__init__(self, OFPXMT_OFB_ARP_SHA, hasmask, 6, value)
- else:
- oxm_tlv.__init__(self, OFPXMT_OFB_ARP_SHA, hasmask, 12, value)
- def show(self, prefix=''):
- outstr = prefix + "name = arp_sha\n"
- outstr += oxm_tlv.show(self, prefix)
- outstr += prefix + "value = " + ":".join(["%.2x" %x
- for x in self.value]) +"\n"
- return outstr
-
-class arp_tha(oxm_tlv):
- """
- Wrapper class for arp_tha match object
-
- Data members inherited from oxm_tlv:
- @arg class
- @arg field
- @arg hasmask
- @arg body
-
- """
- def __init__(self, value=None, hasmask=False):
- if not hasmask:
- oxm_tlv.__init__(self, OFPXMT_OFB_ARP_THA, hasmask, 6, value)
- else:
- oxm_tlv.__init__(self, OFPXMT_OFB_ARP_THA, hasmask, 12, value)
- def show(self, prefix=''):
- outstr = prefix + "name = arp_tha\n"
- outstr += oxm_tlv.show(self, prefix)
- outstr += prefix + "value = " + str(self.value) +"\n"
- return outstr
-
-class ipv6_src(oxm_tlv):
- """
- Wrapper class for ipv6_src match object
-
- Data members inherited from oxm_tlv:
- @arg class
- @arg field
- @arg hasmask
- @arg body
-
- """
- def __init__(self, value=None, hasmask=False):
- if not hasmask:
- oxm_tlv.__init__(self, OFPXMT_OFB_IPV6_SRC, False, 16, value)
- else:
- oxm_tlv.__init__(self, OFPXMT_OFB_IPV6_SRC, True, 32, value)
- def show(self, prefix=''):
- outstr = prefix + "name = ipv6_src\n"
- try:
- addr = ipaddr.IPv6Address(self.value)
- except ValueError:
- addr = ipaddr.IPv6Address(int(self.value, 16))
- outstr += oxm_tlv.show(self, prefix)
- outstr += prefix + "value = " + str(addr) +"\n"
- return outstr
-
-class ipv6_dst(oxm_tlv):
- """
- Wrapper class for ipv6_dst match object
-
- Data members inherited from oxm_tlv:
- @arg class
- @arg field
- @arg hasmask
- @arg body
-
- """
- def __init__(self, value=None, hasmask=False):
- if not hasmask:
- oxm_tlv.__init__(self, OFPXMT_OFB_IPV6_DST, False, 16, value)
- else:
- oxm_tlv.__init__(self, OFPXMT_OFB_IPV6_DST, True, 32, value)
- def show(self, prefix=''):
- outstr = prefix + "name = ipv6_dst\n"
- try:
- addr = ipaddr.IPv6Address(self.value)
- except ValueError:
- addr = ipaddr.IPv6Address(int(self.value, 16))
- outstr += oxm_tlv.show(self, prefix)
- outstr += prefix + "value = " + str(addr) +"\n"
- return outstr
-
-class ipv6_flabel(oxm_tlv):
- """
- Wrapper class for ipv6_flabel match object
-
- Data members inherited from oxm_tlv:
- @arg class
- @arg field
- @arg hasmask
- @arg body
-
- """
- def __init__(self, value=None, hasmask=False):
- if not hasmask:
- oxm_tlv.__init__(self, OFPXMT_OFB_IPV6_FLABEL, hasmask, 4, value)
- else:
- oxm_tlv.__init__(self, OFPXMT_OFB_IPV6_FLABEL, hasmask, 8, value)
- def show(self, prefix=''):
- outstr = prefix + "name = ipv6_flabel\n"
- outstr += oxm_tlv.show(self, prefix)
- return outstr
-
-class icmpv6_type(oxm_tlv):
- """
- Wrapper class for icmpv6_type match object
-
- Data members inherited from oxm_tlv:
- @arg class
- @arg field
- @arg hasmask
- @arg body
-
- """
- def __init__(self, value=None, hasmask=False):
- oxm_tlv.__init__(self, OFPXMT_OFB_ICMPV6_TYPE, hasmask, 1, value)
- def show(self, prefix=''):
- outstr = prefix + "name = icmpv6_type\n"
- outstr += oxm_tlv.show(self, prefix)
- outstr += prefix + "value = " + str(self.value) +"\n"
- return outstr
-
-class icmpv6_code(oxm_tlv):
- """
- Wrapper class for icmpv6_code match object
-
- Data members inherited from oxm_tlv:
- @arg class
- @arg field
- @arg hasmask
- @arg body
-
- """
- def __init__(self, value=None, hasmask=False):
- oxm_tlv.__init__(self, OFPXMT_OFB_ICMPV6_CODE, hasmask, 1, value)
- def show(self, prefix=''):
- outstr = prefix + "name = icmpv6_code\n"
- outstr += oxm_tlv.show(self, prefix)
- outstr += prefix + "value = " + str(self.value) +"\n"
- return outs
-
-class ipv6_nd_target(oxm_tlv):
- """
- Wrapper class for ipv6_nd_target match object
-
- Data members inherited from oxm_tlv:
- @arg class
- @arg field
- @arg hasmask
- @arg body
-
- """
- def __init__(self, value=None, hasmask=False):
- oxm_tlv.__init__(self, OFPXMT_OFB_IPV6_ND_TARGET, hasmask, 16, value)
- def show(self, prefix=''):
- outstr = prefix + "name = ipv6_nd_target\n"
- try:
- addr = ipaddr.IPv6Address(self.value)
- except ValueError:
- addr = ipaddr.IPv6Address(int(self.value, 16))
- outstr += oxm_tlv.show(self, prefix)
- outstr += prefix + "value = " + str(addr) +"\n"
- return outstr
-
-class ipv6_nd_sll(oxm_tlv):
- """
- Wrapper class for ipv6_nd_sll match object
-
- Data members inherited from oxm_tlv:
- @arg class
- @arg field
- @arg hasmask
- @arg body
-
- """
- def __init__(self, value=None, hasmask=False):
- oxm_tlv.__init__(self, OFPXMT_OFB_IPV6_ND_SLL, hasmask, 6, value)
- def show(self, prefix=''):
- outstr = prefix + "name = ipv6_nd_sll\n"
- outstr += oxm_tlv.show(self, prefix)
- outstr += prefix + "value = " + str(self.value) +"\n"
- return outstr
-
-class ipv6_nd_tll(oxm_tlv):
- """
- Wrapper class for ipv6_nd_tll match object
-
- Data members inherited from oxm_tlv:
- @arg class
- @arg field
- @arg hasmask
- @arg body
-
- """
- def __init__(self, value=None, hasmask=False):
- oxm_tlv.__init__(self, OFPXMT_OFB_IPV6_ND_TLL, hasmask, 6, value)
- def show(self, prefix=''):
- outstr = prefix + "name = ipv6_nd_tll\n"
- outstr += oxm_tlv.show(self, prefix)
- outstr += prefix + "value = " + str(self.value) +"\n"
- return outstr
-
-class mpls_label(oxm_tlv):
- """
- Wrapper class for mpls_label match object
-
- Data members inherited from oxm_tlv:
- @arg class
- @arg field
- @arg hasmask
- @arg body
-
- """
- def __init__(self, value=None, hasmask=False):
- oxm_tlv.__init__(self, OFPXMT_OFB_MPLS_LABEL, hasmask, 4, value)
- def show(self, prefix=''):
- outstr = prefix + "name = mpls_label\n"
- outstr += oxm_tlv.show(self, prefix)
- outstr += prefix + "value = " + str(self.value) +"\n"
- return outstr
-
-class mpls_tc(oxm_tlv):
- """
- Wrapper class for mpls_ltc match object
-
- Data members inherited from oxm_tlv:
- @arg class
- @arg field
- @arg hasmask
- @arg body
-
- """
- def __init__(self, value=None, hasmask=False):
- oxm_tlv.__init__(self, OFPXMT_OFB_MPLS_TC, hasmask, 1, value)
- def show(self, prefix=''):
- outstr = prefix + "name = mpls_tc\n"
- outstr += oxm_tlv.show(self, prefix)
- outstr += prefix + "value = " + str(self.value) +"\n"
- return outstr
-
-match_class_list = (
- in_port,
- in_phy_port,
- metadata,
- eth_dst,
- eth_src,
- eth_type,
- vlan_vid,
- vlan_pcp,
- ip_dscp,
- ip_ecn,
- ip_proto,
- ipv4_src,
- ipv4_dst,
- tcp_src,
- tcp_dst,
- udp_src,
- udp_dst,
- sctp_src,
- sctp_dst,
- icmpv4_type,
- icmpv4_code,
- arp_op,
- arp_spa,
- arp_tpa,
- arp_sha,
- arp_tha,
- ipv6_src,
- ipv6_dst,
- ipv6_flabel,
- icmpv6_type,
- icmpv6_code,
- ipv6_nd_target,
- ipv6_nd_sll,
- ipv6_nd_tll,
- mpls_label,
- mpls_tc)
diff --git a/src/python/of12/match_list.py b/src/python/of12/match_list.py
deleted file mode 100644
index 7a50c75..0000000
--- a/src/python/of12/match_list.py
+++ /dev/null
@@ -1,90 +0,0 @@
-import struct
-import binascii
-import match as match
-from match import oxm_tlv
-from base_list import ofp_base_list
-
-
-class match_list(ofp_base_list):
-
- def __init__(self):
- ofp_base_list.__init__(self)
- self.tlvs = self.items
- self.name = "match"
- self.class_list = match.match_class_list
-
- def __len__(self):
- return sum([len(i) for i in self])
-
- def __eq__(self, other):
- self.tlvs.sort(key=lambda x: x.field);
- other.tlvs.sort(key=lambda x: x.field);
- return self.tlvs == other.tlvs
-
- def unpack(self, binary_string, bytes=None):
- oxm_tlv.factory()
- if bytes <= 4:
- return binary_string[4:]
- if bytes == None:
- bytes = len(binary_string)
- offset = 0
- cur_string = binary_string
- part = lambda: cur_string[read+4:read+4+oxm_length]
- while offset < bytes:
- read = 0
- oxm_class, oxm_fieldhm, oxm_length = struct.unpack("!HBB",
- cur_string[read:read+4])
- #Found padding bytes?
- if not oxm_class:
- break
- oxm_field = oxm_fieldhm >> 1
- oxm_hasmask = oxm_fieldhm & 0x00000001
-
- if oxm_length == 1:
- if oxm_hasmask:
- value, mask = struct.unpack("BB", part())[:2]
- else:
- value = struct.unpack("!B", part())[0]
- mask = None
- elif oxm_length == 2 or (oxm_length == 4 and oxm_hasmask == True):
- if oxm_hasmask:
- value, mask = struct.unpack("!HH", part())[:2]
- else:
- value = struct.unpack("!H", part())[0]
- mask = None
- elif oxm_length == 4 or (oxm_length == 8 and oxm_hasmask == True):
- if oxm_hasmask:
- value, mask = struct.unpack("!II", part())[:2]
- else:
- value = struct.unpack("!I", part())[0]
- mask = None
- elif oxm_length == 6 or oxm_length == 12:
- if oxm_hasmask:
- data = struct.unpack("!12B", part())[0]
- value, mask = data[:6], data[6:]
- else:
- value = list(struct.unpack("!6B", part()))
- mask = None
- elif oxm_length == 8 or (oxm_length == 16 and oxm_hasmask == True):
- if oxm_hasmask:
- value, mask = struct.unpack("!QQ", part())[0]
- else:
- value = struct.unpack("!Q", part())[0]
- mask = None
- elif oxm_length == 16 or oxm_length == 32:
- if oxm_hasmask:
- data = struct.unpack("!32s", part())[0]
- value, mask = data[:16], data[16:]
- else:
- value = struct.unpack("!16s", part())[0]
- mask = None
-
- oxm = oxm_tlv.create(oxm_field)
- oxm.set_hasmask(oxm_hasmask)
- oxm.set_value(value)
- oxm.set_mask(mask)
- self.tlvs.append(oxm)
- read = 4 + oxm_length
- offset += read
- cur_string = cur_string[read:]
- return cur_string
diff --git a/src/python/of12/message.py b/src/python/of12/message.py
deleted file mode 100644
index b8fb9b8..0000000
--- a/src/python/of12/message.py
+++ /dev/null
@@ -1,4015 +0,0 @@
-
-# Python OpenFlow message wrapper classes
-
-from cstruct import *
-from match import oxm_tlv
-from match import roundup
-from match_list import match_list
-from action_list import action_list
-from instruction_list import instruction_list
-from bucket_list import bucket_list
-from error import *
-
-# Define templates for documentation
-class ofp_template_msg(object):
- """
- Sample base class for template_msg; normally auto generated
- This class should live in the of_header name space and provides the
- base class for this type of message. It will be wrapped for the
- high level API.
-
- """
- def __init__(self, **kwargs):
- """
- Constructor for base class
-
- """
- self.header = ofp_header()
- # Additional base data members declared here
-
- # Normally will define pack, unpack, __len__ functions
-
-class template_msg(ofp_template_msg):
- """
- Sample class wrapper for template_msg
- This class should live in the of_message name space and provides the
- high level API for an OpenFlow message object. These objects must
- implement the functions indicated in this template.
-
- """
- def __init__(self, **kwargs):
- """
- Constructor
- Must set the header type value appropriately for the message
-
- """
-
- ##@var header
- # OpenFlow message header: length, version, xid, type
- ofp_template_msg.__init__(self)
- self.header = ofp_header()
- # For a real message, will be set to an integer
- self.header.type = "TEMPLATE_MSG_VALUE"
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- pass
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
-
- @return Typically returns the remainder of binary_string that
- was not parsed. May give a warning if that string is non-empty
-
- """
- pass
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- pass
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
- pass
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- pass
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- pass
-
-
-################################################################
-#
-# OpenFlow Message Definitions
-#
-################################################################
-
-class barrier_reply(object):
- """
- Wrapper class for barrier_reply
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (3)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_BARRIER_REPLY=21)
-
-
- """
-
- def __init__(self, **kwargs):
- self.header = ofp_header()
- self.header.type = OFPT_BARRIER_REPLY
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'barrier_reply (OFPT_BARRIER_REPLY)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class barrier_request(object):
- """
- Wrapper class for barrier_request
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (3)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_BARRIER_REQUEST=20)
-
-
- """
-
- def __init__(self, **kwargs):
- self.header = ofp_header()
- self.header.type = OFPT_BARRIER_REQUEST
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'barrier_request (OFPT_BARRIER_REQUEST)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class echo_reply(object):
- """
- Wrapper class for echo_reply
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (3)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_ECHO_REPLY=3)
-
- @arg data: Binary string following message members
-
- """
-
- def __init__(self, **kwargs):
- self.header = ofp_header()
- self.header.type = OFPT_ECHO_REPLY
- self.data = ""
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- self.data = binary_string
- binary_string = ''
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += len(self.data)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'echo_reply (OFPT_ECHO_REPLY)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += prefix + 'data is of length ' + str(len(self.data)) + '\n'
- ##@todo Fix this circular reference
- # if len(self.data) > 0:
- # obj = of_message_parse(self.data)
- # if obj != None:
- # outstr += obj.show(prefix)
- # else:
- # outstr += prefix + "Unable to parse data\n"
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if self.data != other.data: return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class echo_request(object):
- """
- Wrapper class for echo_request
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (3)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_ECHO_REQUEST=2)
-
- @arg data: Binary string following message members
-
- """
-
- def __init__(self, **kwargs):
- self.header = ofp_header()
- self.header.type = OFPT_ECHO_REQUEST
- self.data = ""
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- self.data = binary_string
- binary_string = ''
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += len(self.data)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'echo_request (OFPT_ECHO_REQUEST)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += prefix + 'data is of length ' + str(len(self.data)) + '\n'
- ##@todo Fix this circular reference
- # if len(self.data) > 0:
- # obj = of_message_parse(self.data)
- # if obj != None:
- # outstr += obj.show(prefix)
- # else:
- # outstr += prefix + "Unable to parse data\n"
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if self.data != other.data: return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class error(ofp_error_msg):
- """
- Wrapper class for error
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (3)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_ERROR=1)
-
- Data members inherited from ofp_error_msg:
- @arg type
- @arg code
- @arg data: Binary string following message members
-
- """
-
- def __init__(self, **kwargs):
- ofp_error_msg.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_ERROR
- self.data = ""
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_error_msg.pack(self)
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_error_msg.unpack(self, binary_string)
- self.data = binary_string
- binary_string = ''
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_error_msg.__len__(self)
- length += len(self.data)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'error (OFPT_ERROR)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_error_msg.show(self, prefix)
- outstr += prefix + 'data is of length ' + str(len(self.data)) + '\n'
- ##@todo Fix this circular reference
- # if len(self.data) > 0:
- # obj = of_message_parse(self.data)
- # if obj != None:
- # outstr += obj.show(prefix)
- # else:
- # outstr += prefix + "Unable to parse data\n"
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_error_msg.__eq__(self, other): return False
- if self.data != other.data: return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class experimenter(ofp_experimenter_header):
- """
- Wrapper class for experimenter
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (3)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_EXPERIMENTER=4)
-
- Data members inherited from ofp_experimenter_header:
- @arg experimenter
- @arg exp_type
- @arg data: Binary string following message members
-
- """
-
- def __init__(self, **kwargs):
- ofp_experimenter_header.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_EXPERIMENTER
- self.data = ""
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_experimenter_header.pack(self)
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_experimenter_header.unpack(self, binary_string)
- self.data = binary_string
- binary_string = ''
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_experimenter_header.__len__(self)
- length += len(self.data)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'experimenter (OFPT_EXPERIMENTER)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_experimenter_header.show(self, prefix)
- outstr += prefix + 'data is of length ' + str(len(self.data)) + '\n'
- ##@todo Fix this circular reference
- # if len(self.data) > 0:
- # obj = of_message_parse(self.data)
- # if obj != None:
- # outstr += obj.show(prefix)
- # else:
- # outstr += prefix + "Unable to parse data\n"
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_experimenter_header.__eq__(self, other): return False
- if self.data != other.data: return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class features_reply(ofp_switch_features):
- """
- Wrapper class for features_reply
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (3)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_FEATURES_REPLY=6)
-
- Data members inherited from ofp_switch_features:
- @arg datapath_id
- @arg n_buffers
- @arg n_tables
- @arg capabilities
- @arg reserved
- @arg ports: Variable length array of TBD
-
- """
-
- def __init__(self, **kwargs):
- ofp_switch_features.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_FEATURES_REPLY
- self.ports = []
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_switch_features.pack(self)
- for obj in self.ports:
- packed += obj.pack()
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_switch_features.unpack(self, binary_string)
- while len(binary_string) >= OFP_PORT_BYTES:
- new_port = ofp_port()
- binary_string = new_port.unpack(binary_string)
- self.ports.append(new_port)
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_switch_features.__len__(self)
- for obj in self.ports:
- length += len(obj)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'features_reply (OFPT_FEATURES_REPLY)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_switch_features.show(self, prefix)
- outstr += prefix + "Array ports\n"
- for obj in self.ports:
- outstr += obj.show(prefix + ' ')
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_switch_features.__eq__(self, other): return False
- if self.ports != other.ports: return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class features_request(object):
- """
- Wrapper class for features_request
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (3)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_FEATURES_REQUEST=5)
-
-
- """
-
- def __init__(self, **kwargs):
- self.header = ofp_header()
- self.header.type = OFPT_FEATURES_REQUEST
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'features_request (OFPT_FEATURES_REQUEST)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class flow_mod(ofp_flow_mod):
- """
- Wrapper class for flow_mod
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (3)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_FLOW_MOD=14)
-
- Data members inherited from ofp_flow_mod:
- @arg cookie
- @arg cookie_mask
- @arg table_id
- @arg command
- @arg idle_timeout
- @arg hard_timeout
- @arg priority
- @arg buffer_id
- @arg out_port
- @arg out_group
- @arg flags
- @arg match
- @arg instructions: Object of type instruction_list
-
- """
-
- def __init__(self, **kwargs):
- ofp_flow_mod.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_FLOW_MOD
- self.buffer_id = 0xffffffff #no buffer
- self.out_port = OFPP_ANY
- self.out_group = OFPG_ANY
- self.match_fields = match_list()
- self.instructions = instruction_list()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- if not len(self.match_fields):
- tlv_pad = oxm_tlv(0,0,0,0,0,0)
- self.match_fields.tlvs.append(tlv_pad)
- else:
- if len(self.match_fields) > 4:
- self.match.length += len(self.match_fields)
- packed = self.header.pack()
- packed += ofp_flow_mod.pack(self)
- self.match_fields.tlvs.sort(key=lambda x : x.field)
- packed += self.match_fields.pack()
- padding_size = roundup( len(self.match) + len(self.match_fields),8) - (len(self.match) + len(self.match_fields))
- padding = [0] * padding_size
- if padding_size:
- packed += struct.pack("!" + str(padding_size) + "B", *padding)
- packed += self.instructions.pack()
- return packed
-
-
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_flow_mod.unpack(self, binary_string)
- binary_string = self.match_fields.unpack(binary_string, bytes = self.match.length - 4)
- padding = roundup(OFP_FLOW_MOD_BYTES + len(self.match_fields),8) - (OFP_FLOW_MOD_BYTES + len(self.match_fields))
- if padding:
- binary_string = binary_string[padding:]
- ai_len = self.length - roundup(OFP_FLOW_MOD_BYTES + len(self.match_fields),8)
- binary_string = self.instructions.unpack(binary_string, bytes=ai_len)
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_flow_mod.__len__(self)
- length = roundup(length + len(self.match_fields), 8)
- length += len(self.instructions)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'flow_mod (OFPT_FLOW_MOD)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_flow_mod.show(self, prefix)
- outstr += self.match_fields.show(prefix + ' ')
- outstr += prefix + "List instructions\n"
- outstr += self.instructions.show(prefix + ' ')
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_flow_mod.__eq__(self, other): return False
- if self.match_fields != other.match_fields: return False
- if self.instructions != other.instructions: return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class flow_removed(ofp_flow_removed):
- """
- Wrapper class for flow_removed
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (3)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_FLOW_REMOVED=11)
-
- Data members inherited from ofp_flow_removed:
- @arg cookie
- @arg priority
- @arg reason
- @arg table_id
- @arg duration_sec
- @arg duration_nsec
- @arg idle_timeout
- @arg hard_timeout
- @arg packet_count
- @arg byte_count
- @arg match
-
- """
-
- def __init__(self, **kwargs):
- ofp_flow_removed.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_FLOW_REMOVED
- self.match_fields = match_list()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- if not len(self.match_fields):
- tlv_pad = oxm_tlv(0,0,0,0,0,0)
- self.match.length += 4
- self.match_fields.tlvs.append(tlv_pad)
- else:
- if len(self.match_fields) > 4:
- self.match.length += len(self.match_fields)
- packed = self.header.pack()
- packed += ofp_flow_removed.pack(self)
- packed += self.match_fields.pack()
- padding_size = roundup( len(self.match) + len(self.match_fields),8) - (len(self.match) + len(self.match_fields))
- padding = [0] * padding_size
- if padding_size:
- packed += struct.pack("!" + str(padding_size) + "B", *padding)
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_flow_removed.unpack(self, binary_string)
- binary_string = self.match_fields.unpack(binary_string, bytes = self.match.length - 4)
- padding = roundup(OFP_FLOW_REMOVED_BYTES + len(self.match_fields),8) - (OFP_FLOW_REMOVED_BYTES + len(self.match_fields))
- if padding:
- binary_string = binary_string[padding:]
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
- length += roundup(ofp_flow_removed.__len__(self) + len(self.match_fields),8)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'flow_removed (OFPT_FLOW_REMOVED)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_flow_removed.show(self, prefix)
- outstr += self.match_fields.show(prefix + ' ')
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
- if not ofp_flow_removed.__eq__(self, other): return False
- if self.match_fields != other.match_fields: return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class get_config_reply(ofp_switch_config):
- """
- Wrapper class for get_config_reply
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (3)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_GET_CONFIG_REPLY=8)
-
- Data members inherited from ofp_switch_config:
- @arg flags
- @arg miss_send_len
-
- """
-
- def __init__(self, **kwargs):
- ofp_switch_config.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_GET_CONFIG_REPLY
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_switch_config.pack(self)
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_switch_config.unpack(self, binary_string)
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_switch_config.__len__(self)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'get_config_reply (OFPT_GET_CONFIG_REPLY)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_switch_config.show(self, prefix)
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_switch_config.__eq__(self, other): return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class get_config_request(object):
- """
- Wrapper class for get_config_request
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (3)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_GET_CONFIG_REQUEST=7)
-
-
- """
-
- def __init__(self, **kwargs):
- self.header = ofp_header()
- self.header.type = OFPT_GET_CONFIG_REQUEST
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'get_config_request (OFPT_GET_CONFIG_REQUEST)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class group_mod(ofp_group_mod):
- """
- Wrapper class for group_mod
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (3)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_GROUP_MOD=15)
-
- Data members inherited from ofp_group_mod:
- @arg command
- @arg type
- @arg group_id
- @arg buckets: Object of type bucket_list
-
- """
-
- def __init__(self, **kwargs):
- ofp_group_mod.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_GROUP_MOD
- self.buckets = bucket_list()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_group_mod.pack(self)
- packed += self.buckets.pack()
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_group_mod.unpack(self, binary_string)
- binary_string = self.buckets.unpack(binary_string)
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_group_mod.__len__(self)
- length += len(self.buckets)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'group_mod (OFPT_GROUP_MOD)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_group_mod.show(self, prefix)
- outstr += prefix + "List buckets\n"
- outstr += self.buckets.show(prefix + ' ')
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_group_mod.__eq__(self, other): return False
- if self.buckets != other.buckets: return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class hello(object):
- """
- Wrapper class for hello
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (3)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_HELLO=0)
-
- @arg data: Binary string following message members
-
- """
-
- def __init__(self, **kwargs):
- self.header = ofp_header()
- self.header.type = OFPT_HELLO
- self.data = ""
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- self.data = binary_string
- binary_string = ''
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += len(self.data)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'hello (OFPT_HELLO)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += prefix + 'data is of length ' + str(len(self.data)) + '\n'
- ##@todo Fix this circular reference
- # if len(self.data) > 0:
- # obj = of_message_parse(self.data)
- # if obj != None:
- # outstr += obj.show(prefix)
- # else:
- # outstr += prefix + "Unable to parse data\n"
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if self.data != other.data: return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class packet_in(ofp_packet_in):
- """
- Wrapper class for packet_in
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (3)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_PACKET_IN=10)
-
- Data members inherited from ofp_packet_in:
- @arg buffer_id
- @arg total_len
- @arg reason
- @arg table_id
- @arg match
- @arg data: Binary string following message members
-
- """
-
- def __init__(self, **kwargs):
- ofp_packet_in.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_PACKET_IN
- self.match_fields = match_list()
- self.data = ""
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- if len(self.match_fields) < 4:
- tlv_pad = oxm_tlv(0,0,0,0,0,0)
- self.match.length += 4
- self.match_fields.tlvs.append(tlv_pad)
- else:
- if len(self.match_fields) > 4:
- self.match.length += len(self.match_fields)
- packed = self.header.pack()
- packed += ofp_packet_in.pack(self)
- packed += self.match_fields.pack()
- padding_size = roundup( len(self.match) + len(self.match_fields),8) - (len(self.match) + len(self.match_fields))
- padding = [0] * padding_size
- if padding_size:
- packed += struct.pack("!" + str(padding_size) + "B", *padding)
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_packet_in.unpack(self, binary_string)
- binary_string = self.match_fields.unpack(binary_string, bytes = self.match.length - 4)
- padding = roundup(OFP_PACKET_IN_BYTES + len(self.match_fields),8) - (OFP_PACKET_IN_BYTES + len(self.match_fields))
- if padding:
- binary_string = binary_string[padding:]
- binary_string = binary_string[2:]
- self.data = binary_string
- binary_string = ''
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += roundup(ofp_packet_in.__len__(self) + len(self.match_fields),8)
- length += len(self.data)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'packet_in (OFPT_PACKET_IN)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_packet_in.show(self, prefix)
- outstr += prefix + 'data is of length ' + str(len(self.data)) + '\n'
- ##@todo Fix this circular reference
- # if len(self.data) > 0:
- # obj = of_message_parse(self.data)
- # if obj != None:
- # outstr += obj.show(prefix)
- # else:
- # outstr += prefix + "Unable to parse data\n"
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_packet_in.__eq__(self, other): return False
- if self.data != other.data: return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class packet_out(ofp_packet_out):
- """
- Wrapper class for packet_out
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (3)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_PACKET_OUT=13)
-
- Data members inherited from ofp_packet_out:
- @arg buffer_id
- @arg in_port
- @arg actions_len
- @arg actions: Object of type action_list
- @arg data: Binary string following message members
-
- """
-
- def __init__(self, **kwargs):
- ofp_packet_out.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_PACKET_OUT
- self.actions = []
- self.data = ""
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- self.actions = action_list(self.actions)
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- self.actions_len = len(self.actions)
- packed += ofp_packet_out.pack(self)
- packed += self.actions.pack()
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_packet_out.unpack(self, binary_string)
- binary_string = self.actions.unpack(binary_string, bytes=self.actions_len)
- self.data = binary_string
- binary_string = ''
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_packet_out.__len__(self)
- length += len(self.actions)
- length += len(self.data)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'packet_out (OFPT_PACKET_OUT)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_packet_out.show(self, prefix)
- outstr += prefix + "List actions\n"
- outstr += self.actions.show(prefix + ' ')
- outstr += prefix + 'data is of length ' + str(len(self.data)) + '\n'
- ##@todo Fix this circular reference
- # if len(self.data) > 0:
- # obj = of_message_parse(self.data)
- # if obj != None:
- # outstr += obj.show(prefix)
- # else:
- # outstr += prefix + "Unable to parse data\n"
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_packet_out.__eq__(self, other): return False
- if self.data != other.data: return False
- if self.actions != other.actions: return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class port_mod(ofp_port_mod):
- """
- Wrapper class for port_mod
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (3)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_PORT_MOD=16)
-
- Data members inherited from ofp_port_mod:
- @arg port_no
- @arg hw_addr
- @arg config
- @arg mask
- @arg advertise
-
- """
-
- def __init__(self, **kwargs):
- ofp_port_mod.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_PORT_MOD
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_port_mod.pack(self)
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_port_mod.unpack(self, binary_string)
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_port_mod.__len__(self)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'port_mod (OFPT_PORT_MOD)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_port_mod.show(self, prefix)
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_port_mod.__eq__(self, other): return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class port_status(ofp_port_status):
- """
- Wrapper class for port_status
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (3)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_PORT_STATUS=12)
-
- Data members inherited from ofp_port_status:
- @arg reason
- @arg desc
-
- """
-
- def __init__(self, **kwargs):
- ofp_port_status.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_PORT_STATUS
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_port_status.pack(self)
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_port_status.unpack(self, binary_string)
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_port_status.__len__(self)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'port_status (OFPT_PORT_STATUS)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_port_status.show(self, prefix)
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_port_status.__eq__(self, other): return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class queue_get_config_reply(ofp_queue_get_config_reply):
- """
- Wrapper class for queue_get_config_reply
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (3)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_QUEUE_GET_CONFIG_REPLY=23)
-
- Data members inherited from ofp_queue_get_config_reply:
- @arg port
- @arg queues: Variable length array of TBD
-
- """
-
- def __init__(self, **kwargs):
- ofp_queue_get_config_reply.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_QUEUE_GET_CONFIG_REPLY
- self.queues = []
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_queue_get_config_reply.pack(self)
- for obj in self.queues:
- packed += obj.pack()
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_queue_get_config_reply.unpack(self, binary_string)
- for obj in self.queues:
- binary_string = obj.unpack(binary_string)
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_queue_get_config_reply.__len__(self)
- for obj in self.queues:
- length += len(obj)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'queue_get_config_reply (OFPT_QUEUE_GET_CONFIG_REPLY)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_queue_get_config_reply.show(self, prefix)
- outstr += prefix + "Array queues\n"
- for obj in self.queues:
- outstr += obj.show(prefix + ' ')
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_queue_get_config_reply.__eq__(self, other): return False
- if self.queues != other.queues: return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class queue_get_config_request(ofp_queue_get_config_request):
- """
- Wrapper class for queue_get_config_request
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (3)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_QUEUE_GET_CONFIG_REQUEST=22)
-
- Data members inherited from ofp_queue_get_config_request:
- @arg port
-
- """
-
- def __init__(self, **kwargs):
- ofp_queue_get_config_request.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_QUEUE_GET_CONFIG_REQUEST
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_queue_get_config_request.pack(self)
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_queue_get_config_request.unpack(self, binary_string)
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_queue_get_config_request.__len__(self)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'queue_get_config_request (OFPT_QUEUE_GET_CONFIG_REQUEST)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_queue_get_config_request.show(self, prefix)
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_queue_get_config_request.__eq__(self, other): return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class set_config(ofp_switch_config):
- """
- Wrapper class for set_config
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (3)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_SET_CONFIG=9)
-
- Data members inherited from ofp_switch_config:
- @arg flags
- @arg miss_send_len
-
- """
-
- def __init__(self, **kwargs):
- ofp_switch_config.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_SET_CONFIG
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_switch_config.pack(self)
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_switch_config.unpack(self, binary_string)
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_switch_config.__len__(self)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'set_config (OFPT_SET_CONFIG)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_switch_config.show(self, prefix)
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_switch_config.__eq__(self, other): return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class stats_reply(ofp_stats_reply):
- """
- Wrapper class for stats_reply
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (3)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_STATS_REPLY=19)
-
- Data members inherited from ofp_stats_reply:
- @arg type
- @arg flags
-
- """
-
- def __init__(self, **kwargs):
- ofp_stats_reply.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_STATS_REPLY
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_stats_reply.pack(self)
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_stats_reply.unpack(self, binary_string)
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_stats_reply.__len__(self)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'stats_reply (OFPT_STATS_REPLY)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_reply.show(self, prefix)
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_stats_reply.__eq__(self, other): return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class stats_request(ofp_stats_request):
- """
- Wrapper class for stats_request
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (3)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_STATS_REQUEST=18)
-
- Data members inherited from ofp_stats_request:
- @arg type
- @arg flags
-
- """
-
- def __init__(self, **kwargs):
- ofp_stats_request.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_STATS_REQUEST
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_stats_request.pack(self)
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_stats_request.unpack(self, binary_string)
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_stats_request.__len__(self)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'stats_request (OFPT_STATS_REQUEST)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_request.show(self, prefix)
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_stats_request.__eq__(self, other): return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class table_mod(ofp_table_mod):
- """
- Wrapper class for table_mod
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (3)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_TABLE_MOD=17)
-
- Data members inherited from ofp_table_mod:
- @arg table_id
- @arg config
-
- """
-
- def __init__(self, **kwargs):
- ofp_table_mod.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_TABLE_MOD
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack()
-
- packed += ofp_table_mod.pack(self)
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- binary_string = ofp_table_mod.unpack(self, binary_string)
- # Fixme: If no self.data, add check for data remaining
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += ofp_table_mod.__len__(self)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'table_mod (OFPT_TABLE_MOD)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_table_mod.show(self, prefix)
- return outstr
-
- def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if not ofp_table_mod.__eq__(self, other): return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-
-################################################################
-#
-# Stats request and reply subclass definitions
-#
-################################################################
-
-
-# Stats request bodies for desc and table stats are not defined in the
-# OpenFlow header; We define them here. They are empty classes, really
-
-class ofp_desc_stats_request(object):
- """
- Forced definition of ofp_desc_stats_request (empty class)
- """
- def __init__(self, **kwargs):
- pass
- def pack(self, assertstruct=True):
- return ""
- def unpack(self, binary_string):
- return binary_string
- def __len__(self):
- return 0
- def show(self, prefix=''):
- return prefix + "ofp_desc_stats_request (empty)\n"
- def __eq__(self, other):
- return type(self) == type(other)
- def __ne__(self, other):
- return type(self) != type(other)
-
-OFP_DESC_STATS_REQUEST_BYTES = 0
-
-class ofp_table_stats_request(object):
- """
- Forced definition of ofp_table_stats_request (empty class)
- """
- def __init__(self, **kwargs):
- pass
- def pack(self, assertstruct=True):
- return ""
- def unpack(self, binary_string):
- return binary_string
- def __len__(self):
- return 0
- def show(self, prefix=''):
- return prefix + "ofp_table_stats_request (empty)\n"
- def __eq__(self, other):
- return type(self) == type(other)
- def __ne__(self, other):
- return type(self) != type(other)
-
-OFP_TABLE_STATS_REQUEST_BYTES = 0
-
-class ofp_group_desc_stats_request(object):
- """
- Forced definition of ofp_group_desc_stats_request (empty class)
- """
- def __init__(self, **kwargs):
- pass
- def pack(self, assertstruct=True):
- return ""
- def unpack(self, binary_string):
- return binary_string
- def __len__(self):
- return 0
- def show(self, prefix=''):
- return prefix + "ofp_group_desc_stats_request (empty)\n"
- def __eq__(self, other):
- return type(self) == type(other)
- def __ne__(self, other):
- return type(self) != type(other)
-
-OFP_GROUP_DESC_STATS_REQUEST_BYTES = 0
-
-
-
-# Stats entries define the content of one element in a stats
-# reply for the indicated type; define _entry for consistency
-
-aggregate_stats_entry = ofp_aggregate_stats_reply
-desc_stats_entry = ofp_desc_stats
-port_stats_entry = ofp_port_stats
-queue_stats_entry = ofp_queue_stats
-table_stats_entry = ofp_table_stats
-group_stats_entry = ofp_group_stats
-group_desc_stats_entry = ofp_group_desc_stats
-
-
-#
-# Flow stats entry contains an action list of variable length, so
-# it is done by hand
-#
-
-class flow_stats_entry(ofp_flow_stats):
- """
- Special case flow stats entry to handle action list object
- """
- def __init__(self, **kwargs):
- ofp_flow_stats.__init__(self)
- self.match_fields = match_list()
- self.instructions = instruction_list()
-
- def pack(self, assertstruct=True):
- self.length = len(self)
- if not len(self.match_fields):
- tlv_pad = oxm_tlv(0,0,0,0,0,0)
- self.match.length += 4
- self.match_fields.tlvs.append(tlv_pad)
- else:
- if len(self.match_fields) > 4:
- self.match.length += len(self.match_fields)
- packed = ofp_flow_stats.pack(self, assertstruct)
- packed += self.match_fields.pack()
- padding_size = roundup(len(self.match) + len(self.match_fields),8) - (len(self.match) + len(self.match_fields))
- padding = [0] * padding_size
- if padding_size:
- packed += struct.pack("!" + str(padding_size) + "B", *padding)
- packed += self.instructions.pack()
- if len(packed) != self.length:
- print("ERROR: flow_stats_entry pack length not equal",
- self.length, len(packed))
- return packed
-
- def unpack(self, binary_string):
- binary_string = ofp_flow_stats.unpack(self, binary_string)
- binary_string = self.match_fields.unpack(binary_string, bytes = self.match.length - 4)
- padding = roundup((OFP_FLOW_STATS_BYTES -4) + self.match.length,8) - ((OFP_FLOW_STATS_BYTES - 4) + self.match.length)
- if padding:
- binary_string = binary_string[padding:]
- ai_len = self.length - roundup(OFP_FLOW_STATS_BYTES + len(self.match_fields),8)
- if ai_len < 0:
- print("ERROR: flow_stats_entry unpack length too small",
- self.length)
- binary_string = self.instructions.unpack(binary_string, bytes=ai_len)
- return binary_string
-
- def __len__(self):
- return roundup(OFP_FLOW_STATS_BYTES + len(self.match_fields),8) + len(self.instructions)
-
- def show(self, prefix=''):
- outstr = prefix + "flow_stats_entry\n"
- outstr += ofp_flow_stats.show(self, prefix + ' ')
- outstr += self.match_fields.show(prefix + ' ')
- outstr += self.instructions.show(prefix + ' ')
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (ofp_flow_stats.__eq__(self, other) and
- self.instructions == other.instructions)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class aggregate_stats_request(ofp_stats_request, ofp_aggregate_stats_request):
- """
- Wrapper class for aggregate stats request message
- """
- def __init__(self, **kwargs):
- self.header = ofp_header()
- ofp_stats_request.__init__(self)
- ofp_aggregate_stats_request.__init__(self)
- self.header.type = OFPT_STATS_REQUEST
- self.type = OFPST_AGGREGATE
- self.match_fields = match_list()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_request.pack(self)
- if not len(self.match_fields):
- tlv_pad = oxm_tlv(0,0,0,0,0,0)
- self.match.length += 4
- self.match_fields.tlvs.append(tlv_pad)
- else:
- if len(self.match_fields) > 4:
- self.match.length += len(self.match_fields)
- packed += ofp_aggregate_stats_request.pack(self, assertstruct)
- packed += self.match_fields.pack()
- padding_size = roundup(len(self.match) + len(self.match_fields),8) - (len(self.match) + len(self.match_fields))
- padding = [0] * padding_size
-
- if padding_size:
- packed += struct.pack("!" + str(padding_size) + "B", *padding)
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_request.unpack(self, binary_string)
- binary_string = ofp_aggregate_stats_request.unpack(self, binary_string)
- binary_string = self.match_fields.unpack(binary_string, bytes = self.match.length - 4)
- padding = roundup(OFP_AGGREGATE_STATS_REQUEST_BYTES + len(self.match_fields),8) - (OFP_AGGREGATE_STATS_REQUEST_BYTES + len(self.match_fields))
- if padding:
- binary_string = binary_string[padding:]
- if len(binary_string) != 0:
- print "ERROR unpacking flow: extra data"
- return binary_string
-
-
- def __len__(self):
- length = len(self.header) + OFP_STATS_REQUEST_BYTES + \
- OFP_AGGREGATE_STATS_REQUEST_BYTES
- if not len(self.match_fields):
- return length + 4
- else:
- return roundup(length + len(self.match_fields),8)
-
- def show(self, prefix=''):
- outstr = prefix + "aggregate_stats_request\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_request.show(self)
- outstr += ofp_aggregate_stats_request.show(self)
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_request.__eq__(self, other) and
- ofp_aggregate_stats_request.__eq__(self, other))
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class aggregate_stats_reply(ofp_stats_reply):
- """
- Wrapper class for aggregate stats reply
- """
- def __init__(self, **kwargs):
- self.header = ofp_header()
- ofp_stats_reply.__init__(self)
- self.header.type = OFPT_STATS_REPLY
- self.type = OFPST_AGGREGATE
- # stats: Array of type aggregate_stats_entry
- self.stats = []
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_reply.pack(self)
- for obj in self.stats:
- packed += obj.pack()
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_reply.unpack(self, binary_string)
- dummy = aggregate_stats_entry()
- while len(binary_string) >= len(dummy):
- obj = aggregate_stats_entry()
- binary_string = obj.unpack(binary_string)
- self.stats.append(obj)
- if len(binary_string) != 0:
- print "ERROR unpacking aggregate stats string: extra bytes"
- return binary_string
-
- def __len__(self):
- length = len(self.header) + OFP_STATS_REPLY_BYTES
- for obj in self.stats:
- length += len(obj)
- return length
-
- def show(self, prefix=''):
- outstr = prefix + "aggregate_stats_reply\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_reply.show(self)
- outstr += prefix + "Stats array of length " + str(len(self.stats)) + '\n'
- for obj in self.stats:
- outstr += obj.show()
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_reply.__eq__(self, other) and
- self.stats == other.stats)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class desc_stats_request(ofp_stats_request, ofp_desc_stats_request):
- """
- Wrapper class for desc stats request message
- """
- def __init__(self, **kwargs):
- self.header = ofp_header()
- ofp_stats_request.__init__(self)
- ofp_desc_stats_request.__init__(self)
- self.header.type = OFPT_STATS_REQUEST
- self.type = OFPST_DESC
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_request.pack(self)
- packed += ofp_desc_stats_request.pack(self)
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_request.unpack(self, binary_string)
- binary_string = ofp_desc_stats_request.unpack(self, binary_string)
- if len(binary_string) != 0:
- print "ERROR unpacking desc: extra data"
- return binary_string
-
- def __len__(self):
- return len(self.header) + OFP_STATS_REQUEST_BYTES + \
- OFP_DESC_STATS_REQUEST_BYTES
-
- def show(self, prefix=''):
- outstr = prefix + "desc_stats_request\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_request.show(self)
- outstr += ofp_desc_stats_request.show(self)
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_request.__eq__(self, other) and
- ofp_desc_stats_request.__eq__(self, other))
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class desc_stats_reply(ofp_stats_reply):
- """
- Wrapper class for desc stats reply
- """
- def __init__(self, **kwargs):
- self.header = ofp_header()
- ofp_stats_reply.__init__(self)
- self.header.type = OFPT_STATS_REPLY
- self.type = OFPST_DESC
- # stats: Array of type desc_stats_entry
- self.stats = []
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_reply.pack(self)
- for obj in self.stats:
- packed += obj.pack()
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_reply.unpack(self, binary_string)
- dummy = desc_stats_entry()
- while len(binary_string) >= len(dummy):
- obj = desc_stats_entry()
- binary_string = obj.unpack(binary_string)
- self.stats.append(obj)
- if len(binary_string) != 0:
- print "ERROR unpacking desc stats string: extra bytes"
- return binary_string
-
- def __len__(self):
- length = len(self.header) + OFP_STATS_REPLY_BYTES
- for obj in self.stats:
- length += len(obj)
- return length
-
- def show(self, prefix=''):
- outstr = prefix + "desc_stats_reply\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_reply.show(self)
- outstr += prefix + "Stats array of length " + str(len(self.stats)) + '\n'
- for obj in self.stats:
- outstr += obj.show()
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_reply.__eq__(self, other) and
- self.stats == other.stats)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class flow_stats_request(ofp_stats_request, ofp_flow_stats_request):
- """
- Wrapper class for flow stats request message
- """
- def __init__(self, **kwargs):
- self.header = ofp_header()
- ofp_stats_request.__init__(self)
- ofp_flow_stats_request.__init__(self)
- self.header.type = OFPT_STATS_REQUEST
- self.type = OFPST_FLOW
- self.match_fields = match_list()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
- def pack(self):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_request.pack(self)
- if not len(self.match_fields):
- tlv_pad = oxm_tlv(0,0,0,0,0,0)
- self.match.length += 4
- self.match_fields.tlvs.append(tlv_pad)
- else:
- if len(self.match_fields) > 4:
- self.match.length += len(self.match_fields)
- packed += ofp_flow_stats_request.pack(self)
- packed += self.match_fields.pack()
- padding_size = roundup(len(self.match) + len(self.match_fields),8) - (len(self.match) + len(self.match_fields))
- padding = [0] * padding_size
- if padding_size:
- packed += struct.pack("!" + str(padding_size) + "B", *padding)
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_request.unpack(self, binary_string)
- binary_string = ofp_flow_stats_request.unpack(self, binary_string)
- binary_string = self.match_fields.unpack(binary_string, bytes = self.match.length - 4)
- padding = roundup(OFP_FLOW_STATS_REQUEST_BYTES + len(self.match_fields),8) - (OFP_FLOW_STATS_REQUEST_BYTES + len(self.match_fields))
- if padding:
- binary_string = binary_string[padding:]
- if len(binary_string) != 0:
- print "ERROR unpacking flow: extra data"
- return binary_string
-
- def __len__(self):
- length = len(self.header) + OFP_STATS_REQUEST_BYTES + \
- OFP_FLOW_STATS_REQUEST_BYTES
- if not len(self.match_fields):
- return length + 4
- else:
- return roundup(length + len(self.match_fields),8)
-
- def show(self, prefix=''):
- outstr = prefix + "flow_stats_request\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_request.show(self)
- outstr += ofp_flow_stats_request.show(self)
- outstr += self.match_fields.show(prefix + ' ')
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_request.__eq__(self, other) and
- ofp_flow_stats_request.__eq__(self, other) and
- self.match_fields != other.match_fields)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class flow_stats_reply(ofp_stats_reply):
- """
- Wrapper class for flow stats reply
- """
- def __init__(self, **kwargs):
- self.header = ofp_header()
- ofp_stats_reply.__init__(self)
- self.header.type = OFPT_STATS_REPLY
- self.type = OFPST_FLOW
- # stats: Array of type flow_stats_entry
- self.stats = []
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_reply.pack(self)
- for obj in self.stats:
- packed += obj.pack()
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_reply.unpack(self, binary_string)
- dummy = flow_stats_entry()
- while len(binary_string) >= len(dummy):
- obj = flow_stats_entry()
- binary_string = obj.unpack(binary_string)
- self.stats.append(obj)
- if len(binary_string) != 0:
- print "ERROR unpacking flow stats string: extra bytes"
- return binary_string
-
- def __len__(self):
- length = len(self.header) + OFP_STATS_REPLY_BYTES
- for obj in self.stats:
- length += len(obj)
- return length
-
- def show(self, prefix=''):
- outstr = prefix + "flow_stats_reply\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_reply.show(self)
- outstr += prefix + "Stats array of length " + str(len(self.stats)) + '\n'
- for obj in self.stats:
- outstr += obj.show()
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_reply.__eq__(self, other) and
- self.stats == other.stats)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class port_stats_request(ofp_stats_request, ofp_port_stats_request):
- """
- Wrapper class for port stats request message
- """
- def __init__(self, **kwargs):
- self.header = ofp_header()
- ofp_stats_request.__init__(self)
- ofp_port_stats_request.__init__(self)
- self.header.type = OFPT_STATS_REQUEST
- self.type = OFPST_PORT
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_request.pack(self)
- packed += ofp_port_stats_request.pack(self)
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_request.unpack(self, binary_string)
- binary_string = ofp_port_stats_request.unpack(self, binary_string)
- if len(binary_string) != 0:
- print "ERROR unpacking port: extra data"
- return binary_string
-
- def __len__(self):
- return len(self.header) + OFP_STATS_REQUEST_BYTES + \
- OFP_PORT_STATS_REQUEST_BYTES
-
- def show(self, prefix=''):
- outstr = prefix + "port_stats_request\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_request.show(self)
- outstr += ofp_port_stats_request.show(self)
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_request.__eq__(self, other) and
- ofp_port_stats_request.__eq__(self, other))
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class port_stats_reply(ofp_stats_reply):
- """
- Wrapper class for port stats reply
- """
- def __init__(self, **kwargs):
- self.header = ofp_header()
- ofp_stats_reply.__init__(self)
- self.header.type = OFPT_STATS_REPLY
- self.type = OFPST_PORT
- # stats: Array of type port_stats_entry
- self.stats = []
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_reply.pack(self)
- for obj in self.stats:
- packed += obj.pack()
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_reply.unpack(self, binary_string)
- dummy = port_stats_entry()
- while len(binary_string) >= len(dummy):
- obj = port_stats_entry()
- binary_string = obj.unpack(binary_string)
- self.stats.append(obj)
- if len(binary_string) != 0:
- print "ERROR unpacking port stats string: extra bytes"
- return binary_string
-
- def __len__(self):
- length = len(self.header) + OFP_STATS_REPLY_BYTES
- for obj in self.stats:
- length += len(obj)
- return length
-
- def show(self, prefix=''):
- outstr = prefix + "port_stats_reply\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_reply.show(self)
- outstr += prefix + "Stats array of length " + str(len(self.stats)) + '\n'
- for obj in self.stats:
- outstr += obj.show()
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_reply.__eq__(self, other) and
- self.stats == other.stats)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class queue_stats_request(ofp_stats_request, ofp_queue_stats_request):
- """
- Wrapper class for queue stats request message
- """
- def __init__(self, **kwargs):
- self.header = ofp_header()
- ofp_stats_request.__init__(self)
- ofp_queue_stats_request.__init__(self)
- self.header.type = OFPT_STATS_REQUEST
- self.type = OFPST_QUEUE
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_request.pack(self)
- packed += ofp_queue_stats_request.pack(self)
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_request.unpack(self, binary_string)
- binary_string = ofp_queue_stats_request.unpack(self, binary_string)
- if len(binary_string) != 0:
- print "ERROR unpacking queue: extra data"
- return binary_string
-
- def __len__(self):
- return len(self.header) + OFP_STATS_REQUEST_BYTES + \
- OFP_QUEUE_STATS_REQUEST_BYTES
-
- def show(self, prefix=''):
- outstr = prefix + "queue_stats_request\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_request.show(self)
- outstr += ofp_queue_stats_request.show(self)
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_request.__eq__(self, other) and
- ofp_queue_stats_request.__eq__(self, other))
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class queue_stats_reply(ofp_stats_reply):
- """
- Wrapper class for queue stats reply
- """
- def __init__(self, **kwargs):
- self.header = ofp_header()
- ofp_stats_reply.__init__(self)
- self.header.type = OFPT_STATS_REPLY
- self.type = OFPST_QUEUE
- # stats: Array of type queue_stats_entry
- self.stats = []
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_reply.pack(self)
- for obj in self.stats:
- packed += obj.pack()
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_reply.unpack(self, binary_string)
- dummy = queue_stats_entry()
- while len(binary_string) >= len(dummy):
- obj = queue_stats_entry()
- binary_string = obj.unpack(binary_string)
- self.stats.append(obj)
- if len(binary_string) != 0:
- print "ERROR unpacking queue stats string: extra bytes"
- return binary_string
-
- def __len__(self):
- length = len(self.header) + OFP_STATS_REPLY_BYTES
- for obj in self.stats:
- length += len(obj)
- return length
-
- def show(self, prefix=''):
- outstr = prefix + "queue_stats_reply\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_reply.show(self)
- outstr += prefix + "Stats array of length " + str(len(self.stats)) + '\n'
- for obj in self.stats:
- outstr += obj.show()
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_reply.__eq__(self, other) and
- self.stats == other.stats)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class group_stats_request(ofp_stats_request, ofp_group_stats_request):
- """
- Wrapper class for group stats request message
- """
- def __init__(self, **kwargs):
- self.header = ofp_header()
- ofp_stats_request.__init__(self)
- ofp_group_stats_request.__init__(self)
- self.header.type = OFPT_STATS_REQUEST
- self.type = OFPST_GROUP
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_request.pack(self)
- packed += ofp_group_stats_request.pack(self)
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_request.unpack(self, binary_string)
- binary_string = ofp_group_stats_request.unpack(self, binary_string)
- if len(binary_string) != 0:
- print "ERROR unpacking group: extra data"
- return binary_string
-
- def __len__(self):
- return len(self.header) + OFP_STATS_REQUEST_BYTES + \
- OFP_GROUP_STATS_REQUEST_BYTES
-
- def show(self, prefix=''):
- outstr = prefix + "group_stats_request\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_request.show(self)
- outstr += ofp_group_stats_request.show(self)
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_request.__eq__(self, other) and
- ofp_group_stats_request.__eq__(self, other))
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class group_stats_reply(ofp_stats_reply):
- """
- Wrapper class for group stats reply
- """
- def __init__(self, **kwargs):
- self.header = ofp_header()
- ofp_stats_reply.__init__(self)
- self.header.type = OFPT_STATS_REPLY
- self.type = OFPST_GROUP
- # stats: Array of type group_stats_entry
- self.stats = []
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_reply.pack(self)
- for obj in self.stats:
- packed += obj.pack()
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_reply.unpack(self, binary_string)
- dummy = group_stats_entry()
- while len(binary_string) >= len(dummy):
- obj = group_stats_entry()
- binary_string = obj.unpack(binary_string)
- self.stats.append(obj)
- if len(binary_string) != 0:
- print "ERROR unpacking group stats string: extra bytes"
- return binary_string
-
- def __len__(self):
- length = len(self.header) + OFP_STATS_REPLY_BYTES
- for obj in self.stats:
- length += len(obj)
- return length
-
- def show(self, prefix=''):
- outstr = prefix + "group_stats_reply\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_reply.show(self)
- outstr += prefix + "Stats array of length " + str(len(self.stats)) + '\n'
- for obj in self.stats:
- outstr += obj.show()
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_reply.__eq__(self, other) and
- self.stats == other.stats)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class group_desc_stats_request(ofp_stats_request, ofp_group_desc_stats_request):
- """
- Wrapper class for group_desc stats request message
- """
- def __init__(self, **kwargs):
- self.header = ofp_header()
- ofp_stats_request.__init__(self)
- ofp_group_desc_stats_request.__init__(self)
- self.header.type = OFPT_STATS_REQUEST
- self.type = OFPST_GROUP_DESC
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_request.pack(self)
- packed += ofp_group_desc_stats_request.pack(self)
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_request.unpack(self, binary_string)
- binary_string = ofp_group_desc_stats_request.unpack(self, binary_string)
- if len(binary_string) != 0:
- print "ERROR unpacking group_desc: extra data"
- return binary_string
-
- def __len__(self):
- return len(self.header) + OFP_STATS_REQUEST_BYTES + \
- OFP_GROUP_DESC_STATS_REQUEST_BYTES
-
- def show(self, prefix=''):
- outstr = prefix + "group_desc_stats_request\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_request.show(self)
- outstr += ofp_group_desc_stats_request.show(self)
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_request.__eq__(self, other) and
- ofp_group_desc_stats_request.__eq__(self, other))
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class group_desc_stats_reply(ofp_stats_reply):
- """
- Wrapper class for group_desc stats reply
- """
- def __init__(self, **kwargs):
- self.header = ofp_header()
- ofp_stats_reply.__init__(self)
- self.header.type = OFPT_STATS_REPLY
- self.type = OFPST_GROUP_DESC
- # stats: Array of type group_desc_stats_entry
- self.stats = []
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_reply.pack(self)
- for obj in self.stats:
- packed += obj.pack()
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_reply.unpack(self, binary_string)
- dummy = group_desc_stats_entry()
- while len(binary_string) >= len(dummy):
- obj = group_desc_stats_entry()
- binary_string = obj.unpack(binary_string)
- self.stats.append(obj)
- if len(binary_string) != 0:
- print "ERROR unpacking group_desc stats string: extra bytes"
- return binary_string
-
- def __len__(self):
- length = len(self.header) + OFP_STATS_REPLY_BYTES
- for obj in self.stats:
- length += len(obj)
- return length
-
- def show(self, prefix=''):
- outstr = prefix + "group_desc_stats_reply\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_reply.show(self)
- outstr += prefix + "Stats array of length " + str(len(self.stats)) + '\n'
- for obj in self.stats:
- outstr += obj.show()
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_reply.__eq__(self, other) and
- self.stats == other.stats)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class table_stats_request(ofp_stats_request, ofp_table_stats_request):
- """
- Wrapper class for table stats request message
- """
- def __init__(self, **kwargs):
- self.header = ofp_header()
- ofp_stats_request.__init__(self)
- ofp_table_stats_request.__init__(self)
- self.header.type = OFPT_STATS_REQUEST
- self.type = OFPST_TABLE
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_request.pack(self)
- packed += ofp_table_stats_request.pack(self)
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_request.unpack(self, binary_string)
- binary_string = ofp_table_stats_request.unpack(self, binary_string)
- if len(binary_string) != 0:
- print "ERROR unpacking table: extra data"
- return binary_string
-
- def __len__(self):
- return len(self.header) + OFP_STATS_REQUEST_BYTES + \
- OFP_TABLE_STATS_REQUEST_BYTES
-
- def show(self, prefix=''):
- outstr = prefix + "table_stats_request\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_request.show(self)
- outstr += ofp_table_stats_request.show(self)
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_request.__eq__(self, other) and
- ofp_table_stats_request.__eq__(self, other))
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-class table_stats_reply(ofp_stats_reply):
- """
- Wrapper class for table stats reply
- """
- def __init__(self, **kwargs):
- self.header = ofp_header()
- ofp_stats_reply.__init__(self)
- self.header.type = OFPT_STATS_REPLY
- self.type = OFPST_TABLE
- # stats: Array of type table_stats_entry
- self.stats = []
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_reply.pack(self)
- for obj in self.stats:
- packed += obj.pack()
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_reply.unpack(self, binary_string)
- dummy = table_stats_entry()
- while len(binary_string) >= len(dummy):
- obj = table_stats_entry()
- binary_string = obj.unpack(binary_string)
- self.stats.append(obj)
- if len(binary_string) != 0:
- print "ERROR unpacking table stats string: extra bytes"
- return binary_string
-
- def __len__(self):
- length = len(self.header) + OFP_STATS_REPLY_BYTES
- for obj in self.stats:
- length += len(obj)
- return length
-
- def show(self, prefix=''):
- outstr = prefix + "table_stats_reply\n"
- outstr += prefix + "ofp header:\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_reply.show(self)
- outstr += prefix + "Stats array of length " + str(len(self.stats)) + '\n'
- for obj in self.stats:
- outstr += obj.show()
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_reply.__eq__(self, other) and
- self.stats == other.stats)
-
- def __ne__(self, other): return not self.__eq__(other)
-
-
-# @todo Add buckets to group and group_desc stats obejcts"
-message_type_list = (
- aggregate_stats_reply,
- aggregate_stats_request,
- bad_action_error_msg,
- bad_request_error_msg,
- barrier_reply,
- barrier_request,
- desc_stats_reply,
- desc_stats_request,
- echo_reply,
- echo_request,
- error,
- experimenter,
- features_reply,
- features_request,
- flow_mod,
- flow_mod_failed_error_msg,
- flow_removed,
- flow_stats_reply,
- flow_stats_request,
- get_config_reply,
- get_config_request,
- group_desc_stats_request,
- group_desc_stats_reply,
- group_stats_request,
- group_stats_reply,
- group_mod,
- group_mod_failed_error_msg,
- hello,
- hello_failed_error_msg,
- packet_in,
- packet_out,
- port_mod,
- port_mod_failed_error_msg,
- port_stats_reply,
- port_stats_request,
- port_status,
- queue_get_config_reply,
- queue_get_config_request,
- queue_op_failed_error_msg,
- queue_stats_reply,
- queue_stats_request,
- set_config,
- switch_config_failed_error_msg,
- table_mod,
- table_mod_failed_error_msg,
- table_stats_reply,
- table_stats_request,
- )
-
diff --git a/src/python/of12/parse.py b/src/python/of12/parse.py
deleted file mode 100644
index 6374a75..0000000
--- a/src/python/of12/parse.py
+++ /dev/null
@@ -1,333 +0,0 @@
-"""
-OpenFlow message parsing functions
-"""
-
-import sys
-import logging
-import message
-from match_list import match_list
-import match
-#from error import *
-#from action import *
-#from action_list import action_list
-import cstruct as ofp
-
-try:
- logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
- from scapy.all import *
- from oftest.mpls import *
-except ImportError:
- sys.exit("Need to install scapy for packet parsing")
-
-"""
-of_message.py
-Contains wrapper functions and classes for the of_message namespace
-that are generated by hand. It includes the rest of the wrapper
-function information into the of_message namespace
-"""
-
-parse_logger = logging.getLogger("parse")
-#parse_logger.setLevel(logging.DEBUG)
-
-# These message types are subclassed
-msg_type_subclassed = [
- ofp.OFPT_STATS_REQUEST,
- ofp.OFPT_STATS_REPLY,
- ofp.OFPT_ERROR
-]
-
-# Maps from sub-types to classes
-stats_reply_to_class_map = {
- ofp.OFPST_DESC : message.desc_stats_reply,
- ofp.OFPST_FLOW : message.flow_stats_reply,
- ofp.OFPST_AGGREGATE : message.aggregate_stats_reply,
- ofp.OFPST_TABLE : message.table_stats_reply,
- ofp.OFPST_PORT : message.port_stats_reply,
- ofp.OFPST_QUEUE : message.queue_stats_reply,
- ofp.OFPST_GROUP : message.group_stats_reply,
- ofp.OFPST_GROUP_DESC : message.group_desc_stats_reply
-# ofp.OFPST_EXPERIMENTER
-}
-
-stats_request_to_class_map = {
- ofp.OFPST_DESC : message.desc_stats_request,
- ofp.OFPST_FLOW : message.flow_stats_request,
- ofp.OFPST_AGGREGATE : message.aggregate_stats_request,
- ofp.OFPST_TABLE : message.table_stats_request,
- ofp.OFPST_PORT : message.port_stats_request,
- ofp.OFPST_QUEUE : message.queue_stats_request,
- ofp.OFPST_GROUP : message.group_stats_request,
- ofp.OFPST_GROUP_DESC : message.group_desc_stats_request
-# ofp.OFPST_EXPERIMENTER
-}
-
-error_to_class_map = {
- ofp.OFPET_HELLO_FAILED : message.hello_failed_error_msg,
- ofp.OFPET_BAD_REQUEST : message.bad_request_error_msg,
- ofp.OFPET_BAD_ACTION : message.bad_action_error_msg,
- ofp.OFPET_BAD_INSTRUCTION : message.bad_instruction_error_msg,
- ofp.OFPET_BAD_MATCH : message.bad_match_error_msg,
- ofp.OFPET_FLOW_MOD_FAILED : message.flow_mod_failed_error_msg,
- ofp.OFPET_GROUP_MOD_FAILED : message.group_mod_failed_error_msg,
- ofp.OFPET_PORT_MOD_FAILED : message.port_mod_failed_error_msg,
- ofp.OFPET_TABLE_MOD_FAILED : message.table_mod_failed_error_msg,
- ofp.OFPET_QUEUE_OP_FAILED : message.queue_op_failed_error_msg,
- ofp.OFPET_SWITCH_CONFIG_FAILED : message.switch_config_failed_error_msg
-}
-
-# Map from header type value to the underlieing message class
-msg_type_to_class_map = {
- ofp.OFPT_HELLO : message.hello,
- ofp.OFPT_ERROR : message.error,
- ofp.OFPT_ECHO_REQUEST : message.echo_request,
- ofp.OFPT_ECHO_REPLY : message.echo_reply,
- ofp.OFPT_EXPERIMENTER : message.experimenter,
- ofp.OFPT_FEATURES_REQUEST : message.features_request,
- ofp.OFPT_FEATURES_REPLY : message.features_reply,
- ofp.OFPT_GET_CONFIG_REQUEST : message.get_config_request,
- ofp.OFPT_GET_CONFIG_REPLY : message.get_config_reply,
- ofp.OFPT_SET_CONFIG : message.set_config,
- ofp.OFPT_PACKET_IN : message.packet_in,
- ofp.OFPT_FLOW_REMOVED : message.flow_removed,
- ofp.OFPT_PORT_STATUS : message.port_status,
- ofp.OFPT_PACKET_OUT : message.packet_out,
- ofp.OFPT_FLOW_MOD : message.flow_mod,
- ofp.OFPT_GROUP_MOD : message.group_mod,
- ofp.OFPT_PORT_MOD : message.port_mod,
- ofp.OFPT_TABLE_MOD : message.table_mod,
- ofp.OFPT_STATS_REQUEST : message.stats_request,
- ofp.OFPT_STATS_REPLY : message.stats_reply,
- ofp.OFPT_BARRIER_REQUEST : message.barrier_request,
- ofp.OFPT_BARRIER_REPLY : message.barrier_reply,
- ofp.OFPT_QUEUE_GET_CONFIG_REQUEST : message.queue_get_config_request,
- ofp.OFPT_QUEUE_GET_CONFIG_REPLY : message.queue_get_config_reply,
-}
-
-def _of_message_to_object(binary_string):
- """
- Map a binary string to the corresponding class.
-
- Appropriately resolves subclasses
- """
- hdr = ofp.ofp_header()
- hdr.unpack(binary_string)
- # FIXME: Add error detection
- if not hdr.type in msg_type_subclassed:
- return msg_type_to_class_map[hdr.type]()
- if hdr.type == ofp.OFPT_STATS_REQUEST:
- sub_hdr = ofp.ofp_stats_request()
- sub_hdr.unpack(binary_string[ofp.OFP_HEADER_BYTES:])
- try:
- obj = stats_request_to_class_map[sub_hdr.type]()
- except LookupError:
- obj = None
- return obj
- elif hdr.type == ofp.OFPT_STATS_REPLY:
- sub_hdr = ofp.ofp_stats_reply()
- sub_hdr.unpack(binary_string[ofp.OFP_HEADER_BYTES:])
- try:
- obj = stats_reply_to_class_map[sub_hdr.type]()
- except LookupError:
- obj = None
- return obj
- elif hdr.type == ofp.OFPT_ERROR:
- sub_hdr = ofp.ofp_error_msg()
- sub_hdr.unpack(binary_string[ofp.OFP_HEADER_BYTES:])
- return error_to_class_map[sub_hdr.type]()
- else:
- parse_logger.error("Cannot parse pkt to message")
- return None
-
-def of_message_parse(binary_string, raw=False):
- """
- Parse an OpenFlow packet
-
- Parses a raw OpenFlow packet into a Python class, with class
- members fully populated.
-
- @param binary_string The packet (string) to be parsed
- @param raw If true, interpret the packet as an L2 packet. Not
- yet supported.
- @return An object of some message class or None if fails
- Note that any data beyond that parsed is not returned
-
- """
-
- if raw:
- parse_logger.error("raw packet message parsing not supported")
- return None
-
- obj = _of_message_to_object(binary_string)
- if obj:
- obj.unpack(binary_string)
- return obj
-
-
-def of_header_parse(binary_string, raw=False):
- """
- Parse only the header from an OpenFlow packet
-
- Parses the header from a raw OpenFlow packet into a
- an ofp_header Python class.
-
- @param binary_string The packet (string) to be parsed
- @param raw If true, interpret the packet as an L2 packet. Not
- yet supported.
- @return An ofp_header object
-
- """
-
- if raw:
- parse_logger.error("raw packet message parsing not supported")
- return None
-
- hdr = ofp.ofp_header()
- hdr.unpack(binary_string)
-
- return hdr
-
-map_wc_field_to_match_member = {
- 'OFPFW_DL_VLAN' : 'dl_vlan',
- 'OFPFW_DL_SRC' : 'dl_src',
- 'OFPFW_DL_DST' : 'dl_dst',
- 'OFPFW_DL_TYPE' : 'dl_type',
- 'OFPFW_NW_PROTO' : 'nw_proto',
- 'OFPFW_TP_SRC' : 'tp_src',
- 'OFPFW_TP_DST' : 'tp_dst',
- 'OFPFW_NW_SRC_SHIFT' : 'nw_src_shift',
- 'OFPFW_NW_SRC_BITS' : 'nw_src_bits',
- 'OFPFW_NW_SRC_MASK' : 'nw_src_mask',
- 'OFPFW_NW_SRC_ALL' : 'nw_src_all',
- 'OFPFW_NW_DST_SHIFT' : 'nw_dst_shift',
- 'OFPFW_NW_DST_BITS' : 'nw_dst_bits',
- 'OFPFW_NW_DST_MASK' : 'nw_dst_mask',
- 'OFPFW_NW_DST_ALL' : 'nw_dst_all',
- 'OFPFW_DL_VLAN_PCP' : 'dl_vlan_pcp',
- 'OFPFW_NW_TOS' : 'nw_tos'
-}
-
-
-def parse_mac(mac_str):
- """
- Parse a MAC address
-
- Parse a MAC address ':' separated string of hex digits to an
- array of integer values. '00:d0:05:5d:24:00' => [0, 208, 5, 93, 36, 0]
- @param mac_str The string to convert
- @return Array of 6 integer values
- """
- return map(lambda val:eval("0x" + val), mac_str.split(":"))
-
-def parse_ip(ip_str):
- """
- Parse an IP address
-
- Parse an IP address '.' separated string of decimal digits to an
- host ordered integer. '172.24.74.77' =>
- @param ip_str The string to convert
- @return Integer value
- """
- array = map(lambda val:eval(val),ip_str.split("."))
- val = 0
- for a in array:
- val <<= 8
- val += a
- return val
-
-def packet_to_flow_match(packet):
- """
- Create a flow match that matches packet with the given wildcards
-
- @param packet The packet to use as a flow template
- @param pkt_format Currently only L2 is supported. Will indicate the
- overall packet type for parsing
- @return An ofp_match object if successful. None if format is not
- recognized. The wildcards of the match will be cleared for the
- values extracted from the packet.
-
- @todo check min length of packet
- @todo Check if packet is other than L2 format
- @todo implement other fields covered by OpenFlow 1.2
- """
- match_ls = match_list()
-
- if Ether in packet:
- ether = packet[Ether]
- eth_type = match.eth_type(ether.type)
- eth_dst = match.eth_dst(parse_mac(ether.dst))
- eth_src = match.eth_src(parse_mac(ether.src))
- match_ls.add(eth_type)
- match_ls.add(eth_dst)
- match_ls.add(eth_src)
- else:
- return match_ls
-
- if Dot1Q in packet:
- #TODO: nicer way to get last vlan tag?
- vlan = packet[Dot1Q:0]
- vlan_vid = match.vlan_vid(vlan.vlan)
- vlan_pcp = match.vlan_pcp(vlan.prio)
- match_ls.add(vlan_vid)
- match_ls.add(vlan_pcp)
- vlan_pl = vlan.payload
- while vlan_pl is not None and vlan_pl.name == Dot1Q.name:
- vlan = vlan_pl
- vlan_pl = vlan.payload
- #We need to overwrite the already
- # inserted eth_type
- eth_index = match.tlvs.index()
- eth_type = match.eth_type(vlan.type)
- match_ls.tlvs.insert(vlan.type,eth_index)
- #TODO ARP
-
- if MPLS in packet:
- mpls = packet[MPLS:0]
- mpls_label = match.mpls_label(mpls.label)
- mpls_tc = match.mpls_tc(mpls.cos)
- match_ls.add(mpls_label)
- match_ls.add(mpls_tc)
- return match_ls
-
- if IP in packet:
- ip = packet[IP]
- ipv4_src = match.ipv4_src(parse_ip(ip.src))
- ipv4_dst = match.ipv4_dst(parse_ip(ip.dst))
- ip_dscp = match.ip_dscp(ip.tos >> 2)
- ip_ecn = match.ip_ecn(ip.tos & 0x03)
- match_ls.add(ipv4_src)
- match_ls.add(ipv4_dst)
- match_ls.add(ip_dscp)
- match_ls.add(ip_ecn)
- else:
- return match_ls
-
- if TCP in packet:
- tcp = packet[TCP]
- ip_proto = match.ip_proto(6)
- tcp_src = match.tcp_src(tcp.sport)
- tcp_dst = match.tcp_dst(tcp.dport)
- match_ls.add(ip_proto)
- match_ls.add(tcp_src)
- match_ls.add(tcp_dst)
- return match_ls
-
- if UDP in packet:
- udp = packet[UDP]
- ip_proto = match.ip_proto(17)
- udp_src = match.tcp_src(udp.sport)
- udp_dst = match.tcp_dst(udp.dport)
- match_ls.add(ip_proto)
- match_ls.add(udp_src)
- match_ls.add(udp_dst)
- return match_ls
-
- if ICMP in packet:
- icmp = packet[ICMP]
- ip_proto = match.ip_proto(1)
- icmp_type = match.icmp_type(icmp.type)
- icmp_code = match.icmp_code(icmp.code)
- match_ls.add(icmp_type)
- match_ls.add(icmp_code)
- return match_ls
-
- return match_ls
diff --git a/src/python/oftest/__init__.py b/src/python/oftest/__init__.py
index 65a5648..9199b1a 100644
--- a/src/python/oftest/__init__.py
+++ b/src/python/oftest/__init__.py
@@ -8,9 +8,3 @@
# Global DataPlane instance used by all tests.
# Populated by oft.
dataplane_instance = None
-
-# Alias of10 modules into oftest namespace for backwards compatbility
-import of10
-from of10 import *
-for modname in of10.__all__:
- sys.modules["oftest." + modname] = sys.modules["of10." + modname]
diff --git a/src/python/oftest/base_tests.py b/src/python/oftest/base_tests.py
index 5c6c9cf..9d905f9 100644
--- a/src/python/oftest/base_tests.py
+++ b/src/python/oftest/base_tests.py
@@ -44,7 +44,7 @@
reply, pkt = self.controller.transact(request)
self.assertTrue(reply is not None,
"Did not complete features_request for handshake")
- if reply.header.version == 1:
+ if reply.version == 1:
self.supported_actions = reply.actions
logging.info("Supported actions: " + hex(self.supported_actions))
except:
diff --git a/src/python/oftest/controller.py b/src/python/oftest/controller.py
index 4d44c14..41ac927 100644
--- a/src/python/oftest/controller.py
+++ b/src/python/oftest/controller.py
@@ -167,6 +167,8 @@
Currently filters packet in messages
@return Boolean, True if packet should be dropped
"""
+ # XXX didn't actually check for packet-in...
+ return False
# Add check for packet in and rate limit
if self.filter_packet_in:
# If we were dropping packets, report number dropped
@@ -203,37 +205,34 @@
# Process each of the OF msgs inside the pkt
offset = 0
while offset < len(pkt):
+ if offset + 8 > len(pkt):
+ break
+
# Parse the header to get type
- hdr = ofp.parse.of_header_parse(pkt[offset:])
- if not hdr or hdr.length == 0:
- self.logger.error("Could not parse header")
- self.logger.error("pkt len %d." % len(pkt))
- if hdr:
- self.logger.error("hdr len %d." % hdr.length)
- self.logger.error("%s" % hex_dump_buffer(pkt[:200]))
- self.shutdown()
- return
+ hdr_version, hdr_type, hdr_length, hdr_xid = ofp.message.parse_header(pkt[offset:])
# Extract the raw message bytes
- if (offset + hdr.length) > len(pkt):
+ if (offset + hdr_length) > len(pkt):
break
- rawmsg = pkt[offset : offset + hdr.length]
- offset += hdr.length
+ rawmsg = pkt[offset : offset + hdr_length]
+ offset += hdr_length
- if self.filter_packet(rawmsg, hdr):
- continue
+ #if self.filter_packet(rawmsg, hdr):
+ # continue
- self.logger.debug("Msg in: buf len %d. hdr.type %s. hdr.len %d hdr.version %d hdr.xid %d" %
- (len(pkt), ofp.cstruct.ofp_type_map[hdr.type], hdr.length, hdr.version, hdr.xid))
- if hdr.version < ofp.cstruct.OFP_VERSION:
+ self.logger.debug("Msg in: version %d type %s (%d) len %d xid %d",
+ hdr_version,
+ ofp.ofp_type_map.get(hdr_type, "unknown"), hdr_type,
+ hdr_length, hdr_version)
+ if hdr_version < ofp.OFP_VERSION:
self.logger.error("Switch only supports up to OpenFlow version %d (OFTest version is %d)",
- hdr.version, ofp.cstruct.OFP_VERSION)
+ hdr_version, ofp.OFP_VERSION)
print "Switch only supports up to OpenFlow version %d (OFTest version is %d)" % \
- (hdr.version, ofp.cstruct.OFP_VERSION)
+ (hdr_version, ofp.OFP_VERSION)
self.disconnect()
return
- msg = ofp.parse.of_message_parse(rawmsg)
+ msg = ofp.message.parse_message(rawmsg)
if not msg:
self.parse_errors += 1
self.logger.warn("Could not parse message")
@@ -242,8 +241,8 @@
with self.sync:
# Check if transaction is waiting
with self.xid_cv:
- if self.xid and hdr.xid == self.xid:
- self.logger.debug("Matched expected XID " + str(hdr.xid))
+ if self.xid and hdr_xid == self.xid:
+ self.logger.debug("Matched expected XID " + str(hdr_xid))
self.xid_response = (msg, rawmsg)
self.xid = None
self.xid_cv.notify()
@@ -251,29 +250,29 @@
# Check if keep alive is set; if so, respond to echo requests
if self.keep_alive:
- if hdr.type == ofp.cstruct.OFPT_ECHO_REQUEST:
+ if hdr_type == ofp.OFPT_ECHO_REQUEST:
self.logger.debug("Responding to echo request")
rep = ofp.message.echo_reply()
- rep.header.xid = hdr.xid
+ rep.xid = hdr_xid
# Ignoring additional data
- self.message_send(rep.pack(), zero_xid=True)
+ self.message_send(rep.pack())
continue
# Log error messages
- if hdr.type == ofp.OFPT_ERROR:
- if msg.type in ofp.ofp_error_type_map:
- type_str = ofp.ofp_error_type_map[msg.type]
- if msg.type == ofp.OFPET_HELLO_FAILED:
+ if hdr_type == ofp.OFPT_ERROR:
+ if msg.err_type in ofp.ofp_error_type_map:
+ type_str = ofp.ofp_error_type_map[msg.err_type]
+ if msg.err_type == ofp.OFPET_HELLO_FAILED:
code_map = ofp.ofp_hello_failed_code_map
- elif msg.type == ofp.OFPET_BAD_REQUEST:
+ elif msg.err_type == ofp.OFPET_BAD_REQUEST:
code_map = ofp.ofp_bad_request_code_map
- elif msg.type == ofp.OFPET_BAD_ACTION:
+ elif msg.err_type == ofp.OFPET_BAD_ACTION:
code_map = ofp.ofp_bad_action_code_map
- elif msg.type == ofp.OFPET_FLOW_MOD_FAILED:
+ elif msg.err_type == ofp.OFPET_FLOW_MOD_FAILED:
code_map = ofp.ofp_flow_mod_failed_code_map
- elif msg.type == ofp.OFPET_PORT_MOD_FAILED:
+ elif msg.err_type == ofp.OFPET_PORT_MOD_FAILED:
code_map = ofp.ofp_port_mod_failed_code_map
- elif msg.type == ofp.OFPET_QUEUE_OP_FAILED:
+ elif msg.err_type == ofp.OFPET_QUEUE_OP_FAILED:
code_map = ofp.ofp_queue_op_failed_code_map
else:
code_map = None
@@ -284,19 +283,22 @@
code_str = "unknown"
else:
type_str = "unknown"
+ code_str = "unknown"
self.logger.warn("Received error message: xid=%d type=%s (%d) code=%s (%d)",
- hdr.xid, type_str, msg.type, code_str, msg.code)
+ hdr_xid, type_str, msg.err_type, code_str, msg.code)
# Now check for message handlers; preference is given to
# handlers for a specific packet
handled = False
- if hdr.type in self.handlers.keys():
- handled = self.handlers[hdr.type](self, msg, rawmsg)
+ if hdr_type in self.handlers.keys():
+ handled = self.handlers[hdr_type](self, msg, rawmsg)
if not handled and ("all" in self.handlers.keys()):
handled = self.handlers["all"](self, msg, rawmsg)
if not handled: # Not handled, enqueue
- self.logger.debug("Enqueuing pkt type " + ofp.cstruct.ofp_type_map[hdr.type])
+ self.logger.debug("Enqueuing pkt type %s (%d)",
+ ofp.ofp_type_map.get(hdr_type, "unknown"),
+ hdr_type)
with self.packets_cv:
if len(self.packets) >= self.max_pkts:
self.packets.pop(0)
@@ -576,8 +578,10 @@
If an error occurs, (None, None) is returned
"""
+ exp_msg_str = ofp.ofp_type_map.get(exp_msg, "unknown (%d)" % exp_msg)
+
if exp_msg is not None:
- self.logger.debug("Poll for %s" % ofp.cstruct.ofp_type_map[exp_msg])
+ self.logger.debug("Poll for %s", exp_msg_str)
else:
self.logger.debug("Poll for any OF message")
@@ -589,11 +593,11 @@
(msg, pkt) = self.packets.pop(0)
return (msg, pkt)
else:
- self.logger.debug("Looking for %s" % ofp.cstruct.ofp_type_map[exp_msg])
+ self.logger.debug("Looking for %s", exp_msg_str)
for i in range(len(self.packets)):
msg = self.packets[i][0]
- self.logger.debug("Checking packets[%d] (%s)" % (i, ofp.cstruct.ofp_type_map[msg.header.type]))
- if msg.header.type == exp_msg:
+ self.logger.debug("Checking packets[%d] (%s)", i, exp_msg_str)
+ if msg.type == exp_msg:
(msg, pkt) = self.packets.pop(i)
return (msg, pkt)
# Not found
@@ -610,7 +614,7 @@
else:
return (None, None)
- def transact(self, msg, timeout=-1, zero_xid=False):
+ def transact(self, msg, timeout=-1):
"""
Run a message transaction with the switch
@@ -620,27 +624,23 @@
@param msg The message object to send; must not be a string
@param timeout The timeout in seconds; if -1 use default.
- @param zero_xid Normally, if the XID is 0 an XID will be generated
- for the message. Set zero_xid to override this behavior
- @return The matching message object or None if unsuccessful
-
"""
- if not zero_xid and msg.header.xid == 0:
- msg.header.xid = ofutils.gen_xid()
+ if msg.xid == None:
+ msg.xid = ofutils.gen_xid()
- self.logger.debug("Running transaction %d" % msg.header.xid)
+ self.logger.debug("Running transaction %d" % msg.xid)
with self.xid_cv:
if self.xid:
self.logger.error("Can only run one transaction at a time")
return (None, None)
- self.xid = msg.header.xid
+ self.xid = msg.xid
self.xid_response = None
self.message_send(msg.pack())
- self.logger.debug("Waiting for transaction %d" % msg.header.xid)
+ self.logger.debug("Waiting for transaction %d" % msg.xid)
ofutils.timed_wait(self.xid_cv, lambda: self.xid_response, timeout=timeout)
if self.xid_response:
@@ -653,16 +653,12 @@
self.logger.warning("No response for xid " + str(self.xid))
return (resp, pkt)
- def message_send(self, msg, zero_xid=False):
+ def message_send(self, msg):
"""
Send the message to the switch
@param msg A string or OpenFlow message object to be forwarded to
the switch.
- @param zero_xid If msg is an OpenFlow object (not a string) and if
- the XID in the header is 0, then an XID will be generated
- for the message. Set zero_xid to override this behavior (and keep an
- existing 0 xid)
"""
if not self.switch_socket:
@@ -670,8 +666,8 @@
raise Exception("no socket")
#@todo If not string, try to pack
if type(msg) != type(""):
- if msg.header.xid == 0 and not zero_xid:
- msg.header.xid = ofutils.gen_xid()
+ if msg.xid == None:
+ msg.xid = ofutils.gen_xid()
outpkt = msg.pack()
else:
outpkt = msg
@@ -679,7 +675,7 @@
msg_version, msg_type, msg_len, msg_xid = struct.unpack_from("!BBHL", outpkt)
self.logger.debug("Msg out: buf len %d. hdr.type %s. hdr.len %d hdr.version %d hdr.xid %d",
len(outpkt),
- ofp.cstruct.ofp_type_map.get(msg_type, "unknown (%d)" % msg_type),
+ ofp.ofp_type_map.get(msg_type, "unknown (%d)" % msg_type),
msg_len,
msg_version,
msg_xid)
diff --git a/src/python/oftest/illegal_message.py b/src/python/oftest/illegal_message.py
index 0c6a878..8e52e33 100644
--- a/src/python/oftest/illegal_message.py
+++ b/src/python/oftest/illegal_message.py
@@ -2,107 +2,42 @@
Support an illegal message
"""
-from cstruct import *
+import struct
+import ofp
-ILLEGAL_MESSAGE_TYPE=217
+class illegal_message_type(object):
+ version = ofp.OFP_VERSION
+ type = 217
-class illegal_message_type:
- """
- Wrapper class for illegal message
-
- OpenFlow message header: length, version, xid, type
- @arg length: The total length of the message
- @arg version: The OpenFlow version (1)
- @arg xid: The transaction ID
- @arg type: The message type (OFPT_ECHO_REQUEST=2)
-
- @arg data: Binary string following message members
-
- The message type is set to "illegal" and the pack assert
- check for the OF header is disabled
- """
-
- def __init__(self):
- self.header = ofp_header()
- self.header.type = ILLEGAL_MESSAGE_TYPE
- self.data = ""
+ def __init__(self, xid=None):
+ self.xid = xid
def pack(self):
- """
- Pack object into string
+ packed = []
+ packed.append(struct.pack("!B", self.version))
+ packed.append(struct.pack("!B", self.type))
+ packed.append(struct.pack("!H", 0)) # placeholder for length at index 2
+ packed.append(struct.pack("!L", self.xid))
+ length = sum([len(x) for x in packed])
+ packed[2] = struct.pack("!H", length)
+ return ''.join(packed)
- @return The packed string which can go on the wire
-
- """
- self.header.length = len(self)
- packed = self.header.pack(assertstruct=False)
-
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- """
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- """
- binary_string = self.header.unpack(binary_string)
-
- self.data = binary_string
- binary_string = ''
- return binary_string
-
- def __len__(self):
- """
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- """
- length = OFP_HEADER_BYTES
-
- length += len(self.data)
- return length
-
- def show(self, prefix=''):
- """
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- """
-
- outstr = prefix + 'illegal_message (' + \
- str(ILLEGAL_MESSAGE_TYPE) + ')\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += self.header.show(prefix + ' ')
- outstr += prefix + 'data is of length ' + str(len(self.data)) + '\n'
- return outstr
+ @staticmethod
+ def unpack(buf):
+ raise NotImplementedError()
def __eq__(self, other):
- """
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- """
if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-
- if self.data != other.data: 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 True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
return not self.__eq__(other)
+
+ def __str__(self):
+ return self.show()
+
+ def show(self):
+ return "illegal_message_type"
diff --git a/src/python/oftest/parse.py b/src/python/oftest/parse.py
new file mode 100644
index 0000000..d75c7cd
--- /dev/null
+++ b/src/python/oftest/parse.py
@@ -0,0 +1,185 @@
+"""
+Utility parsing functions
+"""
+
+import sys
+import logging
+import ofp
+try:
+ import scapy.all as scapy
+except:
+ try:
+ import scapy as scapy
+ except:
+ sys.exit("Need to install scapy for packet parsing")
+
+map_wc_field_to_match_member = {
+ 'OFPFW_DL_VLAN' : 'vlan_vid',
+ 'OFPFW_DL_SRC' : 'eth_src',
+ 'OFPFW_DL_DST' : 'eth_dst',
+ 'OFPFW_DL_TYPE' : 'eth_type',
+ 'OFPFW_NW_PROTO' : 'ip_proto',
+ 'OFPFW_TP_SRC' : 'tcp_src',
+ 'OFPFW_TP_DST' : 'tcp_dst',
+ 'OFPFW_NW_SRC_SHIFT' : 'nw_src_shift',
+ 'OFPFW_NW_SRC_BITS' : 'nw_src_bits',
+ 'OFPFW_NW_SRC_MASK' : 'nw_src_mask',
+ 'OFPFW_NW_SRC_ALL' : 'nw_src_all',
+ 'OFPFW_NW_DST_SHIFT' : 'nw_dst_shift',
+ 'OFPFW_NW_DST_BITS' : 'nw_dst_bits',
+ 'OFPFW_NW_DST_MASK' : 'nw_dst_mask',
+ 'OFPFW_NW_DST_ALL' : 'nw_dst_all',
+ 'OFPFW_DL_VLAN_PCP' : 'vlan_pcp',
+ 'OFPFW_NW_TOS' : 'ip_dscp'
+}
+
+
+def parse_mac(mac_str):
+ """
+ Parse a MAC address
+
+ Parse a MAC address ':' separated string of hex digits to an
+ array of integer values. '00:d0:05:5d:24:00' => [0, 208, 5, 93, 36, 0]
+ @param mac_str The string to convert
+ @return Array of 6 integer values
+ """
+ return map(lambda val: int(val, 16), mac_str.split(":"))
+
+def parse_ip(ip_str):
+ """
+ Parse an IP address
+
+ Parse an IP address '.' separated string of decimal digits to an
+ host ordered integer. '172.24.74.77' =>
+ @param ip_str The string to convert
+ @return Integer value
+ """
+ array = map(lambda val: int(val), ip_str.split("."))
+ val = 0
+ for a in array:
+ val <<= 8
+ val += a
+ return val
+
+def packet_type_classify(ether):
+ try:
+ dot1q = ether[scapy.Dot1Q]
+ except:
+ dot1q = None
+
+ try:
+ ip = ether[scapy.IP]
+ except:
+ ip = None
+
+ try:
+ tcp = ether[scapy.TCP]
+ except:
+ tcp = None
+
+ try:
+ udp = ether[scapy.UDP]
+ except:
+ udp = None
+
+ try:
+ icmp = ether[scapy.ICMP]
+ except:
+ icmp = None
+
+ try:
+ arp = ether[scapy.ARP]
+ except:
+ arp = None
+ return (dot1q, ip, tcp, udp, icmp, arp)
+
+def packet_to_flow_match(packet, pkt_format="L2"):
+ """
+ Create a flow match that matches packet with the given wildcards
+
+ @param packet The packet to use as a flow template
+ @param pkt_format Currently only L2 is supported. Will indicate the
+ overall packet type for parsing
+ @return An ofp_match object if successful. None if format is not
+ recognized. The wildcards of the match will be cleared for the
+ values extracted from the packet.
+
+ @todo check min length of packet
+ @todo Check if packet is other than L2 format
+ @todo Implement ICMP and ARP fields
+ """
+
+ #@todo check min length of packet
+ if pkt_format.upper() != "L2":
+ logging.error("Only L2 supported for packet_to_flow")
+ return None
+
+ if type(packet) == type(""):
+ ether = scapy.Ether(packet)
+ else:
+ ether = packet
+
+ # For now, assume ether IP packet and ignore wildcards
+ try:
+ (dot1q, ip, tcp, udp, icmp, arp) = packet_type_classify(ether)
+ except:
+ logging.error("packet_to_flow_match: Classify error")
+ return None
+
+ match = ofp.match()
+ match.wildcards = ofp.OFPFW_ALL
+ #@todo Check if packet is other than L2 format
+ match.eth_dst = parse_mac(ether.dst)
+ match.wildcards &= ~ofp.OFPFW_DL_DST
+ match.eth_src = parse_mac(ether.src)
+ match.wildcards &= ~ofp.OFPFW_DL_SRC
+ match.eth_type = ether.type
+ match.wildcards &= ~ofp.OFPFW_DL_TYPE
+
+ if dot1q:
+ match.vlan_vid = dot1q.vlan
+ match.vlan_pcp = dot1q.prio
+ match.eth_type = dot1q.type
+ else:
+ match.vlan_vid = ofp.OFP_VLAN_NONE
+ match.vlan_pcp = 0
+ match.wildcards &= ~ofp.OFPFW_DL_VLAN
+ match.wildcards &= ~ofp.OFPFW_DL_VLAN_PCP
+
+ if ip:
+ match.ipv4_src = parse_ip(ip.src)
+ match.wildcards &= ~ofp.OFPFW_NW_SRC_MASK
+ match.ipv4_dst = parse_ip(ip.dst)
+ match.wildcards &= ~ofp.OFPFW_NW_DST_MASK
+ match.ip_dscp = ip.tos
+ match.wildcards &= ~ofp.OFPFW_NW_TOS
+
+ if tcp:
+ match.ip_proto = 6
+ match.wildcards &= ~ofp.OFPFW_NW_PROTO
+ elif not tcp and udp:
+ tcp = udp
+ match.ip_proto = 17
+ match.wildcards &= ~ofp.OFPFW_NW_PROTO
+
+ if tcp:
+ match.tcp_src = tcp.sport
+ match.wildcards &= ~ofp.OFPFW_TP_SRC
+ match.tcp_dst = tcp.dport
+ match.wildcards &= ~ofp.OFPFW_TP_DST
+
+ if icmp:
+ match.ip_proto = 1
+ match.tcp_src = icmp.type
+ match.tcp_dst = icmp.code
+ match.wildcards &= ~ofp.OFPFW_NW_PROTO
+
+ if arp:
+ match.ip_proto = arp.op
+ match.wildcards &= ~ofp.OFPFW_NW_PROTO
+ match.ipv4_src = parse_ip(arp.psrc)
+ match.wildcards &= ~ofp.OFPFW_NW_SRC_MASK
+ match.ipv4_dst = parse_ip(arp.pdst)
+ match.wildcards &= ~ofp.OFPFW_NW_DST_MASK
+
+ return match
diff --git a/src/python/oftest/testutils.py b/src/python/oftest/testutils.py
index fcd8f21..980099f 100644
--- a/src/python/oftest/testutils.py
+++ b/src/python/oftest/testutils.py
@@ -16,10 +16,8 @@
import oftest
import oftest.controller
import oftest.dataplane
-import of10.cstruct
-import of10.message
-import of10.action
-import of10.parse
+import oftest.parse
+import ofp
global skipped_test_count
skipped_test_count = 0
@@ -40,10 +38,9 @@
"""
logging.info("Deleting all flows")
- msg = of10.message.flow_mod()
- msg.match.wildcards = of10.cstruct.OFPFW_ALL
- msg.out_port = of10.cstruct.OFPP_NONE
- msg.command = of10.cstruct.OFPFC_DELETE
+ msg = ofp.message.flow_delete()
+ msg.match.wildcards = ofp.OFPFW_ALL
+ msg.out_port = ofp.OFPP_NONE
msg.buffer_id = 0xffffffff
ctrl.message_send(msg)
return 0 # for backwards compatibility
@@ -51,17 +48,17 @@
def required_wildcards(parent):
w = test_param_get('required_wildcards', default='default')
if w == 'l3-l4':
- return (of10.cstruct.OFPFW_NW_SRC_ALL | of10.cstruct.OFPFW_NW_DST_ALL | of10.cstruct.OFPFW_NW_TOS
- | of10.cstruct.OFPFW_NW_PROTO | of10.cstruct.OFPFW_TP_SRC | of10.cstruct.OFPFW_TP_DST)
+ return (ofp.OFPFW_NW_SRC_ALL | ofp.OFPFW_NW_DST_ALL | ofp.OFPFW_NW_TOS
+ | ofp.OFPFW_NW_PROTO | ofp.OFPFW_TP_SRC | ofp.OFPFW_TP_DST)
else:
return 0
def simple_tcp_packet(pktlen=100,
- dl_dst='00:01:02:03:04:05',
- dl_src='00:06:07:08:09:0a',
+ eth_dst='00:01:02:03:04:05',
+ eth_src='00:06:07:08:09:0a',
dl_vlan_enable=False,
- dl_vlan=0,
- dl_vlan_pcp=0,
+ vlan_vid=0,
+ vlan_pcp=0,
dl_vlan_cfi=0,
ip_src='192.168.0.1',
ip_dst='192.168.0.2',
@@ -77,11 +74,11 @@
Supports a few parameters:
@param len Length of packet in bytes w/o CRC
- @param dl_dst Destinatino MAC
- @param dl_src Source MAC
+ @param eth_dst Destinatino MAC
+ @param eth_src Source MAC
@param dl_vlan_enable True if the packet is with vlan, False otherwise
- @param dl_vlan VLAN ID
- @param dl_vlan_pcp VLAN priority
+ @param vlan_vid VLAN ID
+ @param vlan_pcp VLAN priority
@param ip_src IP source
@param ip_dst IP destination
@param ip_tos IP ToS
@@ -99,17 +96,17 @@
# Note Dot1Q.id is really CFI
if (dl_vlan_enable):
- pkt = scapy.Ether(dst=dl_dst, src=dl_src)/ \
- scapy.Dot1Q(prio=dl_vlan_pcp, id=dl_vlan_cfi, vlan=dl_vlan)/ \
+ pkt = scapy.Ether(dst=eth_dst, src=eth_src)/ \
+ scapy.Dot1Q(prio=vlan_pcp, id=dl_vlan_cfi, vlan=vlan_vid)/ \
scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, ttl=ip_ttl, ihl=ip_ihl)/ \
scapy.TCP(sport=tcp_sport, dport=tcp_dport)
else:
if not ip_options:
- pkt = scapy.Ether(dst=dl_dst, src=dl_src)/ \
+ pkt = scapy.Ether(dst=eth_dst, src=eth_src)/ \
scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, ttl=ip_ttl, ihl=ip_ihl)/ \
scapy.TCP(sport=tcp_sport, dport=tcp_dport)
else:
- pkt = scapy.Ether(dst=dl_dst, src=dl_src)/ \
+ pkt = scapy.Ether(dst=eth_dst, src=eth_src)/ \
scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, ttl=ip_ttl, ihl=ip_ihl, options=ip_options)/ \
scapy.TCP(sport=tcp_sport, dport=tcp_dport)
@@ -118,11 +115,11 @@
return pkt
def simple_udp_packet(pktlen=100,
- dl_dst='00:01:02:03:04:05',
- dl_src='00:06:07:08:09:0a',
+ eth_dst='00:01:02:03:04:05',
+ eth_src='00:06:07:08:09:0a',
dl_vlan_enable=False,
- dl_vlan=0,
- dl_vlan_pcp=0,
+ vlan_vid=0,
+ vlan_pcp=0,
dl_vlan_cfi=0,
ip_src='192.168.0.1',
ip_dst='192.168.0.2',
@@ -138,11 +135,11 @@
Supports a few parameters:
@param len Length of packet in bytes w/o CRC
- @param dl_dst Destination MAC
- @param dl_src Source MAC
+ @param eth_dst Destination MAC
+ @param eth_src Source MAC
@param dl_vlan_enable True if the packet is with vlan, False otherwise
- @param dl_vlan VLAN ID
- @param dl_vlan_pcp VLAN priority
+ @param vlan_vid VLAN ID
+ @param vlan_pcp VLAN priority
@param ip_src IP source
@param ip_dst IP destination
@param ip_tos IP ToS
@@ -159,17 +156,17 @@
# Note Dot1Q.id is really CFI
if (dl_vlan_enable):
- pkt = scapy.Ether(dst=dl_dst, src=dl_src)/ \
- scapy.Dot1Q(prio=dl_vlan_pcp, id=dl_vlan_cfi, vlan=dl_vlan)/ \
+ pkt = scapy.Ether(dst=eth_dst, src=eth_src)/ \
+ scapy.Dot1Q(prio=vlan_pcp, id=dl_vlan_cfi, vlan=vlan_vid)/ \
scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, ttl=ip_ttl, ihl=ip_ihl)/ \
scapy.UDP(sport=udp_sport, dport=udp_dport)
else:
if not ip_options:
- pkt = scapy.Ether(dst=dl_dst, src=dl_src)/ \
+ pkt = scapy.Ether(dst=eth_dst, src=eth_src)/ \
scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, ttl=ip_ttl, ihl=ip_ihl)/ \
scapy.UDP(sport=udp_sport, dport=udp_dport)
else:
- pkt = scapy.Ether(dst=dl_dst, src=dl_src)/ \
+ pkt = scapy.Ether(dst=eth_dst, src=eth_src)/ \
scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, ttl=ip_ttl, ihl=ip_ihl, options=ip_options)/ \
scapy.UDP(sport=udp_sport, dport=udp_dport)
@@ -178,11 +175,11 @@
return pkt
def simple_icmp_packet(pktlen=60,
- dl_dst='00:01:02:03:04:05',
- dl_src='00:06:07:08:09:0a',
+ eth_dst='00:01:02:03:04:05',
+ eth_src='00:06:07:08:09:0a',
dl_vlan_enable=False,
- dl_vlan=0,
- dl_vlan_pcp=0,
+ vlan_vid=0,
+ vlan_pcp=0,
ip_src='192.168.0.1',
ip_dst='192.168.0.2',
ip_tos=0,
@@ -195,11 +192,11 @@
Supports a few parameters:
@param len Length of packet in bytes w/o CRC
- @param dl_dst Destinatino MAC
- @param dl_src Source MAC
+ @param eth_dst Destinatino MAC
+ @param eth_src Source MAC
@param dl_vlan_enable True if the packet is with vlan, False otherwise
- @param dl_vlan VLAN ID
- @param dl_vlan_pcp VLAN priority
+ @param vlan_vid VLAN ID
+ @param vlan_pcp VLAN priority
@param ip_src IP source
@param ip_dst IP destination
@param ip_tos IP ToS
@@ -216,12 +213,12 @@
pktlen = MINSIZE
if (dl_vlan_enable):
- pkt = scapy.Ether(dst=dl_dst, src=dl_src)/ \
- scapy.Dot1Q(prio=dl_vlan_pcp, id=0, vlan=dl_vlan)/ \
+ pkt = scapy.Ether(dst=eth_dst, src=eth_src)/ \
+ scapy.Dot1Q(prio=vlan_pcp, id=0, vlan=vlan_vid)/ \
scapy.IP(src=ip_src, dst=ip_dst, ttl=ip_ttl, tos=ip_tos)/ \
scapy.ICMP(type=icmp_type, code=icmp_code)
else:
- pkt = scapy.Ether(dst=dl_dst, src=dl_src)/ \
+ pkt = scapy.Ether(dst=eth_dst, src=eth_src)/ \
scapy.IP(src=ip_src, dst=ip_dst, ttl=ip_ttl, tos=ip_tos)/ \
scapy.ICMP(type=icmp_type, code=icmp_code)
@@ -230,8 +227,8 @@
return pkt
def simple_arp_packet(pktlen=60,
- dl_dst='ff:ff:ff:ff:ff:ff',
- dl_src='00:06:07:08:09:0a',
+ eth_dst='ff:ff:ff:ff:ff:ff',
+ eth_src='00:06:07:08:09:0a',
arp_op=1,
ip_snd='192.168.0.1',
ip_tgt='192.168.0.2',
@@ -243,8 +240,8 @@
Supports a few parameters:
@param len Length of packet in bytes w/o CRC
- @param dl_dst Destinatino MAC
- @param dl_src Source MAC
+ @param eth_dst Destinatino MAC
+ @param eth_src Source MAC
@param arp_op Operation (1=request, 2=reply)
@param ip_snd Sender IP
@param ip_tgt Target IP
@@ -259,7 +256,7 @@
if MINSIZE > pktlen:
pktlen = MINSIZE
- pkt = scapy.Ether(dst=dl_dst, src=dl_src)/ \
+ pkt = scapy.Ether(dst=eth_dst, src=eth_src)/ \
scapy.ARP(hwsrc=hw_snd, hwdst=hw_tgt, pdst=ip_tgt, psrc=ip_snd, op=arp_op)
pkt = pkt/("0" * (pktlen - len(pkt)))
@@ -267,27 +264,27 @@
return pkt
def simple_eth_packet(pktlen=60,
- dl_dst='00:01:02:03:04:05',
- dl_src='01:80:c2:00:00:00',
- dl_type=0x88cc):
+ eth_dst='00:01:02:03:04:05',
+ eth_src='01:80:c2:00:00:00',
+ eth_type=0x88cc):
if MINSIZE > pktlen:
pktlen = MINSIZE
- pkt = scapy.Ether(dst=dl_dst, src=dl_src, type=dl_type)
+ pkt = scapy.Ether(dst=eth_dst, src=eth_src, type=eth_type)
pkt = pkt/("0" * (pktlen - len(pkt)))
return pkt
def qinq_tcp_packet(pktlen=100,
- dl_dst='00:01:02:03:04:05',
- dl_src='00:06:07:08:09:0a',
+ eth_dst='00:01:02:03:04:05',
+ eth_src='00:06:07:08:09:0a',
dl_vlan_outer=20,
dl_vlan_pcp_outer=0,
dl_vlan_cfi_outer=0,
- dl_vlan=10,
- dl_vlan_pcp=0,
+ vlan_vid=10,
+ vlan_pcp=0,
dl_vlan_cfi=0,
ip_src='192.168.0.1',
ip_dst='192.168.0.2',
@@ -303,13 +300,13 @@
Supports a few parameters:
@param len Length of packet in bytes w/o CRC
- @param dl_dst Destinatino MAC
- @param dl_src Source MAC
+ @param eth_dst Destinatino MAC
+ @param eth_src Source MAC
@param dl_vlan_outer Outer VLAN ID
@param dl_vlan_pcp_outer Outer VLAN priority
@param dl_vlan_cfi_outer Outer VLAN cfi bit
- @param dl_vlan Inner VLAN ID
- @param dl_vlan_pcp VLAN priority
+ @param vlan_vid Inner VLAN ID
+ @param vlan_pcp VLAN priority
@param dl_vlan_cfi VLAN cfi bit
@param ip_src IP source
@param ip_dst IP destination
@@ -326,9 +323,9 @@
pktlen = MINSIZE
# Note Dot1Q.id is really CFI
- pkt = scapy.Ether(dst=dl_dst, src=dl_src)/ \
+ pkt = scapy.Ether(dst=eth_dst, src=eth_src)/ \
scapy.Dot1Q(prio=dl_vlan_pcp_outer, id=dl_vlan_cfi_outer, vlan=dl_vlan_outer)/ \
- scapy.Dot1Q(prio=dl_vlan_pcp, id=dl_vlan_cfi, vlan=dl_vlan)/ \
+ scapy.Dot1Q(prio=vlan_pcp, id=dl_vlan_cfi, vlan=vlan_vid)/ \
scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, ttl=ip_ttl, ihl=ip_ihl)/ \
scapy.TCP(sport=tcp_sport, dport=tcp_dport)
@@ -341,7 +338,7 @@
Do a barrier command
Return 0 on success, -1 on error
"""
- b = of10.message.barrier_request()
+ b = ofp.message.barrier_request()
(resp, pkt) = ctrl.transact(b, timeout=timeout)
if resp is None:
raise AssertionError("barrier failed")
@@ -358,7 +355,7 @@
@returns (hwaddr, config, advert) The hwaddress, configuration and
advertised values
"""
- request = of10.message.features_request()
+ request = ofp.message.features_request()
reply, pkt = controller.transact(request)
logging.debug(reply.show())
if reply is None:
@@ -380,7 +377,7 @@
configuration value according to config and mask
"""
logging.info("Setting port " + str(port_no) + " to config " + str(config))
- request = of10.message.features_request()
+ request = ofp.message.features_request()
reply, pkt = controller.transact(request)
if reply is None:
return -1
@@ -390,7 +387,7 @@
if reply.ports[idx].port_no == port_no:
p = reply.ports[idx]
break
- mod = of10.message.port_mod()
+ mod = ofp.message.port_mod()
mod.port_no = port_no
if p:
mod.hw_addr = p.hw_addr
@@ -461,7 +458,7 @@
# Expect a packet from each port on egr port list
for egr_port in egr_port_list:
check_port = egr_port
- if egr_port == of10.cstruct.OFPP_IN_PORT:
+ if egr_port == ofp.OFPP_IN_PORT:
check_port = ing_port
(rcv_port, rcv_pkt, pkt_time) = parent.dataplane.poll(
port_number=check_port, exp_pkt=exp_pkt_arg)
@@ -500,52 +497,52 @@
parent.assertEqual(req_match.in_port, res_match.in_port,
'Match failed: in_port: ' + str(req_match.in_port) +
" != " + str(res_match.in_port))
- parent.assertEqual(str(req_match.dl_src), str(res_match.dl_src),
- 'Match failed: dl_src: ' + str(req_match.dl_src) +
- " != " + str(res_match.dl_src))
- parent.assertEqual(str(req_match.dl_dst), str(res_match.dl_dst),
- 'Match failed: dl_dst: ' + str(req_match.dl_dst) +
- " != " + str(res_match.dl_dst))
- parent.assertEqual(req_match.dl_vlan, res_match.dl_vlan,
- 'Match failed: dl_vlan: ' + str(req_match.dl_vlan) +
- " != " + str(res_match.dl_vlan))
- parent.assertEqual(req_match.dl_vlan_pcp, res_match.dl_vlan_pcp,
- 'Match failed: dl_vlan_pcp: ' +
- str(req_match.dl_vlan_pcp) + " != " +
- str(res_match.dl_vlan_pcp))
- parent.assertEqual(req_match.dl_type, res_match.dl_type,
- 'Match failed: dl_type: ' + str(req_match.dl_type) +
- " != " + str(res_match.dl_type))
+ parent.assertEqual(str(req_match.eth_src), str(res_match.eth_src),
+ 'Match failed: eth_src: ' + str(req_match.eth_src) +
+ " != " + str(res_match.eth_src))
+ parent.assertEqual(str(req_match.eth_dst), str(res_match.eth_dst),
+ 'Match failed: eth_dst: ' + str(req_match.eth_dst) +
+ " != " + str(res_match.eth_dst))
+ parent.assertEqual(req_match.vlan_vid, res_match.vlan_vid,
+ 'Match failed: vlan_vid: ' + str(req_match.vlan_vid) +
+ " != " + str(res_match.vlan_vid))
+ parent.assertEqual(req_match.vlan_pcp, res_match.vlan_pcp,
+ 'Match failed: vlan_pcp: ' +
+ str(req_match.vlan_pcp) + " != " +
+ str(res_match.vlan_pcp))
+ parent.assertEqual(req_match.eth_type, res_match.eth_type,
+ 'Match failed: eth_type: ' + str(req_match.eth_type) +
+ " != " + str(res_match.eth_type))
- if (not(req_match.wildcards & of10.cstruct.OFPFW_DL_TYPE)
- and (req_match.dl_type == IP_ETHERTYPE)):
- parent.assertEqual(req_match.nw_tos, res_match.nw_tos,
- 'Match failed: nw_tos: ' + str(req_match.nw_tos) +
- " != " + str(res_match.nw_tos))
- parent.assertEqual(req_match.nw_proto, res_match.nw_proto,
- 'Match failed: nw_proto: ' + str(req_match.nw_proto) +
- " != " + str(res_match.nw_proto))
- parent.assertEqual(req_match.nw_src, res_match.nw_src,
- 'Match failed: nw_src: ' + str(req_match.nw_src) +
- " != " + str(res_match.nw_src))
- parent.assertEqual(req_match.nw_dst, res_match.nw_dst,
- 'Match failed: nw_dst: ' + str(req_match.nw_dst) +
- " != " + str(res_match.nw_dst))
+ if (not(req_match.wildcards & ofp.OFPFW_DL_TYPE)
+ and (req_match.eth_type == IP_ETHERTYPE)):
+ parent.assertEqual(req_match.ip_dscp, res_match.ip_dscp,
+ 'Match failed: ip_dscp: ' + str(req_match.ip_dscp) +
+ " != " + str(res_match.ip_dscp))
+ parent.assertEqual(req_match.ip_proto, res_match.ip_proto,
+ 'Match failed: ip_proto: ' + str(req_match.ip_proto) +
+ " != " + str(res_match.ip_proto))
+ parent.assertEqual(req_match.ipv4_src, res_match.ipv4_src,
+ 'Match failed: ipv4_src: ' + str(req_match.ipv4_src) +
+ " != " + str(res_match.ipv4_src))
+ parent.assertEqual(req_match.ipv4_dst, res_match.ipv4_dst,
+ 'Match failed: ipv4_dst: ' + str(req_match.ipv4_dst) +
+ " != " + str(res_match.ipv4_dst))
- if (not(req_match.wildcards & of10.cstruct.OFPFW_NW_PROTO)
- and ((req_match.nw_proto == TCP_PROTOCOL)
- or (req_match.nw_proto == UDP_PROTOCOL))):
- parent.assertEqual(req_match.tp_src, res_match.tp_src,
- 'Match failed: tp_src: ' +
- str(req_match.tp_src) +
- " != " + str(res_match.tp_src))
- parent.assertEqual(req_match.tp_dst, res_match.tp_dst,
- 'Match failed: tp_dst: ' +
- str(req_match.tp_dst) +
- " != " + str(res_match.tp_dst))
+ if (not(req_match.wildcards & ofp.OFPFW_NW_PROTO)
+ and ((req_match.ip_proto == TCP_PROTOCOL)
+ or (req_match.ip_proto == UDP_PROTOCOL))):
+ parent.assertEqual(req_match.tcp_src, res_match.tcp_src,
+ 'Match failed: tcp_src: ' +
+ str(req_match.tcp_src) +
+ " != " + str(res_match.tcp_src))
+ parent.assertEqual(req_match.tcp_dst, res_match.tcp_dst,
+ 'Match failed: tcp_dst: ' +
+ str(req_match.tcp_dst) +
+ " != " + str(res_match.tcp_dst))
def packet_to_flow_match(parent, packet):
- match = of10.parse.packet_to_flow_match(packet)
+ match = oftest.parse.packet_to_flow_match(packet)
match.wildcards |= required_wildcards(parent)
return match
@@ -560,12 +557,12 @@
@param in_band if True, do not wildcard ingress port
@param egr_ports None (drop), single port or list of ports
"""
- match = of10.parse.packet_to_flow_match(pkt)
+ match = oftest.parse.packet_to_flow_match(pkt)
parent.assertTrue(match is not None, "Flow match from pkt failed")
if wildcards is None:
wildcards = required_wildcards(parent)
if in_band:
- wildcards &= ~of10.cstruct.OFPFW_IN_PORT
+ wildcards &= ~ofp.OFPFW_IN_PORT
match.wildcards = wildcards
match.in_port = ing_port
@@ -574,31 +571,31 @@
else:
egr_port_list = [egr_ports]
- request = of10.message.flow_mod()
+ request = ofp.message.flow_add()
request.match = match
request.buffer_id = 0xffffffff
if check_expire:
- request.flags |= of10.cstruct.OFPFF_SEND_FLOW_REM
+ request.flags |= ofp.OFPFF_SEND_FLOW_REM
request.hard_timeout = 1
if action_list is not None:
for act in action_list:
logging.debug("Adding action " + act.show())
- request.actions.add(act)
+ request.actions.append(act)
# Set up output/enqueue action if directed
if egr_queue is not None:
parent.assertTrue(egr_ports is not None, "Egress port not set")
- act = of10.action.action_enqueue()
+ act = ofp.action.enqueue()
for egr_port in egr_port_list:
act.port = egr_port
act.queue_id = egr_queue
- request.actions.add(act)
+ request.actions.append(act)
elif egr_ports is not None:
for egr_port in egr_port_list:
- act = of10.action.action_output()
+ act = ofp.action.output()
act.port = egr_port
- request.actions.add(act)
+ request.actions.append(act)
logging.debug(request.show())
@@ -627,7 +624,7 @@
do_barrier(parent.controller)
def flow_match_test_port_pair(parent, ing_port, egr_ports, wildcards=None,
- dl_vlan=-1, pkt=None, exp_pkt=None,
+ vlan_vid=-1, pkt=None, exp_pkt=None,
action_list=None):
"""
Flow match test on single TCP packet
@@ -641,9 +638,9 @@
wildcards = required_wildcards(parent)
logging.info("Pkt match test: " + str(ing_port) + " to " +
str(egr_ports))
- logging.debug(" WC: " + hex(wildcards) + " vlan: " + str(dl_vlan))
+ logging.debug(" WC: " + hex(wildcards) + " vlan: " + str(vlan_vid))
if pkt is None:
- pkt = simple_tcp_packet(dl_vlan_enable=(dl_vlan >= 0), dl_vlan=dl_vlan)
+ pkt = simple_tcp_packet(dl_vlan_enable=(vlan_vid >= 0), vlan_vid=vlan_vid)
request = flow_msg_create(parent, pkt, ing_port=ing_port,
wildcards=wildcards, egr_ports=egr_ports,
@@ -660,7 +657,7 @@
receive_pkt_verify(parent, egr_ports, exp_pkt, ing_port)
def flow_match_test_pktout(parent, ing_port, egr_ports,
- dl_vlan=-1, pkt=None, exp_pkt=None,
+ vlan_vid=-1, pkt=None, exp_pkt=None,
action_list=None):
"""
Packet-out test on single TCP packet
@@ -672,21 +669,21 @@
"""
if pkt is None:
- pkt = simple_tcp_packet(dl_vlan_enable=(dl_vlan >= 0), dl_vlan=dl_vlan)
+ pkt = simple_tcp_packet(dl_vlan_enable=(vlan_vid >= 0), vlan_vid=vlan_vid)
- msg = of10.message.packet_out()
+ msg = ofp.message.packet_out()
msg.in_port = ing_port
msg.data = str(pkt)
if action_list is not None:
for act in action_list:
- msg.actions.add(act)
+ msg.actions.append(act)
# Set up output action
if egr_ports is not None:
for egr_port in egr_ports:
- act = of10.action.action_output()
+ act = ofp.action.output()
act.port = egr_port
- msg.actions.add(act)
+ msg.actions.append(act)
logging.debug(msg.show())
parent.controller.message_send(msg)
@@ -719,7 +716,7 @@
logging.debug("Could not generate enough egress ports for test")
return []
-def flow_match_test(parent, port_map, wildcards=None, dl_vlan=-1, pkt=None,
+def flow_match_test(parent, port_map, wildcards=None, vlan_vid=-1, pkt=None,
exp_pkt=None, action_list=None,
max_test=0, egr_count=1, ing_port=False):
"""
@@ -730,7 +727,7 @@
and logging
@param pkt If not None, use this packet for ingress
@param wildcards For flow match entry
- @param dl_vlan If not -1, and pkt is None, create a pkt w/ VLAN tag
+ @param vlan_vid If not -1, and pkt is None, create a pkt w/ VLAN tag
@param exp_pkt If not None, use this as the expected output pkt; els use pkt
@param action_list Additional actions to add to flow mod
@param egr_count Number of egress ports; -1 means get from config w/ dflt 2
@@ -750,12 +747,12 @@
egr_ports = get_egr_list(parent, of_ports, egr_count,
exclude_list=[ingress_port])
if ing_port:
- egr_ports.append(of10.cstruct.OFPP_IN_PORT)
+ egr_ports.append(ofp.OFPP_IN_PORT)
if len(egr_ports) == 0:
parent.assertTrue(0, "Failed to generate egress port list")
flow_match_test_port_pair(parent, ingress_port, egr_ports,
- wildcards=wildcards, dl_vlan=dl_vlan,
+ wildcards=wildcards, vlan_vid=vlan_vid,
pkt=pkt, exp_pkt=exp_pkt,
action_list=action_list)
test_count += 1
@@ -770,9 +767,9 @@
egr_ports = get_egr_list(parent, of_ports, egr_count,
exclude_list=[ingress_port])
if ing_port:
- egr_ports.append(of10.cstruct.OFPP_IN_PORT)
+ egr_ports.append(ofp.OFPP_IN_PORT)
flow_match_test_pktout(parent, ingress_port, egr_ports,
- dl_vlan=dl_vlan,
+ vlan_vid=vlan_vid,
pkt=pkt, exp_pkt=exp_pkt,
action_list=action_list)
@@ -816,43 +813,43 @@
if field_to_mod in ['pktlen']:
return None
- if field_to_mod == 'dl_dst':
- act = of10.action.action_set_dl_dst()
- act.dl_addr = of10.parse.parse_mac(mod_field_vals['dl_dst'])
- elif field_to_mod == 'dl_src':
- act = of10.action.action_set_dl_src()
- act.dl_addr = of10.parse.parse_mac(mod_field_vals['dl_src'])
+ if field_to_mod == 'eth_dst':
+ act = ofp.action.set_dl_dst()
+ act.dl_addr = oftest.parse.parse_mac(mod_field_vals['eth_dst'])
+ elif field_to_mod == 'eth_src':
+ act = ofp.action.set_dl_src()
+ act.dl_addr = oftest.parse.parse_mac(mod_field_vals['eth_src'])
elif field_to_mod == 'dl_vlan_enable':
if not mod_field_vals['dl_vlan_enable']: # Strip VLAN tag
- act = of10.action.action_strip_vlan()
- # Add VLAN tag is handled by dl_vlan field
+ act = ofp.action.strip_vlan()
+ # Add VLAN tag is handled by vlan_vid field
# Will return None in this case
- elif field_to_mod == 'dl_vlan':
- act = of10.action.action_set_vlan_vid()
- act.vlan_vid = mod_field_vals['dl_vlan']
- elif field_to_mod == 'dl_vlan_pcp':
- act = of10.action.action_set_vlan_pcp()
- act.vlan_pcp = mod_field_vals['dl_vlan_pcp']
+ elif field_to_mod == 'vlan_vid':
+ act = ofp.action.set_vlan_vid()
+ act.vlan_vid = mod_field_vals['vlan_vid']
+ elif field_to_mod == 'vlan_pcp':
+ act = ofp.action.set_vlan_pcp()
+ act.vlan_pcp = mod_field_vals['vlan_pcp']
elif field_to_mod == 'ip_src':
- act = of10.action.action_set_nw_src()
- act.nw_addr = of10.parse.parse_ip(mod_field_vals['ip_src'])
+ act = ofp.action.set_nw_src()
+ act.nw_addr = oftest.parse.parse_ip(mod_field_vals['ip_src'])
elif field_to_mod == 'ip_dst':
- act = of10.action.action_set_nw_dst()
- act.nw_addr = of10.parse.parse_ip(mod_field_vals['ip_dst'])
+ act = ofp.action.set_nw_dst()
+ act.nw_addr = oftest.parse.parse_ip(mod_field_vals['ip_dst'])
elif field_to_mod == 'ip_tos':
- act = of10.action.action_set_nw_tos()
+ act = ofp.action.set_nw_tos()
act.nw_tos = mod_field_vals['ip_tos']
elif field_to_mod == 'tcp_sport':
- act = of10.action.action_set_tp_src()
+ act = ofp.action.set_tp_src()
act.tp_port = mod_field_vals['tcp_sport']
elif field_to_mod == 'tcp_dport':
- act = of10.action.action_set_tp_dst()
+ act = ofp.action.set_tp_dst()
act.tp_port = mod_field_vals['tcp_dport']
elif field_to_mod == 'udp_sport':
- act = of10.action.action_set_tp_src()
+ act = ofp.action.set_tp_src()
act.tp_port = mod_field_vals['udp_sport']
elif field_to_mod == 'udp_dport':
- act = of10.action.action_set_tp_dst()
+ act = ofp.action.set_tp_dst()
act.tp_port = mod_field_vals['udp_dport']
else:
parent.assertTrue(0, "Unknown field to modify: " + str(field_to_mod))
@@ -878,11 +875,11 @@
base_pkt_params = {}
base_pkt_params['pktlen'] = 100
- base_pkt_params['dl_dst'] = '00:DE:F0:12:34:56'
- base_pkt_params['dl_src'] = '00:23:45:67:89:AB'
+ base_pkt_params['eth_dst'] = '00:DE:F0:12:34:56'
+ base_pkt_params['eth_src'] = '00:23:45:67:89:AB'
base_pkt_params['dl_vlan_enable'] = False
- base_pkt_params['dl_vlan'] = 2
- base_pkt_params['dl_vlan_pcp'] = 0
+ base_pkt_params['vlan_vid'] = 2
+ base_pkt_params['vlan_pcp'] = 0
base_pkt_params['ip_src'] = '192.168.0.1'
base_pkt_params['ip_dst'] = '192.168.0.2'
base_pkt_params['ip_tos'] = 0
@@ -897,11 +894,11 @@
mod_pkt_params = {}
mod_pkt_params['pktlen'] = 100
- mod_pkt_params['dl_dst'] = '00:21:0F:ED:CB:A9'
- mod_pkt_params['dl_src'] = '00:ED:CB:A9:87:65'
+ mod_pkt_params['eth_dst'] = '00:21:0F:ED:CB:A9'
+ mod_pkt_params['eth_src'] = '00:ED:CB:A9:87:65'
mod_pkt_params['dl_vlan_enable'] = False
- mod_pkt_params['dl_vlan'] = 3
- mod_pkt_params['dl_vlan_pcp'] = 7
+ mod_pkt_params['vlan_vid'] = 3
+ mod_pkt_params['vlan_pcp'] = 7
mod_pkt_params['ip_src'] = '10.20.30.40'
mod_pkt_params['ip_dst'] = '50.60.70.80'
mod_pkt_params['ip_tos'] = 0xf0
@@ -926,9 +923,9 @@
if vid:
base_pkt_params['dl_vlan_enable'] = True
- base_pkt_params['dl_vlan'] = vid
- if 'dl_vlan' in mod_fields:
- mod_pkt_params['dl_vlan'] = vid + 1
+ base_pkt_params['vlan_vid'] = vid
+ if 'vlan_vid' in mod_fields:
+ mod_pkt_params['vlan_vid'] = vid + 1
if add_vlan:
base_pkt_params['dl_vlan_enable'] = False
@@ -936,8 +933,8 @@
mod_pkt_params['pktlen'] = base_pkt_params['pktlen'] + 4
mod_fields.append('pktlen')
mod_fields.append('dl_vlan_enable')
- if 'dl_vlan' not in mod_fields:
- mod_fields.append('dl_vlan')
+ if 'vlan_vid' not in mod_fields:
+ mod_fields.append('vlan_vid')
elif strip_vlan:
base_pkt_params['dl_vlan_enable'] = True
mod_pkt_params['dl_vlan_enable'] = False
@@ -969,10 +966,10 @@
# Generate a simple "drop" flow mod
# If in_band is true, then only drop from first test port
def flow_mod_gen(port_map, in_band):
- request = of10.message.flow_mod()
- request.match.wildcards = of10.cstruct.OFPFW_ALL
+ request = ofp.message.flow_add()
+ request.match.wildcards = ofp.OFPFW_ALL
if in_band:
- request.match.wildcards = of10.cstruct.OFPFW_ALL - of10.cstruct.OFPFW_IN_PORT
+ request.match.wildcards = ofp.OFPFW_ALL - ofp.OFPFW_IN_PORT
for of_port, ifname in port_map.items(): # Grab first port
break
request.match.in_port = of_port
@@ -1002,28 +999,28 @@
@returns dict with keys flows, packets, bytes, active (flows),
lookups, matched
"""
- stat_req = of10.message.aggregate_stats_request()
- stat_req.match = of10.cstruct.ofp_match()
- stat_req.match.wildcards = of10.cstruct.OFPFW_ALL
+ stat_req = ofp.message.aggregate_stats_request()
+ stat_req.match = ofp.match()
+ stat_req.match.wildcards = ofp.OFPFW_ALL
stat_req.table_id = 0xff
- stat_req.out_port = of10.cstruct.OFPP_NONE
+ stat_req.out_port = ofp.OFPP_NONE
rv = {}
(reply, pkt) = parent.controller.transact(stat_req)
- parent.assertTrue(len(reply.stats) == 1, "Did not receive flow stats reply")
+ parent.assertTrue(len(reply.entries) == 1, "Did not receive flow stats reply")
- for obj in reply.stats:
+ for obj in reply.entries:
(rv["flows"], rv["packets"], rv["bytes"]) = (obj.flow_count,
obj.packet_count, obj.byte_count)
break
- request = of10.message.table_stats_request()
+ request = ofp.message.table_stats_request()
(reply , pkt) = parent.controller.transact(request)
(rv["active"], rv["lookups"], rv["matched"]) = (0,0,0)
- for obj in reply.stats:
+ for obj in reply.entries:
rv["active"] += obj.active_count
rv["lookups"] += obj.lookup_count
rv["matched"] += obj.matched_count
@@ -1147,18 +1144,18 @@
stats = []
reply, _ = test.controller.transact(req)
test.assertTrue(reply is not None, "No response to stats request")
- stats.extend(reply.stats)
- while reply.flags & of10.OFPSF_REPLY_MORE != 0:
- reply, pkt = self.controller.poll(exp_msg=of10.OFPT_STATS_REPLY)
+ stats.extend(reply.entries)
+ while reply.flags & ofp.OFPSF_REPLY_MORE != 0:
+ reply, pkt = self.controller.poll(exp_msg=ofp.OFPT_STATS_REPLY)
test.assertTrue(reply is not None, "No response to stats request")
- stats.extend(reply.stats)
+ stats.extend(reply.entries)
return stats
-def get_flow_stats(test, match, table_id=0xff, out_port=of10.cstruct.OFPP_NONE):
+def get_flow_stats(test, match, table_id=0xff, out_port=ofp.OFPP_NONE):
"""
Retrieve a list of flow stats entries.
"""
- req = of10.message.flow_stats_request(match=match,
+ req = ofp.message.flow_stats_request(match=match,
table_id=table_id,
out_port=out_port)
return get_stats(test, req)
@@ -1167,18 +1164,18 @@
"""
Retrieve a list of port stats entries.
"""
- req = of10.message.port_stats_request(port_no=port_no)
+ req = ofp.message.port_stats_request(port_no=port_no)
return get_stats(test, req)
def get_queue_stats(test, port_no, queue_id):
"""
Retrieve a list of queue stats entries.
"""
- req = of10.message.queue_stats_request(port_no=port_no, queue_id=queue_id)
+ req = ofp.message.queue_stats_request(port_no=port_no, queue_id=queue_id)
return get_stats(test, req)
def verify_flow_stats(test, match, table_id=0xff,
- out_port=of10.cstruct.OFPP_NONE,
+ out_port=ofp.OFPP_NONE,
initial=[],
pkts=None, bytes=None):
"""
diff --git a/tests/FuncUtils.py b/tests/FuncUtils.py
index cbbf87e..1aefae1 100644
--- a/tests/FuncUtils.py
+++ b/tests/FuncUtils.py
@@ -5,10 +5,8 @@
import random
import oftest.controller as controller
-import oftest.cstruct as ofp
-import oftest.message as message
+import ofp
import oftest.dataplane as dataplane
-import oftest.action as action
import oftest.parse as parse
import logging
import types
@@ -20,17 +18,16 @@
#################### Functions for various types of flow_mod ##########################################################################################
def match_send_flowadd(self, match, priority, port):
- msg = message.flow_mod()
+ msg = ofp.message.flow_add()
msg.out_port = ofp.OFPP_NONE
- msg.command = ofp.OFPFC_ADD
# msg.cookie = random.randint(0,9007199254740992)
msg.buffer_id = 0xffffffff
msg.match = match
if priority != None :
msg.priority = priority
- act = action.action_output()
+ act = ofp.action.output()
act.port = port
- msg.actions.add(act)
+ msg.actions.append(act)
self.controller.message_send(msg)
do_barrier(self.controller)
@@ -42,7 +39,7 @@
match = parse.packet_to_flow_match(pkt_exactflow)
self.assertTrue(match is not None, "Could not generate flow match from pkt")
match.in_port = of_ports[0]
- #match.nw_src = 1
+ #match.ipv4_src = 1
match.wildcards=0
match_send_flowadd(self, match, priority, of_ports[1])
return (pkt_exactflow,match)
@@ -55,7 +52,7 @@
match = parse.packet_to_flow_match(pkt_exactflow)
self.assertTrue(match is not None, "Could not generate flow match from pkt")
match.in_port = of_ports[0]
- #match.nw_src = 1
+ #match.ipv4_src = 1
match.wildcards=0
match_send_flowadd(self, match, priority, of_ports[2])
return (pkt_exactflow,match)
@@ -69,7 +66,7 @@
match1 = parse.packet_to_flow_match(pkt_wildcardsrc)
self.assertTrue(match1 is not None, "Could not generate flow match from pkt")
match1.in_port = of_ports[0]
- #match1.nw_src = 1
+ #match1.ipv4_src = 1
match1.wildcards = ofp.OFPFW_DL_SRC
match_send_flowadd(self, match1, priority, of_ports[1])
return (pkt_wildcardsrc,match1)
@@ -78,7 +75,7 @@
#Generate Match_Ethernet_SrC_Address flow
#Create a simple tcp packet and generate match on ethernet src address flow
- pkt_MatchSrc = simple_eth_packet(dl_src='00:01:01:01:01:01')
+ pkt_MatchSrc = simple_eth_packet(eth_src='00:01:01:01:01:01')
match = parse.packet_to_flow_match(pkt_MatchSrc)
self.assertTrue(match is not None, "Could not generate flow match from pkt")
match.wildcards = ofp.OFPFW_ALL ^ofp.OFPFW_DL_SRC
@@ -89,7 +86,7 @@
#Generate Match_Ethernet_Dst_Address flow
#Create a simple tcp packet and generate match on ethernet dst address flow
- pkt_matchdst = simple_eth_packet(dl_dst='00:01:01:01:01:01')
+ pkt_matchdst = simple_eth_packet(eth_dst='00:01:01:01:01:01')
match = parse.packet_to_flow_match(pkt_matchdst)
self.assertTrue(match is not None, "Could not generate flow match from pkt")
@@ -138,7 +135,7 @@
#Generate Match_Vlan_Id
#Create a simple tcp packet and generate match on ethernet dst address flow
- pkt_matchvlanid = simple_tcp_packet(dl_vlan_enable=True,dl_vlan=1)
+ pkt_matchvlanid = simple_tcp_packet(dl_vlan_enable=True,vlan_vid=1)
match = parse.packet_to_flow_match(pkt_matchvlanid)
self.assertTrue(match is not None, "Could not generate flow match from pkt")
@@ -150,7 +147,7 @@
#Generate Match_Vlan_Priority
#Create a simple tcp packet and generate match on ethernet dst address flow
- pkt_matchvlanpcp = simple_tcp_packet(dl_vlan_enable=True,dl_vlan=1,dl_vlan_pcp=5)
+ pkt_matchvlanpcp = simple_tcp_packet(dl_vlan_enable=True,vlan_vid=1,vlan_pcp=5)
match = parse.packet_to_flow_match(pkt_matchvlanpcp)
self.assertTrue(match is not None, "Could not generate flow match from pkt")
@@ -163,7 +160,7 @@
#Generate Match_Mul_L2 flow
#Create a simple eth packet and generate match on ethernet protocol flow
- pkt_mulL2 = simple_eth_packet(dl_type=0x88cc,dl_src='00:01:01:01:01:01',dl_dst='00:01:01:01:01:02')
+ pkt_mulL2 = simple_eth_packet(eth_type=0x88cc,eth_src='00:01:01:01:01:01',eth_dst='00:01:01:01:01:02')
match = parse.packet_to_flow_match(pkt_mulL2)
self.assertTrue(match is not None, "Could not generate flow match from pkt")
@@ -310,7 +307,7 @@
#Generate a Match_Ethernet_Type flow
#Create a simple tcp packet and generate match on ethernet type flow
- pkt_matchtype = simple_eth_packet(dl_type=0x88cc)
+ pkt_matchtype = simple_eth_packet(eth_type=0x88cc)
match = parse.packet_to_flow_match(pkt_matchtype)
self.assertTrue(match is not None, "Could not generate flow match from pkt")
@@ -325,14 +322,13 @@
# Strict Modify the flow Action
#Create a flow_mod message , command MODIFY_STRICT
- msg5 = message.flow_mod()
+ msg5 = ofp.message.flow_modify_strict()
msg5.match = match
msg5.cookie = random.randint(0,9007199254740992)
- msg5.command = ofp.OFPFC_MODIFY_STRICT
msg5.buffer_id = 0xffffffff
- act5 = action.action_output()
+ act5 = ofp.action.output()
act5.port = egress_port
- msg5.actions.add(act5)
+ msg5.actions.append(act5)
if priority != None :
msg5.priority = priority
@@ -345,16 +341,15 @@
# Modify the flow action
#Create a flow_mod message , command MODIFY
- msg8 = message.flow_mod()
+ msg8 = ofp.message.flow_modify()
msg8.match = match
msg8.cookie = random.randint(0,9007199254740992)
- msg8.command = ofp.OFPFC_MODIFY
#out_port will be ignored for flow adds and flow modify (here for test-case Add_Modify_With_Outport)
msg8.out_port = of_ports[3]
msg8.buffer_id = 0xffffffff
- act8 = action.action_output()
+ act8 = ofp.action.output()
act8.port = of_ports[2]
- msg8.actions.add(act8)
+ msg8.actions.append(act8)
if priority != None :
msg8.priority = priority
@@ -373,13 +368,13 @@
"Could not generate flow match from pkt")
match.in_port = ingress_port
- request = message.flow_mod()
+ request = ofp.message.flow_add()
request.match = match
request.buffer_id = 0xffffffff
- act = action.action_enqueue()
+ act = ofp.action.enqueue()
act.port = egress_port
act.queue_id = egress_queue_id
- request.actions.add(act)
+ request.actions.append(act)
logging.info("Inserting flow")
self.controller.message_send(request)
@@ -391,7 +386,7 @@
def get_flowstats(self,match):
# Generate flow_stats request
- stat_req = message.flow_stats_request()
+ stat_req = ofp.message.flow_stats_request()
stat_req.match = match
stat_req.table_id = 0xff
stat_req.out_port = ofp.OFPP_NONE
@@ -405,7 +400,7 @@
def get_portstats(self,port_num):
# Return all the port counters in the form a tuple
- port_stats_req = message.port_stats_request()
+ port_stats_req = ofp.message.port_stats_request()
port_stats_req.port_no = port_num
response,pkt = self.controller.transact(port_stats_req)
self.assertTrue(response is not None,"No response received for port stats request")
@@ -424,7 +419,7 @@
tx_err=0
- for obj in response.stats:
+ for obj in response.entries:
rx_pkts += obj.rx_packets
tx_pkts += obj.tx_packets
rx_byts += obj.rx_bytes
@@ -443,7 +438,7 @@
def get_queuestats(self,port_num,queue_id):
#Generate Queue Stats request
- request = message.queue_stats_request()
+ request = ofp.message.queue_stats_request()
request.port_no = port_num
request.queue_id = queue_id
(queue_stats, p) = self.controller.transact(request)
@@ -454,7 +449,7 @@
def get_tablestats(self):
# Send Table_Stats request (retrieve current table counters )
- stat_req = message.table_stats_request()
+ stat_req = ofp.message.table_stats_request()
response, pkt = self.controller.transact(stat_req,
timeout=5)
self.assertTrue(response is not None,
@@ -463,7 +458,7 @@
current_matched = 0
current_active = 0
- for obj in response.stats:
+ for obj in response.entries:
current_lookedup += obj.lookup_count
current_matched += obj.matched_count
current_active += obj.active_count
@@ -474,7 +469,7 @@
def verify_tablestats(self,expect_lookup=None,expect_match=None,expect_active=None):
- stat_req = message.table_stats_request()
+ stat_req = ofp.message.table_stats_request()
for i in range(0,100):
@@ -488,7 +483,7 @@
matched = 0
active = 0
- for item in response.stats:
+ for item in response.entries:
lookedup += item.lookup_count
matched += item.matched_count
active += item.active_count
@@ -518,9 +513,8 @@
# Issue Strict Delete
#Create flow_mod message, command DELETE_STRICT
- msg4 = message.flow_mod()
+ msg4 = ofp.message.flow_delete_strict()
msg4.out_port = ofp.OFPP_NONE
- msg4.command = ofp.OFPFC_DELETE_STRICT
msg4.buffer_id = 0xffffffff
msg4.match = match
@@ -535,9 +529,8 @@
# Issue Non_Strict Delete
#Create flow_mod message, command DELETE
- msg6 = message.flow_mod()
+ msg6 = ofp.message.flow_delete()
msg6.out_port = ofp.OFPP_NONE
- msg6.command = ofp.OFPFC_DELETE
msg6.buffer_id = 0xffffffff
msg6.match = match
@@ -574,7 +567,7 @@
cache_supported_actions = None
if cache_supported_actions is None or not use_cache:
- request = message.features_request()
+ request = ofp.message.features_request()
(reply, pkt) = parent.controller.transact(request)
parent.assertTrue(reply is not None, "Did not get response to ftr req")
cache_supported_actions = reply.actions
diff --git a/tests/actions.py b/tests/actions.py
index bacb67c..494d941 100644
--- a/tests/actions.py
+++ b/tests/actions.py
@@ -14,10 +14,8 @@
from oftest import config
import oftest.controller as controller
-import oftest.cstruct as ofp
-import oftest.message as message
+import ofp
import oftest.dataplane as dataplane
-import oftest.action as action
import oftest.parse as parse
import oftest.base_tests as base_tests
@@ -51,9 +49,8 @@
match.wildcards=ofp.OFPFW_ALL
match.in_port = of_ports[0]
- msg = message.flow_mod()
+ msg = ofp.message.flow_add()
msg.out_port = ofp.OFPP_NONE
- msg.command = ofp.OFPFC_ADD
msg.buffer_id = 0xffffffff
msg.match = match
self.controller.message_send(msg)
@@ -87,10 +84,10 @@
logging.info("Expecting Features Reply with supported actions")
# Sending Features_Request
- request = message.features_request()
+ request = ofp.message.features_request()
(reply, pkt) = self.controller.transact(request)
self.assertTrue(reply is not None, "Failed to get any reply")
- self.assertEqual(reply.header.type, ofp.OFPT_FEATURES_REPLY,'Response is not Features_reply')
+ self.assertEqual(reply.type, ofp.OFPT_FEATURES_REPLY,'Response is not Features_reply')
supported_actions =[]
if(reply.actions &1<<ofp.OFPAT_OUTPUT):
@@ -144,7 +141,7 @@
#Create a packet
pkt = simple_tcp_packet()
match = parse.packet_to_flow_match(pkt)
- act = action.action_output()
+ act = ofp.action.output()
#Delete all flows
delete_all_flows(self.controller)
@@ -152,11 +149,11 @@
match.in_port = ingress_port
#Create a flow mod with action.port = OFPP_ALL
- request = message.flow_mod()
+ request = ofp.message.flow_add()
request.match = match
request.match.wildcards = ofp.OFPFW_ALL&~ofp.OFPFW_IN_PORT
act.port = ofp.OFPP_ALL
- request.actions.add(act)
+ request.actions.append(act)
logging.info("Inserting flow")
self.controller.message_send(request)
@@ -195,7 +192,7 @@
#Create packet
pkt = simple_tcp_packet()
match = parse.packet_to_flow_match(pkt)
- act = action.action_output()
+ act = ofp.action.output()
for ingress_port in of_ports:
#Delete all flows
@@ -204,10 +201,10 @@
match.in_port = ingress_port
#Create a flow mod message
- request = message.flow_mod()
+ request = ofp.message.flow_add()
request.match = match
act.port = ofp.OFPP_CONTROLLER
- request.actions.add(act)
+ request.actions.append(act)
logging.info("Inserting flow")
self.controller.message_send(request)
@@ -247,7 +244,7 @@
#Clear switch state
pkt = simple_tcp_packet()
match = parse.packet_to_flow_match(pkt)
- act = action.action_output()
+ act = ofp.action.output()
for ingress_port in of_ports:
#Delete the flows
@@ -255,10 +252,10 @@
match.in_port = ingress_port
#Create flow mod message
- request = message.flow_mod()
+ request = ofp.message.flow_add()
request.match = match
act.port = ofp.OFPP_LOCAL
- request.actions.add(act)
+ request.actions.append(act)
logging.info("Inserting flow")
self.controller.message_send(request)
@@ -295,7 +292,7 @@
#Create a packet
pkt = simple_tcp_packet()
match = parse.packet_to_flow_match(pkt)
- act = action.action_output()
+ act = ofp.action.output()
#Delete all flows
delete_all_flows(self.controller)
@@ -303,11 +300,11 @@
match.in_port = ingress_port
#Create a flow mod with action.port = OFPP_ALL
- request = message.flow_mod()
+ request = ofp.message.flow_add()
request.match = match
request.match.wildcards = ofp.OFPFW_ALL&~ofp.OFPFW_IN_PORT
act.port = ofp.OFPP_FLOOD
- request.actions.add(act)
+ request.actions.append(act)
logging.info("Inserting flow")
self.controller.message_send(request)
@@ -345,7 +342,7 @@
#Create a packet
pkt = simple_tcp_packet()
match = parse.packet_to_flow_match(pkt)
- act = action.action_output()
+ act = ofp.action.output()
#Delete the flows
delete_all_flows(self.controller)
@@ -353,11 +350,11 @@
match.in_port = ingress_port
# Create a flow mod message
- request = message.flow_mod()
+ request = ofp.message.flow_add()
request.match = match
act.port = ofp.OFPP_IN_PORT
- request.actions.add(act)
+ request.actions.append(act)
logging.info("Inserting flow")
self.controller.message_send(request)
do_barrier(self.controller)
@@ -396,12 +393,12 @@
(pkt,match) = wildcard_all(self,of_ports)
#Create a packet out message
- pkt_out =message.packet_out();
+ pkt_out =ofp.message.packet_out();
pkt_out.data = str(pkt)
pkt_out.in_port = of_ports[0]
- act = action.action_output()
+ act = ofp.action.output()
act.port = ofp.OFPP_TABLE
- pkt_out.actions.add(act)
+ pkt_out.actions.append(act)
self.controller.message_send(pkt_out)
#Verifying packet out message recieved on the expected dataplane port.
@@ -441,8 +438,8 @@
len_w_vid = 104
pkt = simple_tcp_packet(pktlen=len_wo_vid)
exp_pkt = simple_tcp_packet(pktlen=len_w_vid, dl_vlan_enable=True,
- dl_vlan=new_vid,dl_vlan_pcp=0)
- vid_act = action.action_set_vlan_vid()
+ vlan_vid=new_vid,vlan_pcp=0)
+ vid_act = ofp.action.set_vlan_vid()
vid_act.vlan_vid = new_vid
#Insert flow with action -- set vid , Send packet matching the flow, Verify recieved packet is expected packet
@@ -477,9 +474,9 @@
#Create a tagged packet with old_vid to be sent, and expected packet with new_vid
old_vid = 2
new_vid = 3
- pkt = simple_tcp_packet(dl_vlan_enable=True, dl_vlan=old_vid)
- exp_pkt = simple_tcp_packet(dl_vlan_enable=True, dl_vlan=new_vid)
- vid_act = action.action_set_vlan_vid()
+ pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=old_vid)
+ exp_pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=new_vid)
+ vid_act = ofp.action.set_vlan_vid()
vid_act.vlan_vid = new_vid
#Insert flow with action -- set vid , Send packet matching the flow.Verify recieved packet is expected packet.
@@ -516,8 +513,8 @@
vlan_pcp = 1
pktlen = 64 if config["minsize"] < 64 else config["minsize"]
pkt = simple_tcp_packet(pktlen=pktlen)
- exp_pkt = simple_tcp_packet(dl_vlan_enable=True, dl_vlan=vlan_id,dl_vlan_pcp=vlan_pcp, pktlen=pktlen + 4)
- act = action.action_set_vlan_pcp()
+ exp_pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=vlan_id,vlan_pcp=vlan_pcp, pktlen=pktlen + 4)
+ act = ofp.action.set_vlan_pcp()
act.vlan_pcp = vlan_pcp
#Insert flow with action -- set vLAN priority, Send packet matching the flow, Verify recieved packet is expected packet
@@ -554,9 +551,9 @@
vid = 123
old_vlan_pcp = 2
new_vlan_pcp = 3
- pkt = simple_tcp_packet(dl_vlan_enable=True, dl_vlan=vid, dl_vlan_pcp=old_vlan_pcp)
- exp_pkt = simple_tcp_packet(dl_vlan_enable=True, dl_vlan=vid, dl_vlan_pcp=new_vlan_pcp)
- vid_act = action.action_set_vlan_pcp()
+ pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=vid, vlan_pcp=old_vlan_pcp)
+ exp_pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=vid, vlan_pcp=new_vlan_pcp)
+ vid_act = ofp.action.set_vlan_pcp()
vid_act.vlan_pcp = new_vlan_pcp
#Insert flow with action -- set vLAN priority, Send tagged packet matching the flow, Verify recieved packet is expected packet
@@ -589,8 +586,8 @@
skip_message_emit(self, "modify_l2_src test skipped")
return
- #Create packet to be sent and expected packet with dl_src set to specified value
- (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['dl_src'],
+ #Create packet to be sent and expected packet with eth_src set to specified value
+ (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['eth_src'],
check_test_params=True)
#Insert flow with action -- set src address, Send packet matching the flow, Verify recieved packet is expected packet
@@ -623,8 +620,8 @@
skip_message_emit(self, "modify_l2_dst test skipped")
return
- #Create packet to be sent and expected packet with dl_src set to specified value
- (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['dl_dst'],
+ #Create packet to be sent and expected packet with eth_src set to specified value
+ (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['eth_dst'],
check_test_params=True)
#Insert flow with action -- set dst address, Send packet matching the flow, Verify recieved packet is expected packet
@@ -656,7 +653,7 @@
skip_message_emit(self, "modify_l3_src test")
return
- #Create packet to be sent and expected packet with nw_src set to specified value
+ #Create packet to be sent and expected packet with ipv4_src set to specified value
(pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['ip_src'],
check_test_params=True)
@@ -689,7 +686,7 @@
skip_message_emit(self, "modify_l3_dst test skipped")
return
- #Create packet to be sent and expected packet with nw_dst set to specified value
+ #Create packet to be sent and expected packet with ipv4_dst set to specified value
(pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['ip_dst'],
check_test_params=True)
diff --git a/tests/basic.py b/tests/basic.py
index 54aea3a..66e0355 100644
--- a/tests/basic.py
+++ b/tests/basic.py
@@ -41,9 +41,9 @@
response, pkt = self.controller.transact(request)
self.assertTrue(response is not None,
"Did not get echo reply")
- self.assertEqual(response.header.type, ofp.OFPT_ECHO_REPLY,
+ self.assertEqual(response.type, ofp.OFPT_ECHO_REPLY,
'response is not echo_reply')
- self.assertEqual(request.header.xid, response.header.xid,
+ self.assertEqual(request.xid, response.xid,
'response xid != request xid')
self.assertEqual(len(response.data), 0, 'response data non-empty')
@@ -56,9 +56,9 @@
response, pkt = self.controller.transact(request)
self.assertTrue(response is not None,
"Did not get echo reply (with data)")
- self.assertEqual(response.header.type, ofp.OFPT_ECHO_REPLY,
+ self.assertEqual(response.type, ofp.OFPT_ECHO_REPLY,
'response is not echo_reply')
- self.assertEqual(request.header.xid, response.header.xid,
+ self.assertEqual(request.xid, response.xid,
'response xid != request xid')
self.assertEqual(request.data, response.data,
'response data does not match request')
@@ -84,7 +84,7 @@
for of_port in config["port_map"].keys():
for pkt, pt in [
(simple_tcp_packet(), "simple TCP packet"),
- (simple_tcp_packet(dl_vlan_enable=True,dl_vlan=vid,pktlen=108),
+ (simple_tcp_packet(dl_vlan_enable=True,vlan_vid=vid,pktlen=108),
"simple tagged TCP packet"),
(simple_eth_packet(), "simple Ethernet packet"),
(simple_eth_packet(pktlen=40), "tiny Ethernet packet")]:
@@ -133,7 +133,7 @@
of_ports = config["port_map"].keys()
d_port = of_ports[0]
- pkt = simple_eth_packet(dl_dst='ff:ff:ff:ff:ff:ff')
+ pkt = simple_eth_packet(eth_dst='ff:ff:ff:ff:ff:ff')
logging.info("BCast Leak Test, send to port %s" % d_port)
self.dataplane.send(d_port, str(pkt))
@@ -391,10 +391,12 @@
request = illegal_message.illegal_message_type()
reply, pkt = self.controller.transact(request)
+ logging.info(repr(pkt))
self.assertTrue(reply is not None, "Did not get response to bad req")
- self.assertTrue(reply.header.type == ofp.OFPT_ERROR,
+ self.assertTrue(reply.type == ofp.OFPT_ERROR,
"reply not an error message")
- self.assertTrue(reply.type == ofp.OFPET_BAD_REQUEST,
+ logging.info(reply.err_type)
+ self.assertTrue(reply.err_type == ofp.OFPET_BAD_REQUEST,
"reply error type is not bad request")
self.assertTrue(reply.code == ofp.OFPBRC_BAD_TYPE,
"reply error code is not bad type")
@@ -416,7 +418,7 @@
request = ofp.message.table_stats_request()
response, _ = self.controller.transact(request)
try:
- table_stats = [x for x in response.stats if x.table_id == table_id][0]
+ table_stats = [x for x in response.entries if x.table_id == table_id][0]
except IndexError:
raise AssertionError("table id %d not found" % table_id)
return table_stats.config
diff --git a/tests/bsn_ipmask.py b/tests/bsn_ipmask.py
index 8304958..8dd603a 100644
--- a/tests/bsn_ipmask.py
+++ b/tests/bsn_ipmask.py
@@ -6,8 +6,7 @@
from oftest import config
import oftest.controller as controller
-import oftest.cstruct as ofp
-import oftest.message as message
+import ofp
import oftest.base_tests as base_tests
from oftest.testutils import *
@@ -48,9 +47,7 @@
given wildcard index
"""
logging.info("Setting index %d to mask is %s" % (index, mask))
- m = message.vendor()
- m.vendor = 0x005c16c7
- m.data = struct.pack("!LBBBBL", 0, index, 0, 0, 0, mask)
+ m = ofp.message.bsn_set_ip_mask(index=index, mask=mask)
self.controller.message_send(m)
def bsn_get_ip_mask(self, index):
@@ -58,16 +55,11 @@
Use the BSN_GET_IP_MASK_REQUEST vendor command to get the current IP mask
for the given wildcard index
"""
- m = message.vendor()
- m.vendor = 0x005c16c7
- m.data = struct.pack( "!LBBBBL", 1, index, 0, 0, 0, 0 )
- self.controller.message_send(m)
- m, r = self.controller.poll(ofp.OFPT_VENDOR)
- self.assertEqual(m.vendor, 0x005c16c7, "Wrong vendor ID")
- x = struct.unpack("!LBBBBL", m.data)
- self.assertEqual(x[0], 2, "Wrong subtype")
- self.assertEqual(x[1], index, "Wrong index")
- return x[5]
+ request = ofp.message.bsn_get_ip_mask_request(index=index)
+ reply, _ = self.controller.transact(request)
+ self.assertTrue(isinstance(reply, ofp.message.bsn_get_ip_mask_reply), "Wrong reply type")
+ self.assertEqual(reply.index, index, "Wrong index")
+ return reply.mask
def runTest(self):
self.assertFalse(required_wildcards(self) & ofp.OFPFW_NW_DST_ALL,
diff --git a/tests/bsn_mirror.py b/tests/bsn_mirror.py
index 10c3f93..4e4343d 100644
--- a/tests/bsn_mirror.py
+++ b/tests/bsn_mirror.py
@@ -6,75 +6,11 @@
from oftest import config
import oftest.controller as controller
-import oftest.cstruct as ofp
-import oftest.message as message
-import oftest.action as action
-import oftest.action_list as action_list
+import ofp
import oftest.base_tests as base_tests
from oftest.testutils import *
-class bsn_action_mirror(action.action_vendor):
- def __init__(self):
- self.type = ofp.OFPAT_VENDOR
- self.len = 24
- self.vendor = 0x005c16c7
- self.subtype = 1
- self.dest_port = 0
- self.vlan_tag = 0
- self.copy_stage = 0
-
- def __assert(self):
- return (True, None)
-
- def pack(self, assertstruct=True):
- return struct.pack("!HHLLLLBBBB", self.type, self.len, self.vendor,
- self.subtype, self.dest_port, self.vlan_tag,
- self.copy_stage, 0, 0, 0)
-
- def unpack(self, binaryString):
- if len(binaryString) < self.len:
- raise Exception("too short")
- x = struct.unpack("!HHLLLLBBBB", binaryString[:self.len])
- if x[0] != self.type:
- raise Exception("wrong type")
- if x[1] != self.len:
- raise Exception("wrong length")
- if x[2] != self.vendor:
- raise Exception("wrong vendor")
- if x[3] != self.subtype:
- raise Exception("wrong subtype")
- self.dest_port = x[4]
- self.vlan_tag = x[5]
- self.copy_stage = x[6]
- return binaryString[self.len:]
-
- def __len__(self):
- return self.len
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- if self.type != other.type: return False
- if self.len != other.len: return False
- if self.vendor != other.vendor: return False
- if self.subtype != other.subtype: return False
- if self.dest_port != other.dest_port: return False
- if self.vlan_tag != other.vlan_tag: return False
- if self.copy_stage != other.copy_stage: return False
- return True
-
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def show(self, prefix=""):
- outstr = prefix + "action_vendor\n"
- for f in ["type", "len", "vendor", "subtype", "dest_port", "vlan_tag",
- "copy_stage"]:
- outstr += prefix + ("%s: %s\n" % (f, getattr(self, f)))
- return outstr
-
-action_list.action_object_map[ofp.OFPAT_VENDOR] = bsn_action_mirror
-
@nonstandard
class BSNMirrorAction(base_tests.SimpleDataPlane):
"""
@@ -87,9 +23,7 @@
Use the BSN_SET_MIRRORING vendor command to enable/disable
mirror action support
"""
- m = message.vendor()
- m.vendor = 0x005c16c7
- m.data = struct.pack("!LBBBB", 3, enabled, 0, 0, 0)
+ m = ofp.message.bsn_set_mirroring(report_mirror_ports=enabled)
self.controller.message_send(m)
def bsn_get_mirroring(self):
@@ -97,15 +31,10 @@
Use the BSN_GET_MIRRORING_REQUEST vendor command to get the
enabled/disabled state of mirror action support
"""
- m = message.vendor()
- m.vendor = 0x005c16c7
- m.data = struct.pack("!LBBBB", 4, 0, 0, 0, 0)
- self.controller.message_send(m)
- m, r = self.controller.poll(ofp.OFPT_VENDOR, 2)
- self.assertEqual(m.vendor, 0x005c16c7, "Wrong vendor ID")
- x = struct.unpack("!LBBBB", m.data)
- self.assertEqual(x[0], 5, "Wrong subtype")
- return x[1]
+ request = ofp.message.bsn_get_mirroring_request()
+ reply, _ = self.controller.transact(request)
+ self.assertTrue(isinstance(reply, ofp.message.bsn_get_mirroring_reply), "Unexpected reply type")
+ return reply.report_mirror_ports
def runTest(self):
mirror_ports = test_param_get("mirror_ports")
@@ -117,7 +46,7 @@
logging.info("Checking that mirror ports are not reported")
self.assertEqual(bool(self.bsn_get_mirroring()), False)
- m, r = self.controller.transact(message.features_request(), 2)
+ m, r = self.controller.transact(ofp.message.features_request(), 2)
p = dict([(pt.port_no, pt) for pt in m.ports])
self.assertFalse(mirror_ports[0] in p or mirror_ports[1] in p,
"Mirror port in features reply")
@@ -127,7 +56,7 @@
logging.info("Checking that mirror ports are reported")
self.assertEqual(bool(self.bsn_get_mirroring()), True)
- m, r = self.controller.transact(message.features_request(), 2)
+ m, r = self.controller.transact(ofp.message.features_request(), 2)
p = dict([(pt.port_no, pt) for pt in m.ports])
self.assertTrue(mirror_ports[0] in p and mirror_ports[1] in p,
"Mirror port not in features reply")
@@ -136,19 +65,19 @@
self.assertTrue(p[mirror_ports[1]].config & (1 << 31),
"Mirror port config flag not set in features reply")
- act1 = bsn_action_mirror()
+ act1 = ofp.action.bsn_mirror()
act1.dest_port = mirror_ports[0]
act1.copy_stage = 0
- act2 = bsn_action_mirror()
+ act2 = ofp.action.bsn_mirror()
act2.dest_port = mirror_ports[1]
act2.copy_stage = 0
- act3 = action.action_output()
+ act3 = ofp.action.output()
act3.port = ports[1]
- flow_mod = message.flow_mod()
+ flow_mod = ofp.message.flow_add()
flow_mod.match = match
- flow_mod.actions.add(act1)
- flow_mod.actions.add(act2)
- flow_mod.actions.add(act3)
+ flow_mod.actions.append(act1)
+ flow_mod.actions.append(act2)
+ flow_mod.actions.append(act3)
delete_all_flows(self.controller)
self.controller.message_send(flow_mod)
do_barrier(self.controller)
diff --git a/tests/bsn_shell.py b/tests/bsn_shell.py
index f4d9969..2ac2f08 100644
--- a/tests/bsn_shell.py
+++ b/tests/bsn_shell.py
@@ -6,8 +6,7 @@
from oftest import config
import oftest.controller as controller
-import oftest.cstruct as ofp
-import oftest.message as message
+import ofp
import oftest.base_tests as base_tests
from oftest.testutils import *
@@ -23,23 +22,17 @@
Use the BSN_SHELL_COMMAND vendor command to run the given command
and receive the output
"""
- m = message.vendor()
- m.vendor = 0x005c16c7
- m.data = struct.pack("!LL", 6, 0) + cmd
- rc = self.controller.message_send(m)
- self.assertNotEqual(rc, -1, "Error sending shell command")
+ m = ofp.message.bsn_shell_command(service=0, data=cmd)
+ self.controller.message_send(m)
out = ""
while True:
- m, r = self.controller.poll(ofp.OFPT_VENDOR, 60)
- self.assertEqual(m.vendor, 0x005c16c7, "Wrong vendor ID")
- subtype = struct.unpack("!L", m.data[:4])[0]
- if subtype == 7:
- out += m.data[4:]
- elif subtype == 8:
- status = struct.unpack("!LL", m.data)[1]
- return status, out
+ m, _ = self.controller.poll(ofp.OFPT_VENDOR, 60)
+ if isinstance(m, ofp.message.bsn_shell_output):
+ out += m.data
+ elif isinstance(m, ofp.message.bsn_shell_status):
+ return m.status, out
else:
- assert False, "Wrong subtype"
+ raise AssertionError("Unexpected message received")
def runTest(self):
status, out = self.bsn_shell_command("echo _one space_")
diff --git a/tests/caps.py b/tests/caps.py
index b87b0e2..7fceeaf 100644
--- a/tests/caps.py
+++ b/tests/caps.py
@@ -9,10 +9,8 @@
from oftest import config
import oftest.controller as controller
-import oftest.cstruct as ofp
-import oftest.message as message
+import ofp
import oftest.dataplane as dataplane
-import oftest.action as action
import oftest.parse as parse
import oftest.base_tests as base_tests
@@ -37,8 +35,8 @@
for port in of_ports:
break;
match.in_port = port
- match.nw_src = 1
- request = message.flow_mod()
+ match.ipv4_src = 1
+ request = ofp.message.flow_add()
count_check = 101 # fixme: better way to determine this.
if is_exact:
match.wildcards = 0
@@ -49,7 +47,7 @@
request.buffer_id = 0xffffffff # set to NONE
logging.info(request.show())
- tstats = message.table_stats_request()
+ tstats = ofp.message.table_stats_request()
try: # Determine the table index to check (or "all")
table_idx = config["caps_table_idx"]
except:
@@ -65,7 +63,7 @@
logging.info("Check every " + str(count_check) + " inserts")
while True:
- request.match.nw_src += 1
+ request.match.ipv4_src += 1
obj.controller.message_send(request)
flow_count += 1
if flow_count % count_check == 0:
@@ -75,10 +73,10 @@
logging.info(response.show())
if table_idx == -1: # Accumulate for all tables
active_flows = 0
- for stats in response.stats:
+ for stats in response.entries:
active_flows += stats.active_count
else: # Table index to use specified in config
- active_flows = response.stats[table_idx].active_count
+ active_flows = response.entries[table_idx].active_count
if active_flows != flow_count:
break
diff --git a/tests/counters.py b/tests/counters.py
index be6c979..77182b6 100644
--- a/tests/counters.py
+++ b/tests/counters.py
@@ -11,10 +11,8 @@
from oftest import config
import oftest.controller as controller
-import oftest.cstruct as ofp
-import oftest.message as message
+import ofp
import oftest.dataplane as dataplane
-import oftest.action as action
import oftest.parse as parse
import oftest.base_tests as base_tests
import time
@@ -26,7 +24,7 @@
def port_queues_get(self, queue_stats, port_num):
result = []
- for qs in queue_stats.stats:
+ for qs in queue_stats.entries:
if qs.port_no != port_num:
continue
result.append(qs.queue_id)
@@ -122,7 +120,7 @@
(pkt,match) = wildcard_all_except_ingress(self,of_ports)
#Create flow_stats request
- stat_req = message.flow_stats_request()
+ stat_req = ofp.message.flow_stats_request()
stat_req.match= match
stat_req.table_id = 0xff
stat_req.out_port = ofp.OFPP_NONE
@@ -133,9 +131,9 @@
response, pkt = self.controller.transact(stat_req)
self.assertTrue(response is not None,"No response to stats request")
- self.assertTrue(len(response.stats) == 1,"Did not receive flow stats reply")
+ self.assertTrue(len(response.entries) == 1,"Did not receive flow stats reply")
- stat = response.stats[0]
+ stat = response.entries[0]
logging.info("Duration of flow is %d s %d ns", stat.duration_sec, stat.duration_nsec)
self.assertTrue(stat.duration_sec == expected_duration, "Flow stats reply incorrect")
diff --git a/tests/cxn.py b/tests/cxn.py
index 34bacad..1a00f1f 100644
--- a/tests/cxn.py
+++ b/tests/cxn.py
@@ -12,10 +12,8 @@
from oftest import config
import oftest.controller as controller
-import oftest.cstruct as ofp
-import oftest.message as message
+import ofp
import oftest.dataplane as dataplane
-import oftest.action as action
from oftest.testutils import *
@@ -90,7 +88,7 @@
logging.info("TCP Connected " +
str(self.controllers[0].switch_addr))
logging.info("Sending hello")
- self.controllers[0].message_send(message.hello())
+ self.controllers[0].message_send(ofp.message.hello())
logging.info("Features request not sent, waiting for timeout")
@@ -163,7 +161,7 @@
if con.cstate == 0:
logging.info(condesc + "Sending hello to " +
str(con.switch_addr))
- con.message_send(message.hello())
+ con.message_send(ofp.message.hello())
con.cstate = 1
con.count = 0
elif con.cstate == 1:
@@ -185,7 +183,7 @@
elif con.cstate == 2:
logging.info(condesc + "Sending features request to " +
str(con.switch_addr))
- con.message_send(message.features_request())
+ con.message_send(ofp.message.features_request())
con.cstate = 3
con.count = 0
elif con.cstate == 3:
diff --git a/tests/default_drop.py b/tests/default_drop.py
index 7103f2a..574593f 100644
--- a/tests/default_drop.py
+++ b/tests/default_drop.py
@@ -6,10 +6,8 @@
from oftest import config
import oftest.controller as controller
-import oftest.cstruct as ofp
-import oftest.message as message
+import ofp
import oftest.dataplane as dataplane
-import oftest.action as action
import oftest.base_tests as base_tests
from oftest.testutils import *
diff --git a/tests/detailed_contr_sw_messages.py b/tests/detailed_contr_sw_messages.py
index 4ca6a6b..a32251d 100644
--- a/tests/detailed_contr_sw_messages.py
+++ b/tests/detailed_contr_sw_messages.py
@@ -11,10 +11,8 @@
from oftest import config
import oftest.controller as controller
-import oftest.cstruct as ofp
-import oftest.message as message
+import ofp
import oftest.dataplane as dataplane
-import oftest.action as action
import oftest.parse as parse
import oftest.base_tests as base_tests
@@ -54,16 +52,15 @@
match3.wildcards = ofp.OFPFW_ALL-ofp.OFPFW_IN_PORT
match3.in_port = of_ports[0]
- msg3 = message.flow_mod()
- msg3.command = ofp.OFPFC_ADD
+ msg3 = ofp.message.flow_add()
msg3.match = match3
msg3.flags |= ofp.OFPFF_CHECK_OVERLAP
msg3.cookie = random.randint(0,9007199254740992)
msg3.buffer_id = 0xffffffff
- act3 = action.action_output()
+ act3 = ofp.action.output()
act3.port = of_ports[1]
- msg3.actions.add(act3)
+ msg3.actions.append(act3)
self.controller.message_send(msg3)
do_barrier(self.controller)
@@ -75,7 +72,7 @@
timeout=5)
self.assertTrue(response is not None,
'Switch did not reply with error message')
- self.assertTrue(response.type==ofp.OFPET_FLOW_MOD_FAILED,
+ self.assertTrue(response.err_type==ofp.OFPET_FLOW_MOD_FAILED,
'Error message type is not flow mod failed ')
self.assertTrue(response.code==ofp.OFPFMFC_OVERLAP,
'Error Message code is not overlap')
@@ -175,17 +172,16 @@
match = parse.packet_to_flow_match(pkt)
match.in_port = of_ports[0]
- request = message.flow_mod()
+ request = ofp.message.flow_add()
request.match = match
- request.command = ofp.OFPFC_ADD
request.flags = request.flags|ofp.OFPFF_EMERG
request.hard_timeout =9
request.idle_timeout =9
- act = action.action_output()
+ act = ofp.action.output()
act.port = of_ports[1]
- request.actions.add(act)
+ request.actions.append(act)
logging.info("Inserting flow")
self.controller.message_send(request)
@@ -196,7 +192,7 @@
timeout=5)
self.assertTrue(response is not None,
'Switch did not reply with error message')
- self.assertTrue(response.type==ofp.OFPET_FLOW_MOD_FAILED,
+ self.assertTrue(response.err_type==ofp.OFPET_FLOW_MOD_FAILED,
'Error message type is not flow mod failed ')
self.assertTrue(response.code==ofp.OFPFMFC_BAD_EMERG_TIMEOUT,
'Error Message code is not bad emergency timeout')
@@ -222,15 +218,14 @@
#Generate a flow-mod,command OFPC_MODIFY
- request = message.flow_mod()
- request.command = ofp.OFPFC_MODIFY
+ request = ofp.message.flow_modify()
request.match.wildcards = ofp.OFPFW_ALL-ofp.OFPFW_IN_PORT
request.match.in_port = of_ports[0]
request.cookie = random.randint(0,9007199254740992)
request.buffer_id = 0xffffffff
- act3 = action.action_output()
+ act3 = ofp.action.output()
act3.port = of_ports[1]
- request.actions.add(act3)
+ request.actions.append(act3)
logging.info("Inserting flow")
self.controller.message_send(request)
@@ -339,10 +334,9 @@
logging.info("Expecting switch to ignore the command , without generating errors")
# Issue a delete command
- msg = message.flow_mod()
+ msg = ofp.message.flow_delete()
msg.match.wildcards = ofp.OFPFW_ALL
msg.out_port = ofp.OFPP_NONE
- msg.command = ofp.OFPFC_DELETE
msg.buffer_id = 0xffffffff
# Verify no message or error is generated by polling the the control plane
@@ -391,7 +385,7 @@
'Received flow removed message for the flow with flow_rem flag not set')
# Insert another flow F' with OFPFF_SEND_FLOW_REM flag set.
- msg9 = message.flow_mod()
+ msg9 = ofp.message.flow_add()
msg9.match.wildcards = ofp.OFPFW_ALL
msg9.cookie = random.randint(0,9007199254740992)
msg9.buffer_id = 0xffffffff
@@ -434,13 +428,12 @@
pkt = simple_tcp_packet()
match = parse.packet_to_flow_match(pkt)
match.in_port = of_ports[0]
- request = message.flow_mod()
+ request = ofp.message.flow_add()
request.match = match
- request.command = ofp.OFPFC_ADD
request.flags = request.flags|ofp.OFPFF_EMERG|ofp.OFPFF_SEND_FLOW_REM
- act = action.action_output()
+ act = ofp.action.output()
act.port = of_ports[1]
- request.actions.add(act)
+ request.actions.append(act)
self.controller.message_send(request)
@@ -566,9 +559,8 @@
verify_tablestats(self,expect_active=1)
#Send delete command matching the flow-1 but with contraint out_port = of_port[2]
- msg7 = message.flow_mod()
+ msg7 = ofp.message.flow_delete()
msg7.out_port = of_ports[2]
- msg7.command = ofp.OFPFC_DELETE
msg7.buffer_id = 0xffffffff
msg7.match = match
@@ -582,9 +574,8 @@
logging.info("Expecting switch to delete the flow")
#Send Delete command with contraint out_port = of_ports[1]
- msg7 = message.flow_mod()
+ msg7 = ofp.message.flow_delete()
msg7.out_port = of_ports[1]
- msg7.command = ofp.OFPFC_DELETE
msg7.buffer_id = 0xffffffff
msg7.match = match
@@ -614,7 +605,7 @@
logging.info("Expecting the flow entry to delete with given idle_timeout")
#Insert a flow entry with idle_timeout=1.Send_Flow_Rem flag set
- msg9 = message.flow_mod()
+ msg9 = ofp.message.flow_add()
msg9.match.wildcards = ofp.OFPFW_ALL
msg9.cookie = random.randint(0,9007199254740992)
msg9.buffer_id = 0xffffffff
@@ -696,7 +687,7 @@
logging.info("Expecting the flow entry to delete with given hard_timeout")
# Insert a flow entry with hardtimeout=1 and send_flow_removed flag set
- msg9 = message.flow_mod()
+ msg9 = ofp.message.flow_add()
msg9.match.wildcards = ofp.OFPFW_ALL
msg9.cookie = random.randint(0,9007199254740992)
msg9.buffer_id = 0xffffffff
@@ -747,17 +738,16 @@
self.assertTrue(match3 is not None, "Could not generate flow match from pkt")
match3.wildcards = ofp.OFPFW_ALL-ofp.OFPFW_IN_PORT
match3.in_port = of_ports[0]
- msg3 = message.flow_mod()
+ msg3 = ofp.message.flow_add()
msg3.out_port = of_ports[2] # ignored by flow add,flow modify
- msg3.command = ofp.OFPFC_ADD
msg3.cookie = random.randint(0,9007199254740992)
msg3.buffer_id = 0xffffffff
msg3.hard_timeout = 1
msg3.buffer_id = 0xffffffff
msg3.match = match3
- act3 = action.action_output()
+ act3 = ofp.action.output()
act3.port = of_ports[1]
- msg3.actions.add(act3)
+ msg3.actions.append(act3)
self.controller.message_send(msg3)
do_barrier(self.controller)
diff --git a/tests/flow_expire.py b/tests/flow_expire.py
index 484f22f..0467e4b 100644
--- a/tests/flow_expire.py
+++ b/tests/flow_expire.py
@@ -11,10 +11,8 @@
from oftest import config
import oftest.controller as controller
-import oftest.cstruct as ofp
-import oftest.message as message
+import ofp
import oftest.dataplane as dataplane
-import oftest.action as action
import oftest.parse as parse
import oftest.base_tests as base_tests
@@ -44,7 +42,7 @@
match.wildcards &= ~ofp.OFPFW_IN_PORT
self.assertTrue(match is not None,
"Could not generate flow match from pkt")
- act = action.action_output()
+ act = ofp.action.output()
of_ports = config["port_map"].keys()
of_ports.sort()
@@ -57,14 +55,14 @@
match.in_port = ingress_port
- request = message.flow_mod()
+ request = ofp.message.flow_add()
request.match = match
request.cookie = random.randint(0,9007199254740992)
request.buffer_id = 0xffffffff
request.idle_timeout = 1
request.flags |= ofp.OFPFF_SEND_FLOW_REM
act.port = egress_port
- request.actions.add(act)
+ request.actions.append(act)
logging.info("Inserting flow")
self.controller.message_send(request)
diff --git a/tests/flow_matches.py b/tests/flow_matches.py
index 9d04093..721d68b 100644
--- a/tests/flow_matches.py
+++ b/tests/flow_matches.py
@@ -12,10 +12,8 @@
from oftest import config
import oftest.controller as controller
-import oftest.cstruct as ofp
-import oftest.message as message
+import ofp
import oftest.dataplane as dataplane
-import oftest.action as action
import oftest.parse as parse
import oftest.base_tests as base_tests
import time
@@ -52,11 +50,11 @@
wildcard_all(self,of_ports)
#check for different match fields and verify packet implements the action specified in the flow
- pkt1 = simple_tcp_packet(dl_src="00:01:01:01:01:01");
+ pkt1 = simple_tcp_packet(eth_src="00:01:01:01:01:01");
self.dataplane.send(of_ports[0], str(pkt1))
receive_pkt_check(self.dataplane,pkt1,[yes_ports],no_ports,self)
- pkt2 = simple_tcp_packet(dl_dst="00:01:01:01:01:01");
+ pkt2 = simple_tcp_packet(eth_dst="00:01:01:01:01:01");
self.dataplane.send(of_ports[0], str(pkt2))
receive_pkt_check(self.dataplane,pkt2,[yes_ports],no_ports,self)
@@ -115,7 +113,7 @@
receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self)
#Sending non matching packet , verify Packetin event gets triggered.
- pkt2 = simple_eth_packet(dl_src='00:01:01:01:01:02');
+ pkt2 = simple_eth_packet(eth_src='00:01:01:01:01:02');
self.dataplane.send(of_ports[0], str(pkt2))
(response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4)
@@ -154,7 +152,7 @@
receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self)
#Send Non-matching packet
- pkt2 = simple_eth_packet(dl_dst='00:01:01:01:01:02');
+ pkt2 = simple_eth_packet(eth_dst='00:01:01:01:01:02');
self.dataplane.send(of_ports[0], str(pkt2))
#Verify PacketIn event gets triggered
@@ -195,7 +193,7 @@
receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self)
#Sending non matching packet ,
- pkt2 = simple_eth_packet(dl_type=0x0806);
+ pkt2 = simple_eth_packet(eth_type=0x0806);
self.dataplane.send(of_ports[0], str(pkt2))
#verify Packetin event gets triggered.
@@ -273,7 +271,7 @@
receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self)
#Send Non-matching packet, i.e packet with different Vlan Id
- pkt2 = simple_tcp_packet(dl_vlan_enable=True,dl_vlan=4);
+ pkt2 = simple_tcp_packet(dl_vlan_enable=True,vlan_vid=4);
self.dataplane.send(of_ports[0], str(pkt2))
#Verify PacketIn event gets triggered
@@ -313,7 +311,7 @@
receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self)
#Send tagged packet with same vlan_id but different vlan priority
- pkt2 = simple_tcp_packet(dl_vlan_enable=True,dl_vlan=1,dl_vlan_pcp=20);
+ pkt2 = simple_tcp_packet(dl_vlan_enable=True,vlan_vid=1,vlan_pcp=20);
self.dataplane.send(of_ports[0], str(pkt2))
#Verify Packet_In event gets triggered
@@ -345,28 +343,28 @@
(pkt,match) = match_mul_l2(self,of_ports)
- #Send eth packet matching the dl_type field, verify it implements the action
+ #Send eth packet matching the eth_type field, verify it implements the action
self.dataplane.send(of_ports[0], str(pkt))
#Verify packet implements the action specified in the flow
receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self)
- #Sending non matching packet (only dl_dst is different) , verify Packetin event gets triggered.
- pkt2 = simple_eth_packet(dl_type=0x88cc,dl_src='00:01:01:01:01:01',dl_dst='00:01:01:02:01:01');
+ #Sending non matching packet (only eth_dst is different) , verify Packetin event gets triggered.
+ pkt2 = simple_eth_packet(eth_type=0x88cc,eth_src='00:01:01:01:01:01',eth_dst='00:01:01:02:01:01');
self.dataplane.send(of_ports[0], str(pkt2))
(response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4)
self.assertTrue(response is not None, "PacketIn not received for non matching packet")
- #Sending non matching packet (only dl_src is different) , verify Packetin event gets triggered.
- pkt2 = simple_eth_packet(dl_type=0x88cc,dl_src='00:01:01:01:01:02',dl_dst='00:01:01:01:01:02');
+ #Sending non matching packet (only eth_src is different) , verify Packetin event gets triggered.
+ pkt2 = simple_eth_packet(eth_type=0x88cc,eth_src='00:01:01:01:01:02',eth_dst='00:01:01:01:01:02');
self.dataplane.send(of_ports[0], str(pkt2))
(response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4)
self.assertTrue(response is not None, "PacketIn not received for non matching packet")
#Sending non matching packet (only ether_type is different) , verify Packetin event gets triggered.
- pkt2 = simple_eth_packet(dl_type=0x0806,dl_src='00:01:01:01:01:01',dl_dst='00:01:01:01:01:02');
+ pkt2 = simple_eth_packet(eth_type=0x0806,eth_src='00:01:01:01:01:01',eth_dst='00:01:01:01:01:02');
self.dataplane.send(of_ports[0], str(pkt2))
#Verify packet_in event gets triggered
diff --git a/tests/flow_query.py b/tests/flow_query.py
index 271be11..e7f1718 100644
--- a/tests/flow_query.py
+++ b/tests/flow_query.py
@@ -67,11 +67,8 @@
from oftest import config
import oftest.controller as controller
-import oftest.cstruct as ofp
-import oftest.message as message
+import ofp
import oftest.dataplane as dataplane
-import oftest.action as action
-import oftest.action_list as action_list
import oftest.parse as parse
import pktact
import oftest.base_tests as base_tests
@@ -307,7 +304,7 @@
result = "{"
sep = ""
for a in all_actions_list:
- if ((1 << a) & bm) != 0:
+ if ((1 << a) & bm) != 0 and a in ofp.ofp_action_type_map:
result = result + sep + ofp.ofp_action_type_map[a]
sep = ", "
result = result + "}"
@@ -335,15 +332,15 @@
# - idle_timeout
# - hard_timeout
# - priority
- # - action_list
+ # - actions
def __init__(self):
self.priority = 0
- self.match = ofp.ofp_match()
+ self.match = ofp.match()
self.match.wildcards = ofp.OFPFW_ALL
self.idle_timeout = 0
self.hard_timeout = 0
- self.actions = action_list.action_list()
+ self.actions = []
# {pri, match} is considered a flow key
def key_equal(self, x):
@@ -356,41 +353,41 @@
and self.match.in_port != x.match.in_port:
return False
if wildcard_get(self.match.wildcards, ofp.OFPFW_DL_DST) == 0 \
- and self.match.dl_dst != x.match.dl_dst:
+ and self.match.eth_dst != x.match.eth_dst:
return False
if wildcard_get(self.match.wildcards, ofp.OFPFW_DL_SRC) == 0 \
- and self.match.dl_src != x.match.dl_src:
+ and self.match.eth_src != x.match.eth_src:
return False
if wildcard_get(self.match.wildcards, ofp.OFPFW_DL_VLAN) == 0 \
- and self.match.dl_vlan != x.match.dl_vlan:
+ and self.match.vlan_vid != x.match.vlan_vid:
return False
if wildcard_get(self.match.wildcards, ofp.OFPFW_DL_VLAN_PCP) == 0 \
- and self.match.dl_vlan_pcp != x.match.dl_vlan_pcp:
+ and self.match.vlan_pcp != x.match.vlan_pcp:
return False
if wildcard_get(self.match.wildcards, ofp.OFPFW_DL_TYPE) == 0 \
- and self.match.dl_type != x.match.dl_type:
+ and self.match.eth_type != x.match.eth_type:
return False
if wildcard_get(self.match.wildcards, ofp.OFPFW_NW_TOS) == 0 \
- and self.match.nw_tos != x.match.nw_tos:
+ and self.match.ip_dscp != x.match.ip_dscp:
return False
if wildcard_get(self.match.wildcards, ofp.OFPFW_NW_PROTO) == 0 \
- and self.match.nw_proto != x.match.nw_proto:
+ and self.match.ip_proto != x.match.ip_proto:
return False
n = wildcard_get(self.match.wildcards, ofp.OFPFW_NW_SRC_MASK)
if n < 32:
m = ~((1 << n) - 1)
- if (self.match.nw_src & m) != (x.match.nw_src & m):
+ if (self.match.ipv4_src & m) != (x.match.ipv4_src & m):
return False
n = wildcard_get(self.match.wildcards, ofp.OFPFW_NW_DST_MASK)
if n < 32:
m = ~((1 << n) - 1)
- if (self.match.nw_dst & m) != (x.match.nw_dst & m):
+ if (self.match.ipv4_dst & m) != (x.match.ipv4_dst & m):
return False
if wildcard_get(self.match.wildcards, ofp.OFPFW_TP_SRC) == 0 \
- and self.match.tp_src != x.match.tp_src:
+ and self.match.tcp_src != x.match.tcp_src:
return False
if wildcard_get(self.match.wildcards, ofp.OFPFW_TP_DST) == 0 \
- and self.match.tp_dst != x.match.tp_dst:
+ and self.match.tcp_dst != x.match.tcp_dst:
return False
return True
@@ -398,8 +395,8 @@
if test_param_get("conservative_ordered_actions", True):
# Compare actions lists as unordered
- aa = copy.deepcopy(x.actions.actions)
- for a in self.actions.actions:
+ aa = copy.deepcopy(x.actions)
+ for a in self.actions:
i = 0
while i < len(aa):
if a == aa[i]:
@@ -434,37 +431,37 @@
if wildcard_get(self.match.wildcards, ofp.OFPFW_IN_PORT) == 0:
result = result + (", in_port=%d" % (self.match.in_port))
if wildcard_get(self.match.wildcards, ofp.OFPFW_DL_DST) == 0:
- result = result + (", dl_dst=%s" \
- % (dl_addr_to_str(self.match.dl_dst)) \
+ result = result + (", eth_dst=%s" \
+ % (dl_addr_to_str(self.match.eth_dst)) \
)
if wildcard_get(self.match.wildcards, ofp.OFPFW_DL_SRC) == 0:
- result = result + (", dl_src=%s" \
- % (dl_addr_to_str(self.match.dl_src)) \
+ result = result + (", eth_src=%s" \
+ % (dl_addr_to_str(self.match.eth_src)) \
)
if wildcard_get(self.match.wildcards, ofp.OFPFW_DL_VLAN) == 0:
- result = result + (", dl_vlan=%d" % (self.match.dl_vlan))
+ result = result + (", vlan_vid=%d" % (self.match.vlan_vid))
if wildcard_get(self.match.wildcards, ofp.OFPFW_DL_VLAN_PCP) == 0:
- result = result + (", dl_vlan_pcp=%d" % (self.match.dl_vlan_pcp))
+ result = result + (", vlan_pcp=%d" % (self.match.vlan_pcp))
if wildcard_get(self.match.wildcards, ofp.OFPFW_DL_TYPE) == 0:
- result = result + (", dl_type=0x%x" % (self.match.dl_type))
+ result = result + (", eth_type=0x%x" % (self.match.eth_type))
if wildcard_get(self.match.wildcards, ofp.OFPFW_NW_TOS) == 0:
- result = result + (", nw_tos=0x%x" % (self.match.nw_tos))
+ result = result + (", ip_dscp=0x%x" % (self.match.ip_dscp))
if wildcard_get(self.match.wildcards, ofp.OFPFW_NW_PROTO) == 0:
- result = result + (", nw_proto=%d" % (self.match.nw_proto))
+ result = result + (", ip_proto=%d" % (self.match.ip_proto))
n = wildcard_get(self.match.wildcards, ofp.OFPFW_NW_SRC_MASK)
if n < 32:
- result = result + (", nw_src=%s" % \
- (ip_addr_to_str(self.match.nw_src, 32 - n)) \
+ result = result + (", ipv4_src=%s" % \
+ (ip_addr_to_str(self.match.ipv4_src, 32 - n)) \
)
n = wildcard_get(self.match.wildcards, ofp.OFPFW_NW_DST_MASK)
if n < 32:
- result = result + (", nw_dst=%s" % \
- (ip_addr_to_str(self.match.nw_dst, 32 - n)) \
+ result = result + (", ipv4_dst=%s" % \
+ (ip_addr_to_str(self.match.ipv4_dst, 32 - n)) \
)
if wildcard_get(self.match.wildcards, ofp.OFPFW_TP_SRC) == 0:
- result = result + (", tp_src=%d" % self.match.tp_src)
+ result = result + (", tcp_src=%d" % self.match.tcp_src)
if wildcard_get(self.match.wildcards, ofp.OFPFW_TP_DST) == 0:
- result = result + (", tp_dst=%d" % self.match.tp_dst)
+ result = result + (", tcp_dst=%d" % self.match.tcp_dst)
return result
def __eq__(self, x):
@@ -475,8 +472,8 @@
result = result + (", cookie=%d" % self.cookie)
result = result + (", idle_timeout=%d" % self.idle_timeout)
result = result + (", hard_timeout=%d" % self.hard_timeout)
- for a in self.actions.actions:
- result = result + (", action=%s" % ofp.ofp_action_type_map[a.type])
+ for a in self.actions:
+ result = result + (", action=%s" % ofp.ofp_action_type_map.get(a.type, "unknown"))
if a.type == ofp.OFPAT_OUTPUT:
result = result + ("(%d)" % (a.port))
elif a.type == ofp.OFPAT_SET_VLAN_VID:
@@ -521,50 +518,50 @@
set_vlanf = False
strip_vlanf = False
- self.actions = action_list.action_list()
+ self.actions = []
for a in actions:
act = None
if a == ofp.OFPAT_OUTPUT:
pass # OUTPUT actions must come last
elif a == ofp.OFPAT_SET_VLAN_VID:
if not strip_vlanf:
- act = action.action_set_vlan_vid()
+ act = ofp.action.set_vlan_vid()
act.vlan_vid = fi.rand_vlan()
set_vlanf = True
elif a == ofp.OFPAT_SET_VLAN_PCP:
if not strip_vlanf:
- act = action.action_set_vlan_pcp()
+ act = ofp.action.set_vlan_pcp()
act.vlan_pcp = random.randint(0, (1 << 3) - 1)
set_vlanf = True
elif a == ofp.OFPAT_STRIP_VLAN:
if not set_vlanf:
- act = action.action_strip_vlan()
+ act = ofp.action.strip_vlan()
strip_vlanf = True
elif a == ofp.OFPAT_SET_DL_SRC:
- act = action.action_set_dl_src()
+ act = ofp.action.set_dl_src()
act.dl_addr = fi.rand_dl_addr()
elif a == ofp.OFPAT_SET_DL_DST:
- act = action.action_set_dl_dst()
+ act = ofp.action.set_dl_dst()
act.dl_addr = fi.rand_dl_addr()
elif a == ofp.OFPAT_SET_NW_SRC:
- act = action.action_set_nw_src()
+ act = ofp.action.set_nw_src()
act.nw_addr = fi.rand_ip_addr()
elif a == ofp.OFPAT_SET_NW_DST:
- act = action.action_set_nw_dst()
+ act = ofp.action.set_nw_dst()
act.nw_addr = fi.rand_ip_addr()
elif a == ofp.OFPAT_SET_NW_TOS:
- act = action.action_set_nw_tos()
- act.nw_tos = fi.rand_ip_tos()
+ act = ofp.action.set_nw_tos()
+ act.ip_dscp = fi.rand_ip_tos()
elif a == ofp.OFPAT_SET_TP_SRC:
- act = action.action_set_tp_src()
+ act = ofp.action.set_tp_src()
act.tp_port = fi.rand_l4_port()
elif a == ofp.OFPAT_SET_TP_DST:
- act = action.action_set_tp_dst()
+ act = ofp.action.set_tp_dst()
act.tp_port = fi.rand_l4_port()
elif a == ofp.OFPAT_ENQUEUE:
pass # Enqueue actions must come last
if act:
- self.actions.add(act)
+ self.actions.append(act)
p = random.randint(1, 100)
if (((1 << ofp.OFPAT_ENQUEUE) & actions_force) != 0 or p <= 33) \
@@ -573,9 +570,9 @@
# In not forecd, one third of the time, include ENQUEUE actions
# at end of list
# At most 1 ENQUEUE action
- act = action.action_enqueue()
+ act = ofp.action.enqueue()
(act.port, act.queue_id) = rand_pick(valid_queues)
- self.actions.add(act)
+ self.actions.append(act)
if (((1 << ofp.OFPAT_OUTPUT) & actions_force) != 0 \
or (p > 33 and p <= 66) \
) \
@@ -588,12 +585,12 @@
else random.randint(1, len(valid_ports))
port_idxs = port_idxs[0 : n]
for pi in port_idxs:
- act = action.action_output()
+ act = ofp.action.output()
act.port = valid_ports[pi]
if act.port != ofp.OFPP_IN_PORT \
or wildcard_get(self.match.wildcards, ofp.OFPFW_IN_PORT) == 0:
# OUTPUT(IN_PORT) only valid if OFPFW_IN_PORT not wildcarded
- self.actions.add(act)
+ self.actions.append(act)
else:
# One third of the time, include neither
pass
@@ -629,7 +626,7 @@
actions = shuffle(actions)
- self.actions = action_list.action_list()
+ self.actions = []
for a in actions:
if a == ofp.OFPAT_OUTPUT:
# TBD - Output actions are clustered in list, spread them out?
@@ -638,47 +635,47 @@
port_idxs = shuffle(range(len(valid_ports)))
port_idxs = port_idxs[0 : random.randint(1, len(valid_ports))]
for pi in port_idxs:
- act = action.action_output()
+ act = ofp.action.output()
act.port = valid_ports[pi]
- self.actions.add(act)
+ self.actions.append(act)
elif a == ofp.OFPAT_SET_VLAN_VID:
- act = action.action_set_vlan_vid()
+ act = ofp.action.set_vlan_vid()
act.vlan_vid = fi.rand_vlan()
- self.actions.add(act)
+ self.actions.append(act)
elif a == ofp.OFPAT_SET_VLAN_PCP:
- act = action.action_set_vlan_pcp()
+ act = ofp.action.set_vlan_pcp()
act.vlan_pcp = random.randint(0, (1 << 3) - 1)
elif a == ofp.OFPAT_STRIP_VLAN:
- act = action.action_strip_vlan()
- self.actions.add(act)
+ act = ofp.action.strip_vlan()
+ self.actions.append(act)
elif a == ofp.OFPAT_SET_DL_SRC:
- act = action.action_set_dl_src()
+ act = ofp.action.set_dl_src()
act.dl_addr = fi.rand_dl_addr()
- self.actions.add(act)
+ self.actions.append(act)
elif a == ofp.OFPAT_SET_DL_DST:
- act = action.action_set_dl_dst()
+ act = ofp.action.set_dl_dst()
act.dl_addr = fi.rand_dl_addr()
- self.actions.add(act)
+ self.actions.append(act)
elif a == ofp.OFPAT_SET_NW_SRC:
- act = action.action_set_nw_src()
+ act = ofp.action.set_nw_src()
act.nw_addr = fi.rand_ip_addr()
- self.actions.add(act)
+ self.actions.append(act)
elif a == ofp.OFPAT_SET_NW_DST:
- act = action.action_set_nw_dst()
+ act = ofp.action.set_nw_dst()
act.nw_addr = fi.rand_ip_addr()
- self.actions.add(act)
+ self.actions.append(act)
elif a == ofp.OFPAT_SET_NW_TOS:
- act = action.action_set_nw_tos()
- act.nw_tos = fi.rand_ip_tos()
- self.actions.add(act)
+ act = ofp.action.set_nw_tos()
+ act.ip_dscp = fi.rand_ip_tos()
+ self.actions.append(act)
elif a == ofp.OFPAT_SET_TP_SRC:
- act = action.action_set_tp_src()
+ act = ofp.action.set_tp_src()
act.tp_port = fi.rand_l4_port()
- self.actions.add(act)
+ self.actions.append(act)
elif a == ofp.OFPAT_SET_TP_DST:
- act = action.action_set_tp_dst()
+ act = ofp.action.set_tp_dst()
act.tp_port = fi.rand_l4_port()
- self.actions.add(act)
+ self.actions.append(act)
elif a == ofp.OFPAT_ENQUEUE:
# TBD - Enqueue actions are clustered in list, spread them out?
if len(valid_queues) == 0:
@@ -686,9 +683,9 @@
qidxs = shuffle(range(len(valid_queues)))
qidxs = qidxs[0 : random.randint(1, len(valid_queues))]
for qi in qidxs:
- act = action.action_enqueue()
+ act = ofp.action.enqueue()
(act.port, act.queue_id) = valid_queues[qi]
- self.actions.add(act)
+ self.actions.append(act)
return self
@@ -733,7 +730,7 @@
or exact \
or flip_coin() \
):
- self.match.dl_dst = fi.rand_dl_addr()
+ self.match.eth_dst = fi.rand_dl_addr()
else:
self.match.wildcards = wildcard_set(self.match.wildcards, \
ofp.OFPFW_DL_DST, \
@@ -745,7 +742,7 @@
or exact \
or flip_coin() \
):
- self.match.dl_src = fi.rand_dl_addr()
+ self.match.eth_src = fi.rand_dl_addr()
else:
self.match.wildcards = wildcard_set(self.match.wildcards, \
ofp.OFPFW_DL_SRC, \
@@ -757,7 +754,7 @@
or exact \
or flip_coin() \
):
- self.match.dl_vlan = fi.rand_vlan()
+ self.match.vlan_vid = fi.rand_vlan()
else:
self.match.wildcards = wildcard_set(self.match.wildcards, \
ofp.OFPFW_DL_VLAN, \
@@ -769,7 +766,7 @@
or exact \
or flip_coin() \
):
- self.match.dl_vlan_pcp = random.randint(0, (1 << 3) - 1)
+ self.match.vlan_pcp = random.randint(0, (1 << 3) - 1)
else:
self.match.wildcards = wildcard_set(self.match.wildcards, \
ofp.OFPFW_DL_VLAN_PCP, \
@@ -781,7 +778,7 @@
or exact \
or flip_coin() \
):
- self.match.dl_type = fi.rand_ethertype()
+ self.match.eth_type = fi.rand_ethertype()
else:
self.match.wildcards = wildcard_set(self.match.wildcards, \
ofp.OFPFW_DL_TYPE, \
@@ -802,11 +799,11 @@
n \
)
if n < 32:
- self.match.nw_src = fi.rand_ip_addr() & ~((1 << n) - 1)
+ self.match.ipv4_src = fi.rand_ip_addr() & ~((1 << n) - 1)
# Specifying any IP address match other than all bits
# don't care requires that Ethertype is one of {IP, ARP}
if flip_coin():
- self.match.dl_type = rand_pick([0x0800, 0x0806])
+ self.match.eth_type = rand_pick([0x0800, 0x0806])
self.match.wildcards = wildcard_set(self.match.wildcards, \
ofp.OFPFW_DL_TYPE, \
0 \
@@ -826,11 +823,11 @@
n \
)
if n < 32:
- self.match.nw_dst = fi.rand_ip_addr() & ~((1 << n) - 1)
+ self.match.ipv4_dst = fi.rand_ip_addr() & ~((1 << n) - 1)
# Specifying any IP address match other than all bits
# don't care requires that Ethertype is one of {IP, ARP}
if flip_coin():
- self.match.dl_type = rand_pick([0x0800, 0x0806])
+ self.match.eth_type = rand_pick([0x0800, 0x0806])
self.match.wildcards = wildcard_set(self.match.wildcards, \
ofp.OFPFW_DL_TYPE, \
0 \
@@ -841,10 +838,10 @@
or exact \
or flip_coin() \
):
- self.match.nw_tos = fi.rand_ip_tos()
+ self.match.ip_dscp = fi.rand_ip_tos()
# Specifying a TOS value requires that Ethertype is IP
if flip_coin():
- self.match.dl_type = 0x0800
+ self.match.eth_type = 0x0800
self.match.wildcards = wildcard_set(self.match.wildcards, \
ofp.OFPFW_DL_TYPE, \
0 \
@@ -855,16 +852,16 @@
1 \
)
- # Known issue on OVS with specifying nw_proto w/o dl_type as IP
+ # Known issue on OVS with specifying ip_proto w/o eth_type as IP
if wildcard_get(wildcards_force, ofp.OFPFW_NW_PROTO) == 0 \
and (wildcard_get(valid_wildcards, ofp.OFPFW_NW_PROTO) == 0 \
or exact \
or flip_coin() \
):
- self.match.nw_proto = fi.rand_ip_proto()
+ self.match.ip_proto = fi.rand_ip_proto()
# Specifying an IP protocol requires that Ethertype is IP
if flip_coin():
- self.match.dl_type = 0x0800
+ self.match.eth_type = 0x0800
self.match.wildcards = wildcard_set(self.match.wildcards, \
ofp.OFPFW_DL_TYPE, \
0 \
@@ -880,23 +877,23 @@
or exact\
or flip_coin() \
):
- self.match.tp_src = fi.rand_l4_port()
+ self.match.tcp_src = fi.rand_l4_port()
# Specifying a L4 port requires that IP protcol is
# one of {ICMP, TCP, UDP}
if flip_coin():
- self.match.nw_proto = rand_pick([1, 6, 17])
+ self.match.ip_proto = rand_pick([1, 6, 17])
self.match.wildcards = wildcard_set(self.match.wildcards, \
ofp.OFPFW_NW_PROTO, \
0 \
)
# Specifying a L4 port requirues that Ethertype is IP
- self.match.dl_type = 0x0800
+ self.match.eth_type = 0x0800
self.match.wildcards = wildcard_set(self.match.wildcards, \
ofp.OFPFW_DL_TYPE, \
0 \
)
- if self.match.nw_proto == 1:
- self.match.tp_src = self.match.tp_src & 0xff
+ if self.match.ip_proto == 1:
+ self.match.tcp_src = self.match.tcp_src & 0xff
else:
self.match.wildcards = wildcard_set(self.match.wildcards, \
ofp.OFPFW_TP_SRC, \
@@ -908,23 +905,23 @@
or exact \
or flip_coin() \
):
- self.match.tp_dst = fi.rand_l4_port()
+ self.match.tcp_dst = fi.rand_l4_port()
# Specifying a L4 port requires that IP protcol is
# one of {ICMP, TCP, UDP}
if flip_coin():
- self.match.nw_proto = rand_pick([1, 6, 17])
+ self.match.ip_proto = rand_pick([1, 6, 17])
self.match.wildcards = wildcard_set(self.match.wildcards, \
ofp.OFPFW_NW_PROTO, \
0 \
)
# Specifying a L4 port requirues that Ethertype is IP
- self.match.dl_type = 0x0800
+ self.match.eth_type = 0x0800
self.match.wildcards = wildcard_set(self.match.wildcards, \
ofp.OFPFW_DL_TYPE, \
0 \
)
- if self.match.nw_proto == 1:
- self.match.tp_dst = self.match.tp_dst & 0xff
+ if self.match.ip_proto == 1:
+ self.match.tcp_dst = self.match.tcp_dst & 0xff
else:
self.match.wildcards = wildcard_set(self.match.wildcards, \
ofp.OFPFW_TP_DST, \
@@ -950,7 +947,7 @@
# Return flow cfg in canonical form
# - There are dependencies between flow qualifiers, e.g. it only makes
- # sense to qualify nw_proto if dl_type is qualified to be 0x0800 (IP).
+ # sense to qualify ip_proto if eth_type is qualified to be 0x0800 (IP).
# The canonical form of flow match criteria will "wildcard out"
# all such cases.
def canonical(self):
@@ -963,10 +960,10 @@
)
if wildcard_get(result.match.wildcards, ofp.OFPFW_DL_TYPE) != 0 \
- or result.match.dl_type not in [0x0800, 0x0806]:
+ or result.match.eth_type not in [0x0800, 0x0806]:
# dl_tyoe is wildcarded, or specified as something other
# than IP or ARP
- # => nw_src, nw_dst, nw_proto cannot be specified,
+ # => ipv4_src, ipv4_dst, ip_proto cannot be specified,
# must be wildcarded
result.match.wildcards = wildcard_set(result.match.wildcards, \
ofp.OFPFW_NW_SRC_MASK, \
@@ -982,9 +979,9 @@
)
if wildcard_get(result.match.wildcards, ofp.OFPFW_DL_TYPE) != 0 \
- or result.match.dl_type != 0x0800:
- # dl_type is wildcarded, or specified as something other than IP
- # => nw_tos, tp_src and tp_dst cannot be specified,
+ or result.match.eth_type != 0x0800:
+ # eth_type is wildcarded, or specified as something other than IP
+ # => ip_dscp, tcp_src and tcp_dst cannot be specified,
# must be wildcarded
result.match.wildcards = wildcard_set(result.match.wildcards, \
ofp.OFPFW_NW_TOS, \
@@ -1012,10 +1009,10 @@
)
if wildcard_get(result.match.wildcards, ofp.OFPFW_NW_PROTO) != 0 \
- or result.match.nw_proto not in [1, 6, 17]:
- # nw_proto is wildcarded, or specified as something other than ICMP,
+ or result.match.ip_proto not in [1, 6, 17]:
+ # ip_proto is wildcarded, or specified as something other than ICMP,
# TCP or UDP
- # => tp_src and tp_dst cannot be specified, must be wildcarded
+ # => tcp_src and tcp_dst cannot be specified, must be wildcarded
result.match.wildcards = wildcard_set(result.match.wildcards, \
ofp.OFPFW_TP_SRC, \
1 \
@@ -1041,43 +1038,43 @@
return False # Receiver more specific
if wildcard_get(self.match.wildcards, ofp.OFPFW_DL_VLAN) == 0:
if wildcard_get(x.match.wildcards, ofp.OFPFW_DL_VLAN) == 0:
- if self.match.dl_vlan != x.match.dl_vlan:
+ if self.match.vlan_vid != x.match.vlan_vid:
return False # Both specified, and not equal
elif delf:
return False # Receiver more specific
if wildcard_get(self.match.wildcards, ofp.OFPFW_DL_SRC) == 0:
if wildcard_get(x.match.wildcards, ofp.OFPFW_DL_SRC) == 0:
- if self.match.dl_src != x.match.dl_src:
+ if self.match.eth_src != x.match.eth_src:
return False # Both specified, and not equal
elif delf:
return False # Receiver more specific
if wildcard_get(self.match.wildcards, ofp.OFPFW_DL_DST) == 0:
if wildcard_get(x.match.wildcards, ofp.OFPFW_DL_DST) == 0:
- if self.match.dl_dst != x.match.dl_dst:
+ if self.match.eth_dst != x.match.eth_dst:
return False # Both specified, and not equal
elif delf:
return False # Receiver more specific
if wildcard_get(self.match.wildcards, ofp.OFPFW_DL_TYPE) == 0:
if wildcard_get(x.match.wildcards, ofp.OFPFW_DL_TYPE) == 0:
- if self.match.dl_type != x.match.dl_type:
+ if self.match.eth_type != x.match.eth_type:
return False # Both specified, and not equal
elif delf:
return False # Recevier more specific
if wildcard_get(self.match.wildcards, ofp.OFPFW_NW_PROTO) == 0:
if wildcard_get(x.match.wildcards, ofp.OFPFW_NW_PROTO) == 0:
- if self.match.nw_proto != x.match.nw_proto:
+ if self.match.ip_proto != x.match.ip_proto:
return False # Both specified, and not equal
elif delf:
return False # Receiver more specific
if wildcard_get(self.match.wildcards, ofp.OFPFW_TP_SRC) == 0:
if wildcard_get(x.match.wildcards, ofp.OFPFW_TP_SRC) == 0:
- if self.match.tp_src != x.match.tp_src:
+ if self.match.tcp_src != x.match.tcp_src:
return False # Both specified, and not equal
elif delf:
return False # Receiver more specific
if wildcard_get(self.match.wildcards, ofp.OFPFW_TP_DST) == 0:
if wildcard_get(x.match.wildcards, ofp.OFPFW_TP_DST) == 0:
- if self.match.tp_dst != x.match.tp_dst:
+ if self.match.tcp_dst != x.match.tcp_dst:
return False # Both specified, and not equal
elif delf:
return False # Receiver more specific
@@ -1087,7 +1084,7 @@
return False # Receiver more specific
if (na < 32 and nb < 32):
m = ~((1 << na) - 1) & ~((1 << nb) - 1)
- if (self.match.nw_src & m) != (x.match.nw_src & m):
+ if (self.match.ipv4_src & m) != (x.match.ipv4_src & m):
return False # Overlapping bits not equal
na = wildcard_get(self.match.wildcards, ofp.OFPFW_NW_DST_MASK)
nb = wildcard_get(x.match.wildcards, ofp.OFPFW_NW_DST_MASK)
@@ -1095,17 +1092,17 @@
return False # Receiver more specific
if (na < 32 and nb < 32):
m = ~((1 << na) - 1) & ~((1 << nb) - 1)
- if (self.match.nw_dst & m) != (x.match.nw_dst & m):
+ if (self.match.ipv4_dst & m) != (x.match.ipv4_dst & m):
return False # Overlapping bits not equal
if wildcard_get(self.match.wildcards, ofp.OFPFW_DL_VLAN_PCP) == 0:
if wildcard_get(x.match.wildcards, ofp.OFPFW_DL_VLAN_PCP) == 0:
- if self.match.dl_vlan_pcp != x.match.dl_vlan_pcp:
+ if self.match.vlan_pcp != x.match.vlan_pcp:
return False # Both specified, and not equal
elif delf:
return False # Receiver more specific
if wildcard_get(self.match.wildcards, ofp.OFPFW_NW_TOS) == 0:
if wildcard_get(x.match.wildcards, ofp.OFPFW_NW_TOS) == 0:
- if self.match.nw_tos != x.match.nw_tos:
+ if self.match.ip_dscp != x.match.ip_dscp:
return False # Both specified, and not equal
elif delf:
return False # Receiver more specific
@@ -1165,7 +1162,7 @@
fc = Flow_Cfg()
fc.rand(fi, \
wildcards_force, \
- sw.tbl_stats.stats[tbl].wildcards, \
+ sw.tbl_stats.entries[tbl].wildcards, \
sw.sw_features.actions, \
sw.valid_ports, \
sw.valid_queues \
@@ -1177,7 +1174,7 @@
self.insert(fc)
i = i + 1
j = j + 1
- if j >= sw.tbl_stats.stats[tbl].max_entries:
+ if j >= sw.tbl_stats.entries[tbl].max_entries:
tbl = tbl + 1
j = 0
@@ -1206,16 +1203,12 @@
def error_handler(self, controller, msg, rawmsg):
logging.info("Got an ERROR message, type=%d, code=%d" \
- % (msg.type, msg.code) \
+ % (msg.err_type, msg.code) \
)
- logging.info("Message header:")
- logging.info(msg.header.show())
self.error_msgs.append(msg)
def removed_handler(self, controller, msg, rawmsg):
logging.info("Got a REMOVED message")
- logging.info("Message header:")
- logging.info(msg.header.show())
self.removed_msgs.append(msg)
def controller_set(self, controller):
@@ -1228,7 +1221,7 @@
def features_get(self):
# Get switch features
- request = message.features_request()
+ request = ofp.message.features_request()
(self.sw_features, pkt) = self.controller.transact(request)
if self.sw_features is None:
logging.error("Get switch features failed")
@@ -1270,13 +1263,13 @@
def tbl_stats_get(self):
# Get table stats
- request = message.table_stats_request()
+ request = ofp.message.table_stats_request()
(self.tbl_stats, pkt) = self.controller.transact(request)
if self.tbl_stats is None:
logging.error("Get table stats failed")
return False
i = 0
- for ts in self.tbl_stats.stats:
+ for ts in self.tbl_stats.entries:
logging.info("Supported wildcards for table %d reported by switch:"
% (i)
)
@@ -1297,7 +1290,7 @@
def queue_stats_get(self):
# Get queue stats
- request = message.queue_stats_request()
+ request = ofp.message.queue_stats_request()
request.port_no = ofp.OFPP_ALL
request.queue_id = ofp.OFPQ_ALL
(self.queue_stats, pkt) = self.controller.transact(request)
@@ -1305,7 +1298,7 @@
logging.error("Get queue stats failed")
return False
self.valid_queues = map(lambda x: (x.port_no, x.queue_id), \
- self.queue_stats.stats \
+ self.queue_stats.entries \
)
logging.info("(Port, queue) pairs reported by switch:")
logging.info(self.valid_queues)
@@ -1325,8 +1318,8 @@
)
def flow_stats_get(self, limit = 10000):
- request = message.flow_stats_request()
- query_match = ofp.ofp_match()
+ request = ofp.message.flow_stats_request()
+ query_match = ofp.match()
query_match.wildcards = ofp.OFPFW_ALL
request.match = query_match
request.table_id = 0xff
@@ -1345,9 +1338,9 @@
if n == 0:
self.flow_stats = resp
else:
- self.flow_stats.stats.extend(resp.stats)
+ self.flow_stats.entries.extend(resp.entries)
n = n + 1
- if len(self.flow_stats.stats) > limit:
+ if len(self.flow_stats.entries) > limit:
logging.error("Too many flows returned")
return False
if (resp.flags & 1) == 0:
@@ -1355,51 +1348,52 @@
return (n > 0)
def flow_add(self, flow_cfg, overlapf = False):
- flow_mod_msg = message.flow_mod()
- flow_mod_msg.command = ofp.OFPFC_ADD
+ flow_mod_msg = ofp.message.flow_add()
flow_mod_msg.buffer_id = 0xffffffff
flow_cfg.to_flow_mod_msg(flow_mod_msg)
if overlapf:
flow_mod_msg.flags = flow_mod_msg.flags | ofp.OFPFF_CHECK_OVERLAP
if flow_cfg.send_rem:
flow_mod_msg.flags = flow_mod_msg.flags | ofp.OFPFF_SEND_FLOW_REM
- flow_mod_msg.header.xid = random.randrange(1,0xffffffff)
+ flow_mod_msg.xid = random.randrange(1,0xffffffff)
logging.info("Sending flow_mod(add), xid=%d"
- % (flow_mod_msg.header.xid)
+ % (flow_mod_msg.xid)
)
self.controller.message_send(flow_mod_msg)
return True
def flow_mod(self, flow_cfg, strictf):
- flow_mod_msg = message.flow_mod()
- flow_mod_msg.command = ofp.OFPFC_MODIFY_STRICT if strictf \
- else ofp.OFPFC_MODIFY
+ if strictf:
+ flow_mod_msg = ofp.message.flow_modify_strict()
+ else:
+ flow_mod_msg = ofp.message.flow_modify()
flow_mod_msg.buffer_id = 0xffffffff
flow_cfg.to_flow_mod_msg(flow_mod_msg)
- flow_mod_msg.header.xid = random.randrange(1,0xffffffff)
+ flow_mod_msg.xid = random.randrange(1,0xffffffff)
logging.info("Sending flow_mod(mod), xid=%d"
- % (flow_mod_msg.header.xid)
+ % (flow_mod_msg.xid)
)
self.controller.message_send(flow_mod_msg)
return True
def flow_del(self, flow_cfg, strictf):
- flow_mod_msg = message.flow_mod()
- flow_mod_msg.command = ofp.OFPFC_DELETE_STRICT if strictf \
- else ofp.OFPFC_DELETE
+ if strictf:
+ flow_mod_msg = ofp.message.flow_delete_strict()
+ else:
+ flow_mod_msg = ofp.message.flow_delete()
flow_mod_msg.buffer_id = 0xffffffff
# TBD - "out_port" filtering of deletes needs to be tested
flow_mod_msg.out_port = ofp.OFPP_NONE
flow_cfg.to_flow_mod_msg(flow_mod_msg)
- flow_mod_msg.header.xid = random.randrange(1,0xffffffff)
+ flow_mod_msg.xid = random.randrange(1,0xffffffff)
logging.info("Sending flow_mod(del), xid=%d"
- % (flow_mod_msg.header.xid)
+ % (flow_mod_msg.xid)
)
self.controller.message_send(flow_mod_msg)
return True
def barrier(self):
- barrier = message.barrier_request()
+ barrier = ofp.message.barrier_request()
(resp, pkt) = self.controller.transact(barrier, 30)
return (resp is not None)
@@ -1419,7 +1413,7 @@
)
f = False
for e in self.error_msgs:
- if e.type == type and e.code == code:
+ if e.err_type == type and e.code == code:
logging.info("Got it")
f = True
if not f:
@@ -1454,7 +1448,7 @@
logging.error("Get table stats failed")
return False
n = 0
- for ts in self.tbl_stats.stats:
+ for ts in self.tbl_stats.entries:
n = n + ts.active_count
logging.info("Table stats reported %d active flows" \
% (n) \
@@ -1469,18 +1463,18 @@
if not self.flow_stats_get():
logging.error("Get flow stats failed")
return False
- logging.info("Retrieved %d flows" % (len(self.flow_stats.stats)))
+ logging.info("Retrieved %d flows" % (len(self.flow_stats.entries)))
# Verify flows returned by switch
- if len(self.flow_stats.stats) != self.flow_tbl.count():
+ if len(self.flow_stats.entries) != self.flow_tbl.count():
logging.error("Switch reported incorrect number of flows")
result = False
logging.info("Verifying received flows")
for fc in self.flow_tbl.values():
fc.matched = False
- for fs in self.flow_stats.stats:
+ for fs in self.flow_stats.entries:
flow_in = Flow_Cfg()
flow_in.from_flow_stat(fs)
logging.info("Received flow:")
@@ -1596,7 +1590,7 @@
# Number of flows requested was 0
# => Generate max number of flows
- for ts in sw.tbl_stats.stats:
+ for ts in sw.tbl_stats.entries:
num_flows = num_flows + ts.max_entries
logging.info("Generating %d flows" % (num_flows))
@@ -1705,7 +1699,7 @@
fc = Flow_Cfg()
fc.rand(fi, \
required_wildcards(self), \
- sw.tbl_stats.stats[0].wildcards, \
+ sw.tbl_stats.entries[0].wildcards, \
sw.sw_features.actions, \
sw.valid_ports, \
sw.valid_queues \
@@ -1808,7 +1802,7 @@
)
num_flows = 0
- for ts in sw.tbl_stats.stats:
+ for ts in sw.tbl_stats.entries:
num_flows = num_flows + ts.max_entries
logging.info("Switch capacity is %d flows" % (num_flows))
@@ -1853,7 +1847,7 @@
fc = Flow_Cfg()
fc.rand(fi, \
required_wildcards(self), \
- sw.tbl_stats.stats[0].wildcards, \
+ sw.tbl_stats.entries[0].wildcards, \
sw.sw_features.actions, \
sw.valid_ports, \
sw.valid_queues \
@@ -1949,7 +1943,7 @@
fc = Flow_Cfg()
fc.rand(fi, \
required_wildcards(self), \
- sw.tbl_stats.stats[0].wildcards, \
+ sw.tbl_stats.entries[0].wildcards, \
sw.sw_features.actions, \
sw.valid_ports, \
sw.valid_queues \
@@ -2071,7 +2065,7 @@
while True:
fc.rand(fi, \
required_wildcards(self), \
- sw.tbl_stats.stats[0].wildcards, \
+ sw.tbl_stats.entries[0].wildcards, \
sw.sw_features.actions, \
sw.valid_ports, \
sw.valid_queues \
@@ -2196,7 +2190,7 @@
fc = Flow_Cfg()
fc.rand(fi, \
required_wildcards(self), \
- sw.tbl_stats.stats[0].wildcards, \
+ sw.tbl_stats.entries[0].wildcards, \
sw.sw_features.actions, \
sw.valid_ports, \
sw.valid_queues \
@@ -2472,7 +2466,7 @@
fc = Flow_Cfg()
fc.rand(fi, \
required_wildcards(self), \
- sw.tbl_stats.stats[0].wildcards, \
+ sw.tbl_stats.entries[0].wildcards, \
sw.sw_features.actions, \
sw.valid_ports, \
sw.valid_queues \
@@ -2564,7 +2558,7 @@
fc = Flow_Cfg()
fc.rand(fi, \
required_wildcards(self), \
- sw.tbl_stats.stats[0].wildcards, \
+ sw.tbl_stats.entries[0].wildcards, \
sw.sw_features.actions, \
sw.valid_ports, \
sw.valid_queues \
@@ -2679,7 +2673,7 @@
fc = Flow_Cfg()
fc.rand(fi, \
required_wildcards(self), \
- sw.tbl_stats.stats[0].wildcards, \
+ sw.tbl_stats.entries[0].wildcards, \
sw.sw_features.actions, \
sw.valid_ports, \
sw.valid_queues \
@@ -2958,7 +2952,7 @@
fc = Flow_Cfg()
fc.rand(fi, \
required_wildcards(self), \
- sw.tbl_stats.stats[0].wildcards, \
+ sw.tbl_stats.entries[0].wildcards, \
sw.sw_features.actions, \
sw.valid_ports, \
sw.valid_queues \
diff --git a/tests/flow_stats.py b/tests/flow_stats.py
index 2f14156..ff33948 100644
--- a/tests/flow_stats.py
+++ b/tests/flow_stats.py
@@ -12,10 +12,8 @@
from oftest import config
import oftest.controller as controller
-import oftest.cstruct as ofp
-import oftest.message as message
+import ofp
import oftest.dataplane as dataplane
-import oftest.action as action
import oftest.parse as parse
import oftest.base_tests as base_tests
@@ -74,7 +72,7 @@
"""
def verifyStats(self, flow_mod_msg, match, out_port, test_timeout, packet_count):
- stat_req = message.flow_stats_request()
+ stat_req = ofp.message.flow_stats_request()
stat_req.match = match
stat_req.table_id = 0xff
stat_req.out_port = out_port
@@ -86,9 +84,9 @@
timeout=test_timeout)
self.assertTrue(response is not None,
"No response to stats request")
- self.assertTrue(len(response.stats) == 1,
+ self.assertTrue(len(response.entries) == 1,
"Did not receive flow stats reply")
- for obj in response.stats:
+ for obj in response.entries:
# TODO: pad1 and pad2 fields may be nonzero, is this a bug?
# for now, just clear them so the assert is simpler
obj.match.pad1 = 0
@@ -127,7 +125,7 @@
match.wildcards &= ~ofp.OFPFW_IN_PORT
self.assertTrue(match is not None,
"Could not generate flow match from pkt")
- act = action.action_output()
+ act = ofp.action.output()
# build flow
ingress_port = of_ports[0];
@@ -135,7 +133,7 @@
logging.info("Ingress " + str(ingress_port) +
" to egress " + str(egress_port))
match.in_port = ingress_port
- flow_mod_msg = message.flow_mod()
+ flow_mod_msg = ofp.message.flow_add()
flow_mod_msg.match = copy.deepcopy(match)
flow_mod_msg.cookie = random.randint(0,9007199254740992)
flow_mod_msg.buffer_id = 0xffffffff
@@ -143,7 +141,7 @@
flow_mod_msg.hard_timeout = 65000
flow_mod_msg.priority = 100
act.port = egress_port
- flow_mod_msg.actions.add(act)
+ flow_mod_msg.actions.append(act)
# send flow
logging.info("Inserting flow")
@@ -187,15 +185,15 @@
"Could not generate flow match from pkt")
match.in_port = ingress_port
- flow_mod_msg = message.flow_mod()
+ flow_mod_msg = ofp.message.flow_add()
flow_mod_msg.match = match
flow_mod_msg.cookie = random.randint(0,9007199254740992)
flow_mod_msg.buffer_id = 0xffffffff
flow_mod_msg.idle_timeout = 0
flow_mod_msg.hard_timeout = 0
- act = action.action_output()
+ act = ofp.action.output()
act.port = egress_port
- flow_mod_msg.actions.add(act)
+ flow_mod_msg.actions.append(act)
logging.info("Ingress " + str(ingress_port) +
" to egress " + str(egress_port))
@@ -204,7 +202,7 @@
def sumStatsReplyCounts(self, response):
total_packets = 0
- for obj in response.stats:
+ for obj in response.entries:
# TODO: pad1 and pad2 fields may be nonzero, is this a bug?
# for now, just clear them so the assert is simpler
#obj.match.pad1 = 0
@@ -217,7 +215,7 @@
return total_packets
def verifyStats(self, match, out_port, test_timeout, packet_count):
- stat_req = message.flow_stats_request()
+ stat_req = ofp.message.flow_stats_request()
stat_req.match = match
stat_req.table_id = 0xff
stat_req.out_port = out_port
@@ -263,7 +261,7 @@
pkt1 = simple_tcp_packet()
flow_mod_msg1 = self.buildFlowModMsg(pkt1, ingress_port, egress_port1)
- pkt2 = simple_tcp_packet(dl_src='0:7:7:7:7:7')
+ pkt2 = simple_tcp_packet(eth_src='0:7:7:7:7:7')
flow_mod_msg2 = self.buildFlowModMsg(pkt2, ingress_port, egress_port2)
logging.info("Inserting flow1")
@@ -312,15 +310,15 @@
"Could not generate flow match from pkt")
match.in_port = ingress_port
- flow_mod_msg = message.flow_mod()
+ flow_mod_msg = ofp.message.flow_add()
flow_mod_msg.match = match
flow_mod_msg.cookie = random.randint(0,9007199254740992)
flow_mod_msg.buffer_id = 0xffffffff
flow_mod_msg.idle_timeout = 0
flow_mod_msg.hard_timeout = 0
- act = action.action_output()
+ act = ofp.action.output()
act.port = egress_port
- flow_mod_msg.actions.add(act)
+ flow_mod_msg.actions.append(act)
logging.info("Ingress " + str(ingress_port) +
" to egress " + str(egress_port))
@@ -329,7 +327,7 @@
def verifyAggFlowStats(self, match, out_port, test_timeout,
flow_count, packet_count):
- stat_req = message.aggregate_stats_request()
+ stat_req = ofp.message.aggregate_stats_request()
stat_req.match = match
stat_req.table_id = 0xff
stat_req.out_port = out_port
@@ -341,15 +339,12 @@
timeout=test_timeout)
self.assertTrue(response is not None,
"No response to stats request")
- self.assertTrue(len(response.stats) == 1,
- "Did not receive flow stats reply")
- for obj in response.stats:
- self.assertTrue(obj.flow_count == flow_count,
- "Flow count " + str(obj.flow_count) +
- " does not match expected " + str(flow_count))
- logging.info("Received " + str(obj.packet_count) + " packets")
- if obj.packet_count == packet_count:
- all_packets_received = 1
+ self.assertTrue(response.flow_count == flow_count,
+ "Flow count " + str(response.flow_count) +
+ " does not match expected " + str(flow_count))
+ logging.info("Received " + str(response.packet_count) + " packets")
+ if response.packet_count == packet_count:
+ all_packets_received = 1
if all_packets_received:
break
@@ -374,7 +369,7 @@
pkt1 = simple_tcp_packet()
flow_mod_msg1 = self.buildFlowModMsg(pkt1, ingress_port, egress_port1)
- pkt2 = simple_tcp_packet(dl_src='0:7:7:7:7:7')
+ pkt2 = simple_tcp_packet(eth_src='0:7:7:7:7:7')
flow_mod_msg2 = self.buildFlowModMsg(pkt2, ingress_port, egress_port2)
logging.info("Inserting flow1")
@@ -413,9 +408,9 @@
"""
def runTest(self):
delete_all_flows(self.controller)
- match = ofp.ofp_match()
+ match = ofp.match()
match.wildcards = 0
- stat_req = message.flow_stats_request()
+ stat_req = ofp.message.flow_stats_request()
stat_req.match = match
stat_req.table_id = 0xff
stat_req.out_port = ofp.OFPP_NONE
@@ -423,7 +418,7 @@
response, pkt = self.controller.transact(stat_req)
self.assertTrue(response is not None,
"No response to stats request")
- self.assertEquals(len(response.stats), 0)
+ self.assertEquals(len(response.entries), 0)
self.assertEquals(response.flags, 0)
class EmptyAggregateStats(base_tests.SimpleDataPlane):
@@ -433,9 +428,9 @@
"""
def runTest(self):
delete_all_flows(self.controller)
- match = ofp.ofp_match()
+ match = ofp.match()
match.wildcards = 0
- stat_req = message.aggregate_stats_request()
+ stat_req = ofp.message.aggregate_stats_request()
stat_req.match = match
stat_req.table_id = 0xff
stat_req.out_port = ofp.OFPP_NONE
@@ -443,11 +438,9 @@
response, pkt = self.controller.transact(stat_req)
self.assertTrue(response is not None,
"No response to stats request")
- self.assertTrue(len(response.stats) == 1,
- "Did not receive flow stats reply")
- self.assertEquals(response.stats[0].flow_count, 0)
- self.assertEquals(response.stats[0].packet_count, 0)
- self.assertEquals(response.stats[0].byte_count, 0)
+ self.assertEquals(response.flow_count, 0)
+ self.assertEquals(response.packet_count, 0)
+ self.assertEquals(response.byte_count, 0)
class DeletedFlowStats(base_tests.SimpleDataPlane):
"""
@@ -476,7 +469,7 @@
match.wildcards &= ~ofp.OFPFW_IN_PORT
self.assertTrue(match is not None,
"Could not generate flow match from pkt")
- act = action.action_output()
+ act = ofp.action.output()
# build flow
ingress_port = of_ports[0];
@@ -484,7 +477,7 @@
logging.info("Ingress " + str(ingress_port) +
" to egress " + str(egress_port))
match.in_port = ingress_port
- flow_mod_msg = message.flow_mod()
+ flow_mod_msg = ofp.message.flow_add()
flow_mod_msg.match = copy.deepcopy(match)
flow_mod_msg.cookie = random.randint(0,9007199254740992)
flow_mod_msg.buffer_id = 0xffffffff
@@ -493,7 +486,7 @@
flow_mod_msg.priority = 100
flow_mod_msg.flags = ofp.OFPFF_SEND_FLOW_REM
act.port = egress_port
- flow_mod_msg.actions.add(act)
+ flow_mod_msg.actions.append(act)
# send flow
logging.info("Inserting flow")
diff --git a/tests/load.py b/tests/load.py
index 830aeed..4680edb 100644
--- a/tests/load.py
+++ b/tests/load.py
@@ -20,10 +20,8 @@
from oftest import config
import oftest.controller as controller
-import oftest.cstruct as ofp
-import oftest.message as message
+import ofp
import oftest.dataplane as dataplane
-import oftest.action as action
import oftest.parse as parse
import oftest.base_tests as base_tests
import time
@@ -60,30 +58,30 @@
match = packet_to_flow_match(self, pkt)
match.wildcards &= ~ofp.OFPFW_IN_PORT
match.in_port = lb_port
- act = action.action_output()
+ act = ofp.action.output()
act.port = lb_port + 1
- request = message.flow_mod()
+ request = ofp.message.flow_add()
request.match = match
request.hard_timeout = 2 * barrier_count
request.buffer_id = 0xffffffff
- request.actions.add(act)
+ request.actions.append(act)
- act = action.action_output()
+ act = ofp.action.output()
act.port = ofp.OFPP_CONTROLLER
- request.actions.add(act)
+ request.actions.append(act)
self.controller.message_send(request)
do_barrier(self.controller)
# Create packet out and send to port lb_port + 1
- msg = message.packet_out()
+ msg = ofp.message.packet_out()
msg.in_port = lb_port
msg.data = str(pkt)
- act = action.action_output()
+ act = ofp.action.output()
act.port = lb_port + 1
- msg.actions.add(act)
+ msg.actions.append(act)
logging.info("Sleeping before starting storm")
time.sleep(1) # Root causing issue with fast disconnects
logging.info("Sending packet out to %d" % (lb_port + 1))
@@ -167,12 +165,12 @@
(simple_eth_packet(pktlen=40), "tiny Ethernet packet")]:
logging.info("PKT OUT test with %s, port %s" % (opt, dp_port))
- msg = message.packet_out()
+ msg = ofp.message.packet_out()
msg.in_port = ofp.OFPP_NONE
msg.data = str(outpkt)
- act = action.action_output()
+ act = ofp.action.output()
act.port = dp_port
- msg.actions.add(act)
+ msg.actions.append(act)
logging.info("PacketOutLoad to: " + str(dp_port))
for count in range(100):
@@ -193,37 +191,35 @@
class FlowModLoad(base_tests.SimpleProtocol):
def checkBarrier(self):
- msg, pkt = self.controller.transact(message.barrier_request(), timeout=60)
+ msg, pkt = self.controller.transact(ofp.message.barrier_request(), timeout=60)
self.assertNotEqual(msg, None, "Barrier failed")
while self.controller.packets:
msg = self.controller.packets.pop(0)[0]
- self.assertNotEqual(msg.header.type, message.OFPT_ERROR,
- "Error received")
+ self.assertNotEqual(msg.type, ofp.OFPT_ERROR, "Error received")
def runTest(self):
- msg, pkt = self.controller.transact(message.table_stats_request())
+ msg, pkt = self.controller.transact(ofp.message.table_stats_request())
# Some switches report an extremely high max_entries that would cause
# us to run out of memory attempting to create all the flow-mods.
- num_flows = min(msg.stats[0].max_entries, 32678)
+ num_flows = min(msg.entries[0].max_entries, 32678)
logging.info("Creating %d flow-mods messages", num_flows)
requests = []
for i in range(num_flows):
- match = ofp.ofp_match()
+ match = ofp.match()
match.wildcards = ofp.OFPFW_ALL & ~ofp.OFPFW_DL_VLAN & ~ofp.OFPFW_DL_DST
- match.dl_vlan = ofp.OFP_VLAN_NONE
- match.dl_dst = [0, 1, 2, 3, i / 256, i % 256]
- act = action.action_output()
+ match.vlan_vid = ofp.OFP_VLAN_NONE
+ match.eth_dst = [0, 1, 2, 3, i / 256, i % 256]
+ act = ofp.action.output()
act.port = ofp.OFPP_CONTROLLER
- request = message.flow_mod()
- request.command = ofp.OFPFC_ADD
+ request = ofp.message.flow_add()
request.buffer_id = 0xffffffff
request.priority = num_flows - i
request.out_port = ofp.OFPP_NONE
request.match = match
- request.actions.add(act)
+ request.actions.append(act)
requests.append(request)
for i in range(3):
diff --git a/tests/message_types.py b/tests/message_types.py
index fe19f61..599764a 100644
--- a/tests/message_types.py
+++ b/tests/message_types.py
@@ -11,10 +11,8 @@
from oftest import config
import oftest.controller as controller
-import oftest.cstruct as ofp
-import oftest.message as message
+import ofp
import oftest.dataplane as dataplane
-import oftest.action as action
import oftest.parse as parse
import oftest.base_tests as base_tests
import time
@@ -24,7 +22,7 @@
from FuncUtils import*
-
+@disabled
class HelloWithBody(base_tests.SimpleDataPlane):
"""Verify switch should be able to receive OFPT_HELLO messages with body ,
@@ -36,7 +34,7 @@
#Send Hello message
logging.info("Sending Hello...")
- request = message.hello()
+ request = ofp.message.hello()
request.data = 'OpenFlow Will Rule The World'
self.controller.message_send(request)
@@ -47,7 +45,7 @@
self.assertTrue(response is not None,
'Switch did not exchange hello message in return')
self.assertEqual(len(response.data), 0, 'Response data field non-empty')
- self.assertTrue(response.header.version == 0x01, 'Openflow-version field is not 1.0.0')
+ self.assertTrue(response.version == 0x01, 'Openflow-version field is not 1.0.0')
class EchoWithData(base_tests.SimpleProtocol):
@@ -61,7 +59,7 @@
#Send Echo Request
logging.info("Sending Echo With Data ...")
- request = message.echo_request()
+ request = ofp.message.echo_request()
request.data = 'OpenFlow Will Rule The World'
self.controller.message_send(request)
@@ -71,9 +69,9 @@
timeout=1)
self.assertTrue(response is not None,
"Did not get echo reply (with data)")
- self.assertEqual(response.header.type, ofp.OFPT_ECHO_REPLY,
+ self.assertEqual(response.type, ofp.OFPT_ECHO_REPLY,
'Response is not echo_reply')
- self.assertEqual(request.header.xid, response.header.xid,
+ self.assertEqual(request.xid, response.xid,
'Response xid does not match the request Xid')
self.assertEqual(request.data, response.data,
'Response data does not match request data')
@@ -96,8 +94,8 @@
#Send Echo Request
logging.info("Sending a Echo request with a version which is not supported by the switch")
- request=message.echo_request()
- request.header.version=0
+ request=ofp.message.echo_request()
+ request.version=0
self.controller.message_send(request)
logging.info("Waiting for a OFPT_ERROR msg on the control plane...")
@@ -105,7 +103,7 @@
timeout=5)
self.assertTrue(response is not None,
'Switch did not reply with error message')
- self.assertTrue(response.type==ofp.OFPET_BAD_REQUEST,
+ self.assertTrue(response.err_type==ofp.OFPET_BAD_REQUEST,
'Message field type is not OFPET_BAD_REQUEST')
self.assertTrue(response.code==ofp.OFPBRC_BAD_VERSION,
'Message field code is not OFPBRC_BAD_VERSION')
@@ -125,11 +123,11 @@
# Sending Features_Request
logging.info("Sending Features_Request...")
- request = message.features_request()
+ request = ofp.message.features_request()
(reply, pkt) = self.controller.transact(request)
self.assertTrue(reply is not None, "Failed to get any reply")
- self.assertEqual(reply.header.type, ofp.OFPT_FEATURES_REPLY,'Response is not Features_reply')
- self.assertEqual(reply.header.xid,request.header.xid,'Transaction id does not match')
+ self.assertEqual(reply.type, ofp.OFPT_FEATURES_REPLY,'Response is not Features_reply')
+ self.assertEqual(reply.xid,request.xid,'Transaction id does not match')
supported_actions =[]
if(reply.actions &1<<ofp.OFPAT_OUTPUT):
@@ -207,14 +205,14 @@
#Send get_config_request
logging.info("Sending Get Config Request...")
- request = message.get_config_request()
+ request = ofp.message.get_config_request()
(reply, pkt) = self.controller.transact(request)
#Verify get_config_reply is recieved
logging.info("Expecting GetConfigReply ")
self.assertTrue(reply is not None, "Failed to get any reply")
- self.assertEqual(reply.header.type, ofp.OFPT_GET_CONFIG_REPLY,'Response is not Config Reply')
- self.assertEqual(reply.header.xid,request.header.xid,'Transaction id does not match')
+ self.assertEqual(reply.type, ofp.OFPT_GET_CONFIG_REPLY,'Response is not Config Reply')
+ self.assertEqual(reply.xid,request.xid,'Transaction id does not match')
if reply.miss_send_len == 0 :
logging.info ("the switch must send zero-size packet_in message")
@@ -243,10 +241,10 @@
#Send get_config_request -- retrive miss_send_len field
logging.info("Sending Get Config Request ")
- request = message.get_config_request()
+ request = ofp.message.get_config_request()
(reply, pkt) = self.controller.transact(request)
self.assertTrue(reply is not None, "Failed to get any reply")
- self.assertEqual(reply.header.type, ofp.OFPT_GET_CONFIG_REPLY,'Response is not Config Reply')
+ self.assertEqual(reply.type, ofp.OFPT_GET_CONFIG_REPLY,'Response is not Config Reply')
miss_send_len = 0
miss_send_len = reply.miss_send_len
@@ -255,7 +253,7 @@
#Send set_config_request --- set a different miss_sen_len field and flag
logging.info("Sending Set Config Request...")
- req = message.set_config()
+ req = ofp.message.set_config()
if miss_send_len < 65400 :# Max miss_send len is 65535
req.miss_send_len = miss_send_len + 100
@@ -275,11 +273,11 @@
#Send get_config_request -- verify change came into effect
logging.info("Sending Get Config Request...")
- request = message.get_config_request()
+ request = ofp.message.get_config_request()
(rep, pkt) = self.controller.transact(request)
self.assertTrue(rep is not None, "Failed to get any reply")
- self.assertEqual(rep.header.type, ofp.OFPT_GET_CONFIG_REPLY,'Response is not Config Reply')
+ self.assertEqual(rep.type, ofp.OFPT_GET_CONFIG_REPLY,'Response is not Config Reply')
self.assertEqual(rep.miss_send_len,new_miss_send_len, "miss_send_len configuration parameter could not be set")
self.assertEqual(rep.flags,new_flags, "frag flags could not be set")
@@ -304,7 +302,7 @@
miss_send_len = [0 ,32 ,64,100]
for bytes in miss_send_len :
- req = message.set_config()
+ req = ofp.message.set_config()
req.miss_send_len = bytes
self.controller.message_send(req)
sleep(1)
@@ -360,13 +358,13 @@
for bytes in max_len :
#Insert a flow entry with action --output to controller
- request = message.flow_mod()
+ request = ofp.message.flow_add()
request.match = match
request.buffer_id = 0xffffffff
- act = action.action_output()
+ act = ofp.action.output()
act.port = ofp.OFPP_CONTROLLER
act.max_len = bytes
- request.actions.add(act)
+ request.actions.append(act)
logging.info("Inserting flow....")
self.controller.message_send(request)
@@ -407,7 +405,7 @@
#Set miss_send_len field
logging.info("Sending set_config_request to set miss_send_len... ")
- req = message.set_config()
+ req = ofp.message.set_config()
req.miss_send_len = 65535
self.controller.message_send(req)
sleep(1)
@@ -459,12 +457,12 @@
match.in_port = of_ports[0]
#Insert a flow entry with action output to controller
- request = message.flow_mod()
+ request = ofp.message.flow_add()
request.match = match
- act = action.action_output()
+ act = ofp.action.output()
act.port = ofp.OFPP_CONTROLLER
act.max_len = 65535 # Send the complete packet and do not buffer
- request.actions.add(act)
+ request.actions.append(act)
logging.info("Inserting flow....")
self.controller.message_send(request)
@@ -674,30 +672,16 @@
logging.info("Running DescStatsGet test")
logging.info("Sending stats request")
- request = message.desc_stats_request()
+ request = ofp.message.desc_stats_request()
response, pkt = self.controller.transact(request)
self.assertTrue(response is not None,
"Did not get reply for desc stats")
-
- mfr_desc = ""
- hw_desc = ""
- sw_dec = ""
- serial_num = ""
- dp_decription = ""
- for stats in response.stats:
-
- mfr_desc += stats.mfr_desc
- hw_desc += stats.hw_desc
- sw_dec += stats.sw_desc
- serial_num += stats.serial_num
- dp_decription += stats.dp_desc
-
- logging.info("Manufacture Description :" + mfr_desc)
- logging.info("Hardware description : " + hw_desc)
- logging.info("Software Description :" + sw_dec)
- logging.info("Serial number :" + serial_num)
- logging.info("Human readable description of datapath :" + dp_decription)
+ logging.info("Manufacture Description :" + response.mfr_desc)
+ logging.info("Hardware description : " + response.hw_desc)
+ logging.info("Software Description :" + response.sw_desc)
+ logging.info("Serial number :" + response.serial_num)
+ logging.info("Human readable description of datapath :" + response.dp_desc)
@@ -714,15 +698,15 @@
of_ports.sort()
logging.info("Sending Queue Config Request ...")
- request = message.queue_get_config_request()
+ request = ofp.message.queue_get_config_request()
request.port = of_ports[0]
response, pkt = self.controller.transact(request)
self.assertTrue(response is not None,
"Did not get reply ")
- self.assertTrue(response.header.type == ofp.OFPT_QUEUE_GET_CONFIG_REPLY, "Reply is not Queue Config Reply")
+ self.assertTrue(response.type == ofp.OFPT_QUEUE_GET_CONFIG_REPLY, "Reply is not Queue Config Reply")
#Verify Reply Body
- self.assertEqual(response.header.xid, request.header.xid , "Transaction Id in reply is not same as request")
+ self.assertEqual(response.xid, request.xid , "Transaction Id in reply is not same as request")
self.assertEqual(response.port,request.port , "Port queried does not match ")
queues = []
queues = response.queues
diff --git a/tests/nicira_dec_ttl.py b/tests/nicira_dec_ttl.py
index 013eae7..f5e8214 100644
--- a/tests/nicira_dec_ttl.py
+++ b/tests/nicira_dec_ttl.py
@@ -2,25 +2,11 @@
import struct
from oftest import config
-import of10 as ofp
+import ofp
import oftest.base_tests as base_tests
from oftest.testutils import *
-class action_nx_dec_ttl(ofp.action.action_vendor):
- def __init__(self):
- ofp.action.action_vendor.__init__(self)
- self.vendor = 0x00002320
-
- def pack(self):
- return ofp.action.action_vendor.pack(self) + struct.pack("!HHL", 18, 0x0, 0x0)
-
- def __len__(self):
- return 16
-
- def show(self, prefix=''):
- return prefix + 'dec_ttl: ' + '\n' + ofp.action.action_vendor.show(self)
-
@nonstandard
class TtlDecrement(base_tests.SimpleDataPlane):
def runTest(self):
@@ -35,17 +21,17 @@
flow_match_test(self, config["port_map"],
pkt=simple_tcp_packet(pktlen=100, ip_ttl=2),
exp_pkt=simple_tcp_packet(pktlen=100, ip_ttl=1),
- action_list=[action_nx_dec_ttl()])
+ action_list=[ofp.action.nicira_dec_ttl()])
outpkt = simple_tcp_packet(pktlen=100, ip_ttl=3)
msg = ofp.message.packet_out(in_port=ofp.OFPP_NONE,
data=str(outpkt),
actions=[
- action_nx_dec_ttl(),
+ ofp.action.nicira_dec_ttl(),
ofp.action.output(port=portA),
- action_nx_dec_ttl(),
+ ofp.action.nicira_dec_ttl(),
ofp.action.output(port=portB),
- action_nx_dec_ttl(),
+ ofp.action.nicira_dec_ttl(),
ofp.action.output(port=portC)])
self.controller.message_send(msg)
diff --git a/tests/nicira_role.py b/tests/nicira_role.py
index fa4cc97..1122a7b 100644
--- a/tests/nicira_role.py
+++ b/tests/nicira_role.py
@@ -6,18 +6,12 @@
from oftest import config
import oftest.controller as controller
-import oftest.cstruct as ofp
-import oftest.message as message
+import ofp
import oftest.base_tests as base_tests
from oftest.testutils import *
-# Nicira vendor extension constants
-NXT_VENDOR = 0x00002320
-
-NXT_ROLE_REQUEST = 10
-
-NXT_ROLE_VALUE = dict( other=0, slave=1, master=2 )
+NX_ROLE_MASTER = 2
@nonstandard
class NiciraRoleRequest(base_tests.SimpleDataPlane):
@@ -25,21 +19,10 @@
Exercise Nicira vendor extension for requesting HA roles
"""
- def nicira_role_request(self, role):
- """
- Use the BSN_SET_IP_MASK vendor command to change the IP mask for the
- given wildcard index
- """
- logging.info("Sending role request %s" % role)
- m = message.vendor()
- m.vendor = NXT_VENDOR
- m.data = struct.pack("!LL", NXT_ROLE_REQUEST, NXT_ROLE_VALUE[role])
- return m
-
def runTest(self):
'''
For now, we only verify that a response is received.
'''
- request = self.nicira_role_request("master")
+ request = ofp.message.nicira_controller_role_request(role=NX_ROLE_MASTER)
response, pkt = self.controller.transact(request)
self.assertTrue(response is not None, "No reply to Nicira role request")
diff --git a/tests/openflow_protocol_messages.py b/tests/openflow_protocol_messages.py
index b182015..c961f2e 100644
--- a/tests/openflow_protocol_messages.py
+++ b/tests/openflow_protocol_messages.py
@@ -12,10 +12,8 @@
from oftest import config
import oftest.controller as controller
-import oftest.cstruct as ofp
-import oftest.message as message
+import ofp
import oftest.dataplane as dataplane
-import oftest.action as action
import oftest.parse as parse
import oftest.base_tests as base_tests
@@ -41,7 +39,7 @@
logging.info("Sending Features_Request")
logging.info("Expecting Features_Reply")
- request = message.features_request()
+ request = ofp.message.features_request()
self.controller.message_send(request)
(response, pkt) = self.controller.poll(exp_msg=ofp.OFPT_FEATURES_REPLY,
@@ -69,7 +67,7 @@
logging.info("Sending OFPT_GET_CONFIG_REQUEST ")
logging.info("Expecting OFPT_GET_CONFIG_REPLY ")
- request = message.get_config_request()
+ request = ofp.message.get_config_request()
self.controller.message_send(request)
(response, pkt) = self.controller.poll(exp_msg=ofp.OFPT_GET_CONFIG_REPLY,
@@ -219,11 +217,11 @@
(simple_eth_packet(), "simple Ethernet packet"),
(simple_eth_packet(pktlen=40), "tiny Ethernet packet")]:
- msg = message.packet_out()
+ msg = ofp.message.packet_out()
msg.data = str(outpkt)
- act = action.action_output()
+ act = ofp.action.output()
act.port = dp_port
- msg.actions.add(act)
+ msg.actions.append(act)
logging.info("PacketOut to: " + str(dp_port))
self.controller.message_send(msg)
@@ -297,12 +295,12 @@
logging.info("Expecting a Hello on the control plane with version--1.0.0")
#Send Hello message
- request = message.hello()
+ request = ofp.message.hello()
(response, pkt) = self.controller.poll(exp_msg=ofp.OFPT_HELLO,
timeout=1)
self.assertTrue(response is not None,
'Switch did not exchange hello message in return')
- self.assertTrue(response.header.version == 0x01, 'switch openflow-version field is not 1.0.0')
+ self.assertTrue(response.version == 0x01, 'switch openflow-version field is not 1.0.0')
@@ -320,12 +318,12 @@
logging.info("Expecting a Echo Reply with version--1.0.0 and same xid")
# Send echo_request
- request = message.echo_request()
+ request = ofp.message.echo_request()
(response, pkt) = self.controller.transact(request)
- self.assertEqual(response.header.type, ofp.OFPT_ECHO_REPLY,'response is not echo_reply')
- self.assertEqual(request.header.xid, response.header.xid,
+ self.assertEqual(response.type, ofp.OFPT_ECHO_REPLY,'response is not echo_reply')
+ self.assertEqual(request.xid, response.xid,
'response xid != request xid')
- self.assertTrue(response.header.version == 0x01, 'switch openflow-version field is not 1.0.1')
+ self.assertTrue(response.version == 0x01, 'switch openflow-version field is not 1.0.1')
self.assertEqual(len(response.data), 0, 'response data non-empty')
@@ -343,10 +341,10 @@
logging.info("Expecting a Barrier Reply with same xid")
#Send Barrier Request
- request = message.barrier_request()
+ request = ofp.message.barrier_request()
(response,pkt) = self.controller.transact(request)
- self.assertEqual(response.header.type, ofp.OFPT_BARRIER_REPLY,'response is not barrier_reply')
- self.assertEqual(request.header.xid, response.header.xid,
+ self.assertEqual(response.type, ofp.OFPT_BARRIER_REPLY,'response is not barrier_reply')
+ self.assertEqual(request.xid, response.xid,
'response xid != request xid')
diff --git a/tests/pktact.py b/tests/pktact.py
index fe92aa0..829a90e 100644
--- a/tests/pktact.py
+++ b/tests/pktact.py
@@ -21,10 +21,8 @@
from oftest import config
import oftest.controller as controller
-import oftest.cstruct as ofp
-import oftest.message as message
+import ofp
import oftest.dataplane as dataplane
-import oftest.action as action
import oftest.parse as parse
import oftest.base_tests as base_tests
import basic # for IterCases
@@ -106,7 +104,7 @@
match.wildcards &= ~ofp.OFPFW_IN_PORT
self.assertTrue(match is not None,
"Could not generate flow match from pkt")
- act = action.action_output()
+ act = ofp.action.output()
for idx in range(len(of_ports)):
delete_all_flows(self.controller)
@@ -118,12 +116,12 @@
match.in_port = ingress_port
- request = message.flow_mod()
+ request = ofp.message.flow_add()
request.match = match
request.buffer_id = 0xffffffff
act.port = egress_port
- request.actions.add(act)
+ request.actions.append(act)
logging.info("Inserting flow")
self.controller.message_send(request)
@@ -175,20 +173,20 @@
match.wildcards &= ~ofp.OFPFW_IN_PORT
self.assertTrue(match is not None,
"Could not generate flow match from pkt")
- act = action.action_output()
+ act = ofp.action.output()
delete_all_flows(self.controller)
ingress_port = of_ports[0]
match.in_port = ingress_port
- request = message.flow_mod()
+ request = ofp.message.flow_add()
request.match = match
request.buffer_id = 0xffffffff
act.port = ofp.OFPP_CONTROLLER
act.max_len = 65535
- request.actions.add(act)
+ request.actions.append(act)
logging.info("Inserting flow")
self.controller.message_send(request)
@@ -225,7 +223,7 @@
def portQueuesGet(self, queue_stats, port_num):
result = []
- for qs in queue_stats.stats:
+ for qs in queue_stats.entries:
if qs.port_no != port_num:
continue
result.append(qs.queue_id)
@@ -247,13 +245,13 @@
# Get queue stats from switch
- request = message.queue_stats_request()
+ request = ofp.message.queue_stats_request()
request.port_no = ofp.OFPP_ALL
request.queue_id = ofp.OFPQ_ALL
(queue_stats, p) = self.controller.transact(request)
self.assertNotEqual(queue_stats, None, "Queue stats request failed")
- act = action.action_enqueue()
+ act = ofp.action.enqueue()
for idx in range(len(of_ports)):
ingress_port = of_ports[idx]
@@ -269,13 +267,13 @@
match.in_port = ingress_port
- request = message.flow_mod()
+ request = ofp.message.flow_add()
request.match = match
request.buffer_id = 0xffffffff
act.port = egress_port
act.queue_id = egress_queue_id
- request.actions.add(act)
+ request.actions.append(act)
logging.info("Inserting flow")
self.controller.message_send(request)
@@ -283,7 +281,7 @@
# Get current stats for selected egress queue
- request = message.queue_stats_request()
+ request = ofp.message.queue_stats_request()
request.port_no = egress_port
request.queue_id = egress_queue_id
(qs_before, p) = self.controller.transact(request)
@@ -315,7 +313,7 @@
# Get current stats for selected egress queue again
- request = message.queue_stats_request()
+ request = ofp.message.queue_stats_request()
request.port_no = egress_port
request.queue_id = egress_queue_id
(qs_after, p) = self.controller.transact(request)
@@ -324,8 +322,8 @@
# Make sure that tx packet counter for selected egress queue was
# incremented
- self.assertEqual(qs_after.stats[0].tx_packets, \
- qs_before.stats[0].tx_packets + 1, \
+ self.assertEqual(qs_after.entries[0].tx_packets, \
+ qs_before.entries[0].tx_packets + 1, \
"Verification of egress queue tx packet count failed"
)
@@ -347,7 +345,7 @@
def portQueuesGet(self, queue_stats, port_num):
result = []
- for qs in queue_stats.stats:
+ for qs in queue_stats.entries:
if qs.port_no != port_num:
continue
result.append(qs.queue_id)
@@ -369,16 +367,16 @@
# Get queue stats from switch
- request = message.queue_stats_request()
+ request = ofp.message.queue_stats_request()
request.port_no = ofp.OFPP_CONTROLLER
request.queue_id = ofp.OFPQ_ALL
(queue_stats, p) = self.controller.transact(request)
self.assertNotEqual(queue_stats, None, "Queue stats request failed")
- if queue_stats.header.type == ofp.OFPT_ERROR:
+ if queue_stats.type == ofp.OFPT_ERROR:
skip_message_emit(self, "Enqueue packet to controller")
return
- act = action.action_enqueue()
+ act = ofp.action.enqueue()
for idx in range(len(of_ports)):
ingress_port = of_ports[idx]
@@ -398,13 +396,13 @@
match.in_port = ingress_port
- request = message.flow_mod()
+ request = ofp.message.flow_add()
request.match = match
request.buffer_id = 0xffffffff
act.port = egress_port
act.queue_id = egress_queue_id
- request.actions.add(act)
+ request.actions.append(act)
logging.info("Inserting flow")
self.controller.message_send(request)
@@ -412,7 +410,7 @@
# Get current stats for selected egress queue
- request = message.queue_stats_request()
+ request = ofp.message.queue_stats_request()
request.port_no = egress_port
request.queue_id = egress_queue_id
(qs_before, p) = self.controller.transact(request)
@@ -454,7 +452,7 @@
# Get current stats for selected egress queue again
- request = message.queue_stats_request()
+ request = ofp.message.queue_stats_request()
request.port_no = egress_port
request.queue_id = egress_queue_id
(qs_after, p) = self.controller.transact(request)
@@ -463,8 +461,8 @@
# Make sure that tx packet counter for selected egress queue was
# incremented
- self.assertEqual(qs_after.stats[0].tx_packets, \
- qs_before.stats[0].tx_packets + 1, \
+ self.assertEqual(qs_after.entries[0].tx_packets, \
+ qs_before.entries[0].tx_packets + 1, \
"Verification of egress queue tx packet count failed"
)
@@ -503,7 +501,6 @@
match.wildcards &= ~ofp.OFPFW_IN_PORT
self.assertTrue(match is not None,
"Could not generate flow match from pkt")
- act = action.action_output()
for idx in range(len(of_ports)):
delete_all_flows(self.controller)
@@ -517,13 +514,11 @@
match.in_port = ingress_port
- request = message.flow_mod()
+ request = ofp.message.flow_add()
request.match = match
request.buffer_id = 0xffffffff
- act.port = egress_port1
- request.actions.add(act)
- act.port = egress_port2
- request.actions.add(act)
+ request.actions.append(ofp.action.output(port=egress_port1))
+ request.actions.append(ofp.action.output(port=egress_port2))
# logging.info(request.show())
logging.info("Inserting flow")
@@ -561,7 +556,6 @@
match.wildcards &= ~ofp.OFPFW_IN_PORT
self.assertTrue(match is not None,
"Could not generate flow match from pkt")
- act = action.action_output()
for ingress_port in of_ports:
delete_all_flows(self.controller)
@@ -570,14 +564,13 @@
" all non-ingress ports")
match.in_port = ingress_port
- request = message.flow_mod()
+ request = ofp.message.flow_add()
request.match = match
request.buffer_id = 0xffffffff
for egress_port in of_ports:
if egress_port == ingress_port:
continue
- act.port = egress_port
- request.actions.add(act)
+ request.actions.append(ofp.action.output(port=egress_port))
logging.debug(request.show())
logging.info("Inserting flow")
@@ -613,7 +606,6 @@
match.wildcards &= ~ofp.OFPFW_IN_PORT
self.assertTrue(match is not None,
"Could not generate flow match from pkt")
- act = action.action_output()
for ingress_port in of_ports:
delete_all_flows(self.controller)
@@ -621,15 +613,16 @@
logging.info("Ingress " + str(ingress_port) + " to all ports")
match.in_port = ingress_port
- request = message.flow_mod()
+ request = ofp.message.flow_add()
request.match = match
request.buffer_id = 0xffffffff
for egress_port in of_ports:
+ act = ofp.action.output()
if egress_port == ingress_port:
act.port = ofp.OFPP_IN_PORT
else:
act.port = egress_port
- request.actions.add(act)
+ request.actions.append(act)
# logging.info(request.show())
logging.info("Inserting flow")
@@ -661,7 +654,7 @@
match.wildcards &= ~ofp.OFPFW_IN_PORT
self.assertTrue(match is not None,
"Could not generate flow match from pkt")
- act = action.action_output()
+ act = ofp.action.output()
for of_port in of_ports:
# Clear relevant bits that might block ports
@@ -677,11 +670,11 @@
logging.info("Ingress " + str(ingress_port) + " to all ports")
match.in_port = ingress_port
- request = message.flow_mod()
+ request = ofp.message.flow_add()
request.match = match
request.buffer_id = 0xffffffff
act.port = ofp.OFPP_FLOOD
- request.actions.add(act)
+ request.actions.append(act)
logging.info(request.show())
logging.info("Inserting flow")
@@ -715,7 +708,6 @@
match.wildcards &= ~ofp.OFPFW_IN_PORT
self.assertTrue(match is not None,
"Could not generate flow match from pkt")
- act = action.action_output()
for ingress_port in of_ports:
delete_all_flows(self.controller)
@@ -723,13 +715,11 @@
logging.info("Ingress " + str(ingress_port) + " to all ports")
match.in_port = ingress_port
- request = message.flow_mod()
+ request = ofp.message.flow_add()
request.match = match
request.buffer_id = 0xffffffff
- act.port = ofp.OFPP_FLOOD
- request.actions.add(act)
- act.port = ofp.OFPP_IN_PORT
- request.actions.add(act)
+ request.actions.append(ofp.action.output(port=ofp.OFPP_FLOOD))
+ request.actions.append(ofp.action.output(port=ofp.OFPP_IN_PORT))
logging.info(request.show())
logging.info("Inserting flow")
@@ -760,7 +750,7 @@
match.wildcards &= ~ofp.OFPFW_IN_PORT
self.assertTrue(match is not None,
"Could not generate flow match from pkt")
- act = action.action_output()
+ act = ofp.action.output()
for ingress_port in of_ports:
delete_all_flows(self.controller)
@@ -768,11 +758,11 @@
logging.info("Ingress " + str(ingress_port) + " to all ports")
match.in_port = ingress_port
- request = message.flow_mod()
+ request = ofp.message.flow_add()
request.match = match
request.buffer_id = 0xffffffff
act.port = ofp.OFPP_ALL
- request.actions.add(act)
+ request.actions.append(act)
logging.info(request.show())
logging.info("Inserting flow")
@@ -806,7 +796,6 @@
match.wildcards &= ~ofp.OFPFW_IN_PORT
self.assertTrue(match is not None,
"Could not generate flow match from pkt")
- act = action.action_output()
for ingress_port in of_ports:
delete_all_flows(self.controller)
@@ -814,13 +803,11 @@
logging.info("Ingress " + str(ingress_port) + " to all ports")
match.in_port = ingress_port
- request = message.flow_mod()
+ request = ofp.message.flow_add()
request.match = match
request.buffer_id = 0xffffffff
- act.port = ofp.OFPP_ALL
- request.actions.add(act)
- act.port = ofp.OFPP_IN_PORT
- request.actions.add(act)
+ request.actions.append(ofp.action.output(port=ofp.OFPP_ALL))
+ request.actions.append(ofp.action.output(port=ofp.OFPP_IN_PORT))
logging.info(request.show())
logging.info("Inserting flow")
@@ -853,7 +840,7 @@
match.wildcards &= ~ofp.OFPFW_IN_PORT
self.assertTrue(match is not None,
"Could not generate flow match from pkt")
- act = action.action_output()
+ act = ofp.action.output()
# Clear OFPPC_NO_FLOOD on each port
for of_port in of_ports:
@@ -873,11 +860,11 @@
match.in_port = ingress_port
- request = message.flow_mod()
+ request = ofp.message.flow_add()
request.match = match
request.buffer_id = 0xffffffff
act.port = ofp.OFPP_FLOOD
- request.actions.add(act)
+ request.actions.append(act)
logging.info(request.show())
logging.info("Inserting flow")
@@ -937,7 +924,7 @@
def runTest(self):
vid = test_param_get('vid', default=TEST_VID_DEFAULT)
- flow_match_test(self, config["port_map"], dl_vlan=vid)
+ flow_match_test(self, config["port_map"], vlan_vid=vid)
@disabled
class ExactMatchTaggedMany(BaseMatchCase):
@@ -947,10 +934,10 @@
def runTest(self):
for vid in range(2,100,10):
- flow_match_test(self, config["port_map"], dl_vlan=vid, max_test=5)
+ flow_match_test(self, config["port_map"], vlan_vid=vid, max_test=5)
for vid in range(100,4000,389):
- flow_match_test(self, config["port_map"], dl_vlan=vid, max_test=5)
- flow_match_test(self, config["port_map"], dl_vlan=4094, max_test=5)
+ flow_match_test(self, config["port_map"], vlan_vid=vid, max_test=5)
+ flow_match_test(self, config["port_map"], vlan_vid=4094, max_test=5)
class SingleWildcardMatchPriority(BaseMatchCase):
"""
@@ -1035,10 +1022,10 @@
def removeFlow(self, prio):
if self.flowMsgs.has_key(prio):
- msg = self.flowMsgs[prio]
- msg.command = ofp.OFPFC_DELETE_STRICT
- # This *must* be set for DELETE
- msg.out_port = ofp.OFPP_NONE
+ old_msg = self.flowMsgs[prio]
+ msg = ofp.message.flow_delete_strict(out_port=ofp.OFPP_NONE,
+ match=old_msg.match,
+ priority=old_msg.priority)
logging.debug("Remove flow with priority " + str(prio))
self.controller.message_send(msg)
do_barrier(self.controller)
@@ -1174,11 +1161,11 @@
wc |= required_wildcards(self)
if wc & ofp.OFPFW_DL_VLAN:
# Set nonzero VLAN id to avoid sending priority-tagged packet
- dl_vlan = vid
+ vlan_vid = vid
else:
- dl_vlan = -1
+ vlan_vid = -1
flow_match_test(self, config["port_map"], wildcards=wc,
- dl_vlan=dl_vlan, max_test=10)
+ vlan_vid=vlan_vid, max_test=10)
class SingleWildcardMatchTagged(BaseMatchCase):
"""
@@ -1188,7 +1175,7 @@
vid = test_param_get('vid', default=TEST_VID_DEFAULT)
for wc in WILDCARD_VALUES:
wc |= required_wildcards(self)
- flow_match_test(self, config["port_map"], wildcards=wc, dl_vlan=vid,
+ flow_match_test(self, config["port_map"], wildcards=wc, vlan_vid=vid,
max_test=10)
class AllExceptOneWildcardMatch(BaseMatchCase):
@@ -1208,11 +1195,11 @@
all_exp_one_wildcard |= required_wildcards(self)
if all_exp_one_wildcard & ofp.OFPFW_DL_VLAN:
# Set nonzero VLAN id to avoid sending priority-tagged packet
- dl_vlan = vid
+ vlan_vid = vid
else:
- dl_vlan = -1
+ vlan_vid = -1
flow_match_test(self, config["port_map"], wildcards=all_exp_one_wildcard,
- dl_vlan=dl_vlan)
+ vlan_vid=vlan_vid)
class AllExceptOneWildcardMatchTagged(BaseMatchCase):
"""
@@ -1223,7 +1210,7 @@
for all_exp_one_wildcard in NO_WILDCARD_VALUES:
all_exp_one_wildcard |= required_wildcards(self)
flow_match_test(self, config["port_map"], wildcards=all_exp_one_wildcard,
- dl_vlan=vid)
+ vlan_vid=vid)
class AllWildcardMatch(BaseMatchCase):
"""
@@ -1246,7 +1233,7 @@
def runTest(self):
vid = test_param_get('vid', default=TEST_VID_DEFAULT)
flow_match_test(self, config["port_map"], wildcards=ofp.OFPFW_ALL,
- dl_vlan=vid)
+ vlan_vid=vid)
@group('smoke')
class AddVLANTag(BaseMatchCase):
@@ -1264,8 +1251,8 @@
len_w_vid = 104
pkt = simple_tcp_packet(pktlen=len)
exp_pkt = simple_tcp_packet(pktlen=len_w_vid, dl_vlan_enable=True,
- dl_vlan=new_vid)
- vid_act = action.action_set_vlan_vid()
+ vlan_vid=new_vid)
+ vid_act = ofp.action.set_vlan_vid()
vid_act.vlan_vid = new_vid
flow_match_test(self, config["port_map"], pkt=pkt,
@@ -1294,7 +1281,7 @@
def runTest(self):
vid = test_param_get('vid', default=TEST_VID_DEFAULT)
- pkt = simple_tcp_packet(dl_vlan_enable=True, dl_vlan=vid)
+ pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=vid)
of_ports = config["port_map"].keys()
of_ports.sort()
ing_port = of_ports[0]
@@ -1318,9 +1305,9 @@
skip_message_emit(self, "Modify VLAN tag test")
return
- pkt = simple_tcp_packet(dl_vlan_enable=True, dl_vlan=old_vid)
- exp_pkt = simple_tcp_packet(dl_vlan_enable=True, dl_vlan=new_vid)
- vid_act = action.action_set_vlan_vid()
+ pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=old_vid)
+ exp_pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=new_vid)
+ vid_act = ofp.action.set_vlan_vid()
vid_act.vlan_vid = new_vid
flow_match_test(self, config["port_map"], pkt=pkt, exp_pkt=exp_pkt,
@@ -1337,7 +1324,7 @@
class ModifyVIDWithTagMatchWildcarded(BaseMatchCase):
"""
- With vlan ID and priority wildcarded, perform SET_VLAN_VID action.
+ With vlan ID and priority wildcarded, perform SET_VLAN_VID ofp.action.
The same flow should match on both untagged and tagged packets.
"""
def runTest(self):
@@ -1359,12 +1346,12 @@
len_w_vid = 104
untagged_pkt = simple_tcp_packet(pktlen=len_untagged)
tagged_pkt = simple_tcp_packet(pktlen=len_w_vid,
- dl_vlan_enable=True, dl_vlan=old_vid)
+ dl_vlan_enable=True, vlan_vid=old_vid)
exp_pkt = simple_tcp_packet(pktlen=len_w_vid, dl_vlan_enable=True,
- dl_vlan=new_vid)
+ vlan_vid=new_vid)
wildcards = (required_wildcards(self) | ofp.OFPFW_DL_VLAN |
ofp.OFPFW_DL_VLAN_PCP)
- vid_act = action.action_set_vlan_vid()
+ vid_act = ofp.action.set_vlan_vid()
vid_act.vlan_vid = new_vid
request = flow_msg_create(self, untagged_pkt, ing_port=ing_port,
wildcards=wildcards, egr_ports=egr_ports,
@@ -1394,9 +1381,9 @@
skip_message_emit(self, "Modify VLAN priority test")
return
- pkt = simple_tcp_packet(dl_vlan_enable=True, dl_vlan=vid, dl_vlan_pcp=old_vlan_pcp)
- exp_pkt = simple_tcp_packet(dl_vlan_enable=True, dl_vlan=vid, dl_vlan_pcp=new_vlan_pcp)
- vid_act = action.action_set_vlan_pcp()
+ pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=vid, vlan_pcp=old_vlan_pcp)
+ exp_pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=vid, vlan_pcp=new_vlan_pcp)
+ vid_act = ofp.action.set_vlan_pcp()
vid_act.vlan_pcp = new_vlan_pcp
flow_match_test(self, config["port_map"], pkt=pkt, exp_pkt=exp_pkt,
@@ -1416,9 +1403,9 @@
len_w_vid = 104
len = 100
pkt = simple_tcp_packet(pktlen=len_w_vid, dl_vlan_enable=True,
- dl_vlan=old_vid)
+ vlan_vid=old_vid)
exp_pkt = simple_tcp_packet(pktlen=len)
- vid_act = action.action_strip_vlan()
+ vid_act = ofp.action.strip_vlan()
flow_match_test(self, config["port_map"], pkt=pkt, exp_pkt=exp_pkt,
action_list=[vid_act])
@@ -1438,11 +1425,11 @@
len_w_vid = 104
len_untagged = 100
pkt = simple_tcp_packet(pktlen=len_w_vid, dl_vlan_enable=True,
- dl_vlan=old_vid)
+ vlan_vid=old_vid)
exp_pkt = simple_tcp_packet(pktlen=len_untagged)
wildcards = (required_wildcards(self) | ofp.OFPFW_DL_VLAN |
ofp.OFPFW_DL_VLAN_PCP)
- vid_act = action.action_strip_vlan()
+ vid_act = ofp.action.strip_vlan()
flow_match_test(self, config["port_map"],
wildcards=wildcards,
@@ -1454,13 +1441,13 @@
Pass back a dictionary with default packet arguments
"""
args = {}
- args["dl_src"] = '00:23:45:67:89:AB'
+ args["eth_src"] = '00:23:45:67:89:AB'
dl_vlan_enable=False
- dl_vlan=-1
+ vlan_vid=-1
if config["test-params"]["vid"]:
dl_vlan_enable=True
- dl_vlan = config["test-params"]["vid"]
+ vlan_vid = config["test-params"]["vid"]
# Unpack operator is ** on a dictionary
@@ -1476,7 +1463,7 @@
skip_message_emit(self, "ModifyL2Src test")
return
- (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['dl_src'],
+ (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['eth_src'],
check_test_params=True)
flow_match_test(self, config["port_map"], pkt=pkt, exp_pkt=exp_pkt,
action_list=acts, max_test=2)
@@ -1491,7 +1478,7 @@
skip_message_emit(self, "ModifyL2dst test")
return
- (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['dl_dst'],
+ (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['eth_dst'],
check_test_params=True)
flow_match_test(self, config["port_map"], pkt=pkt, exp_pkt=exp_pkt,
action_list=acts, max_test=2)
@@ -1611,7 +1598,7 @@
skip_message_emit(self, "ModifyL2dstMC test")
return
- (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['dl_dst'],
+ (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['eth_dst'],
check_test_params=True)
flow_match_test(self, config["port_map"], pkt=pkt, exp_pkt=exp_pkt,
action_list=acts, max_test=2, egr_count=-1)
@@ -1626,7 +1613,7 @@
skip_message_emit(self, "ModifyL2dstIngress test")
return
- (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['dl_dst'],
+ (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['eth_dst'],
check_test_params=True)
flow_match_test(self, config["port_map"], pkt=pkt, exp_pkt=exp_pkt,
action_list=acts, max_test=2, egr_count=0,
@@ -1642,7 +1629,7 @@
skip_message_emit(self, "ModifyL2dstMC test")
return
- (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['dl_dst'],
+ (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['eth_dst'],
check_test_params=True)
flow_match_test(self, config["port_map"], pkt=pkt, exp_pkt=exp_pkt,
action_list=acts, max_test=2, egr_count=-1,
@@ -1658,7 +1645,7 @@
skip_message_emit(self, "ModifyL2SrcMC test")
return
- (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['dl_src'],
+ (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['eth_src'],
check_test_params=True)
flow_match_test(self, config["port_map"], pkt=pkt, exp_pkt=exp_pkt,
action_list=acts, max_test=2, egr_count=-1)
@@ -1674,7 +1661,7 @@
skip_message_emit(self, "ModifyL2SrcDstMC test")
return
- mod_fields = ['dl_dst', 'dl_src']
+ mod_fields = ['eth_dst', 'eth_src']
(pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=mod_fields,
check_test_params=True)
flow_match_test(self, config["port_map"], pkt=pkt, exp_pkt=exp_pkt,
@@ -1691,7 +1678,7 @@
skip_message_emit(self, "ModifyL2DstVIDMC test")
return
- mod_fields = ['dl_dst', 'dl_vlan']
+ mod_fields = ['eth_dst', 'vlan_vid']
(pkt, exp_pkt, acts) = pkt_action_setup(self,
start_field_vals={'dl_vlan_enable':True}, mod_fields=mod_fields,
check_test_params=True)
@@ -1707,11 +1694,11 @@
sup_acts = self.supported_actions
sup_map = {
- "dl_dst" : ofp.OFPAT_SET_DL_DST,
- "dl_src" : ofp.OFPAT_SET_DL_SRC,
+ "eth_dst" : ofp.OFPAT_SET_DL_DST,
+ "eth_src" : ofp.OFPAT_SET_DL_SRC,
"dl_vlan_enable" : ofp.OFPAT_SET_VLAN_VID,
- "dl_vlan" : ofp.OFPAT_SET_VLAN_VID,
- "dl_vlan_pcp" : ofp.OFPAT_SET_VLAN_PCP,
+ "vlan_vid" : ofp.OFPAT_SET_VLAN_VID,
+ "vlan_pcp" : ofp.OFPAT_SET_VLAN_PCP,
"ip_src" : ofp.OFPAT_SET_NW_SRC,
"ip_dst" : ofp.OFPAT_SET_NW_DST,
"ip_tos" : ofp.OFPAT_SET_NW_TOS,
@@ -1751,8 +1738,8 @@
logging.info("Running flow toggle with %d flows, %d iterations" %
(flow_count, iter_count))
acts = []
- acts.append(action.action_output())
- acts.append(action.action_output())
+ acts.append(ofp.action.output())
+ acts.append(ofp.action.output())
of_ports = config["port_map"].keys()
if len(of_ports) < 3:
@@ -1771,14 +1758,13 @@
for toggle in range(2):
for f_idx in range(flow_count):
pkt = simple_tcp_packet(tcp_sport=f_idx)
- msg = message.flow_mod()
+ msg = ofp.message.flow_add()
match = packet_to_flow_match(self, pkt)
match.in_port = of_ports[2]
match.wildcards = wildcards
msg.match = match
msg.buffer_id = 0xffffffff
- msg.command = ofp.OFPFC_ADD
- msg.actions.add(acts[toggle])
+ msg.actions.append(acts[toggle])
flows[toggle].append(msg)
# Show two sample flows
@@ -1923,7 +1909,7 @@
delete_all_flows(self.controller)
- pkt = simple_tcp_packet(dl_vlan_enable=True, dl_vlan=2)
+ pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=2)
ingress_port = of_ports[0]
egress_port = of_ports[1]
@@ -1943,13 +1929,13 @@
else:
new = ~orig & mask
setattr(match, field, new)
- request = message.flow_mod()
+ request = ofp.message.flow_add()
request.match = match
request.buffer_id = 0xffffffff
request.priority = priority
- act = action.action_output()
+ act = ofp.action.output()
act.port = output_port
- request.actions.add(act)
+ request.actions.append(act)
logging.info("Inserting flow")
self.controller.message_send(request)
@@ -1979,26 +1965,26 @@
wildcards = required_wildcards(self)
# TODO in_port
if not (wildcards & ofp.OFPFW_DL_SRC):
- testField("dl_src", [0xff]*6)
+ testField("eth_src", [0xff]*6)
if not (wildcards & ofp.OFPFW_DL_DST):
- testField("dl_dst", [0xff]*6)
+ testField("eth_dst", [0xff]*6)
if not (wildcards & ofp.OFPFW_DL_TYPE):
- testField("dl_type", 0xffff)
+ testField("eth_type", 0xffff)
if not (wildcards & ofp.OFPFW_DL_VLAN):
- testField("dl_vlan", 0xfff)
- # TODO dl_vlan_pcp
+ testField("vlan_vid", 0xfff)
+ # TODO vlan_pcp
if not (wildcards & ofp.OFPFW_NW_SRC_ALL):
- testField("nw_src", 0xffffffff)
+ testField("ipv4_src", 0xffffffff)
if not (wildcards & ofp.OFPFW_NW_DST_ALL):
- testField("nw_dst", 0xffffffff)
+ testField("ipv4_dst", 0xffffffff)
if not (wildcards & ofp.OFPFW_NW_TOS):
- testField("nw_tos", 0x3f)
+ testField("ip_dscp", 0x3f)
if not (wildcards & ofp.OFPFW_NW_PROTO):
- testField("nw_proto", 0xff)
+ testField("ip_proto", 0xff)
if not (wildcards & ofp.OFPFW_TP_SRC):
- testField("tp_src", 0xffff)
+ testField("tcp_src", 0xffff)
if not (wildcards & ofp.OFPFW_TP_DST):
- testField("tp_dst", 0xffff)
+ testField("tcp_dst", 0xffff)
class DirectBadPacketBase(base_tests.SimpleDataPlane):
"""
@@ -2028,19 +2014,19 @@
# - action
def createMatch(self, **kwargs):
- match = ofp.ofp_match()
+ match = ofp.match()
match.wildcards = ofp.OFPFW_ALL
fields = {
- 'dl_dst': ofp.OFPFW_DL_DST,
- 'dl_src': ofp.OFPFW_DL_SRC,
- 'dl_type': ofp.OFPFW_DL_TYPE,
- 'dl_vlan': ofp.OFPFW_DL_VLAN,
- 'nw_src': ofp.OFPFW_NW_SRC_MASK,
- 'nw_dst': ofp.OFPFW_NW_DST_MASK,
- 'nw_tos': ofp.OFPFW_NW_TOS,
- 'nw_proto': ofp.OFPFW_NW_PROTO,
- 'tp_src': ofp.OFPFW_TP_SRC,
- 'tp_dst': ofp.OFPFW_TP_DST,
+ 'eth_dst': ofp.OFPFW_DL_DST,
+ 'eth_src': ofp.OFPFW_DL_SRC,
+ 'eth_type': ofp.OFPFW_DL_TYPE,
+ 'vlan_vid': ofp.OFPFW_DL_VLAN,
+ 'ipv4_src': ofp.OFPFW_NW_SRC_MASK,
+ 'ipv4_dst': ofp.OFPFW_NW_DST_MASK,
+ 'ip_dscp': ofp.OFPFW_NW_TOS,
+ 'ip_proto': ofp.OFPFW_NW_PROTO,
+ 'tcp_src': ofp.OFPFW_TP_SRC,
+ 'tcp_dst': ofp.OFPFW_TP_DST,
}
for key in kwargs:
setattr(match, key, kwargs[key])
@@ -2073,29 +2059,29 @@
match.in_port = ingress_port
- request = message.flow_mod()
+ request = ofp.message.flow_add()
request.match = match
request.priority = 1
request.buffer_id = 0xffffffff
for act in acts:
act.port = egress_port
- request.actions.add(act)
+ request.actions.append(act)
logging.info("Inserting flow")
self.controller.message_send(request)
# This flow speeds up negative tests
logging.info("Inserting catch-all flow")
- request2 = message.flow_mod()
+ request2 = ofp.message.flow_add()
request2.match = self.createMatch()
request2.match.wildcards &= ~ofp.OFPFW_IN_PORT
request2.match.in_port = ingress_port
request2.priority = 0
- act = action.action_output()
+ act = ofp.action.output()
act.port = ofp.OFPP_IN_PORT
- request2.actions.add(act)
+ request2.actions.append(act)
self.controller.message_send(request2)
do_barrier(self.controller)
@@ -2155,8 +2141,8 @@
pass
def runTestWithProto(self, protoName = 'TCP'):
- dl_dst='00:01:02:03:04:05'
- dl_src='00:06:07:08:09:0a'
+ eth_dst='00:01:02:03:04:05'
+ eth_src='00:06:07:08:09:0a'
ip_src='192.168.0.1'
ip_dst='192.168.0.2'
ip_tos=0
@@ -2174,7 +2160,7 @@
else:
raise Exception("Passed in unknown proto name")
- match_pkt = scapy.Ether(dst=dl_dst, src=dl_src)/ \
+ match_pkt = scapy.Ether(dst=eth_dst, src=eth_src)/ \
scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos)/ \
tp(sport=tcp_sport, dport=tcp_dport)
match = packet_to_flow_match(self, match_pkt)
@@ -2183,7 +2169,7 @@
match.wildcards &= ~ofp.OFPFW_IN_PORT
def testPacket(title, pkt, result):
- act = action.action_output()
+ act = ofp.action.output()
pkts = [
[title, pkt, result]
]
@@ -2191,32 +2177,32 @@
# Try incomplete IP headers
testPacket("Incomplete IP header (1 bytes)",
- scapy.Ether(dst=dl_dst, src=dl_src)/ \
+ scapy.Ether(dst=eth_dst, src=eth_src)/ \
str(scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, proto=proto))[0:1],
self.RESULT_NOMATCH,
)
testPacket("Incomplete IP header (2 bytes)",
- scapy.Ether(dst=dl_dst, src=dl_src)/ \
+ scapy.Ether(dst=eth_dst, src=eth_src)/ \
str(scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, proto=proto))[0:2],
self.RESULT_NOMATCH,
)
testPacket("Incomplete IP header (3 bytes)",
- scapy.Ether(dst=dl_dst, src=dl_src)/ \
+ scapy.Ether(dst=eth_dst, src=eth_src)/ \
str(scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, proto=proto))[0:3],
self.RESULT_NOMATCH,
)
testPacket("Incomplete IP header (12 bytes)",
- scapy.Ether(dst=dl_dst, src=dl_src)/ \
+ scapy.Ether(dst=eth_dst, src=eth_src)/ \
str(scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, proto=proto))[0:12],
self.RESULT_NOMATCH,
)
testPacket("Incomplete IP header (16 bytes)",
- scapy.Ether(dst=dl_dst, src=dl_src)/ \
+ scapy.Ether(dst=eth_dst, src=eth_src)/ \
str(scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, proto=proto))[0:16],
self.RESULT_NOMATCH,
)
testPacket("Incomplete IP header (19 bytes)",
- scapy.Ether(dst=dl_dst, src=dl_src)/ \
+ scapy.Ether(dst=eth_dst, src=eth_src)/ \
str(scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, proto=proto))[0:19],
self.RESULT_NOMATCH,
)
@@ -2226,29 +2212,29 @@
# we initiatlize once with a non-matching full packet and once with a
# matching full packet.
testPacket("Non-Matching TCP packet, warming buffer",
- scapy.Ether(dst=dl_dst, src=dl_src)/ \
+ scapy.Ether(dst=eth_dst, src=eth_src)/ \
scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, proto=proto)/ \
tp(sport=tcp_sport, dport=tcp_dport + 1),
self.RESULT_NOMATCH,
)
testPacket("Missing TCP header, buffer warmed with non-match",
- scapy.Ether(dst=dl_dst, src=dl_src)/ \
+ scapy.Ether(dst=eth_dst, src=eth_src)/ \
scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, proto=proto),
self.RESULT_NOMATCH,
)
testPacket("Matching TCP packet, warming buffer",
- scapy.Ether(dst=dl_dst, src=dl_src)/ \
+ scapy.Ether(dst=eth_dst, src=eth_src)/ \
scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, proto=proto)/ \
tp(sport=tcp_sport, dport=tcp_dport),
self.RESULT_MATCH,
)
testPacket("Missing TCP header, buffer warmed with match",
- scapy.Ether(dst=dl_dst, src=dl_src)/ \
+ scapy.Ether(dst=eth_dst, src=eth_src)/ \
scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, proto=proto),
self.RESULT_NOMATCH,
)
testPacket("Truncated TCP header: 2 bytes",
- scapy.Ether(dst=dl_dst, src=dl_src)/ \
+ scapy.Ether(dst=eth_dst, src=eth_src)/ \
scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, proto=proto)/ \
(str(tp(sport=tcp_sport, dport=tcp_dport))[0:2]),
self.RESULT_NOMATCH,
@@ -2278,27 +2264,27 @@
self.RESULT_NOMATCH,
)
testPacket("Missing TCP header, corrupt ihl",
- scapy.Ether(dst=dl_dst, src=dl_src)/ \
+ scapy.Ether(dst=eth_dst, src=eth_src)/ \
scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, ihl=0xf, proto=proto),
self.RESULT_NOMATCH,
)
testPacket("Missing TCP header, corrupt total length",
- scapy.Ether(dst=dl_dst, src=dl_src)/ \
+ scapy.Ether(dst=eth_dst, src=eth_src)/ \
scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, proto=proto, len= 100),
self.RESULT_NOMATCH,
)
testPacket("Missing TCP header, corrupt ihl and total length",
- scapy.Ether(dst=dl_dst, src=dl_src)/ \
+ scapy.Ether(dst=eth_dst, src=eth_src)/ \
scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, ihl=0xf, proto=proto, len=43),
self.RESULT_NOMATCH,
)
testPacket("Incomplete IP header (12 bytes), corrupt ihl and total length",
- scapy.Ether(dst=dl_dst, src=dl_src)/ \
+ scapy.Ether(dst=eth_dst, src=eth_src)/ \
str(scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, proto=proto, ihl=10, len=43))[0:12],
self.RESULT_NOMATCH,
)
testPacket("Incomplete IP header (16 bytes), corrupt ihl and total length",
- scapy.Ether(dst=dl_dst, src=dl_src)/ \
+ scapy.Ether(dst=eth_dst, src=eth_src)/ \
str(scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, proto=proto, ihl=10, len=43))[0:16],
self.RESULT_NOMATCH,
)
@@ -2307,7 +2293,7 @@
# destination ports. As that is all we care about during matching, some
# implementations may match and some may drop the packet
testPacket("Incomplete TCP header: src/dst port present",
- scapy.Ether(dst=dl_dst, src=dl_src)/ \
+ scapy.Ether(dst=eth_dst, src=eth_src)/ \
scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, proto=proto)/ \
(str(tp(sport=tcp_sport, dport=tcp_dport))[0:4]),
self.RESULT_ANY,
@@ -2316,7 +2302,7 @@
for i in range(1):
for length in range(40 / 4): # IPv4 options are a maximum of 40 in length
bytes = "".join([("%c" % random.randint(0, 255)) for x in range(length * 4)])
- eth = scapy.Ether(dst=dl_dst, src=dl_src)
+ eth = scapy.Ether(dst=eth_dst, src=eth_src)
ip = scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, ihl=5 + length, proto=proto)
tcp = tp(sport=tcp_sport, dport=tcp_dport+1)
pkt = eth / ip
@@ -2327,7 +2313,7 @@
self.RESULT_NOMATCH
)
- eth = scapy.Ether(dst=dl_dst, src=dl_src)
+ eth = scapy.Ether(dst=eth_dst, src=eth_src)
ip = scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, ihl=5 + length, proto=proto)
tcp = tp(sport=tcp_sport, dport=tcp_dport)
pkt = eth / ip
@@ -2359,8 +2345,8 @@
Verify LLC/SNAP parsing and matching. Focus on packet corruptions
"""
def runTest(self):
- dl_dst='00:01:02:03:04:05'
- dl_src='00:06:07:08:09:0a'
+ eth_dst='00:01:02:03:04:05'
+ eth_src='00:06:07:08:09:0a'
ip_src='192.168.0.1'
ip_dst='192.168.0.2'
ip_tos=0
@@ -2372,19 +2358,19 @@
IS_NOT_SNAP_IP = 3
def testPacketTcpMatch(title, llc):
- match_pkt = scapy.Ether(dst=dl_dst, src=dl_src)/ \
+ match_pkt = scapy.Ether(dst=eth_dst, src=eth_src)/ \
scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos)/ \
scapy.TCP(sport=tcp_sport, dport=tcp_dport)
match = packet_to_flow_match(self, match_pkt)
self.assertTrue(match is not None,
"Could not generate flow match from pkt")
match.wildcards &= ~ofp.OFPFW_IN_PORT
- act = action.action_output()
+ act = ofp.action.output()
self.testPktsAgainstFlow(
[[
"TCP match - LLC frame correct length - %s" % title,
- scapy.Ether(dst=dl_dst, src=dl_src, type=len(llc)) / llc,
+ scapy.Ether(dst=eth_dst, src=eth_src, type=len(llc)) / llc,
self.RESULT_ANY,
]],
act, match
@@ -2395,7 +2381,7 @@
self.testPktsAgainstFlow(
[[
"TCP match - LLC frame corrupted length - %s" % title,
- scapy.Ether(dst=dl_dst, src=dl_src, type=ethLen) / llc,
+ scapy.Ether(dst=eth_dst, src=eth_src, type=ethLen) / llc,
self.RESULT_ANY,
]],
act, match
@@ -2403,7 +2389,7 @@
def testPacketEthSrcDstMatch(title, llc):
# Matching based on Ethernet source and destination
- match_pkt = scapy.Ether(dst=dl_dst, src=dl_src)
+ match_pkt = scapy.Ether(dst=eth_dst, src=eth_src)
match = packet_to_flow_match(self, match_pkt)
self.assertTrue(match is not None,
"Could not generate flow match from pkt")
@@ -2412,10 +2398,10 @@
self.testPktsAgainstFlow(
[[
"Eth addr match - LLC frame correct length- %s" % title,
- scapy.Ether(dst=dl_dst, src=dl_src, type=len(llc)) / llc,
+ scapy.Ether(dst=eth_dst, src=eth_src, type=len(llc)) / llc,
self.RESULT_MATCH,
]],
- action.action_output(), match
+ ofp.action.output(), match
)
# Corrupt length field
@@ -2423,15 +2409,15 @@
self.testPktsAgainstFlow(
[[
"Eth addr match - LLC frame corrupted length- %s" % title,
- scapy.Ether(dst=dl_dst, src=dl_src, type=ethLen) / llc,
+ scapy.Ether(dst=eth_dst, src=eth_src, type=ethLen) / llc,
self.RESULT_ANY,
]],
- action.action_output(), match
+ ofp.action.output(), match
)
def testPacketEthSrcDstTypeMatch(title, llc, is_snap_ip):
# Matching based on Ethernet source, destination and type
- match_pkt = scapy.Ether(dst=dl_dst, src=dl_src, type=0x800)
+ match_pkt = scapy.Ether(dst=eth_dst, src=eth_src, type=0x800)
match = packet_to_flow_match(self, match_pkt)
self.assertTrue(match is not None,
"Could not generate flow match from pkt")
@@ -2445,10 +2431,10 @@
self.testPktsAgainstFlow(
[[
"Eth addr+type match - LLC frame correct length - %s" % title,
- scapy.Ether(dst=dl_dst, src=dl_src, type=len(llc)) / llc,
+ scapy.Ether(dst=eth_dst, src=eth_src, type=len(llc)) / llc,
is_match,
]],
- action.action_output(), match
+ ofp.action.output(), match
)
# Corrupt length field
@@ -2456,10 +2442,10 @@
self.testPktsAgainstFlow(
[[
"Eth addr+type match - LLC frame corrupted length - %s" % title,
- scapy.Ether(dst=dl_dst, src=dl_src, type=ethLen) / llc,
+ scapy.Ether(dst=eth_dst, src=eth_src, type=ethLen) / llc,
self.RESULT_ANY,
]],
- action.action_output(), match
+ ofp.action.output(), match
)
def testPacket(title, llc, is_snap_ip):
@@ -2512,8 +2498,8 @@
Verify LLC/SNAP parsing (valid and corrupted packets) and matching
"""
def runTest(self):
- dl_dst='00:01:02:03:04:05'
- dl_src='00:06:07:08:09:0a'
+ eth_dst='00:01:02:03:04:05'
+ eth_src='00:06:07:08:09:0a'
ip_src='192.168.0.1'
ip_dst='192.168.0.2'
ip_tos=0
@@ -2526,7 +2512,7 @@
IS_NOT_SNAP = 3
def testPacketEthTypeIP(title, llc, is_snap):
- match_pkt = scapy.Ether(dst=dl_dst, src=dl_src, type=0x800)
+ match_pkt = scapy.Ether(dst=eth_dst, src=eth_src, type=0x800)
match = packet_to_flow_match(self, match_pkt)
self.assertTrue(match is not None,
"Could not generate flow match from pkt")
@@ -2538,14 +2524,14 @@
result = self.RESULT_MATCH
pkts.append([
"Ether type 0x800 match - %s" % title,
- scapy.Ether(dst=dl_dst, src=dl_src, type=len(llc)) / llc,
+ scapy.Ether(dst=eth_dst, src=eth_src, type=len(llc)) / llc,
result,
])
- act = action.action_output()
+ act = ofp.action.output()
self.testPktsAgainstFlow(pkts, act, match)
def testPacketEthTypeNotEth(title, llc, is_snap):
- match_pkt = scapy.Ether(dst = dl_dst, src = dl_src,
+ match_pkt = scapy.Ether(dst = eth_dst, src = eth_src,
type = ofp.OFP_DL_TYPE_NOT_ETH_TYPE)
match = packet_to_flow_match(self, match_pkt)
self.assertTrue(match is not None,
@@ -2558,10 +2544,10 @@
result = self.RESULT_NOMATCH
pkts.append([
"Ether type OFP_DL_TYPE_NOT_ETH_TYPE match - %s" % title,
- scapy.Ether(dst=dl_dst, src=dl_src, type=len(llc)) / llc,
+ scapy.Ether(dst=eth_dst, src=eth_src, type=len(llc)) / llc,
result,
])
- act = action.action_output()
+ act = ofp.action.output()
self.testPktsAgainstFlow(pkts, act, match)
def testPacket(title, llc, is_snap):
@@ -2625,8 +2611,8 @@
self.testArpHandling()
def testArpHandling(self):
- dl_dst='00:01:02:03:04:05'
- dl_src='00:06:07:08:09:0a'
+ eth_dst='00:01:02:03:04:05'
+ eth_src='00:06:07:08:09:0a'
ip_src='192.168.0.1'
ip_dst='192.168.0.2'
ip_src2='192.168.1.1'
@@ -2638,7 +2624,7 @@
def testPacket(title, arp_match, arp_pkt, result):
pkts = []
- match_pkt = scapy.Ether(dst=dl_dst, src=dl_src) / arp_match
+ match_pkt = scapy.Ether(dst=eth_dst, src=eth_src) / arp_match
match = packet_to_flow_match(self, match_pkt)
self.assertTrue(match is not None,
"Could not generate flow match from pkt")
@@ -2646,16 +2632,16 @@
pkts.append([
title,
- scapy.Ether(dst=dl_dst, src=dl_src) / arp_pkt,
+ scapy.Ether(dst=eth_dst, src=eth_src) / arp_pkt,
result,
])
- act = action.action_output()
+ act = ofp.action.output()
self.testPktsAgainstFlow(pkts, act, match)
testPacket("Basic ARP",
scapy.ARP(psrc=ip_src, pdst=ip_dst, op = 1),
- scapy.ARP(hwdst = '00:00:00:00:00:00', hwsrc = dl_src,
+ scapy.ARP(hwdst = '00:00:00:00:00:00', hwsrc = eth_src,
psrc = ip_src, pdst = ip_dst, hwlen = 6, plen = 4,
ptype = 0x800, hwtype = 1, op = 1),
self.RESULT_MATCH
@@ -2672,8 +2658,8 @@
Verify VLAN parsing (valid and corrupted packets) and ARP matching
"""
def runTest(self):
- dl_dst='00:01:02:03:04:05'
- dl_src='00:06:07:08:09:0a'
+ eth_dst='00:01:02:03:04:05'
+ eth_src='00:06:07:08:09:0a'
ip_src='192.168.0.1'
ip_dst='192.168.0.2'
ip_src2='192.168.1.1'
@@ -2695,65 +2681,65 @@
result,
])
- act = action.action_output()
+ act = ofp.action.output()
self.testPktsAgainstFlow(pkts, act, match)
testPacket("Basic MAC matching - IPv4 payload",
- self.createMatch(dl_dst=parse_mac(dl_dst), dl_src=parse_mac(dl_src)),
- scapy.Ether(dst=dl_dst, src=dl_src, type=0x800) / scapy.IP(),
+ self.createMatch(eth_dst=parse_mac(eth_dst), eth_src=parse_mac(eth_src)),
+ scapy.Ether(dst=eth_dst, src=eth_src, type=0x800) / scapy.IP(),
self.RESULT_MATCH
)
testPacket("Basic MAC matching - VMware beacon - no payload",
- self.createMatch(dl_dst=parse_mac(dl_dst), dl_src=parse_mac(dl_src)),
- scapy.Ether(dst=dl_dst, src=dl_src, type=0x8922),
+ self.createMatch(eth_dst=parse_mac(eth_dst), eth_src=parse_mac(eth_src)),
+ scapy.Ether(dst=eth_dst, src=eth_src, type=0x8922),
self.RESULT_MATCH
)
testPacket("Basic MAC matching - VMware beacon - with payload",
- self.createMatch(dl_dst=parse_mac(dl_dst), dl_src=parse_mac(dl_src)),
- scapy.Ether(dst=dl_dst, src=dl_src, type=0x8922)/ ("X" * 1),
+ self.createMatch(eth_dst=parse_mac(eth_dst), eth_src=parse_mac(eth_src)),
+ scapy.Ether(dst=eth_dst, src=eth_src, type=0x8922)/ ("X" * 1),
self.RESULT_MATCH
)
testPacket("Basic MAC matching - IPv6 payload",
- self.createMatch(dl_dst=parse_mac(dl_dst), dl_src=parse_mac(dl_src)),
- scapy.Ether(dst=dl_dst, src=dl_src) / scapy.IPv6(),
+ self.createMatch(eth_dst=parse_mac(eth_dst), eth_src=parse_mac(eth_src)),
+ scapy.Ether(dst=eth_dst, src=eth_src) / scapy.IPv6(),
self.RESULT_MATCH
)
testPacket("Basic MAC matching with VLAN tag present",
- self.createMatch(dl_dst=parse_mac(dl_dst), dl_src=parse_mac(dl_src)),
- scapy.Ether(dst=dl_dst, src=dl_src)/ \
+ self.createMatch(eth_dst=parse_mac(eth_dst), eth_src=parse_mac(eth_src)),
+ scapy.Ether(dst=eth_dst, src=eth_src)/ \
scapy.Dot1Q(prio=5, vlan=1000)/ \
scapy.IP(),
self.RESULT_MATCH
)
testPacket("Basic MAC matching with VLAN tag present",
- self.createMatch(dl_dst=parse_mac(dl_dst), dl_src=parse_mac(dl_src),
- dl_type=0x800),
- scapy.Ether(dst=dl_dst, src=dl_src)/ \
+ self.createMatch(eth_dst=parse_mac(eth_dst), eth_src=parse_mac(eth_src),
+ eth_type=0x800),
+ scapy.Ether(dst=eth_dst, src=eth_src)/ \
scapy.Dot1Q(prio=5, vlan=1000)/ \
scapy.IP(),
self.RESULT_MATCH
)
testPacket("Ether matching with VLAN tag present - No type match",
- self.createMatch(dl_dst=parse_mac(dl_dst), dl_src=parse_mac(dl_src),
- dl_type=0x801),
- scapy.Ether(dst=dl_dst, src=dl_src)/ \
+ self.createMatch(eth_dst=parse_mac(eth_dst), eth_src=parse_mac(eth_src),
+ eth_type=0x801),
+ scapy.Ether(dst=eth_dst, src=eth_src)/ \
scapy.Dot1Q(prio=5, vlan=1000)/ \
scapy.IP(),
self.RESULT_NOMATCH
)
testPacket("Ether matching with VLAN tag present - No type match 0x8100",
- self.createMatch(dl_dst=parse_mac(dl_dst), dl_src=parse_mac(dl_src),
- dl_type=0x8100),
- scapy.Ether(dst=dl_dst, src=dl_src)/ \
+ self.createMatch(eth_dst=parse_mac(eth_dst), eth_src=parse_mac(eth_src),
+ eth_type=0x8100),
+ scapy.Ether(dst=eth_dst, src=eth_src)/ \
scapy.Dot1Q(prio=5, vlan=1000)/ \
scapy.IP(),
self.RESULT_NOMATCH
)
testPacket("IP matching - VLAN tag",
- self.createMatch(dl_dst=parse_mac(dl_dst), dl_src=parse_mac(dl_src),
- dl_type=0x0800,
- nw_src=parse_ip(ip_src), nw_dst=parse_ip(ip_dst)),
- scapy.Ether(dst=dl_dst, src=dl_src)/ \
+ self.createMatch(eth_dst=parse_mac(eth_dst), eth_src=parse_mac(eth_src),
+ eth_type=0x0800,
+ ipv4_src=parse_ip(ip_src), ipv4_dst=parse_ip(ip_dst)),
+ scapy.Ether(dst=eth_dst, src=eth_src)/ \
scapy.Dot1Q(prio=5, vlan=1000)/ \
scapy.IP(src=ip_src, dst=ip_dst),
self.RESULT_MATCH
@@ -2769,8 +2755,8 @@
the treatment of these cases, so broken out to be non-standard
"""
def runTest(self):
- dl_dst='00:01:02:03:04:05'
- dl_src='00:06:07:08:09:0a'
+ eth_dst='00:01:02:03:04:05'
+ eth_src='00:06:07:08:09:0a'
ip_src='192.168.0.1'
ip_dst='192.168.0.2'
ip_src2='192.168.1.1'
@@ -2792,21 +2778,21 @@
result,
])
- act = action.action_output()
+ act = ofp.action.output()
self.testPktsAgainstFlow(pkts, act, match)
testPacket("Ether matching with double VLAN tag - Wrong type match",
- self.createMatch(dl_dst=parse_mac(dl_dst), dl_src=parse_mac(dl_src),
- dl_type=0x800),
- scapy.Ether(dst=dl_dst, src=dl_src)/ \
+ self.createMatch(eth_dst=parse_mac(eth_dst), eth_src=parse_mac(eth_src),
+ eth_type=0x800),
+ scapy.Ether(dst=eth_dst, src=eth_src)/ \
scapy.Dot1Q(prio=5, vlan=1000)/ \
scapy.Dot1Q(prio=3, vlan=1005)/ \
scapy.IP(),
self.RESULT_NOMATCH
)
testPacket("Ether matching with double VLAN tag - Type match",
- self.createMatch(dl_dst=parse_mac(dl_dst), dl_src=parse_mac(dl_src),
- dl_type=0x8100),
- scapy.Ether(dst=dl_dst, src=dl_src)/ \
+ self.createMatch(eth_dst=parse_mac(eth_dst), eth_src=parse_mac(eth_src),
+ eth_type=0x8100),
+ scapy.Ether(dst=eth_dst, src=eth_src)/ \
scapy.Dot1Q(prio=5, vlan=1000)/ \
scapy.Dot1Q(prio=3, vlan=1005)/ \
scapy.IP(),
diff --git a/tests/port_stats.py b/tests/port_stats.py
index 5e0648f..7fac164 100644
--- a/tests/port_stats.py
+++ b/tests/port_stats.py
@@ -11,10 +11,8 @@
from oftest import config
import oftest.controller as controller
-import oftest.cstruct as ofp
-import oftest.message as message
+import ofp
import oftest.dataplane as dataplane
-import oftest.action as action
import oftest.parse as parse
import oftest.base_tests as base_tests
@@ -62,16 +60,16 @@
'Response packet does not match send packet')
def getStats(obj, port):
- stat_req = message.port_stats_request()
+ stat_req = ofp.message.port_stats_request()
stat_req.port_no = port
logging.info("Sending stats request")
response, pkt = obj.controller.transact(stat_req, timeout=2)
obj.assertTrue(response is not None,
"No response to stats request")
- obj.assertTrue(len(response.stats) == 1,
+ obj.assertTrue(len(response.entries) == 1,
"Did not receive port stats reply")
- for item in response.stats:
+ for item in response.entries:
logging.info("Sent " + str(item.tx_packets) + " packets")
packet_sent = item.tx_packets
packet_recv = item.rx_packets
@@ -79,22 +77,22 @@
return packet_sent, packet_recv
def getAllStats(obj):
- stat_req = message.port_stats_request()
+ stat_req = ofp.message.port_stats_request()
stat_req.port_no = ofp.OFPP_NONE
logging.info("Sending all port stats request")
response, pkt = obj.controller.transact(stat_req, timeout=2)
obj.assertTrue(response is not None,
"No response to stats request")
- obj.assertTrue(len(response.stats) >= 3,
+ obj.assertTrue(len(response.entries) >= 3,
"Did not receive all port stats reply")
stats = {}
- for item in response.stats:
+ for item in response.entries:
stats[ item.port_no ] = ( item.tx_packets, item.rx_packets )
return stats
def verifyStats(obj, port, test_timeout, packet_sent, packet_recv):
- stat_req = message.port_stats_request()
+ stat_req = ofp.message.port_stats_request()
stat_req.port_no = port
all_packets_received = 0
@@ -106,9 +104,9 @@
timeout=test_timeout)
obj.assertTrue(response is not None,
"No response to stats request")
- obj.assertTrue(len(response.stats) == 1,
+ obj.assertTrue(len(response.entries) == 1,
"Did not receive port stats reply")
- for item in response.stats:
+ for item in response.entries:
sent = item.tx_packets
recv = item.rx_packets
logging.info("Sent " + str(item.tx_packets) + " packets")
@@ -157,7 +155,7 @@
match.wildcards &= ~ofp.OFPFW_IN_PORT
self.assertTrue(match is not None,
"Could not generate flow match from pkt")
- act = action.action_output()
+ act = ofp.action.output()
# build flow
ingress_port = of_ports[0];
@@ -165,14 +163,14 @@
logging.info("Ingress " + str(ingress_port) +
" to egress " + str(egress_port))
match.in_port = ingress_port
- flow_mod_msg = message.flow_mod()
+ flow_mod_msg = ofp.message.flow_add()
flow_mod_msg.match = match
flow_mod_msg.cookie = random.randint(0,9007199254740992)
flow_mod_msg.buffer_id = 0xffffffff
flow_mod_msg.idle_timeout = 0
flow_mod_msg.hard_timeout = 0
act.port = egress_port
- flow_mod_msg.actions.add(act)
+ flow_mod_msg.actions.append(act)
# send flow
logging.info("Inserting flow")
@@ -210,15 +208,15 @@
"Could not generate flow match from pkt")
match.in_port = ingress_port
- flow_mod_msg = message.flow_mod()
+ flow_mod_msg = ofp.message.flow_add()
flow_mod_msg.match = match
flow_mod_msg.cookie = random.randint(0,9007199254740992)
flow_mod_msg.buffer_id = 0xffffffff
flow_mod_msg.idle_timeout = 0
flow_mod_msg.hard_timeout = 0
- act = action.action_output()
+ act = ofp.action.output()
act.port = egress_port
- flow_mod_msg.actions.add(act)
+ flow_mod_msg.actions.append(act)
logging.info("Ingress " + str(ingress_port) +
" to egress " + str(egress_port))
@@ -241,7 +239,7 @@
pkt1 = simple_tcp_packet()
flow_mod_msg1 = self.buildFlowModMsg(pkt1, ingress_port, egress_port1)
- pkt2 = simple_tcp_packet(dl_src='0:7:7:7:7:7')
+ pkt2 = simple_tcp_packet(eth_src='0:7:7:7:7:7')
flow_mod_msg2 = self.buildFlowModMsg(pkt2, ingress_port, egress_port2)
logging.info("Inserting flow1")
@@ -287,15 +285,15 @@
"Could not generate flow match from pkt")
match.in_port = ingress_port
- flow_mod_msg = message.flow_mod()
+ flow_mod_msg = ofp.message.flow_add()
flow_mod_msg.match = match
flow_mod_msg.cookie = random.randint(0,9007199254740992)
flow_mod_msg.buffer_id = 0xffffffff
flow_mod_msg.idle_timeout = 0
flow_mod_msg.hard_timeout = 0
- act = action.action_output()
+ act = ofp.action.output()
act.port = egress_port
- flow_mod_msg.actions.add(act)
+ flow_mod_msg.actions.append(act)
logging.info("Ingress " + str(ingress_port) +
" to egress " + str(egress_port))
@@ -317,7 +315,7 @@
pkt1 = simple_tcp_packet()
flow_mod_msg1 = self.buildFlowModMsg(pkt1, port0, port1)
- pkt2 = simple_tcp_packet(dl_src='0:7:7:7:7:7')
+ pkt2 = simple_tcp_packet(eth_src='0:7:7:7:7:7')
flow_mod_msg2 = self.buildFlowModMsg(pkt2, port0, port2)
logging.info("Inserting flow1")
diff --git a/tools/munger/Makefile b/tools/munger/Makefile
deleted file mode 100644
index c6cc8f1..0000000
--- a/tools/munger/Makefile
+++ /dev/null
@@ -1,97 +0,0 @@
-#
-# Simple make file to generate OpenFlow python files
-#
-# Fixme: Would like pylibopenflow to be able to run remotely
-# Currently, we have to cd to it's dir and refer back to local
-
-TOP_DIR = ../..
-TOOLS_DIR = ..
-DOC_DIR = ${TOP_DIR}/doc
-TESTS_DIR = ${TOP_DIR}/tests
-
-PYLIBOF_DIR = ${TOOLS_DIR}/pylibopenflow
-
-TARGET_DIR = ${TOP_DIR}/src/python/of10
-
-# Relative to pyopenflow-pythonize exec location
-OF_HEADER = include/openflow.h
-
-# Relative to here
-ABS_OF_HEADER = ${PYLIBOF_DIR}/${OF_HEADER}
-
-PYTHONIZE = bin/pyopenflow-pythonize.py
-CSTRUCT_GEN_CMD = (cd ${PYLIBOF_DIR} && ${PYTHONIZE} -i ${OF_HEADER} \
- ${TARGET_DIR}/cstruct.py)
-CSTRUCT_AUX_INFO = ${TARGET_DIR}/class_maps.py
-
-# Dependencies for cstruct.py
-CSTRUCT_DEP = ${ABS_OF_HEADER} $(wildcard ${PYLIBOF_DIR}/pylib/*.py)
-CSTRUCT_DEP += $(wildcard ${PYLIBOF_DIR}/pylib/of/*.py)
-
-# Generated and other files
-GEN_FILES := $(addprefix ${TARGET_DIR}/,cstruct.py message.py error.py \
- action.py)
-# class_maps is generated as a side effect of cstruct....
-OTHER_FILES := $(addprefix ${TARGET_DIR}/,action_list.py parse.py \
- controller.py dataplane.py class_maps.py)
-LINT_SOURCE := ${GEN_FILES} ${OTHER_FILES}
-LINT_FILES := $(subst .py,.log,${LINT_SOURCE})
-LINT_FILES := $(subst ${TARGET_DIR}/,lint/,${LINT_FILES})
-
-all: ${GEN_FILES}
-
-install: all
-
-# The core OpenFlow libraries generated from openflow.h
-${TARGET_DIR}/cstruct.py: ${CSTRUCT_DEP}
- ${CSTRUCT_GEN_CMD} > ${CSTRUCT_AUX_INFO}
-
-# General rule like src/message.py comes from scripts/message_gen.py
-${TARGET_DIR}/%.py: scripts/%_gen.py ${TARGET_DIR}/cstruct.py
- python $< > $@
-
-# The pylint files
-lint/%.log: ${TARGET_DIR}/%.py
- mkdir -p lint
- (cd ${TARGET_DIR} && pylint -e $(notdir $<)) > $@
-
-# Note that lint has issues with scapy syntax
-lint: ${LINT_FILES}
-
-${TESTS_DIR}/oft.py:
- ln -s oft $@
-
-# For now. just local source doc generated
-doc: ${GEN_FILES} ${OTHER_FILES} ${DOC_DIR}/Doxyfile ${TESTS_DIR}/oft.py
- (cd ${DOC_DIR} && doxygen)
-
-clean:
- rm -rf ${GEN_FILES} ${LINT_FILES} ${DOC_DIR}/html/*
-
-test: all
- (cd tests && python msg_test.py) > tests/msg_test.log
-
-help:
- @echo
- @echo "Makefile for oftest source munger"
- @echo " Default builds python files and installs in ${TARGET_DIR}"
- @echo " make local: Generate files and put in src/"
- @echo
- @echo "Targets:"
- @echo " all: Puts generated .py in ${TARGET_DIR}"
- @echo " lint: Puts error report in lint/*.log"
- @echo " doc: Runs doxygen on generated files in ../../doc"
- @echo " clean: Removes generated files"
- @echo
- @echo "Debug info:"
- @echo
- @echo "Files generated GEN_FILES: ${GEN_FILES}"
- @echo
- @echo "Dependencies for cstruct.py CSTRUCT_DEP: ${CSTRUCT_DEP}"
- @echo
- @echo "Already created files OTHER_FILES: ${OTHER_FILES}"
- @echo
- @echo "LINT_FILES: ${LINT_FILES}"
-
-
-.PHONY: all local install help doc lint clean test
diff --git a/tools/munger/scripts/action_gen.py b/tools/munger/scripts/action_gen.py
deleted file mode 100644
index e4f2350..0000000
--- a/tools/munger/scripts/action_gen.py
+++ /dev/null
@@ -1,114 +0,0 @@
-#!/usr/bin/python
-#
-# This python script generates action subclasses
-#
-
-import re
-import sys
-sys.path.append("../../src/python/of10")
-from cstruct import *
-from class_maps import class_to_members_map
-
-print """
-# Python OpenFlow action wrapper classes
-
-from cstruct import *
-
-"""
-
-################################################################
-#
-# Action subclasses
-#
-################################################################
-
-action_structs = [
- 'output',
- 'vlan_vid',
- 'vlan_pcp',
- 'dl_addr',
- 'nw_addr',
- 'tp_port',
- 'nw_tos',
- 'vendor_header']
-
-action_types = [
- 'output',
- 'set_vlan_vid',
- 'set_vlan_pcp',
- 'strip_vlan',
- 'set_dl_src',
- 'set_dl_dst',
- 'set_nw_src',
- 'set_nw_dst',
- 'set_nw_tos',
- 'set_tp_src',
- 'set_tp_dst',
- 'enqueue',
- 'vendor'
-]
-action_types.sort()
-
-action_class_map = {
- 'output' : 'ofp_action_output',
- 'set_vlan_vid' : 'ofp_action_vlan_vid',
- 'set_vlan_pcp' : 'ofp_action_vlan_pcp',
- 'strip_vlan' : 'ofp_action_header',
- 'set_dl_src' : 'ofp_action_dl_addr',
- 'set_dl_dst' : 'ofp_action_dl_addr',
- 'set_nw_src' : 'ofp_action_nw_addr',
- 'set_nw_dst' : 'ofp_action_nw_addr',
- 'set_nw_tos' : 'ofp_action_nw_tos',
- 'set_tp_src' : 'ofp_action_tp_port',
- 'set_tp_dst' : 'ofp_action_tp_port',
- 'enqueue' : 'ofp_action_enqueue',
- 'vendor' : 'ofp_action_vendor_header'
-}
-
-template = """
-class --TYPE--(--PARENT_TYPE--):
- \"""
- Wrapper class for --TYPE-- action object
-
- --DOC_INFO--
- \"""
- def __init__(self, **kwargs):
- --PARENT_TYPE--.__init__(self)
- self.type = --ACTION_NAME--
- self.len = self.__len__()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- def show(self, prefix=''):
- outstr = prefix + "action_--TYPE--\\n"
- outstr += --PARENT_TYPE--.show(self, prefix)
- return outstr
-
-action_--TYPE-- = --TYPE-- # for backwards compatibility
-"""
-
-if __name__ == '__main__':
- for (t, parent) in action_class_map.items():
- if not parent in class_to_members_map.keys():
- doc_info = "Unknown parent action class: " + parent
- else:
- doc_info = "Data members inherited from " + parent + ":\n"
- for var in class_to_members_map[parent]:
- doc_info += " @arg " + var + "\n"
- action_name = "OFPAT_" + t.upper()
- to_print = re.sub('--TYPE--', t, template)
- to_print = re.sub('--PARENT_TYPE--', parent, to_print)
- to_print = re.sub('--ACTION_NAME--', action_name, to_print)
- to_print = re.sub('--DOC_INFO--', doc_info, to_print)
- print to_print
-
- # Generate a list of action classes
- print "action_class_list = ("
- prev = None
- for (t, parent) in action_class_map.items():
- if prev:
- print " action_" + prev + ","
- prev = t
- print " action_" + prev + ")"
diff --git a/tools/munger/scripts/error_gen.py b/tools/munger/scripts/error_gen.py
deleted file mode 100644
index b1f360e..0000000
--- a/tools/munger/scripts/error_gen.py
+++ /dev/null
@@ -1,90 +0,0 @@
-#!/usr/bin/python
-#
-# This python script generates error subclasses
-#
-
-import re
-import sys
-sys.path.append("../../src/python/of10")
-from cstruct import *
-from class_maps import class_to_members_map
-
-print """
-# Python OpenFlow error wrapper classes
-
-from cstruct import *
-
-"""
-
-################################################################
-#
-# Error message subclasses
-#
-################################################################
-
-# Template for error subclasses
-
-template = """
-class --TYPE--_error_msg(ofp_error_msg):
- \"""
- Wrapper class for --TYPE-- error message class
-
- Data members inherited from ofp_error_msg:
- @arg type
- @arg code
- @arg data: Binary string following message members
-
- \"""
- def __init__(self):
- ofp_error_msg.__init__(self)
- self.header = ofp_header()
- self.header.type = OFPT_ERROR
- self.type = --ERROR_NAME--
- self.data = ""
-
- def pack(self, assertstruct=True):
- self.header.length = self.__len__()
- packed = self.header.pack()
- packed += ofp_error_msg.pack(self)
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_error_msg.unpack(self, binary_string)
- self.data = binary_string
- return ""
-
- def __len__(self):
- return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
-
- def show(self, prefix=''):
- outstr = prefix + "--TYPE--_error_msg\\m"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_error_msg.show(self, prefix + ' ')
- outstr += prefix + "data is of length " + str(len(self.data)) + '\\n'
- ##@todo Consider trying to parse the string
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_error_msg.__eq__(self, other) and
- self.data == other.data)
-
- def __ne__(self, other): return not self.__eq__(other)
-"""
-
-error_types = [
- 'hello_failed',
- 'bad_request',
- 'bad_action',
- 'flow_mod_failed',
- 'port_mod_failed',
- 'queue_op_failed']
-
-for t in error_types:
- error_name = "OFPET_" + t.upper()
- to_print = re.sub('--TYPE--', t, template)
- to_print = re.sub('--ERROR_NAME--', error_name, to_print)
- print to_print
diff --git a/tools/munger/scripts/message_gen.py b/tools/munger/scripts/message_gen.py
deleted file mode 100644
index ff535f7..0000000
--- a/tools/munger/scripts/message_gen.py
+++ /dev/null
@@ -1,817 +0,0 @@
-#!/usr/bin/python
-#
-# This python script generates wrapper functions for OpenFlow messages
-#
-# See the doc string below for more info
-#
-
-# To do:
-# Default type values for messages
-# Generate all message objects
-# Action list objects?
-# Autogen lengths when possible
-# Dictionaries for enum strings
-# Resolve sub struct initializers (see ofp_flow_mod)
-
-
-"""
-Generate wrapper classes for OpenFlow messages
-
-(C) Copyright Stanford University
-Date February 2010
-Created by dtalayco
-
-Attempting to follow http://www.python.org/dev/peps/pep-0008/
-The main exception is that our class names do not use CamelCase
-so as to more closely match the original C code names.
-
-This file is meant to generate a file of_wrapper.py which imports
-the base classes generated form automatic processing of openflow.h
-and produces wrapper classes for each OpenFlow message type.
-
-This file will normally be included in of_message.py which provides
-additional hand-generated work.
-
-There are two types of structures/classes here: base components and
-message classes.
-
-Base components are the base data classes which are fixed
-length structures including:
- ofp_header
- Each ofp_action structure
- ofp_phy_port
- The array elements of all the stats reply messages
-The base components are to be imported from a file of_header.py.
-
-Message classes define a complete message on the wire. These are
-comprised of possibly variable length lists of possibly variably
-typed objects from the base component list above.
-
-Each OpenFlow message has a header and zero or more fixed length
-members (the "core members" of the class) followed by zero or more
-variable length lists.
-
-The wrapper classes should live in their own name space, probably
-of_message. Automatically generated base component and skeletons for
-the message classes are assumed generated and the wrapper classes
-will inherit from those.
-
-Every message class must implement pack and unpack functions to
-convert between the class and a string representing what goes on the
-wire.
-
-For unpacking, the low level (base-component) classes must implement
-their own unpack functions. A single top level unpack function
-will do the parsing and call the lower layer unpack functions as
-appropriate.
-
-Every base and message class should implement a show function to
-(recursively) display the contents of the object.
-
-Certain OpenFlow message types are further subclassed. These include
-stats_request, stats_reply and error.
-
-"""
-
-# Don't generate header object in messages
-# Map each message to a body that doesn't include the header
-# The body has does not include variable length info at the end
-
-import re
-import string
-import sys
-sys.path.append("../../src/python/of10")
-from cstruct import *
-from class_maps import class_to_members_map
-
-message_top_matter = """
-# Python OpenFlow message wrapper classes
-
-from cstruct import *
-from action_list import action_list
-from error import *
-
-# Define templates for documentation
-class ofp_template_msg:
- \"""
- Sample base class for template_msg; normally auto generated
- This class should live in the of_header name space and provides the
- base class for this type of message. It will be wrapped for the
- high level API.
-
- \"""
- def __init__(self):
- \"""
- Constructor for base class
-
- \"""
- self.header = ofp_header()
- # Additional base data members declared here
-
- # Normally will define pack, unpack, __len__ functions
-
-class template_msg(ofp_template_msg):
- \"""
- Sample class wrapper for template_msg
- This class should live in the of_message name space and provides the
- high level API for an OpenFlow message object. These objects must
- implement the functions indicated in this template.
-
- \"""
- def __init__(self):
- \"""
- Constructor
- Must set the header type value appropriately for the message
-
- \"""
-
- ##@var header
- # OpenFlow message header: length, version, xid, type
- ofp_template_msg.__init__(self)
- self.header = ofp_header()
- # For a real message, will be set to an integer
- self.header.type = "TEMPLATE_MSG_VALUE"
- def pack(self):
- \"""
- Pack object into string
-
- @return The packed string which can go on the wire
-
- \"""
- pass
- def unpack(self, binary_string):
- \"""
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
-
- @return Typically returns the remainder of binary_string that
- was not parsed. May give a warning if that string is non-empty
-
- \"""
- pass
- def __len__(self):
- \"""
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- \"""
- pass
- def show(self, prefix=''):
- \"""
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- \"""
- pass
- def __eq__(self, other):
- \"""
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- \"""
- pass
- def __ne__(self, other):
- \"""
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- \"""
- pass
-"""
-
-# Dictionary mapping wrapped classes to the auto-generated structure
-# underlieing the class (body only, not header or var-length data)
-message_class_map = {
- "hello" : "ofp_header",
- "error" : "ofp_error_msg",
- "echo_request" : "ofp_header",
- "echo_reply" : "ofp_header",
- "vendor" : "ofp_vendor_header",
- "features_request" : "ofp_header",
- "features_reply" : "ofp_switch_features",
- "get_config_request" : "ofp_header",
- "get_config_reply" : "ofp_switch_config",
- "set_config" : "ofp_switch_config",
- "packet_in" : "ofp_packet_in",
- "flow_removed" : "ofp_flow_removed",
- "port_status" : "ofp_port_status",
- "packet_out" : "ofp_packet_out",
- "flow_mod" : "ofp_flow_mod",
- "port_mod" : "ofp_port_mod",
- "stats_request" : "ofp_stats_request",
- "stats_reply" : "ofp_stats_reply",
- "barrier_request" : "ofp_header",
- "barrier_reply" : "ofp_header",
- "queue_get_config_request" : "ofp_queue_get_config_request",
- "queue_get_config_reply" : "ofp_queue_get_config_reply"
-}
-
-# These messages have a string member at the end of the data
-string_members = [
- "hello",
- "error",
- "echo_request",
- "echo_reply",
- "vendor",
- "packet_in",
- "packet_out"
-]
-
-# These messages have a list (with the given name) in the data,
-# after the core members; the type is given for validation
-list_members = {
- "features_reply" : ('ports', None),
- "packet_out" : ('actions', 'action_list'),
- "flow_mod" : ('actions', 'action_list'),
- "queue_get_config_reply" : ('queues', None)
-}
-
-_ind = " "
-
-def _p1(s): print _ind + s
-def _p2(s): print _ind * 2 + s
-def _p3(s): print _ind * 3 + s
-def _p4(s): print _ind * 4 + s
-
-# Okay, this gets kind of ugly:
-# There are three variables:
-# has_core_members: If parent class is not ofp_header, has inheritance
-# has_list: Whether class has trailing array or class
-# has_string: Whether class has trailing string
-
-def gen_message_wrapper(msg):
- """
- Generate a wrapper for the given message based on above info
- @param msg String identifying the message name for the class
- """
-
- msg_name = "OFPT_" + msg.upper()
- parent = message_class_map[msg]
-
- has_list = False # Has trailing list
- has_core_members = False
- has_string = False # Has trailing string
- if parent != 'ofp_header':
- has_core_members = True
- if msg in list_members.keys():
- (list_var, list_type) = list_members[msg]
- has_list = True
- if msg in string_members:
- has_string = True
-
- if has_core_members:
- print "class " + msg + "(" + parent + "):"
- else:
- print "class " + msg + ":"
- _p1('"""')
- _p1("Wrapper class for " + msg)
- print
- _p1("OpenFlow message header: length, version, xid, type")
- _p1("@arg length: The total length of the message")
- _p1("@arg version: The OpenFlow version (" + str(OFP_VERSION) + ")")
- _p1("@arg xid: The transaction ID")
- _p1("@arg type: The message type (" + msg_name + "=" +
- str(eval(msg_name)) + ")")
- print
- if has_core_members and parent in class_to_members_map.keys():
- _p1("Data members inherited from " + parent + ":")
- for var in class_to_members_map[parent]:
- _p1("@arg " + var)
- if has_list:
- if list_type == None:
- _p1("@arg " + list_var + ": Variable length array of TBD")
- else:
- _p1("@arg " + list_var + ": Object of type " + list_type);
- if has_string:
- _p1("@arg data: Binary string following message members")
- print
- _p1('"""')
-
- print
- _p1("def __init__(self, **kwargs):")
- if has_core_members:
- _p2(parent + ".__init__(self)")
- _p2("self.header = ofp_header()")
- _p2("self.header.type = " + msg_name)
- if has_list:
- _p2('self.' + list_var + ' = []')
- if has_string:
- _p2('self.data = ""')
- _p2('for (k, v) in kwargs.items():')
- _p3('if hasattr(self, k):')
- _p4('setattr(self, k, v)')
- _p3('else:')
- _p4('raise NameError("field %s does not exist in %s" % (k, self.__class__))')
- if has_list and list_type != None:
- _p2('# Coerce keyword arg into list type')
- _p2('self.%(list_var)s = %(list_type)s(self.%(list_var)s)' % dict(list_type=list_type, list_var=list_var))
-
- print """
-
- def pack(self):
- \"""
- Pack object into string
-
- @return The packed string which can go on the wire
-
- \"""
- self.header.length = len(self)
- packed = self.header.pack()
-"""
-
- # Have to special case the action length calculation for pkt out
- if msg == 'packet_out':
- _p2('self.actions_len = len(self.actions)')
- if has_core_members:
- _p2("packed += " + parent + ".pack(self)")
- if has_list:
- if list_type == None:
- _p2('for obj in self.' + list_var + ':')
- _p3('packed += obj.pack()')
- else:
- _p2('packed += self.' + list_var + '.pack()')
- if has_string:
- _p2('packed += self.data')
- _p2("return packed")
-
- print """
- def unpack(self, binary_string):
- \"""
- Unpack object from a binary string
-
- @param binary_string The wire protocol byte string holding the object
- represented as an array of bytes.
- @return The remainder of binary_string that was not parsed.
-
- \"""
- binary_string = self.header.unpack(binary_string)
-"""
- if has_core_members:
- _p2("binary_string = " + parent + ".unpack(self, binary_string)")
- if has_list:
- if msg == "features_reply": # Special case port parsing
- # For now, cheat and assume the rest of the message is port list
- _p2("while len(binary_string) >= OFP_PHY_PORT_BYTES:")
- _p3("new_port = ofp_phy_port()")
- _p3("binary_string = new_port.unpack(binary_string)")
- _p3("self.ports.append(new_port)")
- elif list_type == None:
- _p2("for obj in self." + list_var + ":")
- _p3("binary_string = obj.unpack(binary_string)")
- elif msg == "packet_out": # Special case this
- _p2('binary_string = self.actions.unpack(' +
- 'binary_string, bytes=self.actions_len)')
- elif msg == "flow_mod": # Special case this
- _p2("ai_len = self.header.length - (OFP_FLOW_MOD_BYTES + " +
- "OFP_HEADER_BYTES)")
- _p2("binary_string = self.actions.unpack(binary_string, " +
- "bytes=ai_len)")
- else:
- _p2("binary_string = self." + list_var + ".unpack(binary_string)")
- if has_string:
- _p2("self.data = binary_string")
- _p2("binary_string = ''")
- else:
- _p2("# Fixme: If no self.data, add check for data remaining")
- _p2("return binary_string")
-
- print """
- def __len__(self):
- \"""
- Return the length of this object once packed into a string
-
- @return An integer representing the number bytes in the packed
- string.
-
- \"""
- length = OFP_HEADER_BYTES
-"""
- if has_core_members:
- _p2("length += " + parent + ".__len__(self)")
- if has_list:
- if list_type == None:
- _p2("for obj in self." + list_var + ":")
- _p3("length += len(obj)")
- else:
- _p2("length += len(self." + list_var + ")")
- if has_string:
- _p2("length += len(self.data)")
- _p2("return length")
-
- print """
- def show(self, prefix=''):
- \"""
- Generate a string (with multiple lines) describing the contents
- of the object in a readable manner
-
- @param prefix Pre-pended at the beginning of each line.
-
- \"""
-"""
- _p2("outstr = prefix + '" + msg + " (" + msg_name + ")\\n'")
- _p2("prefix += ' '")
- _p2("outstr += prefix + 'ofp header\\n'")
- _p2("outstr += self.header.show(prefix + ' ')")
- if has_core_members:
- _p2("outstr += " + parent + ".show(self, prefix)")
- if has_list:
- if list_type == None:
- _p2('outstr += prefix + "Array ' + list_var + '\\n"')
- _p2('for obj in self.' + list_var +':')
- _p3("outstr += obj.show(prefix + ' ')")
- else:
- _p2('outstr += prefix + "List ' + list_var + '\\n"')
- _p2('outstr += self.' + list_var + ".show(prefix + ' ')")
- if has_string:
- _p2("outstr += prefix + 'data is of length ' + str(len(self.data)) + '\\n'")
- _p2("##@todo Fix this circular reference")
- _p2("# if len(self.data) > 0:")
- _p3("# obj = of_message_parse(self.data)")
- _p3("# if obj != None:")
- _p4("# outstr += obj.show(prefix)")
- _p3("# else:")
- _p4('# outstr += prefix + "Unable to parse data\\n"')
- _p2('return outstr')
-
- print """
- def __eq__(self, other):
- \"""
- Return True if self and other hold the same data
-
- @param other Other object in comparison
-
- \"""
- if type(self) != type(other): return False
- if not self.header.__eq__(other.header): return False
-"""
- if has_core_members:
- _p2("if not " + parent + ".__eq__(self, other): return False")
- if has_string:
- _p2("if self.data != other.data: return False")
- if has_list:
- _p2("if self." + list_var + " != other." + list_var + ": return False")
- _p2("return True")
-
- print """
- def __ne__(self, other):
- \"""
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- \"""
- return not self.__eq__(other)
- """
-
-
-################################################################
-#
-# Stats request subclasses
-# description_request, flow, aggregate, table, port, vendor
-#
-################################################################
-
-# table and desc stats requests are special with empty body
-extra_ofp_stats_req_defs = """
-# Stats request bodies for desc and table stats are not defined in the
-# OpenFlow header; We define them here. They are empty classes, really
-
-class ofp_desc_stats_request:
- \"""
- Forced definition of ofp_desc_stats_request (empty class)
- \"""
- def __init__(self):
- pass
- def pack(self, assertstruct=True):
- return ""
- def unpack(self, binary_string):
- return binary_string
- def __len__(self):
- return 0
- def show(self, prefix=''):
- return prefix + "ofp_desc_stats_request (empty)\\n"
- def __eq__(self, other):
- return type(self) == type(other)
- def __ne__(self, other):
- return type(self) != type(other)
-
-OFP_DESC_STATS_REQUEST_BYTES = 0
-
-class ofp_table_stats_request:
- \"""
- Forced definition of ofp_table_stats_request (empty class)
- \"""
- def __init__(self):
- pass
- def pack(self, assertstruct=True):
- return ""
- def unpack(self, binary_string):
- return binary_string
- def __len__(self):
- return 0
- def show(self, prefix=''):
- return prefix + "ofp_table_stats_request (empty)\\n"
- def __eq__(self, other):
- return type(self) == type(other)
- def __ne__(self, other):
- return type(self) != type(other)
-
-OFP_TABLE_STATS_REQUEST_BYTES = 0
-
-"""
-
-stats_request_template = """
-class --TYPE--_stats_request(ofp_stats_request, ofp_--TYPE--_stats_request):
- \"""
- Wrapper class for --TYPE-- stats request message
- \"""
- def __init__(self, **kwargs):
- self.header = ofp_header()
- ofp_stats_request.__init__(self)
- ofp_--TYPE--_stats_request.__init__(self)
- self.header.type = OFPT_STATS_REQUEST
- self.type = --STATS_NAME--
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_request.pack(self)
- packed += ofp_--TYPE--_stats_request.pack(self)
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_request.unpack(self, binary_string)
- binary_string = ofp_--TYPE--_stats_request.unpack(self, binary_string)
- if len(binary_string) != 0:
- print "ERROR unpacking --TYPE--: extra data"
- return binary_string
-
- def __len__(self):
- return len(self.header) + OFP_STATS_REQUEST_BYTES + \\
- OFP_--TYPE_UPPER--_STATS_REQUEST_BYTES
-
- def show(self, prefix=''):
- outstr = prefix + "--TYPE--_stats_request\\n"
- outstr += prefix + "ofp header:\\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_request.show(self)
- outstr += ofp_--TYPE--_stats_request.show(self)
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_request.__eq__(self, other) and
- ofp_--TYPE--_stats_request.__eq__(self, other))
-
- def __ne__(self, other): return not self.__eq__(other)
-"""
-
-################################################################
-#
-# Stats replies always have an array at the end.
-# For aggregate and desc, these arrays are always of length 1
-# This array is always called stats
-#
-################################################################
-
-
-# Template for objects stats reply messages
-stats_reply_template = """
-class --TYPE--_stats_reply(ofp_stats_reply):
- \"""
- Wrapper class for --TYPE-- stats reply
- \"""
- def __init__(self):
- self.header = ofp_header()
- ofp_stats_reply.__init__(self)
- self.header.type = OFPT_STATS_REPLY
- self.type = --STATS_NAME--
- # stats: Array of type --TYPE--_stats_entry
- self.stats = []
-
- def pack(self, assertstruct=True):
- self.header.length = len(self)
- packed = self.header.pack()
- packed += ofp_stats_reply.pack(self)
- for obj in self.stats:
- packed += obj.pack()
- return packed
-
- def unpack(self, binary_string):
- binary_string = self.header.unpack(binary_string)
- binary_string = ofp_stats_reply.unpack(self, binary_string)
- dummy = --TYPE--_stats_entry()
- while len(binary_string) >= len(dummy):
- obj = --TYPE--_stats_entry()
- binary_string = obj.unpack(binary_string)
- self.stats.append(obj)
- if len(binary_string) != 0:
- print "ERROR unpacking --TYPE-- stats string: extra bytes"
- return binary_string
-
- def __len__(self):
- length = len(self.header) + OFP_STATS_REPLY_BYTES
- for obj in self.stats:
- length += len(obj)
- return length
-
- def show(self, prefix=''):
- outstr = prefix + "--TYPE--_stats_reply\\n"
- outstr += prefix + "ofp header:\\n"
- outstr += self.header.show(prefix + ' ')
- outstr += ofp_stats_reply.show(self)
- outstr += prefix + "Stats array of length " + str(len(self.stats)) + '\\n'
- for obj in self.stats:
- outstr += obj.show()
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (self.header == other.header and
- ofp_stats_reply.__eq__(self, other) and
- self.stats == other.stats)
-
- def __ne__(self, other): return not self.__eq__(other)
-"""
-
-#
-# To address variations in stats reply bodies, the following
-# "_entry" classes are defined for each element in the reply
-#
-
-extra_stats_entry_defs = """
-# Stats entries define the content of one element in a stats
-# reply for the indicated type; define _entry for consistency
-
-aggregate_stats_entry = ofp_aggregate_stats_reply
-desc_stats_entry = ofp_desc_stats
-port_stats_entry = ofp_port_stats
-queue_stats_entry = ofp_queue_stats
-table_stats_entry = ofp_table_stats
-"""
-
-# Special case flow_stats to handle actions_list
-
-flow_stats_entry_def = """
-#
-# Flow stats entry contains an action list of variable length, so
-# it is done by hand
-#
-
-class flow_stats_entry(ofp_flow_stats):
- \"""
- Special case flow stats entry to handle action list object
- \"""
- def __init__(self):
- ofp_flow_stats.__init__(self)
- self.actions = action_list()
-
- def pack(self, assertstruct=True):
- self.length = len(self)
- packed = ofp_flow_stats.pack(self, assertstruct)
- packed += self.actions.pack()
- if len(packed) != self.length:
- print("ERROR: flow_stats_entry pack length not equal",
- self.length, len(packed))
- return packed
-
- def unpack(self, binary_string):
- binary_string = ofp_flow_stats.unpack(self, binary_string)
- ai_len = self.length - OFP_FLOW_STATS_BYTES
- if ai_len < 0:
- print("ERROR: flow_stats_entry unpack length too small",
- self.length)
- binary_string = self.actions.unpack(binary_string, bytes=ai_len)
- return binary_string
-
- def __len__(self):
- return OFP_FLOW_STATS_BYTES + len(self.actions)
-
- def show(self, prefix=''):
- outstr = prefix + "flow_stats_entry\\n"
- outstr += ofp_flow_stats.show(self, prefix + ' ')
- outstr += self.actions.show(prefix + ' ')
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (ofp_flow_stats.__eq__(self, other) and
- self.actions == other.actions)
-
- def __ne__(self, other): return not self.__eq__(other)
-"""
-
-stats_types = [
- 'aggregate',
- 'desc',
- 'flow',
- 'port',
- 'queue',
- 'table']
-
-if __name__ == '__main__':
-
- print message_top_matter
-
- print """
-################################################################
-#
-# OpenFlow Message Definitions
-#
-################################################################
-"""
-
- msg_types = message_class_map.keys()
- msg_types.sort()
-
- for t in msg_types:
- gen_message_wrapper(t)
- print
-
- print """
-################################################################
-#
-# Stats request and reply subclass definitions
-#
-################################################################
-"""
-
- print extra_ofp_stats_req_defs
- print extra_stats_entry_defs
- print flow_stats_entry_def
-
- # Generate stats request and reply subclasses
- for t in stats_types:
- stats_name = "OFPST_" + t.upper()
- to_print = re.sub('--TYPE--', t, stats_request_template)
- to_print = re.sub('--TYPE_UPPER--', t.upper(), to_print)
- to_print = re.sub('--STATS_NAME--', stats_name, to_print)
- print to_print
- to_print = re.sub('--TYPE--', t, stats_reply_template)
- to_print = re.sub('--STATS_NAME--', stats_name, to_print)
- print to_print
-
- # Lastly, generate a tuple containing all the message classes
- print """
-message_type_list = (
- aggregate_stats_reply,
- aggregate_stats_request,
- bad_action_error_msg,
- bad_request_error_msg,
- barrier_reply,
- barrier_request,
- desc_stats_reply,
- desc_stats_request,
- echo_reply,
- echo_request,
- features_reply,
- features_request,
- flow_mod,
- flow_mod_failed_error_msg,
- flow_removed,
- flow_stats_reply,
- flow_stats_request,
- get_config_reply,
- get_config_request,
- hello,
- hello_failed_error_msg,
- packet_in,
- packet_out,
- port_mod,
- port_mod_failed_error_msg,
- port_stats_reply,
- port_stats_request,
- port_status,
- queue_get_config_reply,
- queue_get_config_request,
- queue_op_failed_error_msg,
- queue_stats_reply,
- queue_stats_request,
- set_config,
- table_stats_reply,
- table_stats_request,
- vendor
- )
-"""
-
-#
-# OFP match variants
-# ICMP 0x801 (?) ==> icmp_type/code replace tp_src/dst
-#
-
-
diff --git a/tools/munger/tests/defs.py b/tools/munger/tests/defs.py
deleted file mode 100644
index 5cb779f..0000000
--- a/tools/munger/tests/defs.py
+++ /dev/null
@@ -1,193 +0,0 @@
-import sys
-sys.path.append('../../../src/python/oftest/protocol')
-from message import *
-from action import *
-from error import *
-from class_maps import *
-
-ofmsg_class_map_to_parents = {
- action_enqueue : [ofp_action_enqueue],
- action_output : [ofp_action_output],
- action_set_dl_dst : [ofp_action_dl_addr],
- action_set_dl_src : [ofp_action_dl_addr],
- action_set_nw_dst : [ofp_action_nw_addr],
- action_set_nw_src : [ofp_action_nw_addr],
- action_set_nw_tos : [ofp_action_nw_tos],
- action_set_tp_dst : [ofp_action_tp_port],
- action_set_tp_src : [ofp_action_tp_port],
- action_set_vlan_pcp : [ofp_action_vlan_pcp],
- action_set_vlan_vid : [ofp_action_vlan_vid],
- action_strip_vlan : [ofp_action_header],
- action_vendor : [ofp_action_vendor_header],
- aggregate_stats_entry : [],
- aggregate_stats_reply : [ofp_stats_reply],
- aggregate_stats_request : [ofp_stats_request,
- ofp_aggregate_stats_request],
- bad_action_error_msg : [ofp_error_msg],
- bad_request_error_msg : [ofp_error_msg],
- barrier_reply : [],
- barrier_request : [],
- desc_stats_entry : [],
- desc_stats_reply : [ofp_stats_reply],
- desc_stats_request : [ofp_stats_request,
- ofp_desc_stats_request],
- echo_reply : [],
- echo_request : [],
- error : [ofp_error_msg],
- features_reply : [ofp_switch_features],
- features_request : [],
- flow_mod : [ofp_flow_mod],
- flow_mod_failed_error_msg : [ofp_error_msg],
- flow_removed : [ofp_flow_removed],
- flow_stats_entry : [ofp_flow_stats],
- flow_stats_reply : [ofp_stats_reply],
- flow_stats_request : [ofp_stats_request,
- ofp_flow_stats_request],
- get_config_reply : [ofp_switch_config],
- get_config_request : [],
- hello : [],
- hello_failed_error_msg : [ofp_error_msg],
- packet_in : [ofp_packet_in],
- packet_out : [ofp_packet_out],
- port_mod : [ofp_port_mod],
- port_mod_failed_error_msg : [ofp_error_msg],
- port_stats_entry : [],
- port_stats_reply : [ofp_stats_reply],
- port_stats_request : [ofp_stats_request,
- ofp_port_stats_request],
- port_status : [ofp_port_status],
- queue_get_config_reply : [ofp_queue_get_config_reply],
- queue_get_config_request : [ofp_queue_get_config_request],
- queue_op_failed_error_msg : [ofp_error_msg],
- queue_stats_entry : [],
- queue_stats_reply : [ofp_stats_reply],
- queue_stats_request : [ofp_stats_request,
- ofp_queue_stats_request],
- set_config : [ofp_switch_config],
- stats_reply : [ofp_stats_reply],
- stats_request : [ofp_stats_request],
- table_stats_entry : [],
- table_stats_reply : [ofp_stats_reply],
- table_stats_request : [ofp_stats_request,
- ofp_table_stats_request],
- vendor : [ofp_vendor_header]
-}
-
-ofmsg_names = {
- action_enqueue : 'action_enqueue',
- action_output : 'action_output',
- action_set_dl_dst : 'action_set_dl_dst',
- action_set_dl_src : 'action_set_dl_src',
- action_set_nw_dst : 'action_set_nw_dst',
- action_set_nw_src : 'action_set_nw_src',
- action_set_nw_tos : 'action_set_nw_tos',
- action_set_tp_dst : 'action_set_tp_dst',
- action_set_tp_src : 'action_set_tp_src',
- action_set_vlan_pcp : 'action_set_vlan_pcp',
- action_set_vlan_vid : 'action_set_vlan_vid',
- action_strip_vlan : 'action_strip_vlan',
- action_vendor : 'action_vendor',
- aggregate_stats_entry : 'aggregate_stats_entry',
- aggregate_stats_reply : 'aggregate_stats_reply',
- aggregate_stats_request : 'aggregate_stats_request',
- bad_action_error_msg : 'bad_action_error_msg',
- bad_request_error_msg : 'bad_request_error_msg',
- barrier_reply : 'barrier_reply',
- barrier_request : 'barrier_request',
- desc_stats_entry : 'desc_stats_entry',
- desc_stats_reply : 'desc_stats_reply',
- desc_stats_request : 'desc_stats_request',
- echo_reply : 'echo_reply',
- echo_request : 'echo_request',
- error : 'error',
- features_reply : 'features_reply',
- features_request : 'features_request',
- flow_mod : 'flow_mod',
- flow_mod_failed_error_msg : 'flow_mod_failed_error_msg',
- flow_removed : 'flow_removed',
- flow_stats_entry : 'flow_stats_entry',
- flow_stats_reply : 'flow_stats_reply',
- flow_stats_request : 'flow_stats_request',
- get_config_reply : 'get_config_reply',
- get_config_request : 'get_config_request',
- hello : 'hello',
- hello_failed_error_msg : 'hello_failed_error_msg',
- ofp_desc_stats_request : 'ofp_desc_stats_request',
- ofp_table_stats_request : 'ofp_table_stats_request',
- packet_in : 'packet_in',
- packet_out : 'packet_out',
- port_mod : 'port_mod',
- port_mod_failed_error_msg : 'port_mod_failed_error_msg',
- port_stats_entry : 'port_stats_entry',
- port_stats_reply : 'port_stats_reply',
- port_stats_request : 'port_stats_request',
- port_status : 'port_status',
- queue_get_config_reply : 'queue_get_config_reply',
- queue_get_config_request : 'queue_get_config_request',
- queue_op_failed_error_msg : 'queue_op_failed_error_msg',
- queue_stats_entry : 'queue_stats_entry',
- queue_stats_reply : 'queue_stats_reply',
- queue_stats_request : 'queue_stats_request',
- set_config : 'set_config',
- stats_reply : 'stats_reply',
- stats_request : 'stats_request',
- table_stats_entry : 'table_stats_entry',
- table_stats_reply : 'table_stats_reply',
- table_stats_request : 'table_stats_request',
- vendor : 'vendor'
-}
-
-stats_entry_types = [
- aggregate_stats_entry,
- desc_stats_entry,
- port_stats_entry,
- queue_stats_entry,
- table_stats_entry
-]
-
-##@var A list of all OpenFlow messages including subtyped messages
-of_messages = [
- aggregate_stats_reply,
- aggregate_stats_request,
- bad_action_error_msg,
- bad_request_error_msg,
- barrier_reply,
- barrier_request,
- desc_stats_reply,
- desc_stats_request,
- echo_reply,
- echo_request,
- features_reply,
- features_request,
- flow_mod,
- flow_mod_failed_error_msg,
- flow_removed,
- flow_stats_reply,
- flow_stats_request,
- get_config_reply,
- get_config_request,
- hello,
- hello_failed_error_msg,
- packet_in,
- packet_out,
- port_mod,
- port_mod_failed_error_msg,
- port_stats_reply,
- port_stats_request,
- port_status,
- queue_get_config_reply,
- queue_get_config_request,
- queue_op_failed_error_msg,
- queue_stats_reply,
- queue_stats_request,
- set_config,
- table_stats_reply,
- table_stats_request,
- vendor
-]
-
-# header_fields = ['version', 'xid']
-# fixed_header_fields = ['type', 'length']
-
-all_objs = ofmsg_class_map_to_parents.keys()
-all_objs.sort()
diff --git a/tools/munger/tests/msg_test.py b/tools/munger/tests/msg_test.py
deleted file mode 100644
index e816cc1..0000000
--- a/tools/munger/tests/msg_test.py
+++ /dev/null
@@ -1,215 +0,0 @@
-import sys
-sys.path.append('../../../src/python/oftest')
-
-from parse import of_message_parse
-from parse import of_header_parse
-
-from defs import *
-
-def error_out(string):
- print >> sys.stderr, string
- print string
-
-def obj_comp(orig, new, objname, errstr=None):
- """
- Compare two objects
- """
- dump = False
- if not errstr:
- errstr = "(unknown)"
- errstr += " " + objname
- if not new:
- error_out("ERROR: obj comp, new is None for " + errstr)
- dump = True
- elif type(orig) != type(new):
- error_out("ERROR: type mismatch for " + errstr + " ")
- dump = True
- elif orig != new:
- error_out("ERROR: " + errstr + " orig != new")
- dump = True
- if dump:
- print "Dump of mismatch for " + errstr
- print "type orig " + str(type(orig))
- print "orig length ", len(orig)
- orig.show(" ")
- if new:
- print "type new" + str(type(new))
- print "new length ", len(new)
- new.show(" ")
- print
-
-
-# Generate a long action list
-
-def action_list_create(n=10):
- """
- Create an action list
-
- @param n The number of actions to put in the list
-
- Cycle through the list of all actions, adding each type
- """
-
- al = action_list()
- for i in range(n):
- idx = i % len(action_class_list)
- cls = action_class_list[idx]()
- al.add(cls)
- return al
-
-# Test classes with action lists
-def class_action_test():
- """
- Test objects that use action lists
- """
-
- print "Testing action lists: flow mod, packet out, flow stats"
- for acount in [0, 1, 5, 16, 34]:
- print " " + str(acount) + " actions in list"
- obj = flow_mod()
- obj.actions = action_list_create(acount)
- packed = obj.pack()
- header = of_header_parse(packed)
- obj_check = flow_mod()
- if obj_check.unpack(packed) != "":
- error_out("ERROR: flow mod action list test extra " +
- "string on unpack")
- obj_comp(obj, obj_check, 'flow_mod', "unpack test " + str(acount))
- obj_check = of_message_parse(packed)
- obj_comp(obj, obj_check, 'flow_mod', "parse test " + str(acount))
- # obj.show()
-
- # packet out with and without data
- obj = packet_out()
- obj.actions = action_list_create(acount)
- packed = obj.pack()
- header = of_header_parse(packed)
- obj_check = packet_out()
- if obj_check.unpack(packed) != "":
- error_out("ERROR: packet out packet_out test extra " +
- "string on unpack")
- obj_comp(obj, obj_check, 'packet_out', "unpack test " + str(acount))
- obj_check = of_message_parse(packed)
- obj_comp(obj, obj_check, 'packet_out', "parse test " + str(acount))
- # obj.show()
-
- obj = packet_out()
- obj.actions = action_list_create(acount)
- obj.data = "short test string for packet data"
- packed = obj.pack()
- header = of_header_parse(packed)
- obj_check = packet_out()
- if obj_check.unpack(packed) != "":
- error_out("ERROR: packet out packet_out test extra " +
- "string on unpack")
- obj_comp(obj, obj_check, 'packet_out', "unpack test " + str(acount))
- obj_check = of_message_parse(packed)
- obj_comp(obj, obj_check, 'packet_out', "parse test " + str(acount))
- # obj.show()
-
- # flow stats entry (not a message)
- obj = flow_stats_entry()
- obj.actions = action_list_create(acount)
- packed = obj.pack()
- obj_check = flow_stats_entry()
- if obj_check.unpack(packed) != "":
- error_out("ERROR: packet out flow stats test extra " +
- "string on unpack")
- obj_comp(obj, obj_check, 'packet_out', "unpack test " + str(acount))
- # obj.show()
-
-print "Generating all classes with no data init"
-print
-for cls in all_objs:
- print "Creating class " + ofmsg_names[cls]
- obj = cls()
- print ofmsg_names[cls] + " length: " + str(len(obj))
- obj.show(" ")
- print
-
-print "End of class generation"
-print
-print
-
-print "Generating messages, packing, showing (to verify len)"
-print "and calling self unpack"
-print
-for cls in all_objs:
- print "Pack/unpack test for class " + ofmsg_names[cls]
- obj = cls()
- packed = obj.pack()
- obj_check = cls()
- string = obj_check.unpack(packed)
- if string != "":
- print >> sys.stderr, "WARNING: " + ofmsg_names[cls] + \
- ", unpack returned string " + string
- obj_comp(obj, obj_check, ofmsg_names[cls], "pack/unpack")
-
-print "End of class pack check"
-print
-print
-
-
-print "Testing message parsing"
-print
-for cls in all_objs:
- # Can only parse real messages
- if not cls in of_messages:
- print "Not testing " + ofmsg_names[cls]
- continue
- print "Parse test for class " + ofmsg_names[cls]
- obj = cls()
- packed = obj.pack()
- header = of_header_parse(packed)
- obj_check = of_message_parse(packed)
- obj_comp(obj, obj_check, ofmsg_names[cls], "parse test")
-
-print "End of parse testing"
-print
-print
-
-class_action_test()
-print
-print
-
-#
-# TO DO
-# Generate varying actions lists and attach to flow_mod,
-# packet out and flow_stats_entry objects.
-# Generate varying lists of stats entries for replies in
-# flow_stats_reply, table_stats_reply, port_stats_reply and
-# queue_stats_reply
-# Create and test packet-to-flow function
-
-
-f = flow_stats_reply()
-ent = flow_stats_entry()
-
-
-act = action_strip_vlan()
-alist = action_list()
-alist.add(act)
-
-act = action_set_tp_dst()
-act.tp_port = 17
-
-m = ofp_match()
-m.wildcards = OFPFW_IN_PORT + OFPFW_DL_VLAN + OFPFW_DL_SRC
-
-#
-# Need: Easy reference from action to data members
-m.in_port = 12
-m.dl_src= [1,2,3,4,5,6]
-m.dl_dst= [11,22,23,24,25,26]
-m.dl_vlan = 83
-m.dl_vlan_pcp = 1
-m.dl_type = 0x12
-m.nw_tos = 3
-m.nw_proto = 0x300
-m.nw_src = 0x232323
-m.nw_dst = 0x3232123
-m.tp_src = 32
-m.tp_dst = 2
-
-m.show()
-
diff --git a/tools/pylibopenflow/.gitignore b/tools/pylibopenflow/.gitignore
deleted file mode 100644
index 2f836aa..0000000
--- a/tools/pylibopenflow/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-*~
-*.pyc
diff --git a/tools/pylibopenflow/bin/cstruct2py-get-struct.py b/tools/pylibopenflow/bin/cstruct2py-get-struct.py
deleted file mode 100755
index d78d7c8..0000000
--- a/tools/pylibopenflow/bin/cstruct2py-get-struct.py
+++ /dev/null
@@ -1,76 +0,0 @@
-#!/usr/bin/env python
-"""This script reads struct from C/C++ header file and output query
-
-Author ykk
-Date June 2009
-"""
-import sys
-import getopt
-import cheader
-import c2py
-
-
-def usage():
- """Display usage
- """
- print "Usage "+sys.argv[0]+" <options> header_files... struct_name\n"+\
- "Options:\n"+\
- "-h/--help\n\tPrint this usage guide\n"+\
- "-c/--cstruct\n\tPrint C struct\n"+\
- "-n/--name\n\tPrint names of struct\n"+\
- "-s/--size\n\tPrint size of struct\n"+\
- ""
-
-#Parse options and arguments
-try:
- opts, args = getopt.getopt(sys.argv[1:], "hcsn",
- ["help","cstruct","size","names"])
-except getopt.GetoptError:
- usage()
- sys.exit(2)
-
-#Check there is at least 1 input file and struct name
-if (len(args) < 2):
- usage()
- sys.exit(2)
-
-#Parse options
-##Print C struct
-printc = False
-##Print names
-printname = False
-##Print size
-printsize = False
-for opt,arg in opts:
- if (opt in ("-h","--help")):
- usage()
- sys.exit(0)
- elif (opt in ("-s","--size")):
- printsize = True
- elif (opt in ("-c","--cstruct")):
- printc = True
- elif (opt in ("-n","--names")):
- printname = True
- else:
- print "Unhandled option :"+opt
- sys.exit(1)
-
-headerfile = cheader.cheaderfile(args[:-1])
-cstruct = headerfile.structs[args[-1].strip()]
-cs2p = c2py.cstruct2py()
-pattern = cs2p.get_pattern(cstruct)
-
-#Print C struct
-if (printc):
- print cstruct
-
-#Print pattern
-print "Python pattern = "+pattern
-
-#Print name
-if (printname):
- print cstruct.get_names()
-
-#Print size
-if (printsize):
- print "Size = "+str(cs2p.get_size(pattern))
diff --git a/tools/pylibopenflow/bin/cstruct2py-pythonize.py b/tools/pylibopenflow/bin/cstruct2py-pythonize.py
deleted file mode 100755
index 39508cf..0000000
--- a/tools/pylibopenflow/bin/cstruct2py-pythonize.py
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/usr/bin/env python
-"""This script reads struct
-
-Author ykk
-Date Jan 2010
-"""
-import sys
-import getopt
-import cpythonize
-import cheader
-
-def usage():
- """Display usage
- """
- print "Usage "+sys.argv[0]+" <options> header_files... output_file\n"+\
- "Options:\n"+\
- "-h/--help\n\tPrint this usage guide\n"+\
- ""
-
-#Parse options and arguments
-try:
- opts, args = getopt.getopt(sys.argv[1:], "h",
- ["help"])
-except getopt.GetoptError:
- usage()
- sys.exit(2)
-
-#Parse options
-for opt,arg in opts:
- if (opt in ("-h","--help")):
- usage()
- sys.exit(0)
- else:
- print "Unhandled option :"+opt
- sys.exit(2)
-
-#Check there is at least 1 input file with 1 output file
-if (len(args) < 2):
- usage()
- sys.exit(2)
-
-ch = cheader.cheaderfile(args[:-1])
-py = cpythonize.pythonizer(ch)
-fileRef = open(args[len(args)-1], "w")
-for l in py.pycode():
- fileRef.write(l+"\n")
-fileRef.close()
-
diff --git a/tools/pylibopenflow/bin/cstruct2py-query-cheader.py b/tools/pylibopenflow/bin/cstruct2py-query-cheader.py
deleted file mode 100755
index ed82316..0000000
--- a/tools/pylibopenflow/bin/cstruct2py-query-cheader.py
+++ /dev/null
@@ -1,138 +0,0 @@
-#!/usr/bin/env python
-"""This script reads C/C++ header file and output query
-
-Author ykk
-Date June 2009
-"""
-import sys
-import getopt
-import cheader
-
-def usage():
- """Display usage
- """
- print "Usage "+sys.argv[0]+" <options> header_file_1 header_file_2 ...\n"+\
- "Options:\n"+\
- "-h/--help\n\tPrint this usage guide\n"+\
- "-E/--enums\n\tPrint all enumerations\n"+\
- "-e/--enum\n\tPrint specified enumeration\n"+\
- "-M/--macros\n\tPrint all macros\n"+\
- "-m/--macro\n\tPrint value of macro\n"+\
- "-S/--structs\n\tPrint all structs\n"+\
- "-s/--struct\n\tPrint struct\n"+\
- "-n/--name-only\n\tPrint names only\n"+\
- "-P/--print-no-comment\n\tPrint with comment removed only\n"+\
- ""
-
-#Parse options and arguments
-try:
- opts, args = getopt.getopt(sys.argv[1:], "hMm:Ee:Ss:nP",
- ["help","macros","macro=","enums","enum=",
- "structs","struct="
- "name-only","print-no-comment"])
-except getopt.GetoptError:
- usage()
- sys.exit(2)
-
-#Check there is at least input file
-if (len(args) < 1):
- usage()
- sys.exit(2)
-
-#Parse options
-##Print names only
-nameOnly = False
-##Print all structs?
-allStructs = False
-##Query specific struct
-struct=""
-##Print all enums?
-allEnums = False
-##Query specific enum
-enum=""
-##Print all macros?
-allMacros = False
-##Query specific macro
-macro=""
-##Print without comment
-printNoComment=False
-for opt,arg in opts:
- if (opt in ("-h","--help")):
- usage()
- sys.exit(0)
- elif (opt in ("-S","--structs")):
- allStructs = True
- elif (opt in ("-s","--struct")):
- struct = arg
- elif (opt in ("-M","--macros")):
- allMacros = True
- elif (opt in ("-m","--macro")):
- macro=arg
- elif (opt in ("-E","--enums")):
- allEnums = True
- elif (opt in ("-e","--enum")):
- enum = arg
- elif (opt in ("-n","--name-only")):
- nameOnly = True
- elif (opt in ("-P","--print-no-comment")):
- printNoComment = True
- else:
- assert (False,"Unhandled option :"+opt)
-
-headerfile = cheader.cheaderfile(args)
-if (printNoComment):
- for line in headerfile.content:
- print line
- sys.exit(0)
-
-#Print all macros
-if (allMacros):
- for (macroname, value) in headerfile.macros.items():
- if (nameOnly):
- print macroname
- else:
- print macroname+"\t=\t"+str(value)
-#Print specified macro
-if (macro != ""):
- try:
- print macro+"="+headerfile.macros[macro]
- except KeyError:
- print "Macro "+macro+" not found!"
-
-#Print all structs
-if (allStructs):
- for (structname, value) in headerfile.structs.items():
- if (nameOnly):
- print structname
- else:
- print str(value)+"\n"
-
-#Print specified struct
-if (struct != ""):
- try:
- print str(headerfile.structs[struct])
- except KeyError:
- print "Struct "+struct+" not found!"
-
-#Print all enumerations
-if (allEnums):
- for (enumname, values) in headerfile.enums.items():
- print enumname
- if (not nameOnly):
- for enumval in values:
- try:
- print "\t"+enumval+"="+\
- str(headerfile.enum_values[enumval])
- except KeyError:
- print enumval+" not found in enum!";
-
-#Print specifed enum
-if (enum != ""):
- try:
- for enumval in headerfile.enums[enum]:
- try:
- print enumval+"="+str(headerfile.enum_values[enumval])
- except KeyError:
- print enumval+" not found in enum!";
- except KeyError:
- print "Enumeration "+enum+" not found!"
diff --git a/tools/pylibopenflow/bin/pyopenflow-get-struct.py b/tools/pylibopenflow/bin/pyopenflow-get-struct.py
deleted file mode 100755
index d07d85e..0000000
--- a/tools/pylibopenflow/bin/pyopenflow-get-struct.py
+++ /dev/null
@@ -1,74 +0,0 @@
-#!/usr/bin/env python
-"""This script reads struct from OpenFlow header file and output query
-
-(C) Copyright Stanford University
-Author ykk
-Date October 2009
-"""
-import sys
-import getopt
-import openflow
-
-def usage():
- """Display usage
- """
- print "Usage "+sys.argv[0]+" <options> struct_name\n"+\
- "Options:\n"+\
- "-h/--help\n\tPrint this usage guide\n"+\
- "-c/--cstruct\n\tPrint C struct\n"+\
- "-n/--name\n\tPrint names of struct\n"+\
- "-s/--size\n\tPrint size of struct\n"+\
- ""
-
-#Parse options and arguments
-try:
- opts, args = getopt.getopt(sys.argv[1:], "hcsn",
- ["help","cstruct","size","names"])
-except getopt.GetoptError:
- usage()
- sys.exit(2)
-
-#Check there is only struct name
-if not (len(args) == 1):
- usage()
- sys.exit(2)
-
-#Parse options
-##Print C struct
-printc = False
-##Print names
-printname = False
-##Print size
-printsize = False
-for opt,arg in opts:
- if (opt in ("-h","--help")):
- usage()
- sys.exit(0)
- elif (opt in ("-s","--size")):
- printsize = True
- elif (opt in ("-c","--cstruct")):
- printc = True
- elif (opt in ("-n","--names")):
- printname = True
- else:
- assert (False,"Unhandled option :"+opt)
-
-pyopenflow = openflow.messages()
-cstruct = pyopenflow.structs[args[0].strip()]
-pattern = pyopenflow.get_pattern(cstruct)
-
-#Print C struct
-if (printc):
- print cstruct
-
-#Print pattern
-print "Python pattern = "+str(pattern)
-
-#Print name
-if (printname):
- print cstruct.get_names()
-
-#Print size
-if (printsize):
- print "Size = "+str(pyopenflow.get_size(pattern))
-
diff --git a/tools/pylibopenflow/bin/pyopenflow-lavi-pythonize.py b/tools/pylibopenflow/bin/pyopenflow-lavi-pythonize.py
deleted file mode 100755
index 914a424..0000000
--- a/tools/pylibopenflow/bin/pyopenflow-lavi-pythonize.py
+++ /dev/null
@@ -1,89 +0,0 @@
-#!/usr/bin/env python
-"""This script generate class files for messenger and lavi in NOX,
-specifically it creates a Python class for each data structure.
-
-(C) Copyright Stanford University
-Author ykk
-Date January 2010
-"""
-import sys
-import os.path
-import getopt
-import cheader
-import lavi.pythonize
-
-def usage():
- """Display usage
- """
- print "Usage "+sys.argv[0]+" <options> nox_dir\n"+\
- "Options:\n"+\
- "-i/--input-dir\n\tSpecify input directory (nox src directory)\n"+\
- "-t/--template\n\tSpecify (non-default) template file\n"+\
- "-n/--no-lavi\n\tSpecify that LAVI's file will not be created\n"+\
- "-h/--help\n\tPrint this usage guide\n"+\
- ""
-
-#Parse options and arguments
-try:
- opts, args = getopt.getopt(sys.argv[1:], "hm:n",
- ["help","messenger-template","no-lavi"])
-except getopt.GetoptError:
- usage()
- sys.exit(2)
-
-#Check there is only NOX directory given
-if not (len(args) == 1):
- usage()
- sys.exit(2)
-
-#Parse options
-##Output LAVI
-outputlavi=True
-##Template file
-templatefile="include/messenger.template.py"
-for opt,arg in opts:
- if (opt in ("-h","--help")):
- usage()
- sys.exit(0)
- elif (opt in ("-t","--template")):
- templatefile=arg
- elif (opt in ("-n","--no-lavi")):
- outputlavi=False
- else:
- print "Unhandled option:"+opt
- sys.exit(2)
-
-#Check for header file in NOX directory
-if not (os.path.isfile(args[0]+"/src/nox/coreapps/messenger/message.hh")):
- print "Messenger header file not found!"
- sys.exit(2)
-if (outputlavi):
- if not (os.path.isfile(args[0]+"/src/nox/netapps/lavi/lavi-message.hh")):
- print "LAVI message header file not found!"
- sys.exit(2)
-
-#Get headerfile and pythonizer
-msgheader = cheader.cheaderfile(args[0]+"/src/nox/coreapps/messenger/message.hh")
-mpynizer = lavi.pythonize.msgpythonizer(msgheader)
-if (outputlavi):
- laviheader = cheader.cheaderfile([args[0]+"/src/nox/coreapps/messenger/message.hh",
- args[0]+"/src/nox/netapps/lavi/lavi-message.hh"])
- lpynizer = lavi.pythonize.lavipythonizer(laviheader)
-
-#Generate Python code for messenger
-fileRef = open(args[0]+"/src/nox/coreapps/messenger/messenger.py", "w")
-for x in mpynizer.pycode(templatefile):
- fileRef.write(x+"\n")
-fileRef.write("\n")
-fileRef.close()
-
-if (outputlavi):
- fileRef = open(args[0]+"/src/nox/netapps/lavi/lavi.py", "w")
- for x in lpynizer.pycode(templatefile):
- fileRef.write(x.replace("def __init__(self,ipAddr,portNo=2603,debug=False):",
- "def __init__(self,ipAddr,portNo=2503,debug=False):").\
- replace("def __init__(self, ipAddr, portNo=1304,debug=False):",
- "def __init__(self, ipAddr, portNo=1305,debug=False):")+\
- "\n")
- fileRef.write("\n")
- fileRef.close()
diff --git a/tools/pylibopenflow/bin/pyopenflow-load-controller.py b/tools/pylibopenflow/bin/pyopenflow-load-controller.py
deleted file mode 100755
index 715a73a..0000000
--- a/tools/pylibopenflow/bin/pyopenflow-load-controller.py
+++ /dev/null
@@ -1,131 +0,0 @@
-#!/usr/bin/env python
-"""This script fakes as n OpenFlow switch and
-load the controller with k packets per second.
-
-(C) Copyright Stanford University
-Author ykk
-Date January 2010
-"""
-import sys
-import getopt
-import struct
-import openflow
-import time
-import output
-import of.msg
-import of.simu
-import of.network
-import dpkt.ethernet
-
-def usage():
- """Display usage
- """
- print "Usage "+sys.argv[0]+" <options> controller\n"+\
- "Options:\n"+\
- "-p/--port\n\tSpecify port number\n"+\
- "-v/--verbose\n\tPrint message exchange\n"+\
- "-r/--rate\n\tSpecify rate per switch to send packets (default=1)\n"+\
- "-d/--duration\n\tSpecify duration of load test in seconds (default=5)\n"+\
- "-s/--switch\n\tSpecify number of switches (default=1)\n"+\
- "-h/--help\n\tPrint this usage guide\n"+\
- ""
-
-#Parse options and arguments
-try:
- opts, args = getopt.getopt(sys.argv[1:], "hvp:s:d:r:",
- ["help","verbose","port=",
- "switch=","duration=","rate="])
-except getopt.GetoptError:
- usage()
- sys.exit(2)
-
-#Check there is only controller
-if not (len(args) == 1):
- usage()
- sys.exit(2)
-
-#Parse options
-##Duration
-duration = 5
-##Rate
-rate = 1.0
-##Switch number
-swno = 1
-##Port to connect to
-port = 6633
-##Set output mode
-output.set_mode("INFO")
-for opt,arg in opts:
- if (opt in ("-h","--help")):
- usage()
- sys.exit(0)
- elif (opt in ("-v","--verbose")):
- output.set_mode("DBG")
- elif (opt in ("-p","--port")):
- port=int(arg)
- elif (opt in ("-s","--switch")):
- swno=int(arg)
- elif (opt in ("-d","--duration")):
- duration=int(arg)
- elif (opt in ("-r","--rate")):
- rate=float(arg)
- else:
- print "Unhandled option :"+opt
- sys.exit(2)
-
-#Form packet
-pkt = dpkt.ethernet.Ethernet()
-pkt.type = dpkt.ethernet.ETH_MIN
-pkt.dst = '\xFF\xFF\xFF\xFF\xFF\xFF'
-
-#Connect to controller
-ofmsg = openflow.messages()
-parser = of.msg.parser(ofmsg)
-ofnet = of.simu.network()
-for i in range(1,swno+1):
- ofsw = of.simu.switch(ofmsg, args[0], port,
- dpid=i,
- parser=parser)
- ofnet.add_switch(ofsw)
- ofsw.send_hello()
-
-output.info("Running "+str(swno)+" switches at "+str(rate)+\
- " packets per seconds for "+str(duration)+" s")
-
-starttime = time.time()
-running = True
-interval = 1.0/(rate*swno)
-ntime=time.time()+(interval/10.0)
-swindex = 0
-pcount = 0
-rcount = 0
-while running:
- ctime = time.time()
- time.sleep(max(0,min(ntime-ctime,interval/10.0)))
-
- if ((ctime-starttime) <= duration):
- #Send packet if time's up
- if (ctime >= ntime):
- ntime += interval
- pkt.src = struct.pack("Q",pcount)[:6]
- ofnet.switches[swindex].send_packet(1,10,pkt.pack()+'A'*3)
- pcount += 1
- swno += 1
- if (swno >= len(ofnet.switches)):
- swno=0
-
- #Process any received message
- (ofsw, msg) = ofnet.connections.msgreceive()
- while (msg != None):
- dic = ofmsg.peek_from_front("ofp_header", msg)
- if (dic["type"][0] == ofmsg.get_value("OFPT_FLOW_MOD")):
- output.dbg("Received flow mod")
- rcount += 1
- ofsw.receive_openflow(msg)
- (ofsw, msg) = ofnet.connections.msgreceive()
- else:
- running = False
-
-output.info("Sent "+str(pcount)+" packets at rate "+\
- str(float(pcount)/float(duration))+" and received "+\
- str(rcount)+" back")
diff --git a/tools/pylibopenflow/bin/pyopenflow-ping-controller.py b/tools/pylibopenflow/bin/pyopenflow-ping-controller.py
deleted file mode 100755
index cae3a43..0000000
--- a/tools/pylibopenflow/bin/pyopenflow-ping-controller.py
+++ /dev/null
@@ -1,78 +0,0 @@
-#!/usr/bin/env python
-"""This script fakes as an OpenFlow switch to the controller
-
-(C) Copyright Stanford University
-Author ykk
-Date October 2009
-"""
-import sys
-import getopt
-import openflow
-import time
-import output
-import of.msg
-import of.simu
-
-def usage():
- """Display usage
- """
- print "Usage "+sys.argv[0]+" <options> controller\n"+\
- "Options:\n"+\
- "-p/--port\n\tSpecify port number\n"+\
- "-v/--verbose\n\tPrint message exchange\n"+\
- "-h/--help\n\tPrint this usage guide\n"+\
- ""
-
-#Parse options and arguments
-try:
- opts, args = getopt.getopt(sys.argv[1:], "hvp:",
- ["help","verbose","port="])
-except getopt.GetoptError:
- usage()
- sys.exit(2)
-
-#Check there is only controller
-if not (len(args) == 1):
- usage()
- sys.exit(2)
-
-#Parse options
-##Port to connect to
-port = 6633
-##Set output mode
-output.set_mode("INFO")
-for opt,arg in opts:
- if (opt in ("-h","--help")):
- usage()
- sys.exit(0)
- elif (opt in ("-v","--verbose")):
- output.set_mode("DBG")
- elif (opt in ("-p","--port")):
- port=int(arg)
- else:
- assert (False,"Unhandled option :"+opt)
-
-#Connect to controller
-ofmsg = openflow.messages()
-parser = of.msg.parser(ofmsg)
-ofsw = of.simu.switch(ofmsg, args[0], port,
- dpid=int("0xcafecafe",16),
- parser=parser)
-ofsw.send_hello()
-#Send echo and wait
-xid = 22092009
-running = True
-ofsw.send_echo(xid)
-starttime = time.time()
-while running:
- msg = ofsw.connection.msgreceive(True, 0.00001)
- pkttime = time.time()
- dic = ofmsg.peek_from_front("ofp_header", msg)
- if (dic["type"][0] == ofmsg.get_value("OFPT_ECHO_REPLY") and
- dic["xid"][0] == xid):
- #Check reply for echo request
- output.info("Received echo reply after "+\
- str((pkttime-starttime)*1000)+" ms", "ping-controller")
- running = False
- else:
- ofsw.receive_openflow(msg)
diff --git a/tools/pylibopenflow/bin/pyopenflow-pythonize.py b/tools/pylibopenflow/bin/pyopenflow-pythonize.py
deleted file mode 100755
index 6da4af9..0000000
--- a/tools/pylibopenflow/bin/pyopenflow-pythonize.py
+++ /dev/null
@@ -1,67 +0,0 @@
-#!/usr/bin/env python
-"""This script generate openflow-packets.py which
-creates Python class for each data structure in openflow.h.
-
-(C) Copyright Stanford University
-Author ykk
-Date December 2009
-"""
-import sys
-#@todo Fix this include path mechanism
-sys.path.append('./bin')
-sys.path.append('./pylib')
-import getopt
-import openflow
-import time
-import output
-import of.pythonize
-
-def usage():
- """Display usage
- """
- print "Usage "+sys.argv[0]+" <options> output_file\n"+\
- "Options:\n"+\
- "-i/--input\n\tSpecify (non-default) OpenFlow header\n"+\
- "-t/--template\n\tSpecify (non-default) template file\n"+\
- "-h/--help\n\tPrint this usage guide\n"+\
- ""
-
-#Parse options and arguments
-try:
- opts, args = getopt.getopt(sys.argv[1:], "hi:t:",
- ["help","input","template"])
-except getopt.GetoptError:
- usage()
- sys.exit(2)
-
-#Check there is only output file
-if not (len(args) == 1):
- usage()
- sys.exit(2)
-
-#Parse options
-##Input
-headerfile=None
-##Template file
-templatefile=None
-for opt,arg in opts:
- if (opt in ("-h","--help")):
- usage()
- sys.exit(0)
- elif (opt in ("-i","--input")):
- headerfile=arg
- elif (opt in ("-t","--template")):
- templatefile=arg
- else:
- print "Unhandled option:"+opt
- sys.exit(2)
-
-#Generate Python code
-ofmsg = openflow.messages(headerfile)
-pynizer = of.pythonize.pythonizer(ofmsg)
-
-fileRef = open(args[0], "w")
-for x in pynizer.pycode(templatefile):
- fileRef.write(x+"\n")
-fileRef.write("\n")
-fileRef.close()
diff --git a/tools/pylibopenflow/include/Put_C_header_files_here b/tools/pylibopenflow/include/Put_C_header_files_here
deleted file mode 100644
index e69de29..0000000
--- a/tools/pylibopenflow/include/Put_C_header_files_here
+++ /dev/null
diff --git a/tools/pylibopenflow/include/messenger.template.py b/tools/pylibopenflow/include/messenger.template.py
deleted file mode 100644
index 25e7c76..0000000
--- a/tools/pylibopenflow/include/messenger.template.py
+++ /dev/null
@@ -1,115 +0,0 @@
-import socket
-import select
-
-## This module provides library to send and receive messages to NOX's messenger
-#
-# This is a rewrite of noxmsg.py from OpenRoads (OpenFlow Wireless)
-#
-# @author ykk (Stanford University)
-# @date January, 2010
-# @see messenger
-
-def stringarray(string):
- """Output array of binary values in string.
- """
- arrstr = ""
- if (len(string) != 0):
- for i in range(0,len(string)):
- arrstr += "%x " % struct.unpack("=B",string[i])[0]
- return arrstr
-
-def printarray(string):
- """Print array of binary values
- """
- print "Array of length "+str(len(string))
- print stringarray(string)
-
-class channel:
- """TCP channel to communicate to NOX with.
- """
- def __init__(self,ipAddr,portNo=2603,debug=False):
- """Initialize with socket
- """
- ##Socket reference for channel
- self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- self.sock.connect((ipAddr,portNo))
- self.debug = debug
- ##Internal buffer for receiving
- self.__buffer = ""
- ##Internal reference to header
- self.__header = messenger_msg()
-
- def baresend(self, msg):
- """Send bare message"""
- self.sock.send(msg)
-
- def send(self,msg):
- """Send message
- """
- msgh = messenger_msg()
- remaining = msgh.unpack(msg)
- if (msgh.length != len(msg)):
- msgh.length = len(msg)
- msg = msgh.pack()+remaining
- self.baresend(msg)
- if (self.debug):
- printarray(msg)
-
- def receive(self, recvLen=0,timeout=0):
- """Receive command
- If length == None, nonblocking receive (return None or message)
- With nonblocking receive, timeout is used for select statement
-
- If length is zero, return single message
- """
- if (recvLen==0):
- #Receive full message
- msg=""
- length=len(self.__header)
- while (len(msg) < length):
- msg+=self.sock.recv(1)
- #Get length
- if (len(msg) == length):
- self.__header.unpack(msg)
- length=self.__header.length
- return msg
- elif (recvLen==None):
- #Non-blocking receive
- ready_to_read = select.select([self.sock],[],[],timeout)[0]
- if (ready_to_read):
- self.__buffer += self.sock.recv(1)
- if (len(self.__buffer) >= len(self.__header)):
- self.__header.unpack(self.__buffer)
- if (self.__header.length == len(self.__buffer)):
- msg = self.__buffer
- self.__buffer = ""
- return msg
- return None
- else:
- #Fixed length blocking receive
- return self.sock.recv(recvLen)
-
- def __del__(self):
- """Terminate connection
- """
- emsg = messenger_msg()
- emsg.type = MSG_DISCONNECT
- emsg.length = len(emsg)
- self.send(emsg.pack())
- self.sock.shutdown(1)
- self.sock.close()
-
-class sslChannel(channel):
- """SSL channel to communicate to NOX with.
- """
- def __init__(self, ipAddr, portNo=1304,debug=False):
- """Initialize with SSL sock
- """
- NOXChannel.__init__(self, ipAddr, portNo,debug)
- ##Reference to SSL socket for channel
- self.sslsock = socket.ssl(self.sock)
-
- def baresend(self, msg):
- """Send bare message"""
- self.sslsock.write(msg)
-
diff --git a/tools/pylibopenflow/include/openflow.h b/tools/pylibopenflow/include/openflow.h
deleted file mode 100644
index c0b5090..0000000
--- a/tools/pylibopenflow/include/openflow.h
+++ /dev/null
@@ -1,970 +0,0 @@
-/* Copyright (c) 2008 The Board of Trustees of The Leland Stanford
- * Junior University
- *
- * We are making the OpenFlow specification and associated documentation
- * (Software) available for public use and benefit with the expectation
- * that others will use, modify and enhance the Software and contribute
- * those enhancements back to the community. However, since we would
- * like to make the Software available for broadest use, with as few
- * restrictions as possible permission is hereby granted, free of
- * charge, to any person obtaining a copy of this Software to deal in
- * the Software under the copyrights without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * The name and trademarks of copyright holder(s) may NOT be used in
- * advertising or publicity pertaining to the Software or any
- * derivatives without specific, written prior permission.
- */
-
-/* OpenFlow: protocol between controller and datapath. */
-
-#ifndef OPENFLOW_OPENFLOW_H
-#define OPENFLOW_OPENFLOW_H 1
-
-#ifdef __KERNEL__
-#include <linux/types.h>
-#else
-#include <stdint.h>
-#endif
-
-#ifdef SWIG
-#define OFP_ASSERT(EXPR) /* SWIG can't handle OFP_ASSERT. */
-#elif !defined(__cplusplus)
-/* Build-time assertion for use in a declaration context. */
-#define OFP_ASSERT(EXPR) \
- extern int (*build_assert(void))[ sizeof(struct { \
- unsigned int build_assert_failed : (EXPR) ? 1 : -1; })]
-#else /* __cplusplus */
-#define OFP_ASSERT(_EXPR) typedef int build_assert_failed[(_EXPR) ? 1 : -1]
-#endif /* __cplusplus */
-
-#ifndef SWIG
-#define OFP_PACKED __attribute__((packed))
-#else
-#define OFP_PACKED /* SWIG doesn't understand __attribute. */
-#endif
-
-/* Version number:
- * Non-experimental versions released: 0x01
- * Experimental versions released: 0x81 -- 0x99
- */
-/* The most significant bit being set in the version field indicates an
- * experimental OpenFlow version.
- */
-#define OFP_VERSION 0x01
-
-#define OFP_MAX_TABLE_NAME_LEN 32
-#define OFP_MAX_PORT_NAME_LEN 16
-
-#define OFP_TCP_PORT 6633
-#define OFP_SSL_PORT 6633
-
-#define OFP_ETH_ALEN 6 /* Bytes in an Ethernet address. */
-
-/* Port numbering. Physical ports are numbered starting from 1. */
-enum ofp_port {
- /* Maximum number of physical switch ports. */
- OFPP_MAX = 0xff00,
-
- /* Fake output "ports". */
- OFPP_IN_PORT = 0xfff8, /* Send the packet out the input port. This
- virtual port must be explicitly used
- in order to send back out of the input
- port. */
- OFPP_TABLE = 0xfff9, /* Perform actions in flow table.
- NB: This can only be the destination
- port for packet-out messages. */
- OFPP_NORMAL = 0xfffa, /* Process with normal L2/L3 switching. */
- OFPP_FLOOD = 0xfffb, /* All physical ports except input port and
- those disabled by STP. */
- OFPP_ALL = 0xfffc, /* All physical ports except input port. */
- OFPP_CONTROLLER = 0xfffd, /* Send to controller. */
- OFPP_LOCAL = 0xfffe, /* Local openflow "port". */
- OFPP_NONE = 0xffff /* Not associated with a physical port. */
-};
-
-enum ofp_type {
- /* Immutable messages. */
- OFPT_HELLO, /* Symmetric message */
- OFPT_ERROR, /* Symmetric message */
- OFPT_ECHO_REQUEST, /* Symmetric message */
- OFPT_ECHO_REPLY, /* Symmetric message */
- OFPT_VENDOR, /* Symmetric message */
-
- /* Switch configuration messages. */
- OFPT_FEATURES_REQUEST, /* Controller/switch message */
- OFPT_FEATURES_REPLY, /* Controller/switch message */
- OFPT_GET_CONFIG_REQUEST, /* Controller/switch message */
- OFPT_GET_CONFIG_REPLY, /* Controller/switch message */
- OFPT_SET_CONFIG, /* Controller/switch message */
-
- /* Asynchronous messages. */
- OFPT_PACKET_IN, /* Async message */
- OFPT_FLOW_REMOVED, /* Async message */
- OFPT_PORT_STATUS, /* Async message */
-
- /* Controller command messages. */
- OFPT_PACKET_OUT, /* Controller/switch message */
- OFPT_FLOW_MOD, /* Controller/switch message */
- OFPT_PORT_MOD, /* Controller/switch message */
-
- /* Statistics messages. */
- OFPT_STATS_REQUEST, /* Controller/switch message */
- OFPT_STATS_REPLY, /* Controller/switch message */
-
- /* Barrier messages. */
- OFPT_BARRIER_REQUEST, /* Controller/switch message */
- OFPT_BARRIER_REPLY, /* Controller/switch message */
-
- /* Queue Configuration messages. */
- OFPT_QUEUE_GET_CONFIG_REQUEST, /* Controller/switch message */
- OFPT_QUEUE_GET_CONFIG_REPLY /* Controller/switch message */
-
-};
-
-/* Header on all OpenFlow packets. */
-struct ofp_header {
- uint8_t version; /* OFP_VERSION. */
- uint8_t type; /* One of the OFPT_ constants. */
- uint16_t length; /* Length including this ofp_header. */
- uint32_t xid; /* Transaction id associated with this packet.
- Replies use the same id as was in the request
- to facilitate pairing. */
-};
-OFP_ASSERT(sizeof(struct ofp_header) == 8);
-
-/* OFPT_HELLO. This message has an empty body, but implementations must
- * ignore any data included in the body, to allow for future extensions. */
-struct ofp_hello {
- struct ofp_header header;
-};
-
-#define OFP_DEFAULT_MISS_SEND_LEN 128
-
-enum ofp_config_flags {
- /* Handling of IP fragments. */
- OFPC_FRAG_NORMAL = 0, /* No special handling for fragments. */
- OFPC_FRAG_DROP = 1, /* Drop fragments. */
- OFPC_FRAG_REASM = 2, /* Reassemble (only if OFPC_IP_REASM set). */
- OFPC_FRAG_MASK = 3
-};
-
-/* Switch configuration. */
-struct ofp_switch_config {
- struct ofp_header header;
- uint16_t flags; /* OFPC_* flags. */
- uint16_t miss_send_len; /* Max bytes of new flow that datapath should
- send to the controller. */
-};
-OFP_ASSERT(sizeof(struct ofp_switch_config) == 12);
-
-/* Capabilities supported by the datapath. */
-enum ofp_capabilities {
- OFPC_FLOW_STATS = 1 << 0, /* Flow statistics. */
- OFPC_TABLE_STATS = 1 << 1, /* Table statistics. */
- OFPC_PORT_STATS = 1 << 2, /* Port statistics. */
- OFPC_STP = 1 << 3, /* 802.1d spanning tree. */
- OFPC_RESERVED = 1 << 4, /* Reserved, must be zero. */
- OFPC_IP_REASM = 1 << 5, /* Can reassemble IP fragments. */
- OFPC_QUEUE_STATS = 1 << 6, /* Queue statistics. */
- OFPC_ARP_MATCH_IP = 1 << 7 /* Match IP addresses in ARP pkts. */
-};
-
-/* Flags to indicate behavior of the physical port. These flags are
- * used in ofp_phy_port to describe the current configuration. They are
- * used in the ofp_port_mod message to configure the port's behavior.
- */
-enum ofp_port_config {
- OFPPC_PORT_DOWN = 1 << 0, /* Port is administratively down. */
-
- OFPPC_NO_STP = 1 << 1, /* Disable 802.1D spanning tree on port. */
- OFPPC_NO_RECV = 1 << 2, /* Drop all packets except 802.1D spanning
- tree packets. */
- OFPPC_NO_RECV_STP = 1 << 3, /* Drop received 802.1D STP packets. */
- OFPPC_NO_FLOOD = 1 << 4, /* Do not include this port when flooding. */
- OFPPC_NO_FWD = 1 << 5, /* Drop packets forwarded to port. */
- OFPPC_NO_PACKET_IN = 1 << 6 /* Do not send packet-in msgs for port. */
-};
-
-/* Current state of the physical port. These are not configurable from
- * the controller.
- */
-enum ofp_port_state {
- OFPPS_LINK_DOWN = 1 << 0, /* No physical link present. */
-
- /* The OFPPS_STP_* bits have no effect on switch operation. The
- * controller must adjust OFPPC_NO_RECV, OFPPC_NO_FWD, and
- * OFPPC_NO_PACKET_IN appropriately to fully implement an 802.1D spanning
- * tree. */
- OFPPS_STP_LISTEN = 0 << 8, /* Not learning or relaying frames. */
- OFPPS_STP_LEARN = 1 << 8, /* Learning but not relaying frames. */
- OFPPS_STP_FORWARD = 2 << 8, /* Learning and relaying frames. */
- OFPPS_STP_BLOCK = 3 << 8, /* Not part of spanning tree. */
- OFPPS_STP_MASK = 3 << 8 /* Bit mask for OFPPS_STP_* values. */
-};
-
-/* Features of physical ports available in a datapath. */
-enum ofp_port_features {
- OFPPF_10MB_HD = 1 << 0, /* 10 Mb half-duplex rate support. */
- OFPPF_10MB_FD = 1 << 1, /* 10 Mb full-duplex rate support. */
- OFPPF_100MB_HD = 1 << 2, /* 100 Mb half-duplex rate support. */
- OFPPF_100MB_FD = 1 << 3, /* 100 Mb full-duplex rate support. */
- OFPPF_1GB_HD = 1 << 4, /* 1 Gb half-duplex rate support. */
- OFPPF_1GB_FD = 1 << 5, /* 1 Gb full-duplex rate support. */
- OFPPF_10GB_FD = 1 << 6, /* 10 Gb full-duplex rate support. */
- OFPPF_COPPER = 1 << 7, /* Copper medium. */
- OFPPF_FIBER = 1 << 8, /* Fiber medium. */
- OFPPF_AUTONEG = 1 << 9, /* Auto-negotiation. */
- OFPPF_PAUSE = 1 << 10, /* Pause. */
- OFPPF_PAUSE_ASYM = 1 << 11 /* Asymmetric pause. */
-};
-
-/* Description of a physical port */
-struct ofp_phy_port {
- uint16_t port_no;
- uint8_t hw_addr[OFP_ETH_ALEN];
- char name[OFP_MAX_PORT_NAME_LEN]; /* Null-terminated */
-
- uint32_t config; /* Bitmap of OFPPC_* flags. */
- uint32_t state; /* Bitmap of OFPPS_* flags. */
-
- /* Bitmaps of OFPPF_* that describe features. All bits zeroed if
- * unsupported or unavailable. */
- uint32_t curr; /* Current features. */
- uint32_t advertised; /* Features being advertised by the port. */
- uint32_t supported; /* Features supported by the port. */
- uint32_t peer; /* Features advertised by peer. */
-};
-OFP_ASSERT(sizeof(struct ofp_phy_port) == 48);
-
-/* Switch features. */
-struct ofp_switch_features {
- struct ofp_header header;
- uint64_t datapath_id; /* Datapath unique ID. The lower 48-bits are for
- a MAC address, while the upper 16-bits are
- implementer-defined. */
-
- uint32_t n_buffers; /* Max packets buffered at once. */
-
- uint8_t n_tables; /* Number of tables supported by datapath. */
- uint8_t pad[3]; /* Align to 64-bits. */
-
- /* Features. */
- uint32_t capabilities; /* Bitmap of support "ofp_capabilities". */
- uint32_t actions; /* Bitmap of supported "ofp_action_type"s. */
-
- /* Port info.*/
- struct ofp_phy_port ports[0]; /* Port definitions. The number of ports
- is inferred from the length field in
- the header. */
-};
-OFP_ASSERT(sizeof(struct ofp_switch_features) == 32);
-
-/* What changed about the physical port */
-enum ofp_port_reason {
- OFPPR_ADD, /* The port was added. */
- OFPPR_DELETE, /* The port was removed. */
- OFPPR_MODIFY /* Some attribute of the port has changed. */
-};
-
-/* A physical port has changed in the datapath */
-struct ofp_port_status {
- struct ofp_header header;
- uint8_t reason; /* One of OFPPR_*. */
- uint8_t pad[7]; /* Align to 64-bits. */
- struct ofp_phy_port desc;
-};
-OFP_ASSERT(sizeof(struct ofp_port_status) == 64);
-
-/* Modify behavior of the physical port */
-struct ofp_port_mod {
- struct ofp_header header;
- uint16_t port_no;
- uint8_t hw_addr[OFP_ETH_ALEN]; /* The hardware address is not
- configurable. This is used to
- sanity-check the request, so it must
- be the same as returned in an
- ofp_phy_port struct. */
-
- uint32_t config; /* Bitmap of OFPPC_* flags. */
- uint32_t mask; /* Bitmap of OFPPC_* flags to be changed. */
-
- uint32_t advertise; /* Bitmap of "ofp_port_features"s. Zero all
- bits to prevent any action taking place. */
- uint8_t pad[4]; /* Pad to 64-bits. */
-};
-OFP_ASSERT(sizeof(struct ofp_port_mod) == 32);
-
-/* Why is this packet being sent to the controller? */
-enum ofp_packet_in_reason {
- OFPR_NO_MATCH, /* No matching flow. */
- OFPR_ACTION /* Action explicitly output to controller. */
-};
-
-/* Packet received on port (datapath -> controller). */
-struct ofp_packet_in {
- struct ofp_header header;
- uint32_t buffer_id; /* ID assigned by datapath. */
- uint16_t total_len; /* Full length of frame. */
- uint16_t in_port; /* Port on which frame was received. */
- uint8_t reason; /* Reason packet is being sent (one of OFPR_*) */
- uint8_t pad;
- uint8_t data[0]; /* Ethernet frame, halfway through 32-bit word,
- so the IP header is 32-bit aligned. The
- amount of data is inferred from the length
- field in the header. Because of padding,
- offsetof(struct ofp_packet_in, data) ==
- sizeof(struct ofp_packet_in) - 2. */
-};
-OFP_ASSERT(sizeof(struct ofp_packet_in) == 20);
-
-enum ofp_action_type {
- OFPAT_OUTPUT, /* Output to switch port. */
- OFPAT_SET_VLAN_VID, /* Set the 802.1q VLAN id. */
- OFPAT_SET_VLAN_PCP, /* Set the 802.1q priority. */
- OFPAT_STRIP_VLAN, /* Strip the 802.1q header. */
- OFPAT_SET_DL_SRC, /* Ethernet source address. */
- OFPAT_SET_DL_DST, /* Ethernet destination address. */
- OFPAT_SET_NW_SRC, /* IP source address. */
- OFPAT_SET_NW_DST, /* IP destination address. */
- OFPAT_SET_NW_TOS, /* IP ToS (DSCP field, 6 bits). */
- OFPAT_SET_TP_SRC, /* TCP/UDP source port. */
- OFPAT_SET_TP_DST, /* TCP/UDP destination port. */
- OFPAT_ENQUEUE, /* Output to queue. */
- OFPAT_VENDOR = 0xffff
-};
-
-/* Action structure for OFPAT_OUTPUT, which sends packets out 'port'.
- * When the 'port' is the OFPP_CONTROLLER, 'max_len' indicates the max
- * number of bytes to send. A 'max_len' of zero means no bytes of the
- * packet should be sent.*/
-struct ofp_action_output {
- uint16_t type; /* OFPAT_OUTPUT. */
- uint16_t len; /* Length is 8. */
- uint16_t port; /* Output port. */
- uint16_t max_len; /* Max length to send to controller. */
-};
-OFP_ASSERT(sizeof(struct ofp_action_output) == 8);
-
-/* The VLAN id is 12 bits, so we can use the entire 16 bits to indicate
- * special conditions. All ones is used to match that no VLAN id was
- * set. */
-#define OFP_VLAN_NONE 0xffff
-
-/* Action structure for OFPAT_SET_VLAN_VID. */
-struct ofp_action_vlan_vid {
- uint16_t type; /* OFPAT_SET_VLAN_VID. */
- uint16_t len; /* Length is 8. */
- uint16_t vlan_vid; /* VLAN id. */
- uint8_t pad[2];
-};
-OFP_ASSERT(sizeof(struct ofp_action_vlan_vid) == 8);
-
-/* Action structure for OFPAT_SET_VLAN_PCP. */
-struct ofp_action_vlan_pcp {
- uint16_t type; /* OFPAT_SET_VLAN_PCP. */
- uint16_t len; /* Length is 8. */
- uint8_t vlan_pcp; /* VLAN priority. */
- uint8_t pad[3];
-};
-OFP_ASSERT(sizeof(struct ofp_action_vlan_pcp) == 8);
-
-/* Action structure for OFPAT_SET_DL_SRC/DST. */
-struct ofp_action_dl_addr {
- uint16_t type; /* OFPAT_SET_DL_SRC/DST. */
- uint16_t len; /* Length is 16. */
- uint8_t dl_addr[OFP_ETH_ALEN]; /* Ethernet address. */
- uint8_t pad[6];
-};
-OFP_ASSERT(sizeof(struct ofp_action_dl_addr) == 16);
-
-/* Action structure for OFPAT_SET_NW_SRC/DST. */
-struct ofp_action_nw_addr {
- uint16_t type; /* OFPAT_SET_TW_SRC/DST. */
- uint16_t len; /* Length is 8. */
- uint32_t nw_addr; /* IP address. */
-};
-OFP_ASSERT(sizeof(struct ofp_action_nw_addr) == 8);
-
-/* Action structure for OFPAT_SET_TP_SRC/DST. */
-struct ofp_action_tp_port {
- uint16_t type; /* OFPAT_SET_TP_SRC/DST. */
- uint16_t len; /* Length is 8. */
- uint16_t tp_port; /* TCP/UDP port. */
- uint8_t pad[2];
-};
-OFP_ASSERT(sizeof(struct ofp_action_tp_port) == 8);
-
-/* Action structure for OFPAT_SET_NW_TOS. */
-struct ofp_action_nw_tos {
- uint16_t type; /* OFPAT_SET_TW_SRC/DST. */
- uint16_t len; /* Length is 8. */
- uint8_t nw_tos; /* IP ToS (DSCP field, 6 bits). */
- uint8_t pad[3];
-};
-OFP_ASSERT(sizeof(struct ofp_action_nw_tos) == 8);
-
-/* Action header for OFPAT_VENDOR. The rest of the body is vendor-defined. */
-struct ofp_action_vendor_header {
- uint16_t type; /* OFPAT_VENDOR. */
- uint16_t len; /* Length is a multiple of 8. */
- uint32_t vendor; /* Vendor ID, which takes the same form
- as in "struct ofp_vendor_header". */
-};
-OFP_ASSERT(sizeof(struct ofp_action_vendor_header) == 8);
-
-/* Action header that is common to all actions. The length includes the
- * header and any padding used to make the action 64-bit aligned.
- * NB: The length of an action *must* always be a multiple of eight. */
-struct ofp_action_header {
- uint16_t type; /* One of OFPAT_*. */
- uint16_t len; /* Length of action, including this
- header. This is the length of action,
- including any padding to make it
- 64-bit aligned. */
- uint8_t pad[4];
-};
-OFP_ASSERT(sizeof(struct ofp_action_header) == 8);
-
-/* Send packet (controller -> datapath). */
-struct ofp_packet_out {
- struct ofp_header header;
- uint32_t buffer_id; /* ID assigned by datapath (-1 if none). */
- uint16_t in_port; /* Packet's input port (OFPP_NONE if none). */
- uint16_t actions_len; /* Size of action array in bytes. */
- struct ofp_action_header actions[0]; /* Actions. */
- /* uint8_t data[0]; */ /* Packet data. The length is inferred
- from the length field in the header.
- (Only meaningful if buffer_id == -1.) */
-};
-OFP_ASSERT(sizeof(struct ofp_packet_out) == 16);
-
-enum ofp_flow_mod_command {
- OFPFC_ADD, /* New flow. */
- OFPFC_MODIFY, /* Modify all matching flows. */
- OFPFC_MODIFY_STRICT, /* Modify entry strictly matching wildcards */
- OFPFC_DELETE, /* Delete all matching flows. */
- OFPFC_DELETE_STRICT /* Strictly match wildcards and priority. */
-};
-
-/* Flow wildcards. */
-enum ofp_flow_wildcards {
- OFPFW_IN_PORT = 1 << 0, /* Switch input port. */
- OFPFW_DL_VLAN = 1 << 1, /* VLAN id. */
- OFPFW_DL_SRC = 1 << 2, /* Ethernet source address. */
- OFPFW_DL_DST = 1 << 3, /* Ethernet destination address. */
- OFPFW_DL_TYPE = 1 << 4, /* Ethernet frame type. */
- OFPFW_NW_PROTO = 1 << 5, /* IP protocol. */
- OFPFW_TP_SRC = 1 << 6, /* TCP/UDP source port. */
- OFPFW_TP_DST = 1 << 7, /* TCP/UDP destination port. */
-
- /* IP source address wildcard bit count. 0 is exact match, 1 ignores the
- * LSB, 2 ignores the 2 least-significant bits, ..., 32 and higher wildcard
- * the entire field. This is the *opposite* of the usual convention where
- * e.g. /24 indicates that 8 bits (not 24 bits) are wildcarded. */
- OFPFW_NW_SRC_SHIFT = 8,
- OFPFW_NW_SRC_BITS = 6,
- OFPFW_NW_SRC_MASK = ((1 << OFPFW_NW_SRC_BITS) - 1) << OFPFW_NW_SRC_SHIFT,
- OFPFW_NW_SRC_ALL = 32 << OFPFW_NW_SRC_SHIFT,
-
- /* IP destination address wildcard bit count. Same format as source. */
- OFPFW_NW_DST_SHIFT = 14,
- OFPFW_NW_DST_BITS = 6,
- OFPFW_NW_DST_MASK = ((1 << OFPFW_NW_DST_BITS) - 1) << OFPFW_NW_DST_SHIFT,
- OFPFW_NW_DST_ALL = 32 << OFPFW_NW_DST_SHIFT,
-
- OFPFW_DL_VLAN_PCP = 1 << 20, /* VLAN priority. */
- OFPFW_NW_TOS = 1 << 21, /* IP ToS (DSCP field, 6 bits). */
-
- /* Wildcard all fields. */
- OFPFW_ALL = ((1 << 22) - 1)
-};
-
-/* The wildcards for ICMP type and code fields use the transport source
- * and destination port fields, respectively. */
-#define OFPFW_ICMP_TYPE OFPFW_TP_SRC
-#define OFPFW_ICMP_CODE OFPFW_TP_DST
-
-/* Values below this cutoff are 802.3 packets and the two bytes
- * following MAC addresses are used as a frame length. Otherwise, the
- * two bytes are used as the Ethernet type.
- */
-#define OFP_DL_TYPE_ETH2_CUTOFF 0x0600
-
-/* Value of dl_type to indicate that the frame does not include an
- * Ethernet type.
- */
-#define OFP_DL_TYPE_NOT_ETH_TYPE 0x05ff
-
-/* The VLAN id is 12-bits, so we can use the entire 16 bits to indicate
- * special conditions. All ones indicates that no VLAN id was set.
- */
-#define OFP_VLAN_NONE 0xffff
-
-/* Fields to match against flows */
-struct ofp_match {
- uint32_t wildcards; /* Wildcard fields. */
- uint16_t in_port; /* Input switch port. */
- uint8_t dl_src[OFP_ETH_ALEN]; /* Ethernet source address. */
- uint8_t dl_dst[OFP_ETH_ALEN]; /* Ethernet destination address. */
- uint16_t dl_vlan; /* Input VLAN id. */
- uint8_t dl_vlan_pcp; /* Input VLAN priority. */
- uint8_t pad1[1]; /* Align to 64-bits */
- uint16_t dl_type; /* Ethernet frame type. */
- uint8_t nw_tos; /* IP ToS (actually DSCP field, 6 bits). */
- uint8_t nw_proto; /* IP protocol or lower 8 bits of
- * ARP opcode. */
- uint8_t pad2[2]; /* Align to 64-bits */
- uint32_t nw_src; /* IP source address. */
- uint32_t nw_dst; /* IP destination address. */
- uint16_t tp_src; /* TCP/UDP source port. */
- uint16_t tp_dst; /* TCP/UDP destination port. */
-};
-OFP_ASSERT(sizeof(struct ofp_match) == 40);
-
-/* The match fields for ICMP type and code use the transport source and
- * destination port fields, respectively. */
-#define icmp_type tp_src
-#define icmp_code tp_dst
-
-/* Value used in "idle_timeout" and "hard_timeout" to indicate that the entry
- * is permanent. */
-#define OFP_FLOW_PERMANENT 0
-
-/* By default, choose a priority in the middle. */
-#define OFP_DEFAULT_PRIORITY 0x8000
-
-enum ofp_flow_mod_flags {
- OFPFF_SEND_FLOW_REM = 1 << 0, /* Send flow removed message when flow
- * expires or is deleted. */
- OFPFF_CHECK_OVERLAP = 1 << 1, /* Check for overlapping entries first. */
- OFPFF_EMERG = 1 << 2 /* Remark this is for emergency. */
-};
-
-/* Flow setup and teardown (controller -> datapath). */
-struct ofp_flow_mod {
- struct ofp_header header;
- struct ofp_match match; /* Fields to match */
- uint64_t cookie; /* Opaque controller-issued identifier. */
-
- /* Flow actions. */
- uint16_t command; /* One of OFPFC_*. */
- uint16_t idle_timeout; /* Idle time before discarding (seconds). */
- uint16_t hard_timeout; /* Max time before discarding (seconds). */
- uint16_t priority; /* Priority level of flow entry. */
- uint32_t buffer_id; /* Buffered packet to apply to (or -1).
- Not meaningful for OFPFC_DELETE*. */
- uint16_t out_port; /* For OFPFC_DELETE* commands, require
- matching entries to include this as an
- output port. A value of OFPP_NONE
- indicates no restriction. */
- uint16_t flags; /* One of OFPFF_*. */
- struct ofp_action_header actions[0]; /* The action length is inferred
- from the length field in the
- header. */
-};
-OFP_ASSERT(sizeof(struct ofp_flow_mod) == 72);
-
-/* Why was this flow removed? */
-enum ofp_flow_removed_reason {
- OFPRR_IDLE_TIMEOUT, /* Flow idle time exceeded idle_timeout. */
- OFPRR_HARD_TIMEOUT, /* Time exceeded hard_timeout. */
- OFPRR_DELETE /* Evicted by a DELETE flow mod. */
-};
-
-/* Flow removed (datapath -> controller). */
-struct ofp_flow_removed {
- struct ofp_header header;
- struct ofp_match match; /* Description of fields. */
- uint64_t cookie; /* Opaque controller-issued identifier. */
-
- uint16_t priority; /* Priority level of flow entry. */
- uint8_t reason; /* One of OFPRR_*. */
- uint8_t pad[1]; /* Align to 32-bits. */
-
- uint32_t duration_sec; /* Time flow was alive in seconds. */
- uint32_t duration_nsec; /* Time flow was alive in nanoseconds beyond
- duration_sec. */
- uint16_t idle_timeout; /* Idle timeout from original flow mod. */
- uint8_t pad2[2]; /* Align to 64-bits. */
- uint64_t packet_count;
- uint64_t byte_count;
-};
-OFP_ASSERT(sizeof(struct ofp_flow_removed) == 88);
-
-/* Values for 'type' in ofp_error_message. These values are immutable: they
- * will not change in future versions of the protocol (although new values may
- * be added). */
-enum ofp_error_type {
- OFPET_HELLO_FAILED, /* Hello protocol failed. */
- OFPET_BAD_REQUEST, /* Request was not understood. */
- OFPET_BAD_ACTION, /* Error in action description. */
- OFPET_FLOW_MOD_FAILED, /* Problem modifying flow entry. */
- OFPET_PORT_MOD_FAILED, /* Port mod request failed. */
- OFPET_QUEUE_OP_FAILED /* Queue operation failed. */
-};
-
-/* ofp_error_msg 'code' values for OFPET_HELLO_FAILED. 'data' contains an
- * ASCII text string that may give failure details. */
-enum ofp_hello_failed_code {
- OFPHFC_INCOMPATIBLE, /* No compatible version. */
- OFPHFC_EPERM /* Permissions error. */
-};
-
-/* ofp_error_msg 'code' values for OFPET_BAD_REQUEST. 'data' contains at least
- * the first 64 bytes of the failed request. */
-enum ofp_bad_request_code {
- OFPBRC_BAD_VERSION, /* ofp_header.version not supported. */
- OFPBRC_BAD_TYPE, /* ofp_header.type not supported. */
- OFPBRC_BAD_STAT, /* ofp_stats_request.type not supported. */
- OFPBRC_BAD_VENDOR, /* Vendor not supported (in ofp_vendor_header
- * or ofp_stats_request or ofp_stats_reply). */
- OFPBRC_BAD_SUBTYPE, /* Vendor subtype not supported. */
- OFPBRC_EPERM, /* Permissions error. */
- OFPBRC_BAD_LEN, /* Wrong request length for type. */
- OFPBRC_BUFFER_EMPTY, /* Specified buffer has already been used. */
- OFPBRC_BUFFER_UNKNOWN /* Specified buffer does not exist. */
-};
-
-/* ofp_error_msg 'code' values for OFPET_BAD_ACTION. 'data' contains at least
- * the first 64 bytes of the failed request. */
-enum ofp_bad_action_code {
- OFPBAC_BAD_TYPE, /* Unknown action type. */
- OFPBAC_BAD_LEN, /* Length problem in actions. */
- OFPBAC_BAD_VENDOR, /* Unknown vendor id specified. */
- OFPBAC_BAD_VENDOR_TYPE, /* Unknown action type for vendor id. */
- OFPBAC_BAD_OUT_PORT, /* Problem validating output action. */
- OFPBAC_BAD_ARGUMENT, /* Bad action argument. */
- OFPBAC_EPERM, /* Permissions error. */
- OFPBAC_TOO_MANY, /* Can't handle this many actions. */
- OFPBAC_BAD_QUEUE /* Problem validating output queue. */
-};
-
-/* ofp_error_msg 'code' values for OFPET_FLOW_MOD_FAILED. 'data' contains
- * at least the first 64 bytes of the failed request. */
-enum ofp_flow_mod_failed_code {
- OFPFMFC_ALL_TABLES_FULL, /* Flow not added because of full tables. */
- OFPFMFC_OVERLAP, /* Attempted to add overlapping flow with
- * CHECK_OVERLAP flag set. */
- OFPFMFC_EPERM, /* Permissions error. */
- OFPFMFC_BAD_EMERG_TIMEOUT, /* Flow not added because of non-zero idle/hard
- * timeout. */
- OFPFMFC_BAD_COMMAND, /* Unknown command. */
- OFPFMFC_UNSUPPORTED /* Unsupported action list - cannot process in
- * the order specified. */
-};
-
-/* ofp_error_msg 'code' values for OFPET_PORT_MOD_FAILED. 'data' contains
- * at least the first 64 bytes of the failed request. */
-enum ofp_port_mod_failed_code {
- OFPPMFC_BAD_PORT, /* Specified port does not exist. */
- OFPPMFC_BAD_HW_ADDR, /* Specified hardware address is wrong. */
-};
-
-/* ofp_error msg 'code' values for OFPET_QUEUE_OP_FAILED. 'data' contains
- * at least the first 64 bytes of the failed request */
-enum ofp_queue_op_failed_code {
- OFPQOFC_BAD_PORT, /* Invalid port (or port does not exist). */
- OFPQOFC_BAD_QUEUE, /* Queue does not exist. */
- OFPQOFC_EPERM /* Permissions error. */
-};
-
-/* OFPT_ERROR: Error message (datapath -> controller). */
-struct ofp_error_msg {
- struct ofp_header header;
-
- uint16_t type;
- uint16_t code;
- uint8_t data[0]; /* Variable-length data. Interpreted based
- on the type and code. */
-};
-OFP_ASSERT(sizeof(struct ofp_error_msg) == 12);
-
-enum ofp_stats_types {
- /* Description of this OpenFlow switch.
- * The request body is empty.
- * The reply body is struct ofp_desc_stats. */
- OFPST_DESC,
-
- /* Individual flow statistics.
- * The request body is struct ofp_flow_stats_request.
- * The reply body is an array of struct ofp_flow_stats. */
- OFPST_FLOW,
-
- /* Aggregate flow statistics.
- * The request body is struct ofp_aggregate_stats_request.
- * The reply body is struct ofp_aggregate_stats_reply. */
- OFPST_AGGREGATE,
-
- /* Flow table statistics.
- * The request body is empty.
- * The reply body is an array of struct ofp_table_stats. */
- OFPST_TABLE,
-
- /* Physical port statistics.
- * The request body is struct ofp_port_stats_request.
- * The reply body is an array of struct ofp_port_stats. */
- OFPST_PORT,
-
- /* Queue statistics for a port
- * The request body defines the port
- * The reply body is an array of struct ofp_queue_stats */
- OFPST_QUEUE,
-
- /* Vendor extension.
- * The request and reply bodies begin with a 32-bit vendor ID, which takes
- * the same form as in "struct ofp_vendor_header". The request and reply
- * bodies are otherwise vendor-defined. */
- OFPST_VENDOR = 0xffff
-};
-
-struct ofp_stats_request {
- struct ofp_header header;
- uint16_t type; /* One of the OFPST_* constants. */
- uint16_t flags; /* OFPSF_REQ_* flags (none yet defined). */
- uint8_t body[0]; /* Body of the request. */
-};
-OFP_ASSERT(sizeof(struct ofp_stats_request) == 12);
-
-enum ofp_stats_reply_flags {
- OFPSF_REPLY_MORE = 1 << 0 /* More replies to follow. */
-};
-
-struct ofp_stats_reply {
- struct ofp_header header;
- uint16_t type; /* One of the OFPST_* constants. */
- uint16_t flags; /* OFPSF_REPLY_* flags. */
- uint8_t body[0]; /* Body of the reply. */
-};
-OFP_ASSERT(sizeof(struct ofp_stats_reply) == 12);
-
-#define DESC_STR_LEN 256
-#define SERIAL_NUM_LEN 32
-/* Body of reply to OFPST_DESC request. Each entry is a NULL-terminated
- * ASCII string. */
-struct ofp_desc_stats {
- char mfr_desc[DESC_STR_LEN]; /* Manufacturer description. */
- char hw_desc[DESC_STR_LEN]; /* Hardware description. */
- char sw_desc[DESC_STR_LEN]; /* Software description. */
- char serial_num[SERIAL_NUM_LEN]; /* Serial number. */
- char dp_desc[DESC_STR_LEN]; /* Human readable description of datapath. */
-};
-OFP_ASSERT(sizeof(struct ofp_desc_stats) == 1056);
-
-/* Body for ofp_stats_request of type OFPST_FLOW. */
-struct ofp_flow_stats_request {
- struct ofp_match match; /* Fields to match. */
- uint8_t table_id; /* ID of table to read (from ofp_table_stats),
- 0xff for all tables or 0xfe for emergency. */
- uint8_t pad; /* Align to 32 bits. */
- uint16_t out_port; /* Require matching entries to include this
- as an output port. A value of OFPP_NONE
- indicates no restriction. */
-};
-OFP_ASSERT(sizeof(struct ofp_flow_stats_request) == 44);
-
-/* Body of reply to OFPST_FLOW request. */
-struct ofp_flow_stats {
- uint16_t length; /* Length of this entry. */
- uint8_t table_id; /* ID of table flow came from. */
- uint8_t pad;
- struct ofp_match match; /* Description of fields. */
- uint32_t duration_sec; /* Time flow has been alive in seconds. */
- uint32_t duration_nsec; /* Time flow has been alive in nanoseconds beyond
- duration_sec. */
- uint16_t priority; /* Priority of the entry. Only meaningful
- when this is not an exact-match entry. */
- uint16_t idle_timeout; /* Number of seconds idle before expiration. */
- uint16_t hard_timeout; /* Number of seconds before expiration. */
- uint8_t pad2[6]; /* Align to 64-bits. */
- uint64_t cookie; /* Opaque controller-issued identifier. */
- uint64_t packet_count; /* Number of packets in flow. */
- uint64_t byte_count; /* Number of bytes in flow. */
- struct ofp_action_header actions[0]; /* Actions. */
-};
-OFP_ASSERT(sizeof(struct ofp_flow_stats) == 88);
-
-/* Body for ofp_stats_request of type OFPST_AGGREGATE. */
-struct ofp_aggregate_stats_request {
- struct ofp_match match; /* Fields to match. */
- uint8_t table_id; /* ID of table to read (from ofp_table_stats)
- 0xff for all tables or 0xfe for emergency. */
- uint8_t pad; /* Align to 32 bits. */
- uint16_t out_port; /* Require matching entries to include this
- as an output port. A value of OFPP_NONE
- indicates no restriction. */
-};
-OFP_ASSERT(sizeof(struct ofp_aggregate_stats_request) == 44);
-
-/* Body of reply to OFPST_AGGREGATE request. */
-struct ofp_aggregate_stats_reply {
- uint64_t packet_count; /* Number of packets in flows. */
- uint64_t byte_count; /* Number of bytes in flows. */
- uint32_t flow_count; /* Number of flows. */
- uint8_t pad[4]; /* Align to 64 bits. */
-};
-OFP_ASSERT(sizeof(struct ofp_aggregate_stats_reply) == 24);
-
-/* Body of reply to OFPST_TABLE request. */
-struct ofp_table_stats {
- uint8_t table_id; /* Identifier of table. Lower numbered tables
- are consulted first. */
- uint8_t pad[3]; /* Align to 32-bits. */
- char name[OFP_MAX_TABLE_NAME_LEN];
- uint32_t wildcards; /* Bitmap of OFPFW_* wildcards that are
- supported by the table. */
- uint32_t max_entries; /* Max number of entries supported. */
- uint32_t active_count; /* Number of active entries. */
- uint64_t lookup_count; /* Number of packets looked up in table. */
- uint64_t matched_count; /* Number of packets that hit table. */
-};
-OFP_ASSERT(sizeof(struct ofp_table_stats) == 64);
-
-/* Body for ofp_stats_request of type OFPST_PORT. */
-struct ofp_port_stats_request {
- uint16_t port_no; /* OFPST_PORT message must request statistics
- * either for a single port (specified in
- * port_no) or for all ports (if port_no ==
- * OFPP_NONE). */
- uint8_t pad[6];
-};
-OFP_ASSERT(sizeof(struct ofp_port_stats_request) == 8);
-
-/* Body of reply to OFPST_PORT request. If a counter is unsupported, set
- * the field to all ones. */
-struct ofp_port_stats {
- uint16_t port_no;
- uint8_t pad[6]; /* Align to 64-bits. */
- uint64_t rx_packets; /* Number of received packets. */
- uint64_t tx_packets; /* Number of transmitted packets. */
- uint64_t rx_bytes; /* Number of received bytes. */
- uint64_t tx_bytes; /* Number of transmitted bytes. */
- uint64_t rx_dropped; /* Number of packets dropped by RX. */
- uint64_t tx_dropped; /* Number of packets dropped by TX. */
- uint64_t rx_errors; /* Number of receive errors. This is a super-set
- of more specific receive errors and should be
- greater than or equal to the sum of all
- rx_*_err values. */
- uint64_t tx_errors; /* Number of transmit errors. This is a super-set
- of more specific transmit errors and should be
- greater than or equal to the sum of all
- tx_*_err values (none currently defined.) */
- uint64_t rx_frame_err; /* Number of frame alignment errors. */
- uint64_t rx_over_err; /* Number of packets with RX overrun. */
- uint64_t rx_crc_err; /* Number of CRC errors. */
- uint64_t collisions; /* Number of collisions. */
-};
-OFP_ASSERT(sizeof(struct ofp_port_stats) == 104);
-
-/* Vendor extension. */
-struct ofp_vendor_header {
- struct ofp_header header; /* Type OFPT_VENDOR. */
- uint32_t vendor; /* Vendor ID:
- * - MSB 0: low-order bytes are IEEE OUI.
- * - MSB != 0: defined by OpenFlow
- * consortium. */
- /* Vendor-defined arbitrary additional data. */
-};
-OFP_ASSERT(sizeof(struct ofp_vendor_header) == 12);
-
-/* All ones is used to indicate all queues in a port (for stats retrieval). */
-#define OFPQ_ALL 0xffffffff
-
-/* Min rate > 1000 means not configured. */
-#define OFPQ_MIN_RATE_UNCFG 0xffff
-
-enum ofp_queue_properties {
- OFPQT_NONE = 0, /* No property defined for queue (default). */
- OFPQT_MIN_RATE, /* Minimum datarate guaranteed. */
- /* Other types should be added here
- * (i.e. max rate, precedence, etc). */
-};
-
-/* Common description for a queue. */
-struct ofp_queue_prop_header {
- uint16_t property; /* One of OFPQT_. */
- uint16_t len; /* Length of property, including this header. */
- uint8_t pad[4]; /* 64-bit alignemnt. */
-};
-OFP_ASSERT(sizeof(struct ofp_queue_prop_header) == 8);
-
-/* Min-Rate queue property description. */
-struct ofp_queue_prop_min_rate {
- struct ofp_queue_prop_header prop_header; /* prop: OFPQT_MIN, len: 16. */
- uint16_t rate; /* In 1/10 of a percent; >1000 -> disabled. */
- uint8_t pad[6]; /* 64-bit alignment */
-};
-OFP_ASSERT(sizeof(struct ofp_queue_prop_min_rate) == 16);
-
-/* Full description for a queue. */
-struct ofp_packet_queue {
- uint32_t queue_id; /* id for the specific queue. */
- uint16_t len; /* Length in bytes of this queue desc. */
- uint8_t pad[2]; /* 64-bit alignment. */
- struct ofp_queue_prop_header properties[0]; /* List of properties. */
-};
-OFP_ASSERT(sizeof(struct ofp_packet_queue) == 8);
-
-/* Query for port queue configuration. */
-struct ofp_queue_get_config_request {
- struct ofp_header header;
- uint16_t port; /* Port to be queried. Should refer
- to a valid physical port (i.e. < OFPP_MAX) */
- uint8_t pad[2]; /* 32-bit alignment. */
-};
-OFP_ASSERT(sizeof(struct ofp_queue_get_config_request) == 12);
-
-/* Queue configuration for a given port. */
-struct ofp_queue_get_config_reply {
- struct ofp_header header;
- uint16_t port;
- uint8_t pad[6];
- struct ofp_packet_queue queues[0]; /* List of configured queues. */
-};
-OFP_ASSERT(sizeof(struct ofp_queue_get_config_reply) == 16);
-
-/* OFPAT_ENQUEUE action struct: send packets to given queue on port. */
-struct ofp_action_enqueue {
- uint16_t type; /* OFPAT_ENQUEUE. */
- uint16_t len; /* Len is 16. */
- uint16_t port; /* Port that queue belongs. Should
- refer to a valid physical port
- (i.e. < OFPP_MAX) or OFPP_IN_PORT. */
- uint8_t pad[6]; /* Pad for 64-bit alignment. */
- uint32_t queue_id; /* Where to enqueue the packets. */
-};
-OFP_ASSERT(sizeof(struct ofp_action_enqueue) == 16);
-
-struct ofp_queue_stats_request {
- uint16_t port_no; /* All ports if OFPT_ALL. */
- uint8_t pad[2]; /* Align to 32-bits. */
- uint32_t queue_id; /* All queues if OFPQ_ALL. */
-};
-OFP_ASSERT(sizeof(struct ofp_queue_stats_request) == 8);
-
-struct ofp_queue_stats {
- uint16_t port_no;
- uint8_t pad[2]; /* Align to 32-bits. */
- uint32_t queue_id; /* Queue i.d */
- uint64_t tx_bytes; /* Number of transmitted bytes. */
- uint64_t tx_packets; /* Number of transmitted packets. */
- uint64_t tx_errors; /* Number of packets dropped due to overrun. */
-};
-OFP_ASSERT(sizeof(struct ofp_queue_stats) == 32);
-
-#endif /* openflow/openflow.h */
diff --git a/tools/pylibopenflow/include/pyopenflow.template.py b/tools/pylibopenflow/include/pyopenflow.template.py
deleted file mode 100644
index 29b59f4..0000000
--- a/tools/pylibopenflow/include/pyopenflow.template.py
+++ /dev/null
@@ -1,21 +0,0 @@
-import socket
-
-class ofsocket:
- """OpenFlow scoket
- """
- def __init__(self, socket):
- """Initialize with socket
- """
- ##Reference to socket
- self.socket = socket
-
- def send(self, msg):
- """Send message
- """
- ofph = ofp_header()
- remaining = ofph.unpack(msg)
- if (ofph.length != len(msg)):
- ofph.length = len(msg)
- msg = ofph.pack()+remaining
- self.socket.send(msg)
-
diff --git a/tools/pylibopenflow/pylib/c2py.py b/tools/pylibopenflow/pylib/c2py.py
deleted file mode 100644
index b699c5e..0000000
--- a/tools/pylibopenflow/pylib/c2py.py
+++ /dev/null
@@ -1,154 +0,0 @@
-"""This module converts C types to Python struct pattern string.
-
-Date June 2009
-Created by ykk
-"""
-import cheader
-import struct
-
-class cstruct2py:
- """Class converts C struct to Python struct pattern string
-
- Date October 2009
- Created by ykk
- """
- def __init__(self):
- """Initialize
- """
- ##Mapping
- self.structmap = {}
- self.structmap["char"] = "c"
- self.structmap["signed char"] = "b"
- self.structmap["uint8_t"]=\
- self.structmap["unsigned char"] = "B"
- self.structmap["short"] = "h"
- self.structmap["uint16_t"] =\
- self.structmap["unsigned short"] = "H"
- self.structmap["int"] = "i"
- self.structmap["unsigned int"] = "I"
- self.structmap["long"] = "l"
- self.structmap["uint32_t"] =\
- self.structmap["unsigned long"] = "L"
- self.structmap["long long"] = "q"
- self.structmap["uint64_t"] =\
- self.structmap["unsigned long long"] = "Q"
- self.structmap["float"] = "f"
- self.structmap["double"] = "d"
-
- def get_pattern(self,ctype):
- """Get pattern string for ctype.
- Return None if ctype is not expanded.
- """
- if (ctype.expanded):
- if (isinstance(ctype, cheader.cprimitive)):
- return self.structmap[ctype.typename]
- elif (isinstance(ctype, cheader.cstruct)):
- string=""
- for member in ctype.members:
- string += self.get_pattern(member)
- return string
- elif (isinstance(ctype, cheader.carray)):
- if (ctype.size == 0):
- return ""
- else:
- string = self.get_pattern(ctype.object)
- return string * ctype.size
- return None
-
- def get_size(self, ctype, prefix="!"):
- """Return size of struct or pattern specified
- """
- if (isinstance(ctype, str)):
- return struct.calcsize(ctype)
- elif (isinstance(ctype, cheader.ctype)):
- return struct.calcsize(prefix + self.get_pattern(ctype))
- else:
- return 0
-
-class structpacker:
- """Pack/unpack packets with ctype.
-
- Date October 2009
- Created by ykk
- """
- def __init__(self, prefix=""):
- """Initialize with prefix to struct
- """
- ##Reference to prefix
- self.prefix = prefix
-
- def pack(self, ctype, *arg):
- """Pack packet accordingly ctype or pattern provided.
- Return struct packed.
- """
- if (isinstance(ctype, str)):
- return struct.pack(self.prefix+ctype, *arg)
- elif (isinstance(ctype, cheader.ctype)):
- return struct.pack(self.prefix+cstruct2py.get_pattern(ctype),
- *arg)
- else:
- return None
-
- def unpack_from_front(self, ctype, binaryString, returnDictionary=True):
- """Unpack packet using front of packet,
- accordingly ctype or pattern provided.
-
- Return (dictionary of values indexed by arg name,
- remaining binary string) if ctype is cheader.ctype
- and returnDictionary is True,
- else return (array of data unpacked, remaining binary string).
- """
- pattern = ""
- if (isinstance(ctype, str)):
- pattern = ctype
- elif (isinstance(ctype, cheader.ctype)):
- pattern = cstruct2py.get_pattern(ctype)
- else:
- return None
- dsize = struct.calcsize(pattern)
-
- if (dsize > len(binaryString)):
- return None
-
- return (structpacker.peek_from_front(self, pattern, binaryString, returnDictionary),
- binaryString[dsize:])
-
- def peek_from_front(self, ctype, binaryString, returnDictionary=True):
- """Unpack packet using front of packet,
- accordingly ctype or pattern provided.
-
- Return dictionary of values indexed by arg name,
- if ctype is cheader.ctype and returnDictionary is True,
- else return array of data unpacked.
- """
- pattern = self.prefix
- if (isinstance(ctype, str)):
- pattern += ctype
- elif (isinstance(ctype, cheader.ctype)):
- pattern += cstruct2py.get_pattern(ctype)
- else:
- return None
- dsize = struct.calcsize(pattern)
- if (dsize > len(binaryString)):
- return None
- data = struct.unpack(pattern, binaryString[0:dsize])
-
- #Return values
- if (isinstance(ctype, str) or
- (not returnDictionary)):
- return data
- else:
- return self.data2dic(data, ctype)
-
- def data2dic(self,ctype,data):
- """Convert data to dictionary
- """
- valDic = {}
- names = ctype.get_names()
- for name in names:
- valDic[name] = []
- for d in data:
- name = names.pop(0)
- valDic[name].append(d)
- return valDic
-
diff --git a/tools/pylibopenflow/pylib/cheader.py b/tools/pylibopenflow/pylib/cheader.py
deleted file mode 100644
index a23e1eb..0000000
--- a/tools/pylibopenflow/pylib/cheader.py
+++ /dev/null
@@ -1,434 +0,0 @@
-"""This module parse and store a C/C++ header file.
-
-Date June 2009
-Created by ykk
-"""
-import re
-from config import *
-
-class textfile:
- """Class to handle text file.
-
- Date June 2009
- Created by ykk
- """
- def __init__(self, filename):
- """Initialize filename with no content.
- """
- ##Filename
- if (isinstance(filename, str)):
- self.filename = []
- self.filename.append(filename)
- else:
- self.filename = filename
- ##Content
- self.content = []
-
- def read(self):
- """Read file
- """
- for filename in self.filename:
- fileRef = open(filename, "r")
- for line in fileRef:
- self.content.append(line)
- fileRef.close()
-
-class ctype:
- """Class to represent types in C
- """
- def __init__(self,typename, name=None, expanded=False):
- """Initialize
- """
- ##Name
- self.name = name
- ##Type of primitive
- self.typename = typename
- ##Expanded
- self.expanded = expanded
-
- def expand(self, cheader):
- """Expand type if applicable
- """
- raise NotImplementedError()
-
- def get_names(self):
- """Return name of variables
- """
- raise NotImplementedError()
-
-class cprimitive(ctype):
- """Class to represent C primitive
-
- Date October 2009
- Created by ykk
- """
- def __init__(self,typename, name=None):
- """Initialize and store primitive
- """
- ctype.__init__(self, typename, name, True)
-
- def __str__(self):
- """Return string representation
- """
- if (self.name == None):
- return self.typename
- else:
- return self.typename+" "+str(self.name)
-
- def expand(self, cheader):
- """Expand type if applicable
- """
- pass
-
- def get_names(self):
- """Return name of variables
- """
- namelist = []
- namelist.append(self.name)
- return namelist
-
-class cstruct(ctype):
- """Class to represent C struct
-
- Date October 2009
- Created by ykk
- """
- def __init__(self, typename, name=None):
- """Initialize struct
- """
- ctype.__init__(self, typename, name)
- ##List of members in struct
- self.members = []
-
- def __str__(self):
- """Return string representation
- """
- string = "struct "+self.typename
- if (self.name != None):
- string += " "+self.name
- if (len(self.members) == 0):
- return string
- #Add members
- string +=" {\n"
- for member in self.members:
- string += "\t"+str(member)
- if (not isinstance(member, cstruct)):
- string += ";"
- string += "\n"
- string +="};"
- return string
-
- def expand(self, cheader):
- """Expand struct
- """
- self.expanded = True
- #Expanded each member
- for member in self.members:
- if (isinstance(member, cstruct) and
- (not member.expanded)):
- try:
- if (not cheader.structs[member.typename].expanded):
- cheader.structs[member.typename].expand(cheader)
- member.members=cheader.structs[member.typename].members[:]
- member.expanded = True
- except KeyError:
- self.expanded=False
- else:
- member.expand(cheader)
-
- def get_names(self):
- """Return name of variables
- """
- namelist = []
- for member in self.members:
- if (isinstance(member, cstruct)):
- tmplist = member.get_names()
- for item in tmplist:
- namelist.append(member.name+"."+item)
- else:
- namelist.extend(member.get_names())
- return namelist
-
-
-class carray(ctype):
- """Class to represent C array
-
- Date October 2009
- Created by ykk
- """
- def __init__(self, typename, name, isPrimitive, size):
- """Initialize array of object.
- """
- ctype.__init__(self, typename, name,
- (isinstance(size, int) and isPrimitive))
- ##Object reference
- if (isPrimitive):
- self.object = cprimitive(typename, name)
- else:
- self.object = cstruct(typename, name)
- ##Size of array
- self.size = size
-
- def __str__(self):
- """Return string representation
- """
- return str(self.object)+"["+str(self.size)+"]"
-
- def expand(self, cheader):
- """Expand array
- """
- self.expanded = True
- if (not self.object.expanded):
- if (isinstance(self.object, cstruct)):
- cheader.structs[self.object.typename].expand(cheader)
- self.object.members=cheader.structs[self.object.typename].members[:]
- else:
- self.object.expand(cheader)
-
- if (not isinstance(self.size, int)):
- val = cheader.get_value(self.size)
- if (val == None):
- self.expanded = False
- else:
- try:
- self.size = int(val)
- except ValueError:
- self.size = val
- self.expanded = False
-
- def get_names(self):
- """Return name of variables
- """
- namelist = []
- for i in range(0,self.size):
- namelist.append(self.object.name)
- return namelist
-
-class ctype_parser:
- """Class to check c types
-
- Date October 2009
- Created by ykk
- """
- def __init__(self):
- """Initialize
- """
- self.CPrimitives = ["char","signed char","unsigned char",
- "short","unsigned short",
- "int","unsigned int",
- "long","unsigned long",
- "long long","unsigned long long",
- "float","double",
- "uint8_t","uint16_t","uint32_t","uint64_t"]
-
- def is_primitive(self,type):
- """Check type given is primitive.
-
- Return true if valid, and false otherwise
- """
- if (type in self.CPrimitives):
- return True
- else:
- return False
-
- def is_array(self, string):
- """Check if string declares an array
- """
- parts=string.strip().split()
- if (len(parts) <= 1):
- return False
- else:
- pattern = re.compile("\[.*?\]", re.MULTILINE)
- values = pattern.findall(string)
- if (len(values) == 1):
- return True
- else:
- return False
-
- def parse_array(self, string):
- """Parse array from string.
- Return occurrence and name.
- """
- pattern = re.compile("\[.*?\]", re.MULTILINE)
- namepattern = re.compile(".*?\[", re.MULTILINE)
- values = pattern.findall(string)
- if (len(values) != 1):
- return (1,string)
- else:
- val = values[0][1:-1]
- try:
- sizeval = int(val)
- except ValueError:
- if (val==""):
- sizeval = 0
- else:
- sizeval = val
- return (sizeval,
- namepattern.findall(string)[0].strip()[0:-1])
-
- def parse_type(self, string):
- """Parse string and return cstruct or cprimitive.
- Else return None
- """
- parts=string.strip().split()
- if (len(parts) >= 2):
- if (parts[0].strip() == "struct"):
- typename = " ".join(parts[1:-1])
- else:
- typename = " ".join(parts[:-1])
- (size, name) = self.parse_array(parts[-1])
- if IGNORE_ZERO_ARRAYS and size == 0:
- return None
- #Create appropriate type
- if (size != 1):
- #Array
- return carray(typename, name,
- self.is_primitive(typename),size)
- else:
- #Not array
- if IGNORE_OFP_HEADER and typename == "ofp_header":
- return None
- if (self.is_primitive(typename)):
- return cprimitive(typename, name)
- else:
- return cstruct(typename, name)
- else:
- return None
-
-class cheaderfile(textfile):
- """Class to handle C header file.
-
- Date June 2009
- Created by ykk
- """
- def __init__(self, filename):
- """Initialize filename and read from file
- """
- textfile.__init__(self,filename)
- self.read()
- self.__remove_comments()
- ##Dictionary of macros
- self.macros = {}
- self.__get_macros()
- ##Dictionary of enumerations
- self.enums = {}
- self.enum_values = {}
- self.__get_enum()
- self.__get_enum_values()
- ##Dictionary of structs
- self.structs = {}
- self.__get_struct()
-
- def get_enum_name(self, enum, value):
- """Return name of variable in enum
- """
- for e in self.enums[enum]:
- if (self.enum_values[e] == value):
- return e
-
- def eval_value(self, value):
- """Evaluate value string
- """
- try:
- return eval(value, self.enum_values)
- except:
- return value.strip()
-
- def get_value(self, name):
- """Get value for variable name,
- searching through enum and macros.
- Else return None
- """
- try:
- return self.enum_values[name]
- except KeyError:
- try:
- return self.macros[name]
- except KeyError:
- return None
-
- def __remove_comments(self):
- """Remove all comments
- """
- fileStr = "".join(self.content)
- pattern = re.compile("\\\.*?\n", re.MULTILINE)
- fileStr = pattern.sub("",fileStr)
- pattern = re.compile(r"/\*.*?\*/", re.MULTILINE|re.DOTALL)
- fileStr = pattern.sub("",fileStr)
- pattern = re.compile("//.*$", re.MULTILINE)
- fileStr = pattern.sub("",fileStr)
- self.content = fileStr.split('\n')
-
- def __get_struct(self):
- """Get all structs
- """
- typeparser = ctype_parser()
- fileStr = "".join(self.content)
- #Remove attribute
- attrpattern = re.compile("} __attribute__ \(\((.+?)\)\);", re.MULTILINE)
- attrmatches = attrpattern.findall(fileStr)
- for amatch in attrmatches:
- fileStr=fileStr.replace(" __attribute__ (("+amatch+"));",";")
- #Find all structs
- pattern = re.compile("struct[\w\s]*?{.*?};", re.MULTILINE)
- matches = pattern.findall(fileStr)
- #Process each struct
- namepattern = re.compile("struct(.+?)[ {]", re.MULTILINE)
- pattern = re.compile("{(.+?)};", re.MULTILINE)
- for match in matches:
- structname = namepattern.findall(match)[0].strip()
- if (len(structname) != 0):
- values = pattern.findall(match)[0].strip().split(";")
- cstru = cstruct(structname)
- for val in values:
- presult = typeparser.parse_type(val)
- if (presult != None):
- cstru.members.append(presult)
- self.structs[structname] = cstru
- #Expand all structs
- for (structname, struct) in self.structs.items():
- struct.expand(self)
-
- def __get_enum(self):
- """Get all enumeration
- """
- fileStr = "".join(self.content)
- #Find all enumerations
- pattern = re.compile("enum[\w\s]*?{.*?}", re.MULTILINE)
- matches = pattern.findall(fileStr)
- #Process each enumeration
- namepattern = re.compile("enum(.+?){", re.MULTILINE)
- pattern = re.compile("{(.+?)}", re.MULTILINE)
- for match in matches:
- values = pattern.findall(match)[0].strip().split(",")
- #Process each value in enumeration
- enumList = []
- value = 0
- for val in values:
- if not (val.strip() == ""):
- valList=val.strip().split("=")
- enumList.append(valList[0].strip())
- if (len(valList) == 1):
- self.enum_values[valList[0].strip()] = value
- value += 1
- else:
- self.enum_values[valList[0].strip()] = self.eval_value(valList[1].strip())
- self.enums[namepattern.findall(match)[0].strip()] = enumList
-
- def __get_enum_values(self):
- """Patch unresolved enum values
- """
- for name,enumval in self.enum_values.items():
- if isinstance(enumval,str):
- self.enum_values[name] = self.eval_value(enumval)
-
- def __get_macros(self):
- """Extract macros
- """
- for line in self.content:
- if (line[0:8] == "#define "):
- lineList = line[8:].split()
- if (len(lineList) >= 2):
- self.macros[lineList[0]] = self.eval_value("".join(lineList[1:]))
- else:
- self.macros[lineList[0]] = ""
diff --git a/tools/pylibopenflow/pylib/config.py b/tools/pylibopenflow/pylib/config.py
deleted file mode 100644
index 61c903d..0000000
--- a/tools/pylibopenflow/pylib/config.py
+++ /dev/null
@@ -1,29 +0,0 @@
-
-# of_message specific controls
-
-# Do not include any arrays marked [0]
-IGNORE_ZERO_ARRAYS = True
-
-# Do not include the ofp_header as a member in any structure
-# This allows messages to be consistently generated as:
-# explicit header declaration
-# core member declaration
-# variable length data
-IGNORE_OFP_HEADER = True
-
-# Generate object equality functions
-GEN_OBJ_EQUALITY = True
-
-# Generate object show functions
-GEN_OBJ_SHOW = True
-
-# Generate lists of enum values
-GEN_ENUM_VALUES_LIST = False
-
-# Generate dictionary of enum strings to values
-GEN_ENUM_DICTIONARY = True
-
-# Auxilary info: Stuff written to stdout for additional processing
-# Currently generates a (python) map from a class to a list of
-# the data members; used for documentation
-GEN_AUX_INFO = True
diff --git a/tools/pylibopenflow/pylib/cpythonize.py b/tools/pylibopenflow/pylib/cpythonize.py
deleted file mode 100644
index 22b5214..0000000
--- a/tools/pylibopenflow/pylib/cpythonize.py
+++ /dev/null
@@ -1,571 +0,0 @@
-"""This module generate Python code for C structs.
-
-Date January 2010
-Created by ykk
-"""
-import sys
-import cheader
-import c2py
-import datetime
-import struct
-import re
-from config import *
-
-def _space_to(n, str):
- """
- Generate a string of spaces to achieve width n given string str
- If length of str >= n, return one space
- """
- spaces = n - len(str)
- if spaces > 0:
- return " " * spaces
- return " "
-
-class rules:
- """Class that specify rules for pythonization
-
- Date January 2010
- Created by ykk
- """
- def __init__(self):
- """Initialize rules
- """
- ##Default values for members
- self.default_values = {}
- #Default values for struct
- self.struct_default = {}
- ##What is a tab
- self.tab = " "
- ##Macros to exclude
- self.excluded_macros = []
- ##Enforce mapping
- self.enforced_maps = {}
-
- def get_enforced_map(self, structname):
- """Get code to enforce mapping
- """
- code = []
- try:
- mapping = self.enforced_maps[structname]
- except KeyError:
- return None
- for (x,xlist) in mapping:
- code.append("if (not (self."+x+" in "+xlist+")):")
- code.append(self.tab+"return (False, \""+x+" must have values from "+xlist+"\")")
- return code
-
-
- def get_struct_default(self, structname, fieldname):
- """Get code to set defaults for member struct
- """
- try:
- return "."+fieldname+self.struct_default[(structname, fieldname)]
- except KeyError:
- return None
-
- def get_default_value(self, structname, fieldname):
- """Get default value for struct's field
- """
- try:
- return self.default_values[(structname, fieldname)]
- except KeyError:
- return 0
-
- def include_macro(self, name):
- """Check if macro should be included
- """
- return not (name in self.excluded_macros)
-
-class pythonizer:
- """Class that pythonize C structures
-
- Date January 2010
- Created by ykk
- """
- def __init__(self, cheaderfile, pyrules = None, tab=" "):
- """Initialize
- """
- ##Rules
- if (pyrules == None):
- self.rules = rules()
- else:
- self.rules = pyrules
- ##What is a tab (same as rules)
- self.tab = str(tab)
- self.rules.tab = self.tab
- ##Reference to C header file
- self.cheader = cheaderfile
- ##Reference to cstruct2py
- self.__c2py = c2py.cstruct2py()
- ##Code for assertion
- self.__assertcode = []
-
- def pycode(self,preamble=None):
- """Return pythonized code
- """
- code = []
- code.append("import struct")
- code.append("")
- if (preamble != None):
- fileRef = open(preamble,"r")
- for l in fileRef:
- code.append(l[:-1])
- fileRef.close()
- code.append("# Structure definitions")
- for name,struct in self.cheader.structs.items():
- code.extend(self.pycode_struct(struct))
- code.append("")
- code.append("# Enumerated type definitions")
- for name,enum in self.cheader.enums.items():
- code.extend(self.pycode_enum(name,enum))
- if GEN_ENUM_DICTIONARY:
- code.extend(self.pycode_enum_map(name,enum))
- code.append("")
- code.append("# Values from macro definitions")
- for name,macro in self.cheader.macros.items():
- code.extend(self.pycode_macro(name))
- code.append("")
- code.append("# Basic structure size definitions.")
- if IGNORE_OFP_HEADER:
- code.append("# Does not include ofp_header members.")
- if IGNORE_ZERO_ARRAYS:
- code.append("# Does not include variable length arrays.")
- struct_keys = self.cheader.structs.keys()
- struct_keys.sort()
- for name in struct_keys:
- struct = self.cheader.structs[name]
- code.append(self.pycode_struct_size(name, struct))
- if GEN_AUX_INFO:
- self.gen_struct_map()
-
- return code
-
- def pycode_enum(self, name, enum):
- """Return Python array for enum
- """
- code=[]
- code.append(name+" = "+str(enum))
- ev = []
- for e in enum:
- v = self.cheader.get_value(e)
- ev.append(v)
- code.append(e+"%s= "%_space_to(36,e)+str(v))
- if GEN_ENUM_VALUES_LIST:
- code.append(name+"_values = "+str(ev))
- return code
-
- def pycode_enum_map(self, name, enum):
- """Return Python dictionary for enum
- """
- code = []
- code.append(name+"_map = {")
- first = 1
- for e in enum:
- v = self.cheader.get_value(e)
- if first:
- prev_e = e
- prev_v = v
- first = 0
- else:
- code.append(self.tab + "%s%s: '%s'," %
- (prev_v, _space_to(32, str(prev_v)), prev_e))
- prev_e = e
- prev_v = v
- code.append(self.tab + "%s%s: '%s'" %
- (prev_v, _space_to(32, str(prev_v)), prev_e))
- code.append("}")
- return code
-
- def pycode_macro(self,name):
- """Return Python dict for macro
- """
- code = []
- if (self.rules.include_macro(name)):
- code.append(name+" = "+str(self.cheader.get_value(name)))
- return code
-
- def pycode_struct_size(self, name, struct):
- """Return one liner giving the structure size in bytes
- """
- pattern = '!' + self.__c2py.get_pattern(struct)
- bytes = self.__c2py.get_size(pattern)
- code = name.upper() + "_BYTES = " + str(bytes)
- return code
-
- def pycode_struct(self, struct_in):
- """Return Python class code given C struct.
-
- Returns None if struct_in is not cheader.cstruct.
- Else return list of strings that codes Python class.
- """
- if (not isinstance(struct_in, cheader.cstruct)):
- return None
-
- code=[]
- self.__assertcode = []
- code.extend(self.codeheader(struct_in))
- code.extend(self.codeinit(struct_in))
- code.append("")
- code.extend(self.codeassert(struct_in))
- code.append("")
- code.extend(self.codepack(struct_in))
- code.append("")
- code.extend(self.codeunpack(struct_in))
- code.append("")
- code.extend(self.codelen(struct_in))
- code.append("")
- if GEN_OBJ_EQUALITY:
- code.extend(self.codeeq(struct_in))
- code.append("")
- if GEN_OBJ_SHOW:
- code.extend(self.codeshow(struct_in))
- code.append("")
- return code
-
- def codeheader(self, struct_in):
- """Return Python code for header
- """
- code=[]
- code.append("class "+struct_in.typename+":")
- code.append(self.tab+"\"\"\"Automatically generated Python class for "+struct_in.typename)
- code.append("")
- code.append(self.tab+"Date "+str(datetime.date.today()))
- code.append(self.tab+"Created by "+self.__module__+"."+self.__class__.__name__)
- if IGNORE_OFP_HEADER:
- code.append(self.tab+"Core structure: Messages do not include ofp_header")
- if IGNORE_ZERO_ARRAYS:
- code.append(self.tab+"Does not include var-length arrays")
- code.append(self.tab+"\"\"\"")
- return code
-
- def codeinit(self, struct_in):
- """Return Python code for init function
- """
- code = []
- code.append(self.tab+"def __init__(self):")
- code.append(self.tab*2+"\"\"\"Initialize")
- code.append(self.tab*2+"Declare members and default values")
- code.append(self.tab*2+"\"\"\"")
- code.extend(self.codemembers(struct_in,self.tab*2+"self"))
- return code
-
- def codemembers(self, struct_in, prepend=""):
- """Return members of class
- """
- code = []
- for member in struct_in.members:
- if (isinstance(member, cheader.cstruct)):
- code.append(prepend+"."+member.name+" = "+member.typename+"()")
- struct_default = self.rules.get_struct_default(struct_in.typename, member.name)
- if (struct_default != None):
- code.append(prepend+struct_default)
- self.__structassert(member, (prepend+"."+member.name).strip())
- elif (isinstance(member, cheader.carray)):
- if (member.typename == "char"):
- initvalue = "\"\""
- self.__stringassert(member, (prepend+"."+member.name).strip())
- else:
- if (isinstance(member.object, cheader.cprimitive)):
- initvalue="0"
- else:
- initvalue="None"
- initvalue=(initvalue+",")*member.size
- initvalue="["+initvalue[:-1]+"]"
- self.__arrayassert(member, (prepend+"."+member.name).strip())
- code.append(prepend+"."+member.name+"= "+initvalue)
- else:
- code.append(prepend+"."+member.name+" = "+
- str(self.rules.get_default_value(struct_in.typename, member.name)))
- return code
-
- def gen_struct_map(self, file=None):
- if not file:
- file = sys.stdout
- print >> file
- print >> file, "# Class to array member map"
- print >> file, "class_to_members_map = {"
- for name, struct in self.cheader.structs.items():
- if not len(struct.members):
- continue
- s = " '" + name + "'"
- print >> file, s + _space_to(36, s) + ": ["
- prev = None
- for member in struct.members:
- if re.search('pad', member.name):
- continue
- if prev:
- print _space_to(39, "") + "'" + prev + "',"
- prev = member.name
- print >> file, _space_to(39, "") + "'" + prev + "'"
- print >> file, _space_to(38, "") + "],"
- print >> file, " '_ignore' : []"
- print >> file, "}"
-
- def __structassert(self, cstruct, cstructname):
- """Return code to check for C array
- """
- self.__assertcode.append(self.tab*2+"if(not isinstance("+cstructname+", "+cstruct.typename+")):")
- self.__assertcode.append(self.tab*3+"return (False, \""+cstructname+" is not class "+cstruct.typename+" as expected.\")")
-
- def __addassert(self, prefix):
- code = []
- code.append(prefix+"if(not self.__assert()[0]):")
- code.append(prefix+self.tab+"return None")
- return code
-
- def __stringassert(self, carray, carrayname):
- """Return code to check for C array
- """
- self.__assertcode.append(self.tab*2+"if(not isinstance("+carrayname+", str)):")
- self.__assertcode.append(self.tab*3+"return (False, \""+carrayname+" is not string as expected.\")")
- self.__assertcode.append(self.tab*2+"if(len("+carrayname+") > "+str(carray.size)+"):")
- self.__assertcode.append(self.tab*3+"return (False, \""+carrayname+" is not of size "+str(carray.size)+" as expected.\")")
-
- def __arrayassert(self, carray, carrayname):
- """Return code to check for C array
- """
- if (carray.size == 0):
- return
- self.__assertcode.append(self.tab*2+"if(not isinstance("+carrayname+", list)):")
- self.__assertcode.append(self.tab*3+"return (False, \""+carrayname+" is not list as expected.\")")
- self.__assertcode.append(self.tab*2+"if(len("+carrayname+") != "+str(carray.size)+"):")
- self.__assertcode.append(self.tab*3+"return (False, \""+carrayname+" is not of size "+str(carray.size)+" as expected.\")")
-
- def codeassert(self, struct_in):
- """Return code for sanity checking
- """
- code = []
- code.append(self.tab+"def __assert(self):")
- code.append(self.tab*2+"\"\"\"Sanity check")
- code.append(self.tab*2+"\"\"\"")
- enforce = self.rules.get_enforced_map(struct_in.typename)
- if (enforce != None):
- for line in enforce:
- code.append(self.tab*2+line)
- code.extend(self.__assertcode)
- code.append(self.tab*2+"return (True, None)")
- return code
-
- def codepack(self, struct_in, prefix="!"):
- """Return code that pack struct
- """
- code = []
- code.append(self.tab+"def pack(self, assertstruct=True):")
- code.append(self.tab*2+"\"\"\"Pack message")
- code.append(self.tab*2+"Packs empty array used as placeholder")
- code.append(self.tab*2+"\"\"\"")
- code.append(self.tab*2+"if(assertstruct):")
- code.extend(self.__addassert(self.tab*3))
- code.append(self.tab*2+"packed = \"\"")
- primPattern = ""
- primMemberNames = []
- for member in struct_in.members:
- if (isinstance(member, cheader.cprimitive)):
- #Primitives
- primPattern += self.__c2py.structmap[member.typename]
- primMemberNames.append("self."+member.name)
- else:
- (primPattern, primMemberNames) = \
- self.__codepackprimitive(code, primPattern,
- primMemberNames, prefix)
- if (isinstance(member, cheader.cstruct)):
- #Struct
- code.append(self.tab*2+"packed += self."+member.name+".pack()")
- elif (isinstance(member, cheader.carray) and member.typename == "char"):
- #String
- code.append(self.tab*2+"packed += self."+member.name+".ljust("+\
- str(member.size)+",'\\0')")
- elif (isinstance(member, cheader.carray) and \
- isinstance(member.object, cheader.cprimitive)):
- #Array of Primitives
- expandedarr = ""
- if (member.size != 0):
- for x in range(0, member.size):
- expandedarr += ", self."+member.name+"["+\
- str(x).strip()+"]"
- code.append(self.tab*2+"packed += struct.pack(\""+prefix+\
- self.__c2py.structmap[member.object.typename]*member.size+\
- "\""+expandedarr+")")
- else:
- code.append(self.tab*2+"for i in self."+member.name+":")
- code.append(self.tab*3+"packed += struct.pack(\""+\
- prefix+self.__c2py.get_pattern(member.object)+\
- "\",i)")
- elif (isinstance(member, cheader.carray) and \
- isinstance(member.object, cheader.cstruct)):
- #Array of struct
- if (member.size != 0):
- for x in range(0, member.size):
- code.append(self.tab*2+"packed += self."+member.name+"["+\
- str(x).strip()+"].pack()")
- else:
- code.append(self.tab*2+"for i in self."+member.name+":")
- code.append(self.tab*3+"packed += i.pack(assertstruct)")
- #Clear remaining fields
- (primPattern, primMemberNames) = \
- self.__codepackprimitive(code, primPattern,
- primMemberNames, prefix)
- code.append(self.tab*2+"return packed")
- return code
-
- def __codepackprimitive(self, code, primPattern, primMemberNames, prefix):
- """Return code for packing primitives
- """
- if (primPattern != ""):
- #Clear prior primitives
- code.append(self.tab*2+"packed += struct.pack(\""+\
- prefix+primPattern+"\", "+\
- str(primMemberNames).replace("'","")[1:-1]+")")
- return ("",[])
-
- def codelen(self, struct_in):
- """Return code to return length
- """
- pattern = "!" + self.__c2py.get_pattern(struct_in)
- code = []
- code.append(self.tab+"def __len__(self):")
- code.append(self.tab*2+"\"\"\"Return length of message")
- code.append(self.tab*2+"\"\"\"")
- code.append(self.tab*2+"l = "+str(self.__c2py.get_size(pattern)))
- for member in struct_in.members:
- if (isinstance(member, cheader.carray) and member.size == 0):
- if (isinstance(member.object, cheader.cstruct)):
- code.append(self.tab*2+"for i in self."+member.name+":")
- # FIXME: Is this right? Doesn't seem to be called
- code.append(self.tab*3+"l += i.length()")
- else:
- pattern="!"+self.__c2py.get_pattern(member.object)
- size=self.__c2py.get_size(pattern)
- code.append(self.tab*2+"l += len(self."+member.name+")*"+str(size))
- code.append(self.tab*2+"return l")
- return code
-
- def codeeq(self, struct_in):
- """Return code to return equality comparisons
- """
- code = []
- code.append(self.tab+"def __eq__(self, other):")
- code.append(self.tab*2+"\"\"\"Return True if self and other have same values")
- code.append(self.tab*2+"\"\"\"")
- code.append(self.tab*2+"if type(self) != type(other): return False")
- for member in struct_in.members:
- code.append(self.tab*2 + "if self." + member.name + " != other." +
- member.name + ": return False")
- code.append(self.tab*2+"return True")
- code.append("")
- code.append(self.tab+"def __ne__(self, other): return not self.__eq__(other)")
- return code
-
- def codeshow(self, struct_in):
- """Return code to print basic members of structure
- """
- code = []
- code.append(self.tab+"def show(self, prefix=''):")
- code.append(self.tab*2+"\"\"\"" + "Generate string showing basic members of structure")
- code.append(self.tab*2+"\"\"\"")
- code.append(self.tab*2+"outstr = ''")
- for member in struct_in.members:
- if re.search('pad', member.name):
- continue
- elif (isinstance(member, cheader.cstruct)):
- code.append(self.tab*2 + "outstr += prefix + '" +
- member.name + ": \\n' ")
- code.append(self.tab*2 + "outstr += self." + member.name +
- ".show(prefix + ' ')")
- elif (isinstance(member, cheader.carray) and
- not isinstance(member.object, cheader.cprimitive)):
- code.append(self.tab*2 + "outstr += prefix + '" + member.name +
- ": \\n' ")
- code.append(self.tab*2 + "for obj in self." + member.name + ":")
- code.append(self.tab*3 + "outstr += obj.show(prefix + ' ')")
- else:
- code.append(self.tab*2 + "outstr += prefix + '" + member.name +
- ": ' + str(self." + member.name + ") + '\\n'")
- code.append(self.tab*2+"return outstr")
- return code
-
- def codeunpack(self, struct_in, prefix="!"):
- """Return code that unpack struct
- """
- pattern = self.__c2py.get_pattern(struct_in)
- structlen = self.__c2py.get_size(prefix + pattern)
- code = []
- code.append(self.tab+"def unpack(self, binaryString):")
- code.append(self.tab*2+"\"\"\"Unpack message")
- code.append(self.tab*2+"Do not unpack empty array used as placeholder")
- code.append(self.tab*2+"since they can contain heterogeneous type")
- code.append(self.tab*2+"\"\"\"")
- code.append(self.tab*2+"if (len(binaryString) < "+str(structlen)+"):")
- code.append(self.tab*3+"return binaryString")
- offset = 0
- primPattern = ""
- primMemberNames = []
- for member in struct_in.members:
- if (isinstance(member, cheader.cprimitive)):
- #Primitives
- primPattern += self.__c2py.structmap[member.typename]
- primMemberNames.append("self."+member.name)
- else:
- (primPattern, primMemberNames, offset) = \
- self.__codeunpackprimitive(code, offset, primPattern,
- primMemberNames, prefix)
- if (isinstance(member, cheader.cstruct)):
- #Struct
- code.append(self.tab*2+"self."+member.name+\
- ".unpack(binaryString["+str(offset)+":])")
- pattern = self.__c2py.get_pattern(member)
- offset += self.__c2py.get_size(prefix+pattern)
- elif (isinstance(member, cheader.carray) and member.typename == "char"):
- #String
- code.append(self.tab*2+"self."+member.name+\
- " = binaryString["+str(offset)+":"+\
- str(offset+member.size)+"].replace(\"\\0\",\"\")")
- offset += member.size
- elif (isinstance(member, cheader.carray) and \
- isinstance(member.object, cheader.cprimitive)):
- #Array of Primitives
- expandedarr = ""
- if (member.size != 0):
- arrpattern = self.__c2py.structmap[member.object.typename]*member.size
- for x in range(0, member.size):
- expandedarr += "self."+member.name+"["+\
- str(x).strip()+"], "
- code.append(self.tab*2 + "fmt = '" + prefix+arrpattern + "'")
- code.append(self.tab*2 + "start = " + str(offset))
- code.append(self.tab*2 + "end = start + struct.calcsize(fmt)")
- code.append(self.tab*2 + "("+expandedarr[:-2] +
- ") = struct.unpack(fmt, binaryString[start:end])")
- offset += struct.calcsize(prefix + arrpattern)
- elif (isinstance(member, cheader.carray) and \
- isinstance(member.object, cheader.cstruct)):
- #Array of struct
- astructlen = self.__c2py.get_size("!"+self.__c2py.get_pattern(member.object))
- for x in range(0, member.size):
- code.append(self.tab*2+"self."+member.name+"["+str(x)+"]"+\
- ".unpack(binaryString["+str(offset)+":])")
- offset += astructlen
- #Clear remaining fields
- (primPattern, primMemberNames, offset) = \
- self.__codeunpackprimitive(code, offset, primPattern,
- primMemberNames, prefix)
- code.append(self.tab*2+"return binaryString["+str(structlen)+":]");
- return code
-
- def __codeunpackprimitive(self, code, offset, primPattern,
- primMemberNames, prefix):
- """Return code for unpacking primitives
- """
- if (primPattern != ""):
- #Clear prior primitives
- code.append(self.tab*2 + "fmt = '" + prefix + primPattern + "'")
- code.append(self.tab*2 + "start = " + str(offset))
- code.append(self.tab*2 + "end = start + struct.calcsize(fmt)")
- if len(primMemberNames) == 1:
- code.append(self.tab*2 + "(" + str(primMemberNames[0]) +
- ",) = struct.unpack(fmt, binaryString[start:end])")
- else:
- code.append(self.tab*2+"("+str(primMemberNames).replace("'","")[1:-1]+
- ") = struct.unpack(fmt, binaryString[start:end])")
-
- return ("",[], offset+struct.calcsize(prefix+primPattern))
-
diff --git a/tools/pylibopenflow/pylib/lavi/__init__.py b/tools/pylibopenflow/pylib/lavi/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/tools/pylibopenflow/pylib/lavi/__init__.py
+++ /dev/null
diff --git a/tools/pylibopenflow/pylib/lavi/pythonize.py b/tools/pylibopenflow/pylib/lavi/pythonize.py
deleted file mode 100644
index 3c150aa..0000000
--- a/tools/pylibopenflow/pylib/lavi/pythonize.py
+++ /dev/null
@@ -1,74 +0,0 @@
-"""This module generate Python code for LAVI and messenger
-
-(C) Copyright Stanford University
-Date January 2010
-Created by ykk
-"""
-import cpythonize
-
-class msgrules(cpythonize.rules):
- """Class that specify rules for pythonization of messenger
-
- (C) Copyright Stanford University
- Date January 2010
- Created by ykk
- """
- def __init__(self):
- """Initialize rules
- """
- cpythonize.rules.__init__(self)
- ##Default values for members
- #Default values for struct
- ##Macros to exclude
- self.excluded_macros = ['MESSAGE_HH__']
- ##Enforce mapping
- self.enforced_maps['messenger_msg'] = [ ('type','msg_type') ]
-
-class lavirules(msgrules):
- """Class that specify rules for pythonization of LAVI messages
-
- (C) Copyright Stanford University
- Date January 2010
- Created by ykk
- """
- def __init__(self, laviheader):
- """Initialize rules
- """
- msgrules.__init__(self)
- ##Default values for members
-
- #Default values for struct
- self.struct_default[('lavi_poll_message',
- 'header')] = ".type = "+str(laviheader.get_value('LAVIT_POLL'))
- self.struct_default[('lavi_poll_stop_message',
- 'header')] = ".type = "+str(laviheader.get_value('LAVIT_POLL_STOP'))
- ##Macros to exclude
- self.excluded_macros = ['LAVI_MSG_HH']
- ##Enforce mapping
- self.enforced_maps['lavi_header'] = [ ('type','lavi_type') ]
-
-class msgpythonizer(cpythonize.pythonizer):
- """Class that pythonize C messenger messages
-
- (C) Copyright Stanford University
- Date January 2010
- Created by ykk
- """
- def __init__(self, msgheader):
- """Initialize
- """
- rules = msgrules()
- cpythonize.pythonizer.__init__(self, msgheader, rules)
-
-class lavipythonizer(cpythonize.pythonizer):
- """Class that pythonize C messenger messages
-
- (C) Copyright Stanford University
- Date December 2009
- Created by ykk
- """
- def __init__(self, msgheader):
- """Initialize
- """
- rules = lavirules(msgheader)
- cpythonize.pythonizer.__init__(self, msgheader, rules)
diff --git a/tools/pylibopenflow/pylib/of/__init__.py b/tools/pylibopenflow/pylib/of/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/tools/pylibopenflow/pylib/of/__init__.py
+++ /dev/null
diff --git a/tools/pylibopenflow/pylib/of/msg.py b/tools/pylibopenflow/pylib/of/msg.py
deleted file mode 100644
index 8617f56..0000000
--- a/tools/pylibopenflow/pylib/of/msg.py
+++ /dev/null
@@ -1,117 +0,0 @@
-"""This module parses OpenFlow packets.
-
-Unfortunately, this has to be updated manually for each OpenFlow version
-and packet type. Ugly.
-
-(C) Copyright Stanford University
-Date October 2009
-Created by ykk
-"""
-class parser:
- """Parser for OpenFlow packets
-
- (C) Copyright Stanford University
- Date October 2009
- Created by ykk
- """
- def __init__(self, messages):
- """Initialize
- """
- ##Internal reference to OpenFlow messages
- self.__messages = messages
-
- def describe(self, packet):
- """Parse OpenFlow packet and return string description
- """
- dic = self.__messages.peek_from_front("ofp_header", packet)
- desc = self.header_describe(dic)
- if (dic["type"][0] == self.__messages.get_value("OFPT_HELLO")):
- pass
- elif (dic["type"][0] == self.__messages.get_value("OFPT_SET_CONFIG")):
- desc += "\n\t"+self.switch_config_describe(packet)
- elif (dic["type"][0] == self.__messages.get_value("OFPT_FLOW_MOD")):
- (fmdic, remaining) = self.__messages.unpack_from_front("ofp_flow_mod", packet)
- desc += self.flow_mod_describe(fmdic, "\n\t")
- desc += "\n\twith remaining "+str(len(remaining))+" bytes"
- else:
- desc += "\n\tUnparsed..."
- return desc
-
- def flow_mod_describe(self, packet, prefix=""):
- """Parse flow mod and return description
- """
- dic = self.__assert_dic(packet, "ofp_flow_mod")
- if (dic == None):
- return ""
- return prefix+\
- "Flow_mod of command "+self.__messages.get_enum_name("ofp_flow_mod_command", dic["command"][0])+\
- " idle/hard timeout:"+str(dic["idle_timeout"][0])+"/"+str(dic["hard_timeout"][0])+\
- self.match_describe(dic, "match.", "\n\t")+\
- prefix+\
- "(priority:"+str(dic["priority"][0])+\
- "/buffer id:"+str(dic["buffer_id"][0])+\
- "/out port:"+str(dic["out_port"][0])+")"
-
- def match_describe(self, dic, nameprefix="", prefix=""):
- """Return description for ofp match
- """
- return prefix+"match wildcards:%x" % dic[nameprefix+"wildcards"][0]+\
- " inport="+str(dic[nameprefix+"in_port"][0])+\
- prefix+" "+\
- " ethertype="+str(dic[nameprefix+"dl_type"][0])+\
- " vlan="+str(dic[nameprefix+"dl_vlan"][0])+\
- " "+self.eth_describe(dic[nameprefix+"dl_src"])+"->"+\
- self.eth_describe(dic[nameprefix+"dl_dst"])+\
- prefix+" "+\
- " ipproto="+str(dic[nameprefix+"nw_proto"][0])+\
- " "+self.ip_describe(dic[nameprefix+"nw_src"][0])+\
- "->"+self.ip_describe(dic[nameprefix+"nw_src"][0])+\
- prefix+" "+\
- " transport "+str(dic[nameprefix+"tp_src"][0])+\
- "->"+str(dic[nameprefix+"tp_dst"][0])
-
- def switch_config_describe(self, packet):
- """Parse OpenFlow switch config and return description
- """
- dic = self.__assert_dic(packet, "ofp_switch_config")
- if (dic == None):
- return ""
- return "with flag "+str(self.__messages.get_enum_name("ofp_config_flags", dic["flags"][0]))+\
- " and miss send length "+str(dic["miss_send_len"][0])
-
- def header_describe(self, packet):
- """Parse OpenFlow header and return string description
- """
- dic = self.__assert_dic(packet, "ofp_header")
- if (dic == None):
- return ""
- return self.__messages.get_enum_name("ofp_type", dic["type"][0])+" packet "+\
- "(length:"+str(dic["length"][0])+\
- "/xid:"+str(dic["xid"][0])+")"
-
- def ip_describe(self, value):
- """Return string for ip address
- """
- desc = ""
- for i in range(0,4):
- (value, cv) = divmod(value, 256)
- desc = str(cv).strip() +"." + desc
- return desc
-
- def eth_describe(self, etheraddr):
- """Return string for ethernet address
- """
- desc = ""
- for value in etheraddr:
- desc += ":"+("%x" % value).zfill(2)
- return desc[1:]
-
- def __assert_dic(self, packet, typename):
- """Assert and ensure dictionary is given
- """
- dic = None
- if (isinstance(packet, str)):
- dic = self.__messages.peek_from_front(typename, packet)
- elif (isinstance(packet, dict)):
- dic = packet
- return dic
diff --git a/tools/pylibopenflow/pylib/of/network.py b/tools/pylibopenflow/pylib/of/network.py
deleted file mode 100644
index 6765a12..0000000
--- a/tools/pylibopenflow/pylib/of/network.py
+++ /dev/null
@@ -1,191 +0,0 @@
-"""This module holds the network.
-
-Copyright(C) 2009, Stanford University
-Date October 2009
-Created by ykk
-"""
-import random
-import openflow
-
-class network:
- """Class holding information about OpenFlow network
- """
- def __init__(self):
- """Initialize
- """
- ##List of switches
- self.switches = []
- ##Dictionary of links
- self.links = {}
- ##Reference to connections
- self.connections = openflow.connections()
-
- def add_switch(self, sw):
- """Add switch to network
- """
- self.switches.append(sw)
- self.connections.add_connection(sw, sw.connection)
-
- def add_link(self, link):
- """Add link to network
- """
- try:
- self.links[link.switch1,link.switch2].append(link)
- except KeyError:
- self.links[link.switch1,link.switch2] = []
- self.links[link.switch1,link.switch2].append(link)
-
-class link:
- """Class to hold information about link
-
- Copyright(C) 2009, Stanford University
- Date November 2009
- Created by ykk
- """
- def __init__(self, switch1, switch2):
- """Initialize link between specified switches
- """
- ##Reference to first switch
- self.switch1 = switch1
- ##Reference to second switch
- self.switch2 = switch2
-
-class switch:
- """Class holding information about OpenFlow switch
-
- Copyright(C) 2009, Stanford University
- Date October 2009
- Created by ykk
- """
- def __init__(self, miss_send_len=128,
- sock=None, dpid=None, n_buffers=100, n_tables=1,
- capability=None):
- """Initialize switch
- """
- ##Socket to controller
- self.sock = sock
- ##Datapath id of switch
- if (dpid != None):
- self.datapath_id = dpid
- else:
- self.datapath_id = random.randrange(1, pow(2,64))
- ##Number of buffers
- self.n_buffers = n_buffers
- ##Number of tables
- self.n_tables= n_tables
- ##Capabilities
- if (isinstance(capability, switch_capabilities)):
- self.capability = capability
- else:
- self.capability = switch_capabilities(miss_send_len)
- ##Valid Actions
- self.valid_actions = 0
- ##List of port
- self.port = []
-
-class switch_capabilities:
- """Class to hold switch capabilities
- """
- def __init__(self, miss_send_len=128):
- """Initialize
-
- Copyright(C) 2009, Stanford University
- Date October 2009
- Created by ykk
- """
- ##Capabilities support by datapath
- self.flow_stats = True
- self.table_stats = True
- self.port_stats = True
- self.stp = True
- self.multi_phy_tx = True
- self.ip_resam = False
- ##Switch config
- self.send_exp = None
- self.ip_frag = 0
- self.miss_send_len = miss_send_len
- ##Valid actions
- self.act_output = True
- self.act_set_vlan_vid = True
- self.act_set_vlan_pcp = True
- self.act_strip_vlan = True
- self.act_set_dl_src = True
- self.act_set_dl_dst = True
- self.act_set_nw_src = True
- self.act_set_nw_dst = True
- self.act_set_tp_src = True
- self.act_set_tp_dst = True
- self.act_vendor = False
-
- def get_capability(self, ofmsg):
- """Return value for uint32_t capability field
- """
- value = 0
- if (self.flow_stats):
- value += ofmsg.get_value("OFPC_FLOW_STATS")
- if (self.table_stats):
- value += ofmsg.get_value("OFPC_TABLE_STATS")
- if (self.port_stats):
- value += ofmsg.get_value("OFPC_PORT_STATS")
- if (self.stp):
- value += ofmsg.get_value("OFPC_STP")
- if (self.multi_phy_tx):
- value += ofmsg.get_value("OFPC_MULTI_PHY_TX")
- if (self.ip_resam):
- value += ofmsg.get_value("OFPC_IP_REASM")
- return value
-
- def get_actions(self, ofmsg):
- """Return value for uint32_t action field
- """
- value = 0
- if (self.act_output):
- value += (1 << (ofmsg.get_value("OFPAT_OUTPUT")+1))
- if (self.act_set_vlan_vid):
- value += (1 << (ofmsg.get_value("OFPAT_SET_VLAN_VID")+1))
- if (self.act_set_vlan_pcp):
- value += (1 << (ofmsg.get_value("OFPAT_SET_VLAN_PCP")+1))
- if (self.act_strip_vlan):
- value += (1 << (ofmsg.get_value("OFPAT_STRIP_VLAN")+1))
- if (self.act_set_dl_src):
- value += (1 << (ofmsg.get_value("OFPAT_SET_DL_SRC")+1))
- if (self.act_set_dl_dst):
- value += (1 << (ofmsg.get_value("OFPAT_SET_DL_DST")+1))
- if (self.act_set_nw_src):
- value += (1 << (ofmsg.get_value("OFPAT_SET_NW_SRC")+1))
- if (self.act_set_nw_dst):
- value += (1 << (ofmsg.get_value("OFPAT_SET_NW_DST")+1))
- if (self.act_set_tp_src):
- value += (1 << (ofmsg.get_value("OFPAT_SET_TP_SRC")+1))
- if (self.act_set_tp_dst):
- value += (1 << (ofmsg.get_value("OFPAT_SET_TP_DST")+1))
- return value
-
-class port:
- """Class to hold information about port
-
- Copyright(C) 2009, Stanford University
- Date October 2009
- Created by ykk
- """
- def __init__(self, port_no, stp=(2 << 8), hw_addr=None, name=""):
- """Initialize
- """
- ##Port properties
- self.port_no = port_no
- if (hw_addr != None):
- self.hw_addr = hw_addr
- else:
- self.hw_addr = random.randrange(1, pow(2,48))
- self.name = name
- ##Port config
- self.port_down = False
- self.no_stp = False
- self.no_recv = False
- self.no_recv_stp = False
- self.no_flood = False
- self.no_fwd = False
- self.no_packet_in = False
- #Port state
- self.link_down = False
- self.stp = stp
diff --git a/tools/pylibopenflow/pylib/of/pythonize.py b/tools/pylibopenflow/pylib/of/pythonize.py
deleted file mode 100644
index 5a28818..0000000
--- a/tools/pylibopenflow/pylib/of/pythonize.py
+++ /dev/null
@@ -1,58 +0,0 @@
-"""This module generate Python code for OpenFlow structs.
-
-(C) Copyright Stanford University
-Date December 2009
-Created by ykk
-"""
-import cpythonize
-from config import *
-
-class rules(cpythonize.rules):
- """Class that specify rules for pythonization of OpenFlow messages
-
- (C) Copyright Stanford University
- Date December 2009
- Created by ykk
- """
- def __init__(self, ofmsg):
- """Initialize rules
- """
- cpythonize.rules.__init__(self)
- ##Reference to ofmsg
- self.__ofmsg = ofmsg
- ##Default values for members
- self.default_values[('ofp_header','version')] = self.__ofmsg.get_value('OFP_VERSION')
- self.default_values[('ofp_switch_config',\
- 'miss_send_len')] = self.__ofmsg.get_value('OFP_DEFAULT_MISS_SEND_LEN')
- for x in ['ofp_flow_mod','ofp_flow_expired','ofp_flow_stats']:
- self.default_values[(x,'priority')] = self.__ofmsg.get_value('OFP_DEFAULT_PRIORITY')
- #Default values for struct
- self.default_values[('ofp_packet_out','buffer_id')] = 0xffffffff
- self.struct_default[('ofp_flow_mod',
- 'header')] = ".type = OFPT_FLOW_MOD"
-# 'header')] = ".type = "+str(self.__ofmsg.get_value('OFPT_FLOW_MOD'))
- ##Macros to exclude
- self.excluded_macros = ['OFP_ASSERT(EXPR)','OFP_ASSERT(_EXPR)','OFP_ASSERT',
- 'icmp_type','icmp_code','OFP_PACKED',
- 'OPENFLOW_OPENFLOW_H']
- ##Enforce mapping
- if GEN_ENUM_VALUES_LIST:
- self.enforced_maps['ofp_header'] = [ ('type','ofp_type_values') ]
- elif GEN_ENUM_DICTIONARY:
- self.enforced_maps['ofp_header'] = \
- [ ('type','ofp_type_map.keys()') ]
-
-class pythonizer(cpythonize.pythonizer):
- """Class that pythonize C structures of OpenFlow messages
-
- (C) Copyright Stanford University
- Date December 2009
- Created by ykk
- """
- def __init__(self, ofmsg):
- """Initialize
- """
- ofrules = rules(ofmsg)
- cpythonize.pythonizer.__init__(self, ofmsg, ofrules)
- ##Reference to OpenFlow message class
- self.__ofmsg = ofmsg
diff --git a/tools/pylibopenflow/pylib/of/simu.py b/tools/pylibopenflow/pylib/of/simu.py
deleted file mode 100644
index 508b076..0000000
--- a/tools/pylibopenflow/pylib/of/simu.py
+++ /dev/null
@@ -1,144 +0,0 @@
-"""This module simulates the network.
-
-Copyright(C) 2009, Stanford University
-Date November 2009
-Created by ykk
-"""
-import openflow
-import output
-import of.msg
-import of.network
-
-class network(of.network.network):
- """Class to simulate OpenFlow network
-
- Copyright(C) 2009, Stanford University
- Date November 2009
- Created by ykk
- """
- def __init__(self):
- """Initialize network
- """
- of.network.network.__init__(self)
- ##Name of use for output
- self.name = self.__class__.__name__+str(id(self))
-
-class link(of.network.link):
- """Class to simulate link
-
- Copyright(C) 2009, Stanford University
- Date November 2009
- Created by ykk
- """
- def __init__(self, switch1, switch2, isUp=True):
- """Initialize link
- """
- of.network.link.__init__(self, switch1, switch2)
- ##Name of use for output
- self.name = self.__class__.__name__+str(id(self))
- ##Indicate if link is up
- self.isUp = isUp
-
-class switch(of.network.switch):
- """Class to simulate OpenFlow switch
-
- Copyright(C) 2009, Stanford University
- Date November 2009
- Created by ykk
- """
- def __init__(self, messages, controller, port, miss_send_len=128,
- dpid=None, n_buffers=100, n_tables=1,
- capability=None, parser=None, connection=None):
- """Initialize switch
- """
- of.network.switch.__init__(self, miss_send_len,
- None, dpid, n_buffers, n_tables,
- capability)
- ##Name of use for output
- self.name = self.__class__.__name__+str(id(self))
- ##Reference to OpenFlow messages
- self.__messages = messages
- ##Reference to connection
- self.connection = openflow.tcpsocket(messages, controller, port)
- self.sock = self.connection.sock
- ##Reference to Parser
- self.parser = None
- if (parser == None):
- self.parser = of.msg.parser(messages)
- else:
- self.parser = parser
-
- def receive_openflow(self, packet):
- """Switch receive OpenFlow packet, and respond accordingly
- """
- dic = self.__messages.peek_from_front("ofp_header", packet)
- if (dic["type"][0] == self.__messages.get_value("OFPT_HELLO")):
- output.dbg("Receive hello", self.name)
- elif (dic["type"][0] == self.__messages.get_value("OFPT_ECHO_REQUEST")):
- self.reply_echo(dic["xid"][0])
- elif (dic["type"][0] == self.__messages.get_value("OFPT_FEATURES_REQUEST")):
- self.reply_features(dic["xid"][0])
- elif (dic["type"][0] == self.__messages.get_value("OFPT_FLOW_MOD")):
- self.handle_flow_mod(packet)
- else:
- output.dbg("Unprocessed message "+self.parser.header_describe(dic),
- self.name)
-
- def send_hello(self):
- """Send hello
- """
- self.connection.structsend("ofp_hello",
- 0, self.__messages.get_value("OFPT_HELLO"),
- 0, 0)
- output.dbg("Send hello",self.name)
-
- def send_packet(self, inport, bufferid=None, packet="", xid=0, reason=None):
- """Send packet in
- Assume no match as reason, bufferid = 0xFFFFFFFF,
- and empty packet by default
- """
- if (reason == None):
- reason = self.__messages.get_value("OFPR_NO_MATCH")
- if (bufferid == None):
- bufferid = int("0xFFFFFFFF",16)
- pktin = self.__messages.pack("ofp_packet_in",
- 0, self.__messages.get_value("OFPT_PACKET_IN"),
- 0, xid, #header
- bufferid, len(packet),
- inport, reason, 0)
- self.connection.structsend_raw(pktin+packet)
- output.dbg("Send packet ",self.name)
-
- def send_echo(self, xid=0):
- """Send echo
- """
- self.connection.structsend_xid("ofp_header",
- 0, self.__messages.get_value("OFPT_ECHO_REQUEST"),
- 0, xid)
- output.dbg("Send echo", self.name)
-
- def reply_echo(self, xid):
- """Reply to echo request
- """
- self.connection.structsend_xid("ofp_header",
- 0, self.__messages.get_value("OFPT_ECHO_REPLY"),
- 0, xid)
- output.dbg("Reply echo of xid:"+str(xid),self.name)
-
- def reply_features(self, xid):
- """Reply to feature request
- """
- self.connection.structsend_xid("ofp_switch_features",
- 0, self.__messages.get_value("OFPT_FEATURES_REPLY"),
- 0, xid,
- self.datapath_id, self.n_buffers,
- self.n_tables,0,0,0,
- self.capability.get_capability(self.__messages),
- self.capability.get_actions(self.__messages))
- output.dbg("Replied features request of xid "+str(xid), self.name)
-
- def handle_flow_mod(self, packet):
- """Handle flow mod: just print it here
- """
- output.dbg(self.parser.flow_mod_describe(packet), self.name)
-
diff --git a/tools/pylibopenflow/pylib/openflow.py b/tools/pylibopenflow/pylib/openflow.py
deleted file mode 100644
index 25945b9..0000000
--- a/tools/pylibopenflow/pylib/openflow.py
+++ /dev/null
@@ -1,336 +0,0 @@
-"""This module exports OpenFlow protocol to Python.
-
-(C) Copyright Stanford University
-Date October 2009
-Created by ykk
-"""
-import c2py
-import cheader
-import os
-import socket
-import select
-import struct
-import time
-
-class messages(cheader.cheaderfile,c2py.cstruct2py,c2py.structpacker):
- """Class to handle OpenFlow messages
-
- (C) Copyright Stanford University
- Date October 2009
- Created by ykk
- """
- def __init__(self, openflow_headerfile=None):
- """Initialize with OpenFlow header file
-
- If filename is not provided, check the environment
- variable PYLIB_OPENFLOW_HEADER and search for openflow.h
- """
- if (openflow_headerfile != None):
- cheader.cheaderfile.__init__(self, openflow_headerfile)
- else:
- #Check environment variable
- path = os.getenv("PYLIB_OPENFLOW_HEADER")
- if not path:
- print "PYLIB_OPENFLOW_HEADER is not set in environment"
- sys.exit(2)
- cheader.cheaderfile.__init__(self, path+"/openflow.h")
- #Initialize cstruct2py
- c2py.cstruct2py.__init__(self)
- #Initalize packet
- c2py.structpacker.__init__(self, "!")
- ##Cached patterns
- self.patterns={}
- for (cstructname, cstruct) in self.structs.items():
- self.patterns[cstructname] = self.get_pattern(cstruct)
-
- def get_size(self, ctype):
- """Get size for ctype or name of type.
- Return None if ctype is not expanded or
- type with name is not found.
- """
- pattern = self.get_pattern(ctype)
- if (pattern != None):
- return c2py.cstruct2py.get_size(self,pattern)
-
- def get_pattern(self,ctype):
- """Get pattern string for ctype or name of type.
- Return None if ctype is not expanded or
- type with name is not found.
- """
- if (isinstance(ctype, str)):
- #Is name
- return self.patterns[ctype]
- else:
- return c2py.cstruct2py.get_pattern(self, ctype)
-
- def pack(self, ctype, *arg):
- """Pack packet accordingly ctype or name of type provided.
- Return struct packed.
- """
- if (isinstance(ctype, str)):
- return struct.pack(self.prefix+self.patterns[ctype], *arg)
- else:
- return c2py.structpacker.pack(self, ctype, *arg)
-
- def peek_from_front(self, ctype, binaryString, returnDictionary=True):
- """Unpack packet using front of the packet,
- accordingly ctype or name of ctype provided.
-
- Return dictionary of values indexed by arg name,
- if ctype is known struct/type and returnDictionary is True,
- else return array of data unpacked.
- """
- if (isinstance(ctype,str)):
- data = c2py.structpacker.peek_from_front(self,
- self.patterns[ctype],
- binaryString,
- returnDictionary)
- return self.data2dic(self.structs[ctype], data)
- else:
- return c2py.structpacker.peek_from_front(self,
- ctype,
- binaryString,
- returnDictionary)
-
- def unpack_from_front(self, ctype, binaryString, returnDictionary=True):
- """Unpack packet using front of packet,
- accordingly ctype or name of ctype provided.
-
- Return (dictionary of values indexed by arg name,
- remaining binary string) if ctype is known struct/type
- and returnDictionary is True,
- else return (array of data unpacked, remaining binary string).
- """
- if (isinstance(ctype,str)):
- (data, remaining) = c2py.structpacker.unpack_from_front(self,
- self.patterns[ctype],
- binaryString,
- returnDictionary)
- return (self.data2dic(self.structs[ctype], data), remaining)
- else:
- return c2py.structpacker.unpack_from_front(self,
- ctype,
- binaryString,
- returnDictionary)
-
-class connection:
- """Class to hold a connection.
-
- (C) Copyright Stanford University
- Date October 2009
- Created by ykk
- """
- def __init__(self, messages, sock=None):
- """Initialize
- """
- ##Reference to socket
- self.sock = sock
- ##Internal reference to OpenFlow messages
- self._messages = messages
- ##Buffer
- self.buffer = ""
- ##Header length for OpenFlow
- self.__header_length = self._messages.get_size("ofp_header")
-
- def send(self, msg):
- """Send bare message (given as binary string)
- """
- raise NotImplementedError()
-
- def structsend(self, ctype, *arg):
- """Build and send message.
- """
- self.send(self._messages.pack(ctype, *arg))
-
- def receive(self, maxlength=1024):
- """Receive raw in non-blocking way.
-
- Return buffer
- """
- if (select.select([self.sock],[],[],0)[0]):
- self.buffer += self.sock.recv(maxlength)
- return self.buffer
-
- def buffer_has_msg(self):
- """Check if buffer has a complete message
- """
- #Check at least ofp_header is received
- if (len(self.buffer) < self.__header_length):
- return False
- values = self._messages.peek_from_front("ofp_header", self.buffer)
- return (len(self.buffer) >= values["length"][0])
-
- def get_msg(self):
- """Get message from current buffer
- """
- if (self.buffer_has_msg()):
- values = self._messages.peek_from_front("ofp_header", self.buffer)
- msg = self.buffer[:values["length"][0]]
- self.buffer = self.buffer[values["length"][0]:]
- return msg
- else:
- return None
-
- def msgreceive(self, blocking=False, pollInterval=0.001):
- """Receive OpenFlow message.
-
- If non-blocking, can return None.
- """
- self.receive()
- if (self.buffer_has_msg()):
- return self.get_msg()
- if (blocking):
- while (not self.buffer_has_msg()):
- time.sleep(pollInterval)
- self.receive()
- return self.get_msg()
-
-class safeconnection(connection):
- """OpenFlow connection with safety checks
-
- (C) Copyright Stanford University
- Date October 2009
- Created by ykk
- """
- def __init__(self, messages, sock=None, version=None,
- xidstart = 0, autoxid=True):
- """Initialize with OpenFlow version.
- """
- connection.__init__(self, messages, sock)
- ##OpenFlow version
- if (version != None):
- self.version = version
- else:
- self.version = messages.get_value("OFP_VERSION")
- ##xid Counter
- self.nextxid = xidstart
- ##Automatic xid
- self.autoxid = autoxid
- ##Miss auto xid
- self.skipautoxid = 0
-
- def skip_auto_xid(self, n):
- """Miss automatic xid for the next n packets
- """
- self.skipautoxid = n
-
- def structsend_xid(self, ctype, *arg):
- """Build and send message, populating header automatically.
- Type and xid of message is not populated.
- """
- self.skipautoxid+=1
- self.structsend(ctype, *arg)
-
- def structsend(self, ctype, *arg):
- """Build and send message, populating header automatically.
- Type of message is not populated
- """
- msg = self._messages.pack(ctype, *arg)
- self.structsend_raw(msg)
-
- def structsend_raw(self, msg):
- """Check ofp_header and ensure correctness before sending.
- """
- (dic, remaining) = self._messages.unpack_from_front("ofp_header", msg)
- #Amend header
- if (self.version != None):
- dic["version"][0] = self.version
- if (self.autoxid and (self.skipautoxid == 0)):
- dic["xid"][0] = self.nextxid
- self.nextxid+=1
- if (self.skipautoxid != 0):
- self.skipautoxid-=1
- dic["length"][0] = len(remaining)+8
- #Send message
- self.send(self._messages.pack("ofp_header",
- dic["version"][0],
- dic["type"][0],
- dic["length"][0],
- dic["xid"][0])+\
- remaining)
-
-class tcpsocket(safeconnection):
- """Class to hold connection
-
- (C) Copyright Stanford University
- Date October 2009
- Created by ykk
- """
- def __init__(self, messages, host, port):
- """Initialize TCP socket to host and port
- """
- safeconnection.__init__(self, messages)
- ##Reference to socket
- self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- self.sock.connect((host, port))
- self.sock.setblocking(False)
- self.sock.setsockopt(socket.SOL_TCP, socket.TCP_NODELAY, 0)
-
- def __del__(self):
- """Terminate connection
- """
- self.sock.shutdown(1)
- self.sock.close()
-
- def send(self, msg):
- """Send raw message (binary string)
- """
- self.sock.sendall(msg)
-
-class connections:
- """Class to hold multiple connections
-
- (C) Copyright Stanford University
- Date November 2009
- Created by ykk
- """
- def __init__(self):
- """Initialize
- """
- ##List of sockets
- self.__sockets = []
- ##Dicionary of sockets to connection
- self.__connections = {}
-
- def add_connection(self, reference, connect):
- """Add connection with opaque reference object
- """
- if (not isinstance(connect,connection)):
- raise RuntimeError("Connection must be openflow.connection!")
- self.__sockets.append(connect.sock)
- self.__connections[connect.sock] = (reference, connect)
-
- def receive(self, maxlength=1024):
- """Receive raw in non-blocking way
- """
- read_ready = select.select(self.__sockets,[],[],0)[0]
- for sock in read_ready:
- self.__connections[sock][1].receive(maxlength)
-
- def has_msg(self):
- """Check if any of the connections has a message
-
- Return (reference,connection) with message
- """
- for sock, refconnect in self.__connections.items():
- if (refconnect[1].buffer_has_msg()):
- return refconnect
- return None
-
- def msgreceive(self, blocking=False, pollInterval=0.001):
- """Receive OpenFlow message.
-
- If non-blocking, can return None.
- """
- self.receive()
- c = self.has_msg()
- if (c != None):
- return (c[0],c[1].get_msg())
- if (blocking):
- while (c == None):
- time.sleep(pollInterval)
- self.receive()
- c = self.has_msg()
- else:
- return (None, None)
- return (c[0],c[1].get_msg())
diff --git a/tools/pylibopenflow/pylib/output.py b/tools/pylibopenflow/pylib/output.py
deleted file mode 100644
index 64df4f5..0000000
--- a/tools/pylibopenflow/pylib/output.py
+++ /dev/null
@@ -1,85 +0,0 @@
-"""This module implements output printing.
-
-Output are divided into 4 levels and
-can be configured for different verbosity
-
-Copyright(C) 2009, Stanford University
-Date August 2009
-Created by ykk
-"""
-
-##Various output modes
-MODE = {}
-MODE["ERR"] = 0
-MODE["WARN"] = 1
-MODE["INFO"] = 2
-MODE["DBG"] = 3
-
-#Global mode
-global output_mode
-output_mode = None
-
-def set_mode(msg_mode, who=None):
- """Set the message mode for who
- If who is None, set global mode
- """
- global output_mode
- if (output_mode == None):
- output_mode = {}
- output_mode["global"] = MODE["WARN"]
- output_mode["DBG"] = []
- output_mode["INFO"] = []
- output_mode["WARN"] = []
-
- #Set global mode
- if (who == None):
- output_mode["global"] = MODE[msg_mode]
- return
-
- #Individual mode
- if (msg_mode == "ERR"):
- return
- for mode in ["WARN","INFO","DBG"]:
- if (not (who in mode[mode])):
- mode[mode].append(who)
- if (msg_mode == mode):
- return
-
-def output(msg_mode, msg, who=None):
- """Print message
- """
- global output_mode
- if (output_mode == None):
- raise RuntimeException("Output mode is not set")
-
- #Indicate who string
- if (who == None):
- whostr = ""
- else:
- whostr = who+":"
-
- #Print output
- if (MODE[msg_mode] <= output_mode["global"]):
- print msg_mode.ljust(4, ' ')+"|"+whostr+msg
- elif (who in output_mode[msg_mode]):
- print msg_mode.ljust(4, ' ')+"|"+whostr+msg
-
-def err(msg, who=None):
- """Print error messages
- """
- output("ERR", msg, who)
-
-def warn(msg, who=None):
- """Print warning messages
- """
- output("WARN", msg, who)
-
-def info(msg, who=None):
- """Print informational messages
- """
- output("INFO", msg, who)
-
-def dbg(msg, who=None):
- """Print debug messages
- """
- output("DBG", msg, who)