+ for _, dev in ipairs(devices) do
+ for _, net in ipairs(dev:get_wifinets()) do
+ assoclist[#assoclist+1] = {}
+ assoclist[#assoclist]['ifname'] = net.iwdata.ifname
+ assoclist[#assoclist]['network'] = net.iwdata.network
+ assoclist[#assoclist]['device'] = net.iwdata.device
+ assoclist[#assoclist]['list'] = net.iwinfo.assoclist
+ end
+ end
+
+ for k, v in ipairs(data) do
+ local interface
+ local snr = 1
+ local signal = 1
+ local noise = 1
+ 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
+ local uprefix = uci:get("network", "globals", "ula_prefix") or ""
+ uprefix = string.gsub(uprefix, "::/.*", "")
+ ip6assign_c = 0
+ uci:foreach("network", "interface",function(vif)
+ local ip6assign = vif.ip6assign or 0
+ if ip6assign ~= 0 then
+ if ip6assign_c == 0 then
+ ip6assign_addr = uprefix.."::1"
+ else
+ ip6assign_addr = uprefix..":"..ip6assign_c.."::1"
+ end
+ ip6assign_c = ip6assign_c + 1
+ end
+ if ip6assign_addr == v.localIP then
+ interface = vif['.name'] or vif.interface
+ neihgt = neightbl.get(vif.ifname) or {}
+ return
+ elseif vif.ip6addr and string.gsub(vif.ip6addr, "/"..ip6assign, "") == v.localIP then
+ interface = vif['.name'] or vif.interface
+ neihgt = neightbl.get(vif.ifname) or {}
+ return
+ 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 = signal/noise
+ 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
+
+ if defaultgw == v.remoteIP then
+ v.defaultgw = 1
+ end
+ end