mirror of
https://github.com/faucetsdn/ryu.git
synced 2026-05-08 22:06:10 +02:00
packet lib: lldp: fix reversibility about json
although LLDP is using internal classes, no class is registered into '_class_prefixes'.
therefore, from_jsondict() does not work correctly.
this patch makes from_jsondict() to work correctly by registering internal classes into '_class_prefixes'.
examination code:
from ryu.lib.packet import lldp
msg1 = lldp.lldp([lldp.ChassisID(subtype=lldp.ChassisID.SUB_MAC_ADDRESS, chassis_id='\x00\x00\x00\x00\x00\x00')])
print msg1
jsondict = msg1.to_jsondict()
msg2 = lldp.lldp.from_jsondict(jsondict['lldp'])
print msg2
print str(msg1) == str(msg2)
before applying this patch:
lldp(tlvs=[ChassisID(chassis_id='\x00\x00\x00\x00\x00\x00',len=7,subtype=4,typelen=519)])
lldp(tlvs=[{'ChassisID': {'subtype': 4, 'typelen': 519, 'chassis_id': '\x00\x00\x00\x00\x00\x00', 'len': 7}}])
False
after applying this patch:
lldp(tlvs=[ChassisID(chassis_id='\x00\x00\x00\x00\x00\x00',len=7,subtype=4,typelen=519)])
lldp(tlvs=[ChassisID(chassis_id='\x00\x00\x00\x00\x00\x00',len=7,subtype=4,typelen=519)])
True
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
parent
95d482a7cc
commit
e52b732840
@ -482,3 +482,6 @@ class OrganizationallySpecific(LLDPBasicTLV):
|
||||
|
||||
def serialize(self):
|
||||
return struct.pack('!H3sB', self.typelen, self.oui, self.subtype)
|
||||
|
||||
|
||||
lldp.set_classes(lldp._tlv_parsers)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user