diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2009-10-10 14:53:39 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2009-10-10 14:53:39 +0000 |
commit | 3fb80187f8f48ab8ac0243a487db067c667662e9 (patch) | |
tree | 387099889c12459a9a717b00e7be867549ad7ca3 /libs | |
parent | 17f2921341f3503677f407d88885a1cb41ad6380 (diff) |
libs/core: fixes for network model
Diffstat (limited to 'libs')
-rw-r--r-- | libs/core/luasrc/model/network.lua | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/libs/core/luasrc/model/network.lua b/libs/core/luasrc/model/network.lua index e6afaa4ce..718f07dc4 100644 --- a/libs/core/luasrc/model/network.lua +++ b/libs/core/luasrc/model/network.lua @@ -32,7 +32,7 @@ module "luci.model.network" local ub = uct.bind("network") -local ifs, brs +local ifs, brs, sws function init(cursor) if cursor then @@ -42,11 +42,13 @@ function init(cursor) ifs = { } brs = { } + sws = { } -- read interface information local n, i for n, i in ipairs(nxo.getifaddrs()) do local name = i.name:match("[^:]+") + local prnt = name:match("^([^%.]+)%.") if not _M:ignore_interface(name) then ifs[name] = ifs[name] or { @@ -58,6 +60,11 @@ function init(cursor) ip6addrs = { } } + if prnt then + sws[name] = true + sws[prnt] = true + end + if i.family == "packet" then ifs[name].flags = i.flags ifs[name].stats = i.data @@ -229,9 +236,7 @@ end function network.get_interfaces(self) local ifaces = { } local iface - for _, iface in ub:list( - (self:ifname() or '') .. ' ' .. (self:device() or '') - ) do + for _, iface in ipairs(ub:list(self:ifname())) do iface = iface:match("[^:]+") if ifs[iface] then ifaces[#ifaces+1] = interface(iface) @@ -242,9 +247,7 @@ end function network.contains_interface(self, iface) local i - local ifaces = ub:list( - (self:ifname() or '') .. ' ' .. (self:device() or '') - ) + local ifaces = ub:list(self:ifname()) if type(iface) ~= "string" then iface = iface:name() @@ -290,7 +293,7 @@ function interface.type(self) return "wifi" elseif brs[self.ifname] then return "bridge" - elseif self.ifname:match("%.") then + elseif sws[self.ifname] or self.ifname:match("%.") then return "switch" else return "ethernet" |