From 1f81bfea2a20e3ad3f105211265279b7cf4f2f5b Mon Sep 17 00:00:00 2001 From: Eriks Dobelis Date: Thu, 12 Nov 2015 23:19:51 +0200 Subject: [PATCH] Fixed regression is traceroute due to changes in PacketList --- scapy/layers/inet.py | 5 +++-- scapy/plist.py | 21 +++++++++++---------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/scapy/layers/inet.py b/scapy/layers/inet.py index bb89910..877c226 100644 --- a/scapy/layers/inet.py +++ b/scapy/layers/inet.py @@ -838,7 +838,7 @@ def defrag(plist): @conf.commands.register def defragment(plist): - """defrag(plist) -> plist defragmented as much as possible """ + """defragment(plist) -> plist defragmented as much as possible """ frags = defaultdict(lambda:[]) final = [] @@ -939,7 +939,7 @@ def _packetlist_timeskew_graph(self, ip, **kargs): ### Create a new packet list class TracerouteResult(SndRcvList): def __init__(self, res=None, name="Traceroute", stats=None): - PacketList.__init__(self, res, name, stats) + PacketList.__init__(self, res, name, stats, vector_index = 1) self.graphdef = None self.graphASres = 0 self.padding = 0 @@ -1319,6 +1319,7 @@ def traceroute(target, dport=80, minttl=1, maxttl=30, sport=RandShort(), l4 = No timeout=timeout, filter=filter, verbose=verbose, **kargs) a = TracerouteResult(a.res) + if verbose: a.show() return a,b diff --git a/scapy/plist.py b/scapy/plist.py index 8fa6f08..651f2f5 100644 --- a/scapy/plist.py +++ b/scapy/plist.py @@ -136,16 +136,6 @@ def filter(self, func): """Returns a packet list filtered by a truth function""" return self.__class__(list(filter(func,self.res)), name="filtered %s"%self.listname) - def make_table(self, *args, **kargs): - """Prints a table using a function that returs for each packet its head column value, head row value and displayed value - ex: p.make_table(lambda x:(x[IP].dst, x[TCP].dport, x[TCP].sprintf("%flags%")) """ - return make_table(self.res, *args, **kargs) - def make_lined_table(self, *args, **kargs): - """Same as make_table, but print a table with lines""" - return make_lined_table(self.res, *args, **kargs) - def make_tex_table(self, *args, **kargs): - """Same as make_table, but print a table with LaTeX syntax""" - return make_tex_table(self.res, *args, **kargs) def plot(self, f, lfilter=None,**kargs): """Applies a function to each packet to get a value that will be plotted with GnuPlot. A gnuplot object is returned @@ -515,3 +505,14 @@ def nsummary(self,prn=None, lfilter=None): def filter(self, func): """Returns a SndRcv list filtered by a truth function""" return self.__class__( [ i for i in self.res if func(*i) ], name='filtered %s'%self.listname) + + def make_table(self, *args, **kargs): + """Prints a table using a function that returs for each packet its head column value, head row value and displayed value + ex: p.make_table(lambda s, r:(s[IP].dst, r[TCP].sport, s[TCP].sprintf("%flags%")) """ + return make_table(self.res, *args, **kargs) + def make_lined_table(self, *args, **kargs): + """Same as make_table, but print a table with lines""" + return make_lined_table(self.res, *args, **kargs) + def make_tex_table(self, *args, **kargs): + """Same as make_table, but print a table with LaTeX syntax""" + return make_tex_table(self.res, *args, **kargs)