summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYAMAMOTO Takashi <yamamoto@valinux.co.jp>2013-04-23 18:28:27 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2013-04-24 19:39:38 +0900
commit3ed8040393f560660343b4770e4d43f4fca006c3 (patch)
tree58a6c46d8f4da2307f122abd916a16aeb4403455
parent4ed1379fee1f4a43584291b46386aa84e028c2cf (diff)
ryu.lib.packet: docstring tweaks for better rendering
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/lib/packet/packet.py23
-rw-r--r--ryu/lib/packet/packet_base.py13
-rw-r--r--ryu/lib/packet/vrrp.py4
3 files changed, 17 insertions, 23 deletions
diff --git a/ryu/lib/packet/packet.py b/ryu/lib/packet/packet.py
index 95332667..84e5bf89 100644
--- a/ryu/lib/packet/packet.py
+++ b/ryu/lib/packet/packet.py
@@ -21,13 +21,17 @@ class Packet(object):
"""A packet decoder/encoder class.
An instance is used to either decode or encode a single packet.
+
+ *data* is a bytearray to describe a raw datagram to decode.
+ When decoding, a Packet object is iteratable.
+ Iterated values are protocol (ethernet, ipv4, ...) headers and the payload.
+ Protocol headers are instances of subclass of packet_base.PacketBase.
+ The payload is a bytearray. They are iterated in on-wire order.
+
+ *data* should be omitted when encoding a packet.
"""
def __init__(self, data=None):
- """*data* is a bytearray to describe a raw datagram to decode.
- *data* should be omitted when encoding a packet.
- """
-
super(Packet, self).__init__()
self.data = data
self.protocols = []
@@ -80,8 +84,6 @@ class Packet(object):
self.protocols.append(proto)
def next(self):
- """See __iter__."""
-
try:
p = self.protocols[self.protocol_idx]
except:
@@ -92,13 +94,4 @@ class Packet(object):
return p
def __iter__(self):
- """Iterate protocol (ethernet, ipv4, ...) headers and the payload.
-
- This method is legal only when decoding a packet.
-
- Protocol headers are instances of subclass of packet_base.PacketBase.
- The payload is a bytearray.
- They are iterated in on-wire order.
- """
-
return self
diff --git a/ryu/lib/packet/packet_base.py b/ryu/lib/packet/packet_base.py
index 8b932154..b0aeca0e 100644
--- a/ryu/lib/packet/packet_base.py
+++ b/ryu/lib/packet/packet_base.py
@@ -49,17 +49,18 @@ class PacketBase(object):
Returns the following two objects.
* An object to describe the decoded header.
- It should have the following attributes at least.
+ It should have the following attributes at least.
- =========== ============
- Attribute Description
- =========== ============
- length The number of the corresponding on-wire octets
- =========== ============
+ =========== ============
+ Attribute Description
+ =========== ============
+ length The number of the corresponding on-wire octets.
+ =========== ============
* A packet_base.PacketBase subclass appropriate for the rest of
the packet. None when the rest of the packet should be considered
as raw payload.
+
"""
pass
diff --git a/ryu/lib/packet/vrrp.py b/ryu/lib/packet/vrrp.py
index 6ce81ceb..7c50fed8 100644
--- a/ryu/lib/packet/vrrp.py
+++ b/ryu/lib/packet/vrrp.py
@@ -406,7 +406,7 @@ class vrrpv2(vrrp):
"""VRRPv2 (RFC 3768) header encoder/decoder class.
Unlike other ryu.lib.packet.packet_base.PacketBase derived classes,
- create method should be used to instantiate an object of this class.
+ *create* method should be used to instantiate an object of this class.
"""
_PACK_STR = '!BBBBBBH'
@@ -513,7 +513,7 @@ class vrrpv3(vrrp):
"""VRRPv3 (RFC 5798) header encoder/decoder class.
Unlike other ryu.lib.packet.packet_base.PacketBase derived classes,
- create method should be used to instantiate an object of this class.
+ *create* method should be used to instantiate an object of this class.
"""
_PACK_STR = '!BBBBHH'