From 513f008fd15de9f6f05a037592d62d7fb8147d70 Mon Sep 17 00:00:00 2001 From: Phil <phil@secdev.org> Date: Sun, 10 Feb 2008 18:58:50 +0100 Subject: [PATCH] Added verbose parameter (from D. Loss, ticket #73) --- scapy.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scapy.py b/scapy.py index acb2da37..fdaf2f9e 100755 --- a/scapy.py +++ b/scapy.py @@ -10230,10 +10230,12 @@ iface: work only on the given interface""" else: return None -def __sr_loop(srfunc, pkts, prn=lambda x:x[1].summary(), prnfail=lambda x:x.summary(), inter=1, timeout=None, count=None, verbose=0, store=1, *args, **kargs): +def __sr_loop(srfunc, pkts, prn=lambda x:x[1].summary(), prnfail=lambda x:x.summary(), inter=1, timeout=None, count=None, verbose=None, store=1, *args, **kargs): n = 0 r = 0 ct = conf.color_theme + if verbose is None: + verbose = conf.verb parity = 0 ans=[] unans=[] @@ -10252,19 +10254,19 @@ def __sr_loop(srfunc, pkts, prn=lambda x:x[1].summary(), prnfail=lambda x:x.summ res = srfunc(pkts, timeout=timeout, verbose=0, chainCC=1, *args, **kargs) n += len(res[0])+len(res[1]) r += len(res[0]) - if prn and len(res[0]) > 0: + if verbose > 1 and prn and len(res[0]) > 0: msg = "RECV %i:" % len(res[0]) print "\r"+ct.success(msg), for p in res[0]: print col(prn(p)) print " "*len(msg), - if prnfail and len(res[1]) > 0: + if verbose > 1 and prnfail and len(res[1]) > 0: msg = "fail %i:" % len(res[1]) print "\r"+ct.fail(msg), for p in res[1]: print col(prnfail(p)) print " "*len(msg), - if not (prn or prnfail): + if verbose > 1 and not (prn or prnfail): print "recv:%i fail:%i" % tuple(map(len, res[:2])) if store: ans += res[0] @@ -10275,7 +10277,7 @@ def __sr_loop(srfunc, pkts, prn=lambda x:x[1].summary(), prnfail=lambda x:x.summ except KeyboardInterrupt: pass - if n>0: + if verbose and n>0: print "%s\nSent %i packets, received %i packets. %3.1f%% hits." % (Color.normal,n,r,100.0*r/n) return SndRcvList(ans),PacketList(unans) -- GitLab