Skip to content
Snippets Groups Projects
Commit 5c6b1ce7 authored by Phil's avatar Phil
Browse files

Sanitized cyclic dependency between plist.py and sendrecv.py

parent e02f12fe
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,6 @@ from base_classes import BasePacket,BasePacketList ...@@ -5,7 +5,6 @@ from base_classes import BasePacket,BasePacketList
from utils import incremental_label,colgen,do_graph,hexdump,make_table,make_lined_table,make_tex_table from utils import incremental_label,colgen,do_graph,hexdump,make_table,make_lined_table,make_tex_table
from packet import Padding,Raw from packet import Padding,Raw
from sendrecv import sr
from layers.inet import IP,TCP,UDP,ICMP from layers.inet import IP,TCP,UDP,ICMP
from layers.l2 import Ether from layers.l2 import Ether
from layers.dot11 import Dot11 from layers.dot11 import Dot11
...@@ -15,6 +14,10 @@ import arch ...@@ -15,6 +14,10 @@ import arch
if arch.GNUPLOT: if arch.GNUPLOT:
Gnuplot=arch.Gnuplot Gnuplot=arch.Gnuplot
import sendrecv
############# #############
## Results ## ## Results ##
############# #############
...@@ -689,7 +692,7 @@ class TracerouteResult(SndRcvList): ...@@ -689,7 +692,7 @@ class TracerouteResult(SndRcvList):
continue continue
savcolor = o.color savcolor = o.color
o.color = (1,0,0) o.color = (1,0,0)
a,b=sr(IP(dst=o.ip)/TCP(dport=[21,22,23,25,80,443]),timeout=2) a,b=sendrecv.sr(IP(dst=o.ip)/TCP(dport=[21,22,23,25,80,443]),timeout=2)
o.color = savcolor o.color = savcolor
if len(a) == 0: if len(a) == 0:
txt = "%s:\nno results" % o.ip txt = "%s:\nno results" % o.ip
......
...@@ -4,8 +4,8 @@ from data import * ...@@ -4,8 +4,8 @@ from data import *
from arch import * from arch import *
from config import conf from config import conf
from packet import Gen from packet import Gen
from plist import PacketList,SndRcvList
from utils import warning from utils import warning
import plist
################# #################
## Debug class ## ## Debug class ##
...@@ -30,9 +30,9 @@ def sndrcv(pks, pkt, timeout = 2, inter = 0, verbose=None, chainCC=0, retry=0, m ...@@ -30,9 +30,9 @@ def sndrcv(pks, pkt, timeout = 2, inter = 0, verbose=None, chainCC=0, retry=0, m
if verbose is None: if verbose is None:
verbose = conf.verb verbose = conf.verb
debug.recv = PacketList([],"Unanswered") debug.recv = plist.PacketList([],"Unanswered")
debug.sent = PacketList([],"Sent") debug.sent = plist.PacketList([],"Sent")
debug.match = SndRcvList([]) debug.match = plist.SndRcvList([])
nbrecv=0 nbrecv=0
ans = [] ans = []
# do it here to fix random fields, so that parent and child have the same # do it here to fix random fields, so that parent and child have the same
...@@ -182,8 +182,8 @@ def sndrcv(pks, pkt, timeout = 2, inter = 0, verbose=None, chainCC=0, retry=0, m ...@@ -182,8 +182,8 @@ def sndrcv(pks, pkt, timeout = 2, inter = 0, verbose=None, chainCC=0, retry=0, m
retry -= 1 retry -= 1
if conf.debug_match: if conf.debug_match:
debug.sent=PacketList(remain[:],"Sent") debug.sent=plist.PacketList(remain[:],"Sent")
debug.match=SndRcvList(ans[:]) debug.match=plist.SndRcvList(ans[:])
#clean the ans list to delete the field _answered #clean the ans list to delete the field _answered
if (multi): if (multi):
...@@ -193,7 +193,7 @@ def sndrcv(pks, pkt, timeout = 2, inter = 0, verbose=None, chainCC=0, retry=0, m ...@@ -193,7 +193,7 @@ def sndrcv(pks, pkt, timeout = 2, inter = 0, verbose=None, chainCC=0, retry=0, m
if verbose: if verbose:
print "\nReceived %i packets, got %i answers, remaining %i packets" % (nbrecv+len(ans), len(ans), notans) print "\nReceived %i packets, got %i answers, remaining %i packets" % (nbrecv+len(ans), len(ans), notans)
return SndRcvList(ans),PacketList(remain,"Unanswered"),debug.recv return plist.SndRcvList(ans),plist.PacketList(remain,"Unanswered"),debug.recv
def __gen_send(s, x, inter=0, loop=0, count=None, verbose=None, *args, **kargs): def __gen_send(s, x, inter=0, loop=0, count=None, verbose=None, *args, **kargs):
...@@ -394,7 +394,7 @@ def __sr_loop(srfunc, pkts, prn=lambda x:x[1].summary(), prnfail=lambda x:x.summ ...@@ -394,7 +394,7 @@ def __sr_loop(srfunc, pkts, prn=lambda x:x[1].summary(), prnfail=lambda x:x.summ
if verbose and n>0: if verbose and n>0:
print ct.normal("\nSent %i packets, received %i packets. %3.1f%% hits." % (n,r,100.0*r/n)) print ct.normal("\nSent %i packets, received %i packets. %3.1f%% hits." % (n,r,100.0*r/n))
return SndRcvList(ans),PacketList(unans) return plist.SndRcvList(ans),plist.PacketList(unans)
def srloop(pkts, *args, **kargs): def srloop(pkts, *args, **kargs):
"""Send a packet at layer 3 in loop and print the answer each time """Send a packet at layer 3 in loop and print the answer each time
...@@ -411,7 +411,7 @@ def sndrcvflood(pks, pkt, prn=lambda (s,r):r.summary(), chainCC=0, store=1, uniq ...@@ -411,7 +411,7 @@ def sndrcvflood(pks, pkt, prn=lambda (s,r):r.summary(), chainCC=0, store=1, uniq
if not isinstance(pkt, Gen): if not isinstance(pkt, Gen):
pkt = SetGen(pkt) pkt = SetGen(pkt)
tobesent = [p for p in pkt] tobesent = [p for p in pkt]
received = SndRcvList() received = plist.SndRcvList()
seen = {} seen = {}
hsent={} hsent={}
...@@ -545,6 +545,6 @@ L2socket: use the provided L2socket ...@@ -545,6 +545,6 @@ L2socket: use the provided L2socket
except KeyboardInterrupt: except KeyboardInterrupt:
break break
s.close() s.close()
return PacketList(lst,"Sniffed") return plist.PacketList(lst,"Sniffed")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment