def packet2dict(packet, *, count=NotImplemented):
if scapy_all is None:<EOL><INDENT>raise ModuleNotFound("<STR_LIT>", name='<STR_LIT>')<EOL><DEDENT>def wrapper(packet):<EOL><INDENT>dict_ = packet.fields<EOL>payload = packet.payload<EOL>if not isinstance(payload, scapy_all.packet.NoPayload):<EOL><INDENT>dict_[payload.name] = wrapper(payload)<EOL><DEDENT>return dict_<EOL><DEDENT>return {<EOL>'<STR_LIT>': bytes(packet),<EOL>packet.name: wrapper(packet),<EOL>}<EOL>
Convert Scapy packet into dict.