this set is the upgrade of the following patch:
http://www.mail-archive.com/[email protected]/msg04444.html

Changes v2 -> v3:

- rebase
- remove patches about improving display (due to send separately)
- simplify the unittests
- make BPDU and LACP reversible


this set fixes reversibility of the packet libraries about json.

each class of the packet libraries inherits stringify.StringifyMixin, so 
provides from_jsondict() and to_jsondict().
to_jsondict() makes a JSON dictionary from the object.
from_jsondict() makes an object from the JSON dictionary.
the JSON dictionary and the object should be mutually reversible.

but some classes of the packet libraries are irreversible because of following:
 - lack of the registration of inner classes into '_class_prefixes'
 - generation of the unnecessary arguments for the constructor by to_jsondict()

NOTE: the variable '_class_prefixes' of stringify.StringifyMixin is used to 
help from_jsondict() to create the class instance.

the classes that are not reversible for the former reason are:
 - BGP, DHCP, ICMP, ICMPv6, IPv6, LLC, LLDP, SCTP
the classes that are not reversible for the latter reason are:
 - BPDU, LACP

this set makes the classes reversible about json by adding inner class names 
into '_class_prefixes' or suppressing the output of the unnecessary members.

for example, the result of stringify BGPUpdate is:
    
BGPUpdate(len=None,marker='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff',nlri=[],path_attributes=[],total_path_attribute_len=None,type=2,withdrawn_routes=[BGPWithdrawnRoute(addr='192.168.0.1',length=0)],withdrawn_routes_len=None)

when using from_jsondict() before applying this set, the result is:
    
BGPUpdate(len=None,marker='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff',nlri=[],path_attributes=[],total_path_attribute_len=None,type=2,withdrawn_routes=[{'BGPWithdrawnRoute':
 {'length': 0, 'addr': '192.168.0.1'}}],withdrawn_routes_len=None)

the result after applying this set is:
    
BGPUpdate(len=None,marker='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff',nlri=[],path_attributes=[],total_path_attribute_len=None,type=2,withdrawn_routes=[BGPWithdrawnRoute(addr='192.168.0.1',length=0)],withdrawn_routes_len=None)


TODO: make VRRP reversible.
since VRRP has an unusual construction method, VRRP is not reversible about 
json.


Yuichi Ito (12):
  packet lib: packet_base: add a method which makes '_class_prefixes'
    easy to use
  packet lib: bgp: fix reversibility about json
  packet lib: bpdu: fix reversibility about json
  packet lib: dhcp: fix reversibility about json
  packet lib: icmp: fix reversibility about json
  packet lib: icmpv6: fix reversibility about json
  packet lib: ipv6: fix reversibility about json
  packet lib: llc: fix reversibility about json
  packet lib: lldp: fix reversibility about json
  packet lib: sctp: fix reversibility about json
  packet lib: slow: fix reversibility about json
  packet lib: add unittests for reversibility about json

 ryu/lib/packet/bgp.py                  |   13 +++--
 ryu/lib/packet/bpdu.py                 |   14 +++---
 ryu/lib/packet/dhcp.py                 |    7 +--
 ryu/lib/packet/icmp.py                 |   10 ++--
 ryu/lib/packet/icmpv6.py               |   17 ++++---
 ryu/lib/packet/ipv6.py                 |    9 ++--
 ryu/lib/packet/llc.py                  |    8 +--
 ryu/lib/packet/lldp.py                 |    6 ++-
 ryu/lib/packet/packet_base.py          |   12 ++++-
 ryu/lib/packet/sctp.py                 |   11 +++--
 ryu/lib/packet/slow.py                 |   40 +++++++--------
 ryu/tests/unit/packet/test_arp.py      |    5 ++
 ryu/tests/unit/packet/test_bgp.py      |   85 ++++++++++++++++++++++++++++++++
 ryu/tests/unit/packet/test_bpdu.py     |   54 ++++++++++++++++++++
 ryu/tests/unit/packet/test_dhcp.py     |    5 ++
 ryu/tests/unit/packet/test_ethernet.py |    5 ++
 ryu/tests/unit/packet/test_icmp.py     |   17 +++++++
 ryu/tests/unit/packet/test_icmpv6.py   |   37 ++++++++++++++
 ryu/tests/unit/packet/test_igmp.py     |    5 ++
 ryu/tests/unit/packet/test_ipv4.py     |    5 ++
 ryu/tests/unit/packet/test_ipv6.py     |   25 ++++++++++
 ryu/tests/unit/packet/test_llc.py      |   42 ++++++++++++++++
 ryu/tests/unit/packet/test_lldp.py     |   43 ++++++++++++++++
 ryu/tests/unit/packet/test_mpls.py     |    5 ++
 ryu/tests/unit/packet/test_packet.py   |   11 ++---
 ryu/tests/unit/packet/test_pbb.py      |    5 ++
 ryu/tests/unit/packet/test_sctp.py     |   69 ++++++++++++++++++++++++++
 ryu/tests/unit/packet/test_slow.py     |   70 ++++++++++++++------------
 ryu/tests/unit/packet/test_tcp.py      |    5 ++
 ryu/tests/unit/packet/test_udp.py      |    5 ++
 ryu/tests/unit/packet/test_vlan.py     |   10 ++++
 31 files changed, 557 insertions(+), 98 deletions(-)
 create mode 100644 ryu/tests/unit/packet/test_bpdu.py
 create mode 100644 ryu/tests/unit/packet/test_llc.py

--
1.7.10.4


------------------------------------------------------------------------------
Sponsored by Intel(R) XDK 
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to