Protocol Chain

pcapkit.corekit.protochain contains special protocol collection class ProtoChain.

class pcapkit.corekit.protochain.ProtoChain(proto=None, alias=None, *, basis=None)[source]

Bases: collections.abc.Container

Protocols chain.

__alias__: pcapkit.corekit.protochain._AliasList

Protocol aliases chain.

__proto__: pcapkit.corekit.protochain._ProtoList

Protocol classes chain.

__contains__(name)[source]

Returns if name is in the chain.

Parameters

name (Union[str, pcapkit.protocols.protocol.Protocol, Type[pcapkit.protocols.protocol, Protocol]]) – name to search

Returns

if name is in the chain

Return type

bool

__getitem__(index)[source]

Subscription (getitem) support.

Parameters

index (int) – Indexing key.

Returns

Protocol alias at such index.

Return type

str

__init__(proto=None, alias=None, *, basis=None)[source]

Initialisation.

Parameters
Keyword Arguments

basis (pcapkit.corekit.protochain.ProtoChain) – Original protocol chain as base stacks.

__repr__()[source]

Returns representation of protocol chain data.

Example

>>> protochain
ProtoChain(<class 'pcapkit.protocols.link.ethernet.Ethernet'>, ...)
__str__()[source]

Returns formatted hex representation of source data stream.

Example

>>> protochain
ProtoChain(<class 'pcapkit.protocols.link.ethernet.Ethernet'>, ...)
>>> print(protochain)
Ethernet:IPv6:Raw
count(value)[source]

Number of occurrences of value.

Parameters

value – (Union[str, pcapkit.protocols.protocol.Protocol, Type[pcapkit.protocols.protocol, Protocol]]): value to search

Returns

Number of occurrences of value.

Return type

int

See also

This method calls self.__alias__.count for the actual processing.

index(value, start=None, stop=None)[source]

First index of value.

Parameters
Returns

First index of value.

Return type

int

Raises

IntError – If the value is not present.

See also

This method calls self.__alias__.index for the actual processing.

property alias

Protocol aliases chain.

Return type

pcapkit.corekit.protocol._AliasList

property chain

Protocol chain string.

Return type

str

property proto

Protocol classes chain.

Return type

pcapkit.corekit.protocol._ProtoList

property tuple

Protocol names.

Return type

Tuple[str]

class pcapkit.corekit.protochain._AliasList(data=None, *, base=None)[source]

Bases: collections.abc.Sequence

List of protocol aliases for ProtoChain

__data__: List[str]

Protocol aliases chain data.

__contains__(x)[source]

Returns if x is in the chain.

Parameters

x (Union[str, pcapkit.protocols.protocol.Protocol, Type[pcapkit.protocols.protocol, Protocol]]) – name to search

Returns

if x is in the chain

Return type

bool

__getitem__(index)[source]

Subscription (getitem) support.

Parameters

index (int) – Indexing key.

Returns

Protocol alias at such index.

Return type

str

__init__(data=None, *, base=None)[source]

Initialisation.

Parameters

data (Optional[str]) – New protocol alias on top stack.

Keyword Arguments

base (Union[pcapkit.corekit.protochain._AliasLists, List[str]]) – Original protocol alias chain as base stacks.

__iter__()[source]

Iterate through the protocol chain.

Return type

Iterator[str]

__len__()[source]

Length of the protocol chain.

Return type

int

__reversed__()[source]

Reverse the protocol alias chain.

Return type

List[str]

count(value)[source]

Number of occurrences of value.

Parameters

value – (Union[str, pcapkit.protocols.protocol.Protocol, Type[pcapkit.protocols.protocol, Protocol]]): value to search

Returns

Number of occurrences of value.

Return type

int

index(value, start=0, stop=None)[source]

First index of value.

Parameters
Returns

First index of value.

Return type

int

Raises

IntError – If the value is not present.

property data

Protocol alias data.

Return type

List[str]

class pcapkit.corekit.protochain._ProtoList(data=None, *, base=None)[source]

Bases: collections.abc.Collection

List of protocol classes for ProtoChain.

__data__: List[pcapkit.protocols.protocol.Protocol]

Protocol classes chain data.

__contains__(x)[source]

Returns if x is in the chain.

Parameters

x (Union[str, pcapkit.protocols.protocol.Protocol, Type[pcapkit.protocols.protocol, Protocol]]) – name to search

Returns

if x is in the chain

Return type

bool

__init__(data=None, *, base=None)[source]

Initialisation.

Parameters

data (Optional[pcapkit.protocols.protocol.Protocol]) – New protocol class on the top stack.

Keyword Arguments

base (Union[pcapkit.corekit.protochain._ProtoList, List[pcapkit.protocols.protocol.Protocol]]) – Original protocol class chain as base stacks.

__iter__()[source]

Iterate through the protocol chain.

Return type

Iterator[pcapkit.protocols.protocol.Protocol]

__len__()[source]

Length of the protocol chain.

Return type

int

property data

Protocol data.

Return type

List[pcapkit.protocols.protocol.Protocol]