Protocol Chain¶
pcapkit.corekit.protochain contains special protocol
collection class ProtoChain.
- class pcapkit.corekit.protochain.ProtoChain(proto, alias=None, *, basis=None)[source]¶
Bases:
SequenceProtocols chain.
- Parameters:
proto (
ProtocolBase|Type[ProtocolBase]) – New protocol class on the top stack.basis (
ProtoChain|None) – Original protocol chain as base stacks.proto – New protocol class on the top stack.
alias – New protocol alias on the top stack.
basis – Original protocol chain as base stacks.
- property protocols: tuple[Type[ProtocolBase], ...][source]¶
List of protocols in the chain.
- classmethod from_list(data)[source]¶
Create a protocol chain from a list.
- Parameters:
data (
list[ProtocolBase|Type[ProtocolBase]]) – Protocol chain list.- Return type:
Self
- index(value, start=None, stop=None)[source]¶
First index of
value.- Parameters:
value (
str|ProtocolBase|Type[ProtocolBase]) – Value to search.
- Raises:
IndexNotFound – If the value is not present.
- Return type:
- count(value)[source]¶
Number of occurrences of
value.- Parameters:
value (
str|ProtocolBase|Type[ProtocolBase]) – Value to search.- Return type:
- __str__()[source]¶
Returns formatted hex representation of source data stream.
Example
>>> protochain ProtoChain(Ethernet, IPv6, Raw) >>> print(protochain) Ethernet:IPv6:Raw
- Return type:
- __repr__()[source]¶
Returns representation of protocol chain data.
Example
>>> protochain ProtoChain(Ethernet, IPv6, Raw)
- Return type:
- __add__(other)[source]¶
Merge protocol chain by appending protocols from
other.- Parameters:
other (
ProtoChain) – Protocol chain to be merged.- Return type:
- Returns:
Merged protocol chain.
- __contains__(name)[source]¶
Returns if
nameis in the chain.- Parameters:
name (
str|ProtocolBase|Type[ProtocolBase]) – Name to search.- Return type:
- Returns:
Whether
nameis in the chain.