mirror of
https://github.com/immortalwrt/immortalwrt.git
synced 2025-08-07 22:06:25 +08:00
hostapd: maintain ucode hostapd.bss list per interface
Preparation for MLO support Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
@ -471,18 +471,26 @@ function bss_find_existing(config, prev_config, prev_hash)
|
||||
return -1;
|
||||
}
|
||||
|
||||
function get_config_bss(config, idx)
|
||||
function get_config_bss(name, config, idx)
|
||||
{
|
||||
if (!config.bss[idx]) {
|
||||
hostapd.printf(`Invalid bss index ${idx}`);
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
let ifname = config.bss[idx].ifname;
|
||||
if (!ifname)
|
||||
if (!ifname) {
|
||||
hostapd.printf(`Could not find bss ${config.bss[idx].ifname}`);
|
||||
return;
|
||||
}
|
||||
|
||||
return hostapd.bss[ifname];
|
||||
let if_bss = hostapd.bss[name];
|
||||
if (!if_bss) {
|
||||
hostapd.printf(`Could not find interface ${name} bss list`);
|
||||
return;
|
||||
}
|
||||
|
||||
return if_bss[ifname];
|
||||
}
|
||||
|
||||
function iface_reload_config(name, phydev, config, old_config)
|
||||
@ -508,7 +516,7 @@ function iface_reload_config(name, phydev, config, old_config)
|
||||
return false;
|
||||
}
|
||||
|
||||
let first_bss = hostapd.bss[iface_name];
|
||||
let first_bss = get_config_bss(name, old_config, 0);
|
||||
if (!first_bss) {
|
||||
hostapd.printf(`Could not find bss of previous interface ${iface_name}`);
|
||||
return false;
|
||||
@ -543,7 +551,7 @@ function iface_reload_config(name, phydev, config, old_config)
|
||||
let cur_config = config.bss[i];
|
||||
let prev_config = old_config.bss[prev];
|
||||
|
||||
let prev_bss = get_config_bss(old_config, prev);
|
||||
let prev_bss = get_config_bss(name, old_config, prev);
|
||||
if (!prev_bss)
|
||||
return false;
|
||||
|
||||
@ -576,7 +584,7 @@ function iface_reload_config(name, phydev, config, old_config)
|
||||
config.bss[0].bssid = old_config.bss[0].bssid;
|
||||
}
|
||||
|
||||
let prev_bss = get_config_bss(old_config, 0);
|
||||
let prev_bss = get_config_bss(name, old_config, 0);
|
||||
if (!prev_bss)
|
||||
return false;
|
||||
|
||||
@ -591,7 +599,7 @@ function iface_reload_config(name, phydev, config, old_config)
|
||||
if (!prev_bss_hash[i])
|
||||
continue;
|
||||
|
||||
let prev_bss = get_config_bss(old_config, i);
|
||||
let prev_bss = get_config_bss(name, old_config, i);
|
||||
if (!prev_bss)
|
||||
return false;
|
||||
|
||||
@ -612,7 +620,7 @@ function iface_reload_config(name, phydev, config, old_config)
|
||||
if (old_ifname == new_ifname)
|
||||
continue;
|
||||
|
||||
if (hostapd.bss[new_ifname]) {
|
||||
if (hostapd.bss[name][new_ifname]) {
|
||||
new_ifname = "tmp_" + substr(hostapd.sha1(new_ifname), 0, 8);
|
||||
push(rename_list, i);
|
||||
}
|
||||
|
@ -47,39 +47,37 @@ hostapd_ucode_iface_get_uval(struct hostapd_iface *hapd)
|
||||
}
|
||||
|
||||
static void
|
||||
hostapd_ucode_update_bss_list(struct hostapd_iface *iface, uc_value_t *if_bss, uc_value_t *bss)
|
||||
hostapd_ucode_update_bss_list(struct hostapd_iface *iface, uc_value_t *bss)
|
||||
{
|
||||
uc_value_t *list;
|
||||
int i;
|
||||
|
||||
list = ucv_array_new(vm);
|
||||
list = ucv_object_new(vm);
|
||||
for (i = 0; iface->bss && i < iface->num_bss; i++) {
|
||||
struct hostapd_data *hapd = iface->bss[i];
|
||||
uc_value_t *uval = hostapd_ucode_bss_get_uval(hapd);
|
||||
|
||||
ucv_array_set(list, i, ucv_string_new(hapd->conf->iface));
|
||||
ucv_object_add(bss, hapd->conf->iface, hostapd_ucode_bss_get_uval(hapd));
|
||||
ucv_object_add(list, hapd->conf->iface, uval);
|
||||
}
|
||||
ucv_object_add(if_bss, iface->phy, list);
|
||||
ucv_object_add(bss, iface->phy, list);
|
||||
}
|
||||
|
||||
static void
|
||||
hostapd_ucode_update_interfaces(void)
|
||||
{
|
||||
uc_value_t *ifs = ucv_object_new(vm);
|
||||
uc_value_t *if_bss = ucv_array_new(vm);
|
||||
uc_value_t *bss = ucv_object_new(vm);
|
||||
uc_value_t *if_bss = ucv_object_new(vm);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < interfaces->count; i++) {
|
||||
struct hostapd_iface *iface = interfaces->iface[i];
|
||||
|
||||
ucv_object_add(ifs, iface->phy, hostapd_ucode_iface_get_uval(iface));
|
||||
hostapd_ucode_update_bss_list(iface, if_bss, bss);
|
||||
hostapd_ucode_update_bss_list(iface, if_bss);
|
||||
}
|
||||
|
||||
ucv_object_add(ucv_prototype_get(global), "interfaces", ifs);
|
||||
ucv_object_add(ucv_prototype_get(global), "interface_bss", if_bss);
|
||||
ucv_object_add(ucv_prototype_get(global), "bss", bss);
|
||||
ucv_object_add(ucv_prototype_get(global), "bss", if_bss);
|
||||
|
||||
ucv_gc(vm);
|
||||
}
|
||||
|
Reference in New Issue
Block a user