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 (
Union[ProtocolBase,Type[ProtocolBase]]) – New protocol class on the top stack.alias (
Optional[str]) – New protocol alias on the top stack.basis (
Optional[ProtoChain]) – 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[Union[ProtocolBase,Type[ProtocolBase]]]) – Protocol chain list.- Return type:
Self
- index(value, start=None, stop=None)[source]¶
First index of
value.- Parameters:
value (
Union[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 (
Union[str,ProtocolBase,Type[ProtocolBase]]) – Value to search.- Return type:
- __str__()[source]¶
Returns formatted hex representation of source data stream. :rtype:
strExample
>>> protochain ProtoChain(Ethernet, IPv6, Raw) >>> print(protochain) Ethernet:IPv6:Raw
- __repr__()[source]¶
Returns representation of protocol chain data. :rtype:
strExample
>>> protochain ProtoChain(Ethernet, IPv6, Raw)
- __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 (
Union[str,ProtocolBase,Type[ProtocolBase]]) – Name to search.- Return type:
- Returns:
Whether
nameis in the chain.