def packet2dict(packet, *, count=NotImplemented):
    """Convert Scapy packet into dict."""
    if scapy_all is None:
        raise ModuleNotFound("No module named 'scapy'", name='scapy')

    def wrapper(packet):
        dict_ = packet.fields
        payload = packet.payload
        if not isinstance(payload, scapy_all.packet.NoPayload):
            dict_[payload.name] = wrapper(payload)
        return dict_

    return {
        'packet': bytes(packet),
        packet.name: wrapper(packet),
    }
def packet2dict ( packet , * , count = NotImplemented ) : if scapy_all is None : raise ModuleNotFound ( "No module named 'scapy'" , name = 'scapy' ) def wrapper ( packet ) : dict_ = packet . fields payload = packet . payload if not isinstance ( payload , scapy_all . packet . NoPayload ) : dict_ [ payload . name ] = wrapper ( payload ) return dict_ return { 'packet' : bytes ( packet ) , packet . name : wrapper ( packet ) , }
Convert Scapy packet into dict.