if (!cfg || !cfg.bss || !cfg.bss[0] || !cfg.bss[0].ifname)
return;
- hostapd.remove_iface(cfg.bss[0].ifname);
for (let bss in cfg.bss)
wdev_remove(bss.ifname);
}
let config_inline = iface_gen_config(phy, config, !!phy_status);
let bss = config.bss[0];
- let ret = hostapd.add_iface(`bss_config=${bss.ifname}:${config_inline}`);
+ let ret = hostapd.add_iface(`bss_config=${phy}:${config_inline}`);
if (ret < 0)
return false;
if (!phy_status)
return true;
- let iface = hostapd.interfaces[bss.ifname];
+ let iface = hostapd.interfaces[phy];
if (!iface)
return false;
return macaddr_list;
}
+function iface_update_supplicant_macaddr(phy, config)
+{
+ let macaddr_list = [];
+ for (let i = 0; i < length(config.bss); i++)
+ push(macaddr_list, config.bss[i].bssid);
+ ubus.call("wpa_supplicant", "phy_set_macaddr_list", { phy: phy, macaddr: macaddr_list });
+}
+
function iface_restart(phydev, config, old_config)
{
let phy = phydev.name;
+ hostapd.remove_iface(phy);
iface_remove(old_config);
iface_remove(config);
bss.bssid = phydev.macaddr_next();
}
+ iface_update_supplicant_macaddr(phy, config);
+
let bss = config.bss[0];
let err = wdev_create(phy, bss.ifname, { mode: "ap" });
if (err)
for (let key in config.hash)
new_cfg.hash[key] = config.hash[key];
delete new_cfg.hash.wpa_psk_file;
+ delete new_cfg.hash.vlan_file;
return new_cfg;
}
if (!old_config.bss || !old_config.bss[0])
return false;
+ let iface = hostapd.interfaces[phy];
let iface_name = old_config.bss[0].ifname;
- let iface = hostapd.interfaces[iface_name];
if (!iface) {
hostapd.printf(`Could not find previous interface ${iface_name}`);
return false;
bss_remove_file_fields(bss_list_cfg[i]))) {
hostapd.printf(`Update config data files for bss ${ifname}`);
if (bss.set_config(config_inline, i, true) < 0) {
- hostapd.printf(`Failed to update config data files for bss ${ifname}`);
+ hostapd.printf(`Could not update config data files for bss ${ifname}`);
return false;
+ } else {
+ bss.ctrl("RELOAD_WPA_PSK");
+ continue;
}
- bss.ctrl("RELOAD_WPA_PSK");
- continue;
}
bss_reload_psk(bss, config.bss[i], bss_list_cfg[i]);
continue;
hostapd.printf(`Reload config for bss '${config.bss[0].ifname}' on phy '${phy}'`);
- hostapd.printf(`old: ${bss_remove_file_fields(bss_list_cfg[i])}`);
- hostapd.printf(`new: ${bss_remove_file_fields(config.bss[i])}`);
if (bss.set_config(config_inline, i) < 0) {
hostapd.printf(`Failed to set config for bss ${ifname}`);
return false;
return true;
}
-function iface_update_supplicant_macaddr(phy, config)
-{
- let macaddr_list = [];
- for (let i = 0; i < length(config.bss); i++)
- push(macaddr_list, config.bss[i].bssid);
- ubus.call("wpa_supplicant", "phy_set_macaddr_list", { phy: phy, macaddr: macaddr_list });
-}
-
function iface_set_config(phy, config)
{
let old_config = hostapd.data.config[phy];
hostapd.data.config[phy] = config;
- if (!config)
+ if (!config) {
+ hostapd.remove_iface(phy);
return iface_remove(old_config);
+ }
let phydev = phy_open(phy);
if (!phydev) {
hostapd.printf(`Restart interface for phy ${phy}`);
let ret = iface_restart(phydev, config, old_config);
- iface_update_supplicant_macaddr(phy, config);
return ret;
}
let bss;
let line;
- while ((line = trim(f.read("line"))) != null) {
+ while ((line = rtrim(f.read("line"), "\n")) != null) {
let val = split(line, "=", 2);
if (!val[0])
continue;
push(config.radio.data, line);
}
- while ((line = trim(f.read("line"))) != null) {
+ while ((line = rtrim(f.read("line"), "\n")) != null) {
if (line == "#default_macaddr")
bss.default_macaddr = true;
if (!config || !config.bss || !config.bss[0] || !config.bss[0].ifname)
return 0;
- let iface = hostapd.interfaces[config.bss[0].ifname];
+ let iface = hostapd.interfaces[phy];
if (!iface)
return 0;
hostapd.data.ubus = ubus;
hostapd.data.obj = ubus.publish("hostapd", main_obj);
+hostapd.udebug_set("hostapd", hostapd.data.ubus);
function bss_event(type, name, data) {
let ubus = hostapd.data.ubus;
shutdown: function() {
for (let phy in hostapd.data.config)
iface_set_config(phy, null);
+ hostapd.udebug_set(null);
hostapd.ubus.disconnect();
},
bss_add: function(name, obj) {