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>
This commit is contained in:
parent
4ed1379fee
commit
3ed8040393
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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'
|
||||
|
Loading…
x
Reference in New Issue
Block a user