mirror of
https://github.com/faucetsdn/ryu.git
synced 2026-05-08 13:56:09 +02:00
packet lib: llc: fix reversibility about json
although LLDP is using internal classes, no class is registered into '_class_prefixes'.
therefore, AssertionError occurs in from_jsondict() when the argument 'control' was processed.
this patch makes from_jsondict() to work correctly by registering internal classes into '_class_prefixes'.
examination code:
from ryu.lib.packet import llc
msg1 = llc.llc(dsap_addr=66, ssap_addr=66, control=llc.ControlFormatI())
print msg1
jsondict = msg1.to_jsondict()
msg2 = llc.llc.from_jsondict(jsondict['llc'])
print msg2
print str(msg1) == str(msg2)
before applying this patch:
llc(control=ControlFormatI(pf_bit=0,receive_sequence_number=0,send_sequence_number=0),dsap_addr=66,ssap_addr=66)
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/llc.py", line 140, in __init__
assert getattr(control, 'TYPE', None) in self._CTR_TYPES
AssertionError
after applying this patch:
llc(control=ControlFormatI(pf_bit=0,receive_sequence_number=0,send_sequence_number=0),dsap_addr=66,ssap_addr=66)
llc(control=ControlFormatI(pf_bit=0,receive_sequence_number=0,send_sequence_number=0),dsap_addr=66,ssap_addr=66)
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
c71af613c9
commit
95d482a7cc
@ -318,3 +318,4 @@ class ControlFormatU(stringify.StringifyMixin):
|
||||
|
||||
|
||||
llc.register_packet_type(bpdu.bpdu, SAP_BPDU)
|
||||
llc.set_classes(llc._CTR_TYPES)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user