Skip to content

Commit

Permalink
Fixed regression is traceroute due to changes in PacketList
Browse files Browse the repository at this point in the history
  • Loading branch information
phaethon committed Nov 12, 2015
1 parent ee66c1d commit 1f81bfe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
5 changes: 3 additions & 2 deletions scapy/layers/inet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
21 changes: 11 additions & 10 deletions scapy/plist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

0 comments on commit 1f81bfe

Please sign in to comment.