libs/core: make general network model aware of the relay pseudo bridge protocol
This commit is contained in:
parent
43672158c1
commit
efcc1bfbf1
1 changed files with 39 additions and 6 deletions
|
@ -17,8 +17,8 @@ limitations under the License.
|
||||||
|
|
||||||
]]--
|
]]--
|
||||||
|
|
||||||
local type, pairs, ipairs, loadfile, table, tonumber, math, i18n
|
local type, next, pairs, ipairs, loadfile, table, tonumber, math, i18n
|
||||||
= type, pairs, ipairs, loadfile, table, tonumber, math, luci.i18n
|
= type, next, pairs, ipairs, loadfile, table, tonumber, math, luci.i18n
|
||||||
|
|
||||||
local nxo = require "nixio"
|
local nxo = require "nixio"
|
||||||
local ipc = require "luci.ip"
|
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("^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("^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("^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
|
end
|
||||||
|
|
||||||
|
@ -505,6 +506,8 @@ function network.ifname(self)
|
||||||
local p = self:proto()
|
local p = self:proto()
|
||||||
if self:is_bridge() then
|
if self:is_bridge() then
|
||||||
return "br-" .. self.sid
|
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
|
elseif self:is_virtual() then
|
||||||
return p .. "-" .. self.sid
|
return p .. "-" .. self.sid
|
||||||
else
|
else
|
||||||
|
@ -547,7 +550,9 @@ function network.device(self)
|
||||||
dev = (type(dev) == "table") and dev[1] or dev
|
dev = (type(dev) == "table") and dev[1] or dev
|
||||||
end
|
end
|
||||||
|
|
||||||
return dev
|
for dev in utl.imatch(dev) do
|
||||||
|
return dev
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function network.proto(self)
|
function network.proto(self)
|
||||||
|
@ -641,7 +646,7 @@ function network.is_virtual(self)
|
||||||
local p = self:proto()
|
local p = self:proto()
|
||||||
return (
|
return (
|
||||||
p == "3g" or p == "6in4" or p == "6to4" or p == "ppp" or
|
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
|
end
|
||||||
|
|
||||||
|
@ -951,7 +956,8 @@ end
|
||||||
|
|
||||||
wifidev = utl.class()
|
wifidev = utl.class()
|
||||||
function wifidev.__init__(self, dev)
|
function wifidev.__init__(self, dev)
|
||||||
self.sid = dev
|
self.sid = dev
|
||||||
|
self.iwinfo = dev and sys.wifi.getiwinfo(dev) or { }
|
||||||
end
|
end
|
||||||
|
|
||||||
function wifidev.get(self, opt)
|
function wifidev.get(self, opt)
|
||||||
|
@ -966,6 +972,33 @@ function wifidev.name(self)
|
||||||
return self.sid
|
return self.sid
|
||||||
end
|
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)
|
function wifidev.is_up(self)
|
||||||
local up = false
|
local up = false
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue