PCAP-NG File Format¶
Removed in version 1.6.0: pcapkit.protocols.misc.pcapng.PacketDirection,
pcapkit.protocols.misc.pcapng.PacketReception and
pcapkit.protocols.misc.pcapng.WireGuardKeyLabel, with no alias: they are in this
module, and pcapkit.protocols.misc.pcapng exports the protocol class alone
(#2534). pcapkit.protocols.misc.pcapng.PAT_EUI_ADDR and
pcapkit.protocols.misc.pcapng.PAT_MAC_ADDR, with no alias:
_read_mac_addr() and
_make_mac_addr() read and make the address
(#2614).
pcapkit.protocols.misc.pcapng.protocol contains
PCAPNG,
which implements an extractor for PCAP-NG file format [*], and the
PacketDirection,
PacketReception and
WireGuardKeyLabel enumerations.
Changed in version 1.5.0: A block rebuilds as it was parsed, byte for byte: its lengths, padding,
byte order, flag bits and repeated options are kept, and so is a block
that is unknown, malformed, shorter than its fixed fields or cut short
(#1272, #1273, #1276, #1277,
#1278, #1279, #1280, #1281,
#1282, #1283, #1284, #1382,
#1383, #1384, #1405, #1413,
#1414, #1422, #1470). A packet block keeps the
octets it captured (#646); an option running past its block’s
option area leaves the whole area kept as captured in options_raw,
with a ProtocolWarning, where it was
read as zeros (#594, #1325); a truncated capture does not
raise ValueError (#678); and timestamp_epoch is not
shifted by the host’s timezone (#361).
- class pcapkit.protocols.misc.pcapng.protocol.PCAPNG(file=None, length=None, **kwargs)[source]¶
Bases:
ProtocolBase[PCAPNG,PCAPNG]PCAP-NG file block extractor.
The class supports parsing of the following protocols, which are registered in the
self.__proto__attribute:Index
Protocol
pcapkit.const.reg.linktype.LinkType.RAWhas no entry of its own: its data is dispatched asIPV4orIPV6by the version nibble of its first octet, see_dispatch_linktype().The class supports parsing of the following block types, which are registered in the
self.__block__attribute:Block Type
Block Parser
Block Constructor
The class supports parsing of the following option types, which are registered in the
self.__option__attribute:Option Type
Option Parser
Option Constructor
opt_custom_2988,opt_custom_2989,opt_custom_19372,opt_custom_19373The class supports parsing of the following name resolution record types, which are registered in the
self.__record__attribute:Record Type
Record Parser
Record Constructor
The class supports parsing of the following decryption secrets types, which are registered in the
self.__secrets__attribute:Secrets Type
Secrets Parser
Secrets Constructor
Changed in version 1.5.0:
contextreturns the caller suppliedContextRegistryinherited fromProtocolBase, on every block. The block’s sectionContext, whichcontextreturned through 1.4.x, issection_context(#2172).Changed in version 1.6.0:
Each enumeration field of
make()and of the block and option makers, and the code of each option and the type of each name resolution record given to a block maker, takes a member or anintcode, resolved with the enumeration’sget, an option code in the block’s namespace; a name, aboolfor a field wider than one bit, or a code the field cannot carry raisesProtocolError, rather than resolving against an enumeration inferred from the caller’s frame, writing a different value or raising another exception (#2594).An option or a name resolution record given to a block maker as raw octets too short to hold its 16-bit code raises
ProtocolError, rather than reading empty octets as code 0 and writing an end-of-options or end-of-records marker for them (#2723).
Removed in version 1.6.0: The
type_default,type_namespaceandtype_reversedarguments ofmake(), and the_default,_namespaceand_reversedarguments that went with each enumeration field of the block and option makers –linktype,secrets_type,filter,direction,reception,algorithmandverdict; resolve a name withresolve_index()first (#2594).- PACKET_TYPES = (<BlockType.Enhanced_Packet_Block: 6>, <BlockType.Simple_Packet_Block: 3>, <BlockType.Packet_Block: 2>)¶
Blocks that carry a captured packet.
- SHORT_HEADER_TYPES = {<BlockType.Interface_Description_Block: 1>: 20, <BlockType.Section_Header_Block: 168627466>: 28}¶
Header blocks mapped to the octets their fixed fields span, so that a shorter Block Total Length is kept as captured (see
_read_block_short_header()). The lengths are read from their one home,pcapkit.protocols.misc.pcapng.schema.BLOCK_MINIMUM(#1739).
- __proto__: DefaultDict[int | LinkType, ModuleDescriptor[ProtocolBase] | Type[ProtocolBase]]¶
Protocol index mapping for decoding the next layer; see
self._decode_next_layerandself._import_next_layer. Each value is aModuleDescriptornaming the module and class, or aProtocolBasesubclass.
- __proto_key__: ClassVar[tuple[Type[EnumRegistry], bool]]¶
What
__proto__is keyed by – the enum a key must be a member of, and whether a bareintis a valid key too. Declared by the class owning the registry, soregister_protocol_code()checks acode=key asregister_pcapng()does;Frame, whose registry is keyed by the same enum, declares its own (#2268).
- __block__: DefaultDict[BlockType | int, str | tuple[Callable[[BlockType, PCAPNG], PCAPNG], Callable[[PCAPNG | None, Any], BlockType]]]¶
Block type to method mapping. A
strvalue names the_read_block_${name}and_make_block_${name}methods, which fall back to_read_block_unknownand_make_block_unknownwhen not defined, as an unregistered code does; any other value is a(parser, constructor)pair of callables.
- __option__: DefaultDict[OptionType | Tuple[str, int], str | tuple[Callable[[Option, OrderedMultiDict[OptionType, Option]], Option], Callable[[OptionType, Option | None, Any], Option]]]¶
Block option type to method mapping. A
strvalue names the_read_option_${name}and_make_option_${name}methods, which fall back to_read_option_unknownand_make_option_unknownwhen not defined, as an unregistered code does; any other value is a(parser, constructor)pair of callables.
- __record__: DefaultDict[RecordType | int, str | tuple[Callable[[NameResolutionRecord, OrderedMultiDict[RecordType, NameResolutionRecord]], NameResolutionRecord], Callable[[RecordType, NameResolutionRecord | None, Any], NameResolutionRecord]]]¶
Name Resolution Block record type to method mapping. A
strvalue names the_read_record_${name}and_make_record_${name}methods, which fall back to_read_record_unknownand_make_record_unknownwhen not defined, as an unregistered code does; any other value is a(parser, constructor)pair of callables.
- __secrets__: DefaultDict[SecretsType | int, str | tuple[Callable[[DSBSecrets, DecryptionSecretsBlock], DSBSecrets], Callable[[SecretsType, DSBSecrets | None, Any], DSBSecrets]]]¶
Decryption secrets type to method mapping. A
strvalue names the_read_secrets_${name}and_make_secrets_${name}methods, which fall back to_read_secrets_unknownand_make_secrets_unknownwhen not defined, as an unregistered code does; any other value is a(parser, constructor)pair of callables.
- property length: int¶
Block total length of corresponding protocol.
Note
This is the wire’s Block Total Length – the whole block, trailing length field included – and not a header length. The two are the same thing for a protocol whose payload runs to the end of its buffer, which is why
Protocol.lengthdoes not distinguish them, but a PCAP-NG block carries a trailer.self.packetis overridden accordingly.
- property packet: Packet¶
Header and payload octets of the current block.
A PCAP-NG block is not a header followed by a payload. The captured octets sit in the middle of a packet block, ahead of the option list and the trailing Block Total Length, so no single split point expresses the shape and the inherited
Protocol.packet– which readsself.lengthoctets of header and takes everything after as payload – cannot produce it. Sinceself.lengthis the Block Total Length, that split would put the entire block in the header and leave the payload empty, sopacketwould beb''whilecaptured_lendeclared the octets.The payload is therefore the block schema’s
__payload__field, which is where the schema layer put the captured octets, and the header is the block octets ahead of it. The block types that carry captured octets –PACKET_TYPES, i.e. the Enhanced Packet Block, the Simple Packet Block and the obsolete Packet Block – each place the payload at a different offset, so the offset is summed from the octets the schema actually unpacked rather than hard-coded per block type. A block declaring no payload field is all header and no payload.
- property section_context: Context¶
Section context of current PCAP-NG block.
- Raises:
UnsupportedCall – If the block holds no section context: a block given
ctx=None, or a Section Header Block, which starts a section rather than reading one, unless thePCAPNGengine read it and assigned it the section it opens.
Added in version 1.5.0: Renamed from
context, with no alias.contextis the one inherited fromProtocolBase, the caller supplied parsing context ofpcapkit.corekit.context(#2172).
- property ts_timezone: timezone¶
Timezone of the current block.
Defaults to UTC when the capture names no
if_tzone, for the reason given inself._get_timezone.
- property linktype: LinkType¶
Data link layer protocol type.
- Raises:
UnsupportedCall – If current block is not a valid packet block, i.e., EPB, SPB or obsolete Packet Block.
- classmethod register(code, protocol)[source]¶
Register a new protocol class.
Notes
The fully qualified class name of the new protocol class should be
{protocol.module}.{protocol.name}.- Parameters:
protocol (
ModuleDescriptor[ProtocolBase] |Type[ProtocolBase]) – module descriptor or aProtocolBasesubclass
- Raises:
pcapkit.utilities.exceptions.RegistryError – If
protocolis not a class, or not aProtocolBasesubclass.- Warns:
pcapkit.utilities.warnings.RegistryWarning– If this link type is already registered against PCAP-NG blocks, naming the displaced entry and its replacement so a caller can tell what was lost. Fires only when the incumbent differs from the replacement, and an unresolved module descriptor counts as different from the class it names; handing back the stored entry, or a descriptor equal to it, is a silent no-op that keeps it. This registry is separate from the PCAP one, soregister_linktype()writing to both cannot make either warn about the other. SeeProtocol.registerfor the shipped descriptor a restore puts back (#1504).
- classmethod register_block(code, meth)[source]¶
Register a block parser.
- Parameters:
- Warns:
RegistryWarning– If a different entry is already registered forcode; it is overwritten. Handing back the entry already stored, or one equal to it, is a silent no-op. The entrycodeshipped with is accepted like any other, so an override can be undone (#1362, #1363).
- classmethod register_option(code, meth)[source]¶
Register an option parser.
- Parameters:
code (
OptionType) – PCAP-NG option type code.meth (
str|tuple[Callable[[Option,OrderedMultiDict[OptionType,Option]],Option],Callable[[OptionType,Option|None,Any],Option]]) – Name of the_read_option_${name}and_make_option_${name}methods, or a(parser, constructor)pair of callables; see__option__.
- Warns:
RegistryWarning– If a different entry is already registered forcode; it is overwritten. Handing back the entry already stored, or one equal to it, is a silent no-op. The entrycodeshipped with is accepted like any other, so an override can be undone (#1362, #1363).
- classmethod register_record(code, meth)[source]¶
Register a name resolution record parser.
- Parameters:
code (
RecordType) – PCAP-NG name resolution record type code.meth (
str|tuple[Callable[[NameResolutionRecord,OrderedMultiDict[RecordType,NameResolutionRecord]],NameResolutionRecord],Callable[[RecordType,NameResolutionRecord|None,Any],NameResolutionRecord]]) – Name of the_read_record_${name}and_make_record_${name}methods, or a(parser, constructor)pair of callables; see__record__.
- Warns:
RegistryWarning– If a different entry is already registered forcode; it is overwritten. Handing back the entry already stored, or one equal to it, is a silent no-op. The entrycodeshipped with is accepted like any other, so an override can be undone (#1362, #1363).
- classmethod register_secrets(code, meth)[source]¶
Register a decryption secrets parser.
- Parameters:
code (
SecretsType) – PCAP-NG decryption secrets type code.meth (
str|tuple[Callable[[DSBSecrets,DecryptionSecretsBlock],DSBSecrets],Callable[[SecretsType,DSBSecrets|None,Any],DSBSecrets]]) – Name of the_read_secrets_${name}and_make_secrets_${name}methods, or a(parser, constructor)pair of callables; see__secrets__.
- Warns:
RegistryWarning– If a different entry is already registered forcode; it is overwritten. Handing back the entry already stored, or one equal to it, is a silent no-op. The entrycodeshipped with is accepted like any other, so an override can be undone (#1362, #1363).
- index(name)[source]¶
Call
ProtoChain.index.- Parameters:
name (
str|ProtocolBase|Type[ProtocolBase]) –nameto be searched- Return type:
- Returns:
First index of
name.- Raises:
IndexNotFound – if
nameis not present
- pack(**kwargs)[source]¶
Pack (construct) packet data.
- Parameters:
**kwargs (
Any) – Arbitrary keyword arguments.- Return type:
- Returns:
Constructed packet data.
Notes
The special keyword argument
__packet__passes the global packet data to underlying methods, for when the current instance does not have it.As in
Protocol.pack, the header is made on a copy outside construction, so the instance keeps its own header, block type, byte order and option counts (#1769).
- unpack(length=None, **kwargs)[source]¶
Unpack (parse) packet data.
- Parameters:
- Return type:
- Returns:
Parsed packet data.
Notes
The special keyword argument
__packet__passes the global packet data to underlying methods, for when the current instance does not have it.A block handed to
make()as rawbytesis written back verbatim past the Block Type, so the schemamake()returns holds the octets rather than the block’s fields. Those octets are parsed here, off the bufferpack()has just filled, which is what a reader of the file would do with them (#2354).
- read(length=None, *, _read=True, _seek_set=0, **kwargs)[source]¶
Read PCAP-NG file blocks.
Structure of PCAP-NG file blocks:
1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 0 | Block Type | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4 | Block Total Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 8 / Block Body / / variable length, padded to 32 bits / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Block Total Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- make(type=BlockType.Simple_Packet_Block, block=b'', **kwargs)[source]¶
Make PCAP-NG block data.
- __post_init__(file=None, length=None, *, num, sct, ctx, **kwargs)[source]¶
Initialisation.
- Overloads:
- Parameters:
Notes
The first block has
num0andctxNone, marking it as the section header block.See also
For construction arguments, please refer to
make().
- __index__()[source]¶
Index of the block.
- Parameters:
- Return type:
- Returns:
If the object is initialised, i.e.
self._fnumexists, and is of a packet block (EPB, SPB or Packet), returns the block index number of itself; else raisesUnsupportedCall.- Raises:
UnsupportedCall – If called on the class, or on a block that is not a packet block.
- _read_block_short(schema, *, header)[source]¶
Read a PCAP-NG EPB or packet block (obsolete) shorter than its fixed fields.
The fixed fields of either block span 32 octets, so a smaller Block Total Length cannot hold them.
- Parameters:
schema (
EnhancedPacketBlock|PacketBlock|UnknownBlock) – Parsed block schema, or on the construction path theUnknownBlockthat_make_block_short()built.header (
PCAPNG) – Parsed PCAP-NG header schema.
- Return type:
- Returns:
Parsed packet data, with the fixed fields the block holds and zero for those it does not, no packet data and no options. The block body is kept as
block_raw, which the block’smakewrites back verbatim, so the block rebuilds at the length it declared (#1414).
- _make_block_short(block)[source]¶
Make a PCAP-NG EPB, packet block (obsolete), SHB or IDB kept as captured.
- Parameters:
block (
EnhancedPacketBlock|PacketBlock|SectionHeaderBlock|InterfaceDescriptionBlock) – Block data model, whoseblock_rawholds the body of a block shorter than its fixed fields (see_read_block_short()and_read_block_short_header()).- Return type:
- Returns:
Constructed block schema, the body written back verbatim.
- _read_block_short_header(schema, *, header)[source]¶
Read a PCAP-NG SHB or IDB shorter than its fixed fields.
The fixed fields of a Section Header Block span 28 octets and those of an Interface Description Block 20 (see
SHORT_HEADER_TYPES), so a smaller Block Total Length cannot hold them.- Parameters:
schema (
SectionHeaderBlock|InterfaceDescriptionBlock|UnknownBlock) – Parsed block schema, or on the construction path theUnknownBlockthat_make_block_short()built.header (
PCAPNG) – Parsed PCAP-NG header schema.
- Return type:
- Returns:
Parsed packet data, with the fixed fields the block holds and zero for those it does not, and no options. The block body is kept as
block_raw, which the block’smakewrites back verbatim, so the block rebuilds at the length it declared (#1422).A section header keeps the byte order its Byte-Order Magic declares. One of 12 octets has no room for the magic, and takes the byte order in which its Block Total Length reads as 12 (see
SectionHeaderBlock).
- _read_block_unknown(schema, *, header)[source]¶
Read unknown PCAP-NG block.
- Parameters:
schema (
UnknownBlock) – Parsed block schema.header (
PCAPNG) – Parsed PCAP-NG header schema.
- Return type:
- Returns:
Parsed packet data.
- _read_block_idb(schema, *, header)[source]¶
Read PCAP-NG interface description block (IDB).
Structure of Interface Description Block:
1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 0 | Block Type = 0x00000001 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4 | Block Total Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 8 | LinkType | Reserved | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 12 | SnapLen | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 16 / / / Options (variable) / / / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Block Total Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- Parameters:
schema (
InterfaceDescriptionBlock) – Parsed block schema.header (
PCAPNG) – Parsed PCAP-NG header schema.
- Return type:
- Returns:
Parsed packet data.
- _read_block_packet(schema, *, header)[source]¶
Read PCAP-NG packet block (obsolete).
Structure of Packet Block:
1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 0 | Block Type = 0x00000002 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4 | Block Total Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 8 | Interface ID | Drops Count | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 12 | Timestamp (High) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 16 | Timestamp (Low) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 20 | Captured Packet Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 24 | Original Packet Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 28 / / / Packet Data / / variable length, padded to 32 bits / / / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ / / / Options (variable) / / / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Block Total Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- Parameters:
schema (
PacketBlock) – Parsed block schema.header (
PCAPNG) – Parsed PCAP-NG header schema.
- Return type:
- Returns:
Parsed packet data.
- _read_block_spb(schema, *, header)[source]¶
Read PCAP-NG simple packet block (SPB).
Structure of Simple Packet Block:
1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 0 | Block Type = 0x00000003 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4 | Block Total Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 8 | Original Packet Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 12 / / / Packet Data / / variable length, padded to 32 bits / / / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Block Total Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- Parameters:
schema (
SimplePacketBlock) – Parsed block schema.header (
PCAPNG) – Parsed PCAP-NG header schema.
- Return type:
- Returns:
Parsed packet data.
- _read_block_nrb(schema, *, header)[source]¶
Read PCAP-NG name resolution block (NRB).
Structure of Name Resolution Block:
1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 0 | Block Type = 0x00000004 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4 | Block Total Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 8 | Record Type | Record Value Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 12 / Record Value / / variable length, padded to 32 bits / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ . . . . . . other records . . . . . . +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Record Type = nrb_record_end | Record Value Length = 0 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ / / / Options (variable) / / / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Block Total Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- Parameters:
schema (
NameResolutionBlock) – Parsed block schema.header (
PCAPNG) – Parsed PCAP-NG header schema.
- Return type:
- Returns:
Parsed packet data.
- _read_block_isb(schema, *, header)[source]¶
Read PCAP-NG interface statistics block (ISB).
Structure of Interface Statistics Block:
1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 0 | Block Type = 0x00000005 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4 | Block Total Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 8 | Interface ID | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 12 | Timestamp (High) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 16 | Timestamp (Low) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 20 / / / Options (variable) / / / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Block Total Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- Parameters:
schema (
InterfaceStatisticsBlock) – Parsed block schema.header (
PCAPNG) – Parsed PCAP-NG header schema.
- Return type:
- Returns:
Parsed packet data.
- _read_block_epb(schema, *, header)[source]¶
Read PCAP-NG enhanced packet block (EPB).
Structure of Enhanced Packet Block:
1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 0 | Block Type = 0x00000006 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4 | Block Total Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 8 | Interface ID | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 12 | Timestamp (High) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 16 | Timestamp (Low) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 20 | Captured Packet Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 24 | Original Packet Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 28 / / / Packet Data / / variable length, padded to 32 bits / / / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ / / / Options (variable) / / / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Block Total Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- Parameters:
schema (
EnhancedPacketBlock) – Parsed block schema.header (
PCAPNG) – Parsed PCAP-NG header schema.
- Return type:
- Returns:
Parsed packet data.
- _read_block_systemd(schema, *, header)[source]¶
Read PCAP-NG systemd(1) journal export block.
Structure of systemd(1) Journal Export Block:
1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 0 | Block Type = 0x00000009 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4 | Block Total Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 8 / / / Journal Entry / / variable length, padded to 32 bits / / / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Block Total Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- Parameters:
schema (
SystemdJournalExportBlock) – Parsed block schema.header (
PCAPNG) – Parsed PCAP-NG header schema.
- Return type:
- Returns:
Parsed packet data.
- _read_block_dsb(schema, *, header)[source]¶
Read PCAP-NG decryption secrets block (DSB).
Structure of Decryption Secrets Block:
1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 0 | Block Type = 0x0000000A | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4 | Block Total Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 8 | Secrets Type | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 12 | Secrets Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 16 / / / Secrets Data / / (variable length, padded to 32 bits) / / / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ / / / Options (variable) / / / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ / Block Total Length / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- Parameters:
schema (
DecryptionSecretsBlock) – Parsed block schema.header (
PCAPNG) – Parsed PCAP-NG header schema.
- Return type:
- Returns:
Parsed packet data.
- _read_block_cb(schema, *, header)[source]¶
Read PCAP-NG custom block (CB).
Structure of Custom Block:
1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 0 | Block Type = 0x00000BAD or 0x40000BAD | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4 | Block Total Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 8 | Private Enterprise Number (PEN) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 12 / / / Custom Data / / variable length, padded to 32 bits / / / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ / / / Options (variable) / / / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Block Total Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- Parameters:
schema (
CustomBlock) – Parsed block schema.header (
PCAPNG) – Parsed PCAP-NG header schema.
- Return type:
- Returns:
Parsed packet data.
- _read_block_shb(schema, *, header)[source]¶
Read PCAP-NG section header block (SHB).
Structure of Section Header Block:
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 0 | Block Type = 0x0A0D0D0A | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4 | Block Total Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 8 | Byte-Order Magic | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 12 | Major Version | Minor Version | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 16 | | | Section Length | | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 24 / / / Options (variable) / / / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Block Total Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- Parameters:
schema (
SectionHeaderBlock) – Parsed block schema.header (
PCAPNG) – Parsed PCAP-NG header schema.
- Return type:
- Returns:
Parsed packet data.
- _read_option_unknown(schema, *, options)[source]¶
Read unknown PCAP-NG option.
- Parameters:
schema (
UnknownOption) – Parsed option schema.options (
OrderedMultiDict[OptionType,Option]) – Parsed PCAP-NG options.
- Return type:
- Returns:
Parsed option data.
- _read_option_endofopt(schema, *, options)[source]¶
Read PCAP-NG
opt_endofoptoption.- Parameters:
schema (
EndOfOption) – Parsed option schema.options (
OrderedMultiDict[OptionType,Option]) – Parsed PCAP-NG options.
- Return type:
- Returns:
Parsed option data.
- _read_option_comment(schema, *, options)[source]¶
Read PCAP-NG
opt_commentoption.- Parameters:
schema (
CommentOption) – Parsed option schema.options (
OrderedMultiDict[OptionType,Option]) – Parsed PCAP-NG options.
- Return type:
- Returns:
Parsed option data.
- _read_option_custom(schema, *, options)[source]¶
Read PCAP-NG
opt_customoption.Structure of PCAP-NG
opt_customoption:1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Custom Option Code | Option Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Private Enterprise Number (PEN) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ / Custom Data / / variable length, padded to 32 bits / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- Parameters:
schema (
CustomOption) – Parsed option schema.options (
OrderedMultiDict[OptionType,Option]) – Parsed PCAP-NG options.
- Return type:
- Returns:
Parsed option data.
- Raises:
ProtocolError – If the option is shorter than its 4-octet private enterprise number, which Option Length includes.
- _read_option_if_name(schema, *, options)[source]¶
Read PCAP-NG
if_nameoption.- Parameters:
schema (
IF_NameOption) – Parsed option schema.options (
OrderedMultiDict[OptionType,Option]) – Parsed PCAP-NG options.
- Return type:
- Returns:
Parsed option data.
- _read_option_if_description(schema, *, options)[source]¶
Read PCAP-NG
if_descriptionoption.- Parameters:
schema (
IF_DescriptionOption) – Parsed option schema.options (
OrderedMultiDict[OptionType,Option]) – Parsed PCAP-NG options.
- Return type:
- Returns:
Parsed option data.
- _read_option_if_ipv4(schema, *, options)[source]¶
Read PCAP-NG
if_IPv4addroption.- Parameters:
schema (
IF_IPv4AddrOption) – Parsed option schema.options (
OrderedMultiDict[OptionType,Option]) – Parsed PCAP-NG options.
- Return type:
- Returns:
Parsed option data.
- _read_option_if_ipv6(schema, *, options)[source]¶
Read PCAP-NG
if_IPv6addroption.- Parameters:
schema (
IF_IPv6AddrOption) – Parsed option schema.options (
OrderedMultiDict[OptionType,Option]) – Parsed PCAP-NG options.
- Return type:
- Returns:
Parsed option data.
- _read_option_if_mac(schema, *, options)[source]¶
Read PCAP-NG
if_MACaddroption.- Parameters:
schema (
IF_MACAddrOption) – Parsed option schema.options (
OrderedMultiDict[OptionType,Option]) – Parsed PCAP-NG options.
- Return type:
- Returns:
Parsed option data.
- _read_option_if_eui(schema, *, options)[source]¶
Read PCAP-NG
if_EUIaddroption.- Parameters:
schema (
IF_EUIAddrOption) – Parsed option schema.options (
OrderedMultiDict[OptionType,Option]) – Parsed PCAP-NG options.
- Return type:
- Returns:
Parsed option data.
- _read_option_if_speed(schema, *, options)[source]¶
Read PCAP-NG
if_speedoption.- Parameters:
schema (
IF_SpeedOption) – Parsed option schema.options (
OrderedMultiDict[OptionType,Option]) – Parsed PCAP-NG options.
- Return type:
- Returns:
Parsed option data.
- _read_option_if_tsresol(schema, *, options)[source]¶
Read PCAP-NG
if_tsresoloption.- Parameters:
schema (
IF_TSResolOption) – Parsed option schema.options (
OrderedMultiDict[OptionType,Option]) – Parsed PCAP-NG options.
- Return type:
- Returns:
Parsed option data.
- _read_option_if_tzone(schema, *, options)[source]¶
Read PCAP-NG
if_tzoneoption.- Parameters:
schema (
IF_TZoneOption) – Parsed option schema.options (
OrderedMultiDict[OptionType,Option]) – Parsed PCAP-NG options.
- Return type:
- Returns:
Parsed option data.
- _read_option_if_filter(schema, *, options)[source]¶
Read PCAP-NG
if_filteroption.- Parameters:
schema (
IF_FilterOption) – Parsed option schema.options (
OrderedMultiDict[OptionType,Option]) – Parsed PCAP-NG options.
- Return type:
- Returns:
Parsed option data.
- _read_option_if_os(schema, *, options)[source]¶
Read PCAP-NG
if_osoption.- Parameters:
schema (
IF_OSOption) – Parsed option schema.options (
OrderedMultiDict[OptionType,Option]) – Parsed PCAP-NG options.
- Return type:
- Returns:
Parsed option data.
- _read_option_if_fcslen(schema, *, options)[source]¶
Read PCAP-NG
if_fcslenoption.- Parameters:
schema (
IF_FCSLenOption) – Parsed option schema.options (
OrderedMultiDict[OptionType,Option]) – Parsed PCAP-NG options.
- Return type:
- Returns:
Parsed option data.
- _read_option_if_tsoffset(schema, *, options)[source]¶
Read PCAP-NG
if_tsoffsetoption.- Parameters:
schema (
IF_TSOffsetOption) – Parsed option schema.options (
OrderedMultiDict[OptionType,Option]) – Parsed PCAP-NG options.
- Return type:
- Returns:
Parsed option data.
- _read_option_if_hardware(schema, *, options)[source]¶
Read PCAP-NG
if_hardwareoption.- Parameters:
schema (
IF_HardwareOption) – Parsed option schema.options (
OrderedMultiDict[OptionType,Option]) – Parsed PCAP-NG options.
- Return type:
- Returns:
Parsed option data.
- _read_option_if_txspeed(schema, *, options)[source]¶
Read PCAP-NG
if_txspeedoption.- Parameters:
schema (
IF_TxSpeedOption) – Parsed option schema.options (
OrderedMultiDict[OptionType,Option]) – Parsed PCAP-NG options.
- Return type:
- Returns:
Parsed option data.
- _read_option_if_rxspeed(schema, *, options)[source]¶
Read PCAP-NG
if_rxspeedoption.- Parameters:
schema (
IF_RxSpeedOption) – Parsed option schema.options (
OrderedMultiDict[OptionType,Option]) – Parsed PCAP-NG options.
- Return type:
- Returns:
Parsed option data.
- _read_option_epb_flags(schema, *, options)[source]¶
Read PCAP-NG
epb_flagsoption.- Parameters:
schema (
EPB_FlagsOption) – Parsed option schema.options (
OrderedMultiDict[OptionType,Option]) – Parsed PCAP-NG options.
- Return type:
- Returns:
Parsed option data.
- _read_option_epb_hash(schema, *, options)[source]¶
Read PCAP-NG
epb_hashoption.- Parameters:
schema (
EPB_HashOption) – Parsed option schema.options (
OrderedMultiDict[OptionType,Option]) – Parsed PCAP-NG options.
- Return type:
- Returns:
Parsed option data.
- _read_option_epb_dropcount(schema, *, options)[source]¶
Read PCAP-NG
epb_dropcountoption.- Parameters:
schema (
EPB_DropCountOption) – Parsed option schema.options (
OrderedMultiDict[OptionType,Option]) – Parsed PCAP-NG options.
- Return type:
- Returns:
Parsed option data.
- _read_option_epb_packetid(schema, *, options)[source]¶
Read PCAP-NG
epb_packetidoption.- Parameters:
schema (
EPB_PacketIDOption) – Parsed option schema.options (
OrderedMultiDict[OptionType,Option]) – Parsed PCAP-NG options.
- Return type:
- Returns:
Parsed option data.
- _read_option_epb_queue(schema, *, options)[source]¶
Read PCAP-NG
epb_queueoption.- Parameters:
schema (
EPB_QueueOption) – Parsed option schema.options (
OrderedMultiDict[OptionType,Option]) – Parsed PCAP-NG options.
- Return type:
- Returns:
Parsed option data.
- _read_option_epb_verdict(schema, *, options)[source]¶
Read PCAP-NG
epb_verdictoption.- Parameters:
schema (
EPB_VerdictOption) – Parsed option schema.options (
OrderedMultiDict[OptionType,Option]) – Parsed PCAP-NG options.
- Return type:
- Returns:
Parsed option data.
- _read_option_ns_dnsname(schema, *, options)[source]¶
Read PCAP-NG
ns_dnsnameoption.- Parameters:
schema (
NS_DNSNameOption) – Parsed option schema.options (
OrderedMultiDict[OptionType,Option]) – Parsed PCAP-NG options.
- Return type:
- Returns:
Parsed option data.
- _read_option_ns_dnsipv4(schema, *, options)[source]¶
Read PCAP-NG
ns_dnsIP4addroption.- Parameters:
schema (
NS_DNSIP4AddrOption) – Parsed option schema.options (
OrderedMultiDict[OptionType,Option]) – Parsed PCAP-NG options.
- Return type:
- Returns:
Parsed option data.
- _read_option_ns_dnsipv6(schema, *, options)[source]¶
Read PCAP-NG
ns_dnsIP6addroption.- Parameters:
schema (
NS_DNSIP6AddrOption) – Parsed option schema.options (
OrderedMultiDict[OptionType,Option]) – Parsed PCAP-NG options.
- Return type:
- Returns:
Parsed option data.
- _read_option_isb_starttime(schema, *, options)[source]¶
Read PCAP-NG
isb_starttimeoption.- Parameters:
schema (
ISB_StartTimeOption) – Parsed option schema.options (
OrderedMultiDict[OptionType,Option]) – Parsed PCAP-NG options.
- Return type:
- Returns:
Parsed option data.
- _read_option_isb_endtime(schema, *, options)[source]¶
Read PCAP-NG
isb_endtimeoption.- Parameters:
schema (
ISB_EndTimeOption) – Parsed option schema.options (
OrderedMultiDict[OptionType,Option]) – Parsed PCAP-NG options.
- Return type:
- Returns:
Parsed option data.
- _read_option_isb_ifrecv(schema, *, options)[source]¶
Read PCAP-NG
isb_ifrecvoption.- Parameters:
schema (
ISB_IFRecvOption) – Parsed option schema.options (
OrderedMultiDict[OptionType,Option]) – Parsed PCAP-NG options.
- Return type:
- Returns:
Parsed option data.
- _read_option_isb_ifdrop(schema, *, options)[source]¶
Read PCAP-NG
isb_ifdropoption.- Parameters:
schema (
ISB_IFDropOption) – Parsed option schema.options (
OrderedMultiDict[OptionType,Option]) – Parsed PCAP-NG options.
- Return type:
- Returns:
Parsed option data.
- _read_option_isb_filteraccept(schema, *, options)[source]¶
Read PCAP-NG
isb_filteracceptoption.- Parameters:
schema (
ISB_FilterAcceptOption) – Parsed option schema.options (
OrderedMultiDict[OptionType,Option]) – Parsed PCAP-NG options.
- Return type:
- Returns:
Parsed option data.
- _read_option_isb_osdrop(schema, *, options)[source]¶
Read PCAP-NG
isb_osdropoption.- Parameters:
schema (
ISB_OSDropOption) – Parsed option schema.options (
OrderedMultiDict[OptionType,Option]) – Parsed PCAP-NG options.
- Return type:
- Returns:
Parsed option data.
- _read_option_isb_usrdeliv(schema, *, options)[source]¶
Read PCAP-NG
isb_usrdelivoption.- Parameters:
schema (
ISB_UsrDelivOption) – Parsed option schema.options (
OrderedMultiDict[OptionType,Option]) – Parsed PCAP-NG options.
- Return type:
- Returns:
Parsed option data.
- _read_option_pack_flags(schema, *, options)[source]¶
Read PCAP-NG
pack_flagsoption.- Parameters:
schema (
PACK_FlagsOption) – Parsed option schema.options (
OrderedMultiDict[OptionType,Option]) – Parsed PCAP-NG options.
- Return type:
- Returns:
Parsed option data.
- _read_option_pack_hash(schema, *, options)[source]¶
Read PCAP-NG
pack_hashoption.- Parameters:
schema (
PACK_HashOption) – Parsed option schema.options (
OrderedMultiDict[OptionType,Option]) – Parsed PCAP-NG options.
- Return type:
- Returns:
Parsed option data.
- _read_record_unknown(schema, *, records)[source]¶
Read PCAP-NG unknown name resolution records.
- Parameters:
schema (
UnknownRecord) – Parsed name resolution record schema.records (
OrderedMultiDict[RecordType,NameResolutionRecord]) – Parsed PCAP-NG records.
- Return type:
- Returns:
Parsed name resolution record data.
- _read_record_end(schema, *, records)[source]¶
Read PCAP-NG
nrb_record_endname resolution records.- Parameters:
schema (
EndRecord) – Parsed name resolution record schema.records (
OrderedMultiDict[RecordType,NameResolutionRecord]) – Parsed PCAP-NG records.
- Return type:
- Returns:
Parsed name resolution record data.
- _read_record_ipv4(schema, *, records)[source]¶
Read PCAP-NG
nrb_record_ipv4name resolution records.- Parameters:
schema (
IPv4Record) – Parsed name resolution record schema.records (
OrderedMultiDict[RecordType,NameResolutionRecord]) – Parsed PCAP-NG records.
- Return type:
- Returns:
Parsed name resolution record data.
- _read_record_ipv6(schema, *, records)[source]¶
Read PCAP-NG
nrb_record_ipv6name resolution records.- Parameters:
schema (
IPv6Record) – Parsed name resolution record schema.records (
OrderedMultiDict[RecordType,NameResolutionRecord]) – Parsed PCAP-NG records.
- Return type:
- Returns:
Parsed name resolution record data.
- _read_secrets_unknown(schema, *, block)[source]¶
Read PCAP-NG unknown secrets.
- Parameters:
schema (
UnknownSecrets) – Parsed secret schema.block (
DecryptionSecretsBlock) – Parsed PCAP-NG decryption secrets block.
- Return type:
- Returns:
Parsed decryption secrets data.
- _read_secrets_tls(schema, *, block)[source]¶
Read PCAP-NG TLS key log secrets.
- Parameters:
schema (
TLSKeyLog) – Parsed secret schema.block (
DecryptionSecretsBlock) – Parsed PCAP-NG decryption secrets block.
- Return type:
- Returns:
Parsed decryption secrets data.
- _read_secrets_wireguard(schema, *, block)[source]¶
Read PCAP-NG WireGuard key log secrets.
- Parameters:
schema (
WireGuardKeyLog) – Parsed secret schema.block (
DecryptionSecretsBlock) – Parsed PCAP-NG decryption secrets block.
- Return type:
- Returns:
Parsed decryption secrets data.
- _read_secrets_zigbee_aps(schema, *, block)[source]¶
Read PCAP-NG ZigBee APS Key secrets.
Structure of ZigBee APS Key secrets:
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +---------------------------------------------------------------+ 0 | Block Type = 0x0000000A | +---------------------------------------------------------------+ 4 | Block Total Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 8 | Secrets Type = 0x5a415053 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 12 | Secrets Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 16 | AES-128 | | APS Key | | (16 octets) | | (128 bits) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 32 | PAN ID | Low Node Short Address | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 36 | High Node Short Address | padding (0) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 40 / / / Options (variable) / / / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ / Block Total Length / +---------------------------------------------------------------+
- Parameters:
schema (
ZigBeeAPSKey) – Parsed secret schema.block (
DecryptionSecretsBlock) – Parsed PCAP-NG decryption secrets block.
- Return type:
- Returns:
Parsed decryption secrets data.
- _read_secrets_zigbee_nwk(schema, *, block)[source]¶
Read PCAP-NG ZigBee NWK Key secrets.
Structure of ZigBee NWK Key secrets:
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +---------------------------------------------------------------+ 0 | Block Type = 0x0000000A | +---------------------------------------------------------------+ 4 | Block Total Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 8 | Secrets Type = 0x5a4e574b | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 12 | Secrets Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 16 | AES-128 | | NWK Key | | (16 octets) | | (128 bits) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 32 | PAN ID | padding (0) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 36 / / / Options (variable) / / / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ / Block Total Length / +---------------------------------------------------------------+
- Parameters:
schema (
ZigBeeNWKKey) – Parsed secret schema.block (
DecryptionSecretsBlock) – Parsed PCAP-NG decryption secrets block.
- Return type:
- Returns:
Parsed decryption secrets data.
- _make_block_unknown(block=None, *, data=b'', **kwargs)[source]¶
Make unknown PCAP-NG block.
- Parameters:
block (
UnknownBlock|None) – Block data model.data (
bytes) – Unspecified block data.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed block schema.
- _make_block_idb(block=None, *, linktype=LinkType.NULL, snaplen=0, options=None, **kwargs)[source]¶
Make PCAP-NG interface description block (IDB).
- Parameters:
block (
InterfaceDescriptionBlock|None) – Block data model.snaplen (
int) – Snap length, an unsigned 32-bit value; 0, the default, means no limit.options (
OrderedMultiDict[OptionType,Option] |list[Option|tuple[OptionType|int,dict[str,Any]] |bytes] |None) – Block options.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed block schema.
- Raises:
ProtocolError – If
linktypeis a name, abool, or a member or code the 16-bit LinkType field cannot carry; or ifsnaplenis not anint(aboolincluded), or is outside0to0xFFFFFFFF, which the 32-bit SnapLen field would truncate (#2278).
Changed in version 1.5.0:
snaplen’s default changed from0xFFFF_FFFF_FFFF_FFFF– which the 32-bit field silently truncated to0xFFFFFFFF– to0, and a value outside the field’s range now raises instead of being truncated (#2278).Changed in version 1.6.0:
snaplenis checked by_make_uint(), so aboolor a non-integer raisesProtocolErrortoo (#2614).
- _make_block_packet(block=None, *, interface_id=0, drop_count=0, timestamp=None, captured_len=None, original_len=None, packet_data=b'', options=None, **kwargs)[source]¶
Make PCAP-NG packet block (obsolete).
- Parameters:
block (
PacketBlock|None) – Block data model.interface_id (
int) – Interface ID.drop_count (
int) – Drops count,0xFFFFfor “not available”.timestamp (
float|Decimal|int|datetime|None) – Packet timestamp.packet_data (
bytes|ProtocolBase|Schema) – Payload of the block.options (
OrderedMultiDict[OptionType,Option] |list[Option|tuple[OptionType|int,dict[str,Any]] |bytes] |None) – Block options.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed block schema.
- Raises:
ProtocolError – If
drop_countis not anint(aboolincluded), or is outside0to0xFFFF.
Changed in version 1.6.0:
drop_countis checked by_make_uint(), so a value the 16-bit field cannot hold,-1included, or aboolraisesProtocolErrorrather than being written masked (#2614).
- _make_block_spb(block=None, *, original_len=None, packet_data=b'', **kwargs)[source]¶
Make PCAP-NG simple packet block (SPB).
- Parameters:
block (
SimplePacketBlock|None) – Block data model.packet_data (
bytes|ProtocolBase|Schema) – Payload of the block.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed block schema.
- _make_block_nrb(block=None, *, records=None, options=None, **kwargs)[source]¶
Make PCAP-NG name resolution block (NRB).
- Parameters:
block (
NameResolutionBlock|None) – Block data model.records (
OrderedMultiDict[RecordType,NameResolutionRecord] |list[NameResolutionRecord|tuple[RecordType|int,dict[str,Any]] |bytes] |None) – Name resolution records.options (
OrderedMultiDict[OptionType,Option] |list[Option|tuple[OptionType|int,dict[str,Any]] |bytes] |None) – Block options.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed block schema.
- _make_block_isb(block=None, *, interface_id=0, timestamp=None, options=None, **kwargs)[source]¶
Make PCAP-NG interface statistics block (ISB).
- Parameters:
block (
InterfaceStatisticsBlock|None) – Block data model.interface_id (
int) – Interface ID.timestamp (
float|Decimal|int|datetime|None) – Block timestamp.options (
OrderedMultiDict[OptionType,Option] |list[Option|tuple[OptionType|int,dict[str,Any]] |bytes] |None) – Block options.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed block schema.
- _make_block_epb(block=None, *, interface_id=0, timestamp=None, captured_len=None, original_len=None, packet_data=b'', options=None, **kwargs)[source]¶
Make PCAP-NG enhanced packet block (EPB).
- Parameters:
block (
EnhancedPacketBlock|None) – Block data model.interface_id (
int) – Interface ID.timestamp (
float|Decimal|int|datetime|None) – Packet timestamp.packet_data (
bytes|ProtocolBase|Schema) – Payload of the block.options (
OrderedMultiDict[OptionType,Option] |list[Option|tuple[OptionType|int,dict[str,Any]] |bytes] |None) – Block options.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed block schema.
- _make_block_systemd(block=None, *, entries=None, **kwargs)[source]¶
Make PCAP-NG systemd(1) journal export block.
- Parameters:
block (
SystemdJournalExportBlock|None) – Block data model.entries (
list[OrderedMultiDict[str,str|bytes]] |bytes|None) – systemd(1) journal export entries.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed block schema.
- _make_block_dsb(block=None, *, secrets_type=SecretsType.TLS_Key_Log, secrets_data=b'', options=None, **kwargs)[source]¶
Make PCAP-NG decryption secrets block (DSB).
- Parameters:
block (
DecryptionSecretsBlock|None) – Block data model.secrets_type (
SecretsType|int) – Decryption secrets type.secrets_data (
DSBSecrets|DSBSecrets|bytes|dict[str,Any]) – Decryption secrets data. Rawbytesare read as the Secrets Data of a parsed block are, through the schema registered forsecrets_type(#2273).options (
OrderedMultiDict[OptionType,Option] |list[Option|tuple[OptionType|int,dict[str,Any]] |bytes] |None) – Block options.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed block schema.
- Raises:
ProtocolError – If
secrets_typeis a name, abool, or a member or code the 32-bit Secrets Type field cannot carry; or ifsecrets_datais none of the forms this maker reads – rawbytes, adictof secrets arguments, aDSBSecretsdata model or aSchema.
- _make_block_cb(block=None, *, pen=0, data=b'', options=None, **kwargs)[source]¶
Make PCAP-NG custom block (CB).
- Parameters:
block (
CustomBlock|None) – Block data model.pen (
int) – Private enterprise number.options (
OrderedMultiDict[OptionType,Option] |list[Option|tuple[OptionType|int,dict[str,Any]] |bytes] |None) – Block options.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed block schema.
- _make_block_shb(block=None, *, version=(1, 0), major_version=None, minor_version=None, section_length=-1, options=None, byteorder=sys.byteorder, **kwargs)[source]¶
Make PCAP-NG section header block (SHB).
- Parameters:
block (
SectionHeaderBlock|None) – Block data model.version (
tuple[int,int] |VersionInfo) – Version information.section_length (
int) – Section length,-1(or0xFFFFFFFFFFFFFFFF) for “not specified”.options (
OrderedMultiDict[OptionType,Option] |list[Option|tuple[OptionType|int,dict[str,Any]] |bytes] |None) – Block options.byteorder (
Literal['big','little']) – Byte order of the section; a parsed block keeps its own.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed block schema.
- Raises:
ProtocolError – If
section_lengthis not anint(aboolincluded), or is outside-2 ** 63to2 ** 64 - 1.
Changed in version 1.6.0:
section_lengthis checked by_make_sint(), so a value outside the 64-bit field in either spelling, aboolor a non-integer raisesProtocolErrorrather than being written masked or failing to pack;-1and0xFFFFFFFFFFFFFFFFstill write the same octets (#2614).
- _make_option_unknown(type, option=None, *, data=b'', **kwargs)[source]¶
Make unknown PCAP-NG option.
- Parameters:
type (
OptionType) – Option type.option (
UnknownOption|None) – Option data model.data (
bytes) – Unspecified option data.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed option schema.
- _make_option_endofopt(type, option=None, **kwargs)[source]¶
Make PCAP-NG
opt_endofoptoption.- Parameters:
type (
OptionType) – Option type.option (
EndOfOption|None) – Option data model.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed option schema.
- _make_option_comment(type, option=None, *, comment='', **kwargs)[source]¶
Make PCAP-NG
opt_commentoption.- Parameters:
type (
OptionType) – Option type.option (
CommentOption|None) – Option data model.comment (
str) – Comment text.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed option schema.
- _make_option_custom(type, option=None, *, pen=0xFFFFFFFF, data=b'', **kwargs)[source]¶
Make PCAP-NG
opt_customoption.- Parameters:
type (
OptionType) – Option type.option (
CustomOption|None) – Option data model.pen (
int) – Private enterprise number.data (
bytes) – Custom data.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed option schema.
- _make_option_if_name(type, option=None, *, name='', **kwargs)[source]¶
Make PCAP-NG
if_nameoption.- Parameters:
type (
OptionType) – Option type.option (
IF_NameOption|None) – Option data model.name (
str) – Interface name.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed option schema.
- _make_option_if_description(type, option=None, *, description='', **kwargs)[source]¶
Make PCAP-NG
if_descriptionoption.- Parameters:
type (
OptionType) – Option type.option (
IF_DescriptionOption|None) – Option data model.description (
str) – Interface description.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed option schema.
- _make_option_if_ipv4(type, option=None, *, interface='192.168.1.1/255.255.255.0', **kwargs)[source]¶
Make PCAP-NG
if_IPv4addroption.- Parameters:
type (
OptionType) – Option type.option (
IF_IPv4AddrOption|None) – Option data model.interface (
IPv4Interface|str) – IPv4 interface.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed option schema.
- _make_option_if_ipv6(type, option=None, *, interface='2001:0db8:85a3:08d3:1319:8a2e:0370:7344/64', **kwargs)[source]¶
Make PCAP-NG
if_IPv6addroption.- Parameters:
type (
OptionType) – Option type.option (
IF_IPv6AddrOption|None) – Option data model.interface (
IPv6Interface|str) – IPv6 interface.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed option schema.
- _make_option_if_mac(type, option=None, *, interface='00:01:02:03:04:05', **kwargs)[source]¶
Make PCAP-NG
if_MACaddroption.- Parameters:
type (
OptionType) – Option type.option (
IF_MACAddrOption|None) – Option data model.interface (
str|bytes|bytearray) – MAC interface address.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed option schema.
- _make_option_if_eui(type, option=None, *, interface='02:34:56:FF:FE:78:9A:BC', **kwargs)[source]¶
Make PCAP-NG
if_EUIaddroption.- Parameters:
type (
OptionType) – Option type.option (
IF_EUIAddrOption|None) – Option data model.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed option schema.
- _make_option_if_speed(type, option=None, *, speed=100000000, **kwargs)[source]¶
Make PCAP-NG
if_speedoption.- Parameters:
type (
OptionType) – Option type.option (
IF_SpeedOption|None) – Option data model.speed (
int) – Interface speed, in bits per second.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed option schema.
- _make_option_if_tsresol(type, option=None, *, resolution=DEFAULT_RESOLUTION, **kwargs)[source]¶
Make PCAP-NG
if_tsresoloption.- Parameters:
type (
OptionType) – Option type.option (
IF_TSResolOption|None) – Option data model.resolution (
int) – Resolution of timestamps, in units per second.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed option schema.
- _make_option_if_tzone(type, option=None, *, tzone=0, **kwargs)[source]¶
Make PCAP-NG
if_tzoneoption.- Parameters:
type (
OptionType) – Option type.option (
IF_TZoneOption|None) – Option data model.tzone (
timezone|timedelta|int) – Timezone offset from UTC, as atimezone, atimedeltaor anintof seconds.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed option schema.
- Raises:
ProtocolError – If
tzoneis none of those types, or is abool, or its seconds do not fit the signed 32-bit field.
Changed in version 1.6.0: An offset the signed 32-bit field cannot hold, or a
bool, raisesProtocolErrorrather than being written truncated (#2614).
- _make_option_if_filter(type, option=None, *, filter=FilterType(0), expression=b'', **kwargs)[source]¶
Make PCAP-NG
if_filteroption.- Parameters:
type (
OptionType) – Option type.option (
IF_FilterOption|None) – Option data model.filter (
FilterType|int) – Filter type.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed option schema.
- Raises:
ProtocolError – If
filteris a name, abool, or a member or code the 8-bit filter type field cannot carry.
- _make_option_if_os(type, option=None, *, os=platform.platform(), **kwargs)[source]¶
Make PCAP-NG
if_osoption.- Parameters:
type (
OptionType) – Option type.option (
IF_OSOption|None) – Option data model.os (
str) – Operating system name.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed option schema.
- _make_option_if_fcslen(type, option=None, *, fcs_length=4, **kwargs)[source]¶
Make PCAP-NG
if_fcslenoption.- Parameters:
type (
OptionType) – Option type.option (
IF_FCSLenOption|None) – Option data model.fcs_length (
int) – FCS length, in bytes.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed option schema.
- _make_option_if_tsoffset(type, option=None, *, offset=0, **kwargs)[source]¶
Make PCAP-NG
if_tsoffsetoption.- Parameters:
type (
OptionType) – Option type.option (
IF_TSOffsetOption|None) – Option data model.offset (
int) – Timestamp offset in seconds.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed option schema.
- Raises:
ProtocolError – If
offsetis not anint, is abool, or does not fit the signed 64-bit field.
Changed in version 1.6.0: An offset the signed 64-bit field cannot hold, a
boolor a non-integer raisesProtocolErrorrather than being written truncated, written as zero (None) or failing to pack (#2614).
- _make_option_if_hardware(type, option=None, *, hardware=platform.processor(), **kwargs)[source]¶
Make PCAP-NG
if_hardwareoption.- Parameters:
type (
OptionType) – Option type.option (
IF_HardwareOption|None) – Option data model.hardware (
str) – Hardware information.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed option schema.
- _make_option_if_txspeed(type, option=None, *, speed=100000000, **kwargs)[source]¶
Make PCAP-NG
if_txspeedoption.- Parameters:
type (
OptionType) – Option type.option (
IF_TxSpeedOption|None) – Option data model.speed (
int) – Interface transmit speed, in bits per second.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed option schema.
- _make_option_if_rxspeed(type, option=None, *, speed=100000000, **kwargs)[source]¶
Make PCAP-NG
if_rxspeedoption.- Parameters:
type (
OptionType) – Option type.option (
IF_RxSpeedOption|None) – Option data model.speed (
int) – Interface receive speed, in bits per second.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed option schema.
- _make_option_epb_flags(type, option=None, *, direction=PacketDirection.UNKNOWN, reception=PacketReception.UNKNOWN, fcs_len=0, checksum_not_ready=False, checksum_valid=False, tcp_segmentation_offloaded=False, reserved=0, crc_error=False, too_long=False, too_short=False, gap_error=False, unaligned_error=False, delimiter_error=False, preamble_error=False, symbol_error=False, **kwargs)[source]¶
Make PCAP-NG
epb_flagsoption.- Parameters:
type (
OptionType) – Option type.option (
EPB_FlagsOption|None) – Option data model.direction (
PacketDirection|int) – Packet direction.reception (
PacketReception|int) – Packet reception.fcs_len (
int) – Length of FCS field, in bytes.checksum_not_ready (
bool) – Whether the checksum is not ready.checksum_valid (
bool) – Whether the checksum is valid.tcp_segmentation_offloaded (
bool) – Whether TCP segmentation was offloaded.reserved (
int) – Bits 12 to 23 of the flags word, verbatim.crc_error (
bool) – Whether CRC error occurred.too_long (
bool) – Whether packet is too long.too_short (
bool) – Whether packet is too short.gap_error (
bool) – Whether gap error occurred.unaligned_error (
bool) – Whether unaligned error occurred.delimiter_error (
bool) – Whether delimiter error occurred.preamble_error (
bool) – Whether preamble error occurred.symbol_error (
bool) – Whether symbol error occurred.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed option schema.
- Raises:
ProtocolError – If
directionorreceptionis a name, abool, or a member or code its 2-bit or 3-bit sub-field cannot carry.
- _make_option_epb_hash(type, option=None, *, algorithm=HashAlgorithm.two_s_complement, hash=b'', **kwargs)[source]¶
Make PCAP-NG
epb_hashoption.- Parameters:
type (
OptionType) – Option type.option (
EPB_HashOption|None) – Option data model.algorithm (
HashAlgorithm|int) – Hash algorithm.hash (
bytes) – Hash value.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed option schema.
- Raises:
ProtocolError – If
algorithmis a name, abool, or a member or code the 8-bit hash algorithm field cannot carry.
- _make_option_epb_dropcount(type, option=None, *, drop_count=0, **kwargs)[source]¶
Make PCAP-NG
epb_dropcountoption.- Parameters:
type (
OptionType) – Option type.option (
EPB_DropCountOption|None) – Option data model.drop_count (
int) – Number of dropped packets.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed option schema.
- _make_option_epb_packetid(type, option=None, *, packet_id=0, **kwargs)[source]¶
Make PCAP-NG
epb_packetidoption.- Parameters:
type (
OptionType) – Option type.option (
EPB_PacketIDOption|None) – Option data model.packet_id (
int) – Packet ID.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed option schema.
- _make_option_epb_queue(type, option=None, *, queue_id=0, **kwargs)[source]¶
Make PCAP-NG
epb_queueoption.- Parameters:
type (
OptionType) – Option type.option (
EPB_QueueOption|None) – Option data model.queue_id (
int) – Queue ID.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed option schema.
- _make_option_epb_verdict(type, option=None, *, verdict=VerdictType.Hardware, value=b'', **kwargs)[source]¶
Make PCAP-NG
epb_verdictoption.- Parameters:
type (
OptionType) – Option type.option (
EPB_VerdictOption|None) – Option data model.verdict (
VerdictType|int) – Verdict type.value (
bytes) – Verdict value.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed option schema.
- Raises:
ProtocolError – If
verdictis a name, abool, or a member or code the 8-bit verdict type field cannot carry.
- _make_option_ns_dnsname(type, option=None, *, name='', **kwargs)[source]¶
Make PCAP-NG
ns_dnsnameoption.- Parameters:
type (
OptionType) – Option type.option (
NS_DNSNameOption|None) – Option data model.name (
str) – DNS server name.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed option schema.
- _make_option_ns_dnsipv4(type, option=None, *, ip='8.8.8.8', **kwargs)[source]¶
Make PCAP-NG
ns_dnsIP4addroption.- Parameters:
type (
OptionType) – Option type.option (
NS_DNSIP4AddrOption|None) – Option data model.ip (
str|bytes|IPv4Address|int) – DNS server IPv4 address.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed option schema.
- _make_option_ns_dnsipv6(type, option=None, *, ip='2001:4860:4860::8888', **kwargs)[source]¶
Make PCAP-NG
ns_dnsIP6addroption.- Parameters:
type (
OptionType) – Option type.option (
NS_DNSIP6AddrOption|None) – Option data model.ip (
str|bytes|IPv6Address|int) – DNS server IPv6 address.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed option schema.
- _make_option_isb_starttime(type, option=None, *, timestamp=None, **kwargs)[source]¶
Make PCAP-NG
isb_starttimeoption.- Parameters:
type (
OptionType) – Option type.option (
ISB_StartTimeOption|None) – Option data model.timestamp (
float|Decimal|int|datetime|None) – Start time.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed option schema.
- _make_option_isb_endtime(type, option=None, *, timestamp=None, **kwargs)[source]¶
Make PCAP-NG
isb_endtimeoption.- Parameters:
type (
OptionType) – Option type.option (
ISB_EndTimeOption|None) – Option data model.timestamp (
float|Decimal|int|datetime|None) – End time.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed option schema.
- _make_option_isb_ifrecv(type, option=None, *, packets=0, **kwargs)[source]¶
Make PCAP-NG
isb_ifrecvoption.- Parameters:
type (
OptionType) – Option type.option (
ISB_IFRecvOption|None) – Option data model.packets (
int) – Number of received packets.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed option schema.
- _make_option_isb_ifdrop(type, option=None, *, packets=0, **kwargs)[source]¶
Make PCAP-NG
isb_ifdropoption.- Parameters:
type (
OptionType) – Option type.option (
ISB_IFDropOption|None) – Option data model.packets (
int) – Number of dropped packets.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed option schema.
- _make_option_isb_filteraccept(type, option=None, *, packets=0, **kwargs)[source]¶
Make PCAP-NG
isb_filteracceptoption.- Parameters:
type (
OptionType) – Option type.option (
ISB_FilterAcceptOption|None) – Option data model.packets (
int) – Number of packets accepted by the filter.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed option schema.
- _make_option_isb_osdrop(type, option=None, *, packets=0, **kwargs)[source]¶
Make PCAP-NG
isb_osdropoption.- Parameters:
type (
OptionType) – Option type.option (
ISB_OSDropOption|None) – Option data model.packets (
int) – Number of packets dropped by the OS.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed option schema.
- _make_option_isb_usrdeliv(type, option=None, *, packets=0, **kwargs)[source]¶
Make PCAP-NG
isb_usrdelivoption.- Parameters:
type (
OptionType) – Option type.option (
ISB_UsrDelivOption|None) – Option data model.packets (
int) – Number of packets delivered to the user.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed option schema.
- _make_option_pack_flags(type, option=None, *, direction=PacketDirection.UNKNOWN, reception=PacketReception.UNKNOWN, fcs_len=0, checksum_not_ready=False, checksum_valid=False, tcp_segmentation_offloaded=False, reserved=0, crc_error=False, too_long=False, too_short=False, gap_error=False, unaligned_error=False, delimiter_error=False, preamble_error=False, symbol_error=False, **kwargs)[source]¶
Make PCAP-NG
pack_flagsoption.- Parameters:
type (
OptionType) – Option type.option (
PACK_FlagsOption|None) – Option data model.direction (
PacketDirection|int) – Packet direction.reception (
PacketReception|int) – Packet reception.fcs_len (
int) – Length of FCS field, in bytes.checksum_not_ready (
bool) – Whether the checksum is not ready.checksum_valid (
bool) – Whether the checksum is valid.tcp_segmentation_offloaded (
bool) – Whether TCP segmentation was offloaded.reserved (
int) – Bits 12 to 23 of the flags word, verbatim.crc_error (
bool) – Whether CRC error occurred.too_long (
bool) – Whether packet is too long.too_short (
bool) – Whether packet is too short.gap_error (
bool) – Whether gap error occurred.unaligned_error (
bool) – Whether unaligned error occurred.delimiter_error (
bool) – Whether delimiter error occurred.preamble_error (
bool) – Whether preamble error occurred.symbol_error (
bool) – Whether symbol error occurred.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed option schema.
- Raises:
ProtocolError – If
directionorreceptionis a name, abool, or a member or code its 2-bit or 3-bit sub-field cannot carry.
- _make_option_pack_hash(type, option=None, *, algorithm=HashAlgorithm.two_s_complement, hash=b'', **kwargs)[source]¶
Make PCAP-NG
pack_hashoption.- Parameters:
type (
OptionType) – Option type.option (
PACK_HashOption|None) – Option data model.algorithm (
HashAlgorithm|int) – Hash algorithm.hash (
bytes) – Hash value.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed option schema.
- Raises:
ProtocolError – If
algorithmis a name, abool, or a member or code the 8-bit hash algorithm field cannot carry.
- _make_record_unknown(type, record=None, *, data=b'', **kwargs)[source]¶
Make PCAP-NG unknown name resolution record.
- Parameters:
type (
RecordType) – Record type.record (
UnknownRecord|None) – Record data model.data (
bytes) – Record data.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed record schema.
- _make_record_end(type, record=None, **kwargs)[source]¶
Make PCAP-NG
nrb_record_endname resolution record.- Parameters:
type (
RecordType) – Record type.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed record schema.
- _make_record_ipv4(type, record=None, *, ip='127.0.0.1', names=None, **kwargs)[source]¶
Make PCAP-NG
nrb_record_ipv4name resolution record.- Parameters:
type (
RecordType) – Record type.record (
IPv4Record|None) – Record data model.ip (
IPv4Address|str|bytes|int) – IPv4 address.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed record schema.
- _make_record_ipv6(type, record=None, *, ip='::1', names=None, **kwargs)[source]¶
Make PCAP-NG
nrb_record_ipv6name resolution record.- Parameters:
type (
RecordType) – Record type.record (
IPv6Record|None) – Record data model.ip (
IPv6Address|str|bytes|int) – IPv6 address.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed record schema.
- _make_secrets_unknown(type, secrets=None, *, data=b'', **kwargs)[source]¶
Make PCAP-NG unknown secrets.
- Parameters:
type (
SecretsType) – Secrets type.secrets (
UnknownSecrets|None) – Secrets data model.data (
bytes) – Secrets data.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed secrets schema.
- _make_secrets_tls(type, secrets=None, *, entries=None, data=None, **kwargs)[source]¶
Make PCAP-NG TLS Key Log secrets.
- Parameters:
type (
SecretsType) – Secrets type.secrets (
TLSKeyLog|None) – Secrets data model. The key log text it was parsed from, if any, is written back verbatim; otherwise its entries are. On a parsed model the text wins, so an edit to itsentriesalone is silently ignored.entries (
Mapping[TLSKeyLabel,OrderedMultiDict[bytes,bytes]] |None) – TLS Key Log entries.data (
str|None) – TLS key log text, written back verbatim in place ofentries, as the text ofsecretsis.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed secrets schema.
- _make_secrets_wireguard(type, secrets=None, *, entries=None, data=None, **kwargs)[source]¶
Make PCAP-NG WireGuard secrets.
- Parameters:
type (
SecretsType) – Secrets type.secrets (
WireGuardKeyLog|None) – Secrets data model. The key log text it was parsed from, if any, is written back verbatim; otherwise its entries are. On a parsed model the text wins, so an edit to itsentriesalone is silently ignored.entries (
OrderedMultiDict[WireGuardKeyLabel,bytes] |None) – WireGuard Key Log entries.data (
str|None) – WireGuard key log text, written back verbatim in place ofentries, as the text ofsecretsis.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed secrets schema.
Changed in version 1.6.0: Takes the key log text as
data, as_make_secrets_tls()does (#2698).
- _make_secrets_zigbee_aps(type, secrets=None, *, aps_key=bytes(16), pan_id=0, short_address=0, data=None, **kwargs)[source]¶
Make PCAP-NG ZigBee APS Key secrets.
- Parameters:
type (
SecretsType) – Secrets type.secrets (
ZigBeeAPSKey|None) – Secrets data model. The Secrets Data octets it was parsed from, if any, are written back verbatim, as for_make_secrets_zigbee_nwk(); otherwise its fields are.aps_key (
bytes) – APS key, 16 octets.pan_id (
int) – PAN ID.short_address (
int) – Short address.data (
bytes|None) – Secrets Data octets, written back verbatim in place of the fields, as the octets ofsecretsare.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed secrets schema.
- Raises:
ProtocolError – If
aps_keyis not 16 octets.
Changed in version 1.6.0:
Takes the Secrets Data octets as
data, as_make_secrets_zigbee_nwk()does (#2698).aps_keyof any other width, empty included, raisesProtocolErrorrather than being padded or cut to the 16-octet key, and defaults to 16 zero octets where it defaulted to empty (#2676).
- _make_secrets_zigbee_nwk(type, secrets=None, *, nwk_key=bytes(16), pan_id=0, data=None, **kwargs)[source]¶
Make PCAP-NG ZigBee NWK Key secrets.
- Parameters:
type (
SecretsType) – Secrets type.secrets (
ZigBeeNWKKey|None) – Secrets data model. The Secrets Data octets it was parsed from, if any, are written back verbatim, so that a key shorter or longer than its fixed width rebuilds as captured (#1986); otherwise its fields are. On a parsed model the octets win, so an edit to its fields alone is silently ignored.nwk_key (
bytes) – NWK key, 16 octets.pan_id (
int) – PAN ID.data (
bytes|None) – Secrets Data octets, written back verbatim in place ofnwk_keyandpan_id, as the octets ofsecretsare.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed secrets schema.
- Raises:
ProtocolError – If
nwk_keyis not 16 octets.
Changed in version 1.6.0:
Takes the Secrets Data octets as
data, so that thedictof a parsed model rebuilds the key as captured, as the model itself does, rather than as its zero-filled fields (#2698).nwk_keyof any other width, empty included, raisesProtocolErrorrather than being padded or cut to the 16-octet key, and defaults to 16 zero octets where it defaulted to empty (#2676).
- _check_block_floor(length)[source]¶
Reject a tail too short to hold any block at all.
- Parameters:
length (
int|None) – Length of packet data, as the caller declared it, orNoneto measure what is left inself._file.- Raises:
StreamEOFError – If fewer than twelve octets are left to read.
A PCAP-NG block is twelve octets at its smallest – Block Type, Block Total Length and the trailing copy of it, over an empty body – which is what
__length_hint__()reports. A tail shorter than that is not a block, so parsing one out of it can only invent fields fromFieldBase.unpack’s zero padding, and once the four octets ofPCAPNG.typehave been padded out of nothing__length__is negative – whichpcapng_block_selector()hands toSchemaField, whereio.RawIOBase.read()raises the bareValueErrorof #678.Reporting the end of the stream instead is what keeps the #431 accommodation:
StreamEOFErroris anEOFError, whichExtractor.record_framesalready catches to stop with the frames read so far, so – unlike a refusal insideFieldBase.unpack, which has no catch point above it and would abort the whole extraction – this costs no frame that was actually in the file. It is the same signalprepare()raises for a derived remainder of exactly zero; a remainder of one, two or three octets passes that check and is caught here instead.Note
This runs on both of
unpack()’s paths. On the parsing path the tail is what the file has left to read; on the construction path it is the octets of a block handed tomake()as rawbytes, whichunpack()parses off the bufferpack()has just filled (#2354) – a caller’s octets are no more trustworthy than a file’s. Octets too short for this floor are therefore refused here rather than byread()’s own Block Total Length check, which sees only what gets past the floor and so names an impossible declared length, never a tail too short to declare one.Measuring an undeclared length needs the stream to seek, and nothing guards that here because
__post_init__()has already calledtell()on it to record_seek_set: a stream that could not seek never reaches this method.
- _get_payload()[source]¶
Get payload of
self.__header__.- Return type:
- Returns:
Payload of
self.__header__asbytes.
See also
This is a wrapper function for
pcapkit.protocols.schema.Schema.get_payload().Note
A packet block kept as captured has no payload (see
_read_block_short()).
- _make_mac_addr(addr, *, size=6, name='MAC address', alias=None)[source]¶
Make a MAC address, or an EUI-64 one with
size=8.- Parameters:
- Return type:
- Returns:
The address packed as
sizeoctets, 6 by default.- Raises:
ProtocolError – If
addris not astr,bytesorbytearray(aboolincluded), or is not a:- or--separated hex encoded address ofsizeoctets.
- _decode_next_layer(dict_, proto=None, length=None, *, packet=None)[source]¶
Decode next layer protocol.
- Parameters:
- Return type:
- Returns:
Current protocol with packet extracted.
Notes
dict_gains__next_type__and__next_name__, the next layer’s protocol type and name, whichInfo.to_dictcarries and the dumpers leave out, andprotocols, the protocol chain of the current packet (frame).protois dispatched as_dispatch_linktype()says, soLINKTYPE_RAWdata is read as IPv4 or IPv6 (#1502).
- _dispatch_linktype(proto, length=None)[source]¶
Link type a packet block’s data is dispatched under.
- Parameters:
- Return type:
- Returns:
For
LinkType.RAWdata whose first octet carries IP version 4 or 6,LinkType.IPV4orLinkType.IPV6; otherwiseproto.
Note
As
Frame._dispatch_linktypedoes for PCAP:LINKTYPE_RAW(101) data is IPv4 or IPv6 by its version nibble, an entry registered underRAWitself is used as it stands, and data of any other version is kept asRaw(#1502).
- _read_pcapng_options(options_schema)[source]¶
Read PCAP-NG options.
Structure of PCAP-NG option:
1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Option Code | Option Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ / Option Value / / variable length, padded to 32 bits / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ / / / . . . other options . . . / / / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Option Code == opt_endofopt | Option Length == 0 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- Parameters:
- Return type:
- Returns:
Parsed PCAP-NG options data.
- _read_nrb_records(records_schema)[source]¶
Read PCAP-NG name resolution records.
- Parameters:
records_schema (
list[NameResolutionRecord]) – Parsed name resolution records.- Return type:
- Returns:
Parsed PCAP-NG name resolution records data.
- _make_pcapng_options(options, namespace)[source]¶
Make options for PCAP-NG.
- Parameters:
options (
OrderedMultiDict[OptionType,Option] |list[Option|tuple[OptionType|int,dict[str,Any]] |bytes] |bytes) – PCAP-NG options. An option’s code is a member, kept as given, or anint, resolved innamespace.namespace (
str) – Namespace of options.
- Return type:
- Returns:
Tuple of options and total length of options.
- Raises:
ProtocolError – If an option’s code is a name, a
bool, or a code the 16-bit option code field cannot carry (#2594), or if an option given as raw octets is shorter than that field (#2723).
- _make_nrb_records(records)[source]¶
Make name resolution records for PCAP-NG.
- Parameters:
records (
OrderedMultiDict[RecordType,NameResolutionRecord] |list[NameResolutionRecord|tuple[RecordType|int,dict[str,Any]] |bytes] |bytes) – PCAP-NG name resolution records.- Return type:
- Returns:
Tuple of name resolution records and total length of the records.
- Raises:
ProtocolError – If a record’s type is a name, a
bool, or a code the 16-bit record type field cannot carry (#2594), or if a record given as raw octets is shorter than that field (#2723).
Auxiliary Data¶
- class pcapkit.protocols.misc.pcapng.protocol.PacketDirection(*values)[source]¶
Bases:
EnumLookup,IntEnumPacket direction for
epb_flagsoptions.Shares the
EnumLookuplookup contract that every non-registry enumeration follows (#877). Its_missing_resolves the one value the specification leaves undefined,0b11, to an unassigned member, so a capture carrying it still parses and rebuilds (#1382).- UNKNOWN = 0¶
Information not available.
- INBOUND = 1¶
Inbound packet.
- OUTBOUND = 2¶
Outbound packet.
- classmethod _missing_(value)[source]¶
Lookup function used when value is not found.
- Parameters:
value (
object) – Value to get enum item.- Return type:
- Returns:
An unassigned member, absent from the lookup tables.
- Raises:
EnumValueError – If
valuedoes not fit the 2-bit sub-field.
- class pcapkit.protocols.misc.pcapng.protocol.PacketReception(*values)[source]¶
Bases:
EnumLookup,IntEnumReception type for
epb_flagsoptions.Shares the
EnumLookuplookup contract that every non-registry enumeration follows (#877). Its_missing_resolves the values the specification leaves undefined,0b101to0b111, to an unassigned member, so a capture carrying one still parses and rebuilds (#1382).- UNKNOWN = 0¶
Not specified.
- UNICAST = 1¶
Unicast.
- MULTICAST = 2¶
Multicast.
- BROADCAST = 3¶
Broadcast.
- PROMISCUOUS = 4¶
Promiscuous.
- classmethod _missing_(value)[source]¶
Lookup function used when value is not found.
- Parameters:
value (
object) – Value to get enum item.- Return type:
- Returns:
An unassigned member, absent from the lookup tables.
- Raises:
EnumValueError – If
valuedoes not fit the 3-bit sub-field.
TLSKeyLabel is defined
in pcapkit.const.pcapng.tls_key_label, generated like its
pcapkit.const.pcapng siblings because RFC 9850 Section 4.2 makes it an
IANA registry.
Removed in version 1.5.0: pcapkit.protocols.misc.pcapng.TLSKeyLabel, with no alias; use
pcapkit.const.pcapng.tls_key_label.TLSKeyLabel instead
(#886, #1744).
- class pcapkit.protocols.misc.pcapng.protocol.WireGuardKeyLabel(*values)[source]¶
Bases:
EnumLookup,StrEnumWireGuard key log label.
Shares the
EnumLookuplookup contract that every non-registry enumeration follows (#877); it defines neithergetnor_missing_of its own.- LOCAL_STATIC_PRIVATE_KEY = 'LOCAL_STATIC_PRIVATE_KEY'¶
- REMOTE_STATIC_PUBLIC_KEY = 'REMOTE_STATIC_PUBLIC_KEY'¶
- LOCAL_EPHEMERAL_PRIVATE_KEY = 'LOCAL_EPHEMERAL_PRIVATE_KEY'¶
- PRESHARED_KEY = 'PRESHARED_KEY'¶
Header Schemas¶
Removed in version 1.6.0: pcapkit.protocols.schema.misc.pcapng, with no alias: the module moved here
(#2534).
- pcapkit.protocols.misc.pcapng.schema.BYTE_ORDER_MAGIC = 439041101¶
Byte-Order Magic of a Section Header Block, read in the byte order of the section that wrote it. The one home of this value (#1739); the format fixes it, so it is never configurable.
Added in version 1.5.0.
- pcapkit.protocols.misc.pcapng.schema.GENERIC_BLOCK_MINIMUM = 12¶
The octets every block’s fixed fields span – Block Type and both copies of Block Total Length – and so the shortest Block Total Length of any block, and the whole of it for a block not in
BLOCK_MINIMUM. The one home of this value (#1739); the format fixes it, so it is never configurable.Added in version 1.5.0.
- pcapkit.protocols.misc.pcapng.schema.BLOCK_MINIMUM: Dict[int, int]¶
Block types mapped to the octets their fixed fields span, Block Type and both copies of Block Total Length included; any other block spans
GENERIC_BLOCK_MINIMUM. The one home of these values (#1739); the format fixes them, so they are never configurable.Added in version 1.5.0.
- pcapkit.protocols.misc.pcapng.schema.DEFAULT_RESOLUTION = 1000000¶
Units per second of a timestamp on an interface that carries no
if_tsresoloption: microseconds, the default the format gives that option. The one home of this value (#1739); the format fixes it, so it is never configurable.Added in version 1.5.0.
- pcapkit.protocols.misc.pcapng.schema.PACKET_FLAGS: dict[str, tuple[int, int]]¶
Sub-fields of the
epb_flagsandpack_flagswords.reservedkeeps bits 12 to 23 verbatim – the reserved bits 12-15 and the link-layer-dependent error bits 16-23 that the data model does not name.
- class pcapkit.protocols.misc.pcapng.schema.PCAPNG(type=NO_VALUE, block=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
SchemaHeader schema for a PCAP-NG file block: its type, then its body.
- class pcapkit.protocols.misc.pcapng.schema.BlockType(*args, **kwargs)[source]¶
Bases:
EnumSchema[BlockType]Base header schema for the body of each PCAP-NG block type.
- class pcapkit.protocols.misc.pcapng.schema.UnknownBlock(length=NO_VALUE, body=NO_VALUE, length2=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
BlockTypeHeader schema for unknown PCAP-NG file blocks.
- class pcapkit.protocols.misc.pcapng.schema.SectionHeaderBlock(match=NO_VALUE, length=NO_VALUE, magic=NO_VALUE, major=NO_VALUE, minor=NO_VALUE, section_length=NO_VALUE, options=NO_VALUE, padding=NO_VALUE, length2=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
BlockTypeHeader schema for PCAP-NG Section Header Block (SHB).
- match: ByteorderTest = <ForwardMatchField match>¶
Fast-forward field to test the byte order.
- padding: bytes = <PaddingField padding>¶
Padding, sized from the
__option_padding__key that OptionField generates.
- pre_pack(packet)[source]¶
Prepare
packetdata for packing process.Note
This method is expected to directly modify any data stored in the
packetand thus no return is required.shb_byteorder_callback()takes the byte order from the Byte-Order Magic asmatchreads it, and a constructed block has nomatchto read – a forward match packs no octets – nor canmagicstand in, since it holds the same constant in either byte order. Somatchis seeded here from the byte order the packet data asks for, and from the host byte order when it asks for none; amatchalready inpacketis kept.
- post_process(packet)[source]¶
Revise
schemadata after unpacking process.This method calculates the byte order value based on the parsed schema.
- Parameters:
- Return type:
- Returns:
Revised schema.
A Block Total Length below the 28 octets of the fixed fields reads the trailing copy past the block, so the two are not compared here;
PCAPNG._read_block_short_headerkeeps the block as captured and compares them itself (#1422). A block of 12 octets has no Byte-Order Magic and takes its byte order from its Block Total Length (seeshb_byteorder_callback()).
- class pcapkit.protocols.misc.pcapng.schema.InterfaceDescriptionBlock(length=NO_VALUE, linktype=NO_VALUE, reserved=NO_VALUE, snaplen=NO_VALUE, options=NO_VALUE, padding=NO_VALUE, length2=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
BlockTypeHeader schema for PCAP-NG Interface Description Block (IDB).
- padding: bytes = <PaddingField padding>¶
Padding, sized from the
__option_padding__key that OptionField generates.
- post_process(packet)[source]¶
Revise
schemadata after unpacking process.A Block Total Length below the 20 octets of the fixed fields reads the trailing copy past the block, so the two are not compared here;
PCAPNG._read_block_short_headerkeeps the block as captured and compares them itself (#1422).
- class pcapkit.protocols.misc.pcapng.schema.EnhancedPacketBlock(length=NO_VALUE, interface_id=NO_VALUE, timestamp_high=NO_VALUE, timestamp_low=NO_VALUE, captured_len=NO_VALUE, original_len=NO_VALUE, packet_data=NO_VALUE, padding_data=NO_VALUE, options=NO_VALUE, padding_opts=NO_VALUE, length2=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
BlockTypeHeader schema for PCAP-NG Enhanced Packet Block (EPB).
- packet_data: bytes = <PayloadField packet_data>¶
Packet data, bounded by the block (see
captured_area()).
- padding_opts: bytes = <PaddingField padding_opts>¶
Padding, sized from the
__option_padding__key that OptionField generates.
- post_process(packet)[source]¶
Revise
schemadata after unpacking process.A Block Total Length below the 32 octets of the fixed fields reads the trailing copy past the block, so the two are not compared here;
PCAPNG._read_block_shortkeeps the block as captured and compares them itself (#1414).
- class pcapkit.protocols.misc.pcapng.schema.SimplePacketBlock(length=NO_VALUE, original_len=NO_VALUE, packet_data=NO_VALUE, padding=NO_VALUE, length2=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
BlockTypeHeader schema for PCAP-NG Simple Packet Block (SPB).
- packet_data: bytes = <PayloadField packet_data>¶
Packet data,
min(original_len, snaplen)octets, bounded by what the block holds; see_spb_data_length().
- class pcapkit.protocols.misc.pcapng.schema.NameResolutionBlock(length=NO_VALUE, records=NO_VALUE, options=NO_VALUE, padding=NO_VALUE, length2=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
BlockTypeHeader schema for PCAP-NG Name Resolution Block (NRB).
- records: list[NameResolutionRecord] = <OptionAreaField records>¶
Name resolution records.
- padding: bytes = <PaddingField padding>¶
Padding, sized from the
__option_padding__key that OptionField generates.
- mapping: MultiDict[IPv4Address | IPv6Address, str]¶
Name resolution mapping (IP address -> name).
- reverse_mapping: MultiDict[str, IPv4Address | IPv6Address]¶
Name resolution mapping (name -> IP address).
- class pcapkit.protocols.misc.pcapng.schema.InterfaceStatisticsBlock(length=NO_VALUE, interface_id=NO_VALUE, timestamp_high=NO_VALUE, timestamp_low=NO_VALUE, options=NO_VALUE, padding=NO_VALUE, length2=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
BlockTypeHeader schema for PCAP-NG Interface Statistics Block (ISB).
- class pcapkit.protocols.misc.pcapng.schema.SystemdJournalExportBlock(length=NO_VALUE, entry=NO_VALUE, length2=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
BlockTypeHeader schema for PCAP-NG systemd(1) Journal Export Block.
- post_process(packet)[source]¶
Revise
schemadata after unpacking process.Note
The entry is walked once, end to end, rather than split apart with
self.entry.split(b'\n\n'): that delimits a length-prefixed format by content, which a binary field’s own bytes need no escaping to defeat (struct.pack('<Q', 2570) == b'\n\n\x00\x00\x00\x00\x00\x00'puts the separator inside the length prefix itself). A binary field’s value is counted out by its prefix and never inspected; a blank line – found by reading – starts the next entry, even an empty one behind a trailing separator. A line of nothing but NUL octets at the end of the entry is the block’s own 32-bit padding and ends it.The walk is strict (#1406, #1413, and #1325, under which
OptionAreaFieldapplies to option areas). Any of the following raisesProtocolError, and the whole entry is then kept as the octets captured, as the onebytesitem ofdata, which the block’smakewrites back verbatim:a line, text field or binary field name, with no terminating newline, e.g. a bare
KEYat the end of the entry;a binary field whose 64-bit length prefix is cut short, or declares more octets than the entry has left – at
2**63and aboveio.BytesIO.read()would refuse it with a bareOverflowError;a binary field’s value not followed by the newline that terminates it, including one that ends the entry;
any other entry that the parsed fields would not rebuild octet for octet, e.g. a field that is not UTF-8.
A
struct.error,OverflowErrororUnicodeDecodeErroris neither one ofpcapkit.utilities.exceptionsnor anEOFError, so any of them would abort the whole extraction rather than this one entry. Field names, keys and values are therefore decoded witherrors='replace'and reported, which the rebuild check then catches, rather than strictly.
- static dump_entries(entries)[source]¶
Serialise journal entries, without the block’s 32-bit padding.
- data: list[OrderedMultiDict[str, str | bytes] | bytes]¶
Journal entry (decoded), or the entry as captured, as one
bytesitem, if it is malformed.
- _read_entries()[source]¶
Walk
entryinto its journal entries, aspost_process()describes.- Return type:
list[OrderedMultiDict[str,str|bytes]]- Returns:
The journal entries.
- Raises:
ProtocolError – If the entry is malformed, as
post_process()lists.
- static _decode_text(octets)[source]¶
Decode a journal field name, key or value, reporting what did not decode.
- Parameters:
octets (
bytes) – Field name, key or value, as it came off the wire.- Return type:
- Returns:
The decoded text, with any octet that is not UTF-8 replaced.
See
post_process()for why this replaces rather than raising.
- class pcapkit.protocols.misc.pcapng.schema.DecryptionSecretsBlock(length=NO_VALUE, secrets_type=NO_VALUE, secrets_length=NO_VALUE, secrets_data=NO_VALUE, padding_data=NO_VALUE, options=NO_VALUE, padding_opts=NO_VALUE, length2=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
BlockTypeHeader schema for PCAP-NG Decryption Secrets Block (DSB).
- secrets_type: SecretsType = <EnumField secrets_type>¶
Secrets type.
- secrets_data: DSBSecrets = <SwitchField secrets_data>¶
Secrets data, bounded by the block (see
secrets_area()).
- padding_opts: bytes = <PaddingField padding_opts>¶
Padding, sized from the
__option_padding__key that OptionField generates.
- post_process(packet)[source]¶
Revise
schemadata after unpacking process.A
secrets_lengthrunning past the block is kept as declared, and the secrets are the octets the block holds (seesecrets_area()), so this reports the overrun as aProtocolWarningand carries on to the next block (#1980).The report is made on the unpacking path only, where
__length__is what is left of the stream.Schema.packseeds it as-1, and rebuilding a block already reported is no new overrun. The lengths are read from the schema rather than frompacket, since packing the option area rebindspacket['length']to each option’s own length.
- class pcapkit.protocols.misc.pcapng.schema.CustomBlock(length=NO_VALUE, pen=NO_VALUE, data=NO_VALUE, length2=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
BlockTypeHeader schema for PCAP-NG Custom Block (CB).
Note
The block carries no length for its custom data, so where the custom data ends and the block options begin is known only to the owner of the private enterprise number.
datatherefore spans the whole region betweenpenand the trailing block total length, i.e. the custom data, its padding to a 32-bit boundary, and any options.
- class pcapkit.protocols.misc.pcapng.schema.PacketBlock(length=NO_VALUE, interface_id=NO_VALUE, drop_count=NO_VALUE, timestamp_high=NO_VALUE, timestamp_low=NO_VALUE, captured_length=NO_VALUE, original_length=NO_VALUE, packet_data=NO_VALUE, padding_data=NO_VALUE, options=NO_VALUE, padding_opts=NO_VALUE, length2=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
BlockTypeHeader schema for PCAP-NG Packet Block (obsolete).
- packet_data: bytes = <PayloadField packet_data>¶
Packet data, bounded by the block (see
captured_area()).
- padding_opts: bytes = <PaddingField padding_opts>¶
Padding, sized from the
__option_padding__key that OptionField generates.
- post_process(packet)[source]¶
Revise
schemadata after unpacking process.A Block Total Length below the 32 octets of the fixed fields reads the trailing copy past the block, so the two are not compared here;
PCAPNG._read_block_shortkeeps the block as captured and compares them itself (#1414).
- class pcapkit.protocols.misc.pcapng.schema.Option(*args, **kwargs)[source]¶
Bases:
EnumSchema[OptionType]Header schema for PCAP-NG file options.
- __enum__: DefaultDict[str, DefaultDict[OptionType, Type[Option]]] = {'dsb': {<OptionType.opt_endofopt: 0>: <class 'pcapkit.protocols.misc.pcapng.schema.EndOfOption'>, <OptionType.opt_comment: 1>: <class 'pcapkit.protocols.misc.pcapng.schema.CommentOption'>, <OptionType.opt_custom: 2988>: <class 'pcapkit.protocols.misc.pcapng.schema.CustomOption'>, <OptionType.opt_custom: 2989>: <class 'pcapkit.protocols.misc.pcapng.schema.CustomOption'>, <OptionType.opt_custom: 19372>: <class 'pcapkit.protocols.misc.pcapng.schema.CustomOption'>, <OptionType.opt_custom: 19373>: <class 'pcapkit.protocols.misc.pcapng.schema.CustomOption'>}, 'epb': {<OptionType.opt_endofopt: 0>: <class 'pcapkit.protocols.misc.pcapng.schema.EndOfOption'>, <OptionType.opt_comment: 1>: <class 'pcapkit.protocols.misc.pcapng.schema.CommentOption'>, <OptionType.epb_flags: 2>: <class 'pcapkit.protocols.misc.pcapng.schema.EPB_FlagsOption'>, <OptionType.epb_hash: 3>: <class 'pcapkit.protocols.misc.pcapng.schema.EPB_HashOption'>, <OptionType.epb_dropcount: 4>: <class 'pcapkit.protocols.misc.pcapng.schema.EPB_DropCountOption'>, <OptionType.epb_packetid: 5>: <class 'pcapkit.protocols.misc.pcapng.schema.EPB_PacketIDOption'>, <OptionType.epb_queue: 6>: <class 'pcapkit.protocols.misc.pcapng.schema.EPB_QueueOption'>, <OptionType.epb_verdict: 7>: <class 'pcapkit.protocols.misc.pcapng.schema.EPB_VerdictOption'>, <OptionType.opt_custom: 2988>: <class 'pcapkit.protocols.misc.pcapng.schema.CustomOption'>, <OptionType.opt_custom: 2989>: <class 'pcapkit.protocols.misc.pcapng.schema.CustomOption'>, <OptionType.opt_custom: 19372>: <class 'pcapkit.protocols.misc.pcapng.schema.CustomOption'>, <OptionType.opt_custom: 19373>: <class 'pcapkit.protocols.misc.pcapng.schema.CustomOption'>}, 'if': {<OptionType.opt_endofopt: 0>: <class 'pcapkit.protocols.misc.pcapng.schema.EndOfOption'>, <OptionType.opt_comment: 1>: <class 'pcapkit.protocols.misc.pcapng.schema.CommentOption'>, <OptionType.if_name: 2>: <class 'pcapkit.protocols.misc.pcapng.schema.IF_NameOption'>, <OptionType.if_description: 3>: <class 'pcapkit.protocols.misc.pcapng.schema.IF_DescriptionOption'>, <OptionType.if_IPv4addr: 4>: <class 'pcapkit.protocols.misc.pcapng.schema.IF_IPv4AddrOption'>, <OptionType.if_IPv6addr: 5>: <class 'pcapkit.protocols.misc.pcapng.schema.IF_IPv6AddrOption'>, <OptionType.if_MACaddr: 6>: <class 'pcapkit.protocols.misc.pcapng.schema.IF_MACAddrOption'>, <OptionType.if_EUIaddr: 7>: <class 'pcapkit.protocols.misc.pcapng.schema.IF_EUIAddrOption'>, <OptionType.if_speed: 8>: <class 'pcapkit.protocols.misc.pcapng.schema.IF_SpeedOption'>, <OptionType.if_tsresol: 9>: <class 'pcapkit.protocols.misc.pcapng.schema.IF_TSResolOption'>, <OptionType.if_tzone: 10>: <class 'pcapkit.protocols.misc.pcapng.schema.IF_TZoneOption'>, <OptionType.if_filter: 11>: <class 'pcapkit.protocols.misc.pcapng.schema.IF_FilterOption'>, <OptionType.if_os: 12>: <class 'pcapkit.protocols.misc.pcapng.schema.IF_OSOption'>, <OptionType.if_fcslen: 13>: <class 'pcapkit.protocols.misc.pcapng.schema.IF_FCSLenOption'>, <OptionType.if_tsoffset: 14>: <class 'pcapkit.protocols.misc.pcapng.schema.IF_TSOffsetOption'>, <OptionType.if_hardware: 15>: <class 'pcapkit.protocols.misc.pcapng.schema.IF_HardwareOption'>, <OptionType.if_txspeed: 16>: <class 'pcapkit.protocols.misc.pcapng.schema.IF_TxSpeedOption'>, <OptionType.if_rxspeed: 17>: <class 'pcapkit.protocols.misc.pcapng.schema.IF_RxSpeedOption'>, <OptionType.opt_custom: 2988>: <class 'pcapkit.protocols.misc.pcapng.schema.CustomOption'>, <OptionType.opt_custom: 2989>: <class 'pcapkit.protocols.misc.pcapng.schema.CustomOption'>, <OptionType.opt_custom: 19372>: <class 'pcapkit.protocols.misc.pcapng.schema.CustomOption'>, <OptionType.opt_custom: 19373>: <class 'pcapkit.protocols.misc.pcapng.schema.CustomOption'>}, 'isb': {<OptionType.opt_endofopt: 0>: <class 'pcapkit.protocols.misc.pcapng.schema.EndOfOption'>, <OptionType.opt_comment: 1>: <class 'pcapkit.protocols.misc.pcapng.schema.CommentOption'>, <OptionType.isb_starttime: 2>: <class 'pcapkit.protocols.misc.pcapng.schema.ISB_StartTimeOption'>, <OptionType.isb_endtime: 3>: <class 'pcapkit.protocols.misc.pcapng.schema.ISB_EndTimeOption'>, <OptionType.isb_ifrecv: 4>: <class 'pcapkit.protocols.misc.pcapng.schema.ISB_IFRecvOption'>, <OptionType.isb_ifdrop: 5>: <class 'pcapkit.protocols.misc.pcapng.schema.ISB_IFDropOption'>, <OptionType.isb_filteraccept: 6>: <class 'pcapkit.protocols.misc.pcapng.schema.ISB_FilterAcceptOption'>, <OptionType.isb_osdrop: 7>: <class 'pcapkit.protocols.misc.pcapng.schema.ISB_OSDropOption'>, <OptionType.isb_usrdeliv: 8>: <class 'pcapkit.protocols.misc.pcapng.schema.ISB_UsrDelivOption'>, <OptionType.opt_custom: 2988>: <class 'pcapkit.protocols.misc.pcapng.schema.CustomOption'>, <OptionType.opt_custom: 2989>: <class 'pcapkit.protocols.misc.pcapng.schema.CustomOption'>, <OptionType.opt_custom: 19372>: <class 'pcapkit.protocols.misc.pcapng.schema.CustomOption'>, <OptionType.opt_custom: 19373>: <class 'pcapkit.protocols.misc.pcapng.schema.CustomOption'>}, 'ns': {<OptionType.opt_endofopt: 0>: <class 'pcapkit.protocols.misc.pcapng.schema.EndOfOption'>, <OptionType.opt_comment: 1>: <class 'pcapkit.protocols.misc.pcapng.schema.CommentOption'>, <OptionType.ns_dnsname: 2>: <class 'pcapkit.protocols.misc.pcapng.schema.NS_DNSNameOption'>, <OptionType.ns_dnsIP4addr: 3>: <class 'pcapkit.protocols.misc.pcapng.schema.NS_DNSIP4AddrOption'>, <OptionType.ns_dnsIP6addr: 4>: <class 'pcapkit.protocols.misc.pcapng.schema.NS_DNSIP6AddrOption'>, <OptionType.opt_custom: 2988>: <class 'pcapkit.protocols.misc.pcapng.schema.CustomOption'>, <OptionType.opt_custom: 2989>: <class 'pcapkit.protocols.misc.pcapng.schema.CustomOption'>, <OptionType.opt_custom: 19372>: <class 'pcapkit.protocols.misc.pcapng.schema.CustomOption'>, <OptionType.opt_custom: 19373>: <class 'pcapkit.protocols.misc.pcapng.schema.CustomOption'>}, 'opt': {<OptionType.opt_endofopt: 0>: <class 'pcapkit.protocols.misc.pcapng.schema.EndOfOption'>, <OptionType.opt_comment: 1>: <class 'pcapkit.protocols.misc.pcapng.schema.CommentOption'>, <OptionType.opt_custom: 2988>: <class 'pcapkit.protocols.misc.pcapng.schema.CustomOption'>, <OptionType.opt_custom: 2989>: <class 'pcapkit.protocols.misc.pcapng.schema.CustomOption'>, <OptionType.opt_custom: 19372>: <class 'pcapkit.protocols.misc.pcapng.schema.CustomOption'>, <OptionType.opt_custom: 19373>: <class 'pcapkit.protocols.misc.pcapng.schema.CustomOption'>}, 'pack': {<OptionType.opt_endofopt: 0>: <class 'pcapkit.protocols.misc.pcapng.schema.EndOfOption'>, <OptionType.opt_comment: 1>: <class 'pcapkit.protocols.misc.pcapng.schema.CommentOption'>, <OptionType.pack_flags: 2>: <class 'pcapkit.protocols.misc.pcapng.schema.PACK_FlagsOption'>, <OptionType.pack_hash: 3>: <class 'pcapkit.protocols.misc.pcapng.schema.PACK_HashOption'>, <OptionType.opt_custom: 2988>: <class 'pcapkit.protocols.misc.pcapng.schema.CustomOption'>, <OptionType.opt_custom: 2989>: <class 'pcapkit.protocols.misc.pcapng.schema.CustomOption'>, <OptionType.opt_custom: 19372>: <class 'pcapkit.protocols.misc.pcapng.schema.CustomOption'>, <OptionType.opt_custom: 19373>: <class 'pcapkit.protocols.misc.pcapng.schema.CustomOption'>}}¶
Mapping of PCAP-NG option type numbers to schemas.
- static register(code, cls, ns=None)[source]¶
Register option type to
__enum__mapping.- Parameters:
code (
OptionType) – Option type code.ns (
str|None) – Namespace of option type enumeration, inferred from the option type code if not given.
- Return type:
A registration that displaces another schema for the same code is reported as a
RegistryWarning, as every other registry in the package does – the lookup that follows cannot tell a deliberate replacement from an accidental one, so an unreported overwrite is a parser silently swapped out for another.The guard is identity-based: it fires only when the incumbent differs from
cls, so re-registering the exact same class under the samecodeis a silent no-op – in every namespacetargetsreaches – rather than a warning about nothing displaced. That is what keeps__init_subclass__()honest: it loops over acodelist with no deduplication, so a repeated or aliased entry reaches this method twice with the same class, and the second call finds itself already the incumbent.Note
ns='opt'fans one registration out across every namespace, so the collision is reported once for the registration and names the namespaces it displaced something in, sorted, rather than once per namespace.A namespace created by this call starts as a copy of
opt’s defaults, so nothing in it is a prior registration and it is exempt: registering anopt-namespace code into a brand-new namespace is exactly what that copy is for.Membership is tested with
.get(), never by subscripting. The per-namespace registries arecollections.defaultdicts – only the outer one is the miss-safe_EnumRegistry– so readingOption.registry[key][code]to see whether it is there would insertUnknownOptionfor a code nobody registered.
- classmethod __init_subclass__(code=None, ns=None, *args, **kwargs)[source]¶
Register option type to
__enum__mapping.- Parameters:
code (
OptionType|Iterable[OptionType] |None) – Option type code. It can be either a single option type enumeration or a list of option type enumerations.ns (
str|None) – Namespace of option type enumeration, inferred from the option type code if not given. Notnamespace: before Python 3.11,abc.ABCMeta.__new__()takes its own parameter of that name by keyword too, so a class keyword so named binds it twice.*args (
Any) – Arbitrary positional arguments.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
Given
code, the subclass is registered under it in the__enum__mapping; otherwise it is not registered.Examples
from pcapkit.const.pcapng.option_type import OptionType as Enum_OptionType from pcapkit.protocols.misc.pcapng.schema import Option class NewOption(Option, ns='opt', code=Enum_OptionType.opt_new): ...
Changed in version 1.5.0: The class keyword
namespaceis renamedns, with no alias (#439).
- type: OptionType¶
Option type.
- class pcapkit.protocols.misc.pcapng.schema._OPT_Option(*args, **kwargs)[source]¶
Bases:
OptionHeader schema for
opt_*options.- type: OptionType = <OptionEnumField type>¶
Option type.
- class pcapkit.protocols.misc.pcapng.schema.UnknownOption(type=NO_VALUE, length=NO_VALUE, data=NO_VALUE, padding=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
_OPT_OptionHeader schema for unknown PCAP-NG file options.
- class pcapkit.protocols.misc.pcapng.schema.EndOfOption(type=NO_VALUE, length=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
_OPT_OptionHeader schema for PCAP-NG file
opt_endofoptoptions.
- class pcapkit.protocols.misc.pcapng.schema.CommentOption(type=NO_VALUE, length=NO_VALUE, comment=NO_VALUE, padding=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
_OPT_OptionHeader schema for PCAP-NG file
opt_commentoptions.
- class pcapkit.protocols.misc.pcapng.schema.CustomOption(type=NO_VALUE, length=NO_VALUE, pen=NO_VALUE, data=NO_VALUE, padding=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
_OPT_OptionHeader schema for PCAP-NG file
opt_customoptions.
- class pcapkit.protocols.misc.pcapng.schema._IF_Option(*args, **kwargs)[source]¶
Bases:
OptionHeader schema for
if_*options.- type: OptionType = <OptionEnumField type>¶
Option type.
- class pcapkit.protocols.misc.pcapng.schema.IF_NameOption(type=NO_VALUE, length=NO_VALUE, name=NO_VALUE, padding=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
_IF_OptionHeader schema for PCAP-NG file
if_nameoptions.
- class pcapkit.protocols.misc.pcapng.schema.IF_DescriptionOption(type=NO_VALUE, length=NO_VALUE, description=NO_VALUE, padding=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
_IF_OptionHeader schema for PCAP-NG file
if_descriptionoptions.
- class pcapkit.protocols.misc.pcapng.schema.IF_IPv4AddrOption(type=NO_VALUE, length=NO_VALUE, interface=NO_VALUE, padding=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
_IF_OptionHeader schema for PCAP-NG file
if_IPv4addroptions.- interface: IPv4Interface = <IPv4InterfaceField interface>¶
IPv4 interface.
- class pcapkit.protocols.misc.pcapng.schema.IF_IPv6AddrOption(type=NO_VALUE, length=NO_VALUE, interface=NO_VALUE, padding=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
_IF_OptionHeader schema for PCAP-NG file
if_IPv6addroptions.- interface: IPv6Interface = <IPv6InterfaceField interface>¶
IPv6 interface.
- class pcapkit.protocols.misc.pcapng.schema.IF_MACAddrOption(type=NO_VALUE, length=NO_VALUE, interface=NO_VALUE, padding=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
_IF_OptionHeader schema for PCAP-NG file
if_MACaddroptions.
- class pcapkit.protocols.misc.pcapng.schema.IF_EUIAddrOption(type=NO_VALUE, length=NO_VALUE, interface=NO_VALUE, padding=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
_IF_OptionHeader schema for PCAP-NG file
if_EUIaddroptions.
- class pcapkit.protocols.misc.pcapng.schema.IF_SpeedOption(type=NO_VALUE, length=NO_VALUE, speed=NO_VALUE, padding=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
_IF_OptionHeader schema for PCAP-NG file
if_speedoptions.
- class pcapkit.protocols.misc.pcapng.schema.IF_TSResolOption(type=NO_VALUE, length=NO_VALUE, tsresol=NO_VALUE, padding=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
_IF_OptionHeader schema for PCAP-NG file
if_tsresoloptions.- tsresol: ResolutionData = <BitField tsresol>¶
Interface timestamp resolution, as the option encodes it – the base flag and the exponent, from which
resolutionis computed.
- class pcapkit.protocols.misc.pcapng.schema.IF_TZoneOption(type=NO_VALUE, length=NO_VALUE, tzone=NO_VALUE, padding=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
_IF_OptionHeader schema for PCAP-NG file
if_tzoneoptions.
- class pcapkit.protocols.misc.pcapng.schema.IF_FilterOption(type=NO_VALUE, length=NO_VALUE, code=NO_VALUE, filter=NO_VALUE, padding=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
_IF_OptionHeader schema for PCAP-NG file
if_filteroptions.- code: FilterType = <EnumField code>¶
Filter code.
- class pcapkit.protocols.misc.pcapng.schema.IF_OSOption(type=NO_VALUE, length=NO_VALUE, os=NO_VALUE, padding=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
_IF_OptionHeader schema for PCAP-NG file
if_osoptions.
- class pcapkit.protocols.misc.pcapng.schema.IF_FCSLenOption(type=NO_VALUE, length=NO_VALUE, fcslen=NO_VALUE, padding=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
_IF_OptionHeader schema for PCAP-NG file
if_fcslenoptions.
- class pcapkit.protocols.misc.pcapng.schema.IF_TSOffsetOption(type=NO_VALUE, length=NO_VALUE, tsoffset=NO_VALUE, padding=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
_IF_OptionHeader schema for PCAP-NG file
if_tsoffsetoptions.
- class pcapkit.protocols.misc.pcapng.schema.IF_HardwareOption(type=NO_VALUE, length=NO_VALUE, hardware=NO_VALUE, padding=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
_IF_OptionHeader schema for PCAP-NG file
if_hardwareoptions.
- class pcapkit.protocols.misc.pcapng.schema.IF_TxSpeedOption(type=NO_VALUE, length=NO_VALUE, tx_speed=NO_VALUE, padding=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
_IF_OptionHeader schema for PCAP-NG file
if_txspeedoptions.
- class pcapkit.protocols.misc.pcapng.schema.IF_RxSpeedOption(type=NO_VALUE, length=NO_VALUE, rx_speed=NO_VALUE, padding=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
_IF_OptionHeader schema for PCAP-NG file
if_rxspeedoptions.
- class pcapkit.protocols.misc.pcapng.schema._EPB_Option(*args, **kwargs)[source]¶
Bases:
OptionHeader schema for
epb_*options.- type: OptionType = <OptionEnumField type>¶
Option type.
- class pcapkit.protocols.misc.pcapng.schema.EPB_FlagsOption(type=NO_VALUE, length=NO_VALUE, flags=NO_VALUE, padding=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
_EPB_OptionHeader schema for PCAP-NG
epb_flagsoptions.
- class pcapkit.protocols.misc.pcapng.schema.EPB_HashOption(type=NO_VALUE, length=NO_VALUE, func=NO_VALUE, data=NO_VALUE, padding=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
_EPB_OptionHeader schema for PCAP-NG
epb_hashoptions.- func: HashAlgorithm = <EnumField func>¶
Hash algorithm.
- class pcapkit.protocols.misc.pcapng.schema.EPB_DropCountOption(type=NO_VALUE, length=NO_VALUE, drop_count=NO_VALUE, padding=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
_EPB_OptionHeader schema for PCAP-NG
epb_dropcountoptions.
- class pcapkit.protocols.misc.pcapng.schema.EPB_PacketIDOption(type=NO_VALUE, length=NO_VALUE, packet_id=NO_VALUE, padding=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
_EPB_OptionHeader schema for PCAP-NG
epb_packetidoptions.
- class pcapkit.protocols.misc.pcapng.schema.EPB_QueueOption(type=NO_VALUE, length=NO_VALUE, queue_id=NO_VALUE, padding=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
_EPB_OptionHeader schema for PCAP-NG
epb_queueoptions.
- class pcapkit.protocols.misc.pcapng.schema.EPB_VerdictOption(type=NO_VALUE, length=NO_VALUE, verdict=NO_VALUE, value=NO_VALUE, padding=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
_EPB_OptionHeader schema for PCAP-NG
epb_verdictoptions.- verdict: VerdictType = <EnumField verdict>¶
Verdict type.
- class pcapkit.protocols.misc.pcapng.schema._NS_Option(*args, **kwargs)[source]¶
Bases:
OptionHeader schema for
ns_*options.- type: OptionType = <OptionEnumField type>¶
Option type.
- class pcapkit.protocols.misc.pcapng.schema.NS_DNSNameOption(type=NO_VALUE, length=NO_VALUE, name=NO_VALUE, padding=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
_NS_OptionHeader schema for PCAP-NG
ns_dnsnameoption.
- class pcapkit.protocols.misc.pcapng.schema.NS_DNSIP4AddrOption(type=NO_VALUE, length=NO_VALUE, ip=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
_NS_OptionHeader schema for PCAP-NG
ns_dnsIP4addroption.- ip: IPv4Address = <IPv4AddressField ip>¶
IPv4 address.
- class pcapkit.protocols.misc.pcapng.schema.NS_DNSIP6AddrOption(type=NO_VALUE, length=NO_VALUE, ip=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
_NS_OptionHeader schema for PCAP-NG
ns_dnsIP6addroption.- ip: IPv6Address = <IPv6AddressField ip>¶
IPv6 address.
- class pcapkit.protocols.misc.pcapng.schema._ISB_Option(*args, **kwargs)[source]¶
Bases:
OptionHeader schema for
isb_*options.- type: OptionType = <OptionEnumField type>¶
Option type.
- class pcapkit.protocols.misc.pcapng.schema.ISB_StartTimeOption(type=NO_VALUE, length=NO_VALUE, timestamp_high=NO_VALUE, timestamp_low=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
_ISB_OptionHeader schema for PCAP-NG
isb_starttimeoption.
- class pcapkit.protocols.misc.pcapng.schema.ISB_EndTimeOption(type=NO_VALUE, length=NO_VALUE, timestamp_high=NO_VALUE, timestamp_low=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
_ISB_OptionHeader schema for PCAP-NG
isb_endtimeoption.
- class pcapkit.protocols.misc.pcapng.schema.ISB_IFRecvOption(type=NO_VALUE, length=NO_VALUE, packets=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
_ISB_OptionHeader schema for PCAP-NG
isb_ifrecvoption.
- class pcapkit.protocols.misc.pcapng.schema.ISB_IFDropOption(type=NO_VALUE, length=NO_VALUE, packets=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
_ISB_OptionHeader schema for PCAP-NG
isb_ifdropoption.
- class pcapkit.protocols.misc.pcapng.schema.ISB_FilterAcceptOption(type=NO_VALUE, length=NO_VALUE, packets=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
_ISB_OptionHeader schema for PCAP-NG
isb_filteracceptoption.
- class pcapkit.protocols.misc.pcapng.schema.ISB_OSDropOption(type=NO_VALUE, length=NO_VALUE, packets=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
_ISB_OptionHeader schema for PCAP-NG
isb_osdropoption.
- class pcapkit.protocols.misc.pcapng.schema.ISB_UsrDelivOption(type=NO_VALUE, length=NO_VALUE, packets=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
_ISB_OptionHeader schema for PCAP-NG
isb_usrdelivoption.
- class pcapkit.protocols.misc.pcapng.schema._PACK_Option(*args, **kwargs)[source]¶
Bases:
OptionHeader schema for
pack_*options.- type: OptionType = <OptionEnumField type>¶
Option type.
- class pcapkit.protocols.misc.pcapng.schema.PACK_FlagsOption(type=NO_VALUE, length=NO_VALUE, flags=NO_VALUE, padding=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
_PACK_OptionHeader schema for PCAP-NG
pack_flagsoptions.
- class pcapkit.protocols.misc.pcapng.schema.PACK_HashOption(type=NO_VALUE, length=NO_VALUE, func=NO_VALUE, data=NO_VALUE, padding=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
_PACK_OptionHeader schema for PCAP-NG
pack_hashoptions.- func: HashAlgorithm = <EnumField func>¶
Hash algorithm.
- class pcapkit.protocols.misc.pcapng.schema.NameResolutionRecord(*args, **kwargs)[source]¶
Bases:
EnumSchema[RecordType]Header schema for PCAP-NG NRB records.
- type: RecordType = <EnumField type>¶
Record type.
- class pcapkit.protocols.misc.pcapng.schema.UnknownRecord(type=NO_VALUE, length=NO_VALUE, data=NO_VALUE, padding=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
NameResolutionRecordHeader schema for PCAP-NG NRB unknown records.
- class pcapkit.protocols.misc.pcapng.schema.EndRecord(type=NO_VALUE, length=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
NameResolutionRecordHeader schema for PCAP-NG
nrb_record_endrecords.
- class pcapkit.protocols.misc.pcapng.schema.IPv4Record(type=NO_VALUE, length=NO_VALUE, ip=NO_VALUE, resol=NO_VALUE, padding=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
NameResolutionRecordHeader schema for PCAP-NG NRB
nrb_record_ipv4records.- ip: IPv4Address = <IPv4AddressField ip>¶
IPv4 address.
- class pcapkit.protocols.misc.pcapng.schema.IPv6Record(type=NO_VALUE, length=NO_VALUE, ip=NO_VALUE, resol=NO_VALUE, padding=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
NameResolutionRecordHeader schema for PCAP-NG NRB
nrb_record_ipv6records.- ip: IPv6Address = <IPv6AddressField ip>¶
IPv6 address.
- class pcapkit.protocols.misc.pcapng.schema.DSBSecrets(*args, **kwargs)[source]¶
Bases:
EnumSchema[SecretsType]Header schema for DSB secrets data.
- class pcapkit.protocols.misc.pcapng.schema.UnknownSecrets(data=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
DSBSecretsHeader schema for unknown DSB secrets data.
- class pcapkit.protocols.misc.pcapng.schema.TLSKeyLog(data=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
DSBSecretsHeader schema for TLS Key Log secrets data.
- post_process(packet)[source]¶
Revise
schemadata after unpacking process.A line that does not parse – an unknown label, a field that is not hexadecimal, a wrong number of fields, or the first octets of an entry cut inside the block’s padding – is left out of
entriesand reported as aProtocolWarningthat names its label and elides its values (see_malformed_line_message()), wherever it sits in the log (#1985). Refusing it would abort the whole extraction rather than this one line, asnonnegative()explains, anddatakeeps the log text verbatim, so the line is still kept as captured and the block rebuilds octet for octet. A last line the capture or the block cut is left out silently (see_cut_last_line()), since the cut is reported already.
- entries: dict[TLSKeyLabel, OrderedMultiDict[bytes, bytes]]¶
TLS Key Log entries.
- class pcapkit.protocols.misc.pcapng.schema.WireGuardKeyLog(data=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
DSBSecretsHeader schema for WireGuard Key Log secrets data.
- post_process(packet)[source]¶
Revise
schemadata after unpacking process.A line that does not parse is left out of
entries, reported and kept as captured indata, asTLSKeyLog.post_process()describes (#1985).
- entries: OrderedMultiDict[WireGuardKeyLabel, bytes]¶
WireGuard Key Log entries.
- class pcapkit.protocols.misc.pcapng.schema.ZigBeeNWKKey(key=NO_VALUE, panid=NO_VALUE, trailing=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
DSBSecretsHeader schema for ZigBee NWK Key and ZigBee PANID secrets data.
- trailing: bytes | None = <ConditionalField trailing>¶
Octets past the PAN ID, if Secrets Length declares any (see
zigbee_key_trailing()).
- class pcapkit.protocols.misc.pcapng.schema.ZigBeeAPSKey(key=NO_VALUE, panid=NO_VALUE, addr_low=NO_VALUE, addr_high=NO_VALUE, trailing=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
DSBSecretsHeader schema for ZigBee APS Key secrets data.
- trailing: bytes | None = <ConditionalField trailing>¶
Octets past the high node short address, if Secrets Length declares any (see
zigbee_key_trailing()).
- class pcapkit.protocols.misc.pcapng.schema.FlagsField(namespace, callback=lambda *_: ...)[source]¶
Bases:
UInt32Field32-bit flags word for protocol fields, with sub-fields numbered from the least-significant bit, as the
epb_flagsandpack_flagsoptions number them.Unlike
BitField, which numbers bits from the most-significant bit of the raw octets and ignores byte order, the word is read as an integer in the section’s byte order first.- Parameters:
- class pcapkit.protocols.misc.pcapng.schema.OptionEnumField(length, default=OptionType.opt_endofopt, signed=False, byteorder='big', bit_length=None, namespace='opt', callback=lambda *_: ...)[source]¶
Bases:
EnumFieldEnumerated value for protocol fields.
- Parameters:
length (
int|Callable[[dict[str,Any]],int]) – Field size (in bytes); if a callable is given, it should return an integer value and accept the current packet as its only argument.default (
OptionType) – Field default value, if any.signed (
bool) – Whether the field is signed.byteorder (
Literal['little','big']) – Field byte order.namespace (
str) – Option namespace, i.e., namespace of the enum item.callback (
Callable[[Self,dict[str,Any]],None]) – Callback function to be called uponself.__call__.
Important
This class is specifically designed for
OptionTypeas it is actually anaenum.StrEnumclass.- post_process(value, packet)[source]¶
Process field value after parsing (unpacked).
- Parameters:
- Return type:
- Returns:
Processed field value – the registry member declared for the option code in this namespace (or in the shared
optnamespace), or an unregistered member of the same registry, carrying the code itself, when neither declares one.
Notes
This replicates the read-only membership test
get()itself runs first, and calls it only once that test finds the code declared. An undeclared option type getsEnumField._unregistered_memberinstead ofget()’s own miss path, for pickle-safety: that method carries its own__reduce_ex__, so a member built this way round-trips throughpickle– see its own docstring – which the override of_unregistered_member(), the miss path, does not. The override’s_value_is the formatted display string ('opt_unknown [8888]', not8888), sopickle.dumpson one succeeds butpickle.loadsof the result raisesValueError: the default reduction reconstructs throughcls(self._value_), and_missing_’s own int-only guard rejects that formatted string outright.The base
_unregistered_member()that override replaces fails earlier, onrepr()itself, sinceopt_name/opt_valueare never set – which is why the override exists, choosing to render correctly over round-tripping correctly.EnumField._unregistered_memberis the only one of these that gets both right.copy.deepcopy()is not the difference: it succeeds on both kinds, since the standard library’senum.Enum(whichaenum.Enumsubclasses) defines__copy__/__deepcopy__to returnselfoutright, so deep-copying any member never reaches__reduce_ex__.
- class pcapkit.protocols.misc.pcapng.schema.OptionAreaField(length=lambda _: ..., base_schema=None, type_name='type', registry=None, eool=None, callback=lambda *_: ...)[source]¶
Bases:
OptionFieldOption list that keeps a malformed option area as the octets captured.
An option in the area that runs past it, or past the data, raises
ProtocolErrorfromOptionField.unpackorbounded_option(). A block has no catch point above its fields, so raising would abort the whole extraction. This field instead returns the area as a singlebytesitem, which packs back verbatim, and reports no padding after it (#1325).
Type Stubs¶
- class pcapkit.protocols.misc.pcapng.schema.ByteorderTest[source]¶
Bases:
TypedDictTest for byte order.
- class pcapkit.protocols.misc.pcapng.schema.ResolutionData[source]¶
Bases:
TypedDictData for resolution.
- class pcapkit.protocols.misc.pcapng.schema.EPBFlags[source]¶
Bases:
TypedDictEPB flags.
- direction: int¶
Inbound / Outbound packet (
00= information not available,01= inbound,10= outbound)
- reception: int¶
Reception type (
000= not specified,001= unicast,010= multicast,011= broadcast,100= promiscuous).
- fcs_len: int¶
FCS length, in octets (
0000if this information is not available). This value overrides theif_fcslenoption of the Interface Description Block, and is used with those link layers (e.g. PPP) where the length of the FCS can change during time.
- class pcapkit.protocols.misc.pcapng.schema.PACKFlags[source]¶
Bases:
TypedDictPACK flags.
- direction: int¶
Inbound / Outbound packet (
00= information not available,01= inbound,10= outbound)
- reception: int¶
Reception type (
000= not specified,001= unicast,010= multicast,011= broadcast,100= promiscuous).
- fcs_len: int¶
FCS length, in octets (
0000if this information is not available). This value overrides theif_fcslenoption of the Interface Description Block, and is used with those link layers (e.g. PPP) where the length of the FCS can change during time.
Auxiliary Functions¶
The byte order of every block but the Section Header Block is read by
byteorder_callback(), which is
shared with the PCAP frame header and documented in
pcapkit.corekit.schema.byteorder.
- pcapkit.protocols.misc.pcapng.schema.shb_byteorder_callback(field, packet)[source]¶
Update byte order of PCAP-NG file for SHB.
A Section Header Block declares the byte order of its own section through its Byte-Order Magic, so it cannot take one from the enclosing packet data: the first SHB of a file has no section context by construction, and a later one would otherwise inherit the previous section’s byte order. The magic is therefore also written back as
packet['byteorder'], which is what the SHB’s own options – read bybyteorder_callback(), after this field – resolve their byte order from.A Section Header Block of 12 octets has no room for the magic, and its place holds the trailing Block Total Length instead. That length is 12 in exactly one byte order, which is the one taken;
SectionHeaderBlock.post_process()then rejects any block that matched this way with a length other than 12 (#1422).- Parameters:
field (
NumberField) – Field instance.
- pcapkit.protocols.misc.pcapng.schema.pcapng_block_selector(packet)[source]¶
Selector function for
PCAPNG.blockfield.- Parameters:
- Return type:
- Returns:
A
SchemaFieldwrappedBlockTypesubclass instance.
Note
__length__is what is left of the stream, not what the block declares, and it is decremented by four forPCAPNG.typewhether or not those four octets were there to read –FieldBase.unpackzero-pads a short read rather than refusing it. A tail of one, two or three octets therefore arrives here negative, whichSchemaField.unpackwould read as no declared length, sizing the block by whatever is left of the stream. The floor is a backstop:PCAPNG._check_block_floorreports that tail as end-of-stream before it gets here, and on the packing pathSchema.packseeds__length__as-1for “unknown”, whichSchemaField.packdoes not read at all.
- pcapkit.protocols.misc.pcapng.schema.dsb_secrets_selector(packet)[source]¶
Selector function for
DecryptionSecretsBlock.secrets_datafield.- Parameters:
- Return type:
- Returns:
A
SchemaFieldwrapped instance of theDSBSecretssubclass registered forsecrets_type, or ofUnknownSecretsif none is, spanning the octets ofsecrets_lengththat the block holds (seesecrets_area()).
- pcapkit.protocols.misc.pcapng.schema.nonnegative(length)[source]¶
Floor a computed field length at zero.
- Parameters:
length (
Callable[[dict[str,Any]],int]) – Callback computing a field’s length from the framing a block, option or record declares.- Return type:
- Returns:
A callback returning that length, never below zero.
Every span in this module is a subtraction – a block’s own Block Total Length less its fixed fields, an option’s declared length less the part of itself it describes, an option area’s leftover – and every operand of those subtractions is a wire field that a malformed or truncated capture is free to set to anything. Nothing else makes the difference non-negative, and the field layer does not either:
_TextField.__call__builds itsstructtemplate asf'{length}s'unconditionally, so a negative length becomes the format'-8s'andstruct.calcsize()raises a barestruct.error. That is not one ofpcapkit.utilities.exceptions, so a caller cannot tell it from a bug in its own code, and it is not anEOFError, so the frame loop does not catch it – one malformed block would therefore cost the whole extraction. A negativeSchemaFieldlength fails silently instead:SchemaField.unpackreads it as no declared length, and sizes the nested schema by whatever is left of the stream.Two shapes reach here. A Block Total Length below the block’s own fixed-field floor – 28 octets for a Section Header Block, 20 for an Interface Description Block, 16 for a Custom Block – makes the area negative directly. And
__option_padding__, whichOptionField.unpackreports as the part of a declared area its options did not consume, goes negative when they consumed more than the area held: it subtracts each parsed option’s real size from the area without checking that it fits. Both mean the same thing for a read – there are no octets here – and zero says that, where a negative says somethingstructcannot express.Flooring rather than refusing is the choice
bounded_area()makes too: a block read has no catch point aboveFieldBase.unpack, so one refusal aborts the whole extraction rather than one block, and a capture cut short by its snapshot length must keep parsing. The end of the file is the one case that is not a floor, since there no block is being read at all – seePCAPNG._check_block_floor, which reports it as theStreamEOFErrorthe frame loop catches.Note
Unlike
bounded_option()this needs no__length__opt-out for the packing path, because it floors a difference rather than checking against the remaining area: a negative difference is not a legitimate thing to pack either –struct.pack('-8s', ...)raises exactly ascalcsizedoes – where checking against the remainder would have refused a perfectly good option.That distinction is what keeps the decryption-secrets payloads –
UnknownSecrets.data,TLSKeyLog.dataandWireGuardKeyLog.data– out of this. They read__length__whole rather than subtracting from it, andSchema.packleaves it at-1for “unknown”, so flooring them packs nothing at all. On the parsing path their__length__is the length the enclosingSchemaFielddeclared from a 32-bitsecrets_length, which cannot be negative, so there is nothing there to floor.
- pcapkit.protocols.misc.pcapng.schema.held_body(framing)[source]¶
Bound a block body read as one field to the octets the stream holds.
- Parameters:
framing (
int) – Octets the block’s fixed fields span, both copies of the Block Total Length included.- Return type:
- Returns:
A callback returning the block’s Block Total Length less
framing, never below zero, and never past what is left of the stream.
The bodies of
UnknownBlock,CustomBlockandSystemdJournalExportBlockare each oneBytesFieldspanning the whole block, so a Block Total Length that runs past the end of the file is one field declaring that many octets. Unbounded, that field is zero-filled withinMAX_ZERO_PAD_LENGTH, and past itFieldBase.unpackraisesFieldValueErrorfrom inside the block’s schema, wherePCAPNG.readcannot keep the block as captured, so the whole extraction ends (#1984). The other block types read their bodies field by field, so none of them declares that much in one field.Bounded, the body is the octets the file actually holds, whatever the block declares, and
PCAPNG.readreports the truncation as it does for every other block type. On a well-formed block the stream holds the body and the trailing Block Total Length, so this is a no-op; on the packing pathSchema.packleaves__length__at-1for “unknown”, and the declared span is kept.
- pcapkit.protocols.misc.pcapng.schema.bounded_option(length)[source]¶
Refuse an option or record payload that runs past its area.
- Parameters:
length (
Callable[[dict[str,Any]],int]) – Callback computing the payload’s nominal length, as the option’s or record’s own declared length field gives it.- Return type:
- Returns:
A callback returning that length.
- Raises:
ProtocolError – If the payload declares more octets than the enclosing option or record area has left.
An option’s length is a 16-bit wire field, so one four-octet option header can declare 65,535 octets of payload. Read as declared, every shortfall would be zero-padded at the field layer, and the zeros rebuilt as if they had been captured (#594, #1325). So a payload that runs past the area is refused here instead. Inside a block,
OptionAreaFieldthen keeps the whole option area as the octets captured, so the block still parses and rebuilds byte for byte.Note
The check is skipped when
__length__is absent or negative, which is whatSchema.packleaves it as when no length is known. The nominal length still goes throughnonnegative()first, on both paths, since an option declaring less payload than the part of itself it describes makes the subtraction negative.
- pcapkit.protocols.misc.pcapng.schema.bounded_area(length)[source]¶
Clamp a packet block’s option area to the octets the block itself holds.
- Parameters:
length (
Callable[[dict[str,Any]],int]) – Callback computing the option area’s nominal span, from the block’s own declared Block Total Length.- Return type:
- Returns:
A callback returning that span, never past the octets left of the block.
bounded_option()refuses a payload that runs past the area, and the area is sized from the block’s declared Block Total Length. Nothing checks that length against the file:BlockType.post_processcompareslengthonly against its own trailing copy. A block declaring 1,000,000 octets while holding 36 would therefore size its option area at 999,964, read the trailing Block Total Length into it, and leave that field to be zero-filled. Clamping the area to__length__keeps the trailing length out of the area, so the area holds exactly the octets the block was handed for it, whatever it declared.This is a no-op on every well-formed block rather than a second guess at the area. At the option field the only field still to come is the trailing Block Total Length, so
__length__is exactly the area plus that field’s four octets, and subtracting them makes the two equal. Taking__length__whole over-grants by exactly four, which is not academic: the area then reaches the trailing length itself and reads it as option payload, measured as four octets of payload on a block that holds none.Note
The non-packet blocks’ option areas – Section Header, Interface Description, Name Resolution, Interface Statistics and Decryption Secrets – are deliberately left unclamped against the block here, since each computes its span with a different offset and the equality above has to be re-established per block rather than assumed. They do go through
nonnegative(), which stops a negative declared length reaching a read at all; the per-block equality is not enforced for them.The nominal span goes through
nonnegative()first here too. That closes a hole in this function’s own arithmetic: acaptured_lenpast the end of the block makes the span negative, andnominal <= availablebelow is then true, so the negative would be returned unclamped and reach astructtemplate asf'{-N}s'. Measured on 200 Enhanced Packet Blocks declaringcaptured_len0xFFFFFFin 8,048 octets.
- pcapkit.protocols.misc.pcapng.schema.captured_area(name)[source]¶
Bound a packet block’s Packet Data to the octets the block holds.
- Parameters:
name (
str) – Name of the block’s captured length field,captured_lenorcaptured_length.- Return type:
- Returns:
A callback returning the captured length, never past the block’s Block Total Length less its 32 framing octets, and never below zero.
A captured length running past the block would otherwise read the trailing Block Total Length, and whatever follows the block, as packet data, so the rebuild could not be byte-exact. Bounded, the block keeps its declared captured length and exactly the octets it holds, and the padding and option area are sized from those octets rather than from the declared length (#1405).
- pcapkit.protocols.misc.pcapng.schema.secrets_area(packet)[source]¶
Bound a Decryption Secrets Block’s Secrets Data to the octets the block holds.
- Parameters:
packet (
dict[str,Any]) – Unpacked data so far, withlengthandsecrets_length.- Return type:
- Returns:
The declared
secrets_length, never past the block’s Block Total Length less its 20 framing octets, and never below zero.
secrets_lengthis a 32-bit wire field. Read as declared, a length past the block would read the trailing Block Total Length and the blocks after it as secrets, and pastMAX_ZERO_PAD_LENGTHthe read would raiseFieldValueErrorfrom inside the block’s schema, ending the whole extraction (#1980). This is the Secrets Data counterpart ofcaptured_area(): the block keeps its declaredsecrets_length, the secrets are the octets the block holds, and the padding and option area are sized from those octets.DecryptionSecretsBlock.post_process()reports the overrun.
- pcapkit.protocols.misc.pcapng.schema.zigbee_key_has_trailing(packet)[source]¶
Tell whether a ZigBee key schema carries octets past its fixed fields.
- pcapkit.protocols.misc.pcapng.schema.zigbee_key_trailing(packet)[source]¶
Size the octets a ZigBee key schema carries past its fixed fields.
- Parameters:
packet (
dict[str,Any]) – Unpacked data so far, or the data being packed.- Return type:
- Returns:
On unpacking, what is left of the span the block gives the key; on packing, the octets the schema holds.
The ZigBee NWK and APS keys have a fixed width, but a block’s Secrets Length may declare more. The octets past the fixed fields are kept here, rather than dropped, so that the key rebuilds as captured (#1986).
- pcapkit.protocols.misc.pcapng.schema.zigbee_key_held(schema, data)[source]¶
Rebuild a ZigBee key schema from the Secrets Data octets its block held.
- Parameters:
schema (
Type[_ZigBeeKey]) –ZigBeeNWKKeyorZigBeeAPSKey.data (
bytes) – The Secrets Data octets, as the block held them.
- Return type:
_ZigBeeKey- Returns:
A
schemainstance that holds, and packs back to, exactlydata.
datais unpacked as the block’s Secrets Data is, with any octets past the fixed fields kept as the schema’strailingoctets. Adatashort of the fixed width is a short read, whichSchema.unpackrecords forSchema._cut_short_read. A key shorter than its fixed width, or a Secrets Length longer than it, then rebuilds byte for byte (#1986). The length is declared, so an emptydatais an empty key rather than the end of the stream. The short read’s warnings are dropped, since the parse that helddatareported them.
- pcapkit.protocols.misc.pcapng.schema._spb_data_length(packet)[source]¶
Length of a Simple Packet Block’s packet data.
- Parameters:
packet (
dict[str,Any]) – Unpacked data so far, withlength,original_lenand, when interface 0 sets one,snaplen.- Return type:
- Returns:
min(original_len, snaplen), bounded by the octets the block holds less its 16 framing octets. A block that holds more than that length and its padding – past the snaplen (#1384) or pastoriginal_len(#1414) – keeps the excess as packet data instead, so no octet is dropped and the trailing Block Total Length is read where it sits.
- pcapkit.protocols.misc.pcapng.schema._cut_last_line(schema, index, lines, packet=None)[source]¶
Tell whether a key log line that did not parse is one the capture cut.
- Parameters:
- Return type:
- Returns:
Whether
lines[index]is the last line of a key log the data ended inside, whichSchema.unpackrecords as__short_read__, or that the enclosing block ended inside, assecrets_area()bounds it (#1980). Such a line is only the first octets of an entry, and the log text, kept verbatim, still rebuilds it (#1470).
- pcapkit.protocols.misc.pcapng.schema._malformed_line_message(kind, labels, line)[source]¶
Report a key log line that does not parse, without quoting what it holds.
- Parameters:
- Return type:
- Returns:
A warning message naming the line’s label, when that is one
labelsknows, and eliding its values. The line itself is never quoted, since it carries key material (#1985); nor is an unrecognised label, which may be key material too.
Data Models¶
Removed in version 1.6.0: pcapkit.protocols.data.misc.pcapng, with no alias: the module moved here
(#2534).
- class pcapkit.protocols.misc.pcapng.data.PCAPNG(*args, **kwargs)[source]¶
Bases:
ProtocolData model for PCAP-NG file blocks.
- class pcapkit.protocols.misc.pcapng.data.UnknownBlock(type, length, body)[source]¶
Bases:
PCAPNGData model for unknown PCAP-NG file blocks.
- class pcapkit.protocols.misc.pcapng.data.SectionHeaderBlock(type, length, byteorder, version, section_length, options)[source]¶
Bases:
PCAPNGData model for PCAP-NG Section Header Block (SHB).
- version: VersionInfo¶
Version number.
- options: OrderedMultiInfo[OptionType, Option]¶
Options.
- class pcapkit.protocols.misc.pcapng.data.InterfaceDescriptionBlock(type, length, linktype, snaplen, options)[source]¶
Bases:
PCAPNGData model for PCAP-NG Interface Description Block (IDB).
- options: OrderedMultiInfo[OptionType, Option]¶
Options.
- class pcapkit.protocols.misc.pcapng.data.EnhancedPacketBlock(type, length, section_number, number, interface_id, timestamp, timestamp_epoch, captured_len, original_len, options)[source]¶
Bases:
PCAPNGData model for PCAP-NG Enhanced Packet Block (EPB).
- options: OrderedMultiInfo[OptionType, Option]¶
Options.
- padding_data: bytes¶
Padding of the packet data to 32 bits, as captured; present only when it is not all zeros (#1437).
- class pcapkit.protocols.misc.pcapng.data.SimplePacketBlock(type, length, section_number, number, original_len, captured_len)[source]¶
Bases:
PCAPNGData model for PCAP-NG Simple Packet Block (SPB).
- class pcapkit.protocols.misc.pcapng.data.NameResolutionBlock(type, length, records, options)[source]¶
Bases:
PCAPNGData model for PCAP-NG Name Resolution Block (NRB).
- records: OrderedMultiInfo[RecordType, NameResolutionRecord]¶
Records.
- options: OrderedMultiInfo[OptionType, Option]¶
Options.
- padding_opts: bytes¶
Octets after
opt_endofopt, as captured; present only when the option area holds any (#1437).
- mapping: MultiInfo[IPv4Address | IPv6Address, str]¶
Name resolution mapping (IP address -> name).
- reverse_mapping: MultiInfo[str, IPv4Address | IPv6Address]¶
Name resolution mapping (name -> IP address).
- class pcapkit.protocols.misc.pcapng.data.InterfaceStatisticsBlock(type, length, interface_id, timestamp, timestamp_epoch, options)[source]¶
Bases:
PCAPNGData model for PCAP-NG Interface Statistics Block (ISB).
- options: OrderedMultiInfo[OptionType, Option]¶
Options.
- class pcapkit.protocols.misc.pcapng.data.SystemdJournalExportBlock(type, length, data)[source]¶
Bases:
PCAPNGData model for PCAP-NG systemd(1) Journal Export Block.
- class pcapkit.protocols.misc.pcapng.data.DecryptionSecretsBlock(type, length, secrets_type, secrets_length, secrets_data, options)[source]¶
Bases:
PCAPNGData model for PCAP-NG Decryption Secrets Block (DSB).
- secrets_type: SecretsType¶
Secrets type.
- secrets_data: DSBSecrets¶
Secrets data.
- options: OrderedMultiInfo[OptionType, Option]¶
Options.
- class pcapkit.protocols.misc.pcapng.data.CustomBlock(type, length, pen, data)[source]¶
Bases:
PCAPNGData model for PCAP-NG Custom Block (CB).
- class pcapkit.protocols.misc.pcapng.data.PacketBlock(type, length, section_number, number, interface_id, drop_count, timestamp, timestamp_epoch, captured_len, original_len, options)[source]¶
Bases:
PCAPNGData model for PCAP-NG Packet Block (obsolete).
- options: OrderedMultiInfo[OptionType, Option]¶
Options.
- padding_data: bytes¶
Padding of the packet data to 32 bits, as captured; present only when it is not all zeros (#1437).
- class pcapkit.protocols.misc.pcapng.data.Option(*args, **kwargs)[source]¶
Bases:
DataData model for PCAP-NG file options.
- type: OptionType¶
Option type.
- class pcapkit.protocols.misc.pcapng.data.UnknownOption(type, length, data)[source]¶
Bases:
OptionData model for unknown PCAP-NG file options.
- class pcapkit.protocols.misc.pcapng.data.EndOfOption(type, length)[source]¶
Bases:
OptionData model for PCAP-NG file
opt_endofoptoptions.
- class pcapkit.protocols.misc.pcapng.data.CommentOption(type, length, comment)[source]¶
Bases:
OptionData model for PCAP-NG file
opt_commentoptions.
- class pcapkit.protocols.misc.pcapng.data.CustomOption(type, length, pen, data)[source]¶
Bases:
OptionData model for PCAP-NG file
opt_customoptions.
- class pcapkit.protocols.misc.pcapng.data.IF_NameOption(type, length, name)[source]¶
Bases:
OptionData model for PCAP-NG file
if_nameoptions.
- class pcapkit.protocols.misc.pcapng.data.IF_DescriptionOption(type, length, description)[source]¶
Bases:
OptionData model for PCAP-NG file
if_descriptionoptions.
- class pcapkit.protocols.misc.pcapng.data.IF_IPv4AddrOption(type, length, interface)[source]¶
Bases:
OptionData model for PCAP-NG file
if_IPv4addroptions.- interface: IPv4Interface¶
IPv4 interface.
- class pcapkit.protocols.misc.pcapng.data.IF_IPv6AddrOption(type, length, interface)[source]¶
Bases:
OptionData model for PCAP-NG file
if_IPv6addroptions.- interface: IPv6Interface¶
IPv6 interface.
- class pcapkit.protocols.misc.pcapng.data.IF_MACAddrOption(type, length, interface)[source]¶
Bases:
OptionData model for PCAP-NG file
if_MACaddroptions.
- class pcapkit.protocols.misc.pcapng.data.IF_EUIAddrOption(type, length, interface)[source]¶
Bases:
OptionData model for PCAP-NG file
if_EUIaddroptions.
- class pcapkit.protocols.misc.pcapng.data.IF_SpeedOption(type, length, speed)[source]¶
Bases:
OptionData model for PCAP-NG file
if_speedoptions.
- class pcapkit.protocols.misc.pcapng.data.IF_TSResolOption(type, length, resolution)[source]¶
Bases:
OptionData model for PCAP-NG file
if_tsresoloptions.
- class pcapkit.protocols.misc.pcapng.data.IF_TZoneOption(type, length, timezone)[source]¶
Bases:
OptionData model for PCAP-NG file
if_tzoneoptions.
- class pcapkit.protocols.misc.pcapng.data.IF_FilterOption(type, length, code, expression)[source]¶
Bases:
OptionData model for PCAP-NG file
if_filteroptions.- code: FilterType¶
Filter code.
- class pcapkit.protocols.misc.pcapng.data.IF_OSOption(type, length, os)[source]¶
Bases:
OptionData model for PCAP-NG file
if_osoptions.
- class pcapkit.protocols.misc.pcapng.data.IF_FCSLenOption(type, length, fcs_length)[source]¶
Bases:
OptionData model for PCAP-NG file
if_fcslenoptions.
- class pcapkit.protocols.misc.pcapng.data.IF_TSOffsetOption(type, length, offset)[source]¶
Bases:
OptionData model for PCAP-NG file
if_tsoffsetoptions.
- class pcapkit.protocols.misc.pcapng.data.IF_HardwareOption(type, length, hardware)[source]¶
Bases:
OptionData model for PCAP-NG file
if_hardwareoptions.
- class pcapkit.protocols.misc.pcapng.data.IF_TxSpeedOption(type, length, speed)[source]¶
Bases:
OptionData model for PCAP-NG file
if_txspeedoptions.
- class pcapkit.protocols.misc.pcapng.data.IF_RxSpeedOption(type, length, speed)[source]¶
Bases:
OptionData model for PCAP-NG file
if_rxspeedoptions.
- class pcapkit.protocols.misc.pcapng.data.EPB_FlagsOption(type, length, direction, reception, fcs_len, checksum_not_ready, checksum_valid, tcp_segmentation_offloaded, reserved, crc_error, too_long, too_short, gap_error, unaligned_error, delimiter_error, preamble_error, symbol_error)[source]¶
Bases:
OptionData model for PCAP-NG file
epb_flagsoptions.- direction: PacketDirection¶
Inbound / Outbound packet.
- reception: PacketReception¶
Reception type.
- class pcapkit.protocols.misc.pcapng.data.EPB_HashOption(type, length, algorithm, hash)[source]¶
Bases:
OptionData model for PCAP-NG
epb_hashoptions.- algorithm: HashAlgorithm¶
Hash algorithm.
- class pcapkit.protocols.misc.pcapng.data.EPB_DropCountOption(type, length, drop_count)[source]¶
Bases:
OptionData model for PCAP-NG
epb_dropcountoptions.
- class pcapkit.protocols.misc.pcapng.data.EPB_PacketIDOption(type, length, packet_id)[source]¶
Bases:
OptionData model for PCAP-NG
epb_packetidoptions.
- class pcapkit.protocols.misc.pcapng.data.EPB_QueueOption(type, length, queue_id)[source]¶
Bases:
OptionData model for PCAP-NG
epb_queueoptions.
- class pcapkit.protocols.misc.pcapng.data.EPB_VerdictOption(type, length, verdict, value)[source]¶
Bases:
OptionData model for PCAP-NG
epb_verdictoptions.- verdict: VerdictType¶
Verdict type.
- class pcapkit.protocols.misc.pcapng.data.NS_DNSNameOption(type, length, name)[source]¶
Bases:
OptionData model for PCAP-NG
ns_dnsnameoption.
- class pcapkit.protocols.misc.pcapng.data.NS_DNSIP4AddrOption(type, length, ip)[source]¶
Bases:
OptionData model for PCAP-NG
ns_dnsIP4addroption.- ip: IPv4Address¶
IPv4 address.
- class pcapkit.protocols.misc.pcapng.data.NS_DNSIP6AddrOption(type, length, ip)[source]¶
Bases:
OptionData model for PCAP-NG
ns_dnsIP6addroption.- ip: IPv6Address¶
IPv6 address.
- class pcapkit.protocols.misc.pcapng.data.ISB_StartTimeOption(type, length, timestamp, timestamp_epoch)[source]¶
Bases:
OptionData model for PCAP-NG
isb_starttimeoption.
- class pcapkit.protocols.misc.pcapng.data.ISB_EndTimeOption(type, length, timestamp, timestamp_epoch)[source]¶
Bases:
OptionData model for PCAP-NG
isb_endtimeoption.
- class pcapkit.protocols.misc.pcapng.data.ISB_IFRecvOption(type, length, packets)[source]¶
Bases:
OptionData model for PCAP-NG
isb_ifrecvoption.
- class pcapkit.protocols.misc.pcapng.data.ISB_IFDropOption(type, length, packets)[source]¶
Bases:
OptionData model for PCAP-NG
isb_ifdropoption.
- class pcapkit.protocols.misc.pcapng.data.ISB_FilterAcceptOption(type, length, packets)[source]¶
Bases:
OptionData model for PCAP-NG
isb_filteracceptoption.
- class pcapkit.protocols.misc.pcapng.data.ISB_OSDropOption(type, length, packets)[source]¶
Bases:
OptionData model for PCAP-NG
isb_osdropoption.
- class pcapkit.protocols.misc.pcapng.data.ISB_UsrDelivOption(type, length, packets)[source]¶
Bases:
OptionData model for PCAP-NG
isb_usrdelivoption.
- class pcapkit.protocols.misc.pcapng.data.PACK_FlagsOption(type, length, direction, reception, fcs_len, checksum_not_ready, checksum_valid, tcp_segmentation_offloaded, reserved, crc_error, too_long, too_short, gap_error, unaligned_error, delimiter_error, preamble_error, symbol_error)[source]¶
Bases:
OptionData model for PCAP-NG file
pack_flagsoptions.- direction: PacketDirection¶
Inbound / Outbound packet.
- reception: PacketReception¶
Reception type.
- class pcapkit.protocols.misc.pcapng.data.PACK_HashOption(type, length, algorithm, hash)[source]¶
Bases:
OptionData model for PCAP-NG
pack_hashoptions.- algorithm: HashAlgorithm¶
Hash algorithm.
- class pcapkit.protocols.misc.pcapng.data.NameResolutionRecord(*args, **kwargs)[source]¶
Bases:
DataData model for PCAP-NG NRB records.
- type: RecordType¶
Record type.
- class pcapkit.protocols.misc.pcapng.data.UnknownRecord(type, length, data)[source]¶
Bases:
NameResolutionRecordData model for PCAP-NG NRB unknown records.
- class pcapkit.protocols.misc.pcapng.data.EndRecord(type, length)[source]¶
Bases:
NameResolutionRecordData model for PCAP-NG
nrb_record_endrecords.
- class pcapkit.protocols.misc.pcapng.data.IPv4Record(type, length, ip, records)[source]¶
Bases:
NameResolutionRecordData model for PCAP-NG
nrb_record_ipv4records.- ip: IPv4Address¶
IPv4 address.
- class pcapkit.protocols.misc.pcapng.data.IPv6Record(type, length, ip, records)[source]¶
Bases:
NameResolutionRecordData model for PCAP-NG
nrb_record_ipv6records.- ip: IPv6Address¶
IPv6 address.
- class pcapkit.protocols.misc.pcapng.data.DSBSecrets(*args, **kwargs)[source]¶
Bases:
DataData model for DSB secrets data.
- class pcapkit.protocols.misc.pcapng.data.UnknownSecrets(data)[source]¶
Bases:
DSBSecretsData model for unknown DSB secrets.
- class pcapkit.protocols.misc.pcapng.data.TLSKeyLogEntries(dict_=None, **kwargs)[source]¶
Bases:
DataData model for the entries of a TLS key log, keyed by label.
A key is each
TLSKeyLabelthe log has an entry under, and its value that label’s client random to secret pairs, in log order, as anOrderedMultiInfo. A label also reads as an attribute, asentries.CLIENT_RANDOM.Added in version 1.6.0.
- class pcapkit.protocols.misc.pcapng.data.TLSKeyLog(entries)[source]¶
Bases:
DSBSecretsData model for TLS key log DSB secrets.
Changed in version 1.6.0:
entriesis aTLSKeyLogEntriesrather than adict, and a mapping given for it is stored as one;to_dict()exports it as anOrderedMultiDict, as it does any nested data model. A pickle holds it as adict, so pickles load across 1.6.0 in both directions (#2726).- entries: TLSKeyLogEntries¶
TLS key log entries.
- data: str¶
TLS key log text as the block carries it, comments and line order included. Set on parsing only, and written back verbatim on rebuild.
- __post_init__()[source]¶
Store a mapping given for
entriesas aTLSKeyLogEntries.
- __getstate__()[source]¶
Return the state to pickle, holding
entriesas adict.A release before 1.6.0 loads them as the
dictit holds, and__setstate__()loads them as aTLSKeyLogEntries.
- __setstate__(state)[source]¶
Restore a pickled state, storing
entriesas aTLSKeyLogEntries.- Parameters:
state (
dict[str,Any]) – The state__getstate__()returns, or one holding the entries as adict, as before 1.6.0.
- class pcapkit.protocols.misc.pcapng.data.WireGuardKeyLog(entries)[source]¶
Bases:
DSBSecretsData model for WireGuard key DSB secrets.
- entries: OrderedMultiInfo[WireGuardKeyLabel, bytes]¶
WireGuard Key Log entries.
- class pcapkit.protocols.misc.pcapng.data.ZigBeeNWKKey(nwk_key, pan_id)[source]¶
Bases:
DSBSecretsData model for ZigBee NWK Key and ZigBee PANID secrets data.
- class pcapkit.protocols.misc.pcapng.data.ZigBeeAPSKey(aps_key, pan_id, short_address)[source]¶
Bases:
DSBSecretsData model for ZigBee APS Key secrets data.
- data: bytes¶
Secrets Data octets as the block carries them, as for
ZigBeeNWKKey.data. Set on parsing only, and written back verbatim on rebuild (#1986).
Footnotes