Raw Packet Data
pcapkit.protocols.misc.raw contains
Raw only, which implements
an extractor for unknown protocols, 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 (int | None) – Length of packet data.
error (Exception | None) – Parsing errors if any.
alias (int | None) – 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:
-
- 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.
- Overloads:
-
When pcapkit meets a malformed packet, the original parsing
error instance is given as error.
- Parameters:
file (IO[bytes] | bytes | None) – Source packet stream.
length (int | None) – Length of packet data.
error – Parsing error if any (for parsing), an Exception
instance or None.
alias – Original enumeration of the unknown protocol, an int
or None.
**kwargs (Any) – Arbitrary keyword arguments.
See also
For construction arguments, 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(packet=NO_VALUE, *, __packet__=None, **kwargs)[source]
Bases: Schema
Schema for raw packet.
-
packet: bytes = <PayloadField packet>
Packet data.
Data Models
-
class pcapkit.protocols.data.misc.raw.Raw(protocol, error)[source]
Bases: Protocol
Raw packet is an unknown protocol.
Changed in version 1.3.1.post8: packet is not a field of this class, so its constructor takes
protocol and error only.
ProtocolBase sets packet on
the data model of every protocol it constructs.
-
protocol: int | None
Original enumeration of this protocol.
-
error: Exception | None
error instance when parsing packet data