Skip to content

Commit ef4937f

Browse files
authored
Update to enable offline sniff() to use a PacketList (#3026)
1 parent a436560 commit ef4937f

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

scapy/sendrecv.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ def _write_to_pcap(packets_list):
887887

888888
if isinstance(offline, Packet):
889889
tempfile_written, offline = _write_to_pcap([offline])
890-
elif isinstance(offline, list) and \
890+
elif isinstance(offline, (list, PacketList)) and \
891891
all(isinstance(elt, Packet) for elt in offline):
892892
tempfile_written, offline = _write_to_pcap(offline)
893893

test/regression.uts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1864,6 +1864,11 @@ fdesc = os.fdopen(fdesc, "wb")
18641864
wrpcap(fdesc, pktpcap)
18651865
fdesc.close()
18661866

1867+
= Check offline sniff() (by PacketList)
1868+
l=sniff(offline=PacketList([IP()/TCP(),IP()/TCP()]))
1869+
assert len(l) == 2
1870+
assert(all(TCP in p for p in l))
1871+
18671872
= Check offline sniff() (by filename)
18681873
assert list(pktpcap) == list(sniff(offline=filename))
18691874

0 commit comments

Comments
 (0)