Skip to content

Commit a7f4150

Browse files
MaochenWang1jhedberg
authored andcommitted
hostap: avoid configuring region domain when SAP is enabled
Configuring the region domain while SAP is enabled may lead to instability in SAP's state and functionality. This change ensures the region domain is not set when SAP is active. Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
1 parent 55ecc63 commit a7f4150

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed

modules/hostap/src/hapd_api.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,18 +365,28 @@ int hostapd_add_enterprise_creds(const struct device *dev,
365365
}
366366
#endif
367367

368-
bool hostapd_ap_reg_domain(const struct device *dev,
368+
int hostapd_ap_reg_domain(const struct device *dev,
369369
struct wifi_reg_domain *reg_domain)
370370
{
371371
struct hostapd_iface *iface;
372+
int ret = 0;
372373

373374
iface = get_hostapd_handle(dev);
374375
if (iface == NULL) {
375376
wpa_printf(MSG_ERROR, "Interface %s not found", dev->name);
376-
return false;
377+
ret = -ENODEV;
378+
}
379+
380+
if (iface->state == HAPD_IFACE_ENABLED) {
381+
wpa_printf(MSG_ERROR, "Interface %s is operational and in SAP mode", dev->name);
382+
ret = -EACCES;
377383
}
378384

379-
return hostapd_cli_cmd_v("set country_code %s", reg_domain->country_code);
385+
if (!hostapd_cli_cmd_v("set country_code %s", reg_domain->country_code)) {
386+
ret = -ENOTSUP;
387+
}
388+
389+
return ret;
380390
}
381391

382392
static int hapd_config_chan_center_seg0(struct hostapd_iface *iface,

modules/hostap/src/hapd_api.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ int hostapd_ap_config_params(const struct device *dev, struct wifi_ap_config_par
2626
*
2727
* @param reg_domain region domain parameters
2828
* @param dev Wi-Fi device
29-
* @return true for OK; false for ERROR
29+
* @return 0 if OK; < 0 if error
3030
*/
31-
bool hostapd_ap_reg_domain(const struct device *dev,
31+
int hostapd_ap_reg_domain(const struct device *dev,
3232
struct wifi_reg_domain *reg_domain);
3333

3434
#ifdef CONFIG_WIFI_NM_HOSTAPD_WPS

modules/hostap/src/supp_api.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,6 +1729,15 @@ int supplicant_reg_domain(const struct device *dev,
17291729
if (reg_domain->oper == WIFI_MGMT_SET) {
17301730
k_mutex_lock(&wpa_supplicant_mutex, K_FOREVER);
17311731

1732+
if (IS_ENABLED(CONFIG_WIFI_NM_HOSTAPD_AP)) {
1733+
const struct device *dev2 = net_if_get_device(net_if_get_wifi_sap());
1734+
1735+
ret = hostapd_ap_reg_domain(dev2, reg_domain);
1736+
if (ret) {
1737+
goto out;
1738+
}
1739+
}
1740+
17321741
wpa_s = get_wpa_s_handle(dev);
17331742
if (!wpa_s) {
17341743
wpa_printf(MSG_ERROR, "Interface %s not found", dev->name);
@@ -1739,14 +1748,6 @@ int supplicant_reg_domain(const struct device *dev,
17391748
goto out;
17401749
}
17411750

1742-
if (IS_ENABLED(CONFIG_WIFI_NM_HOSTAPD_AP)) {
1743-
const struct device *dev2 = net_if_get_device(net_if_get_wifi_sap());
1744-
1745-
if (!hostapd_ap_reg_domain(dev2, reg_domain)) {
1746-
goto out;
1747-
}
1748-
}
1749-
17501751
ret = 0;
17511752

17521753
out:

0 commit comments

Comments
 (0)