44"""
55
66from pyof .foundation .base import GenericStruct
7- from pyof .foundation .basic_types import (BinaryData , HWAddress , IPAddress ,
8- UBInt8 , UBInt16 )
7+ from pyof .foundation .basic_types import (
8+ BinaryData , HWAddress , IPAddress , UBInt8 , UBInt16 )
99from pyof .foundation .exceptions import PackException
1010
1111__all__ = ('Ethernet' , 'GenericTLV' , 'IPv4' , 'TLVWithSubType' , 'LLDP' )
@@ -140,7 +140,7 @@ def get_size(self, value=None):
140140
141141
142142class IPv4 (GenericStruct ):
143- """IPv4 packet "struct"
143+ """IPv4 packet "struct".
144144
145145 Contains all fields of an IP version 4 packet header, plus the upper layer
146146 content as binary data.
@@ -197,7 +197,7 @@ def __init__(self, version=4, ihl=5, dscp=0, ecn=0, length=0, # noqa
197197 self .data = data
198198
199199 def _update_checksum (self ):
200- """Updates the packet checksum to enable integrity check."""
200+ """Update the packet checksum to enable integrity check."""
201201 source_list = [int (octet ) for octet in self .source .split ("." )]
202202 destination_list = [int (octet ) for octet in
203203 self .destination .split ("." )]
@@ -218,6 +218,10 @@ def _update_checksum(self):
218218 self .checksum = ~ block_sum & 65535
219219
220220 def pack (self , value = None ):
221+ """Pack the struct in a binary representation.
222+
223+ Merge some fields to ensure correct packing.
224+ """
221225 # Set the correct IHL based on options size
222226 if self .options :
223227 self .ihl += int (len (self .options ) / 4 )
@@ -235,6 +239,10 @@ def pack(self, value=None):
235239 return super ().pack ()
236240
237241 def unpack (self , buff , offset = 0 ):
242+ """Unpack a binary struct into this object's attributes.
243+
244+ Return the values instead of the lib's basic types.
245+ """
238246 super ().unpack (buff , offset )
239247
240248 self .version = self ._version_ihl .value >> 4
0 commit comments