although IPv6 is using internal classes, no class is registered into
'_class_prefixes'.
therefore, AssertionError occurs in from_jsondict() when the argument
'ext_hdrs' was processed.
this patch makes from_jsondict() to work correctly by registering internal
classes into '_class_prefixes'.
examination code:
from ryu.lib.packet import ipv6
msg1 = ipv6.ipv6(ext_hdrs=[ipv6.hop_opts()])
print msg1
jsondict = msg1.to_jsondict()
msg2 = ipv6.ipv6.from_jsondict(jsondict['ipv6'])
print msg2
print str(msg1) == str(msg2)
before applying this patch:
ipv6(dst='::',ext_hdrs=[hop_opts(data=None,nxt=6,size=0)],flow_label=0,hop_limit=255,nxt=6,payload_length=0,src='::',traffic_class=0,version=6)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/ryu/lib/stringify.py", line
293, in from_jsondict
return cls(**dict(kwargs, **additional_args))
File "/usr/local/lib/python2.7/dist-packages/ryu/lib/packet/ipv6.py",
line 86, in __init__
assert isinstance(ext_hdr, header)
AssertionError
after applying this patch:
ipv6(dst='::',ext_hdrs=[hop_opts(data=None,nxt=6,size=0)],flow_label=0,hop_limit=255,nxt=6,payload_length=0,src='::',traffic_class=0,version=6)
ipv6(dst='::',ext_hdrs=[hop_opts(data=None,nxt=6,size=0)],flow_label=0,hop_limit=255,nxt=6,payload_length=0,src='::',traffic_class=0,version=6)
True
Signed-off-by: Yuichi Ito <[email protected]>
---
ryu/lib/packet/ipv6.py | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/ryu/lib/packet/ipv6.py b/ryu/lib/packet/ipv6.py
index f5ee038..9f04da5 100644
--- a/ryu/lib/packet/ipv6.py
+++ b/ryu/lib/packet/ipv6.py
@@ -173,6 +173,7 @@ class opt_header(header):
_PACK_STR = '!BB'
_MIN_LEN = struct.calcsize(_PACK_STR)
_FIX_SIZE = 8
+ _class_prefixes = ['option']
@abc.abstractmethod
def __init__(self, nxt, size, data):
@@ -434,3 +435,6 @@ class auth(header):
def __len__(self):
return auth._get_size(self.size)
+
+
+ipv6.set_classes(ipv6._IPV6_EXT_HEADER_TYPE)
--
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