although ICMPv6 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 icmpv6
    msg1 = icmpv6.icmpv6(data=icmpv6.nd_neighbor())
    print msg1
    jsondict = msg1.to_jsondict()
    msg2 = icmpv6.icmpv6.from_jsondict(jsondict['icmpv6'])
    print msg2
    print str(msg1) == str(msg2)

before applying this patch:

    icmpv6(code=0,csum=0,data=nd_neighbor(dst='::',option=None,res=0),type_=0)
    icmpv6(code=0,csum=0,data={'nd_neighbor': {'res': 0, 'dst': '::', 'option': 
None}},type_=0)
    False

after applying this patch:

    icmpv6(code=0,csum=0,data=nd_neighbor(dst='::',option=None,res=0),type_=0)
    icmpv6(code=0,csum=0,data=nd_neighbor(dst='::',option=None,res=0),type_=0)
    True

Signed-off-by: Yuichi Ito <[email protected]>
---
 ryu/lib/packet/icmpv6.py |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/ryu/lib/packet/icmpv6.py b/ryu/lib/packet/icmpv6.py
index d4bb00b..54e36fa 100644
--- a/ryu/lib/packet/icmpv6.py
+++ b/ryu/lib/packet/icmpv6.py
@@ -642,3 +642,9 @@ class echo(stringify.StringifyMixin):
         if self.data is not None:
             length += len(self.data)
         return length
+
+
+icmpv6.set_classes(icmpv6._ICMPV6_TYPES)
+nd_neighbor.set_classes(nd_neighbor._ND_OPTION_TYPES)
+nd_router_solicit.set_classes(nd_router_solicit._ND_OPTION_TYPES)
+nd_router_advert.set_classes(nd_router_advert._ND_OPTION_TYPES)
-- 
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

Reply via email to