Skip to content

Commit

Permalink
Update to enable offline sniff() to use a PacketList (#3026)
Browse files Browse the repository at this point in the history
  • Loading branch information
piersoh authored Jan 14, 2021
1 parent a436560 commit ef4937f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion scapy/sendrecv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
5 changes: 5 additions & 0 deletions test/regression.uts
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down

0 comments on commit ef4937f

Please sign in to comment.