1 -- module to access linux ARP cache
3 config = require "config"
6 _ARPCACHE4 = '/sbin/ip -4 n'
9 return string.match(ip,"%d*%.%d*%.%d*%.%d*")
14 function _arpcache.get_mac(ip)
16 local rec = _arpcache.cache[ip]
17 if rec and rec.timestamp+config.arp_ttl > os.time() then
28 local f = io.popen(cmd)
41 for k in string.gmatch(line, "(%S+)") do
54 _arpcache.cache[ip] = { mac = res, timestamp = os.time() }