luci-olsr: neightbl for ipv6 neighbours

This commit is contained in:
Patrick Grimm 2013-07-07 20:16:39 +00:00
parent 54001e307e
commit cd04b1541d
2 changed files with 42 additions and 18 deletions

View file

@ -134,6 +134,7 @@ function action_neigh(json)
local devices = ntm:get_wifidevs()
local sys = require "luci.sys"
local assoclist = {}
local neightbl = require "neightbl"
luci.sys.net.routes(function(r)
if r.dest:prefix() == 0 then
@ -165,10 +166,11 @@ function action_neigh(json)
local signal = 1
local noise = 1
local arptable = sys.net.arptable()
local mac
local rmac
local lmac
local mac = ""
local rmac = ""
local lmac = ""
local ip
local neihgt = {}
if resolve == "1" then
hostname = nixio.getnameinfo(v.remoteIP, nil, 100)
@ -190,6 +192,36 @@ function action_neigh(json)
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
@ -202,14 +234,6 @@ function action_neigh(json)
end
end
end
elseif v.proto == '6' then
uci:foreach("network", "interface",function(vif)
if vif.ip6addr and string.gsub(vif.ip6addr, "/64", "") == v.localIP then
interface = vif['.name'] or vif.interface
return
end
end)
end
if interface then
v.interface = interface
end

View file

@ -324,7 +324,7 @@ $(eval $(call application,meshwizard, Shellscript based wizard to setup mesh net
+PACKAGE_luci-app-freifunk-meshwizard:meshwizard))
$(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,\
luci-app-olsr +olsrd-mod-txtinfo))