X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=modules%2Fniu%2Fluasrc%2Fniulib.lua;h=7690294bc1a4f06d33e34c1615c8349076577428;hp=2a46355531004422d9a7ea2b9d24a9b47fb06ada;hb=1a2165b0bd10694db696daa79ea1e388ecae4ef2;hpb=4cf6fdcdbeddb60f512961aad345447972ab94e4 diff --git a/modules/niu/luasrc/niulib.lua b/modules/niu/luasrc/niulib.lua index 2a4635553..7690294bc 100644 --- a/modules/niu/luasrc/niulib.lua +++ b/modules/niu/luasrc/niulib.lua @@ -15,7 +15,9 @@ $Id$ local ipairs, pairs, require = ipairs, pairs, require local os = require "os" -local cursor = require "luci.model.uci".inst +local uci = require "luci.model.uci" +local cursor = uci.inst +local state = uci.inst_state module "luci.niulib" @@ -36,7 +38,21 @@ function eth_get_available(except) return ifs end -function wifi_get_available(except) +function eth_get_bridged(except) + local devs = state:get("network", except, "device") or "" + + local ifs = {} + local cnt = 0 + for x in devs:gmatch("[^ ]+") do + cnt = cnt + 1 + if x:find("eth") == 1 then + ifs[#ifs+1] = x + end + end + return cnt > 1 and ifs or {} +end + +function wifi_get_available(except, types) cursor:unload("wireless") local iwinfo = require "iwinfo" @@ -50,13 +66,13 @@ function wifi_get_available(except) for k in pairs(used) do local t = iwinfo.type(k) if t and iwinfo[t] then - used[k] = (iwinfo[t].mbssid_support() < 1) + used[k] = (iwinfo[t].mbssid_support(k) < 1) end end local wifis = {} cursor:foreach("wireless", "wifi-device", function(s) - if not used[s[".name"]] then + if not used[s[".name"]] and (not types or types[s.type]) then wifis[#wifis+1] = s[".name"] end end)