/*
 * WPA Supplicant - Basic AP mode support routines
 * Copyright (c) 2003-2009, Jouni Malinen <j@w1.fi>
 * Copyright (c) 2009, Atheros Communications
 *
 * This software may be distributed under the terms of the BSD license.
 * See README for more details.
 */

#include "utils/includes.h"

#include "utils/common.h"
#include "utils/eloop.h"
#include "utils/uuid.h"
#include "common/ieee802_11_defs.h"
#include "common/wpa_ctrl.h"
#include "eapol_supp/eapol_supp_sm.h"
#include "crypto/dh_group5.h"
#include "ap/hostapd.h"
#include "ap/ap_config.h"
#include "ap/ap_drv_ops.h"
#ifdef NEED_AP_MLME
#include "ap/ieee802_11.h"
#endif /* NEED_AP_MLME */
#include "ap/beacon.h"
#include "ap/ieee802_1x.h"
#include "ap/wps_hostapd.h"
#include "ap/ctrl_iface_ap.h"
#include "ap/dfs.h"
#include "wps/wps.h"
#include "common/ieee802_11_defs.h"
#include "config_ssid.h"
#include "config.h"
#include "wpa_supplicant_i.h"
#include "driver_i.h"
#include "p2p_supplicant.h"
#include "ap.h"
#include "ap/sta_info.h"
#include "notify.h"


#ifdef CONFIG_WPS
static void wpas_wps_ap_pin_timeout(void *eloop_data, void *user_ctx);
#endif /* CONFIG_WPS */


#ifdef CONFIG_P2P
static bool is_chanwidth160_supported(struct hostapd_hw_modes *mode,
				      struct hostapd_config *conf)
{
#ifdef CONFIG_IEEE80211AX
	if (conf->ieee80211ax) {
		struct he_capabilities *he_cap;

		he_cap = &mode->he_capab[IEEE80211_MODE_AP];
		if (he_cap->phy_cap[HE_PHYCAP_CHANNEL_WIDTH_SET_IDX] &
		    (HE_PHYCAP_CHANNEL_WIDTH_SET_80PLUS80MHZ_IN_5G |
		     HE_PHYCAP_CHANNEL_WIDTH_SET_160MHZ_IN_5G))
			return true;
	}
#endif /* CONFIG_IEEE80211AX */
	if (mode->vht_capab & (VHT_CAP_SUPP_CHAN_WIDTH_160MHZ |
			       VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ))
		return true;
	return false;
}
#endif /* CONFIG_P2P */


static void wpas_conf_ap_vht(struct wpa_supplicant *wpa_s,
			     struct wpa_ssid *ssid,
			     struct hostapd_config *conf,
			     struct hostapd_hw_modes *mode)
{
#ifdef CONFIG_P2P
	u8 center_chan = 0;
	u8 channel = conf->channel;
#endif /* CONFIG_P2P */
	u8 freq_seg_idx;

	if (!conf->secondary_channel)
		goto no_vht;

	/* Use the maximum oper channel width if it's given. */
	if (ssid->max_oper_chwidth)
		hostapd_set_oper_chwidth(conf, ssid->max_oper_chwidth);
	if (hostapd_get_oper_chwidth(conf))
		ieee80211_freq_to_channel_ext(ssid->frequency, 0,
					      hostapd_get_oper_chwidth(conf),
					      &conf->op_class,
					      &conf->channel);

	if (hostapd_get_oper_chwidth(conf) == CONF_OPER_CHWIDTH_80P80MHZ) {
		ieee80211_freq_to_chan(ssid->vht_center_freq2,
				       &freq_seg_idx);
		hostapd_set_oper_centr_freq_seg1_idx(conf, freq_seg_idx);
	}

	if (!ssid->p2p_group) {
		if (!ssid->vht_center_freq1)
			goto no_vht;
		ieee80211_freq_to_chan(ssid->vht_center_freq1,
				       &freq_seg_idx);
		hostapd_set_oper_centr_freq_seg0_idx(conf, freq_seg_idx);

		wpa_printf(MSG_DEBUG,
			   "VHT seg0 index %d and seg1 index %d for AP",
			   hostapd_get_oper_centr_freq_seg0_idx(conf),
			   hostapd_get_oper_centr_freq_seg1_idx(conf));
		return;
	}

#ifdef CONFIG_P2P
	switch (hostapd_get_oper_chwidth(conf)) {
	case CONF_OPER_CHWIDTH_80MHZ:
	case CONF_OPER_CHWIDTH_80P80MHZ:
		center_chan = wpas_p2p_get_vht80_center(wpa_s, mode, channel,
							conf->op_class);
		wpa_printf(MSG_DEBUG,
			   "VHT center channel %u for 80 or 80+80 MHz bandwidth",
			   center_chan);
		break;
	case CONF_OPER_CHWIDTH_160MHZ:
		center_chan = wpas_p2p_get_vht160_center(wpa_s, mode, channel,
							 conf->op_class);
		wpa_printf(MSG_DEBUG,
			   "VHT center channel %u for 160 MHz bandwidth",
			   center_chan);
		break;
	default:
		/*
		 * conf->vht_oper_chwidth might not be set for non-P2P GO cases,
		 * try oper_cwidth 160 MHz first then VHT 80 MHz, if 160 MHz is
		 * not supported.
		 */
		hostapd_set_oper_chwidth(conf, CONF_OPER_CHWIDTH_160MHZ);
		ieee80211_freq_to_channel_ext(ssid->frequency, 0,
					      conf->vht_oper_chwidth,
					      &conf->op_class,
					      &conf->channel);
		center_chan = wpas_p2p_get_vht160_center(wpa_s, mode, channel,
							 conf->op_class);
		if (center_chan && is_chanwidth160_supported(mode, conf)) {
			wpa_printf(MSG_DEBUG,
				   "VHT center channel %u for auto-selected 160 MHz bandwidth",
				   center_chan);
		} else {
			hostapd_set_oper_chwidth(conf, CONF_OPER_CHWIDTH_80MHZ);
			ieee80211_freq_to_channel_ext(ssid->frequency, 0,
						      conf->vht_oper_chwidth,
						      &conf->op_class,
						      &conf->channel);
			center_chan = wpas_p2p_get_vht80_center(wpa_s, mode,
								channel,
								conf->op_class);
			wpa_printf(MSG_DEBUG,
				   "VHT center channel %u for auto-selected 80 MHz bandwidth",
				   center_chan);
		}
		break;
	}
	if (!center_chan)
		goto no_vht;

	hostapd_set_oper_centr_freq_seg0_idx(conf, center_chan);
	wpa_printf(MSG_DEBUG, "VHT seg0 index %d for P2P GO",
		   hostapd_get_oper_centr_freq_seg0_idx(conf));
	return;
#endif /* CONFIG_P2P */

no_vht:
	wpa_printf(MSG_DEBUG,
		   "No VHT higher bandwidth support for the selected channel %d",
		   conf->channel);
	hostapd_set_oper_centr_freq_seg0_idx(
		conf, conf->channel + conf->secondary_channel * 2);
	hostapd_set_oper_chwidth(conf, CONF_OPER_CHWIDTH_USE_HT);
	ieee80211_freq_to_channel_ext(ssid->frequency, 0,
				      conf->vht_oper_chwidth,
				      &conf->op_class, &conf->channel);
}


static struct hostapd_hw_modes *
wpa_supplicant_find_hw_mode(struct wpa_supplicant *wpa_s,
			    enum hostapd_hw_mode hw_mode)
{
	struct hostapd_hw_modes *mode = NULL;
	int i;

	for (i = 0; i < wpa_s->hw.num_modes; i++) {
		if (wpa_s->hw.modes[i].mode == hw_mode) {
			mode = &wpa_s->hw.modes[i];
			break;
		}
	}

	return mode;
}


#ifdef CONFIG_P2P

static int get_max_oper_chwidth_6ghz(int chwidth)
{
	switch (chwidth) {
	case CONF_OPER_CHWIDTH_USE_HT:
		return 20;
	case CONF_OPER_CHWIDTH_40MHZ_6GHZ:
		return 40;
	case CONF_OPER_CHWIDTH_80MHZ:
		return 80;
	case CONF_OPER_CHWIDTH_80P80MHZ:
	case CONF_OPER_CHWIDTH_160MHZ:
		return 160;
	default:
		return 0;
	}
}


static void wpas_conf_ap_he_6ghz(struct wpa_supplicant *wpa_s,
				 struct hostapd_hw_modes *mode,
				 struct wpa_ssid *ssid,
				 struct hostapd_config *conf)
{
	bool is_chanwidth_40_80, is_chanwidth_160;
	int he_chanwidth;

	he_chanwidth =
		mode->he_capab[wpas_mode_to_ieee80211_mode(
			ssid->mode)].phy_cap[HE_PHYCAP_CHANNEL_WIDTH_SET_IDX];
	is_chanwidth_40_80 = he_chanwidth &
		HE_PHYCAP_CHANNEL_WIDTH_SET_40MHZ_80MHZ_IN_5G;
	is_chanwidth_160 = he_chanwidth &
		HE_PHYCAP_CHANNEL_WIDTH_SET_160MHZ_IN_5G;

	wpa_printf(MSG_DEBUG,
		   "Enable HE support (p2p_group=%d he_chwidth_cap=%d)",
		   ssid->p2p_group, he_chanwidth);

	if (mode->he_capab[wpas_mode_to_ieee80211_mode(
			    ssid->mode)].he_supported &&
	    ssid->he)
		conf->ieee80211ax = 1;

	if (is_chanwidth_40_80 && ssid->p2p_group &&
	    get_max_oper_chwidth_6ghz(ssid->max_oper_chwidth) >= 40) {
		conf->secondary_channel =
			wpas_p2p_get_sec_channel_offset_40mhz(
				wpa_s, mode, conf->channel);
		wpa_printf(MSG_DEBUG,
			   "Secondary channel offset %d for P2P group",
			   conf->secondary_channel);
		if (ssid->max_oper_chwidth == CONF_OPER_CHWIDTH_40MHZ_6GHZ)
			ssid->max_oper_chwidth = CONF_OPER_CHWIDTH_USE_HT;
	}

	if ((is_chanwidth_40_80 || is_chanwidth_160) && ssid->p2p_group &&
	    get_max_oper_chwidth_6ghz(ssid->max_oper_chwidth) >= 80)
		wpas_conf_ap_vht(wpa_s, ssid, conf, mode);
}

#endif /* CONFIG_P2P */


int wpa_supplicant_conf_ap_ht(struct wpa_supplicant *wpa_s,
			      struct wpa_ssid *ssid,
			      struct hostapd_config *conf)
{
	conf->hw_mode = ieee80211_freq_to_channel_ext(ssid->frequency, 0,
						      CONF_OPER_CHWIDTH_USE_HT,
						      &conf->op_class,
						      &conf->channel);
	if (conf->hw_mode == NUM_HOSTAPD_MODES) {
		wpa_printf(MSG_ERROR, "Unsupported AP mode frequency: %d MHz",
			   ssid->frequency);
		return -1;
	}

	/*
	 * Enable HT20 if the driver supports it, by setting conf->ieee80211n
	 * and a mask of allowed capabilities within conf->ht_capab.
	 * Using default config settings for: conf->ht_op_mode_fixed,
	 * conf->secondary_channel, conf->require_ht
	 */
	if (wpa_s->hw.modes) {
		struct hostapd_hw_modes *mode = NULL;
		int no_ht = 0;

		wpa_printf(MSG_DEBUG,
			   "Determining HT/VHT options based on driver capabilities (freq=%u chan=%u)",
			   ssid->frequency, conf->channel);

		mode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes,
				conf->hw_mode, is_6ghz_freq(ssid->frequency));

		/* May drop to IEEE 802.11b if the driver does not support IEEE
		 * 802.11g */
		if (!mode && conf->hw_mode == HOSTAPD_MODE_IEEE80211G) {
			conf->hw_mode = HOSTAPD_MODE_IEEE80211B;
			wpa_printf(MSG_INFO,
				   "Try downgrade to IEEE 802.11b as 802.11g is not supported by the current hardware");
			mode = wpa_supplicant_find_hw_mode(wpa_s,
							   conf->hw_mode);
		}

		if (!mode) {
			wpa_printf(MSG_ERROR,
				   "No match between requested and supported hw modes found");
			return -1;
		}

#ifdef CONFIG_HT_OVERRIDES
		if (ssid->disable_ht)
			ssid->ht = 0;
		if (ssid->disable_ht40)
			ssid->ht40 = 0;
#endif /* CONFIG_HT_OVERRIDES */

#ifdef CONFIG_VHT_OVERRIDES
		if (ssid->disable_vht)
			ssid->vht = 0;
#endif /* CONFIG_VHT_OVERRIDES */

#ifdef CONFIG_HE_OVERRIDES
		if (ssid->disable_he)
			ssid->he = 0;
#endif /* CONFIG_HE_OVERRIDES */

		if (!ssid->ht) {
			wpa_printf(MSG_DEBUG,
				   "HT not enabled in network profile");
			conf->ieee80211n = 0;
			conf->ht_capab = 0;
			no_ht = 1;
		}

		if (mode && is_6ghz_freq(ssid->frequency) &&
		    conf->hw_mode == HOSTAPD_MODE_IEEE80211A) {
			if (mode->eht_capab[wpas_mode_to_ieee80211_mode(
					    ssid->mode)].eht_supported &&
			    ssid->eht)
				conf->ieee80211be = 1;

			if (mode->he_capab[wpas_mode_to_ieee80211_mode(
					    ssid->mode)].he_supported &&
			    ssid->he)
				conf->ieee80211ax = 1;

#ifdef CONFIG_P2P
			wpas_conf_ap_he_6ghz(wpa_s, mode, ssid, conf);
#endif /* CONFIG_P2P */
		} else if (!no_ht && mode && mode->ht_capab) {
			wpa_printf(MSG_DEBUG,
				   "Enable HT support (p2p_group=%d 11a=%d ht40_hw_capab=%d ssid->ht40=%d)",
				   ssid->p2p_group,
				   conf->hw_mode == HOSTAPD_MODE_IEEE80211A,
				   !!(mode->ht_capab &
				      HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET),
				   ssid->ht40);
			conf->ieee80211n = 1;

			if (ssid->ht40 &&
			    (mode->ht_capab &
			     HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET))
				conf->secondary_channel = ssid->ht40;
			else
				conf->secondary_channel = 0;

#ifdef CONFIG_P2P
			if (ssid->p2p_group &&
			    conf->hw_mode == HOSTAPD_MODE_IEEE80211A &&
			    (mode->ht_capab &
			     HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET) &&
			    ssid->ht40) {
				conf->secondary_channel =
					wpas_p2p_get_sec_channel_offset_40mhz(
						wpa_s, mode, conf->channel);
				wpa_printf(MSG_DEBUG,
					   "HT secondary channel offset %d for P2P group",
					   conf->secondary_channel);
			} else if (ssid->p2p_group && conf->secondary_channel &&
				   conf->hw_mode != HOSTAPD_MODE_IEEE80211A) {
				/* This ended up trying to configure invalid
				 * 2.4 GHz channels (e.g., HT40+ on channel 11)
				 * in some cases, so clear the secondary channel
				 * configuration now to avoid such cases that
				 * would lead to group formation failures. */
				wpa_printf(MSG_DEBUG,
					   "Disable HT secondary channel for P2P group on 2.4 GHz");
				conf->secondary_channel = 0;
			}
#endif /* CONFIG_P2P */

			if (!ssid->p2p_group &&
			    (mode->ht_capab &
			     HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET)) {
				conf->secondary_channel = ssid->ht40;
				wpa_printf(MSG_DEBUG,
					   "HT secondary channel offset %d for AP",
					   conf->secondary_channel);
			}

			if (conf->secondary_channel)
				conf->ht_capab |=
					HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET;

			/*
			 * include capabilities that won't cause issues
			 * to connecting stations, while leaving the current
			 * capabilities intact (currently disabled SMPS).
			 */
			conf->ht_capab |= mode->ht_capab &
				(HT_CAP_INFO_GREEN_FIELD |
				 HT_CAP_INFO_SHORT_GI20MHZ |
				 HT_CAP_INFO_SHORT_GI40MHZ |
				 HT_CAP_INFO_RX_STBC_MASK |
				 HT_CAP_INFO_TX_STBC |
				 HT_CAP_INFO_MAX_AMSDU_SIZE);

			/* check this before VHT, because setting oper chan
			 * width and friends is the same call for HE and VHT
			 * and checks if conf->ieee8021ax == 1 */
			if (mode->eht_capab[wpas_mode_to_ieee80211_mode(
					    ssid->mode)].eht_supported &&
			    ssid->eht)
				conf->ieee80211be = 1;

			if (mode->he_capab[wpas_mode_to_ieee80211_mode(
					    ssid->mode)].he_supported &&
			    ssid->he)
				conf->ieee80211ax = 1;

			if (mode->vht_capab && ssid->vht) {
				conf->ieee80211ac = 1;
				conf->vht_capab |= mode->vht_capab;
				wpas_conf_ap_vht(wpa_s, ssid, conf, mode);
			}
		}
	}

	if (wpa_s->p2p_go_no_pri_sec_switch) {
		conf->no_pri_sec_switch = 1;
	} else if (conf->secondary_channel) {
		struct wpa_supplicant *iface;

		for (iface = wpa_s->global->ifaces; iface; iface = iface->next)
		{
			if (iface == wpa_s ||
			    iface->wpa_state < WPA_AUTHENTICATING ||
			    (int) iface->assoc_freq != ssid->frequency)
				continue;

			/*
			 * Do not allow 40 MHz co-ex PRI/SEC switch to force us
			 * to change our PRI channel since we have an existing,
			 * concurrent connection on that channel and doing
			 * multi-channel concurrency is likely to cause more
			 * harm than using different PRI/SEC selection in
			 * environment with multiple BSSes on these two channels
			 * with mixed 20 MHz or PRI channel selection.
			 */
			conf->no_pri_sec_switch = 1;
		}
	}

	return 0;
}


static int wpa_supplicant_conf_ap(struct wpa_supplicant *wpa_s,
				  struct wpa_ssid *ssid,
				  struct hostapd_config *conf)
{
	struct hostapd_bss_config *bss = conf->bss[0];

	conf->driver = wpa_s->driver;

	os_strlcpy(bss->iface, wpa_s->ifname, sizeof(bss->iface));

	if (wpa_supplicant_conf_ap_ht(wpa_s, ssid, conf))
		return -1;

	if (ssid->pbss > 1) {
		wpa_printf(MSG_ERROR, "Invalid pbss value(%d) for AP mode",
			   ssid->pbss);
		return -1;
	}
	bss->pbss = ssid->pbss;

#ifdef CONFIG_ACS
	if (ssid->acs) {
		/* Setting channel to 0 in order to enable ACS */
		conf->channel = 0;
		wpa_printf(MSG_DEBUG, "Use automatic channel selection");
	}
#endif /* CONFIG_ACS */

	if (ieee80211_is_dfs(ssid->frequency, wpa_s->hw.modes,
			     wpa_s->hw.num_modes) && wpa_s->conf->country[0]) {
		conf->ieee80211h = 1;
		conf->ieee80211d = 1;
		conf->country[0] = wpa_s->conf->country[0];
		conf->country[1] = wpa_s->conf->country[1];
		conf->country[2] = ' ';
	}

#ifdef CONFIG_P2P
	if (conf->hw_mode == HOSTAPD_MODE_IEEE80211G &&
	    (ssid->mode == WPAS_MODE_P2P_GO ||
	     ssid->mode == WPAS_MODE_P2P_GROUP_FORMATION)) {
		/* Remove 802.11b rates from supported and basic rate sets */
		int *list = os_malloc(4 * sizeof(int));
		if (list) {
			list[0] = 60;
			list[1] = 120;
			list[2] = 240;
			list[3] = -1;
		}
		conf->basic_rates = list;

		list = os_malloc(9 * sizeof(int));
		if (list) {
			list[0] = 60;
			list[1] = 90;
			list[2] = 120;
			list[3] = 180;
			list[4] = 240;
			list[5] = 360;
			list[6] = 480;
			list[7] = 540;
			list[8] = -1;
		}
		conf->supported_rates = list;
	}

#ifdef CONFIG_IEEE80211AX
	if (ssid->mode == WPAS_MODE_P2P_GO ||
	    ssid->mode == WPAS_MODE_P2P_GROUP_FORMATION)
		conf->ieee80211ax = ssid->he;
#endif /* CONFIG_IEEE80211AX */

	bss->isolate = !wpa_s->conf->p2p_intra_bss;
	bss->extended_key_id = wpa_s->conf->extended_key_id;
	bss->force_per_enrollee_psk = wpa_s->global->p2p_per_sta_psk;
	bss->wpa_deny_ptk0_rekey = ssid->wpa_deny_ptk0_rekey;

	if (ssid->p2p_group) {
		os_memcpy(bss->ip_addr_go, wpa_s->p2pdev->conf->ip_addr_go, 4);
		os_memcpy(bss->ip_addr_mask, wpa_s->p2pdev->conf->ip_addr_mask,
			  4);
		os_memcpy(bss->ip_addr_start,
			  wpa_s->p2pdev->conf->ip_addr_start, 4);
		os_memcpy(bss->ip_addr_end, wpa_s->p2pdev->conf->ip_addr_end,
			  4);
	}
#endif /* CONFIG_P2P */

	if (ssid->ssid_len == 0) {
		wpa_printf(MSG_ERROR, "No SSID configured for AP mode");
		return -1;
	}
	os_memcpy(bss->ssid.ssid, ssid->ssid, ssid->ssid_len);
	bss->ssid.ssid_len = ssid->ssid_len;
	bss->ssid.ssid_set = 1;

	bss->ignore_broadcast_ssid = ssid->ignore_broadcast_ssid;

	if (ssid->auth_alg)
		bss->auth_algs = ssid->auth_alg;

	if (wpa_key_mgmt_wpa_psk(ssid->key_mgmt))
		bss->wpa = ssid->proto;
	if (ssid->key_mgmt == DEFAULT_KEY_MGMT)
		bss->wpa_key_mgmt = WPA_KEY_MGMT_PSK;
	else
		bss->wpa_key_mgmt = ssid->key_mgmt;
	bss->wpa_pairwise = ssid->pairwise_cipher;
	if (wpa_key_mgmt_sae(bss->wpa_key_mgmt) && ssid->passphrase) {
		bss->ssid.wpa_passphrase = os_strdup(ssid->passphrase);
	} else if (ssid->psk_set) {
		bin_clear_free(bss->ssid.wpa_psk, sizeof(*bss->ssid.wpa_psk));
		bss->ssid.wpa_psk = os_zalloc(sizeof(struct hostapd_wpa_psk));
		if (bss->ssid.wpa_psk == NULL)
			return -1;
		os_memcpy(bss->ssid.wpa_psk->psk, ssid->psk, PMK_LEN);
		bss->ssid.wpa_psk->group = 1;
		bss->ssid.wpa_psk_set = 1;
	} else if (ssid->passphrase) {
		bss->ssid.wpa_passphrase = os_strdup(ssid->passphrase);
#ifdef CONFIG_WEP
	} else if (ssid->wep_key_len[0] || ssid->wep_key_len[1] ||
		   ssid->wep_key_len[2] || ssid->wep_key_len[3]) {
		struct hostapd_wep_keys *wep = &bss->ssid.wep;
		int i;
		for (i = 0; i < NUM_WEP_KEYS; i++) {
			if (ssid->wep_key_len[i] == 0)
				continue;
			wep->key[i] = os_memdup(ssid->wep_key[i],
						ssid->wep_key_len[i]);
			if (wep->key[i] == NULL)
				return -1;
			wep->len[i] = ssid->wep_key_len[i];
		}
		wep->idx = ssid->wep_tx_keyidx;
		wep->keys_set = 1;
#endif /* CONFIG_WEP */
	}
#ifdef CONFIG_SAE
	if (ssid->sae_password) {
		struct sae_password_entry *pw;

		pw = os_zalloc(sizeof(*pw));
		if (!pw)
			return -1;
		os_memset(pw->peer_addr, 0xff, ETH_ALEN);
		pw->password = os_strdup(ssid->sae_password);
		if (!pw->password) {
			os_free(pw);
			return -1;
		}
		if (ssid->sae_password_id) {
			pw->identifier = os_strdup(ssid->sae_password_id);
			if (!pw->identifier) {
				str_clear_free(pw->password);
				os_free(pw);
				return -1;
			}
		}

		pw->next = bss->sae_passwords;
		bss->sae_passwords = pw;
	}

	if (ssid->sae_pwe != DEFAULT_SAE_PWE)
		bss->sae_pwe = ssid->sae_pwe;
	else
		bss->sae_pwe = wpa_s->conf->sae_pwe;
#endif /* CONFIG_SAE */

	if (wpa_s->conf->go_interworking) {
		wpa_printf(MSG_DEBUG,
			   "P2P: Enable Interworking with access_network_type: %d",
			   wpa_s->conf->go_access_network_type);
		bss->interworking = wpa_s->conf->go_interworking;
		bss->access_network_type = wpa_s->conf->go_access_network_type;
		bss->internet = wpa_s->conf->go_internet;
		if (wpa_s->conf->go_venue_group) {
			wpa_printf(MSG_DEBUG,
				   "P2P: Venue group: %d  Venue type: %d",
				   wpa_s->conf->go_venue_group,
				   wpa_s->conf->go_venue_type);
			bss->venue_group = wpa_s->conf->go_venue_group;
			bss->venue_type = wpa_s->conf->go_venue_type;
			bss->venue_info_set = 1;
		}
	}

	if (ssid->ap_max_inactivity)
		bss->ap_max_inactivity = ssid->ap_max_inactivity;

	if (ssid->dtim_period)
		bss->dtim_period = ssid->dtim_period;
	else if (wpa_s->conf->dtim_period)
		bss->dtim_period = wpa_s->conf->dtim_period;

	if (ssid->beacon_int)
		conf->beacon_int = ssid->beacon_int;
	else if (wpa_s->conf->beacon_int)
		conf->beacon_int = wpa_s->conf->beacon_int;

#ifdef CONFIG_P2P
	if (ssid->mode == WPAS_MODE_P2P_GO ||
	    ssid->mode == WPAS_MODE_P2P_GROUP_FORMATION) {
		if (wpa_s->conf->p2p_go_ctwindow > conf->beacon_int) {
			wpa_printf(MSG_INFO,
				   "CTWindow (%d) is bigger than beacon interval (%d) - avoid configuring it",
				   wpa_s->conf->p2p_go_ctwindow,
				   conf->beacon_int);
			conf->p2p_go_ctwindow = 0;
		} else {
			conf->p2p_go_ctwindow = wpa_s->conf->p2p_go_ctwindow;
		}
	}
#endif /* CONFIG_P2P */

	if ((bss->wpa & 2) && bss->rsn_pairwise == 0)
		bss->rsn_pairwise = bss->wpa_pairwise;
	bss->wpa_group = wpa_select_ap_group_cipher(bss->wpa, bss->wpa_pairwise,
						    bss->rsn_pairwise);

	if (bss->wpa && bss->ieee802_1x) {
		bss->ssid.security_policy = SECURITY_WPA;
	} else if (bss->wpa) {
		bss->ssid.security_policy = SECURITY_WPA_PSK;
#ifdef CONFIG_WEP
	} else if (bss->ieee802_1x) {
		int cipher = WPA_CIPHER_NONE;
		bss->ssid.security_policy = SECURITY_IEEE_802_1X;
		bss->ssid.wep.default_len = bss->default_wep_key_len;
		if (bss->default_wep_key_len)
			cipher = bss->default_wep_key_len >= 13 ?
				WPA_CIPHER_WEP104 : WPA_CIPHER_WEP40;
		bss->wpa_group = cipher;
		bss->wpa_pairwise = cipher;
		bss->rsn_pairwise = cipher;
	} else if (bss->ssid.wep.keys_set) {
		int cipher = WPA_CIPHER_WEP40;
		if (bss->ssid.wep.len[0] >= 13)
			cipher = WPA_CIPHER_WEP104;
		bss->ssid.security_policy = SECURITY_STATIC_WEP;
		bss->wpa_group = cipher;
		bss->wpa_pairwise = cipher;
		bss->rsn_pairwise = cipher;
#endif /* CONFIG_WEP */
	} else {
		bss->ssid.security_policy = SECURITY_PLAINTEXT;
		bss->wpa_group = WPA_CIPHER_NONE;
		bss->wpa_pairwise = WPA_CIPHER_NONE;
		bss->rsn_pairwise = WPA_CIPHER_NONE;
	}

	if (bss->wpa_group_rekey < 86400 && (bss->wpa & 2) &&
	    (bss->wpa_group == WPA_CIPHER_CCMP ||
	     bss->wpa_group == WPA_CIPHER_GCMP ||
	     bss->wpa_group == WPA_CIPHER_CCMP_256 ||
	     bss->wpa_group == WPA_CIPHER_GCMP_256)) {
		/*
		 * Strong ciphers do not need frequent rekeying, so increase
		 * the default GTK rekeying period to 24 hours.
		 */
		bss->wpa_group_rekey = 86400;
	}

	if (ssid->ieee80211w != MGMT_FRAME_PROTECTION_DEFAULT) {
		bss->ieee80211w = ssid->ieee80211w;
	} else if (wpa_s->conf->pmf != MGMT_FRAME_PROTECTION_DEFAULT) {
		if (ssid->mode == WPAS_MODE_AP)
			bss->ieee80211w = wpa_s->conf->pmf;
	}

#ifdef CONFIG_OCV
	bss->ocv = ssid->ocv;
#endif /* CONFIG_OCV */

#ifdef CONFIG_WPS
	/*
	 * Enable WPS by default for open and WPA/WPA2-Personal network, but
	 * require user interaction to actually use it. Only the internal
	 * Registrar is supported.
	 */
	if (bss->ssid.security_policy != SECURITY_WPA_PSK &&
	    bss->ssid.security_policy != SECURITY_PLAINTEXT)
		goto no_wps;
	if (bss->ssid.security_policy == SECURITY_WPA_PSK &&
	    (!(bss->rsn_pairwise & (WPA_CIPHER_CCMP | WPA_CIPHER_GCMP)) ||
	     !(bss->wpa & 2)))
		goto no_wps; /* WPS2 does not allow WPA/TKIP-only
			      * configuration */
	if (ssid->wps_disabled)
		goto no_wps;
	bss->eap_server = 1;

	if (!ssid->ignore_broadcast_ssid)
		bss->wps_state = 2;

	bss->ap_setup_locked = 2;
	if (wpa_s->conf->config_methods)
		bss->config_methods = os_strdup(wpa_s->conf->config_methods);
	os_memcpy(bss->device_type, wpa_s->conf->device_type,
		  WPS_DEV_TYPE_LEN);
	if (wpa_s->conf->device_name) {
		bss->device_name = os_strdup(wpa_s->conf->device_name);
		bss->friendly_name = os_strdup(wpa_s->conf->device_name);
	}
	if (wpa_s->conf->manufacturer)
		bss->manufacturer = os_strdup(wpa_s->conf->manufacturer);
	if (wpa_s->conf->model_name)
		bss->model_name = os_strdup(wpa_s->conf->model_name);
	if (wpa_s->conf->model_number)
		bss->model_number = os_strdup(wpa_s->conf->model_number);
	if (wpa_s->conf->serial_number)
		bss->serial_number = os_strdup(wpa_s->conf->serial_number);
	if (is_nil_uuid(wpa_s->conf->uuid))
		os_memcpy(bss->uuid, wpa_s->wps->uuid, WPS_UUID_LEN);
	else
		os_memcpy(bss->uuid, wpa_s->conf->uuid, WPS_UUID_LEN);
	os_memcpy(bss->os_version, wpa_s->conf->os_version, 4);
	bss->pbc_in_m1 = wpa_s->conf->pbc_in_m1;
	if (ssid->eap.fragment_size != DEFAULT_FRAGMENT_SIZE)
		bss->fragment_size = ssid->eap.fragment_size;
no_wps:
#endif /* CONFIG_WPS */

	if (wpa_s->max_stations &&
	    wpa_s->max_stations < wpa_s->conf->max_num_sta)
		bss->max_num_sta = wpa_s->max_stations;
	else
		bss->max_num_sta = wpa_s->conf->max_num_sta;

	if (!bss->isolate)
		bss->isolate = wpa_s->conf->ap_isolate;

	bss->disassoc_low_ack = wpa_s->conf->disassoc_low_ack;

	if (wpa_s->conf->ap_vendor_elements) {
		bss->vendor_elements =
			wpabuf_dup(wpa_s->conf->ap_vendor_elements);
	}
	if (wpa_s->conf->ap_assocresp_elements) {
		bss->assocresp_elements =
			wpabuf_dup(wpa_s->conf->ap_assocresp_elements);
	}

	bss->ftm_responder = wpa_s->conf->ftm_responder;
	bss->ftm_initiator = wpa_s->conf->ftm_initiator;

	bss->transition_disable = ssid->transition_disable;

	return 0;
}


static void ap_public_action_rx(void *ctx, const u8 *buf, size_t len, int freq)
{
#ifdef CONFIG_P2P
	struct wpa_supplicant *wpa_s = ctx;
	const struct ieee80211_mgmt *mgmt;

	mgmt = (const struct ieee80211_mgmt *) buf;
	if (len < IEEE80211_HDRLEN + 1)
		return;
	if (mgmt->u.action.category != WLAN_ACTION_PUBLIC)
		return;
	wpas_p2p_rx_action(wpa_s, mgmt->da, mgmt->sa, mgmt->bssid,
			   mgmt->u.action.category,
			   buf + IEEE80211_HDRLEN + 1,
			   len - IEEE80211_HDRLEN - 1, freq);
#endif /* CONFIG_P2P */
}


static void ap_wps_event_cb(void *ctx, enum wps_event event,
			    union wps_event_data *data)
{
#ifdef CONFIG_P2P
	struct wpa_supplicant *wpa_s = ctx;

	if (event == WPS_EV_FAIL) {
		struct wps_event_fail *fail = &data->fail;

		if (wpa_s->p2pdev && wpa_s->p2pdev != wpa_s &&
		    wpa_s == wpa_s->global->p2p_group_formation) {
			/*
			 * src/ap/wps_hostapd.c has already sent this on the
			 * main interface, so only send on the parent interface
			 * here if needed.
			 */
			wpa_msg(wpa_s->p2pdev, MSG_INFO, WPS_EVENT_FAIL
				"msg=%d config_error=%d",
				fail->msg, fail->config_error);
		}
		wpas_p2p_wps_failed(wpa_s, fail);
	}
#endif /* CONFIG_P2P */
}


static void ap_sta_authorized_cb(void *ctx, const u8 *mac_addr,
				 int authorized, const u8 *p2p_dev_addr, const u8 *ip)
{
	wpas_notify_sta_authorized(ctx, mac_addr, authorized, p2p_dev_addr, ip);
}


#ifdef CONFIG_P2P
static void ap_new_psk_cb(void *ctx, const u8 *mac_addr, const u8 *p2p_dev_addr,
			  const u8 *psk, size_t psk_len)
{

	struct wpa_supplicant *wpa_s = ctx;
	if (wpa_s->ap_iface == NULL || wpa_s->current_ssid == NULL)
		return;
	wpas_p2p_new_psk_cb(wpa_s, mac_addr, p2p_dev_addr, psk, psk_len);
}
#endif /* CONFIG_P2P */


static int ap_vendor_action_rx(void *ctx, const u8 *buf, size_t len, int freq)
{
#ifdef CONFIG_P2P
	struct wpa_supplicant *wpa_s = ctx;
	const struct ieee80211_mgmt *mgmt;

	mgmt = (const struct ieee80211_mgmt *) buf;
	if (len < IEEE80211_HDRLEN + 1)
		return -1;
	wpas_p2p_rx_action(wpa_s, mgmt->da, mgmt->sa, mgmt->bssid,
			   mgmt->u.action.category,
			   buf + IEEE80211_HDRLEN + 1,
			   len - IEEE80211_HDRLEN - 1, freq);
#endif /* CONFIG_P2P */
	return 0;
}


static int ap_probe_req_rx(void *ctx, const u8 *sa, const u8 *da,
			   const u8 *bssid, const u8 *ie, size_t ie_len,
			   int ssi_signal)
{
	struct wpa_supplicant *wpa_s = ctx;
	unsigned int freq = 0;

	if (wpa_s->ap_iface)
		freq = wpa_s->ap_iface->freq;

	return wpas_p2p_probe_req_rx(wpa_s, sa, da, bssid, ie, ie_len,
				     freq, ssi_signal);
}


static void ap_wps_reg_success_cb(void *ctx, const u8 *mac_addr,
				  const u8 *uuid_e)
{
	struct wpa_supplicant *wpa_s = ctx;
	wpas_p2p_wps_success(wpa_s, mac_addr, 1);
}


static void wpas_ap_configured_cb(void *ctx)
{
	struct wpa_supplicant *wpa_s = ctx;

	wpa_printf(MSG_DEBUG, "AP interface setup completed - state %s",
		   hostapd_state_text(wpa_s->ap_iface->state));
	if (wpa_s->ap_iface->state == HAPD_IFACE_DISABLED) {
		wpa_supplicant_ap_deinit(wpa_s);
		return;
	}

	if (wpa_s->current_ssid) {
		int acs = 0;

#ifdef CONFIG_ACS
		acs = wpa_s->current_ssid->acs;
#endif /* CONFIG_ACS */
		if (acs || (wpa_s->assoc_freq && wpa_s->ap_iface->freq &&
			    (int) wpa_s->assoc_freq != wpa_s->ap_iface->freq)) {
			wpa_s->assoc_freq = wpa_s->ap_iface->freq;
			wpa_s->current_ssid->frequency = wpa_s->ap_iface->freq;
		}
	}

	wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);

	if (wpa_s->ap_configured_cb)
		wpa_s->ap_configured_cb(wpa_s->ap_configured_cb_ctx,
					wpa_s->ap_configured_cb_data);
}


int wpa_supplicant_create_ap(struct wpa_supplicant *wpa_s,
			     struct wpa_ssid *ssid)
{
	struct wpa_driver_associate_params params;
	struct hostapd_iface *hapd_iface;
	struct hostapd_config *conf;
	size_t i;

	if (ssid->ssid == NULL || ssid->ssid_len == 0) {
		wpa_printf(MSG_ERROR, "No SSID configured for AP mode");
		return -1;
	}

	wpa_supplicant_ap_deinit(wpa_s);

	wpa_printf(MSG_DEBUG, "Setting up AP (SSID='%s')",
		   wpa_ssid_txt(ssid->ssid, ssid->ssid_len));

	os_memset(&params, 0, sizeof(params));
	params.ssid = ssid->ssid;
	params.ssid_len = ssid->ssid_len;
	switch (ssid->mode) {
	case WPAS_MODE_AP:
	case WPAS_MODE_P2P_GO:
	case WPAS_MODE_P2P_GROUP_FORMATION:
		params.mode = IEEE80211_MODE_AP;
		break;
	default:
		return -1;
	}
	if (ssid->frequency == 0)
		ssid->frequency = 2462; /* default channel 11 */
	params.freq.freq = ssid->frequency;

	if ((ssid->mode == WPAS_MODE_AP || ssid->mode == WPAS_MODE_P2P_GO) &&
	    ssid->enable_edmg) {
		u8 primary_channel;

		if (ieee80211_freq_to_chan(ssid->frequency, &primary_channel) ==
		    NUM_HOSTAPD_MODES) {
			wpa_printf(MSG_WARNING,
				   "EDMG: Failed to get the primary channel");
			return -1;
		}

		hostapd_encode_edmg_chan(ssid->enable_edmg, ssid->edmg_channel,
					 primary_channel, &params.freq.edmg);
	}

	params.wpa_proto = ssid->proto;
	if (ssid->key_mgmt & WPA_KEY_MGMT_PSK)
		wpa_s->key_mgmt = WPA_KEY_MGMT_PSK;
	else if (ssid->key_mgmt & WPA_KEY_MGMT_SAE)
		wpa_s->key_mgmt = WPA_KEY_MGMT_SAE;
	else
		wpa_s->key_mgmt = WPA_KEY_MGMT_NONE;
	params.key_mgmt_suite = wpa_s->key_mgmt;

	wpa_s->pairwise_cipher = wpa_pick_pairwise_cipher(ssid->pairwise_cipher,
							  1);
	if (wpa_s->pairwise_cipher < 0) {
		wpa_printf(MSG_WARNING, "WPA: Failed to select pairwise "
			   "cipher.");
		return -1;
	}
	params.pairwise_suite = wpa_s->pairwise_cipher;
	params.group_suite = params.pairwise_suite;

#ifdef CONFIG_P2P
	if (ssid->mode == WPAS_MODE_P2P_GO ||
	    ssid->mode == WPAS_MODE_P2P_GROUP_FORMATION)
		params.p2p = 1;
#endif /* CONFIG_P2P */

	if (wpa_s->p2pdev->set_ap_uapsd)
		params.uapsd = wpa_s->p2pdev->ap_uapsd;
	else if (params.p2p && (wpa_s->drv_flags & WPA_DRIVER_FLAGS_AP_UAPSD))
		params.uapsd = 1; /* mandatory for P2P GO */
	else
		params.uapsd = -1;

	if (ieee80211_is_dfs(params.freq.freq, wpa_s->hw.modes,
			     wpa_s->hw.num_modes))
		params.freq.freq = 0; /* set channel after CAC */

	if (params.p2p)
		wpa_drv_get_ext_capa(wpa_s, WPA_IF_P2P_GO);
	else
		wpa_drv_get_ext_capa(wpa_s, WPA_IF_AP_BSS);

	if (wpa_drv_associate(wpa_s, &params) < 0) {
		wpa_msg(wpa_s, MSG_INFO, "Failed to start AP functionality");
		return -1;
	}

	wpa_s->ap_iface = hapd_iface = hostapd_alloc_iface();
	if (hapd_iface == NULL)
		return -1;
	hapd_iface->owner = wpa_s;
	hapd_iface->drv_flags = wpa_s->drv_flags;
	hapd_iface->drv_flags2 = wpa_s->drv_flags2;
	hapd_iface->probe_resp_offloads = wpa_s->probe_resp_offloads;
	hapd_iface->extended_capa = wpa_s->extended_capa;
	hapd_iface->extended_capa_mask = wpa_s->extended_capa_mask;
	hapd_iface->extended_capa_len = wpa_s->extended_capa_len;
	hapd_iface->drv_max_acl_mac_addrs = wpa_s->drv_max_acl_mac_addrs;

	wpa_s->ap_iface->conf = conf = hostapd_config_defaults();
	if (conf == NULL) {
		wpa_supplicant_ap_deinit(wpa_s);
		return -1;
	}

	os_memcpy(wpa_s->ap_iface->conf->wmm_ac_params,
		  wpa_s->conf->wmm_ac_params,
		  sizeof(wpa_s->conf->wmm_ac_params));

	os_memcpy(wpa_s->ap_iface->conf->tx_queue, wpa_s->conf->tx_queue,
		  sizeof(wpa_s->conf->tx_queue));

	if (params.uapsd > 0) {
		conf->bss[0]->wmm_enabled = 1;
		conf->bss[0]->wmm_uapsd = 1;
	}

	if (wpa_supplicant_conf_ap(wpa_s, ssid, conf)) {
		wpa_printf(MSG_ERROR, "Failed to create AP configuration");
		wpa_supplicant_ap_deinit(wpa_s);
		return -1;
	}

#ifdef CONFIG_P2P
	if (ssid->mode == WPAS_MODE_P2P_GO)
		conf->bss[0]->p2p = P2P_ENABLED | P2P_GROUP_OWNER;
	else if (ssid->mode == WPAS_MODE_P2P_GROUP_FORMATION)
		conf->bss[0]->p2p = P2P_ENABLED | P2P_GROUP_OWNER |
			P2P_GROUP_FORMATION;
#endif /* CONFIG_P2P */

	hapd_iface->num_bss = conf->num_bss;
	hapd_iface->bss = os_calloc(conf->num_bss,
				    sizeof(struct hostapd_data *));
	if (hapd_iface->bss == NULL) {
		wpa_supplicant_ap_deinit(wpa_s);
		return -1;
	}

	for (i = 0; i < conf->num_bss; i++) {
		hapd_iface->bss[i] =
			hostapd_alloc_bss_data(hapd_iface, conf,
					       conf->bss[i]);
		if (hapd_iface->bss[i] == NULL) {
			wpa_supplicant_ap_deinit(wpa_s);
			return -1;
		}

		hapd_iface->bss[i]->msg_ctx = wpa_s;
		hapd_iface->bss[i]->msg_ctx_parent = wpa_s->p2pdev;
		hapd_iface->bss[i]->public_action_cb = ap_public_action_rx;
		hapd_iface->bss[i]->public_action_cb_ctx = wpa_s;
		hapd_iface->bss[i]->vendor_action_cb = ap_vendor_action_rx;
		hapd_iface->bss[i]->vendor_action_cb_ctx = wpa_s;
		hostapd_register_probereq_cb(hapd_iface->bss[i],
					     ap_probe_req_rx, wpa_s);
		hapd_iface->bss[i]->wps_reg_success_cb = ap_wps_reg_success_cb;
		hapd_iface->bss[i]->wps_reg_success_cb_ctx = wpa_s;
		hapd_iface->bss[i]->wps_event_cb = ap_wps_event_cb;
		hapd_iface->bss[i]->wps_event_cb_ctx = wpa_s;
		hapd_iface->bss[i]->sta_authorized_cb = ap_sta_authorized_cb;
		hapd_iface->bss[i]->sta_authorized_cb_ctx = wpa_s;
#ifdef CONFIG_P2P
		hapd_iface->bss[i]->new_psk_cb = ap_new_psk_cb;
		hapd_iface->bss[i]->new_psk_cb_ctx = wpa_s;
		hapd_iface->bss[i]->p2p = wpa_s->global->p2p;
		hapd_iface->bss[i]->p2p_group = wpas_p2p_group_init(wpa_s,
								    ssid);
#endif /* CONFIG_P2P */
		hapd_iface->bss[i]->setup_complete_cb = wpas_ap_configured_cb;
		hapd_iface->bss[i]->setup_complete_cb_ctx = wpa_s;
#ifdef CONFIG_TESTING_OPTIONS
		hapd_iface->bss[i]->ext_eapol_frame_io =
			wpa_s->ext_eapol_frame_io;
#endif /* CONFIG_TESTING_OPTIONS */

#ifdef CONFIG_WNM_AP
		if (ssid->mode == WPAS_MODE_AP)
			hapd_iface->bss[i]->conf->bss_transition = 1;
#endif /* CONFIG_WNM_AP */
	}

	os_memcpy(hapd_iface->bss[0]->own_addr, wpa_s->own_addr, ETH_ALEN);
	hapd_iface->bss[0]->driver = wpa_s->driver;
	hapd_iface->bss[0]->drv_priv = wpa_s->drv_priv;

	wpa_s->current_ssid = ssid;
	eapol_sm_notify_config(wpa_s->eapol, NULL, NULL);
	os_memcpy(wpa_s->bssid, wpa_s->own_addr, ETH_ALEN);
	wpa_s->assoc_freq = ssid->frequency;
	wpa_s->ap_iface->conf->enable_edmg = ssid->enable_edmg;
	wpa_s->ap_iface->conf->edmg_channel = ssid->edmg_channel;

#if defined(CONFIG_P2P) && defined(CONFIG_ACS)
	if (wpa_s->p2p_go_do_acs) {
		wpa_s->ap_iface->conf->channel = 0;
		wpa_s->ap_iface->conf->hw_mode = wpa_s->p2p_go_acs_band;
		ssid->acs = 1;
	}
#endif /* CONFIG_P2P && CONFIG_ACS */

	if (hostapd_setup_interface(wpa_s->ap_iface)) {
		wpa_printf(MSG_ERROR, "Failed to initialize AP interface");
		wpa_supplicant_ap_deinit(wpa_s);
		return -1;
	}

	return 0;
}


void wpa_supplicant_ap_deinit(struct wpa_supplicant *wpa_s)
{
#ifdef CONFIG_WPS
	eloop_cancel_timeout(wpas_wps_ap_pin_timeout, wpa_s, NULL);
#endif /* CONFIG_WPS */

	if (wpa_s->ap_iface == NULL)
		return;

	wpa_s->current_ssid = NULL;
	eapol_sm_notify_config(wpa_s->eapol, NULL, NULL);
	wpa_s->assoc_freq = 0;
	wpas_p2p_ap_deinit(wpa_s);
	wpa_s->ap_iface->driver_ap_teardown =
		!!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_AP_TEARDOWN_SUPPORT);

	hostapd_interface_deinit(wpa_s->ap_iface);
	hostapd_interface_free(wpa_s->ap_iface);
	wpa_s->ap_iface = NULL;
	wpa_drv_deinit_ap(wpa_s);
	wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_DISCONNECTED "bssid=" MACSTR
		" reason=%d locally_generated=1",
		MAC2STR(wpa_s->own_addr), WLAN_REASON_DEAUTH_LEAVING);
}


void ap_tx_status(void *ctx, const u8 *addr,
		  const u8 *buf, size_t len, int ack)
{
#ifdef NEED_AP_MLME
	struct wpa_supplicant *wpa_s = ctx;
	hostapd_tx_status(wpa_s->ap_iface->bss[0], addr, buf, len, ack);
#endif /* NEED_AP_MLME */
}


void ap_eapol_tx_status(void *ctx, const u8 *dst,
			const u8 *data, size_t len, int ack)
{
#ifdef NEED_AP_MLME
	struct wpa_supplicant *wpa_s = ctx;
	if (!wpa_s->ap_iface)
		return;
	hostapd_tx_status(wpa_s->ap_iface->bss[0], dst, data, len, ack);
#endif /* NEED_AP_MLME */
}


void ap_client_poll_ok(void *ctx, const u8 *addr)
{
#ifdef NEED_AP_MLME
	struct wpa_supplicant *wpa_s = ctx;
	if (wpa_s->ap_iface)
		hostapd_client_poll_ok(wpa_s->ap_iface->bss[0], addr);
#endif /* NEED_AP_MLME */
}


void ap_rx_from_unknown_sta(void *ctx, const u8 *addr, int wds)
{
#ifdef NEED_AP_MLME
	struct wpa_supplicant *wpa_s = ctx;
	ieee802_11_rx_from_unknown(wpa_s->ap_iface->bss[0], addr, wds);
#endif /* NEED_AP_MLME */
}


void ap_mgmt_rx(void *ctx, struct rx_mgmt *rx_mgmt)
{
#ifdef NEED_AP_MLME
	struct wpa_supplicant *wpa_s = ctx;
	struct hostapd_frame_info fi;
	os_memset(&fi, 0, sizeof(fi));
	fi.freq = rx_mgmt->freq;
	fi.datarate = rx_mgmt->datarate;
	fi.ssi_signal = rx_mgmt->ssi_signal;
	ieee802_11_mgmt(wpa_s->ap_iface->bss[0], rx_mgmt->frame,
			rx_mgmt->frame_len, &fi);
#endif /* NEED_AP_MLME */
}


void ap_mgmt_tx_cb(void *ctx, const u8 *buf, size_t len, u16 stype, int ok)
{
#ifdef NEED_AP_MLME
	struct wpa_supplicant *wpa_s = ctx;
	ieee802_11_mgmt_cb(wpa_s->ap_iface->bss[0], buf, len, stype, ok);
#endif /* NEED_AP_MLME */
}


void wpa_supplicant_ap_rx_eapol(struct wpa_supplicant *wpa_s,
				const u8 *src_addr, const u8 *buf, size_t len,
				enum frame_encryption encrypted)
{
	ieee802_1x_receive(wpa_s->ap_iface->bss[0], src_addr, buf, len,
			   encrypted);
}


#ifdef CONFIG_WPS

int wpa_supplicant_ap_wps_pbc(struct wpa_supplicant *wpa_s, const u8 *bssid,
			      const u8 *p2p_dev_addr)
{
	if (!wpa_s->ap_iface)
		return -1;
	return hostapd_wps_button_pushed(wpa_s->ap_iface->bss[0],
					 p2p_dev_addr);
}


int wpa_supplicant_ap_wps_cancel(struct wpa_supplicant *wpa_s)
{
	struct wps_registrar *reg;
	int reg_sel = 0, wps_sta = 0;

	if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0]->wps)
		return -1;

	reg = wpa_s->ap_iface->bss[0]->wps->registrar;
	reg_sel = wps_registrar_wps_cancel(reg);
	wps_sta = ap_for_each_sta(wpa_s->ap_iface->bss[0],
				  ap_sta_wps_cancel, NULL);

	if (!reg_sel && !wps_sta) {
		wpa_printf(MSG_DEBUG, "No WPS operation in progress at this "
			   "time");
		return -1;
	}

	/*
	 * There are 2 cases to return wps cancel as success:
	 * 1. When wps cancel was initiated but no connection has been
	 *    established with client yet.
	 * 2. Client is in the middle of exchanging WPS messages.
	 */

	return 0;
}


int wpa_supplicant_ap_wps_pin(struct wpa_supplicant *wpa_s, const u8 *bssid,
			      const char *pin, char *buf, size_t buflen,
			      int timeout)
{
	int ret, ret_len = 0;

	if (!wpa_s->ap_iface)
		return -1;

	if (pin == NULL) {
		unsigned int rpin;

		if (wps_generate_pin(&rpin) < 0)
			return -1;
		ret_len = os_snprintf(buf, buflen, "%08d", rpin);
		if (os_snprintf_error(buflen, ret_len))
			return -1;
		pin = buf;
	} else if (buf) {
		ret_len = os_snprintf(buf, buflen, "%s", pin);
		if (os_snprintf_error(buflen, ret_len))
			return -1;
	}

	ret = hostapd_wps_add_pin(wpa_s->ap_iface->bss[0], bssid, "any", pin,
				  timeout);
	if (ret)
		return -1;
	return ret_len;
}


static void wpas_wps_ap_pin_timeout(void *eloop_data, void *user_ctx)
{
	struct wpa_supplicant *wpa_s = eloop_data;
	wpa_printf(MSG_DEBUG, "WPS: AP PIN timed out");
	wpas_wps_ap_pin_disable(wpa_s);
}


static void wpas_wps_ap_pin_enable(struct wpa_supplicant *wpa_s, int timeout)
{
	struct hostapd_data *hapd;

	if (wpa_s->ap_iface == NULL)
		return;
	hapd = wpa_s->ap_iface->bss[0];
	wpa_printf(MSG_DEBUG, "WPS: Enabling AP PIN (timeout=%d)", timeout);
	hapd->ap_pin_failures = 0;
	eloop_cancel_timeout(wpas_wps_ap_pin_timeout, wpa_s, NULL);
	if (timeout > 0)
		eloop_register_timeout(timeout, 0,
				       wpas_wps_ap_pin_timeout, wpa_s, NULL);
}


void wpas_wps_ap_pin_disable(struct wpa_supplicant *wpa_s)
{
	struct hostapd_data *hapd;

	if (wpa_s->ap_iface == NULL)
		return;
	wpa_printf(MSG_DEBUG, "WPS: Disabling AP PIN");
	hapd = wpa_s->ap_iface->bss[0];
	os_free(hapd->conf->ap_pin);
	hapd->conf->ap_pin = NULL;
	eloop_cancel_timeout(wpas_wps_ap_pin_timeout, wpa_s, NULL);
}


const char * wpas_wps_ap_pin_random(struct wpa_supplicant *wpa_s, int timeout)
{
	struct hostapd_data *hapd;
	unsigned int pin;
	char pin_txt[9];

	if (wpa_s->ap_iface == NULL)
		return NULL;
	hapd = wpa_s->ap_iface->bss[0];
	if (wps_generate_pin(&pin) < 0)
		return NULL;
	os_snprintf(pin_txt, sizeof(pin_txt), "%08u", pin);
	os_free(hapd->conf->ap_pin);
	hapd->conf->ap_pin = os_strdup(pin_txt);
	if (hapd->conf->ap_pin == NULL)
		return NULL;
	wpas_wps_ap_pin_enable(wpa_s, timeout);

	return hapd->conf->ap_pin;
}


const char * wpas_wps_ap_pin_get(struct wpa_supplicant *wpa_s)
{
	struct hostapd_data *hapd;
	if (wpa_s->ap_iface == NULL)
		return NULL;
	hapd = wpa_s->ap_iface->bss[0];
	return hapd->conf->ap_pin;
}


int wpas_wps_ap_pin_set(struct wpa_supplicant *wpa_s, const char *pin,
			int timeout)
{
	struct hostapd_data *hapd;
	char pin_txt[9];
	int ret;

	if (wpa_s->ap_iface == NULL)
		return -1;
	hapd = wpa_s->ap_iface->bss[0];
	ret = os_snprintf(pin_txt, sizeof(pin_txt), "%s", pin);
	if (os_snprintf_error(sizeof(pin_txt), ret))
		return -1;
	os_free(hapd->conf->ap_pin);
	hapd->conf->ap_pin = os_strdup(pin_txt);
	if (hapd->conf->ap_pin == NULL)
		return -1;
	wpas_wps_ap_pin_enable(wpa_s, timeout);

	return 0;
}


void wpa_supplicant_ap_pwd_auth_fail(struct wpa_supplicant *wpa_s)
{
	struct hostapd_data *hapd;

	if (wpa_s->ap_iface == NULL)
		return;
	hapd = wpa_s->ap_iface->bss[0];

	/*
	 * Registrar failed to prove its knowledge of the AP PIN. Disable AP
	 * PIN if this happens multiple times to slow down brute force attacks.
	 */
	hapd->ap_pin_failures++;
	wpa_printf(MSG_DEBUG, "WPS: AP PIN authentication failure number %u",
		   hapd->ap_pin_failures);
	if (hapd->ap_pin_failures < 3)
		return;

	wpa_printf(MSG_DEBUG, "WPS: Disable AP PIN");
	hapd->ap_pin_failures = 0;
	os_free(hapd->conf->ap_pin);
	hapd->conf->ap_pin = NULL;
}


#ifdef CONFIG_WPS_NFC

struct wpabuf * wpas_ap_wps_nfc_config_token(struct wpa_supplicant *wpa_s,
					     int ndef)
{
	struct hostapd_data *hapd;

	if (wpa_s->ap_iface == NULL)
		return NULL;
	hapd = wpa_s->ap_iface->bss[0];
	return hostapd_wps_nfc_config_token(hapd, ndef);
}


struct wpabuf * wpas_ap_wps_nfc_handover_sel(struct wpa_supplicant *wpa_s,
					     int ndef)
{
	struct hostapd_data *hapd;

	if (wpa_s->ap_iface == NULL)
		return NULL;
	hapd = wpa_s->ap_iface->bss[0];
	return hostapd_wps_nfc_hs_cr(hapd, ndef);
}


int wpas_ap_wps_nfc_report_handover(struct wpa_supplicant *wpa_s,
				    const struct wpabuf *req,
				    const struct wpabuf *sel)
{
	struct hostapd_data *hapd;

	if (wpa_s->ap_iface == NULL)
		return -1;
	hapd = wpa_s->ap_iface->bss[0];
	return hostapd_wps_nfc_report_handover(hapd, req, sel);
}

#endif /* CONFIG_WPS_NFC */

#endif /* CONFIG_WPS */


#ifdef CONFIG_CTRL_IFACE

int ap_ctrl_iface_sta_first(struct wpa_supplicant *wpa_s,
			    char *buf, size_t buflen)
{
	struct hostapd_data *hapd;

	if (wpa_s->ap_iface)
		hapd = wpa_s->ap_iface->bss[0];
	else if (wpa_s->ifmsh)
		hapd = wpa_s->ifmsh->bss[0];
	else
		return -1;
	return hostapd_ctrl_iface_sta_first(hapd, buf, buflen);
}


int ap_ctrl_iface_sta(struct wpa_supplicant *wpa_s, const char *txtaddr,
		      char *buf, size_t buflen)
{
	struct hostapd_data *hapd;

	if (wpa_s->ap_iface)
		hapd = wpa_s->ap_iface->bss[0];
	else if (wpa_s->ifmsh)
		hapd = wpa_s->ifmsh->bss[0];
	else
		return -1;
	return hostapd_ctrl_iface_sta(hapd, txtaddr, buf, buflen);
}


int ap_ctrl_iface_sta_next(struct wpa_supplicant *wpa_s, const char *txtaddr,
			   char *buf, size_t buflen)
{
	struct hostapd_data *hapd;

	if (wpa_s->ap_iface)
		hapd = wpa_s->ap_iface->bss[0];
	else if (wpa_s->ifmsh)
		hapd = wpa_s->ifmsh->bss[0];
	else
		return -1;
	return hostapd_ctrl_iface_sta_next(hapd, txtaddr, buf, buflen);
}


int ap_ctrl_iface_sta_disassociate(struct wpa_supplicant *wpa_s,
				   const char *txtaddr)
{
	if (wpa_s->ap_iface == NULL)
		return -1;
	return hostapd_ctrl_iface_disassociate(wpa_s->ap_iface->bss[0],
					       txtaddr);
}


int ap_ctrl_iface_sta_deauthenticate(struct wpa_supplicant *wpa_s,
				     const char *txtaddr)
{
	if (wpa_s->ap_iface == NULL)
		return -1;
	return hostapd_ctrl_iface_deauthenticate(wpa_s->ap_iface->bss[0],
						 txtaddr);
}


int ap_ctrl_iface_wpa_get_status(struct wpa_supplicant *wpa_s, char *buf,
				 size_t buflen, int verbose)
{
	char *pos = buf, *end = buf + buflen;
	int ret;
	struct hostapd_bss_config *conf;

	if (wpa_s->ap_iface == NULL)
		return -1;

	conf = wpa_s->ap_iface->bss[0]->conf;
	if (conf->wpa == 0)
		return 0;

	ret = os_snprintf(pos, end - pos,
			  "pairwise_cipher=%s\n"
			  "group_cipher=%s\n"
			  "key_mgmt=%s\n",
			  wpa_cipher_txt(conf->rsn_pairwise),
			  wpa_cipher_txt(conf->wpa_group),
			  wpa_key_mgmt_txt(conf->wpa_key_mgmt,
					   conf->wpa));
	if (os_snprintf_error(end - pos, ret))
		return pos - buf;
	pos += ret;
	return pos - buf;
}


#ifdef CONFIG_WNM_AP

int ap_ctrl_iface_disassoc_imminent(struct wpa_supplicant *wpa_s,
				    const char *buf)
{
	struct hostapd_data *hapd;

	if (wpa_s->ap_iface)
		hapd = wpa_s->ap_iface->bss[0];
	else
		return -1;
	return hostapd_ctrl_iface_disassoc_imminent(hapd, buf);
}


int ap_ctrl_iface_ess_disassoc(struct wpa_supplicant *wpa_s, const char *buf)
{
	struct hostapd_data *hapd;

	if (wpa_s->ap_iface)
		hapd = wpa_s->ap_iface->bss[0];
	else
		return -1;
	return hostapd_ctrl_iface_ess_disassoc(hapd, buf);
}


int ap_ctrl_iface_bss_tm_req(struct wpa_supplicant *wpa_s, const char *buf)
{
	struct hostapd_data *hapd;

	if (wpa_s->ap_iface)
		hapd = wpa_s->ap_iface->bss[0];
	else
		return -1;
	return hostapd_ctrl_iface_bss_tm_req(hapd, buf);
}

#endif /* CONFIG_WNM_AP */


int ap_ctrl_iface_acl_add_mac(struct wpa_supplicant *wpa_s,
			      enum macaddr_acl acl_type,
			      const char *buf)
{
	struct hostapd_data *hapd;

	if (wpa_s->ap_iface)
		hapd = wpa_s->ap_iface->bss[0];
	else
		return -1;

	hapd->conf->macaddr_acl = acl_type;

	if (acl_type == ACCEPT_UNLESS_DENIED)
		return hostapd_ctrl_iface_acl_add_mac(&hapd->conf->deny_mac,
						      &hapd->conf->num_deny_mac,
						      buf);
	if (acl_type == DENY_UNLESS_ACCEPTED)
		return hostapd_ctrl_iface_acl_add_mac(
			&hapd->conf->accept_mac,
			&hapd->conf->num_accept_mac, buf);

	return -1;
}


int ap_ctrl_iface_acl_del_mac(struct wpa_supplicant *wpa_s,
			      enum macaddr_acl acl_type,
			      const char *buf)
{
	struct hostapd_data *hapd;

	if (wpa_s->ap_iface)
		hapd = wpa_s->ap_iface->bss[0];
	else
		return -1;

	hapd->conf->macaddr_acl = acl_type;

	if (acl_type == ACCEPT_UNLESS_DENIED)
		return hostapd_ctrl_iface_acl_del_mac(&hapd->conf->deny_mac,
						      &hapd->conf->num_deny_mac,
						      buf);
	if (acl_type == DENY_UNLESS_ACCEPTED)
		return hostapd_ctrl_iface_acl_del_mac(
			&hapd->conf->accept_mac, &hapd->conf->num_accept_mac,
			buf);

	return -1;
}


int ap_ctrl_iface_acl_show_mac(struct wpa_supplicant *wpa_s,
			       enum macaddr_acl acl_type, char *buf,
			       size_t buflen)
{
	struct hostapd_data *hapd;

	if (wpa_s->ap_iface)
		hapd = wpa_s->ap_iface->bss[0];
	else
		return -1;

	if (acl_type == ACCEPT_UNLESS_DENIED)
		return hostapd_ctrl_iface_acl_show_mac(hapd->conf->deny_mac,
						       hapd->conf->num_deny_mac,
						       buf, buflen);
	if (acl_type == DENY_UNLESS_ACCEPTED)
		return hostapd_ctrl_iface_acl_show_mac(
			hapd->conf->accept_mac,	hapd->conf->num_accept_mac,
			buf, buflen);

	return -1;
}


void ap_ctrl_iface_acl_clear_list(struct wpa_supplicant *wpa_s,
				  enum macaddr_acl acl_type)
{
	struct hostapd_data *hapd;

	if (wpa_s->ap_iface)
		hapd = wpa_s->ap_iface->bss[0];
	else
		return;

	hapd->conf->macaddr_acl = acl_type;

	if (acl_type == ACCEPT_UNLESS_DENIED)
		hostapd_ctrl_iface_acl_clear_list(&hapd->conf->deny_mac,
						  &hapd->conf->num_deny_mac);
	else if (acl_type == DENY_UNLESS_ACCEPTED)
		hostapd_ctrl_iface_acl_clear_list(&hapd->conf->accept_mac,
						  &hapd->conf->num_accept_mac);
}


int ap_ctrl_iface_disassoc_deny_mac(struct wpa_supplicant *wpa_s)
{
	struct hostapd_data *hapd;

	if (wpa_s->ap_iface)
		hapd = wpa_s->ap_iface->bss[0];
	else
		return -1;

	return hostapd_disassoc_deny_mac(hapd);
}


int ap_ctrl_iface_disassoc_accept_mac(struct wpa_supplicant *wpa_s)
{
	struct hostapd_data *hapd;

	if (wpa_s->ap_iface)
		hapd = wpa_s->ap_iface->bss[0];
	else
		return -1;

	return hostapd_disassoc_accept_mac(hapd);
}


int ap_ctrl_iface_set_acl(struct wpa_supplicant *wpa_s)
{
	struct hostapd_data *hapd;

	if (wpa_s->ap_iface)
		hapd = wpa_s->ap_iface->bss[0];
	else
		return -1;

	return hostapd_set_acl(hapd);
}

#endif /* CONFIG_CTRL_IFACE */


int wpa_supplicant_ap_update_beacon(struct wpa_supplicant *wpa_s)
{
	struct hostapd_iface *iface = wpa_s->ap_iface;
	struct wpa_ssid *ssid = wpa_s->current_ssid;
	struct hostapd_data *hapd;

	if (ssid == NULL || wpa_s->ap_iface == NULL ||
	    ssid->mode == WPAS_MODE_INFRA ||
	    ssid->mode == WPAS_MODE_IBSS)
		return -1;

#ifdef CONFIG_P2P
	if (ssid->mode == WPAS_MODE_P2P_GO)
		iface->conf->bss[0]->p2p = P2P_ENABLED | P2P_GROUP_OWNER;
	else if (ssid->mode == WPAS_MODE_P2P_GROUP_FORMATION)
		iface->conf->bss[0]->p2p = P2P_ENABLED | P2P_GROUP_OWNER |
			P2P_GROUP_FORMATION;
#endif /* CONFIG_P2P */

	hapd = iface->bss[0];
	if (hapd->drv_priv == NULL)
		return -1;
	ieee802_11_set_beacons(iface);
	hostapd_set_ap_wps_ie(hapd);

	return 0;
}


int ap_switch_channel(struct wpa_supplicant *wpa_s,
		      struct csa_settings *settings)
{
#ifdef NEED_AP_MLME
	struct hostapd_iface *iface = NULL;

	if (wpa_s->ap_iface)
		iface = wpa_s->ap_iface;
	else if (wpa_s->ifmsh)
		iface = wpa_s->ifmsh;

	if (!iface || !iface->bss[0])
		return -1;

	return hostapd_switch_channel(iface->bss[0], settings);
#else /* NEED_AP_MLME */
	return -1;
#endif /* NEED_AP_MLME */
}


#ifdef CONFIG_CTRL_IFACE
int ap_ctrl_iface_chanswitch(struct wpa_supplicant *wpa_s, const char *pos)
{
	struct csa_settings settings;
	int ret = hostapd_parse_csa_settings(pos, &settings);

	if (ret)
		return ret;

	return ap_switch_channel(wpa_s, &settings);
}
#endif /* CONFIG_CTRL_IFACE */


void wpas_ap_ch_switch(struct wpa_supplicant *wpa_s, int freq, int ht,
		       int offset, int width, int cf1, int cf2,
		       u16 punct_bitmap, int finished)
{
	struct hostapd_iface *iface = wpa_s->ap_iface;

	if (!iface)
		iface = wpa_s->ifmsh;
	if (!iface)
		return;
	wpa_s->assoc_freq = freq;
	if (wpa_s->current_ssid)
		wpa_s->current_ssid->frequency = freq;
	hostapd_event_ch_switch(iface->bss[0], freq, ht,
				offset, width, cf1, cf2, punct_bitmap,
				finished);
}


int wpa_supplicant_ap_mac_addr_filter(struct wpa_supplicant *wpa_s,
				      const u8 *addr)
{
	struct hostapd_data *hapd;
	struct hostapd_bss_config *conf;

	if (!wpa_s->ap_iface)
		return -1;

	if (addr)
		wpa_printf(MSG_DEBUG, "AP: Set MAC address filter: " MACSTR,
			   MAC2STR(addr));
	else
		wpa_printf(MSG_DEBUG, "AP: Clear MAC address filter");

	hapd = wpa_s->ap_iface->bss[0];
	conf = hapd->conf;

	os_free(conf->accept_mac);
	conf->accept_mac = NULL;
	conf->num_accept_mac = 0;
	os_free(conf->deny_mac);
	conf->deny_mac = NULL;
	conf->num_deny_mac = 0;

	if (addr == NULL) {
		conf->macaddr_acl = ACCEPT_UNLESS_DENIED;
		return 0;
	}

	conf->macaddr_acl = DENY_UNLESS_ACCEPTED;
	conf->accept_mac = os_zalloc(sizeof(struct mac_acl_entry));
	if (conf->accept_mac == NULL)
		return -1;
	os_memcpy(conf->accept_mac[0].addr, addr, ETH_ALEN);
	conf->num_accept_mac = 1;

	return 0;
}


#ifdef CONFIG_WPS_NFC
int wpas_ap_wps_add_nfc_pw(struct wpa_supplicant *wpa_s, u16 pw_id,
			   const struct wpabuf *pw, const u8 *pubkey_hash)
{
	struct hostapd_data *hapd;
	struct wps_context *wps;

	if (!wpa_s->ap_iface)
		return -1;
	hapd = wpa_s->ap_iface->bss[0];
	wps = hapd->wps;

	if (wpa_s->p2pdev->conf->wps_nfc_dh_pubkey == NULL ||
	    wpa_s->p2pdev->conf->wps_nfc_dh_privkey == NULL) {
		wpa_printf(MSG_DEBUG, "P2P: No NFC DH key known");
		return -1;
	}

	dh5_free(wps->dh_ctx);
	wpabuf_free(wps->dh_pubkey);
	wpabuf_free(wps->dh_privkey);
	wps->dh_privkey = wpabuf_dup(
		wpa_s->p2pdev->conf->wps_nfc_dh_privkey);
	wps->dh_pubkey = wpabuf_dup(
		wpa_s->p2pdev->conf->wps_nfc_dh_pubkey);
	if (wps->dh_privkey == NULL || wps->dh_pubkey == NULL) {
		wps->dh_ctx = NULL;
		wpabuf_free(wps->dh_pubkey);
		wps->dh_pubkey = NULL;
		wpabuf_free(wps->dh_privkey);
		wps->dh_privkey = NULL;
		return -1;
	}
	wps->dh_ctx = dh5_init_fixed(wps->dh_privkey, wps->dh_pubkey);
	if (wps->dh_ctx == NULL)
		return -1;

	return wps_registrar_add_nfc_pw_token(hapd->wps->registrar, pubkey_hash,
					      pw_id,
					      pw ? wpabuf_head(pw) : NULL,
					      pw ? wpabuf_len(pw) : 0, 1);
}
#endif /* CONFIG_WPS_NFC */


#ifdef CONFIG_CTRL_IFACE
int wpas_ap_stop_ap(struct wpa_supplicant *wpa_s)
{
	struct hostapd_data *hapd;

	if (!wpa_s->ap_iface)
		return -1;
	hapd = wpa_s->ap_iface->bss[0];
	return hostapd_ctrl_iface_stop_ap(hapd);
}


int wpas_ap_pmksa_cache_list(struct wpa_supplicant *wpa_s, char *buf,
			     size_t len)
{
	size_t reply_len = 0, i;
	char ap_delimiter[] = "---- AP ----\n";
	char mesh_delimiter[] = "---- mesh ----\n";
	size_t dlen;

	if (wpa_s->ap_iface) {
		dlen = os_strlen(ap_delimiter);
		if (dlen > len - reply_len)
			return reply_len;
		os_memcpy(&buf[reply_len], ap_delimiter, dlen);
		reply_len += dlen;

		for (i = 0; i < wpa_s->ap_iface->num_bss; i++) {
			reply_len += hostapd_ctrl_iface_pmksa_list(
				wpa_s->ap_iface->bss[i],
				&buf[reply_len], len - reply_len);
		}
	}

	if (wpa_s->ifmsh) {
		dlen = os_strlen(mesh_delimiter);
		if (dlen > len - reply_len)
			return reply_len;
		os_memcpy(&buf[reply_len], mesh_delimiter, dlen);
		reply_len += dlen;

		reply_len += hostapd_ctrl_iface_pmksa_list(
			wpa_s->ifmsh->bss[0], &buf[reply_len],
			len - reply_len);
	}

	return reply_len;
}


void wpas_ap_pmksa_cache_flush(struct wpa_supplicant *wpa_s)
{
	size_t i;

	if (wpa_s->ap_iface) {
		for (i = 0; i < wpa_s->ap_iface->num_bss; i++)
			hostapd_ctrl_iface_pmksa_flush(wpa_s->ap_iface->bss[i]);
	}

	if (wpa_s->ifmsh)
		hostapd_ctrl_iface_pmksa_flush(wpa_s->ifmsh->bss[0]);
}


#ifdef CONFIG_PMKSA_CACHE_EXTERNAL
#ifdef CONFIG_MESH

int wpas_ap_pmksa_cache_list_mesh(struct wpa_supplicant *wpa_s, const u8 *addr,
				  char *buf, size_t len)
{
	return hostapd_ctrl_iface_pmksa_list_mesh(wpa_s->ifmsh->bss[0], addr,
						  &buf[0], len);
}


int wpas_ap_pmksa_cache_add_external(struct wpa_supplicant *wpa_s, char *cmd)
{
	struct external_pmksa_cache *entry;
	void *pmksa_cache;

	pmksa_cache = hostapd_ctrl_iface_pmksa_create_entry(wpa_s->own_addr,
							    cmd);
	if (!pmksa_cache)
		return -1;

	entry = os_zalloc(sizeof(struct external_pmksa_cache));
	if (!entry)
		return -1;

	entry->pmksa_cache = pmksa_cache;

	dl_list_add(&wpa_s->mesh_external_pmksa_cache, &entry->list);

	return 0;
}

#endif /* CONFIG_MESH */
#endif /* CONFIG_PMKSA_CACHE_EXTERNAL */


int wpas_ap_update_beacon(struct wpa_supplicant *wpa_s)
{
	struct hostapd_data *hapd;

	if (!wpa_s->ap_iface)
		return -1;
	hapd = wpa_s->ap_iface->bss[0];

	wpabuf_free(hapd->conf->assocresp_elements);
	hapd->conf->assocresp_elements = NULL;
	if (wpa_s->conf->ap_assocresp_elements) {
		hapd->conf->assocresp_elements =
			wpabuf_dup(wpa_s->conf->ap_assocresp_elements);
	}

	wpabuf_free(hapd->conf->vendor_elements);
	hapd->conf->vendor_elements = NULL;
	if (wpa_s->conf->ap_vendor_elements) {
		hapd->conf->vendor_elements =
			wpabuf_dup(wpa_s->conf->ap_vendor_elements);
	}

	return ieee802_11_set_beacon(hapd);
}

#endif /* CONFIG_CTRL_IFACE */


#ifdef NEED_AP_MLME
void wpas_ap_event_dfs_radar_detected(struct wpa_supplicant *wpa_s,
				      struct dfs_event *radar)
{
	struct hostapd_iface *iface = wpa_s->ap_iface;

	if (!iface)
		iface = wpa_s->ifmsh;
	if (!iface || !iface->bss[0])
		return;
	wpa_printf(MSG_DEBUG, "DFS radar detected on %d MHz", radar->freq);
	hostapd_dfs_radar_detected(iface, radar->freq,
				   radar->ht_enabled, radar->chan_offset,
				   radar->chan_width,
				   radar->cf1, radar->cf2);
}


void wpas_ap_event_dfs_cac_started(struct wpa_supplicant *wpa_s,
				   struct dfs_event *radar)
{
	struct hostapd_iface *iface = wpa_s->ap_iface;

	if (!iface)
		iface = wpa_s->ifmsh;
	if (!iface || !iface->bss[0])
		return;
	wpa_printf(MSG_DEBUG, "DFS CAC started on %d MHz", radar->freq);
	hostapd_dfs_start_cac(iface, radar->freq,
			      radar->ht_enabled, radar->chan_offset,
			      radar->chan_width, radar->cf1, radar->cf2);
}


void wpas_ap_event_dfs_cac_finished(struct wpa_supplicant *wpa_s,
				    struct dfs_event *radar)
{
	struct hostapd_iface *iface = wpa_s->ap_iface;

	if (!iface)
		iface = wpa_s->ifmsh;
	if (!iface || !iface->bss[0])
		return;
	wpa_printf(MSG_DEBUG, "DFS CAC finished on %d MHz", radar->freq);
	hostapd_dfs_complete_cac(iface, 1, radar->freq,
				 radar->ht_enabled, radar->chan_offset,
				 radar->chan_width, radar->cf1, radar->cf2);
}


void wpas_ap_event_dfs_cac_aborted(struct wpa_supplicant *wpa_s,
				   struct dfs_event *radar)
{
	struct hostapd_iface *iface = wpa_s->ap_iface;

	if (!iface)
		iface = wpa_s->ifmsh;
	if (!iface || !iface->bss[0])
		return;
	wpa_printf(MSG_DEBUG, "DFS CAC aborted on %d MHz", radar->freq);
	hostapd_dfs_complete_cac(iface, 0, radar->freq,
				 radar->ht_enabled, radar->chan_offset,
				 radar->chan_width, radar->cf1, radar->cf2);
}


void wpas_ap_event_dfs_cac_nop_finished(struct wpa_supplicant *wpa_s,
					struct dfs_event *radar)
{
	struct hostapd_iface *iface = wpa_s->ap_iface;

	if (!iface)
		iface = wpa_s->ifmsh;
	if (!iface || !iface->bss[0])
		return;
	wpa_printf(MSG_DEBUG, "DFS NOP finished on %d MHz", radar->freq);
	hostapd_dfs_nop_finished(iface, radar->freq,
				 radar->ht_enabled, radar->chan_offset,
				 radar->chan_width, radar->cf1, radar->cf2);
}
#endif /* NEED_AP_MLME */


void ap_periodic(struct wpa_supplicant *wpa_s)
{
	if (wpa_s->ap_iface)
		hostapd_periodic_iface(wpa_s->ap_iface);
}
