diff options
-rw-r--r-- | ryu/lib/packet/lldp.py | 15 | ||||
-rw-r--r-- | ryu/tests/unit/packet/test_lldp.py | 4 |
2 files changed, 7 insertions, 12 deletions
diff --git a/ryu/lib/packet/lldp.py b/ryu/lib/packet/lldp.py index 914f07c1..a48884d7 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' + # system cap(2) + enabled cap(2) + _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) = \ - struct.unpack(self._PACK_STR, self.tlv_info[:self._PACK_SIZE]) + (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 d8d261c2..a5c96bda 100644 --- a/ryu/tests/unit/packet/test_lldp.py +++ b/ryu/tests/unit/packet/test_lldp.py @@ -227,8 +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'\x07' \ + + b'\x04\x00\x14\x00\x14\x10\x0e\x07' \ + b'\x06\x00\x01\x30\xf9\xad\xa0\x02' \ + b'\x00\x00\x03\xe9\x00\xfe\x07\x00' \ + b'\x12\x0f\x02\x07\x01\x00\xfe\x09' \ @@ -274,7 +273,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, |