diff options
author | watanabe.fumitaka <watanabe.fumitaka@nttcom.co.jp> | 2013-08-05 13:07:32 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2013-08-06 09:25:48 +0900 |
commit | 87cb024392b554ea98fd6aeddec251d1a8f4bd7a (patch) | |
tree | b2a8be0b28f66809645017acfa46a5897e159413 | |
parent | 2a60164b64f917d4ed7e9fc324011ca5f0a22c45 (diff) |
packet lib to string: inherits StringifyMixin
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 <watanabe.fumitaka@nttcom.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/lib/packet/dhcp.py | 6 | ||||
-rw-r--r-- | ryu/lib/packet/icmp.py | 7 | ||||
-rw-r--r-- | ryu/lib/packet/icmpv6.py | 7 | ||||
-rw-r--r-- | ryu/lib/packet/llc.py | 7 | ||||
-rw-r--r-- | ryu/lib/packet/lldp.py | 4 | ||||
-rw-r--r-- | 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 1783518a..3907c757 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 f90f45d6..eefde815 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 fe16d092..92a9f535 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 fccd39f9..085b2d58 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 cd13626a..41dc2977 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 e6774ba7..0731fd95 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 = {} |