Shared Context Variables

pcapkit.utilities.contextvars holds the ContextVar objects that more than one pcapkit module sets or reads, so that no module imports another’s private state (#2616). A context variable that only its own module uses stays there. This module imports nothing from pcapkit, so a module at any layer may import it; see Choosing Between utilities and corekit.

Added in version 1.6.0.

pcapkit.utilities.contextvars.beholding

Whether a layer that raises is discarded by its caller, as beholder() replaces it and _default_extension_header() drops it, so that Protocol._parse_next_layer drops its warnings with it (#2308).

Type:

contextvars.ContextVar[bool]

pcapkit.utilities.contextvars.frame_depth

How many layers of the frame being dissected come before the next one Protocol._parse_next_layer parses; see FRAME_LAYER_LIMIT.

Type:

contextvars.ContextVar[int]

pcapkit.utilities.contextvars.frame_length: ContextVar[tuple[int, int] | None]

The captured and the original length of the frame being dissected, in octets, as its PCAP record or PCAP-NG packet block states them; None outside a frame, and inside the payload of an Internet layer that bounds it, which neither an IPv4 Total Length of 0 nor AH does (#2689). A frame the capture cut short holds fewer octets than were on the wire, which a layer stating no length of its own, as GRE, cannot tell from the octets it is handed (#2653).

Type:

contextvars.ContextVar[tuple[int, int] | None]

pcapkit.utilities.contextvars.rebuilding

Whether a payload is being rebuilt by Protocol._make_payload, so that the layer it is rebuilt for parses the same octets again and reports what they carry, which the payload’s own parse then does not (#2711); see FRAME_LAYER_LIMIT.

Type:

contextvars.ContextVar[bool]