diff options
Diffstat (limited to 'libs')
-rw-r--r-- | libs/core/luasrc/model/network.lua | 45 |
1 files changed, 39 insertions, 6 deletions
diff --git a/libs/core/luasrc/model/network.lua b/libs/core/luasrc/model/network.lua index 3c0964841..10fa03cff 100644 --- a/libs/core/luasrc/model/network.lua +++ b/libs/core/luasrc/model/network.lua @@ -17,8 +17,8 @@ limitations under the License. ]]-- -local type, pairs, ipairs, loadfile, table, tonumber, math, i18n - = type, pairs, ipairs, loadfile, table, tonumber, math, luci.i18n +local type, next, pairs, ipairs, loadfile, table, tonumber, math, i18n + = type, next, pairs, ipairs, loadfile, table, tonumber, math, luci.i18n local nxo = require "nixio" local ipc = require "luci.ip" @@ -155,7 +155,8 @@ function _iface_ignore(x) x:match("^wmaster%d") or x:match("^wifi%d") or x:match("^hwsim%d") or x:match("^imq%d") or x:match("^mon.wlan%d") or x:match("^6in4-%w") or x:match("^6to4-%w") or x:match("^3g-%w") or x:match("^ppp-%w") or - x:match("^pppoe-%w") or x:match("^pppoa-%w") or x == "sit0" or x == "lo" + x:match("^pppoe-%w") or x:match("^pppoa-%w") or x:match("^relay-%w") or + x == "sit0" or x == "lo" ) end @@ -505,6 +506,8 @@ function network.ifname(self) local p = self:proto() if self:is_bridge() then return "br-" .. self.sid + elseif self:proto() == "relay" then + return uci_s:get("network", self.sid, "up") == "1" and "lo" or nil elseif self:is_virtual() then return p .. "-" .. self.sid else @@ -547,7 +550,9 @@ function network.device(self) dev = (type(dev) == "table") and dev[1] or dev end - return dev + for dev in utl.imatch(dev) do + return dev + end end function network.proto(self) @@ -641,7 +646,7 @@ function network.is_virtual(self) local p = self:proto() return ( p == "3g" or p == "6in4" or p == "6to4" or p == "ppp" or - p == "pppoe" or p == "pppoa" + p == "pppoe" or p == "pppoa" or p == "relay" ) end @@ -951,7 +956,8 @@ end wifidev = utl.class() function wifidev.__init__(self, dev) - self.sid = dev + self.sid = dev + self.iwinfo = dev and sys.wifi.getiwinfo(dev) or { } end function wifidev.get(self, opt) @@ -966,6 +972,33 @@ function wifidev.name(self) return self.sid end +function wifidev.hwmodes(self) + local l = self.iwinfo.hwmodelist + if l and next(l) then + return l + else + return { b = true, g = true } + end +end + +function wifidev.get_i18n(self) + local t = "Generic" + if self.iwinfo.type == "wl" then + t = "Broadcom" + elseif self.iwinfo.type == "madwifi" then + t = "Atheros" + end + + local m = "" + local l = self:hwmodes() + if l.a then m = m .. "a" end + if l.b then m = m .. "b" end + if l.g then m = m .. "g" end + if l.n then m = m .. "n" end + + return "%s 802.11%s Wireless Controller (%s)" %{ t, m, self:name() } +end + function wifidev.is_up(self) local up = false |