dhcpkit_vpp.protocols.layer4 module¶
Classes and constants for layer 4 protocols
-
class
dhcpkit_vpp.protocols.layer4.
UDP
(source_port: int = 0, destination_port: int = 0, checksum: int = 0, payload: bytes = b'')[source]¶ Bases:
dhcpkit_vpp.protocols.Layer4Protocol
The class for UDP packets.
-
calculate_checksum
(l3_packet: dhcpkit_vpp.protocols.Layer3Packet)[source]¶ Calculate the checksum based on the current payload and the provided layer 3 packet.
Parameters: l3_packet – The layer 3 packet that contains this UDP message Returns: The calculated checksum
-
classmethod
determine_class
(buffer: bytes, offset: int = 0) → type[source]¶ Return the appropriate class to parse this element with.
Parameters: - buffer – The buffer to read data from
- offset – The offset in the buffer where to start reading
Returns: The best known class for this data
-
length
¶ Return the length of this protocol+payload
Returns: The length
-
load_from
(buffer: bytes, offset: int = 0, length: int = None) → int[source]¶ Load the internal state of this object from the given buffer. The buffer may contain more data after the structured element is parsed. This data is ignored.
Parameters: - buffer – The buffer to read data from
- offset – The offset in the buffer where to start reading
- length – The amount of data we are allowed to read from the buffer
Returns: The number of bytes used from the buffer
-
protocol_number
= 17¶
-
save
(zero_checksum: bool = False, recalculate_checksum_for: dhcpkit_vpp.protocols.Layer3Packet = None) → bytearray[source]¶ Save the internal state of this object as a buffer.
Parameters: - zero_checksum – Save with zeroes where the checksum should be
- recalculate_checksum_for – Recalculate the checksum for the given layer 3 packet headers
Returns: The buffer with the data from this element
-
-
class
dhcpkit_vpp.protocols.layer4.
UnknownLayer4Protocol
(data: bytes = b'')[source]¶ Bases:
dhcpkit_vpp.protocols.Layer4Protocol
,dhcpkit.protocol_element.UnknownProtocolElement
A layer 3 packet of unknown type
-
classmethod
determine_class
(buffer: bytes, offset: int = 0) → type[source]¶ Return the appropriate class to parse this element with.
Parameters: - buffer – The buffer to read data from
- offset – The offset in the buffer where to start reading
Returns: The best known class for this data
-
length
¶ The length of our data
Returns: The length
-
save
(zero_checksum: bool = False, recalculate_checksum_for: dhcpkit_vpp.protocols.Layer3Packet = None) → bytearray[source]¶ Save the internal state of this object as a buffer.
Parameters: - zero_checksum – Save with zeroes where the checksum should be
- recalculate_checksum_for – Recalculate the checksum for the given layer 3 packet headers
Returns: The buffer with the data from this element
-
classmethod