libs/core: adapt luci.model.network for wifi-iface instances which are members of multiple networks
This commit is contained in:
parent
1e5066815c
commit
647a0d33c3
1 changed files with 43 additions and 12 deletions
|
@ -384,7 +384,17 @@ function del_network(self, n)
|
||||||
|
|
||||||
_uci_real:foreach("wireless", "wifi-iface",
|
_uci_real:foreach("wireless", "wifi-iface",
|
||||||
function(s)
|
function(s)
|
||||||
if s.network == n then
|
local net
|
||||||
|
local rest = { }
|
||||||
|
for net in utl.imatch(s.network) do
|
||||||
|
if net ~= n then
|
||||||
|
rest[#rest+1] = net
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if #rest > 0 then
|
||||||
|
_uci_real:set("wireless", s['.name'], "network",
|
||||||
|
table.concat(rest, " "))
|
||||||
|
else
|
||||||
_uci_real:delete("wireless", s['.name'], "network")
|
_uci_real:delete("wireless", s['.name'], "network")
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
@ -421,8 +431,18 @@ function rename_network(self, old, new)
|
||||||
|
|
||||||
_uci_real:foreach("wireless", "wifi-iface",
|
_uci_real:foreach("wireless", "wifi-iface",
|
||||||
function(s)
|
function(s)
|
||||||
if s.network == old then
|
local net
|
||||||
_uci_real:set("wireless", s['.name'], "network", new)
|
local list = { }
|
||||||
|
for net in utl.imatch(s.network) do
|
||||||
|
if net == old then
|
||||||
|
list[#list+1] = new
|
||||||
|
else
|
||||||
|
list[#list+1] = net
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if #list > 0 then
|
||||||
|
_uci_real:set("wireless", s['.name'], "network",
|
||||||
|
table.concat(list, " "))
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@ -678,11 +698,14 @@ function protocol.ifname(self)
|
||||||
num[s.device] = num[s.device]
|
num[s.device] = num[s.device]
|
||||||
and num[s.device] + 1 or 1
|
and num[s.device] + 1 or 1
|
||||||
|
|
||||||
if s.network == self.sid then
|
local net
|
||||||
|
for net in utl.imatch(s.network) do
|
||||||
|
if net == self.sid then
|
||||||
ifname = "%s.network%d" %{ s.device, num[s.device] }
|
ifname = "%s.network%d" %{ s.device, num[s.device] }
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
return ifname
|
return ifname
|
||||||
|
@ -879,11 +902,15 @@ function protocol.get_interface(self)
|
||||||
function(s)
|
function(s)
|
||||||
if s.device then
|
if s.device then
|
||||||
num[s.device] = num[s.device] and num[s.device] + 1 or 1
|
num[s.device] = num[s.device] and num[s.device] + 1 or 1
|
||||||
if s.network == self.sid then
|
|
||||||
|
local net
|
||||||
|
for net in utl.imatch(s.network) do
|
||||||
|
if net == self.sid then
|
||||||
ifn = "%s.network%d" %{ s.device, num[s.device] }
|
ifn = "%s.network%d" %{ s.device, num[s.device] }
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
return ifn and interface(ifn, self)
|
return ifn and interface(ifn, self)
|
||||||
end
|
end
|
||||||
|
@ -910,11 +937,15 @@ function protocol.get_interfaces(self)
|
||||||
function(s)
|
function(s)
|
||||||
if s.device then
|
if s.device then
|
||||||
num[s.device] = num[s.device] and num[s.device] + 1 or 1
|
num[s.device] = num[s.device] and num[s.device] + 1 or 1
|
||||||
if s.network == self.sid then
|
|
||||||
|
local net
|
||||||
|
for net in utl.imatch(s.network) do
|
||||||
|
if net == self.sid then
|
||||||
ifn = "%s.network%d" %{ s.device, num[s.device] }
|
ifn = "%s.network%d" %{ s.device, num[s.device] }
|
||||||
wfs[ifn] = interface(ifn, self)
|
wfs[ifn] = interface(ifn, self)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
for ifn in utl.kspairs(wfs) do
|
for ifn in utl.kspairs(wfs) do
|
||||||
|
|
Loading…
Reference in a new issue