Some class inherits stringify.StringifyMixin

and, remove class variable 'tlvs' (not used as class variable
and interferes to string) from lldp.lldp


Signed-off-by: WATANABE Fumitaka <[email protected]>
---
 ryu/lib/packet/dhcp.py        |    6 ++++--
 ryu/lib/packet/icmp.py        |    7 ++++---
 ryu/lib/packet/icmpv6.py      |    7 ++++---
 ryu/lib/packet/llc.py         |    7 ++++---
 ryu/lib/packet/lldp.py        |    4 ++--
 ryu/lib/packet/packet_base.py |    3 ++-
 6 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/ryu/lib/packet/dhcp.py b/ryu/lib/packet/dhcp.py
index 1783518..3907c75 100644
--- a/ryu/lib/packet/dhcp.py
+++ b/ryu/lib/packet/dhcp.py
@@ -58,6 +58,8 @@ import socket
 import struct

 from . import packet_base
+from ryu.lib import stringify
+

 DHCP_BOOT_REQUEST = 1
 DHCP_BOOT_REPLY = 2
@@ -190,7 +192,7 @@ class dhcp(packet_base.PacketBase):
                            self.chaddr, self.sname, self.boot_file, seri_opt)


-class options(object):
+class options(stringify.StringifyMixin):
     """DHCP (RFC 2132) options encoder/decoder class.

     This is used with ryu.lib.packet.dhcp.dhcp.
@@ -250,7 +252,7 @@ class options(object):
         return seri_opt


-class option(object):
+class option(stringify.StringifyMixin):
     """DHCP (RFC 2132) options encoder/decoder class.

     This is used with ryu.lib.packet.dhcp.dhcp.options.
diff --git a/ryu/lib/packet/icmp.py b/ryu/lib/packet/icmp.py
index f90f45d..eefde81 100644
--- a/ryu/lib/packet/icmp.py
+++ b/ryu/lib/packet/icmp.py
@@ -17,6 +17,7 @@ import struct

 from . import packet_base
 from . import packet_utils
+from ryu.lib import stringify


 ICMP_ECHO_REPLY = 0
@@ -114,7 +115,7 @@ class icmp(packet_base.PacketBase):


 @icmp.register_icmp_type(ICMP_ECHO_REPLY, ICMP_ECHO_REQUEST)
-class echo(object):
+class echo(stringify.StringifyMixin):
     """ICMP sub encoder/decoder class for Echo and Echo Reply messages.

     This is used with ryu.lib.packet.icmp.icmp for
@@ -164,7 +165,7 @@ class echo(object):


 @icmp.register_icmp_type(ICMP_DEST_UNREACH)
-class dest_unreach(object):
+class dest_unreach(stringify.StringifyMixin):
     """ICMP sub encoder/decoder class for Destination Unreachable Message.

     This is used with ryu.lib.packet.icmp.icmp for
@@ -220,7 +221,7 @@ class dest_unreach(object):


 @icmp.register_icmp_type(ICMP_TIME_EXCEEDED)
-class TimeExceeded(object):
+class TimeExceeded(stringify.StringifyMixin):
     """ICMP sub encoder/decoder class for Time Exceeded Message.

     This is used with ryu.lib.packet.icmp.icmp for
diff --git a/ryu/lib/packet/icmpv6.py b/ryu/lib/packet/icmpv6.py
index fe16d09..92a9f53 100644
--- a/ryu/lib/packet/icmpv6.py
+++ b/ryu/lib/packet/icmpv6.py
@@ -21,6 +21,7 @@ import binascii
 from . import packet_base
 from . import packet_utils
 from ryu.lib import addrconv
+from ryu.lib import stringify

 ICMPV6_DST_UNREACH = 1       # dest unreachable, codes:
 ICMPV6_PACKET_TOO_BIG = 2       # packet too big
@@ -125,7 +126,7 @@ class icmpv6(packet_base.PacketBase):


 @icmpv6.register_icmpv6_type(ND_NEIGHBOR_SOLICIT, ND_NEIGHBOR_ADVERT)
-class nd_neighbor(object):
+class nd_neighbor(stringify.StringifyMixin):
     """ICMPv6 sub encoder/decoder class for Neighbor Solicitation and
     Neighbor Advertisement messages. (RFC 4861)

@@ -210,7 +211,7 @@ class nd_neighbor(object):

 @nd_neighbor.register_nd_option_type(nd_neighbor.ND_OPTION_SLA,
                                      nd_neighbor.ND_OPTION_TLA)
-class nd_option_la(object):
+class nd_option_la(stringify.StringifyMixin):
     """ICMPv6 sub encoder/decoder class for Neighbor discovery
     Source/Target Link-Layer Address Option. (RFC 4861)

@@ -263,7 +264,7 @@ class nd_option_la(object):


 @icmpv6.register_icmpv6_type(ICMPV6_ECHO_REPLY, ICMPV6_ECHO_REQUEST)
-class echo(object):
+class echo(stringify.StringifyMixin):
     """ICMPv6 sub encoder/decoder class for Echo Request and Echo Reply
     messages.

diff --git a/ryu/lib/packet/llc.py b/ryu/lib/packet/llc.py
index fccd39f..085b2d5 100644
--- a/ryu/lib/packet/llc.py
+++ b/ryu/lib/packet/llc.py
@@ -90,6 +90,7 @@ Control field
 import struct
 from . import bpdu
 from . import packet_base
+from ryu.lib import stringify


 SAP_BDPU = 0x42
@@ -164,7 +165,7 @@ class llc(packet_base.PacketBase):


 @llc.register_control_type
-class ControlFormatI(object):
+class ControlFormatI(stringify.StringifyMixin):
     """LLC sub encoder/decoder class for control I-format field.

     An instance has the following attributes at least.
@@ -213,7 +214,7 @@ class ControlFormatI(object):


 @llc.register_control_type
-class ControlFormatS(object):
+class ControlFormatS(stringify.StringifyMixin):
     """LLC sub encoder/decoder class for control S-format field.

     An instance has the following attributes at least.
@@ -265,7 +266,7 @@ class ControlFormatS(object):


 @llc.register_control_type
-class ControlFormatU(object):
+class ControlFormatU(stringify.StringifyMixin):
     """LLC sub encoder/decoder class for control U-format field.

     An instance has the following attributes at least.
diff --git a/ryu/lib/packet/lldp.py b/ryu/lib/packet/lldp.py
index cd13626..41dc297 100644
--- a/ryu/lib/packet/lldp.py
+++ b/ryu/lib/packet/lldp.py
@@ -41,6 +41,7 @@ optional TLV may be inserted in any order
 """

 import struct
+from ryu.lib import stringify
 from ryu.lib.packet import packet_base


@@ -70,7 +71,7 @@ LLDP_TLV_MANAGEMENT_ADDRESS = 8         # Management Address
 LLDP_TLV_ORGANIZATIONALLY_SPECIFIC = 127  # organizationally Specific TLVs


-class LLDPBasicTLV(object):
+class LLDPBasicTLV(stringify.StringifyMixin):
     _LEN_MIN = 0
     _LEN_MAX = 511
     tlv_type = None
@@ -106,7 +107,6 @@ class LLDPBasicTLV(object):

 class lldp(packet_base.PacketBase):
     _tlv_parsers = {}
-    tlvs = []

     def __init__(self, tlvs):
         super(lldp, self).__init__()
diff --git a/ryu/lib/packet/packet_base.py b/ryu/lib/packet/packet_base.py
index e6774ba..0731fd9 100644
--- a/ryu/lib/packet/packet_base.py
+++ b/ryu/lib/packet/packet_base.py
@@ -14,9 +14,10 @@
 # limitations under the License.

 import abc
+from ryu.lib import stringify


-class PacketBase(object):
+class PacketBase(stringify.StringifyMixin):
     """A base class for a protocol (ethernet, ipv4, ...) header."""
     __metaclass__ = abc.ABCMeta
     _TYPES = {}
-- 1.7.10.4


------------------------------------------------------------------------------
Get your SQL database under version control now!
Version control is standard for application code, but databases havent 
caught up. So what steps can you take to put your SQL databases under 
version control? Why should you start doing it? Read more to find out.
http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to