[docs]defcallback_payload(self:'PayloadField',packet:'dict[str, Any]')->'None':"""Callback function for :attr:`Ethernet.payload`."""frompcapkit.protocols.link.ethernetimportEthernet# pylint: disable=import-outside-topleveltype_=packet['type']protocol=Ethernet.__proto__[type_]ifisinstance(protocol,ModuleDescriptor):protocol=protocol.klassself.protocol=protocol
[docs]@schema_finalclassEthernet(Schema):"""Header schema for ethernet packet."""#: Destination MAC address.dst:'bytes'=BytesField(length=6)#: Source MAC address.src:'bytes'=BytesField(length=6)#: Protocol (internet layer).type:'Enum_EtherType'=EnumField(length=2,namespace=Enum_EtherType)#: Payload.payload:'bytes'=PayloadField(length=lambdapkt:pkt['__length__'],callback=callback_payload,)ifTYPE_CHECKING:def__init__(self,dst:'bytes',src:'bytes',type:'Enum_EtherType',payload:'bytes | Protocol | Schema')->'None':...