mirror of
https://github.com/hanwckf/immortalwrt-mt798x.git
synced 2025-01-09 02:43:53 +08:00
mtwifi-cfg: setup vifs in sequence of ap->apcli
This commit is contained in:
parent
ca88ac1356
commit
b093cfa42c
@ -139,6 +139,14 @@ function vif_in_dev(vif, dev)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function vif_is_apcli(vif, dev)
|
||||||
|
if (string.match(vif, utils.esc(dev.apcli_ifname).."[0-9]+")) then
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function vif_count(cfg)
|
function vif_count(cfg)
|
||||||
local vif_num = 0
|
local vif_num = 0
|
||||||
local ap_num = 0
|
local ap_num = 0
|
||||||
@ -156,6 +164,18 @@ function vif_count(cfg)
|
|||||||
return vif_num, ap_num, apcli_num
|
return vif_num, ap_num, apcli_num
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function mtwifi_cfg_foreach_vif(cfg, mode, func)
|
||||||
|
if cfg == nil or func == nil then return end
|
||||||
|
|
||||||
|
local vif_num,_,_ = vif_count(cfg)
|
||||||
|
for idx=0,vif_num-1 do
|
||||||
|
local v = cfg.interfaces[tostring(idx)]
|
||||||
|
if v.config.mode and v.config.mode == mode then
|
||||||
|
func(v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function __apcli_auto_connect(ifname)
|
function __apcli_auto_connect(ifname)
|
||||||
__exec_iwpriv_cmd(ifname, "ApCliEnable", "1")
|
__exec_iwpriv_cmd(ifname, "ApCliEnable", "1")
|
||||||
__exec_iwpriv_cmd(ifname, "ApCliAutoConnect", "3")
|
__exec_iwpriv_cmd(ifname, "ApCliAutoConnect", "3")
|
||||||
@ -177,14 +197,18 @@ function mtwifi_up(devname, cfg, restore_vifs, is_dbdc)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if restore_vifs and devname ~= cfg.device then
|
if restore_vifs and devname ~= cfg.device then
|
||||||
|
-- restart ap vif
|
||||||
for _,vif in ipairs(restore_vifs) do
|
for _,vif in ipairs(restore_vifs) do
|
||||||
if vif_in_dev(vif, dev) then
|
if vif_in_dev(vif, dev) and (not vif_is_apcli(vif, dev)) then
|
||||||
nixio.syslog("info", "mtwifi-cfg: restore vif: "..vif)
|
nixio.syslog("info", "mtwifi-cfg: restore ap vif: "..vif)
|
||||||
ifup(vif)
|
ifup(vif)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
-- restart apcli vif
|
||||||
for _,vif in ipairs(restore_vifs) do
|
for _,vif in ipairs(restore_vifs) do
|
||||||
if string.match(vif, utils.esc(dev.apcli_ifname).."[0-9]+") then
|
if vif_is_apcli(vif, dev) then
|
||||||
|
nixio.syslog("info", "mtwifi-cfg: restore apcli vif: "..vif)
|
||||||
|
ifup(vif)
|
||||||
__apcli_auto_connect(vif)
|
__apcli_auto_connect(vif)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -192,18 +216,16 @@ function mtwifi_up(devname, cfg, restore_vifs, is_dbdc)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- start vifs
|
local start_vif = function(v)
|
||||||
local vif_num,_,_ = vif_count(cfg)
|
if (not v.config.disabled) and v.mtwifi_ifname then
|
||||||
for idx=0,vif_num-1 do
|
|
||||||
local v = cfg.interfaces[tostring(idx)]
|
|
||||||
local mode = v.config.mode
|
|
||||||
if mode and (mode == "ap" or mode == "sta")
|
|
||||||
and (not v.config.disabled) and v.mtwifi_ifname then
|
|
||||||
local vif = v.mtwifi_ifname
|
local vif = v.mtwifi_ifname
|
||||||
nixio.syslog("info", "mtwifi-cfg: up vif: "..vif)
|
nixio.syslog("info", "mtwifi-cfg: up vif: "..vif)
|
||||||
ifup(vif)
|
ifup(vif)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
mtwifi_cfg_foreach_vif(cfg, "ap", start_vif)
|
||||||
|
mtwifi_cfg_foreach_vif(cfg, "sta", start_vif)
|
||||||
end
|
end
|
||||||
|
|
||||||
function mtwifi_down(devname, cfg)
|
function mtwifi_down(devname, cfg)
|
||||||
@ -254,28 +276,24 @@ function __exec_iwpriv_cmd(ifname, key, val)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function mtwifi_cfg_iwpriv_hook(cfg)
|
function mtwifi_cfg_iwpriv_hook(cfg)
|
||||||
local cmd
|
local ap_hook = function(v)
|
||||||
local iwpriv_cfgs = {}
|
if (not v.config.disabled) and v.mtwifi_ifname then
|
||||||
if cfg == nil then return end
|
|
||||||
|
|
||||||
local vif_num,_,_ = vif_count(cfg)
|
|
||||||
for idx=0,vif_num-1 do
|
|
||||||
local v = cfg.interfaces[tostring(idx)]
|
|
||||||
if not v.config.disabled and v.mtwifi_ifname then
|
|
||||||
local vif = v.mtwifi_ifname
|
local vif = v.mtwifi_ifname
|
||||||
local mode = v.config.mode
|
for k, j in pairs(defs.iwpriv_ap_cfgs) do
|
||||||
if mode == "ap" then
|
|
||||||
iwpriv_cfgs = defs.iwpriv_ap_cfgs
|
|
||||||
end
|
|
||||||
for k, j in pairs(iwpriv_cfgs) do
|
|
||||||
__exec_iwpriv_cmd(vif, j[1], v.config[k] or j[2])
|
__exec_iwpriv_cmd(vif, j[1], v.config[k] or j[2])
|
||||||
end
|
end
|
||||||
if mode == "sta" then
|
end
|
||||||
-- setup apcli auto connect
|
end
|
||||||
|
|
||||||
|
local apcli_hook = function(v)
|
||||||
|
if (not v.config.disabled) and v.mtwifi_ifname then
|
||||||
|
local vif = v.mtwifi_ifname
|
||||||
__apcli_auto_connect(vif)
|
__apcli_auto_connect(vif)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
mtwifi_cfg_foreach_vif(cfg, "ap", ap_hook)
|
||||||
|
mtwifi_cfg_foreach_vif(cfg, "sta", apcli_hook)
|
||||||
end
|
end
|
||||||
|
|
||||||
function set_chip_cfg(cfg, dats)
|
function set_chip_cfg(cfg, dats)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user