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 <[email protected]>
---
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 41dc297..1202225 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)
--
1.7.10.4
------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel