From e52b732840d68a5316ccb868dbf5c109144af753 Mon Sep 17 00:00:00 2001 From: Yuichi Ito Date: Thu, 12 Dec 2013 15:34:31 +0900 Subject: [PATCH] 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 Signed-off-by: FUJITA Tomonori --- ryu/lib/packet/lldp.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ryu/lib/packet/lldp.py b/ryu/lib/packet/lldp.py index 41dc2977..12022250 100644 --- a/ryu/lib/packet/lldp.py +++ b/ryu/lib/packet/lldp.py @@ -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)