Commit 4bfdb643 authored by Gang Li's avatar Gang Li Committed by Fabio Baltieri
Browse files

hostap: add AP configuration cmd support



Implement AP configuration parameter operations.

Signed-off-by: default avatarGang Li <gang.li_1@nxp.com>
parent 1dca8224
Loading
Loading
Loading
Loading
+51 −0
Original line number Diff line number Diff line
@@ -1410,6 +1410,57 @@ int hapd_config_network(struct hostapd_iface *iface,
out:
	return ret;
}

int supplicant_ap_config_params(const struct device *dev, struct wifi_ap_config_params *params)
{
	struct hostapd_iface *iface;
	const struct wifi_mgmt_ops *const wifi_mgmt_api = get_wifi_mgmt_api(dev);
	int ret = 0;

	if (params->type & WIFI_AP_CONFIG_PARAM_MAX_INACTIVITY) {
		if (!wifi_mgmt_api || !wifi_mgmt_api->ap_config_params) {
			wpa_printf(MSG_ERROR, "ap_config_params not supported");
			return -ENOTSUP;
		}

		ret = wifi_mgmt_api->ap_config_params(dev, params);
		if (ret) {
			wpa_printf(MSG_ERROR,
				   "Failed to set maximum inactivity duration for stations");
		} else {
			wpa_printf(MSG_INFO, "Set maximum inactivity duration for stations: %d (s)",
				   params->max_inactivity);
		}
	}
	if (params->type & WIFI_AP_CONFIG_PARAM_MAX_NUM_STA) {
		k_mutex_lock(&wpa_supplicant_mutex, K_FOREVER);

		iface = get_hostapd_handle(dev);
		if (!iface) {
			ret = -ENOENT;
			wpa_printf(MSG_ERROR, "Interface %s not found", dev->name);
			goto out;
		}

		if (iface->state > HAPD_IFACE_DISABLED) {
			ret = -EBUSY;
			wpa_printf(MSG_ERROR, "Interface %s is not in disable state", dev->name);
			goto out;
		}

		if (!hostapd_cli_cmd_v("set max_num_sta %d", params->max_num_sta)) {
			ret = -EINVAL;
			wpa_printf(MSG_ERROR, "Failed to set maximum number of stations");
			goto out;
		}
		wpa_printf(MSG_INFO, "Set maximum number of stations: %d", params->max_num_sta);

out:
		k_mutex_unlock(&wpa_supplicant_mutex);
	}

	return ret;
}
#endif

int supplicant_ap_enable(const struct device *dev,
+9 −0
Original line number Diff line number Diff line
@@ -225,6 +225,15 @@ int supplicant_get_wifi_conn_params(const struct device *dev,
 * @return 0 for OK; -1 for ERROR
 */
int hapd_state(const struct device *dev, int *state);

/**
 * @brief Wi-Fi AP configuration parameter.
 *
 * @param dev Wi-Fi device
 * @param params AP parameters
 * @return 0 for OK; -1 for ERROR
 */
int supplicant_ap_config_params(const struct device *dev, struct wifi_ap_config_params *params);
#else
static inline int hapd_state(const struct device *dev, int *state)
{
+1 −0
Original line number Diff line number Diff line
@@ -99,6 +99,7 @@ static const struct wifi_mgmt_ops mgmt_ap_ops = {
#ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_DPP
	.dpp_dispatch = hapd_dpp_dispatch,
#endif /* CONFIG_WIFI_NM_WPA_SUPPLICANT_DPP */
	.ap_config_params = supplicant_ap_config_params,
};

DEFINE_WIFI_NM_INSTANCE(hostapd, &mgmt_ap_ops);