Base Protocol

pcapkit.protocols.internet.internet contains Internet, which is a base class for internet layer protocols, eg. AH, IPsec, IPv4, IPv6, IPX, and etc.

class pcapkit.protocols.internet.internet.Internet(file=None, length=None, **kwargs)[source]

Bases: ProtocolBase[_PT, _ST], Generic[_PT, _ST]

Abstract base class for internet layer protocol family.

This class parses the following protocols, which are registered in the self.__proto__ attribute:

property layer: Literal['Internet']

Protocol layer.

classmethod register(code, protocol)[source]

Register a new protocol class.

Notes

The fully qualified class name should be {protocol.module}.{protocol.name}.

Parameters:
Raises:

pcapkit.utilities.exceptions.RegistryError – If protocol is not a class, or not a Protocol subclass.

Warns:

pcapkit.utilities.warnings.RegistryWarning – If this protocol number is already registered, naming the displaced entry and its replacement so a caller can tell what was lost. Fires only when the incumbent differs from the replacement; see ProtocolBase.register for the guard this shares with register_protocol.

_decode_next_layer(dict_, proto=None, length=None, *, packet=None, version=4, ipv6_exthdr=None, payload=None)[source]

Decode next layer extractor.

Parameters:
Return type:

TypeVar(_PT, bound= Data)

Returns:

Current protocol with next layer extracted.

Notes

dict_ gains the key __next_type__ (next layer protocol type) and __next_name__ (next layer protocol name). Neither is included when Info.to_dict is called.

_import_next_layer(proto, length=None, *, packet=None, version=4, extension=False, payload=None)[source]

Import next layer extractor.

Parameters:
Return type:

ProtocolBase

Returns:

Instance of next layer.

__layer__: Literal['Internet']

Layer of protocol.

__proto__: DefaultDict[int, ModuleDescriptor[ProtocolBase] | Type[ProtocolBase]]

Protocol index mapping for decoding next layer, c.f. self._decode_next_layer & self._import_next_layer.

Type:

DefaultDict[int, ModuleDescriptor[ProtocolBase] | Type[ProtocolBase]]