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

Changes v3 -> v4:

- simplify the implementation of the method 'set_classes' as:
  * move the method from packet_base to stringify
  * delete the unnecessary initialization
  * use dict.extend() instead of sorted() and set() to avoid duplications


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                  |    4 ++
 ryu/lib/packet/bpdu.py                 |   14 +++---
 ryu/lib/packet/dhcp.py                 |    2 +
 ryu/lib/packet/icmp.py                 |    3 ++
 ryu/lib/packet/icmpv6.py               |    6 +++
 ryu/lib/packet/ipv6.py                 |    4 ++
 ryu/lib/packet/llc.py                  |    1 +
 ryu/lib/packet/lldp.py                 |    3 ++
 ryu/lib/packet/sctp.py                 |    4 ++
 ryu/lib/packet/slow.py                 |   40 +++++++--------
 ryu/lib/stringify.py                   |    5 ++
 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, 528 insertions(+), 66 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


------------------------------------------------------------------------------
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

Reply via email to