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)
-
-
