diff --git a/scapy/sendrecv.py b/scapy/sendrecv.py index d0612d2139c..acb5b3cf67a 100644 --- a/scapy/sendrecv.py +++ b/scapy/sendrecv.py @@ -887,7 +887,7 @@ def _write_to_pcap(packets_list): if isinstance(offline, Packet): tempfile_written, offline = _write_to_pcap([offline]) - elif isinstance(offline, list) and \ + elif isinstance(offline, (list, PacketList)) and \ all(isinstance(elt, Packet) for elt in offline): tempfile_written, offline = _write_to_pcap(offline) diff --git a/test/regression.uts b/test/regression.uts index 0219ce0f04e..3fa99744ed5 100644 --- a/test/regression.uts +++ b/test/regression.uts @@ -1864,6 +1864,11 @@ fdesc = os.fdopen(fdesc, "wb") wrpcap(fdesc, pktpcap) fdesc.close() += Check offline sniff() (by PacketList) +l=sniff(offline=PacketList([IP()/TCP(),IP()/TCP()])) +assert len(l) == 2 +assert(all(TCP in p for p in l)) + = Check offline sniff() (by filename) assert list(pktpcap) == list(sniff(offline=filename))