mirror of
https://github.com/faucetsdn/ryu.git
synced 2026-05-08 13:56:09 +02:00
packet lib: icmp: fix reversibility about json
although ICMP 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 icmp
msg1 = icmp.icmp(data=icmp.echo())
print msg1
jsondict = msg1.to_jsondict()
msg2 = icmp.icmp.from_jsondict(jsondict['icmp'])
print msg2
print str(msg1) == str(msg2)
before applying this patch:
icmp(code=0,csum=0,data=echo(data=None,id=0,seq=0),type=8)
icmp(code=0,csum=0,data={'echo': {'data': None, 'id': 0, 'seq': 0}},type=8)
False
after applying this patch:
icmp(code=0,csum=0,data=echo(data=None,id=0,seq=0),type=8)
icmp(code=0,csum=0,data=echo(data=None,id=0,seq=0),type=8)
True
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
parent
8cee77dad1
commit
3731f46ba2
@ -300,3 +300,6 @@ class TimeExceeded(stringify.StringifyMixin):
|
||||
if self.data is not None:
|
||||
length += len(self.data)
|
||||
return length
|
||||
|
||||
|
||||
icmp.set_classes(icmp._ICMP_TYPES)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user