scapy.cborpacket

CBOR Packet

Packet holding data encoded in Concise Binary Object Representation (CBOR). Modelled after scapy/asn1packet.py.

class scapy.cborpacket.CBORPacket_metaclass(name: str, bases: Tuple[type, ...], dct: Dict[str, Any])[source]

Bases: Packet_metaclass

class scapy.cborpacket.CBOR_Packet(_pkt, /)[source]

Bases: Packet

CBOR_root = None
aliastypes = [<class 'scapy.cborpacket.CBOR_Packet'>, <class 'scapy.packet.Packet'>]
do_dissect(x: bytes) bytes[source]

Dissect CBOR-encoded bytes into packet fields.

Delegates to CBOR_root.dissect() which reads CBOR items from x, populates each field on the packet, and returns any unconsumed bytes.

self_build() bytes[source]

Build this CBOR packet to wire bytes using CBOR_root.

Returns the raw packet cache when already built, otherwise delegates to CBOR_root.build() which encodes all fields according to the CBOR schema defined for this packet.