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 (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:
self, file (IO[bytes] | bytes), length (Optional[int]), kwargs (Any) → None
self, kwargs (Any) → None
Would pcapkit encounter malformed packets, the original parsing
error instance will be provided as in error.
- Parameters:
file (IO[bytes] | bytes | None) – Source packet stream.
length (int | None) – 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.
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: int | None
Original enumeration of this protocol.
-
error: Exception | None
error instance when parsing packet data