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

Moved ARP cache db to conf.arp_cache

parent ddf8525d
No related branches found
No related tags found
No related merge requests found
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import sys,os,struct,socket,time import sys,os,struct,socket,time
from fcntl import ioctl from fcntl import ioctl
from data import * from data import *
from config import conf
try: try:
import Gnuplot import Gnuplot
...@@ -371,8 +372,6 @@ def get_if_hwaddr(iff): ...@@ -371,8 +372,6 @@ def get_if_hwaddr(iff):
ARPTIMEOUT=120 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 if 0 and DNET: ## XXX Can't use this because it does not resolve IPs not in cache
dnet_arp_object = dnet.arp() dnet_arp_object = dnet.arp()
...@@ -401,8 +400,8 @@ else: ...@@ -401,8 +400,8 @@ else:
if gw != "0.0.0.0": if gw != "0.0.0.0":
ip = gw ip = gw
if arp_cache.has_key(ip): if conf.arp_cache.has_key(ip):
mac, timeout = arp_cache[ip] mac, timeout = conf.arp_cache[ip]
if not timeout or (time.time()-timeout < ARPTIMEOUT): if not timeout or (time.time()-timeout < ARPTIMEOUT):
return mac return mac
...@@ -415,7 +414,7 @@ else: ...@@ -415,7 +414,7 @@ else:
nofilter=1) nofilter=1)
if res is not None: if res is not None:
mac = res.payload.hwsrc mac = res.payload.hwsrc
arp_cache[ip] = (mac,time.time()) conf.arp_cache[ip] = (mac,time.time())
return mac return mac
return None return None
...@@ -174,6 +174,7 @@ extensions_paths: path or list of paths where extensions are to be looked for ...@@ -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") manufdb = load_manuf("/usr/share/wireshark/wireshark/manuf")
stats_classic_protocols = [] stats_classic_protocols = []
stats_dot11_protocols = [] stats_dot11_protocols = []
arp_cache = {}
conf=Conf() conf=Conf()
......
...@@ -85,8 +85,8 @@ class Route: ...@@ -85,8 +85,8 @@ class Route:
self.routes[i] = (the_net,the_msk,gw,iface,the_addr) self.routes[i] = (the_net,the_msk,gw,iface,the_addr)
else: else:
self.routes[i] = (net,msk,gw,iface,the_addr) self.routes[i] = (net,msk,gw,iface,the_addr)
for i in arp_cache.keys(): for i in conf.arp_cache.keys():
del(arp_cache[i]) del(conf.arp_cache[i])
......
...@@ -91,7 +91,7 @@ def sndrcv(pks, pkt, timeout = 2, inter = 0, verbose=None, chainCC=0, retry=0, m ...@@ -91,7 +91,7 @@ def sndrcv(pks, pkt, timeout = 2, inter = 0, verbose=None, chainCC=0, retry=0, m
try: try:
os.setpgrp() # Chance process group to avoid ctrl-C os.setpgrp() # Chance process group to avoid ctrl-C
sent_times = [p.sent_time for p in all_stimuli if p.sent_time] 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() wrpipe.close()
except: except:
pass pass
...@@ -161,7 +161,7 @@ def sndrcv(pks, pkt, timeout = 2, inter = 0, verbose=None, chainCC=0, retry=0, m ...@@ -161,7 +161,7 @@ def sndrcv(pks, pkt, timeout = 2, inter = 0, verbose=None, chainCC=0, retry=0, m
except EOFError: except EOFError:
warning("Child died unexpectedly. Packets may have not been sent %i"%os.getpid()) warning("Child died unexpectedly. Packets may have not been sent %i"%os.getpid())
else: else:
arp_cache.update(ac) conf.arp_cache.update(ac)
for p,t in zip(all_stimuli, sent_times): for p,t in zip(all_stimuli, sent_times):
p.sent_time = t p.sent_time = t
os.waitpid(pid,0) os.waitpid(pid,0)
......
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