luci-olsr: neightbl for ipv6 neighbours
This commit is contained in:
parent
54001e307e
commit
cd04b1541d
2 changed files with 42 additions and 18 deletions
|
@ -134,6 +134,7 @@ function action_neigh(json)
|
||||||
local devices = ntm:get_wifidevs()
|
local devices = ntm:get_wifidevs()
|
||||||
local sys = require "luci.sys"
|
local sys = require "luci.sys"
|
||||||
local assoclist = {}
|
local assoclist = {}
|
||||||
|
local neightbl = require "neightbl"
|
||||||
|
|
||||||
luci.sys.net.routes(function(r)
|
luci.sys.net.routes(function(r)
|
||||||
if r.dest:prefix() == 0 then
|
if r.dest:prefix() == 0 then
|
||||||
|
@ -165,10 +166,11 @@ function action_neigh(json)
|
||||||
local signal = 1
|
local signal = 1
|
||||||
local noise = 1
|
local noise = 1
|
||||||
local arptable = sys.net.arptable()
|
local arptable = sys.net.arptable()
|
||||||
local mac
|
local mac = ""
|
||||||
local rmac
|
local rmac = ""
|
||||||
local lmac
|
local lmac = ""
|
||||||
local ip
|
local ip
|
||||||
|
local neihgt = {}
|
||||||
|
|
||||||
if resolve == "1" then
|
if resolve == "1" then
|
||||||
hostname = nixio.getnameinfo(v.remoteIP, nil, 100)
|
hostname = nixio.getnameinfo(v.remoteIP, nil, 100)
|
||||||
|
@ -190,25 +192,47 @@ function action_neigh(json)
|
||||||
rmac = string.lower(arpt['HW address'] or "")
|
rmac = string.lower(arpt['HW address'] or "")
|
||||||
end
|
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
|
|
||||||
elseif v.proto == '6' then
|
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)
|
uci:foreach("network", "interface",function(vif)
|
||||||
if vif.ip6addr and string.gsub(vif.ip6addr, "/64", "") == v.localIP then
|
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
|
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
|
return
|
||||||
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 = signal/noise
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if interface then
|
if interface then
|
||||||
v.interface = interface
|
v.interface = interface
|
||||||
|
|
|
@ -324,7 +324,7 @@ $(eval $(call application,meshwizard, Shellscript based wizard to setup mesh net
|
||||||
+PACKAGE_luci-app-freifunk-meshwizard:meshwizard))
|
+PACKAGE_luci-app-freifunk-meshwizard:meshwizard))
|
||||||
|
|
||||||
$(eval $(call application,olsr,OLSR configuration and status module,\
|
$(eval $(call application,olsr,OLSR configuration and status module,\
|
||||||
+olsrd +olsrd-mod-jsoninfo))
|
+olsrd +olsrd-mod-jsoninfo +luci-lib-luaneightbl))
|
||||||
|
|
||||||
$(eval $(call application,olsr-viz,OLSR Visualisation,\
|
$(eval $(call application,olsr-viz,OLSR Visualisation,\
|
||||||
luci-app-olsr +olsrd-mod-txtinfo))
|
luci-app-olsr +olsrd-mod-txtinfo))
|
||||||
|
|
Loading…
Reference in a new issue