Skip to content

Commit 4bfdb64

Browse files
gangli02fabiobaltieri
authored andcommitted
hostap: add AP configuration cmd support
Implement AP configuration parameter operations. Signed-off-by: Gang Li <[email protected]>
1 parent 1dca822 commit 4bfdb64

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

modules/hostap/src/supp_api.c

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,6 +1410,57 @@ int hapd_config_network(struct hostapd_iface *iface,
14101410
out:
14111411
return ret;
14121412
}
1413+
1414+
int supplicant_ap_config_params(const struct device *dev, struct wifi_ap_config_params *params)
1415+
{
1416+
struct hostapd_iface *iface;
1417+
const struct wifi_mgmt_ops *const wifi_mgmt_api = get_wifi_mgmt_api(dev);
1418+
int ret = 0;
1419+
1420+
if (params->type & WIFI_AP_CONFIG_PARAM_MAX_INACTIVITY) {
1421+
if (!wifi_mgmt_api || !wifi_mgmt_api->ap_config_params) {
1422+
wpa_printf(MSG_ERROR, "ap_config_params not supported");
1423+
return -ENOTSUP;
1424+
}
1425+
1426+
ret = wifi_mgmt_api->ap_config_params(dev, params);
1427+
if (ret) {
1428+
wpa_printf(MSG_ERROR,
1429+
"Failed to set maximum inactivity duration for stations");
1430+
} else {
1431+
wpa_printf(MSG_INFO, "Set maximum inactivity duration for stations: %d (s)",
1432+
params->max_inactivity);
1433+
}
1434+
}
1435+
if (params->type & WIFI_AP_CONFIG_PARAM_MAX_NUM_STA) {
1436+
k_mutex_lock(&wpa_supplicant_mutex, K_FOREVER);
1437+
1438+
iface = get_hostapd_handle(dev);
1439+
if (!iface) {
1440+
ret = -ENOENT;
1441+
wpa_printf(MSG_ERROR, "Interface %s not found", dev->name);
1442+
goto out;
1443+
}
1444+
1445+
if (iface->state > HAPD_IFACE_DISABLED) {
1446+
ret = -EBUSY;
1447+
wpa_printf(MSG_ERROR, "Interface %s is not in disable state", dev->name);
1448+
goto out;
1449+
}
1450+
1451+
if (!hostapd_cli_cmd_v("set max_num_sta %d", params->max_num_sta)) {
1452+
ret = -EINVAL;
1453+
wpa_printf(MSG_ERROR, "Failed to set maximum number of stations");
1454+
goto out;
1455+
}
1456+
wpa_printf(MSG_INFO, "Set maximum number of stations: %d", params->max_num_sta);
1457+
1458+
out:
1459+
k_mutex_unlock(&wpa_supplicant_mutex);
1460+
}
1461+
1462+
return ret;
1463+
}
14131464
#endif
14141465

14151466
int supplicant_ap_enable(const struct device *dev,

modules/hostap/src/supp_api.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,15 @@ int supplicant_get_wifi_conn_params(const struct device *dev,
225225
* @return 0 for OK; -1 for ERROR
226226
*/
227227
int hapd_state(const struct device *dev, int *state);
228+
229+
/**
230+
* @brief Wi-Fi AP configuration parameter.
231+
*
232+
* @param dev Wi-Fi device
233+
* @param params AP parameters
234+
* @return 0 for OK; -1 for ERROR
235+
*/
236+
int supplicant_ap_config_params(const struct device *dev, struct wifi_ap_config_params *params);
228237
#else
229238
static inline int hapd_state(const struct device *dev, int *state)
230239
{

modules/hostap/src/supp_main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ static const struct wifi_mgmt_ops mgmt_ap_ops = {
9999
#ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_DPP
100100
.dpp_dispatch = hapd_dpp_dispatch,
101101
#endif /* CONFIG_WIFI_NM_WPA_SUPPLICANT_DPP */
102+
.ap_config_params = supplicant_ap_config_params,
102103
};
103104

104105
DEFINE_WIFI_NM_INSTANCE(hostapd, &mgmt_ap_ops);

0 commit comments

Comments
 (0)