lldp: fixed SystemCapabilities TLV
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_miko1@o2.pl> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
parent
c29c9019ac
commit
99fc573a9c
@ -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)
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user