Raw Packet Data

pcapkit.protocols.misc.raw contains Raw only, which implements extractor for unknown protocol, and constructs a Protocol like object.

class pcapkit.protocols.misc.raw.Raw(file=None, length=None, **kwargs)[source]

Bases: ProtocolBase[Raw, Raw]

This class implements universal unknown protocol.

property name: Literal['Unknown']

Name of current protocol.

property length: Literal[0]

Header length of current protocol.

property protocol: NoReturn

Name of next layer protocol.

Raises:

UnsupportedCall – This protocol doesn’t support protocol.

read(length=None, *, error=None, alias=None, **kwargs)[source]

Read raw packet data.

Parameters:
  • length (Optional[int]) – Length of packet data.

  • error (Optional[Exception]) – Parsing errors if any.

  • alias (Optional[int]) – Original enumeration of the unknown protocol.

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

Return type:

Raw

Returns:

The parsed packet data.

make(packet=b'', **kwargs)[source]

Make raw packet data.

Parameters:
  • packet (bytes) – Raw packet data.

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

Return type:

Raw

Returns:

Constructed packet schema.

classmethod _make_data(data)[source]

Create key-value pairs from data for protocol construction.

Parameters:

data (Raw) – protocol data

Return type:

dict[str, Any]

Returns:

Key-value pairs for protocol construction.

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

Post initialisation hook.

Would pcapkit encounter malformed packets, the original parsing error instance will be provided as in error.

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

  • length (Optional[int]) – Length of packet data.

  • error (Optional[Exception]) – Parsing errors if any (for parsing).

  • alias (Optional[int]) – Original enumeration of the unknown protocol.

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

Return type:

None

See also

For construction argument, please refer to make().

classmethod __index__()[source]

Numeral registry index of the protocol.

Raises:

UnsupportedCall – This protocol has no registry entry.

Return type:

NoReturn

Header Schemas

class pcapkit.protocols.schema.misc.raw.Raw(dict_=None, **kwargs)[source]

Bases: Schema

Schema for raw packet.

packet: bytes = <PayloadField packet>

Packet data.

Data Models

class pcapkit.protocols.data.misc.raw.Raw(*args: VT, **kwargs: VT)[source]

Bases: Protocol

Raw packet is an unknown protocol.

protocol: Optional[int]

Original enumeration of this protocol.

error: Optional[Exception]

error instance when parsing packet data