move and check in OpenFlow protocol modules
Move all the protocol code out of the oftest package and into a of10 package to
prepare for supporting more OpenFlow versions.
The generated code is now checked-in to make it simpler to use OFTest.
Backwards compatibility with out of tree tests is maintained by aliasing the
old module names. The basic test module has been changed to use the new API.
diff --git a/src/python/of10/__init__.py b/src/python/of10/__init__.py
new file mode 100644
index 0000000..c4407ee
--- /dev/null
+++ b/src/python/of10/__init__.py
@@ -0,0 +1,8 @@
+"""
+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/of10/action.py b/src/python/of10/action.py
new file mode 100644
index 0000000..c478c62
--- /dev/null
+++ b/src/python/of10/action.py
@@ -0,0 +1,372 @@
+
+# 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
new file mode 100644
index 0000000..fbbddea
--- /dev/null
+++ b/src/python/of10/action_list.py
@@ -0,0 +1,189 @@
+"""
+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
new file mode 100644
index 0000000..19600e6
--- /dev/null
+++ b/src/python/of10/class_maps.py
@@ -0,0 +1,249 @@
+
+# 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
new file mode 100644
index 0000000..a41e115
--- /dev/null
+++ b/src/python/of10/cstruct.py
@@ -0,0 +1,4021 @@
+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
new file mode 100644
index 0000000..c69b70d
--- /dev/null
+++ b/src/python/of10/error.py
@@ -0,0 +1,306 @@
+
+# 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
new file mode 100644
index 0000000..bf0064e
--- /dev/null
+++ b/src/python/of10/message.py
@@ -0,0 +1,3373 @@
+
+# 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
new file mode 100644
index 0000000..a3421a1
--- /dev/null
+++ b/src/python/of10/parse.py
@@ -0,0 +1,343 @@
+"""
+OpenFlow message parsing functions
+"""
+
+import sys
+import logging
+from message import *
+from error import *
+from action import *
+from action_list import action_list
+from cstruct import *
+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 = [
+ OFPT_STATS_REQUEST,
+ OFPT_STATS_REPLY,
+ OFPT_ERROR
+]
+
+# Maps from sub-types to classes
+stats_reply_to_class_map = {
+ OFPST_DESC : desc_stats_reply,
+ OFPST_AGGREGATE : aggregate_stats_reply,
+ OFPST_FLOW : flow_stats_reply,
+ OFPST_TABLE : table_stats_reply,
+ OFPST_PORT : port_stats_reply,
+ OFPST_QUEUE : queue_stats_reply
+}
+
+stats_request_to_class_map = {
+ OFPST_DESC : desc_stats_request,
+ OFPST_AGGREGATE : aggregate_stats_request,
+ OFPST_FLOW : flow_stats_request,
+ OFPST_TABLE : table_stats_request,
+ OFPST_PORT : port_stats_request,
+ OFPST_QUEUE : queue_stats_request
+}
+
+error_to_class_map = {
+ OFPET_HELLO_FAILED : hello_failed_error_msg,
+ OFPET_BAD_REQUEST : bad_request_error_msg,
+ OFPET_BAD_ACTION : bad_action_error_msg,
+ OFPET_FLOW_MOD_FAILED : flow_mod_failed_error_msg,
+ OFPET_PORT_MOD_FAILED : port_mod_failed_error_msg,
+ OFPET_QUEUE_OP_FAILED : queue_op_failed_error_msg
+}
+
+# Map from header type value to the underlieing message class
+msg_type_to_class_map = {
+ OFPT_HELLO : hello,
+ OFPT_ERROR : error,
+ OFPT_ECHO_REQUEST : echo_request,
+ OFPT_ECHO_REPLY : echo_reply,
+ OFPT_VENDOR : vendor,
+ OFPT_FEATURES_REQUEST : features_request,
+ OFPT_FEATURES_REPLY : features_reply,
+ OFPT_GET_CONFIG_REQUEST : get_config_request,
+ OFPT_GET_CONFIG_REPLY : get_config_reply,
+ OFPT_SET_CONFIG : set_config,
+ OFPT_PACKET_IN : packet_in,
+ OFPT_FLOW_REMOVED : flow_removed,
+ OFPT_PORT_STATUS : port_status,
+ OFPT_PACKET_OUT : packet_out,
+ OFPT_FLOW_MOD : flow_mod,
+ OFPT_PORT_MOD : port_mod,
+ OFPT_STATS_REQUEST : stats_request,
+ OFPT_STATS_REPLY : stats_reply,
+ OFPT_BARRIER_REQUEST : barrier_request,
+ OFPT_BARRIER_REPLY : barrier_reply,
+ OFPT_QUEUE_GET_CONFIG_REQUEST : queue_get_config_request,
+ OFPT_QUEUE_GET_CONFIG_REPLY : queue_get_config_reply
+}
+
+def _of_message_to_object(binary_string):
+ """
+ Map a binary string to the corresponding class.
+
+ Appropriately resolves subclasses
+ """
+ hdr = 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 == OFPT_STATS_REQUEST:
+ sub_hdr = ofp_stats_request()
+ sub_hdr.unpack(binary_string[OFP_HEADER_BYTES:])
+ try:
+ obj = stats_request_to_class_map[sub_hdr.type]()
+ except KeyError:
+ obj = None
+ return obj
+ elif hdr.type == OFPT_STATS_REPLY:
+ sub_hdr = ofp_stats_reply()
+ sub_hdr.unpack(binary_string[OFP_HEADER_BYTES:])
+ try:
+ obj = stats_reply_to_class_map[sub_hdr.type]()
+ except KeyError:
+ obj = None
+ return obj
+ elif hdr.type == OFPT_ERROR:
+ sub_hdr = ofp_error_msg()
+ sub_hdr.unpack(binary_string[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_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 = ofp_match()
+ match.wildcards = OFPFW_ALL
+ #@todo Check if packet is other than L2 format
+ match.dl_dst = parse_mac(ether.dst)
+ match.wildcards &= ~OFPFW_DL_DST
+ match.dl_src = parse_mac(ether.src)
+ match.wildcards &= ~OFPFW_DL_SRC
+ match.dl_type = ether.type
+ match.wildcards &= ~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 = OFP_VLAN_NONE
+ match.dl_vlan_pcp = 0
+ match.wildcards &= ~OFPFW_DL_VLAN
+ match.wildcards &= ~OFPFW_DL_VLAN_PCP
+
+ if ip:
+ match.nw_src = parse_ip(ip.src)
+ match.wildcards &= ~OFPFW_NW_SRC_MASK
+ match.nw_dst = parse_ip(ip.dst)
+ match.wildcards &= ~OFPFW_NW_DST_MASK
+ match.nw_tos = ip.tos
+ match.wildcards &= ~OFPFW_NW_TOS
+
+ if tcp:
+ match.nw_proto = 6
+ match.wildcards &= ~OFPFW_NW_PROTO
+ elif not tcp and udp:
+ tcp = udp
+ match.nw_proto = 17
+ match.wildcards &= ~OFPFW_NW_PROTO
+
+ if tcp:
+ match.tp_src = tcp.sport
+ match.wildcards &= ~OFPFW_TP_SRC
+ match.tp_dst = tcp.dport
+ match.wildcards &= ~OFPFW_TP_DST
+
+ if icmp:
+ match.nw_proto = 1
+ match.tp_src = icmp.type
+ match.tp_dst = icmp.code
+ match.wildcards &= ~OFPFW_NW_PROTO
+
+ if arp:
+ match.nw_proto = arp.op
+ match.wildcards &= ~OFPFW_NW_PROTO
+ match.nw_src = parse_ip(arp.psrc)
+ match.wildcards &= ~OFPFW_NW_SRC_MASK
+ match.nw_dst = parse_ip(arp.pdst)
+ match.wildcards &= ~OFPFW_NW_DST_MASK
+
+ return match