summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-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'