Fix: LLDP.OrganizationallySpecific not ignoring info field

LLDP.OrganizationallySpecificTLV did not set info field and produced
malformed LLDP packets

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
Jonas Grunert 2016-07-14 17:34:15 +09:00 committed by FUJITA Tomonori
parent b09b39c11d
commit 99d641c7d4

View File

@ -479,6 +479,7 @@ class OrganizationallySpecific(LLDPBasicTLV):
if buf:
(self.oui, self.subtype) = struct.unpack(
self._PACK_STR, self.tlv_info[:self._PACK_SIZE])
self.info = self.tlv_info[self._PACK_SIZE:]
else:
self.oui = kwargs['oui']
self.subtype = kwargs['subtype']
@ -488,7 +489,8 @@ class OrganizationallySpecific(LLDPBasicTLV):
self.typelen = (self.tlv_type << LLDP_TLV_TYPE_SHIFT) | self.len
def serialize(self):
return struct.pack('!H3sB', self.typelen, self.oui, self.subtype)
return struct.pack('!H3sB', self.typelen, self.oui,
self.subtype) + self.info
lldp.set_classes(lldp._tlv_parsers)