diff --git a/scapy/arch.py b/scapy/arch.py index debf2c1bbed57e8081cee7fcd948dba6f14b2336..7d1f70510b4d44ee3ff6961ec1aaf661380c7b6f 100644 --- a/scapy/arch.py +++ b/scapy/arch.py @@ -2,6 +2,7 @@ import sys,os,struct,socket,time from fcntl import ioctl from data import * +from config import conf try: import Gnuplot @@ -371,8 +372,6 @@ def get_if_hwaddr(iff): ARPTIMEOUT=120 -# XXX Fill arp_cache with /etc/ether and arp cache -arp_cache={} if 0 and DNET: ## XXX Can't use this because it does not resolve IPs not in cache dnet_arp_object = dnet.arp() @@ -401,8 +400,8 @@ else: if gw != "0.0.0.0": ip = gw - if arp_cache.has_key(ip): - mac, timeout = arp_cache[ip] + if conf.arp_cache.has_key(ip): + mac, timeout = conf.arp_cache[ip] if not timeout or (time.time()-timeout < ARPTIMEOUT): return mac @@ -415,7 +414,7 @@ else: nofilter=1) if res is not None: mac = res.payload.hwsrc - arp_cache[ip] = (mac,time.time()) + conf.arp_cache[ip] = (mac,time.time()) return mac return None diff --git a/scapy/config.py b/scapy/config.py index 93bcfe7e9182411b912cb131193922e9338263ac..5d7872fffaf698a8ac519d7aade6c950b20aa972 100644 --- a/scapy/config.py +++ b/scapy/config.py @@ -174,6 +174,7 @@ extensions_paths: path or list of paths where extensions are to be looked for manufdb = load_manuf("/usr/share/wireshark/wireshark/manuf") stats_classic_protocols = [] stats_dot11_protocols = [] + arp_cache = {} conf=Conf() diff --git a/scapy/route.py b/scapy/route.py index 33cfad1591a009b248b4b2f5b72d136fa6fff4ef..8ee2a966ce7a91bc31f78fbb794113bf90b199e7 100644 --- a/scapy/route.py +++ b/scapy/route.py @@ -85,8 +85,8 @@ class Route: self.routes[i] = (the_net,the_msk,gw,iface,the_addr) else: self.routes[i] = (net,msk,gw,iface,the_addr) - for i in arp_cache.keys(): - del(arp_cache[i]) + for i in conf.arp_cache.keys(): + del(conf.arp_cache[i]) diff --git a/scapy/sendrecv.py b/scapy/sendrecv.py index aa54e7db64843151a95dcc1bb85f2b01dc89ee25..8fa501b77f2332aa9b00dff0763f0a1592757139 100644 --- a/scapy/sendrecv.py +++ b/scapy/sendrecv.py @@ -91,7 +91,7 @@ def sndrcv(pks, pkt, timeout = 2, inter = 0, verbose=None, chainCC=0, retry=0, m try: os.setpgrp() # Chance process group to avoid ctrl-C sent_times = [p.sent_time for p in all_stimuli if p.sent_time] - cPickle.dump( (arp_cache,sent_times), wrpipe ) + cPickle.dump( (conf.arp_cache,sent_times), wrpipe ) wrpipe.close() except: pass @@ -161,7 +161,7 @@ def sndrcv(pks, pkt, timeout = 2, inter = 0, verbose=None, chainCC=0, retry=0, m except EOFError: warning("Child died unexpectedly. Packets may have not been sent %i"%os.getpid()) else: - arp_cache.update(ac) + conf.arp_cache.update(ac) for p,t in zip(all_stimuli, sent_times): p.sent_time = t os.waitpid(pid,0)