remove of10
diff --git a/src/python/of10/__init__.py b/src/python/of10/__init__.py
deleted file mode 100644
index 26dbd76..0000000
--- a/src/python/of10/__init__.py
+++ /dev/null
@@ -1,17 +0,0 @@
-"""
-Python OpenFlow 1.0 library
-
-Most of the files in this package are automatically generated by tools/munger.
-They are checked in to simplify running OFTest.
-"""
-
-__all__ = ["action_list", "action", "cstruct", "error", "message"]
-
-# Allow accessing constants through the top-level module
-from cstruct import *
-
-# Allow accessing submodules without additional imports
-import action
-import message
-
-match = ofp_match
diff --git a/src/python/of10/action.py b/src/python/of10/action.py
deleted file mode 100644
index c478c62..0000000
--- a/src/python/of10/action.py
+++ /dev/null
@@ -1,372 +0,0 @@
-
-# Python OpenFlow action wrapper classes
-
-from cstruct import *
-
-
-
-class vendor(ofp_action_vendor_header):
- """
- Wrapper class for vendor action object
-
- Data members inherited from ofp_action_vendor_header:
- @arg type
- @arg len
- @arg vendor
-
- """
- def __init__(self, **kwargs):
- ofp_action_vendor_header.__init__(self)
- self.type = OFPAT_VENDOR
- self.len = self.__len__()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- def show(self, prefix=''):
- outstr = prefix + "action_vendor\n"
- outstr += ofp_action_vendor_header.show(self, prefix)
- return outstr
-
-action_vendor = vendor # for backwards compatibility
-
-
-class set_tp_dst(ofp_action_tp_port):
- """
- Wrapper class for set_tp_dst action object
-
- Data members inherited from ofp_action_tp_port:
- @arg type
- @arg len
- @arg tp_port
-
- """
- def __init__(self, **kwargs):
- ofp_action_tp_port.__init__(self)
- self.type = OFPAT_SET_TP_DST
- self.len = self.__len__()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- def show(self, prefix=''):
- outstr = prefix + "action_set_tp_dst\n"
- outstr += ofp_action_tp_port.show(self, prefix)
- return outstr
-
-action_set_tp_dst = set_tp_dst # for backwards compatibility
-
-
-class set_vlan_pcp(ofp_action_vlan_pcp):
- """
- Wrapper class for set_vlan_pcp action object
-
- Data members inherited from ofp_action_vlan_pcp:
- @arg type
- @arg len
- @arg vlan_pcp
-
- """
- def __init__(self, **kwargs):
- ofp_action_vlan_pcp.__init__(self)
- self.type = OFPAT_SET_VLAN_PCP
- self.len = self.__len__()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- def show(self, prefix=''):
- outstr = prefix + "action_set_vlan_pcp\n"
- outstr += ofp_action_vlan_pcp.show(self, prefix)
- return outstr
-
-action_set_vlan_pcp = set_vlan_pcp # for backwards compatibility
-
-
-class enqueue(ofp_action_enqueue):
- """
- Wrapper class for enqueue action object
-
- Data members inherited from ofp_action_enqueue:
- @arg type
- @arg len
- @arg port
- @arg queue_id
-
- """
- def __init__(self, **kwargs):
- ofp_action_enqueue.__init__(self)
- self.type = OFPAT_ENQUEUE
- self.len = self.__len__()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- def show(self, prefix=''):
- outstr = prefix + "action_enqueue\n"
- outstr += ofp_action_enqueue.show(self, prefix)
- return outstr
-
-action_enqueue = enqueue # for backwards compatibility
-
-
-class set_tp_src(ofp_action_tp_port):
- """
- Wrapper class for set_tp_src action object
-
- Data members inherited from ofp_action_tp_port:
- @arg type
- @arg len
- @arg tp_port
-
- """
- def __init__(self, **kwargs):
- ofp_action_tp_port.__init__(self)
- self.type = OFPAT_SET_TP_SRC
- self.len = self.__len__()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- def show(self, prefix=''):
- outstr = prefix + "action_set_tp_src\n"
- outstr += ofp_action_tp_port.show(self, prefix)
- return outstr
-
-action_set_tp_src = set_tp_src # for backwards compatibility
-
-
-class set_nw_tos(ofp_action_nw_tos):
- """
- Wrapper class for set_nw_tos action object
-
- Data members inherited from ofp_action_nw_tos:
- @arg type
- @arg len
- @arg nw_tos
-
- """
- def __init__(self, **kwargs):
- ofp_action_nw_tos.__init__(self)
- self.type = OFPAT_SET_NW_TOS
- self.len = self.__len__()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- def show(self, prefix=''):
- outstr = prefix + "action_set_nw_tos\n"
- outstr += ofp_action_nw_tos.show(self, prefix)
- return outstr
-
-action_set_nw_tos = set_nw_tos # for backwards compatibility
-
-
-class set_nw_dst(ofp_action_nw_addr):
- """
- Wrapper class for set_nw_dst action object
-
- Data members inherited from ofp_action_nw_addr:
- @arg type
- @arg len
- @arg nw_addr
-
- """
- def __init__(self, **kwargs):
- ofp_action_nw_addr.__init__(self)
- self.type = OFPAT_SET_NW_DST
- self.len = self.__len__()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- def show(self, prefix=''):
- outstr = prefix + "action_set_nw_dst\n"
- outstr += ofp_action_nw_addr.show(self, prefix)
- return outstr
-
-action_set_nw_dst = set_nw_dst # for backwards compatibility
-
-
-class strip_vlan(ofp_action_header):
- """
- Wrapper class for strip_vlan action object
-
- Data members inherited from ofp_action_header:
- @arg type
- @arg len
-
- """
- def __init__(self, **kwargs):
- ofp_action_header.__init__(self)
- self.type = OFPAT_STRIP_VLAN
- self.len = self.__len__()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- def show(self, prefix=''):
- outstr = prefix + "action_strip_vlan\n"
- outstr += ofp_action_header.show(self, prefix)
- return outstr
-
-action_strip_vlan = strip_vlan # for backwards compatibility
-
-
-class set_dl_dst(ofp_action_dl_addr):
- """
- Wrapper class for set_dl_dst action object
-
- Data members inherited from ofp_action_dl_addr:
- @arg type
- @arg len
- @arg dl_addr
-
- """
- def __init__(self, **kwargs):
- ofp_action_dl_addr.__init__(self)
- self.type = OFPAT_SET_DL_DST
- self.len = self.__len__()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- def show(self, prefix=''):
- outstr = prefix + "action_set_dl_dst\n"
- outstr += ofp_action_dl_addr.show(self, prefix)
- return outstr
-
-action_set_dl_dst = set_dl_dst # for backwards compatibility
-
-
-class set_nw_src(ofp_action_nw_addr):
- """
- Wrapper class for set_nw_src action object
-
- Data members inherited from ofp_action_nw_addr:
- @arg type
- @arg len
- @arg nw_addr
-
- """
- def __init__(self, **kwargs):
- ofp_action_nw_addr.__init__(self)
- self.type = OFPAT_SET_NW_SRC
- self.len = self.__len__()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- def show(self, prefix=''):
- outstr = prefix + "action_set_nw_src\n"
- outstr += ofp_action_nw_addr.show(self, prefix)
- return outstr
-
-action_set_nw_src = set_nw_src # for backwards compatibility
-
-
-class set_vlan_vid(ofp_action_vlan_vid):
- """
- Wrapper class for set_vlan_vid action object
-
- Data members inherited from ofp_action_vlan_vid:
- @arg type
- @arg len
- @arg vlan_vid
-
- """
- def __init__(self, **kwargs):
- ofp_action_vlan_vid.__init__(self)
- self.type = OFPAT_SET_VLAN_VID
- self.len = self.__len__()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- def show(self, prefix=''):
- outstr = prefix + "action_set_vlan_vid\n"
- outstr += ofp_action_vlan_vid.show(self, prefix)
- return outstr
-
-action_set_vlan_vid = set_vlan_vid # for backwards compatibility
-
-
-class set_dl_src(ofp_action_dl_addr):
- """
- Wrapper class for set_dl_src action object
-
- Data members inherited from ofp_action_dl_addr:
- @arg type
- @arg len
- @arg dl_addr
-
- """
- def __init__(self, **kwargs):
- ofp_action_dl_addr.__init__(self)
- self.type = OFPAT_SET_DL_SRC
- self.len = self.__len__()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- def show(self, prefix=''):
- outstr = prefix + "action_set_dl_src\n"
- outstr += ofp_action_dl_addr.show(self, prefix)
- return outstr
-
-action_set_dl_src = set_dl_src # for backwards compatibility
-
-
-class output(ofp_action_output):
- """
- Wrapper class for output action object
-
- Data members inherited from ofp_action_output:
- @arg type
- @arg len
- @arg port
- @arg max_len
-
- """
- def __init__(self, **kwargs):
- ofp_action_output.__init__(self)
- self.type = OFPAT_OUTPUT
- self.len = self.__len__()
- for (k, v) in kwargs.items():
- if hasattr(self, k):
- setattr(self, k, v)
- else:
- raise NameError("field %s does not exist in %s" % (k, self.__class__))
- def show(self, prefix=''):
- outstr = prefix + "action_output\n"
- outstr += ofp_action_output.show(self, prefix)
- return outstr
-
-action_output = output # for backwards compatibility
-
-action_class_list = (
- action_vendor,
- action_set_tp_dst,
- action_set_vlan_pcp,
- action_enqueue,
- action_set_tp_src,
- action_set_nw_tos,
- action_set_nw_dst,
- action_strip_vlan,
- action_set_dl_dst,
- action_set_nw_src,
- action_set_vlan_vid,
- action_set_dl_src,
- action_output)
diff --git a/src/python/of10/action_list.py b/src/python/of10/action_list.py
deleted file mode 100644
index 2c5a906..0000000
--- a/src/python/of10/action_list.py
+++ /dev/null
@@ -1,154 +0,0 @@
-"""
-OpenFlow actions list class
-"""
-
-from action import *
-from cstruct import ofp_header
-import copy
-
-# # Map OFP action identifiers to the actual structures used on the wire
-# action_object_map = {
-# OFPAT_OUTPUT : ofp_action_output,
-# OFPAT_SET_VLAN_VID : ofp_action_vlan_vid,
-# OFPAT_SET_VLAN_PCP : ofp_action_vlan_pcp,
-# OFPAT_STRIP_VLAN : ofp_action_header,
-# OFPAT_SET_DL_SRC : ofp_action_dl_addr,
-# OFPAT_SET_DL_DST : ofp_action_dl_addr,
-# OFPAT_SET_NW_SRC : ofp_action_nw_addr,
-# OFPAT_SET_NW_DST : ofp_action_nw_addr,
-# OFPAT_SET_NW_TOS : ofp_action_nw_tos,
-# OFPAT_SET_TP_SRC : ofp_action_tp_port,
-# OFPAT_SET_TP_DST : ofp_action_tp_port,
-# OFPAT_ENQUEUE : ofp_action_enqueue
-# }
-
-action_object_map = {
- OFPAT_OUTPUT : action_output,
- OFPAT_SET_VLAN_VID : action_set_vlan_vid,
- OFPAT_SET_VLAN_PCP : action_set_vlan_pcp,
- OFPAT_STRIP_VLAN : action_strip_vlan,
- OFPAT_SET_DL_SRC : action_set_dl_src,
- OFPAT_SET_DL_DST : action_set_dl_dst,
- OFPAT_SET_NW_SRC : action_set_nw_src,
- OFPAT_SET_NW_DST : action_set_nw_dst,
- OFPAT_SET_NW_TOS : action_set_nw_tos,
- OFPAT_SET_TP_SRC : action_set_tp_src,
- OFPAT_SET_TP_DST : action_set_tp_dst,
- OFPAT_ENQUEUE : action_enqueue,
- OFPAT_VENDOR : action_vendor
-}
-
-class action_list(object):
- """
- Maintain a list of actions
-
- Data members:
- @arg actions: An array of action objects such as action_output, etc.
-
- Methods:
- @arg pack: Pack the structure into a string
- @arg unpack: Unpack a string to objects, with proper typing
- @arg add: Add an action to the list; you can directly access
- the action member, but add will validate that the added object
- is an action.
-
- """
-
- def __init__(self, actions=None):
- if actions == None:
- actions = []
- self.actions = actions
-
- def pack(self):
- """
- Pack a list of actions
-
- Returns the packed string
- """
-
- packed = ""
- for act in self.actions:
- packed += act.pack()
- return packed
-
- def unpack(self, binary_string, bytes=None):
- """
- Unpack a list of actions
-
- Unpack actions from a binary string, creating an array
- of objects of the appropriate type
-
- @param binary_string The string to be unpacked
-
- @param bytes The total length of the action list in bytes.
- Ignored if decode is True. If None and decode is false, the
- list is assumed to extend through the entire string.
-
- @return The remainder of binary_string that was not parsed
-
- """
- if bytes == None:
- bytes = len(binary_string)
- bytes_done = 0
- count = 0
- cur_string = binary_string
- while bytes_done < bytes:
- hdr = ofp_action_header()
- hdr.unpack(cur_string)
- if hdr.len < OFP_ACTION_HEADER_BYTES:
- print "ERROR: Action too short"
- break
- if not hdr.type in action_object_map.keys():
- print "WARNING: Skipping unknown action ", hdr.type, hdr.len
- else:
- self.actions.append(action_object_map[hdr.type]())
- self.actions[count].unpack(cur_string)
- count += 1
- cur_string = cur_string[hdr.len:]
- bytes_done += hdr.len
- return cur_string
-
- def append(self, action):
- """
- Append an action to an action list
-
- @param action The action to append
-
- """
- 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 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 __iter__(self):
- return self.actions.__iter__()
-
- 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)
diff --git a/src/python/of10/class_maps.py b/src/python/of10/class_maps.py
deleted file mode 100644
index b638eec..0000000
--- a/src/python/of10/class_maps.py
+++ /dev/null
@@ -1,311 +0,0 @@
-
-# Class to array member map
-class_to_members_map = {
- 'ofp_phy_port' : [
- 'port_no',
- 'hw_addr',
- 'name',
- 'config',
- 'state',
- 'curr',
- 'advertised',
- 'supported',
- 'peer'
- ],
- 'ofp_aggregate_stats_reply' : [
- 'packet_count',
- 'byte_count',
- 'flow_count'
- ],
- 'ofp_table_stats' : [
- 'table_id',
- 'name',
- 'wildcards',
- 'max_entries',
- 'active_count',
- 'lookup_count',
- 'matched_count'
- ],
- 'ofp_flow_removed' : [
- 'version',
- 'type',
- 'length',
- 'xid',
- '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' : [
- 'version',
- 'type',
- 'length',
- 'xid',
- 'stats_type',
- 'flags'
- ],
- 'ofp_hello' : [
- 'version',
- 'type',
- 'length',
- 'xid'
- ],
- 'ofp_aggregate_stats_request' : [
- 'match',
- 'table_id',
- 'out_port'
- ],
- 'ofp_port_status' : [
- 'version',
- 'type',
- 'length',
- 'xid',
- 'reason',
- 'desc'
- ],
- 'ofp_action_header' : [
- 'type',
- 'len'
- ],
- 'ofp_port_mod' : [
- 'version',
- 'type',
- 'length',
- 'xid',
- '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' : [
- 'version',
- 'type',
- 'length',
- 'xid',
- 'flags',
- 'miss_send_len'
- ],
- 'ofp_action_nw_tos' : [
- 'type',
- 'len',
- 'nw_tos'
- ],
- 'ofp_queue_get_config_reply' : [
- 'version',
- 'type',
- 'length',
- 'xid',
- 'port'
- ],
- 'ofp_packet_in' : [
- 'version',
- 'type',
- 'length',
- 'xid',
- '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' : [
- 'version',
- 'type',
- 'length',
- 'xid',
- 'stats_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' : [
- 'version',
- 'type',
- 'length',
- 'xid',
- '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' : [
- 'version',
- 'type',
- 'length',
- 'xid',
- 'datapath_id',
- 'n_buffers',
- 'n_tables',
- 'capabilities',
- 'actions'
- ],
- 'ofp_match' : [
- 'wildcards',
- 'in_port',
- 'eth_src',
- 'eth_dst',
- 'vlan_vid',
- 'vlan_pcp',
- 'eth_type',
- 'ip_dscp',
- 'ip_proto',
- 'ipv4_src',
- 'ipv4_dst',
- 'tcp_src',
- 'tcp_dst'
- ],
- 'ofp_header' : [
- 'version',
- 'type',
- 'length',
- 'xid'
- ],
- 'ofp_vendor_header' : [
- 'version',
- 'type',
- 'length',
- 'xid',
- 'vendor'
- ],
- 'ofp_packet_out' : [
- 'version',
- 'type',
- 'length',
- 'xid',
- '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' : [
- 'version',
- 'type',
- 'length',
- 'xid',
- 'match',
- 'cookie',
- 'command',
- 'idle_timeout',
- 'hard_timeout',
- 'priority',
- 'buffer_id',
- 'out_port',
- 'flags'
- ],
- 'ofp_error_msg' : [
- 'version',
- 'type',
- 'length',
- 'xid',
- 'err_type',
- 'code'
- ],
- '_ignore' : []
-}
diff --git a/src/python/of10/cstruct.py b/src/python/of10/cstruct.py
deleted file mode 100644
index ede9b31..0000000
--- a/src/python/of10/cstruct.py
+++ /dev/null
@@ -1,4216 +0,0 @@
-import struct
-
-# Structure definitions
-class ofp_phy_port:
- """Automatically generated Python class for ofp_phy_port
-
- Date 2013-03-11
- 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-03-11
- 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-03-11
- 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-03-11
- 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 = 0
- self.type = 0
- self.length = 0
- self.xid = 0
- 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 += struct.pack("!BBHL", self.version, self.type, self.length, self.xid)
- 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) < 88):
- 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])
- self.match.unpack(binaryString[8:])
- fmt = '!QHBBLLH'
- start = 48
- 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 = 70
- end = start + struct.calcsize(fmt)
- (self.pad2[0], self.pad2[1]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!QQ'
- start = 72
- end = start + struct.calcsize(fmt)
- (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.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
- 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 + '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'
- 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-03-11
- 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-03-11
- 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-03-11
- 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-03-11
- 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-03-11
- 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 = 0
- self.type = 0
- self.length = 0
- self.xid = 0
- self.stats_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("!BBHLHH", self.version, self.type, self.length, self.xid, self.stats_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) < 12):
- return binaryString
- fmt = '!BBHLHH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.version, self.type, self.length, self.xid, self.stats_type, self.flags) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[12:]
-
- def __len__(self):
- """Return length of message
- """
- l = 12
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.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
- if self.stats_type != other.stats_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 + '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'
- outstr += prefix + 'stats_type: ' + str(self.stats_type) + '\n'
- outstr += prefix + 'flags: ' + str(self.flags) + '\n'
- return outstr
-
-
-class ofp_hello:
- """Automatically generated Python class for ofp_hello
-
- Date 2013-03-11
- 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 = 0
- self.type = 0
- self.length = 0
- self.xid = 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("!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_aggregate_stats_request:
- """Automatically generated Python class for ofp_aggregate_stats_request
-
- Date 2013-03-11
- 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-03-11
- 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 = 0
- self.type = 0
- self.length = 0
- self.xid = 0
- 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("!BBHLB", self.version, self.type, self.length, self.xid, 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) < 64):
- return binaryString
- fmt = '!BBHLB'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.version, self.type, self.length, self.xid, self.reason) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBBBBB'
- start = 9
- 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[16:])
- 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.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
- 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 + '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'
- 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-03-11
- 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-03-11
- 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 = 0
- self.type = 0
- self.length = 0
- self.xid = 0
- 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("!BBHLH", self.version, self.type, self.length, self.xid, 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) < 32):
- return binaryString
- fmt = '!BBHLH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.version, self.type, self.length, self.xid, self.port_no) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBBBB'
- start = 10
- 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 = 16
- end = start + struct.calcsize(fmt)
- (self.config, self.mask, self.advertise) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBB'
- start = 28
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2], self.pad[3]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[32:]
-
- def __len__(self):
- """Return length of message
- """
- l = 32
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.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
- 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 + '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'
- 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-03-11
- 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-03-11
- 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-03-11
- 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 = 0
- self.type = 0
- self.length = 0
- self.xid = 0
- 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("!BBHLHH", self.version, self.type, self.length, self.xid, 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) < 12):
- return binaryString
- fmt = '!BBHLHH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.version, self.type, self.length, self.xid, self.flags, self.miss_send_len) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[12:]
-
- def __len__(self):
- """Return length of message
- """
- l = 12
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.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
- 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 + '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'
- 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-03-11
- 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-03-11
- 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 = 0
- self.type = 0
- self.length = 0
- self.xid = 0
- 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("!BBHLH", self.version, self.type, self.length, self.xid, 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) < 16):
- return binaryString
- fmt = '!BBHLH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.version, self.type, self.length, self.xid, self.port) = 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.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
- 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 + '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'
- outstr += prefix + 'port: ' + str(self.port) + '\n'
- return outstr
-
-
-class ofp_packet_in:
- """Automatically generated Python class for ofp_packet_in
-
- Date 2013-03-11
- 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 = 0
- self.type = 0
- self.length = 0
- self.xid = 0
- 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("!BBHLLHHBB", self.version, self.type, self.length, self.xid, 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) < 18):
- return binaryString
- fmt = '!BBHLLHHBB'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.version, self.type, self.length, self.xid, self.buffer_id, self.total_len, self.in_port, self.reason, self.pad) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[18:]
-
- def __len__(self):
- """Return length of message
- """
- l = 18
- 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
- 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 + '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'
- 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-03-11
- 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-03-11
- 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-03-11
- 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-03-11
- 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 = 0
- self.type = 0
- self.length = 0
- self.xid = 0
- self.stats_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("!BBHLHH", self.version, self.type, self.length, self.xid, self.stats_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) < 12):
- return binaryString
- fmt = '!BBHLHH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.version, self.type, self.length, self.xid, self.stats_type, self.flags) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[12:]
-
- def __len__(self):
- """Return length of message
- """
- l = 12
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.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
- if self.stats_type != other.stats_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 + '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'
- outstr += prefix + 'stats_type: ' + str(self.stats_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-03-11
- 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-03-11
- 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-03-11
- 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 = 0
- self.type = 0
- self.length = 0
- self.xid = 0
- 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("!BBHLH", self.version, self.type, self.length, self.xid, 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) < 12):
- return binaryString
- fmt = '!BBHLH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.version, self.type, self.length, self.xid, self.port) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BB'
- start = 10
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1]) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[12:]
-
- def __len__(self):
- """Return length of message
- """
- l = 12
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.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
- 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 + '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'
- outstr += prefix + 'port: ' + str(self.port) + '\n'
- return outstr
-
-
-class ofp_packet_queue:
- """Automatically generated Python class for ofp_packet_queue
-
- Date 2013-03-11
- 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-03-11
- 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-03-11
- 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-03-11
- 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-03-11
- 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-03-11
- 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 = 0
- self.type = 0
- self.length = 0
- self.xid = 0
- 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("!BBHLQLB", self.version, self.type, self.length, self.xid, 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) < 32):
- return binaryString
- fmt = '!BBHLQLB'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.version, self.type, self.length, self.xid, self.datapath_id, self.n_buffers, self.n_tables) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBB'
- start = 21
- end = start + struct.calcsize(fmt)
- (self.pad[0], self.pad[1], self.pad[2]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!LL'
- start = 24
- end = start + struct.calcsize(fmt)
- (self.capabilities, self.actions) = 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.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
- 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 + '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'
- 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-03-11
- 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.eth_src= [0,0,0,0,0,0]
- self.eth_dst= [0,0,0,0,0,0]
- self.vlan_vid = 0
- self.vlan_pcp = 0
- self.pad1 = 0
- self.eth_type = 0
- self.ip_dscp = 0
- self.ip_proto = 0
- self.pad2= [0,0]
- self.ipv4_src = 0
- self.ipv4_dst = 0
- self.tcp_src = 0
- self.tcp_dst = 0
-
- def __assert(self):
- """Sanity check
- """
- if(not isinstance(self.eth_src, list)):
- return (False, "self.eth_src is not list as expected.")
- if(len(self.eth_src) != 6):
- return (False, "self.eth_src is not of size 6 as expected.")
- if(not isinstance(self.eth_dst, list)):
- return (False, "self.eth_dst is not list as expected.")
- if(len(self.eth_dst) != 6):
- return (False, "self.eth_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.eth_src[0], self.eth_src[1], self.eth_src[2], self.eth_src[3], self.eth_src[4], self.eth_src[5])
- packed += struct.pack("!BBBBBB", self.eth_dst[0], self.eth_dst[1], self.eth_dst[2], self.eth_dst[3], self.eth_dst[4], self.eth_dst[5])
- packed += struct.pack("!HBBHBB", self.vlan_vid, self.vlan_pcp, self.pad1, self.eth_type, self.ip_dscp, self.ip_proto)
- packed += struct.pack("!BB", self.pad2[0], self.pad2[1])
- packed += struct.pack("!LLHH", self.ipv4_src, self.ipv4_dst, self.tcp_src, self.tcp_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.eth_src[0], self.eth_src[1], self.eth_src[2], self.eth_src[3], self.eth_src[4], self.eth_src[5]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!BBBBBB'
- start = 12
- end = start + struct.calcsize(fmt)
- (self.eth_dst[0], self.eth_dst[1], self.eth_dst[2], self.eth_dst[3], self.eth_dst[4], self.eth_dst[5]) = struct.unpack(fmt, binaryString[start:end])
- fmt = '!HBBHBB'
- start = 18
- end = start + struct.calcsize(fmt)
- (self.vlan_vid, self.vlan_pcp, self.pad1, self.eth_type, self.ip_dscp, self.ip_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.ipv4_src, self.ipv4_dst, self.tcp_src, self.tcp_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.eth_src != other.eth_src: return False
- if self.eth_dst != other.eth_dst: return False
- if self.vlan_vid != other.vlan_vid: return False
- if self.vlan_pcp != other.vlan_pcp: return False
- if self.pad1 != other.pad1: return False
- if self.eth_type != other.eth_type: return False
- if self.ip_dscp != other.ip_dscp: return False
- if self.ip_proto != other.ip_proto: return False
- if self.pad2 != other.pad2: return False
- if self.ipv4_src != other.ipv4_src: return False
- if self.ipv4_dst != other.ipv4_dst: return False
- if self.tcp_src != other.tcp_src: return False
- if self.tcp_dst != other.tcp_dst: return False
- return True
-
- def __ne__(self, other): return not self.__eq__(other)
-
- def show(self, 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 + 'eth_src: ' + str(self.eth_src) + '\n'
- outstr += prefix + 'eth_dst: ' + str(self.eth_dst) + '\n'
- outstr += prefix + 'vlan_vid: ' + str(self.vlan_vid) + '\n'
- outstr += prefix + 'vlan_pcp: ' + str(self.vlan_pcp) + '\n'
- outstr += prefix + 'eth_type: ' + str(self.eth_type) + '\n'
- outstr += prefix + 'ip_dscp: ' + str(self.ip_dscp) + '\n'
- outstr += prefix + 'ip_proto: ' + str(self.ip_proto) + '\n'
- outstr += prefix + 'ipv4_src: ' + str(self.ipv4_src) + '\n'
- outstr += prefix + 'ipv4_dst: ' + str(self.ipv4_dst) + '\n'
- outstr += prefix + 'tcp_src: ' + str(self.tcp_src) + '\n'
- outstr += prefix + 'tcp_dst: ' + str(self.tcp_dst) + '\n'
- return outstr
-
-
-class ofp_header:
- """Automatically generated Python class for ofp_header
-
- Date 2013-03-11
- 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-03-11
- 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 = 0
- self.type = 0
- self.length = 0
- self.xid = 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("!BBHLL", self.version, self.type, self.length, self.xid, 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) < 12):
- return binaryString
- fmt = '!BBHLL'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.version, self.type, self.length, self.xid, self.vendor) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[12:]
-
- def __len__(self):
- """Return length of message
- """
- l = 12
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.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
- 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 + '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'
- outstr += prefix + 'vendor: ' + str(self.vendor) + '\n'
- return outstr
-
-
-class ofp_packet_out:
- """Automatically generated Python class for ofp_packet_out
-
- Date 2013-03-11
- 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 = 0
- self.type = 0
- self.length = 0
- self.xid = 0
- 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("!BBHLLHH", self.version, self.type, self.length, self.xid, 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) < 16):
- return binaryString
- fmt = '!BBHLLHH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.version, self.type, self.length, self.xid, self.buffer_id, self.in_port, self.actions_len) = 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.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
- 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 + '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'
- 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-03-11
- 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-03-11
- 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-03-11
- 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 = 0
- self.type = 0
- self.length = 0
- self.xid = 0
- 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 += struct.pack("!BBHL", self.version, self.type, self.length, self.xid)
- 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) < 72):
- 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])
- self.match.unpack(binaryString[8:])
- fmt = '!QHHHHLHH'
- start = 48
- 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[72:]
-
- def __len__(self):
- """Return length of message
- """
- l = 72
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.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
- 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 + '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'
- 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-03-11
- 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 = 0
- self.type = 0
- self.length = 0
- self.xid = 0
- self.err_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("!BBHLHH", self.version, self.type, self.length, self.xid, self.err_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) < 12):
- return binaryString
- fmt = '!BBHLHH'
- start = 0
- end = start + struct.calcsize(fmt)
- (self.version, self.type, self.length, self.xid, self.err_type, self.code) = struct.unpack(fmt, binaryString[start:end])
- return binaryString[12:]
-
- def __len__(self):
- """Return length of message
- """
- l = 12
- return l
-
- def __eq__(self, other):
- """Return True if self and other have same values
- """
- if type(self) != type(other): return False
- if self.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
- if self.err_type != other.err_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 + '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'
- outstr += prefix + 'err_type: ' + str(self.err_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 = 12
-OFP_FLOW_MOD_BYTES = 72
-OFP_FLOW_REMOVED_BYTES = 88
-OFP_FLOW_STATS_BYTES = 88
-OFP_FLOW_STATS_REQUEST_BYTES = 44
-OFP_HEADER_BYTES = 8
-OFP_HELLO_BYTES = 8
-OFP_MATCH_BYTES = 40
-OFP_PACKET_IN_BYTES = 18
-OFP_PACKET_OUT_BYTES = 16
-OFP_PACKET_QUEUE_BYTES = 8
-OFP_PHY_PORT_BYTES = 48
-OFP_PORT_MOD_BYTES = 32
-OFP_PORT_STATS_BYTES = 104
-OFP_PORT_STATS_REQUEST_BYTES = 8
-OFP_PORT_STATUS_BYTES = 64
-OFP_QUEUE_GET_CONFIG_REPLY_BYTES = 16
-OFP_QUEUE_GET_CONFIG_REQUEST_BYTES = 12
-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 = 12
-OFP_STATS_REQUEST_BYTES = 12
-OFP_SWITCH_CONFIG_BYTES = 12
-OFP_SWITCH_FEATURES_BYTES = 32
-OFP_TABLE_STATS_BYTES = 64
-OFP_VENDOR_HEADER_BYTES = 12
-
diff --git a/src/python/of10/error.py b/src/python/of10/error.py
deleted file mode 100644
index f545bc5..0000000
--- a/src/python/of10/error.py
+++ /dev/null
@@ -1,294 +0,0 @@
-
-# Python OpenFlow error wrapper classes
-
-from cstruct import *
-
-
-
-class hello_failed_error_msg(ofp_error_msg):
- """
- Wrapper class for hello_failed error message class
-
- Data members inherited from ofp_error_msg:
- @arg type
- @arg code
- @arg data: Binary string following message members
-
- """
- def __init__(self):
- ofp_error_msg.__init__(self)
- self.version = OFP_VERSION
- self.type = OFPT_ERROR
- self.xid = None
- self.err_type = OFPET_HELLO_FAILED
- self.data = ""
-
- def pack(self, assertstruct=True):
- self.header.length = self.__len__()
- packed = ""
- packed += ofp_error_msg.pack(self)
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- binary_string = ofp_error_msg.unpack(self, binary_string)
- self.data = binary_string
- return ""
-
- def __len__(self):
- return OFP_ERROR_MSG_BYTES + len(self.data)
-
- def show(self, prefix=''):
- outstr = prefix + "hello_failed_error_msg\m"
- 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 (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.version = OFP_VERSION
- self.type = OFPT_ERROR
- self.xid = None
- self.err_type = OFPET_BAD_REQUEST
- self.data = ""
-
- def pack(self, assertstruct=True):
- self.header.length = self.__len__()
- packed = ""
- packed += ofp_error_msg.pack(self)
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- binary_string = ofp_error_msg.unpack(self, binary_string)
- self.data = binary_string
- return ""
-
- def __len__(self):
- return OFP_ERROR_MSG_BYTES + len(self.data)
-
- def show(self, prefix=''):
- outstr = prefix + "bad_request_error_msg\m"
- 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 (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.version = OFP_VERSION
- self.type = OFPT_ERROR
- self.xid = None
- self.err_type = OFPET_BAD_ACTION
- self.data = ""
-
- def pack(self, assertstruct=True):
- self.header.length = self.__len__()
- packed = ""
- packed += ofp_error_msg.pack(self)
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- binary_string = ofp_error_msg.unpack(self, binary_string)
- self.data = binary_string
- return ""
-
- def __len__(self):
- return OFP_ERROR_MSG_BYTES + len(self.data)
-
- def show(self, prefix=''):
- outstr = prefix + "bad_action_error_msg\m"
- 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 (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.version = OFP_VERSION
- self.type = OFPT_ERROR
- self.xid = None
- self.err_type = OFPET_FLOW_MOD_FAILED
- self.data = ""
-
- def pack(self, assertstruct=True):
- self.header.length = self.__len__()
- packed = ""
- packed += ofp_error_msg.pack(self)
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- binary_string = ofp_error_msg.unpack(self, binary_string)
- self.data = binary_string
- return ""
-
- def __len__(self):
- return OFP_ERROR_MSG_BYTES + len(self.data)
-
- def show(self, prefix=''):
- outstr = prefix + "flow_mod_failed_error_msg\m"
- 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 (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.version = OFP_VERSION
- self.type = OFPT_ERROR
- self.xid = None
- self.err_type = OFPET_PORT_MOD_FAILED
- self.data = ""
-
- def pack(self, assertstruct=True):
- self.header.length = self.__len__()
- packed = ""
- packed += ofp_error_msg.pack(self)
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- binary_string = ofp_error_msg.unpack(self, binary_string)
- self.data = binary_string
- return ""
-
- def __len__(self):
- return OFP_ERROR_MSG_BYTES + len(self.data)
-
- def show(self, prefix=''):
- outstr = prefix + "port_mod_failed_error_msg\m"
- 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 (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.version = OFP_VERSION
- self.type = OFPT_ERROR
- self.xid = None
- self.err_type = OFPET_QUEUE_OP_FAILED
- self.data = ""
-
- def pack(self, assertstruct=True):
- self.header.length = self.__len__()
- packed = ""
- packed += ofp_error_msg.pack(self)
- packed += self.data
- return packed
-
- def unpack(self, binary_string):
- binary_string = ofp_error_msg.unpack(self, binary_string)
- self.data = binary_string
- return ""
-
- def __len__(self):
- return OFP_ERROR_MSG_BYTES + len(self.data)
-
- def show(self, prefix=''):
- outstr = prefix + "queue_op_failed_error_msg\m"
- 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 (ofp_error_msg.__eq__(self, other) and
- self.data == other.data)
-
- def __ne__(self, other): return not self.__eq__(other)
-
diff --git a/src/python/of10/message.py b/src/python/of10/message.py
deleted file mode 100644
index 889bbdf..0000000
--- a/src/python/of10/message.py
+++ /dev/null
@@ -1,3611 +0,0 @@
-
-# Python OpenFlow message wrapper classes
-
-import logging
-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
-
- """
- # 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)
- # For a real message, will be set to an integer
- self.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(ofp_header):
- """
- 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)
-
- Data members inherited from ofp_header:
- @arg version
- @arg type
- @arg length
- @arg xid
-
- """
-
- def __init__(self, **kwargs):
- ofp_header.__init__(self)
- self.version = OFP_VERSION
- self.type = OFPT_BARRIER_REPLY
- self.xid = None
- 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.length = len(self)
- packed = ""
-
- packed += ofp_header.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 = ofp_header.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 = 0
-
- length += ofp_header.__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 + 'barrier_reply (OFPT_BARRIER_REPLY)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += ofp_header.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 ofp_header.__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 barrier_request(ofp_header):
- """
- 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)
-
- Data members inherited from ofp_header:
- @arg version
- @arg type
- @arg length
- @arg xid
-
- """
-
- def __init__(self, **kwargs):
- ofp_header.__init__(self)
- self.version = OFP_VERSION
- self.type = OFPT_BARRIER_REQUEST
- self.xid = None
- 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.length = len(self)
- packed = ""
-
- packed += ofp_header.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 = ofp_header.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 = 0
-
- length += ofp_header.__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 + 'barrier_request (OFPT_BARRIER_REQUEST)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += ofp_header.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 ofp_header.__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 echo_reply(ofp_header):
- """
- 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)
-
- Data members inherited from ofp_header:
- @arg version
- @arg type
- @arg length
- @arg xid
- @arg data: Binary string following message members
-
- """
-
- def __init__(self, **kwargs):
- ofp_header.__init__(self)
- self.version = OFP_VERSION
- self.type = OFPT_ECHO_REPLY
- self.xid = None
- 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.length = len(self)
- packed = ""
-
- packed += ofp_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 = ofp_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 = 0
-
- length += ofp_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 + 'echo_reply (OFPT_ECHO_REPLY)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += ofp_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 ofp_header.__eq__(self, other): return False
- if self.data != other.data: return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class echo_request(ofp_header):
- """
- 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)
-
- Data members inherited from ofp_header:
- @arg version
- @arg type
- @arg length
- @arg xid
- @arg data: Binary string following message members
-
- """
-
- def __init__(self, **kwargs):
- ofp_header.__init__(self)
- self.version = OFP_VERSION
- self.type = OFPT_ECHO_REQUEST
- self.xid = None
- 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.length = len(self)
- packed = ""
-
- packed += ofp_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 = ofp_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 = 0
-
- length += ofp_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 + 'echo_request (OFPT_ECHO_REQUEST)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += ofp_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 ofp_header.__eq__(self, other): return False
- if self.data != other.data: return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class 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 version
- @arg type
- @arg length
- @arg xid
- @arg err_type
- @arg code
- @arg data: Binary string following message members
-
- """
-
- def __init__(self, **kwargs):
- ofp_error_msg.__init__(self)
- self.version = OFP_VERSION
- self.type = OFPT_ERROR
- self.xid = None
- 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.length = len(self)
- packed = ""
-
- 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 = 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 = 0
-
- 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 += 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 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 version
- @arg type
- @arg length
- @arg xid
- @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.version = OFP_VERSION
- self.type = OFPT_FEATURES_REPLY
- self.xid = None
- 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.length = len(self)
- packed = ""
-
- 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 = 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 = 0
-
- 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 += 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 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(ofp_header):
- """
- 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)
-
- Data members inherited from ofp_header:
- @arg version
- @arg type
- @arg length
- @arg xid
-
- """
-
- def __init__(self, **kwargs):
- ofp_header.__init__(self)
- self.version = OFP_VERSION
- self.type = OFPT_FEATURES_REQUEST
- self.xid = None
- 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.length = len(self)
- packed = ""
-
- packed += ofp_header.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 = ofp_header.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 = 0
-
- length += ofp_header.__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 + 'features_request (OFPT_FEATURES_REQUEST)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += ofp_header.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 ofp_header.__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 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 version
- @arg type
- @arg length
- @arg xid
- @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.version = OFP_VERSION
- self.type = OFPT_FLOW_MOD
- self.xid = None
- 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__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.length = len(self)
- packed = ""
-
- packed += ofp_flow_mod.pack(self)
- packed += action_list(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 = ofp_flow_mod.unpack(self, binary_string)
- ai_len = self.length - (OFP_FLOW_MOD_BYTES + OFP_HEADER_BYTES)
- obj = action_list()
- binary_string = obj.unpack(binary_string, bytes=ai_len)
- self.actions = list(obj)
- # 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 = 0
-
- length += ofp_flow_mod.__len__(self)
- for obj in self.actions:
- 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 + 'flow_mod (OFPT_FLOW_MOD)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += ofp_flow_mod.show(self, prefix)
- outstr += prefix + "List actions\n"
- for obj in self.actions:
- 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 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 version
- @arg type
- @arg length
- @arg xid
- @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.version = OFP_VERSION
- self.type = OFPT_FLOW_REMOVED
- self.xid = None
- 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.length = len(self)
- packed = ""
-
- 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 = 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 = 0
-
- 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 += 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 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 version
- @arg type
- @arg length
- @arg xid
- @arg flags
- @arg miss_send_len
-
- """
-
- def __init__(self, **kwargs):
- ofp_switch_config.__init__(self)
- self.version = OFP_VERSION
- self.type = OFPT_GET_CONFIG_REPLY
- self.xid = None
- 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.length = len(self)
- packed = ""
-
- 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 = 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 = 0
-
- 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 += 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 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(ofp_header):
- """
- 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)
-
- Data members inherited from ofp_header:
- @arg version
- @arg type
- @arg length
- @arg xid
-
- """
-
- def __init__(self, **kwargs):
- ofp_header.__init__(self)
- self.version = OFP_VERSION
- self.type = OFPT_GET_CONFIG_REQUEST
- self.xid = None
- 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.length = len(self)
- packed = ""
-
- packed += ofp_header.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 = ofp_header.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 = 0
-
- length += ofp_header.__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_request (OFPT_GET_CONFIG_REQUEST)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += ofp_header.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 ofp_header.__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 hello(ofp_header):
- """
- 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)
-
- Data members inherited from ofp_header:
- @arg version
- @arg type
- @arg length
- @arg xid
- @arg data: Binary string following message members
-
- """
-
- def __init__(self, **kwargs):
- ofp_header.__init__(self)
- self.version = OFP_VERSION
- self.type = OFPT_HELLO
- self.xid = None
- 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.length = len(self)
- packed = ""
-
- packed += ofp_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 = ofp_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 = 0
-
- length += ofp_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 + 'hello (OFPT_HELLO)\n'
- prefix += ' '
- outstr += prefix + 'ofp header\n'
- outstr += ofp_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 ofp_header.__eq__(self, other): return False
- if self.data != other.data: return False
- return True
-
- def __ne__(self, other):
- """
- Return True if self and other do not hold the same data
-
- @param other Other object in comparison
-
- """
- return not self.__eq__(other)
-
-
-class 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 version
- @arg type
- @arg length
- @arg xid
- @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.version = OFP_VERSION
- self.type = OFPT_PACKET_IN
- self.xid = None
- 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.length = len(self)
- packed = ""
-
- 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 = 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 = 0
-
- 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 += 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 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 version
- @arg type
- @arg length
- @arg xid
- @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.version = OFP_VERSION
- self.type = OFPT_PACKET_OUT
- self.xid = None
- 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__))
-
-
- def pack(self):
- """
- Pack object into string
-
- @return The packed string which can go on the wire
-
- """
- self.length = len(self)
- packed = ""
-
- self.actions_len = 0
- for obj in self.actions:
- self.actions_len += len(obj)
- packed += ofp_packet_out.pack(self)
- packed += action_list(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 = ofp_packet_out.unpack(self, binary_string)
- obj = action_list()
- binary_string = obj.unpack(binary_string, bytes=self.actions_len)
- self.actions = list(obj)
- 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 = 0
-
- length += ofp_packet_out.__len__(self)
- for obj in self.actions:
- length += len(obj)
- 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 += ofp_packet_out.show(self, prefix)
- outstr += prefix + "List actions\n"
- for obj in self.actions:
- outstr += obj.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 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 version
- @arg type
- @arg length
- @arg xid
- @arg port_no
- @arg hw_addr
- @arg config
- @arg mask
- @arg advertise
-
- """
-
- def __init__(self, **kwargs):
- ofp_port_mod.__init__(self)
- self.version = OFP_VERSION
- self.type = OFPT_PORT_MOD
- self.xid = None
- 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.length = len(self)
- packed = ""
-
- 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 = 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 = 0
-
- 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 += 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 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 version
- @arg type
- @arg length
- @arg xid
- @arg reason
- @arg desc
-
- """
-
- def __init__(self, **kwargs):
- ofp_port_status.__init__(self)
- self.version = OFP_VERSION
- self.type = OFPT_PORT_STATUS
- self.xid = None
- 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.length = len(self)
- packed = ""
-
- 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 = 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 = 0
-
- 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 += 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 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 version
- @arg type
- @arg length
- @arg xid
- @arg port
- @arg queues: Variable length array of TBD
-
- """
-
- def __init__(self, **kwargs):
- ofp_queue_get_config_reply.__init__(self)
- self.version = OFP_VERSION
- self.type = OFPT_QUEUE_GET_CONFIG_REPLY
- self.xid = None
- 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.length = len(self)
- packed = ""
-
- 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 = 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 = 0
-
- 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 += 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 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 version
- @arg type
- @arg length
- @arg xid
- @arg port
-
- """
-
- def __init__(self, **kwargs):
- ofp_queue_get_config_request.__init__(self)
- self.version = OFP_VERSION
- self.type = OFPT_QUEUE_GET_CONFIG_REQUEST
- self.xid = None
- 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.length = len(self)
- packed = ""
-
- 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 = 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 = 0
-
- 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 += 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 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 version
- @arg type
- @arg length
- @arg xid
- @arg flags
- @arg miss_send_len
-
- """
-
- def __init__(self, **kwargs):
- ofp_switch_config.__init__(self)
- self.version = OFP_VERSION
- self.type = OFPT_SET_CONFIG
- self.xid = None
- 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.length = len(self)
- packed = ""
-
- 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 = 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 = 0
-
- 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 += 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 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 version
- @arg type
- @arg length
- @arg xid
- @arg stats_type
- @arg flags
-
- """
-
- def __init__(self, **kwargs):
- ofp_stats_reply.__init__(self)
- self.version = OFP_VERSION
- self.type = OFPT_STATS_REPLY
- self.xid = None
- 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.length = len(self)
- packed = ""
-
- 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 = 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 = 0
-
- 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 += 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 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 version
- @arg type
- @arg length
- @arg xid
- @arg stats_type
- @arg flags
-
- """
-
- def __init__(self, **kwargs):
- ofp_stats_request.__init__(self)
- self.version = OFP_VERSION
- self.type = OFPT_STATS_REQUEST
- self.xid = None
- 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.length = len(self)
- packed = ""
-
- 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 = 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 = 0
-
- 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 += 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 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 version
- @arg type
- @arg length
- @arg xid
- @arg vendor
- @arg data: Binary string following message members
-
- """
-
- def __init__(self, **kwargs):
- ofp_vendor_header.__init__(self)
- self.version = OFP_VERSION
- self.type = OFPT_VENDOR
- self.xid = None
- 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.length = len(self)
- packed = ""
-
- 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 = 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 = 0
-
- 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 += 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 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 = []
-
- def pack(self, assertstruct=True):
- self.length = len(self)
- packed = ofp_flow_stats.pack(self, assertstruct)
- packed += action_list(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)
- obj = action_list()
- binary_string = obj.unpack(binary_string, bytes=ai_len)
- self.actions = list(obj)
- 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 += prefix + "List actions\n"
- for obj in self.actions:
- outstr += obj.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):
- ofp_stats_request.__init__(self)
- ofp_aggregate_stats_request.__init__(self)
- self.version = OFP_VERSION
- self.type = OFPT_STATS_REQUEST
- self.xid = None
- self.stats_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.length = len(self)
- packed = ""
- packed += ofp_stats_request.pack(self)
- packed += ofp_aggregate_stats_request.pack(self)
- return packed
-
- def unpack(self, 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 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 += 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 (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):
- ofp_stats_reply.__init__(self)
- self.version = OFP_VERSION
- self.type = OFPT_STATS_REPLY
- self.xid = None
- self.stats_type = OFPST_AGGREGATE
- # stats: Array of type aggregate_stats_entry
- self.entries = []
-
- def pack(self, assertstruct=True):
- self.length = len(self)
- packed = ""
- packed += ofp_stats_reply.pack(self)
- for obj in self.entries:
- packed += obj.pack()
- return packed
-
- def unpack(self, 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.entries.append(obj)
- if len(binary_string) != 0:
- print "ERROR unpacking aggregate stats string: extra bytes"
- return binary_string
-
- def __len__(self):
- length = OFP_STATS_REPLY_BYTES
- for obj in self.entries:
- length += len(obj)
- return length
-
- def show(self, prefix=''):
- outstr = prefix + "aggregate_stats_reply\n"
- outstr += prefix + "ofp header:\n"
- outstr += ofp_stats_reply.show(self)
- outstr += prefix + "Stats array of length " + str(len(self.entries)) + '\n'
- for obj in self.entries:
- outstr += obj.show()
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (ofp_stats_reply.__eq__(self, other) and
- self.entries == other.entries)
-
- 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):
- ofp_stats_request.__init__(self)
- ofp_desc_stats_request.__init__(self)
- self.version = OFP_VERSION
- self.type = OFPT_STATS_REQUEST
- self.xid = None
- self.stats_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.length = len(self)
- packed = ""
- packed += ofp_stats_request.pack(self)
- packed += ofp_desc_stats_request.pack(self)
- return packed
-
- def unpack(self, 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 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 += 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 (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):
- ofp_stats_reply.__init__(self)
- self.version = OFP_VERSION
- self.type = OFPT_STATS_REPLY
- self.xid = None
- self.stats_type = OFPST_DESC
- # stats: Array of type desc_stats_entry
- self.entries = []
-
- def pack(self, assertstruct=True):
- self.length = len(self)
- packed = ""
- packed += ofp_stats_reply.pack(self)
- for obj in self.entries:
- packed += obj.pack()
- return packed
-
- def unpack(self, 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.entries.append(obj)
- if len(binary_string) != 0:
- print "ERROR unpacking desc stats string: extra bytes"
- return binary_string
-
- def __len__(self):
- length = OFP_STATS_REPLY_BYTES
- for obj in self.entries:
- length += len(obj)
- return length
-
- def show(self, prefix=''):
- outstr = prefix + "desc_stats_reply\n"
- outstr += prefix + "ofp header:\n"
- outstr += ofp_stats_reply.show(self)
- outstr += prefix + "Stats array of length " + str(len(self.entries)) + '\n'
- for obj in self.entries:
- outstr += obj.show()
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (ofp_stats_reply.__eq__(self, other) and
- self.entries == other.entries)
-
- 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):
- ofp_stats_request.__init__(self)
- ofp_flow_stats_request.__init__(self)
- self.version = OFP_VERSION
- self.type = OFPT_STATS_REQUEST
- self.xid = None
- self.stats_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.length = len(self)
- packed = ""
- packed += ofp_stats_request.pack(self)
- packed += ofp_flow_stats_request.pack(self)
- return packed
-
- def unpack(self, 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 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 += 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 (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):
- ofp_stats_reply.__init__(self)
- self.version = OFP_VERSION
- self.type = OFPT_STATS_REPLY
- self.xid = None
- self.stats_type = OFPST_FLOW
- # stats: Array of type flow_stats_entry
- self.entries = []
-
- def pack(self, assertstruct=True):
- self.length = len(self)
- packed = ""
- packed += ofp_stats_reply.pack(self)
- for obj in self.entries:
- packed += obj.pack()
- return packed
-
- def unpack(self, 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.entries.append(obj)
- if len(binary_string) != 0:
- print "ERROR unpacking flow stats string: extra bytes"
- return binary_string
-
- def __len__(self):
- length = OFP_STATS_REPLY_BYTES
- for obj in self.entries:
- length += len(obj)
- return length
-
- def show(self, prefix=''):
- outstr = prefix + "flow_stats_reply\n"
- outstr += prefix + "ofp header:\n"
- outstr += ofp_stats_reply.show(self)
- outstr += prefix + "Stats array of length " + str(len(self.entries)) + '\n'
- for obj in self.entries:
- outstr += obj.show()
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (ofp_stats_reply.__eq__(self, other) and
- self.entries == other.entries)
-
- 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):
- ofp_stats_request.__init__(self)
- ofp_port_stats_request.__init__(self)
- self.version = OFP_VERSION
- self.type = OFPT_STATS_REQUEST
- self.xid = None
- self.stats_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.length = len(self)
- packed = ""
- packed += ofp_stats_request.pack(self)
- packed += ofp_port_stats_request.pack(self)
- return packed
-
- def unpack(self, 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 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 += 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 (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):
- ofp_stats_reply.__init__(self)
- self.version = OFP_VERSION
- self.type = OFPT_STATS_REPLY
- self.xid = None
- self.stats_type = OFPST_PORT
- # stats: Array of type port_stats_entry
- self.entries = []
-
- def pack(self, assertstruct=True):
- self.length = len(self)
- packed = ""
- packed += ofp_stats_reply.pack(self)
- for obj in self.entries:
- packed += obj.pack()
- return packed
-
- def unpack(self, 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.entries.append(obj)
- if len(binary_string) != 0:
- print "ERROR unpacking port stats string: extra bytes"
- return binary_string
-
- def __len__(self):
- length = OFP_STATS_REPLY_BYTES
- for obj in self.entries:
- length += len(obj)
- return length
-
- def show(self, prefix=''):
- outstr = prefix + "port_stats_reply\n"
- outstr += prefix + "ofp header:\n"
- outstr += ofp_stats_reply.show(self)
- outstr += prefix + "Stats array of length " + str(len(self.entries)) + '\n'
- for obj in self.entries:
- outstr += obj.show()
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (ofp_stats_reply.__eq__(self, other) and
- self.entries == other.entries)
-
- 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):
- ofp_stats_request.__init__(self)
- ofp_queue_stats_request.__init__(self)
- self.version = OFP_VERSION
- self.type = OFPT_STATS_REQUEST
- self.xid = None
- self.stats_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.length = len(self)
- packed = ""
- packed += ofp_stats_request.pack(self)
- packed += ofp_queue_stats_request.pack(self)
- return packed
-
- def unpack(self, 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 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 += 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 (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):
- ofp_stats_reply.__init__(self)
- self.version = OFP_VERSION
- self.type = OFPT_STATS_REPLY
- self.xid = None
- self.stats_type = OFPST_QUEUE
- # stats: Array of type queue_stats_entry
- self.entries = []
-
- def pack(self, assertstruct=True):
- self.length = len(self)
- packed = ""
- packed += ofp_stats_reply.pack(self)
- for obj in self.entries:
- packed += obj.pack()
- return packed
-
- def unpack(self, 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.entries.append(obj)
- if len(binary_string) != 0:
- print "ERROR unpacking queue stats string: extra bytes"
- return binary_string
-
- def __len__(self):
- length = OFP_STATS_REPLY_BYTES
- for obj in self.entries:
- length += len(obj)
- return length
-
- def show(self, prefix=''):
- outstr = prefix + "queue_stats_reply\n"
- outstr += prefix + "ofp header:\n"
- outstr += ofp_stats_reply.show(self)
- outstr += prefix + "Stats array of length " + str(len(self.entries)) + '\n'
- for obj in self.entries:
- outstr += obj.show()
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (ofp_stats_reply.__eq__(self, other) and
- self.entries == other.entries)
-
- 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):
- ofp_stats_request.__init__(self)
- ofp_table_stats_request.__init__(self)
- self.version = OFP_VERSION
- self.type = OFPT_STATS_REQUEST
- self.xid = None
- self.stats_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.length = len(self)
- packed = ""
- packed += ofp_stats_request.pack(self)
- packed += ofp_table_stats_request.pack(self)
- return packed
-
- def unpack(self, 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 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 += 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 (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):
- ofp_stats_reply.__init__(self)
- self.version = OFP_VERSION
- self.type = OFPT_STATS_REPLY
- self.xid = None
- self.stats_type = OFPST_TABLE
- # stats: Array of type table_stats_entry
- self.entries = []
-
- def pack(self, assertstruct=True):
- self.length = len(self)
- packed = ""
- packed += ofp_stats_reply.pack(self)
- for obj in self.entries:
- packed += obj.pack()
- return packed
-
- def unpack(self, 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.entries.append(obj)
- if len(binary_string) != 0:
- print "ERROR unpacking table stats string: extra bytes"
- return binary_string
-
- def __len__(self):
- length = OFP_STATS_REPLY_BYTES
- for obj in self.entries:
- length += len(obj)
- return length
-
- def show(self, prefix=''):
- outstr = prefix + "table_stats_reply\n"
- outstr += prefix + "ofp header:\n"
- outstr += ofp_stats_reply.show(self)
- outstr += prefix + "Stats array of length " + str(len(self.entries)) + '\n'
- for obj in self.entries:
- outstr += obj.show()
- return outstr
-
- def __eq__(self, other):
- if type(self) != type(other): return False
- return (ofp_stats_reply.__eq__(self, other) and
- self.entries == other.entries)
-
- 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
- )
-
-
-_flow_mod = flow_mod
-flow_mod = None
-
-class flow_add(_flow_mod):
- def __init__(self, **kwargs):
- _flow_mod.__init__(self, **kwargs)
- self.command = OFPFC_ADD
-
-class flow_modify(_flow_mod):
- def __init__(self, **kwargs):
- _flow_mod.__init__(self, **kwargs)
- self.command = OFPFC_MODIFY
-
-class flow_modify_strict(_flow_mod):
- def __init__(self, **kwargs):
- _flow_mod.__init__(self, **kwargs)
- self.command = OFPFC_MODIFY_STRICT
-
-class flow_delete(_flow_mod):
- def __init__(self, **kwargs):
- _flow_mod.__init__(self, **kwargs)
- self.command = OFPFC_DELETE
-
-class flow_delete_strict(_flow_mod):
- def __init__(self, **kwargs):
- _flow_mod.__init__(self, **kwargs)
- self.command = OFPFC_DELETE_STRICT
-
-# 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)
- logging.info(hdr.show())
- # 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)
- try:
- obj = stats_request_to_class_map[sub_hdr.stats_type]()
- except KeyError:
- obj = None
- return obj
- elif hdr.type == OFPT_STATS_REPLY:
- sub_hdr = ofp_stats_reply()
- sub_hdr.unpack(binary_string)
- try:
- obj = stats_reply_to_class_map[sub_hdr.stats_type]()
- except KeyError:
- obj = None
- return obj
- elif hdr.type == OFPT_ERROR:
- sub_hdr = ofp_error_msg()
- sub_hdr.unpack(binary_string)
- return error_to_class_map[sub_hdr.err_type]()
- else:
- logging.error("Cannot parse pkt to message")
- return None
-
-def parse_message(binary_string):
- """
- 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
-
- """
- obj = _of_message_to_object(binary_string)
- if obj:
- obj.unpack(binary_string)
- return obj
-
-
-def parse_header(binary_string):
- """
- 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
- @return Tuple of (verison, type, length, xid)
-
- """
- return struct.unpack_from("!BBHL", binary_string)
-
-