Repository: kytos/python-openflow

Issue:
OF 1.3 Compliance: Wrong pad attribute size
File: `v0x04/controller2switch/common.py`

`class PortStatsRequest(GenericStruct):`
In source code the pad attribute size is set to 6, but in 1.3 Spec it is 4.

Espec 1.3: `pad[4]`
Source Code: `pad = Pad(6)`

Comments:

Patch:
diff --git a/pyof/v0x04/common/action.py b/pyof/v0x04/common/action.py
index 9b550a2..78d6004 100644
--- a/pyof/v0x04/common/action.py
+++ b/pyof/v0x04/common/action.py
@@ -72,7 +72,6 @@ class ActionType(Enum):
     OFPAT_POP_PBB = 27
     #: Experimenter type
     OFPAT_EXPERIMENTER = 0xffff
-    OFPAT_VENDOR = 0xffff
 
 
 class ControllerMaxLen(Enum):
@@ -254,6 +253,8 @@ class ActionPopMPLS(GenericStruct):
     length = UBInt16(8)
     #: Ethertype
     ethertype = UBInt16()
+    #: Padding
+    pad = Pad(2)
 
     def __init__(self, ethertype=None):
         """Action structure for OFPAT_POP_MPLS.
diff --git a/pyof/v0x04/common/port.py b/pyof/v0x04/common/port.py
index db3b41c..41b5be3 100644
--- a/pyof/v0x04/common/port.py
+++ b/pyof/v0x04/common/port.py
@@ -44,7 +44,7 @@ class PortNo(Enum):
     #: Wildcard port used only for flow mod (delete) and flow stats requests.
     #: Selects all flows regardless of output port (including flows with no
     #: output port).
-    OFPP_NONE = 0xffffffff
+    OFPP_ANY = 0xffffffff
 
 
 class PortConfig(GenericBitMask):
diff --git a/pyof/v0x04/controller2switch/common.py b/pyof/v0x04/controller2switch/common.py
index bebb8b2..1bcc883 100644
--- a/pyof/v0x04/controller2switch/common.py
+++ b/pyof/v0x04/controller2switch/common.py
@@ -251,9 +251,11 @@ class DescStats(GenericStruct):
     sw_desc = Char(length=DESC_STR_LEN)
     #: Serial number
     serial_num = Char(length=SERIAL_NUM_LEN)
+    #: Datapath description
+    dp_desc = Char(length=DESC_STR_LEN)
 
     def __init__(self, mfr_desc=None, hw_desc=None, sw_desc=None,
-                 serial_num=None):
+                 serial_num=None, dp_desc=None):
         """The constructor just assings parameters to object attributes.
 
         Args:
@@ -261,12 +263,14 @@ class DescStats(GenericStruct):
             hw_desc (str): Hardware description
             sw_desc (str): Software description
             serial_num (str): Serial number
+            dp_desc (str): Datapath description
         """
         super().__init__()
         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(GenericStruct):
@@ -454,9 +458,9 @@ class PortStats(GenericStruct):
 class PortStatsRequest(GenericStruct):
     """Body for ofp_stats_request of type OFPST_PORT."""
 
-    port_no = UBInt16()
+    port_no = UBInt32()
     #: Align to 64-bits.
-    pad = Pad(6)
+    pad = Pad(4)
 
     def __init__(self, port_no=None):
         """The constructor just assings parameters to object attributes.
diff --git a/pyof/v0x04/controller2switch/packet_out.py b/pyof/v0x04/controller2switch/packet_out.py
index e23fc87..1520f85 100644
--- a/pyof/v0x04/controller2switch/packet_out.py
+++ b/pyof/v0x04/controller2switch/packet_out.py
@@ -13,7 +13,7 @@ __all__ = ('PacketOut',)
 # Classes
 
 #: in_port valid virtual port values, for validation
-_VIRT_IN_PORTS = (PortNo.OFPP_LOCAL, PortNo.OFPP_CONTROLLER, PortNo.OFPP_NONE)
+_VIRT_IN_PORTS = (PortNo.OFPP_LOCAL, PortNo.OFPP_CONTROLLER, PortNo.OFPP_ANY)
 
 
 class PacketOut(GenericMessage):


Test patch:
diff --git a/tests/v0x04/test_controller2switch/test_packet_out.py b/tests/v0x04/test_controller2switch/test_packet_out.py
index 733fff2..803eb1a 100644
--- a/tests/v0x04/test_controller2switch/test_packet_out.py
+++ b/tests/v0x04/test_controller2switch/test_packet_out.py
@@ -23,7 +23,7 @@ class TestPacketOut(TestStruct):
         super().setUpClass()
         super().set_raw_dump_file('v0x04', 'ofpt_packet_out')
         super().set_raw_dump_object(PacketOut, xid=80, buffer_id=5,
-                                    in_port=PortNo.OFPP_NONE)
+                                    in_port=PortNo.OFPP_ANY)
         super().set_minimum_size(24)
 
     def test_valid_virtual_in_ports(self):
@@ -34,7 +34,7 @@ class TestPacketOut(TestStruct):
             raise self.skipTest(NO_RAW)
         else:
             valid = (PortNo.OFPP_LOCAL, PortNo.OFPP_CONTROLLER,
-                     PortNo.OFPP_NONE)
+                     PortNo.OFPP_ANY)
             msg = self.get_raw_object()
             for in_port in valid:
                 msg.in_port = in_port