summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYuichi Ito <ito.yuichi0@gmail.com>2013-12-12 15:33:05 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2013-12-12 18:21:59 +0900
commitf460bc61a0a84f9a887f2c599e3e8e7d0006322e (patch)
treeffbd26dd198c682e05a7b0196360034af8722e08
parent3731f46ba2ed6edff7fd3e3c4e2434c8b445f5df (diff)
packet lib: icmpv6: fix reversibility about json
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 <ito.yuichi0@gmail.com> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/lib/packet/icmpv6.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/ryu/lib/packet/icmpv6.py b/ryu/lib/packet/icmpv6.py
index d4bb00b9..54e36fa7 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)