Protocol Chain
pcapkit.corekit.protochain
contains special protocol
collection class ProtoChain
.
-
class pcapkit.corekit.protochain.ProtoChain(proto, alias=None, *, basis=None)[source]
Bases: Sequence
Protocols chain.
- Parameters
proto (Protocol | Type[Protocol]) – 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.
-
property protocols: tuple[Type[Protocol], ...]
List of protocols in the chain.
-
property aliases: tuple[str, ...]
Protocol names.
-
property chain: str
Protocol chain string.
- Return type
str
-
classmethod from_list(data)[source]
Create a protocol chain from a list.
- Parameters
data (list[Protocol | Type[Protocol]]) – Protocol chain list.
- Return type
ProtoChain
-
index(value, start=None, stop=None)[source]
First index of value
.
- Parameters
-
- Raises
IndexNotFound – If the value is not present.
- Return type
int
-
count(value)[source]
Number of occurrences of value
.
- Parameters
value (str | Protocol | Type[Protocol]) – Value to search.
- Return type
int
-
__init__(proto, alias=None, *, basis=None)[source]
Initialisation.
- Parameters
proto – New protocol class on the top stack.
alias – New protocol alias on the top stack.
basis – Original protocol chain as base stacks.
-
__str__()[source]
Returns formatted hex representation of source data stream.
Example
>>> protochain
ProtoChain(Ethernet, IPv6, Raw)
>>> print(protochain)
Ethernet:IPv6:Raw
- Return type
str
-
__repr__()[source]
Returns representation of protocol chain data.
Example
>>> protochain
ProtoChain(Ethernet, IPv6, Raw)
- Return type
str