summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/luasrc/sys.lua
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2018-01-02 00:24:10 +0100
committerJo-Philipp Wich <jo@mein.io>2018-01-02 00:24:10 +0100
commitf9b8d7ff7bbd3c82f9889b65af07a28d94d9fed7 (patch)
treec1da9bd9e0dbc7ddae9556eefd340fcc2716be47 /modules/luci-base/luasrc/sys.lua
parentf2162a9a668db1c45bd0bc7ad59ebfd9b7abe762 (diff)
luci-base: rework wireless state handling (#1179)
- fix mapping of ubus wireless state to uci declared vifs - fix leaking foreign vif info into per-phy iwinfo stats Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base/luasrc/sys.lua')
-rw-r--r--modules/luci-base/luasrc/sys.lua35
1 files changed, 4 insertions, 31 deletions
diff --git a/modules/luci-base/luasrc/sys.lua b/modules/luci-base/luasrc/sys.lua
index 115c54d54..3fcfd4def 100644
--- a/modules/luci-base/luasrc/sys.lua
+++ b/modules/luci-base/luasrc/sys.lua
@@ -7,6 +7,7 @@ local table = require "table"
local nixio = require "nixio"
local fs = require "nixio.fs"
local uci = require "luci.model.uci"
+local ntm = require "luci.model.network"
local luci = {}
luci.util = require "luci.util"
@@ -451,37 +452,9 @@ end
wifi = {}
function wifi.getiwinfo(ifname)
- local stat, iwinfo = pcall(require, "iwinfo")
-
- if ifname then
- local d, n = ifname:match("^(%w+)%.network(%d+)")
- local wstate = luci.util.ubus("network.wireless", "status") or { }
-
- d = d or ifname
- n = n and tonumber(n) or 1
-
- if type(wstate[d]) == "table" and
- type(wstate[d].interfaces) == "table" and
- type(wstate[d].interfaces[n]) == "table" and
- type(wstate[d].interfaces[n].ifname) == "string"
- then
- ifname = wstate[d].interfaces[n].ifname
- else
- ifname = d
- end
-
- local t = stat and iwinfo.type(ifname)
- local x = t and iwinfo[t] or { }
- return setmetatable({}, {
- __index = function(t, k)
- if k == "ifname" then
- return ifname
- elseif x[k] then
- return x[k](ifname)
- end
- end
- })
- end
+ ntm.init()
+ local wnet = ntm.wifinet(ifname)
+ return wnet.iwinfo or { ifname = ifname }
end