This patch removes 'Subtype' byte from SystemCapabilities TLV.
There was an inconsistency in offical IEEE document which was corrected
in 802.1AB-2009/Cor 1-2013.

Signed-off-by: Marcin Chron <marcin_mi...@o2.pl>
---
 ryu/lib/packet/lldp.py             | 11 ++++-------
 ryu/tests/unit/packet/test_lldp.py |  3 +--
 2 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/ryu/lib/packet/lldp.py b/ryu/lib/packet/lldp.py
index 914f07c..d328691 100644
--- a/ryu/lib/packet/lldp.py
+++ b/ryu/lib/packet/lldp.py
@@ -455,13 +455,12 @@ class SystemCapabilities(LLDPBasicTLV):
     Attribute         Description
     ================= =====================================
     buf               Binary data to parse.
-    subtype           Subtype.
     system_cap        System Capabilities.
     enabled_cap       Enabled Capabilities.
     ================= =====================================
     """
     # chassis subtype(1) + system cap(2) + enabled cap(2)
-    _PACK_STR = '!BHH'
+    _PACK_STR = '!HH'
     _PACK_SIZE = struct.calcsize(_PACK_STR)
     _LEN_MIN = _PACK_SIZE
     _LEN_MAX = _PACK_SIZE
@@ -481,10 +480,9 @@ class SystemCapabilities(LLDPBasicTLV):
     def __init__(self, buf=None, *args, **kwargs):
         super(SystemCapabilities, self).__init__(buf, *args, **kwargs)
         if buf:
-            (self.subtype, self.system_cap, self.enabled_cap) = \
+            (self.system_cap, self.enabled_cap) = \
struct.unpack(self._PACK_STR, self.tlv_info[:self._PACK_SIZE])
         else:
-            self.subtype = kwargs['subtype']
             self.system_cap = kwargs['system_cap']
             self.enabled_cap = kwargs['enabled_cap']
             self.len = self._PACK_SIZE
@@ -492,9 +490,8 @@ class SystemCapabilities(LLDPBasicTLV):
self.typelen = (self.tlv_type << LLDP_TLV_TYPE_SHIFT) | self.len

     def serialize(self):
-        return struct.pack('!HBHH',
-                           self.typelen, self.subtype,
-                           self.system_cap, self.enabled_cap)
+        return struct.pack('!HHH',
+ self.typelen, self.system_cap, self.enabled_cap)


 @lldp.set_tlv_type(LLDP_TLV_MANAGEMENT_ADDRESS)
diff --git a/ryu/tests/unit/packet/test_lldp.py b/ryu/tests/unit/packet/test_lldp.py
index d8d261c..87a66de 100644
--- a/ryu/tests/unit/packet/test_lldp.py
+++ b/ryu/tests/unit/packet/test_lldp.py
@@ -227,7 +227,7 @@ class TestLLDPOptionalTLV(unittest.TestCase):
                     + b'\x73\x74\x65\x72\x20\x30\x35\x2f' \
                     + b'\x32\x37\x2f\x30\x35\x20\x30\x34' \
                     + b'\x3a\x35\x33\x3a\x31\x31\x00\x0e' \
-                    + b'\x05\x01\x00\x14\x00\x14\x10\x0e' \
+                    + b'\x04\x00\x14\x00\x14\x10\x0e' \
                     + b'\x07' \
                     + b'\x06\x00\x01\x30\xf9\xad\xa0\x02' \
                     + b'\x00\x00\x03\xe9\x00\xfe\x07\x00' \
@@ -274,7 +274,6 @@ class TestLLDPOptionalTLV(unittest.TestCase):

         # SystemCapabilities
         eq_(tlvs[6].tlv_type, lldp.LLDP_TLV_SYSTEM_CAPABILITIES)
-        eq_(tlvs[6].subtype, lldp.ChassisID.SUB_CHASSIS_COMPONENT)
eq_(tlvs[6].system_cap & lldp.SystemCapabilities.CAP_MAC_BRIDGE,
             lldp.SystemCapabilities.CAP_MAC_BRIDGE)
eq_(tlvs[6].enabled_cap & lldp.SystemCapabilities.CAP_MAC_BRIDGE,
--
2.7.4

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to