dhcpkit_vpp.protocols.layer3 module

Classes and constants for layer 3 protocols

class dhcpkit_vpp.protocols.layer3.IPv6(traffic_class: int = 0, flow_label: int = 0, next_header: int = 0, hop_limit: int = 0, source: ipaddress.IPv6Address = None, destination: ipaddress.IPv6Address = None, payload: dhcpkit.protocol_element.ProtocolElement = None)[source]

Bases: dhcpkit_vpp.protocols.Layer3Packet

The class for IPv6 packets.

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

get_pseudo_header(l4_payload: dhcpkit_vpp.protocols.Layer4Protocol) → bytes[source]

Return the pseudo header for this protocol

Parameters:l4_payload – The payload protocol to calculate the pseudo header for
Returns:The pseudo header bytes
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

save() → bytearray[source]

Save the internal state of this object as a buffer.

Returns:The buffer with the data from this element
validate()[source]

Validate that the contents of this object conform to protocol specs.

class dhcpkit_vpp.protocols.layer3.UnknownLayer3Packet(data: bytes = b'')[source]

Bases: dhcpkit_vpp.protocols.Layer3Packet, 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

get_pseudo_header(for_payload: dhcpkit_vpp.protocols.Layer4Protocol) → bytes[source]

We don’t have a pseudo header

Parameters:for_payload – Get the pseudo header for the given layer 4 protocol
Returns:The pseudo header