Application Layer Base Protocol

pcapkit.protocols.application.application contains only Application, which is a base class for application layer protocols, e.g. HTTP/1.* and HTTP/2.

Changed in version 1.5.0: _decode_next_layer() and _import_next_layer() accept the -1 sentinel, so an application layer protocol can carry the rest of its packet undissected as its payload; every call raised UnsupportedCall (#719).

class pcapkit.protocols.application.application.Application[_PT: Data, _ST: Schema](file=None, length=None, **kwargs)[source]

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

Abstract base class for application layer protocol family.

An application layer protocol has no protocol layer above it, so _decode_next_layer() and _import_next_layer() refuse a protocol number. They accept only the -1 sentinel, which resolves the rest of the packet to Raw, or to NoPayload when nothing remains. A subclass may dissect the rest instead, as TLS, SSLv2 and DTLS do for a further record and HTTPv2 for a further frame.

__layer__: Literal['Application']

Layer of protocol.

property layer: Literal['Application']

Protocol layer.

__post_init__(file=None, length=None, **kwargs)[source]

Post initialisation hook.

Overloads:
Parameters:
  • file (IO[bytes] | bytes | None) – Source packet stream.

  • length (int | None) – Length of packet data.

  • **kwargs (Any) – Arbitrary keyword arguments.

See also

self.make for the construction arguments.

classmethod __index__()[source]

Numeral registry index of the protocol.

Raises:

IntError – This protocol doesn’t support __index__().

Return type:

NoReturn

_decode_next_layer(dict_, proto=None, length=None, *, packet=None)[source]

Decode next layer protocol.

Parameters:
  • dict_ (_PT) – info buffer

  • proto (int | None) – next layer protocol index; only the -1 sentinel (the rest, undissected) is accepted

  • length (int | None) – valid (non-padding) length

  • packet (dict[str, Any] | None) – packet info (passed from self.unpack)

Return type:

_PT

Returns:

Current protocol with the undissected remainder as payload.

Raises:

UnsupportedCall – If proto is anything but -1, i.e. a real protocol dispatch, which this protocol doesn’t support.

_import_next_layer(proto, length=None, *, packet=None)[source]

Import next layer extractor.

Parameters:
  • proto (int) – next layer protocol index; only the -1 sentinel (the rest, undissected) is accepted

  • length (int | None) – valid (non-padding) length

  • packet (dict[str, Any] | None) – packet info (passed from self.unpack)

Return type:

ProtocolBase

Returns:

Instance of Raw, or of NoPayload when nothing remains.

Raises:

UnsupportedCall – If proto is anything but -1, i.e. a real protocol dispatch, which this protocol doesn’t support.