Source code for pcapkit.protocols.schema.misc.pcap.frame
# -*- coding: utf-8 -*-# mypy: disable-error-code=assignment"""header schema for frame header of PCAP file format"""importsysfromtypingimportTYPE_CHECKINGfrompcapkit.corekit.fields.miscimportPayloadFieldfrompcapkit.corekit.fields.numbersimportUInt32Fieldfrompcapkit.protocols.schema.schemaimportSchema,schema_final__all__=['Frame']ifTYPE_CHECKING:fromtypingimportAnyfrompcapkit.corekit.fields.numbersimportNumberFieldasFieldfrompcapkit.protocols.protocolimportProtocolBaseasProtocoldefbyteorder_callback(field:'Field',packet:'dict[str, Any]')->'None':"""Update byte order of PCAP file. Args: field: Field instance. packet: Packet data. """field._byteorder=packet.get('byteorder',sys.byteorder)
[docs]@schema_finalclassFrame(Schema):"""Frame header of PCAP file format."""__payload__='packet'#: Timestamp seconds.ts_sec:'int'=UInt32Field(callback=byteorder_callback)#: Timestamp microseconds.ts_usec:'int'=UInt32Field(callback=byteorder_callback)#: Number of octets of packet saved in file.incl_len:'int'=UInt32Field(callback=byteorder_callback)#: Actual length of packet.orig_len:'int'=UInt32Field(callback=byteorder_callback)#: Payload.packet:'bytes'=PayloadField(length=lambdapkt:pkt['incl_len'])ifTYPE_CHECKING:def__init__(self,ts_sec:'int',ts_usec:'int',incl_len:'int',orig_len:'int',packet:'bytes | Protocol | Schema')->'None':...