+ for k, v in ipairs(data) do
+ local interface
+ local snr = 0
+ local signal = 0
+ local noise = 0
+ local arptable = sys.net.arptable()
+ local mac = ""
+ local rmac = ""
+ local lmac = ""
+ local ip
+ local neihgt = {}
+
+ if resolve == "1" then
+ hostname = nixio.getnameinfo(v.remoteIP, nil, 100)
+ if hostname then
+ v.hostname = hostname
+ end
+ end
+ if v.proto == '4' then
+ uci:foreach("network", "interface",function(vif)
+ if vif.ipaddr and vif.ipaddr == v.localIP then
+ interface = vif['.name'] or vif.interface
+ lmac = string.lower(vif.macaddr or "")
+ return
+ end
+ end)
+ for _, arpt in ipairs(arptable) do
+ ip = arpt['IP address']
+ if ip == v.remoteIP then
+ rmac = string.lower(arpt['HW address'] or "")
+ end
+ end
+ elseif v.proto == '6' then
+ uci:foreach("network", "interface",function(vif)
+ local name = vif['.name']
+ local net = ntm:get_network(name)
+ local device = net and net:get_interface()
+ local locip = ipc.IPv6(v.localIP)
+ if device and device:ip6addrs() and locip then
+ for _, a in ipairs(device:ip6addrs()) do
+ if not a:is6linklocal() then
+ if a:host() == locip:host() then
+ interface = name
+ neihgt = neightbl.get(device.ifname) or {}
+ end
+ end
+ end
+ end
+ end)
+ for ip,mac in pairs(neihgt) do
+ if ip == v.remoteIP then
+ rmac = mac
+ end
+ end
+ end
+ for _, val in ipairs(assoclist) do
+ if val.network == interface and val.list then
+ for assocmac, assot in pairs(val.list) do
+ assocmac = string.lower(assocmac or "")
+ if rmac == assocmac then
+ signal = tonumber(assot.signal)
+ noise = tonumber(assot.noise)
+ snr = (noise*-1) - (signal*-1)
+ end
+ end
+ end
+ end
+ if interface then
+ v.interface = interface
+ end
+ v.snr = snr
+ v.signal = signal
+ v.noise = noise
+ if rmac then
+ v.remoteMAC = rmac
+ end
+ if lmac then
+ v.localMAC = lmac
+ end