Scapy TSHARK
diff --git a/scapy/sendrecv.py b/scapy/sendrecv.py
index b5c1380..d67e010 100644
--- a/scapy/sendrecv.py
+++ b/scapy/sendrecv.py
@@ -853,7 +853,11 @@
@conf.commands.register
def tshark(*args,**kargs):
- """Sniff packets and print them calling pkt.show(), a bit like text wireshark"""
- sniff(prn=lambda x: x.display(),*args,**kargs)
-
-
+ """Sniff packets and print them calling pkt.summary(), a bit like text wireshark"""
+ print("Capturing on '" + str(kargs.get('iface') if 'iface' in kargs else conf.iface) + "'")
+ i = [0] # This should be a nonlocal variable, using a mutable object for Python 2 compatibility
+ def _cb(pkt):
+ print("%5d\t%s" % (i[0], pkt.summary()))
+ i[0] += 1
+ sniff(prn=_cb, store=False, *args, **kargs)
+ print("\n%d packet%s captured" % (i[0], 's' if i[0] > 1 else ''))
diff --git a/test/regression.uts b/test/regression.uts
index 8f095e9..01693f2 100644
--- a/test/regression.uts
+++ b/test/regression.uts
@@ -5544,6 +5544,10 @@
values = [tuple(int(val) for val in line[:-1].split(b'\t')) for line in tcpdump(pcapfile, prog=conf.prog.tshark, getfd=True, args=['-T', 'fields', '-e', 'ip.ttl', '-e', 'ip.proto'])]
assert values == [(64, 6), (64, 17), (64, 1)]
+= Run scapy's tshark command
+~ netaccess
+tshark(count=1, timeout=3)
+
= Check Raw IP pcap files
import tempfile