Repository: kytos/python-openflow

Issue:
Move all non-messages classes to other files
Some classes (structs) does not define messages, but only structures that will be used on messages (such as "desc_stats").

As defined, only "messages" will have a "file" (submodule) for itself.

No, the files that does not hold a message should have its content splitted into other files.

Discussion:

Patch:
diff --git a/pyof/v0x01/common/flow_match.py b/pyof/v0x01/common/flow_match.py
index a900b81..07d103e 100644
--- a/pyof/v0x01/common/flow_match.py
+++ b/pyof/v0x01/common/flow_match.py
@@ -1,6 +1,7 @@
 """Defines flow statistics structures and related items"""
 
 # System imports
+import enum
 
 # Third-party imports
 
@@ -8,7 +9,10 @@
 from pyof.v0x01.foundation import base
 from pyof.v0x01.foundation import basic_types
 
-class FlowWildCards(base.GenericBitMask):
+# Enums
+
+
+class FlowWildCards(enum.Enum):
     """
     Wildcards used to identify flows.
 
diff --git a/pyof/v0x01/common/phy_port.py b/pyof/v0x01/common/phy_port.py
index 7395fb6..b45777f 100644
--- a/pyof/v0x01/common/phy_port.py
+++ b/pyof/v0x01/common/phy_port.py
@@ -1,6 +1,7 @@
 """Defines physical port classes and related items"""
 
 # System imports
+import enum
 
 # Third-party imports
 
@@ -8,20 +9,9 @@
 from pyof.v0x01.foundation import base
 from pyof.v0x01.foundation import basic_types
 
+# Enums
+
 class PortConfig(base.GenericBitMask):
-    """Flags to indicate behavior of the physical port.
-
-    These flags are used in OFPPhyPort to describe the current configuration.
-    They are used in the OFPPortMod message to configure the port's behavior.
-
-        OFPPC_PORT_DOWN     # Port is administratively down.
-        OFPPC_NO_STP        # Disable 802.1D spanning tree on port.
-        OFPPC_NO_RECV       # Drop all packets except 802.1D spanning tree.
-        OFPPC_NO_RECV_STP   # Drop received 802.1D STP packets.
-        OFPPC_NO_FLOOD      # Do not include this port when flooding.
-        OFPPC_NO_FWD        # Drop packets forwarded to port.
-        OFPPC_NO_PACKET_IN  # Do not send packet-in msgs for port.
-    """
     OFPC_PORT_DOWN = 1 << 0
     OFPPC_NO_STP = 1 << 1
     OFPPC_NO_RECV = 1 << 2
@@ -31,9 +21,32 @@ class PortConfig(base.GenericBitMask):
     OFPPC_NO_PACKET_IN = 1 << 6
 
 
-
-
-class PortState(base.GenericBitMask):
+#class PortConfig(enum.Enum):
+#    """Flags to indicate behavior of the physical port.
+#
+#    These flags are used in OFPPhyPort to describe the current configuration.
+#    They are used in the OFPPortMod message to configure the port's behavior.
+#
+#    Enums:
+#        OFPPC_PORT_DOWN     # Port is administratively down.
+#        OFPPC_NO_STP        # Disable 802.1D spanning tree on port.
+#        OFPPC_NO_RECV       # Drop all packets except 802.1D spanning tree.
+#        OFPPC_NO_RECV_STP   # Drop received 802.1D STP packets.
+#        OFPPC_NO_FLOOD      # Do not include this port when flooding.
+#        OFPPC_NO_FWD        # Drop packets forwarded to port.
+#        OFPPC_NO_PACKET_IN  # Do not send packet-in msgs for port.
+#    """
+#
+#    OFPPC_PORT_DOWN = 1 << 0
+#    OFPPC_NO_STP = 1 << 1
+#    OFPPC_NO_RECV = 1 << 2
+#    OFPPC_NO_RECV_STP = 1 << 3
+#    OFPPC_FLOOD = 1 << 4
+#    OFPPC_NO_FWD = 1 << 5
+#    OFPPC_NO_PACKET_IN = 1 << 6
+
+
+class PortState(enum.Enum):
     """Current state of the physical port.
 
     These are not configurable from the controller.
@@ -42,6 +55,7 @@ class PortState(base.GenericBitMask):
     must adjust OFPPC_NO_RECV, OFPPC_NO_FWD, and OFPPC_NO_PACKET_IN
     appropriately to fully implement an 802.1D spanning tree.
 
+    Enums:
         OFPPS_LINK_DOWN    # Not learning or relaying frames.
         OFPPS_STP_LISTEN   # Not learning or relaying frames.
         OFPPS_STP_LEARN    # Learning but not relaying frames.
@@ -58,7 +72,7 @@ class PortState(base.GenericBitMask):
     # OFPPS_STP_MASK = 3 << 8  - Refer to ISSUE #7
 
 
-class Port(base.GenericBitMask):
+class Port(enum.Enum):
     """Port numbering.
 
     Physical ports are numbered starting from 1. Port number 0 is reserved by
@@ -87,13 +101,14 @@ class Port(base.GenericBitMask):
     OFPP_NONE = 0xffff
 
 
-class PortFeatures(base.GenericBitMask):
+class PortFeatures(enum.Enum):
     """Physical ports features.
 
     The curr, advertised, supported, and peer fields indicate link modes
     (10M to 10G full and half-duplex), link type (copper/fiber) and
     link features (autone-gotiation and pause).
 
+    Enums:
         OFPPF_10MB_HD     # 10 Mb half-duplex rate support.
         OFPPF_10MB_FD     # 10 Mb full-duplex rate support.
         OFPPF_100MB_HD    # 100 Mb half-duplex rate support.
diff --git a/pyof/v0x01/controller2switch/aggregate_stats_reply.py b/pyof/v0x01/controller2switch/aggregate_stats_reply.py
deleted file mode 100644
index 339127c..0000000
--- a/pyof/v0x01/controller2switch/aggregate_stats_reply.py
+++ /dev/null
@@ -1,31 +0,0 @@
-"""Body of the reply message"""
-
-# System imports
-
-# Third-party imports
-
-# Local source tree imports
-from pyof.v0x01.foundation import base
-from pyof.v0x01.foundation import basic_types
-
-# Classes
-
-
-class AggregateStatsReply(base.GenericStruct):
-    """Body of reply to OFPST_AGGREGATE request.
-
-    :param packet_count: Number of packets in flows
-    :param byte_count:   Number of bytes in flows
-    :param flow_count:   Number of flows
-    :param pad:          Align to 64 bits
-
-    """
-    packet_count = basic_types.UBInt64()
-    byte_count = basic_types.UBInt64()
-    flow_count = basic_types.UBInt32()
-    pad = basic_types.PAD(4)
-
-    def __init__(self, packet_count=None, byte_count=None, flow_count=None):
-        self.packet_count = packet_count
-        self.byte_count = byte_count
-        self.flow_count = flow_count
diff --git a/pyof/v0x01/controller2switch/aggregate_stats_request.py b/pyof/v0x01/controller2switch/aggregate_stats_request.py
deleted file mode 100644
index b45f923..0000000
--- a/pyof/v0x01/controller2switch/aggregate_stats_request.py
+++ /dev/null
@@ -1,38 +0,0 @@
-"""Aggregate information about multiple flows is requested with the
-OFPST_AGGREGATE stats request type"""
-
-# System imports
-
-# Third-party imports
-
-# Local source tree imports
-from pyof.v0x01.common import flow_match
-from pyof.v0x01.foundation import base
-from pyof.v0x01.foundation import basic_types
-
-# Classes
-
-
-class AggregateStatsRequest(base.GenericStruct):
-    """
-    Body for ofp_stats_request of type OFPST_AGGREGATE.
-
-    :param match:    Fields to match
-    :param table_id: ID of table to read (from pyof_table_stats) 0xff
-                     for all tables or 0xfe for emergency.
-    :param pad:      Align to 32 bits
-    :param out_port: Require matching entries to include this as an
-                     output port.  A value of OFPP_NONE indicates
-                     no restriction
-
-    """
-    match = flow_match.Match()
-    table_id = basic_types.UBInt8()
-    pad = basic_types.PAD(1)
-    out_port = basic_types.UBInt16()
-
-    def __init__(self, match=None, table_id=None, out_port=None):
-        super().__init__()
-        self.match = match
-        self.table_id = table_id
-        self.out_port = out_port
diff --git a/pyof/v0x01/controller2switch/common.py b/pyof/v0x01/controller2switch/common.py
index c5490dd..bfb9cd3 100644
--- a/pyof/v0x01/controller2switch/common.py
+++ b/pyof/v0x01/controller2switch/common.py
@@ -8,6 +8,7 @@ import enum
 # Local source tree imports
 from pyof.v0x01.common import header as of_header
 from pyof.v0x01.common import action
+from pyof.v0x01.common import flow_match
 from pyof.v0x01.foundation import base
 from pyof.v0x01.foundation import basic_types
 
@@ -65,3 +66,313 @@ class ListOfActions(basic_types.FixedTypeList):
     """
     def __init__(self, items=None):
         super().__init__(pyof_class=action.ActionHeader, items=items)
+
+
+class AggregateStatsReply(base.GenericStruct):
+    """Body of reply to OFPST_AGGREGATE request.
+
+    :param packet_count: Number of packets in flows
+    :param byte_count:   Number of bytes in flows
+    :param flow_count:   Number of flows
+    :param pad:          Align to 64 bits
+
+    """
+    packet_count = basic_types.UBInt64()
+    byte_count = basic_types.UBInt64()
+    flow_count = basic_types.UBInt32()
+    pad = basic_types.PAD(4)
+
+    def __init__(self, packet_count=None, byte_count=None, flow_count=None):
+        self.packet_count = packet_count
+        self.byte_count = byte_count
+        self.flow_count = flow_count
+
+
+class AggregateStatsRequest(base.GenericStruct):
+    """
+    Body for ofp_stats_request of type OFPST_AGGREGATE.
+
+    :param match:    Fields to match
+    :param table_id: ID of table to read (from pyof_table_stats) 0xff
+                     for all tables or 0xfe for emergency.
+    :param pad:      Align to 32 bits
+    :param out_port: Require matching entries to include this as an
+                     output port.  A value of OFPP_NONE indicates
+                     no restriction
+
+    """
+    match = flow_match.Match()
+    table_id = basic_types.UBInt8()
+    pad = basic_types.PAD(1)
+    out_port = basic_types.UBInt16()
+
+    def __init__(self, match=None, table_id=None, out_port=None):
+        super().__init__()
+        self.match = match
+        self.table_id = table_id
+        self.out_port = out_port
+
+
+class DescStats(base.GenericStruct):
+    """
+    Information about the switch manufacturer, hardware revision, software
+    revision, serial number, and a description field is avail- able from
+    the OFPST_DESC stats request.
+
+    :param mfr_desc:   Manufacturer description
+    :param hw_desc:    Hardware description
+    :param sw_desc:    Software description
+    :param serial_num: Serial number
+    :param dp_desc:    Human readable description of datapath
+
+    """
+    mfr_desc = basic_types.Char(length=base.DESC_STR_LEN)
+    hw_desc = basic_types.Char(length=base.DESC_STR_LEN)
+    sw_desc = basic_types.Char(length=base.DESC_STR_LEN)
+    serial_num = basic_types.Char(length=base.SERIAL_NUM_LEN)
+    dp_desc = basic_types.Char(length=base.DESC_STR_LEN)
+
+    def __init__(self, mfr_desc=None, hw_desc=None, sw_desc=None,
+                 serial_num=None, dp_desc=None):
+        self.mfr_desc = mfr_desc
+        self.hw_desc = hw_desc
+        self.sw_desc = sw_desc
+        self.serial_num = serial_num
+        self.dp_desc = dp_desc
+
+
+class FlowStats(base.GenericStruct):
+    """
+    Body of reply to OFPST_FLOW request.
+
+    :param length:        Length of this entry
+    :param table_id:      ID of table flow came from
+    :param pad:           Align to 32 bits
+    :param match:         Description of fields
+    :param duration_sec:  Time flow has been alive in seconds
+    :param duration_nsec: Time flow has been alive in nanoseconds beyond
+                          duration_sec
+    :param priority:      Priority of the entry. Only meaningful when this
+                          is not an exact-match entry
+    :param idle_timeout:  Number of seconds idle before expiration
+    :param hard_timeout:  Number of seconds before expiration
+    :param pad2:          Align to 64-bits
+    :param cookie:        Opaque controller-issued identifier
+    :param packet_count:  Number of packets in flow
+    :param byte_count:    Number of bytes in flow
+    :param actions:       Actions
+    """
+    length = basic_types.UBInt16()
+    table_id = basic_types.UBInt8()
+    pad = basic_types.PAD(1)
+    match = flow_match.Match()
+    duration_sec = basic_types.UBInt32()
+    duration_nsec = basic_types.UBInt32()
+    priority = basic_types.UBInt16()
+    idle_timeout = basic_types.UBInt16()
+    hard_timeout = basic_types.UBInt16()
+    pad2 = basic_types.PAD(6)
+    cookie = basic_types.UBInt64()
+    packet_count = basic_types.UBInt64()
+    byte_count = basic_types.UBInt64()
+    actions = ListOfActions()
+
+    def __init__(self, length=None, table_id=None, match=None,
+                 duration_sec=None, duration_nsec=None, priority=None,
+                 idle_timeout=None, hard_timeout=None, cookie=None,
+                 packet_count=None, byte_count=None, actions=None):
+        self.length = length
+        self.table_id = table_id
+        self.match = match
+        self.duration_sec = duration_sec
+        self.duration_nsec = duration_nsec
+        self.prioriry = priority
+        self.idle_timeout = idle_timeout
+        self.hard_timeout = hard_timeout
+        self.cookie = cookie
+        self.packet_count = packet_count
+        self.byte_count = byte_count
+        self.actions = [] if actions is None else actions
+
+
+class FlowStatsRequest(base.GenericStruct):
+    """
+    Body for ofp_stats_request of type OFPST_FLOW.
+
+    :param match:    Fields to match
+    :param table_id: ID of table to read (from pyof_table_stats)
+                     0xff for all tables or 0xfe for emergency
+    :param pad:      Align to 32 bits
+    :param out_port: Require matching entries to include this as an output
+                     port. A value of OFPP_NONE indicates no restriction.
+
+    """
+    match = flow_match.Match()
+    table_id = basic_types.UBInt8()
+    pad = basic_types.PAD(1)
+    out_port = basic_types.UBInt16()
+
+    def __init__(self, match=None, table_id=None, out_port=None):
+        self.match = match
+        self.table_id = table_id
+        self.out_port = out_port
+
+
+class PortStats(base.GenericStruct):
+    """Body of reply to OFPST_PORT request.
+
+    If a counter is unsupported, set the field to all ones.
+
+    :param port_no:      Port number
+    :param pad:          Align to 64-bits
+    :param rx_packets:   Number of received packets
+    :param tx_packets:   Number of transmitted packets
+    :param rx_bytes:     Number of received bytes
+    :param tx_bytes:     Number of transmitted bytes
+    :param rx_dropped:   Number of packets dropped by RX
+    :param tx_dropped:   Number of packets dropped by TX
+    :param rx_errors:    Number of receive errors.  This is a super-set
+                         of more specific receive errors and should be
+                         greater than or equal to the sum of all
+                         rx_*_err values
+    :param tx_errors:    Number of transmit errors.  This is a super-set
+                         of more specific transmit errors and should be
+                         greater than or equal to the sum of all
+                         tx_*_err values (none currently defined.)
+    :param rx_frame_err: Number of frame alignment errors
+    :param rx_over_err:  Number of packets with RX overrun
+    :param rx_crc_err:   Number of CRC errors
+    :param collisions:   Number of collisions
+
+    """
+    port_no = basic_types.UBInt16()
+    pad = basic_types.PAD(6)
+    rx_packets = basic_types.UBInt64()
+    tx_packets = basic_types.UBInt64()
+    rx_bytes = basic_types.UBInt64()
+    tx_bytes = basic_types.UBInt64()
+    rx_dropped = basic_types.UBInt64()
+    tx_dropped = basic_types.UBInt64()
+    rx_errors = basic_types.UBInt64()
+    tx_errors = basic_types.UBInt64()
+    rx_frame_err = basic_types.UBInt64()
+    rx_over_err = basic_types.UBInt64()
+    rx_crc_err = basic_types.UBInt64()
+    collisions = basic_types.UBInt64()
+
+    def __init__(self, port_no=None, rx_packets=None,
+                 tx_packets=None, rx_bytes=None, tx_bytes=None,
+                 rx_dropped=None, tx_dropped=None, rx_errors=None,
+                 tx_errors=None, rx_frame_err=None, rx_over_err=None,
+                 rx_crc_err=None, collisions=None):
+        self.port_no = port_no
+        self.rx_packets = rx_packets
+        self.tx_packets = tx_packets
+        self.rx_bytes = rx_bytes
+        self.tx_bytes = tx_bytes
+        self.rx_dropped = rx_dropped
+        self.tx_dropped = tx_dropped
+        self.rx_errors = rx_errors
+        self.tx_errors = tx_errors
+        self.rx_frame_err = rx_frame_err
+        self.rx_over_err = rx_over_err
+        self.rx_crc_err = rx_crc_err
+        self.collisions = collisions
+
+
+class PortStatsRequest(base.GenericStruct):
+    """
+    Body for ofp_stats_request of type OFPST_PORT
+
+    :param port_no: OFPST_PORT message must request statistics either
+                    for a single port (specified in port_no) or for
+                    all ports (if port_no == OFPP_NONE).
+    :param pad:
+
+    """
+    port_no = basic_types.UBInt16()
+    pad = basic_types.PAD(6)
+
+    def __init__(self, port_no=None):
+        self.port_no = port_no
+
+
+class QueueStats(base.GenericStruct):
+    """
+    Implements the reply body of a port_no
+
+    :param port_no:    Port Number
+    :param pad:        Align to 32-bits
+    :param queue_id:   Queue ID
+    :param tx_bytes:   Number of transmitted bytes
+    :param tx_packets: Number of transmitted packets
+    :param tx_errors:  Number of packets dropped due to overrun
+
+    """
+    port_no = basic_types.UBInt16()
+    pad = basic_types.PAD(2)
+    queue_id = basic_types.UBInt32()
+    tx_bytes = basic_types.UBInt64()
+    tx_packets = basic_types.UBInt64()
+    tx_errors = basic_types.UBInt64()
+
+    def __init__(self, port_no=None, queue_id=None, tx_bytes=None,
+                 tx_packets=None, tx_errors=None):
+        self.port_no = port_no
+        self.queue_id = queue_id
+        self.tx_bytes = tx_bytes
+        self.tx_packets = tx_packets
+        self.tx_errors = tx_errors
+
+
+class QueueStatsRequest(base.GenericStruct):
+    """
+    Implements the request body of a port_no
+
+    :param port_no:  All ports if OFPT_ALL
+    :param pad:      Align to 32-bits
+    :param queue_id: All queues if OFPQ_ALL
+    """
+    port_no = basic_types.UBInt16()
+    pad = basic_types.PAD(2)
+    queue_id = basic_types.UBInt32()
+
+    def __init__(self, port_no=None, queue_id=None):
+        self.port_no = port_no
+        self.queue_id = queue_id
+
+
+class TableStats(base.GenericStruct):
+    """Body of reply to OFPST_TABLE request.
+
+    :param table_id:      Identifier of table.  Lower numbered tables
+                          are consulted first
+    :param pad:           Align to 32-bits
+    :param name:          Table name
+    :param wildcards:     Bitmap of OFPFW_* wildcards that are supported
+                          by the table
+    :param max_entries:   Max number of entries supported
+    :param active_count:  Number of active entries
+    :param count_lookup:  Number of packets looked up in table
+    :param count_matched: Number of packets that hit table
+
+    """
+    table_id = basic_types.UBInt8()
+    pad = basic_types.PAD(3)
+    name = basic_types.Char(length=base.OFP_MAX_TABLE_NAME_LEN)
+    wildcards = basic_types.UBInt32()
+    max_entries = basic_types.UBInt32()
+    active_count = basic_types.UBInt32()
+    count_lookup = basic_types.UBInt64()
+    count_matched = basic_types.UBInt64()
+
+    def __init__(self, table_id=None, name=None, wildcards=None,
+                 max_entries=None, active_count=None, count_lookup=None,
+                 count_matched=None):
+        self.table_id = table_id
+        self.name = name
+        self.wildcards = wildcards
+        self.max_entries = max_entries
+        self.active_count = active_count
+        self.count_lookup = count_lookup
+        self.count_matched = count_matched
diff --git a/pyof/v0x01/controller2switch/desc_stats.py b/pyof/v0x01/controller2switch/desc_stats.py
deleted file mode 100644
index bceffb9..0000000
--- a/pyof/v0x01/controller2switch/desc_stats.py
+++ /dev/null
@@ -1,39 +0,0 @@
-"""Information about the switch manufactures"""
-
-# System imports
-
-# Third-party imports
-
-# Local source tree imports
-from pyof.v0x01.foundation import base
-from pyof.v0x01.foundation import basic_types
-
-# Classes
-
-
-class DescStats(base.GenericStruct):
-    """
-    Information about the switch manufacturer, hardware revision, software
-    revision, serial number, and a description field is avail- able from
-    the OFPST_DESC stats request.
-
-    :param mfr_desc:   Manufacturer description
-    :param hw_desc:    Hardware description
-    :param sw_desc:    Software description
-    :param serial_num: Serial number
-    :param dp_desc:    Human readable description of datapath
-
-    """
-    mfr_desc = basic_types.Char(length=base.DESC_STR_LEN)
-    hw_desc = basic_types.Char(length=base.DESC_STR_LEN)
-    sw_desc = basic_types.Char(length=base.DESC_STR_LEN)
-    serial_num = basic_types.Char(length=base.SERIAL_NUM_LEN)
-    dp_desc = basic_types.Char(length=base.DESC_STR_LEN)
-
-    def __init__(self, mfr_desc=None, hw_desc=None, sw_desc=None,
-                 serial_num=None, dp_desc=None):
-        self.mfr_desc = mfr_desc
-        self.hw_desc = hw_desc
-        self.sw_desc = sw_desc
-        self.serial_num = serial_num
-        self.dp_desc = dp_desc
diff --git a/pyof/v0x01/controller2switch/features_reply.py b/pyof/v0x01/controller2switch/features_reply.py
index c5f3bca..e02f012 100644
--- a/pyof/v0x01/controller2switch/features_reply.py
+++ b/pyof/v0x01/controller2switch/features_reply.py
@@ -1,6 +1,7 @@
 """Defines Features Reply classes and related items"""
 
 # System imports
+import enum
 
 # Third-party imports
 
@@ -11,9 +12,13 @@ from pyof.v0x01.foundation import base
 from pyof.v0x01.foundation import basic_types
 
 
-class Capabilities(base.GenericBitMask):
-    """Capabilities supported by the datapath
+# Enums
 
+
+class Capabilities(enum.Enum):
+    """Enumeration of Capabilities supported by the datapath
+
+    Enums:
         OFPC_FLOW_STATS     # Flow statistics
         OFPC_TABLE_STATS    # Table statistics
         OFPC_PORT_STATS     # Port statistics
diff --git a/pyof/v0x01/controller2switch/flow_stats.py b/pyof/v0x01/controller2switch/flow_stats.py
deleted file mode 100644
index efb5edd..0000000
--- a/pyof/v0x01/controller2switch/flow_stats.py
+++ /dev/null
@@ -1,67 +0,0 @@
-"""Body of the reply to an OFPST_FLOW"""
-
-# System imports
-
-# Third-party imports
-
-# Local source tree imports
-from pyof.v0x01.common import flow_match
-from pyof.v0x01.controller2switch import common
-from pyof.v0x01.foundation import base
-from pyof.v0x01.foundation import basic_types
-
-# Classes
-
-
-class FlowStats(base.GenericStruct):
-    """
-    Body of reply to OFPST_FLOW request.
-
-    :param length:        Length of this entry
-    :param table_id:      ID of table flow came from
-    :param pad:           Align to 32 bits
-    :param match:         Description of fields
-    :param duration_sec:  Time flow has been alive in seconds
-    :param duration_nsec: Time flow has been alive in nanoseconds beyond
-                          duration_sec
-    :param priority:      Priority of the entry. Only meaningful when this
-                          is not an exact-match entry
-    :param idle_timeout:  Number of seconds idle before expiration
-    :param hard_timeout:  Number of seconds before expiration
-    :param pad2:          Align to 64-bits
-    :param cookie:        Opaque controller-issued identifier
-    :param packet_count:  Number of packets in flow
-    :param byte_count:    Number of bytes in flow
-    :param actions:       Actions
-    """
-    length = basic_types.UBInt16()
-    table_id = basic_types.UBInt8()
-    pad = basic_types.PAD(1)
-    match = flow_match.Match()
-    duration_sec = basic_types.UBInt32()
-    duration_nsec = basic_types.UBInt32()
-    priority = basic_types.UBInt16()
-    idle_timeout = basic_types.UBInt16()
-    hard_timeout = basic_types.UBInt16()
-    pad2 = basic_types.PAD(6)
-    cookie = basic_types.UBInt64()
-    packet_count = basic_types.UBInt64()
-    byte_count = basic_types.UBInt64()
-    actions = common.ListOfActions()
-
-    def __init__(self, length=None, table_id=None, match=None,
-                 duration_sec=None, duration_nsec=None, priority=None,
-                 idle_timeout=None, hard_timeout=None, cookie=None,
-                 packet_count=None, byte_count=None, actions=None):
-        self.length = length
-        self.table_id = table_id
-        self.match = match
-        self.duration_sec = duration_sec
-        self.duration_nsec = duration_nsec
-        self.prioriry = priority
-        self.idle_timeout = idle_timeout
-        self.hard_timeout = hard_timeout
-        self.cookie = cookie
-        self.packet_count = packet_count
-        self.byte_count = byte_count
-        self.actions = [] if actions is None else actions
diff --git a/pyof/v0x01/controller2switch/flow_stats_request.py b/pyof/v0x01/controller2switch/flow_stats_request.py
deleted file mode 100644
index 1fc5794..0000000
--- a/pyof/v0x01/controller2switch/flow_stats_request.py
+++ /dev/null
@@ -1,35 +0,0 @@
-"""Information about individual flows"""
-
-# System imports
-
-# Third-party imports
-
-# Local source tree imports
-from pyof.v0x01.common import flow_match
-from pyof.v0x01.foundation import base
-from pyof.v0x01.foundation import basic_types
-
-# Classes
-
-
-class FlowStatsRequest(base.GenericStruct):
-    """
-    Body for ofp_stats_request of type OFPST_FLOW.
-
-    :param match:    Fields to match
-    :param table_id: ID of table to read (from pyof_table_stats)
-                     0xff for all tables or 0xfe for emergency
-    :param pad:      Align to 32 bits
-    :param out_port: Require matching entries to include this as an output
-                     port. A value of OFPP_NONE indicates no restriction.
-
-    """
-    match = flow_match.Match()
-    table_id = basic_types.UBInt8()
-    pad = basic_types.PAD(1)
-    out_port = basic_types.UBInt16()
-
-    def __init__(self, match=None, table_id=None, out_port=None):
-        self.match = match
-        self.table_id = table_id
-        self.out_port = out_port
diff --git a/pyof/v0x01/controller2switch/port_stats.py b/pyof/v0x01/controller2switch/port_stats.py
deleted file mode 100644
index 474828d..0000000
--- a/pyof/v0x01/controller2switch/port_stats.py
+++ /dev/null
@@ -1,73 +0,0 @@
-"""Body of the port stats reply"""
-
-# System imports
-
-# Third-party imports
-
-# Local source tree imports
-from pyof.v0x01.foundation import base
-from pyof.v0x01.foundation import basic_types
-
-# Classes
-
-
-class PortStats(base.GenericStruct):
-    """Body of reply to OFPST_PORT request.
-
-    If a counter is unsupported, set the field to all ones.
-
-    :param port_no:      Port number
-    :param pad:          Align to 64-bits
-    :param rx_packets:   Number of received packets
-    :param tx_packets:   Number of transmitted packets
-    :param rx_bytes:     Number of received bytes
-    :param tx_bytes:     Number of transmitted bytes
-    :param rx_dropped:   Number of packets dropped by RX
-    :param tx_dropped:   Number of packets dropped by TX
-    :param rx_errors:    Number of receive errors.  This is a super-set
-                         of more specific receive errors and should be
-                         greater than or equal to the sum of all
-                         rx_*_err values
-    :param tx_errors:    Number of transmit errors.  This is a super-set
-                         of more specific transmit errors and should be
-                         greater than or equal to the sum of all
-                         tx_*_err values (none currently defined.)
-    :param rx_frame_err: Number of frame alignment errors
-    :param rx_over_err:  Number of packets with RX overrun
-    :param rx_crc_err:   Number of CRC errors
-    :param collisions:   Number of collisions
-
-    """
-    port_no = basic_types.UBInt16()
-    pad = basic_types.PAD(6)
-    rx_packets = basic_types.UBInt64()
-    tx_packets = basic_types.UBInt64()
-    rx_bytes = basic_types.UBInt64()
-    tx_bytes = basic_types.UBInt64()
-    rx_dropped = basic_types.UBInt64()
-    tx_dropped = basic_types.UBInt64()
-    rx_errors = basic_types.UBInt64()
-    tx_errors = basic_types.UBInt64()
-    rx_frame_err = basic_types.UBInt64()
-    rx_over_err = basic_types.UBInt64()
-    rx_crc_err = basic_types.UBInt64()
-    collisions = basic_types.UBInt64()
-
-    def __init__(self, port_no=None, rx_packets=None,
-                 tx_packets=None, rx_bytes=None, tx_bytes=None,
-                 rx_dropped=None, tx_dropped=None, rx_errors=None,
-                 tx_errors=None, rx_frame_err=None, rx_over_err=None,
-                 rx_crc_err=None, collisions=None):
-        self.port_no = port_no
-        self.rx_packets = rx_packets
-        self.tx_packets = tx_packets
-        self.rx_bytes = rx_bytes
-        self.tx_bytes = tx_bytes
-        self.rx_dropped = rx_dropped
-        self.tx_dropped = tx_dropped
-        self.rx_errors = rx_errors
-        self.tx_errors = tx_errors
-        self.rx_frame_err = rx_frame_err
-        self.rx_over_err = rx_over_err
-        self.rx_crc_err = rx_crc_err
-        self.collisions = collisions
diff --git a/pyof/v0x01/controller2switch/port_stats_request.py b/pyof/v0x01/controller2switch/port_stats_request.py
deleted file mode 100644
index 8fa4049..0000000
--- a/pyof/v0x01/controller2switch/port_stats_request.py
+++ /dev/null
@@ -1,26 +0,0 @@
-"""Information about physical ports is requested with OFPST_PORT"""
-
-# System imports
-
-# Third-party imports
-
-# Local source tree imports
-from pyof.v0x01.foundation import base
-from pyof.v0x01.foundation import basic_types
-
-
-class PortStatsRequest(base.GenericStruct):
-    """
-    Body for ofp_stats_request of type OFPST_PORT
-
-    :param port_no: OFPST_PORT message must request statistics either
-                    for a single port (specified in port_no) or for
-                    all ports (if port_no == OFPP_NONE).
-    :param pad:
-
-    """
-    port_no = basic_types.UBInt16()
-    pad = basic_types.PAD(6)
-
-    def __init__(self, port_no=None):
-        self.port_no = port_no
diff --git a/pyof/v0x01/controller2switch/queue_stats.py b/pyof/v0x01/controller2switch/queue_stats.py
deleted file mode 100644
index d7df9b3..0000000
--- a/pyof/v0x01/controller2switch/queue_stats.py
+++ /dev/null
@@ -1,38 +0,0 @@
-"""The OFPST_QUEUE stats reply message provides queue statistics for one
-or more ports."""
-
-# System imports
-
-# Third-party imports
-
-# Local source tree imports
-from pyof.v0x01.foundation import base
-from pyof.v0x01.foundation import basic_types
-
-
-class QueueStats(base.GenericStruct):
-    """
-    Implements the reply body of a port_no
-
-    :param port_no:    Port Number
-    :param pad:        Align to 32-bits
-    :param queue_id:   Queue ID
-    :param tx_bytes:   Number of transmitted bytes
-    :param tx_packets: Number of transmitted packets
-    :param tx_errors:  Number of packets dropped due to overrun
-
-    """
-    port_no = basic_types.UBInt16()
-    pad = basic_types.PAD(2)
-    queue_id = basic_types.UBInt32()
-    tx_bytes = basic_types.UBInt64()
-    tx_packets = basic_types.UBInt64()
-    tx_errors = basic_types.UBInt64()
-
-    def __init__(self, port_no=None, queue_id=None, tx_bytes=None,
-                 tx_packets=None, tx_errors=None):
-        self.port_no = port_no
-        self.queue_id = queue_id
-        self.tx_bytes = tx_bytes
-        self.tx_packets = tx_packets
-        self.tx_errors = tx_errors
diff --git a/pyof/v0x01/controller2switch/queue_stats_request.py b/pyof/v0x01/controller2switch/queue_stats_request.py
deleted file mode 100644
index c1b431b..0000000
--- a/pyof/v0x01/controller2switch/queue_stats_request.py
+++ /dev/null
@@ -1,27 +0,0 @@
-"""The OFPST_QUEUE stats request message provides queue statistics for one
-or more ports."""
-
-# System imports
-
-# Third-party imports
-
-# Local source tree imports
-from pyof.v0x01.foundation import base
-from pyof.v0x01.foundation import basic_types
-
-
-class QueueStatsRequest(base.GenericStruct):
-    """
-    Implements the request body of a port_no
-
-    :param port_no:  All ports if OFPT_ALL
-    :param pad:      Align to 32-bits
-    :param queue_id: All queues if OFPQ_ALL
-    """
-    port_no = basic_types.UBInt16()
-    pad = basic_types.PAD(2)
-    queue_id = basic_types.UBInt32()
-
-    def __init__(self, port_no=None, queue_id=None):
-        self.port_no = port_no
-        self.queue_id = queue_id
diff --git a/pyof/v0x01/controller2switch/table_stats.py b/pyof/v0x01/controller2switch/table_stats.py
deleted file mode 100644
index bf2e42f..0000000
--- a/pyof/v0x01/controller2switch/table_stats.py
+++ /dev/null
@@ -1,45 +0,0 @@
-"""Information about tables is requested with OFPST_TABLE stats request type"""
-
-# System imports
-
-# Third-party imports
-
-# Local source tree imports
-from pyof.v0x01.foundation import base
-from pyof.v0x01.foundation import basic_types
-
-
-class TableStats(base.GenericStruct):
-    """Body of reply to OFPST_TABLE request.
-
-    :param table_id:      Identifier of table.  Lower numbered tables
-                          are consulted first
-    :param pad:           Align to 32-bits
-    :param name:          Table name
-    :param wildcards:     Bitmap of OFPFW_* wildcards that are supported
-                          by the table
-    :param max_entries:   Max number of entries supported
-    :param active_count:  Number of active entries
-    :param count_lookup:  Number of packets looked up in table
-    :param count_matched: Number of packets that hit table
-
-    """
-    table_id = basic_types.UBInt8()
-    pad = basic_types.PAD(3)
-    name = basic_types.Char(length=base.OFP_MAX_TABLE_NAME_LEN)
-    wildcards = basic_types.UBInt32()
-    max_entries = basic_types.UBInt32()
-    active_count = basic_types.UBInt32()
-    count_lookup = basic_types.UBInt64()
-    count_matched = basic_types.UBInt64()
-
-    def __init__(self, table_id=None, name=None, wildcards=None,
-                 max_entries=None, active_count=None, count_lookup=None,
-                 count_matched=None):
-        self.table_id = table_id
-        self.name = name
-        self.wildcards = wildcards
-        self.max_entries = max_entries
-        self.active_count = active_count
-        self.count_lookup = count_lookup
-        self.count_matched = count_matched


Test patch:
diff --git a/tests/v0x01/test_controller2switch/test_aggregate_stats_reply.py b/tests/v0x01/test_controller2switch/test_aggregate_stats_reply.py
index 3fc3326..1c699dd 100644
--- a/tests/v0x01/test_controller2switch/test_aggregate_stats_reply.py
+++ b/tests/v0x01/test_controller2switch/test_aggregate_stats_reply.py
@@ -1,12 +1,12 @@
 import unittest
 
-from pyof.v0x01.controller2switch import aggregate_stats_reply
+from pyof.v0x01.controller2switch.common import AggregateStatsReply
 
 
 class TestAggregateStatsReply(unittest.TestCase):
 
     def setUp(self):
-        self.message = aggregate_stats_reply.AggregateStatsReply()
+        self.message = AggregateStatsReply()
         self.message.packet_count = 5
         self.message.byte_count = 1
         self.message.flow_count = 8
diff --git a/tests/v0x01/test_controller2switch/test_aggregate_stats_request.py b/tests/v0x01/test_controller2switch/test_aggregate_stats_request.py
index ca563fe..8e4be10 100644
--- a/tests/v0x01/test_controller2switch/test_aggregate_stats_request.py
+++ b/tests/v0x01/test_controller2switch/test_aggregate_stats_request.py
@@ -2,13 +2,13 @@ import unittest
 
 from pyof.v0x01.common import flow_match
 from pyof.v0x01.common import phy_port
-from pyof.v0x01.controller2switch import aggregate_stats_request
+from pyof.v0x01.controller2switch.common import AggregateStatsRequest
 
 
 class TestAggregateStatsRequest(unittest.TestCase):
 
     def setUp(self):
-        self.message = aggregate_stats_request.AggregateStatsRequest()
+        self.message = AggregateStatsRequest()
         self.message.match = flow_match.Match()
         self.message.table_id = 1
         self.message.out_port = phy_port.Port.OFPP_NONE
diff --git a/tests/v0x01/test_controller2switch/test_desc_stats.py b/tests/v0x01/test_controller2switch/test_desc_stats.py
index 5ea6422..4f13f97 100644
--- a/tests/v0x01/test_controller2switch/test_desc_stats.py
+++ b/tests/v0x01/test_controller2switch/test_desc_stats.py
@@ -1,6 +1,6 @@
 import unittest
 
-from pyof.v0x01.controller2switch import desc_stats
+from pyof.v0x01.controller2switch.common import DescStats
 from pyof.v0x01.foundation import base
 
 
@@ -8,7 +8,7 @@ class TestDescStats(unittest.TestCase):
 
     def setUp(self):
         content = bytes('A' * base.DESC_STR_LEN, 'utf-8')
-        self.message = desc_stats.DescStats()
+        self.message = DescStats()
         self.message.mfr_desc = content
         self.message.hw_desc = content
         self.message.sw_desc = content
diff --git a/tests/v0x01/test_controller2switch/test_flow_stats.py b/tests/v0x01/test_controller2switch/test_flow_stats.py
index 1de34ab..2a04c07 100644
--- a/tests/v0x01/test_controller2switch/test_flow_stats.py
+++ b/tests/v0x01/test_controller2switch/test_flow_stats.py
@@ -1,13 +1,13 @@
 import unittest
 
 from pyof.v0x01.common import flow_match
-from pyof.v0x01.controller2switch import flow_stats
+from pyof.v0x01.controller2switch.common import FlowStats
 
 
 class TestFlowStats(unittest.TestCase):
 
     def setUp(self):
-        self.message = flow_stats.FlowStats()
+        self.message = FlowStats()
         self.message.length = 160
         self.message.table_id = 1
         self.message.match = flow_match.Match()
diff --git a/tests/v0x01/test_controller2switch/test_flow_stats_request.py b/tests/v0x01/test_controller2switch/test_flow_stats_request.py
index 85a33bb..2a6f3fb 100644
--- a/tests/v0x01/test_controller2switch/test_flow_stats_request.py
+++ b/tests/v0x01/test_controller2switch/test_flow_stats_request.py
@@ -1,13 +1,13 @@
 import unittest
 
 from pyof.v0x01.common import flow_match
-from pyof.v0x01.controller2switch import flow_stats_request
+from pyof.v0x01.controller2switch.common import FlowStatsRequest
 
 
 class TestFlowStatsRequest(unittest.TestCase):
 
     def setUp(self):
-        self.message = flow_stats_request.FlowStatsRequest()
+        self.message = FlowStatsRequest()
         self.message.match = flow_match.Match()
         self.message.table_id = 1
         self.message.out_port = 80
diff --git a/tests/v0x01/test_controller2switch/test_port_stats.py b/tests/v0x01/test_controller2switch/test_port_stats.py
index 7a58485..e6f4b55 100644
--- a/tests/v0x01/test_controller2switch/test_port_stats.py
+++ b/tests/v0x01/test_controller2switch/test_port_stats.py
@@ -1,12 +1,12 @@
 import unittest
 
-from pyof.v0x01.controller2switch import port_stats
+from pyof.v0x01.controller2switch.common import PortStats
 
 
 class TestPortStats(unittest.TestCase):
 
     def setUp(self):
-        self.message = port_stats.PortStats()
+        self.message = PortStats()
         self.message.port_no = 80
         self.message.rx_packets = 5
         self.message.tx_packets = 10
diff --git a/tests/v0x01/test_controller2switch/test_port_stats_request.py b/tests/v0x01/test_controller2switch/test_port_stats_request.py
index e0454dc..8025055 100644
--- a/tests/v0x01/test_controller2switch/test_port_stats_request.py
+++ b/tests/v0x01/test_controller2switch/test_port_stats_request.py
@@ -1,12 +1,12 @@
 import unittest
 
-from pyof.v0x01.controller2switch import port_stats_request
+from pyof.v0x01.controller2switch.common import PortStatsRequest 
 
 
 class TestPortStatsRequest(unittest.TestCase):
 
     def setUp(self):
-        self.message = port_stats_request.PortStatsRequest()
+        self.message = PortStatsRequest()
         self.message.port_no = 80
 
     def test_get_size(self):
diff --git a/tests/v0x01/test_controller2switch/test_queue_stats.py b/tests/v0x01/test_controller2switch/test_queue_stats.py
index fb03ee7..b1f1219 100644
--- a/tests/v0x01/test_controller2switch/test_queue_stats.py
+++ b/tests/v0x01/test_controller2switch/test_queue_stats.py
@@ -1,12 +1,12 @@
 import unittest
 
-from pyof.v0x01.controller2switch import queue_stats
+from pyof.v0x01.controller2switch.common import QueueStats
 
 
 class TestQueueStats(unittest.TestCase):
 
     def setUp(self):
-        self.message = queue_stats.QueueStats()
+        self.message = QueueStats()
         self.message.port_no = 80
         self.message.queue_id = 5
         self.message.tx_bytes = 1
diff --git a/tests/v0x01/test_controller2switch/test_queue_stats_request.py b/tests/v0x01/test_controller2switch/test_queue_stats_request.py
index 80cad68..2f95381 100644
--- a/tests/v0x01/test_controller2switch/test_queue_stats_request.py
+++ b/tests/v0x01/test_controller2switch/test_queue_stats_request.py
@@ -1,12 +1,12 @@
 import unittest
 
-from pyof.v0x01.controller2switch import queue_stats_request
+from pyof.v0x01.controller2switch.common import QueueStatsRequest
 
 
 class TestQueueStatsRequest(unittest.TestCase):
 
     def setUp(self):
-        self.message = queue_stats_request.QueueStatsRequest()
+        self.message = QueueStatsRequest()
         self.message.port_no = 80
         self.message.queue_id = 5
 
diff --git a/tests/v0x01/test_controller2switch/test_table_stats.py b/tests/v0x01/test_controller2switch/test_table_stats.py
index 353f6de..39888b5 100644
--- a/tests/v0x01/test_controller2switch/test_table_stats.py
+++ b/tests/v0x01/test_controller2switch/test_table_stats.py
@@ -1,14 +1,14 @@
 import unittest
 
 from pyof.v0x01.common import flow_match
-from pyof.v0x01.controller2switch import table_stats
+from pyof.v0x01.controller2switch.common import TableStats
 from pyof.v0x01.foundation import base
 
 
 class TestTableStats(unittest.TestCase):
 
     def setUp(self):
-        self.message = table_stats.TableStats()
+        self.message = TableStats()
         self.message.table_id = 1
         self.message.name = bytes('X' * base.OFP_MAX_TABLE_NAME_LEN, 'utf-8')
         self.message.wildcards = flow_match.FlowWildCards.OFPFW_TP_DST