Raw Packet Data
pcapkit.protocols.misc.raw.protocol contains
Raw only, which implements
an extractor for unknown protocols, and constructs a
Protocol like object.
-
class pcapkit.protocols.misc.raw.protocol.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 (str | None) – Message saying why the data is kept raw, 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.
-
__post_init__(file=None, length=None, **kwargs)[source]
Post initialisation hook.
- Overloads:
-
When pcapkit meets a malformed packet, or a layer past a
dissection limit, the message saying so is given as error.
- Parameters:
file (IO[bytes] | bytes | None) – Source packet stream.
length (int | None) – Length of packet data.
error – Message saying why the data is kept raw, if any (for
parsing), a str 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
-
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.
Header Schemas
Removed in version 1.6.0: pcapkit.protocols.schema.misc.raw, with no alias: the module moved here
(#2534).
-
class pcapkit.protocols.misc.raw.schema.Raw(packet=NO_VALUE, *, __packet__=None, **kwargs)[source]
Bases: Schema
Schema for raw packet.
-
packet: bytes = <PayloadField packet>
Packet data.
Data Models
Removed in version 1.6.0: pcapkit.protocols.data.misc.raw, with no alias: the module moved here
(#2534).
-
class pcapkit.protocols.misc.raw.data.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: str | None
Message saying why the packet data is kept raw, if any – that of the error its
parse raised, or the dissection limit it is past.