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 currently supports parsing of 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 full qualified class name of the new protocol class should be as {protocol.module}.{protocol.name}.

Parameters:
Return type:

None

_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

We added a new key __next_type__ to dict_ to store the next layer protocol type, and a new key __next_name__ to store the next layer protocol name. These two keys will NOT be 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__: Optional[Literal["Link", "Internet", "Transport", "Application"]]

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[Protocol] | Type[Protocol]]