2 * WPA Supplicant - Basic AP mode support routines
3 * Copyright (c) 2003-2009, Jouni Malinen <j@w1.fi>
4 * Copyright (c) 2009, Atheros Communications
6 * This software may be distributed under the terms of the BSD license.
7 * See README for more details.
10 #include "utils/includes.h"
12 #include "utils/common.h"
13 #include "utils/eloop.h"
14 #include "utils/uuid.h"
15 #include "common/ieee802_11_defs.h"
16 #include "common/wpa_ctrl.h"
17 #include "eapol_supp/eapol_supp_sm.h"
18 #include "crypto/dh_group5.h"
19 #include "ap/hostapd.h"
20 #include "ap/ap_config.h"
21 #include "ap/ap_drv_ops.h"
23 #include "ap/ieee802_11.h"
24 #endif /* NEED_AP_MLME */
25 #include "ap/beacon.h"
26 #include "ap/ieee802_1x.h"
27 #include "ap/wps_hostapd.h"
28 #include "ap/ctrl_iface_ap.h"
31 #include "common/ieee802_11_defs.h"
32 #include "config_ssid.h"
34 #include "wpa_supplicant_i.h"
36 #include "p2p_supplicant.h"
38 #include "ap/sta_info.h"
43 static void wpas_wps_ap_pin_timeout(void *eloop_data, void *user_ctx);
44 #endif /* CONFIG_WPS */
47 #ifdef CONFIG_IEEE80211N
48 static void wpas_conf_ap_vht(struct wpa_supplicant *wpa_s,
49 struct hostapd_config *conf,
50 struct hostapd_hw_modes *mode)
54 u8 channel = conf->channel;
56 if (!conf->secondary_channel)
59 switch (conf->vht_oper_chwidth) {
60 case VHT_CHANWIDTH_80MHZ:
61 case VHT_CHANWIDTH_80P80MHZ:
62 center_chan = wpas_p2p_get_vht80_center(wpa_s, mode, channel);
64 case VHT_CHANWIDTH_160MHZ:
65 center_chan = wpas_p2p_get_vht160_center(wpa_s, mode, channel);
69 * conf->vht_oper_chwidth might not be set for non-P2P GO cases,
70 * try oper_cwidth 160 MHz first then VHT 80 MHz, if 160 MHz is
73 conf->vht_oper_chwidth = VHT_CHANWIDTH_160MHZ;
74 center_chan = wpas_p2p_get_vht160_center(wpa_s, mode, channel);
76 conf->vht_oper_chwidth = VHT_CHANWIDTH_80MHZ;
77 center_chan = wpas_p2p_get_vht80_center(wpa_s, mode,
85 conf->vht_oper_centr_freq_seg0_idx = center_chan;
89 conf->vht_oper_centr_freq_seg0_idx =
90 channel + conf->secondary_channel * 2;
91 #else /* CONFIG_P2P */
92 conf->vht_oper_centr_freq_seg0_idx =
93 conf->channel + conf->secondary_channel * 2;
94 #endif /* CONFIG_P2P */
95 conf->vht_oper_chwidth = VHT_CHANWIDTH_USE_HT;
97 #endif /* CONFIG_IEEE80211N */
100 int wpa_supplicant_conf_ap_ht(struct wpa_supplicant *wpa_s,
101 struct wpa_ssid *ssid,
102 struct hostapd_config *conf)
104 conf->hw_mode = ieee80211_freq_to_chan(ssid->frequency,
107 if (conf->hw_mode == NUM_HOSTAPD_MODES) {
108 wpa_printf(MSG_ERROR, "Unsupported AP mode frequency: %d MHz",
113 /* TODO: enable HT40 if driver supports it;
114 * drop to 11b if driver does not support 11g */
116 #ifdef CONFIG_IEEE80211N
118 * Enable HT20 if the driver supports it, by setting conf->ieee80211n
119 * and a mask of allowed capabilities within conf->ht_capab.
120 * Using default config settings for: conf->ht_op_mode_fixed,
121 * conf->secondary_channel, conf->require_ht
123 if (wpa_s->hw.modes) {
124 struct hostapd_hw_modes *mode = NULL;
126 for (i = 0; i < wpa_s->hw.num_modes; i++) {
127 if (wpa_s->hw.modes[i].mode == conf->hw_mode) {
128 mode = &wpa_s->hw.modes[i];
133 #ifdef CONFIG_HT_OVERRIDES
134 if (ssid->disable_ht) {
135 conf->ieee80211n = 0;
139 #endif /* CONFIG_HT_OVERRIDES */
141 if (!no_ht && mode && mode->ht_capab) {
142 conf->ieee80211n = 1;
144 if (conf->hw_mode == HOSTAPD_MODE_IEEE80211A &&
146 HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET) &&
148 conf->secondary_channel =
149 wpas_p2p_get_ht40_mode(wpa_s, mode,
151 if (conf->secondary_channel)
153 HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET;
154 #endif /* CONFIG_P2P */
157 * white-list capabilities that won't cause issues
158 * to connecting stations, while leaving the current
159 * capabilities intact (currently disabled SMPS).
161 conf->ht_capab |= mode->ht_capab &
162 (HT_CAP_INFO_GREEN_FIELD |
163 HT_CAP_INFO_SHORT_GI20MHZ |
164 HT_CAP_INFO_SHORT_GI40MHZ |
165 HT_CAP_INFO_RX_STBC_MASK |
166 HT_CAP_INFO_TX_STBC |
167 HT_CAP_INFO_MAX_AMSDU_SIZE);
169 if (mode->vht_capab && ssid->vht) {
170 conf->ieee80211ac = 1;
171 wpas_conf_ap_vht(wpa_s, conf, mode);
176 if (conf->secondary_channel) {
177 struct wpa_supplicant *iface;
179 for (iface = wpa_s->global->ifaces; iface; iface = iface->next)
181 if (iface == wpa_s ||
182 iface->wpa_state < WPA_AUTHENTICATING ||
183 (int) iface->assoc_freq != ssid->frequency)
187 * Do not allow 40 MHz co-ex PRI/SEC switch to force us
188 * to change our PRI channel since we have an existing,
189 * concurrent connection on that channel and doing
190 * multi-channel concurrency is likely to cause more
191 * harm than using different PRI/SEC selection in
192 * environment with multiple BSSes on these two channels
193 * with mixed 20 MHz or PRI channel selection.
195 conf->no_pri_sec_switch = 1;
198 #endif /* CONFIG_IEEE80211N */
204 static int wpa_supplicant_conf_ap(struct wpa_supplicant *wpa_s,
205 struct wpa_ssid *ssid,
206 struct hostapd_config *conf)
208 struct hostapd_bss_config *bss = conf->bss[0];
210 conf->driver = wpa_s->driver;
212 os_strlcpy(bss->iface, wpa_s->ifname, sizeof(bss->iface));
214 if (wpa_supplicant_conf_ap_ht(wpa_s, ssid, conf))
217 if (ssid->pbss > 1) {
218 wpa_printf(MSG_ERROR, "Invalid pbss value(%d) for AP mode",
222 bss->pbss = ssid->pbss;
226 /* Setting channel to 0 in order to enable ACS */
228 wpa_printf(MSG_DEBUG, "Use automatic channel selection");
230 #endif /* CONFIG_ACS */
232 if (ieee80211_is_dfs(ssid->frequency) && wpa_s->conf->country[0]) {
233 conf->ieee80211h = 1;
234 conf->ieee80211d = 1;
235 conf->country[0] = wpa_s->conf->country[0];
236 conf->country[1] = wpa_s->conf->country[1];
240 if (conf->hw_mode == HOSTAPD_MODE_IEEE80211G &&
241 (ssid->mode == WPAS_MODE_P2P_GO ||
242 ssid->mode == WPAS_MODE_P2P_GROUP_FORMATION)) {
243 /* Remove 802.11b rates from supported and basic rate sets */
244 int *list = os_malloc(4 * sizeof(int));
251 conf->basic_rates = list;
253 list = os_malloc(9 * sizeof(int));
265 conf->supported_rates = list;
268 bss->isolate = !wpa_s->conf->p2p_intra_bss;
269 bss->force_per_enrollee_psk = wpa_s->global->p2p_per_sta_psk;
271 if (ssid->p2p_group) {
272 os_memcpy(bss->ip_addr_go, wpa_s->p2pdev->conf->ip_addr_go, 4);
273 os_memcpy(bss->ip_addr_mask, wpa_s->p2pdev->conf->ip_addr_mask,
275 os_memcpy(bss->ip_addr_start,
276 wpa_s->p2pdev->conf->ip_addr_start, 4);
277 os_memcpy(bss->ip_addr_end, wpa_s->p2pdev->conf->ip_addr_end,
280 #endif /* CONFIG_P2P */
282 if (ssid->ssid_len == 0) {
283 wpa_printf(MSG_ERROR, "No SSID configured for AP mode");
286 os_memcpy(bss->ssid.ssid, ssid->ssid, ssid->ssid_len);
287 bss->ssid.ssid_len = ssid->ssid_len;
288 bss->ssid.ssid_set = 1;
290 bss->ignore_broadcast_ssid = ssid->ignore_broadcast_ssid;
293 bss->auth_algs = ssid->auth_alg;
295 if (wpa_key_mgmt_wpa_psk(ssid->key_mgmt))
296 bss->wpa = ssid->proto;
297 if (ssid->key_mgmt == DEFAULT_KEY_MGMT)
298 bss->wpa_key_mgmt = WPA_KEY_MGMT_PSK;
300 bss->wpa_key_mgmt = ssid->key_mgmt;
301 bss->wpa_pairwise = ssid->pairwise_cipher;
303 bin_clear_free(bss->ssid.wpa_psk, sizeof(*bss->ssid.wpa_psk));
304 bss->ssid.wpa_psk = os_zalloc(sizeof(struct hostapd_wpa_psk));
305 if (bss->ssid.wpa_psk == NULL)
307 os_memcpy(bss->ssid.wpa_psk->psk, ssid->psk, PMK_LEN);
308 bss->ssid.wpa_psk->group = 1;
309 bss->ssid.wpa_psk_set = 1;
310 } else if (ssid->passphrase) {
311 bss->ssid.wpa_passphrase = os_strdup(ssid->passphrase);
312 } else if (ssid->wep_key_len[0] || ssid->wep_key_len[1] ||
313 ssid->wep_key_len[2] || ssid->wep_key_len[3]) {
314 struct hostapd_wep_keys *wep = &bss->ssid.wep;
316 for (i = 0; i < NUM_WEP_KEYS; i++) {
317 if (ssid->wep_key_len[i] == 0)
319 wep->key[i] = os_malloc(ssid->wep_key_len[i]);
320 if (wep->key[i] == NULL)
322 os_memcpy(wep->key[i], ssid->wep_key[i],
323 ssid->wep_key_len[i]);
324 wep->len[i] = ssid->wep_key_len[i];
326 wep->idx = ssid->wep_tx_keyidx;
330 if (ssid->ap_max_inactivity)
331 bss->ap_max_inactivity = ssid->ap_max_inactivity;
333 if (ssid->dtim_period)
334 bss->dtim_period = ssid->dtim_period;
335 else if (wpa_s->conf->dtim_period)
336 bss->dtim_period = wpa_s->conf->dtim_period;
338 if (ssid->beacon_int)
339 conf->beacon_int = ssid->beacon_int;
340 else if (wpa_s->conf->beacon_int)
341 conf->beacon_int = wpa_s->conf->beacon_int;
344 if (ssid->mode == WPAS_MODE_P2P_GO ||
345 ssid->mode == WPAS_MODE_P2P_GROUP_FORMATION) {
346 if (wpa_s->conf->p2p_go_ctwindow > conf->beacon_int) {
348 "CTWindow (%d) is bigger than beacon interval (%d) - avoid configuring it",
349 wpa_s->conf->p2p_go_ctwindow,
351 conf->p2p_go_ctwindow = 0;
353 conf->p2p_go_ctwindow = wpa_s->conf->p2p_go_ctwindow;
356 #endif /* CONFIG_P2P */
358 if ((bss->wpa & 2) && bss->rsn_pairwise == 0)
359 bss->rsn_pairwise = bss->wpa_pairwise;
360 bss->wpa_group = wpa_select_ap_group_cipher(bss->wpa, bss->wpa_pairwise,
363 if (bss->wpa && bss->ieee802_1x)
364 bss->ssid.security_policy = SECURITY_WPA;
366 bss->ssid.security_policy = SECURITY_WPA_PSK;
367 else if (bss->ieee802_1x) {
368 int cipher = WPA_CIPHER_NONE;
369 bss->ssid.security_policy = SECURITY_IEEE_802_1X;
370 bss->ssid.wep.default_len = bss->default_wep_key_len;
371 if (bss->default_wep_key_len)
372 cipher = bss->default_wep_key_len >= 13 ?
373 WPA_CIPHER_WEP104 : WPA_CIPHER_WEP40;
374 bss->wpa_group = cipher;
375 bss->wpa_pairwise = cipher;
376 bss->rsn_pairwise = cipher;
377 } else if (bss->ssid.wep.keys_set) {
378 int cipher = WPA_CIPHER_WEP40;
379 if (bss->ssid.wep.len[0] >= 13)
380 cipher = WPA_CIPHER_WEP104;
381 bss->ssid.security_policy = SECURITY_STATIC_WEP;
382 bss->wpa_group = cipher;
383 bss->wpa_pairwise = cipher;
384 bss->rsn_pairwise = cipher;
386 bss->ssid.security_policy = SECURITY_PLAINTEXT;
387 bss->wpa_group = WPA_CIPHER_NONE;
388 bss->wpa_pairwise = WPA_CIPHER_NONE;
389 bss->rsn_pairwise = WPA_CIPHER_NONE;
392 if (bss->wpa_group_rekey < 86400 && (bss->wpa & 2) &&
393 (bss->wpa_group == WPA_CIPHER_CCMP ||
394 bss->wpa_group == WPA_CIPHER_GCMP ||
395 bss->wpa_group == WPA_CIPHER_CCMP_256 ||
396 bss->wpa_group == WPA_CIPHER_GCMP_256)) {
398 * Strong ciphers do not need frequent rekeying, so increase
399 * the default GTK rekeying period to 24 hours.
401 bss->wpa_group_rekey = 86400;
404 #ifdef CONFIG_IEEE80211W
405 if (ssid->ieee80211w != MGMT_FRAME_PROTECTION_DEFAULT)
406 bss->ieee80211w = ssid->ieee80211w;
407 #endif /* CONFIG_IEEE80211W */
411 * Enable WPS by default for open and WPA/WPA2-Personal network, but
412 * require user interaction to actually use it. Only the internal
413 * Registrar is supported.
415 if (bss->ssid.security_policy != SECURITY_WPA_PSK &&
416 bss->ssid.security_policy != SECURITY_PLAINTEXT)
418 if (bss->ssid.security_policy == SECURITY_WPA_PSK &&
419 (!(bss->rsn_pairwise & (WPA_CIPHER_CCMP | WPA_CIPHER_GCMP)) ||
421 goto no_wps; /* WPS2 does not allow WPA/TKIP-only
423 if (ssid->wps_disabled)
427 if (!ssid->ignore_broadcast_ssid)
430 bss->ap_setup_locked = 2;
431 if (wpa_s->conf->config_methods)
432 bss->config_methods = os_strdup(wpa_s->conf->config_methods);
433 os_memcpy(bss->device_type, wpa_s->conf->device_type,
435 if (wpa_s->conf->device_name) {
436 bss->device_name = os_strdup(wpa_s->conf->device_name);
437 bss->friendly_name = os_strdup(wpa_s->conf->device_name);
439 if (wpa_s->conf->manufacturer)
440 bss->manufacturer = os_strdup(wpa_s->conf->manufacturer);
441 if (wpa_s->conf->model_name)
442 bss->model_name = os_strdup(wpa_s->conf->model_name);
443 if (wpa_s->conf->model_number)
444 bss->model_number = os_strdup(wpa_s->conf->model_number);
445 if (wpa_s->conf->serial_number)
446 bss->serial_number = os_strdup(wpa_s->conf->serial_number);
447 if (is_nil_uuid(wpa_s->conf->uuid))
448 os_memcpy(bss->uuid, wpa_s->wps->uuid, WPS_UUID_LEN);
450 os_memcpy(bss->uuid, wpa_s->conf->uuid, WPS_UUID_LEN);
451 os_memcpy(bss->os_version, wpa_s->conf->os_version, 4);
452 bss->pbc_in_m1 = wpa_s->conf->pbc_in_m1;
453 if (ssid->eap.fragment_size != DEFAULT_FRAGMENT_SIZE)
454 bss->fragment_size = ssid->eap.fragment_size;
456 #endif /* CONFIG_WPS */
458 if (wpa_s->max_stations &&
459 wpa_s->max_stations < wpa_s->conf->max_num_sta)
460 bss->max_num_sta = wpa_s->max_stations;
462 bss->max_num_sta = wpa_s->conf->max_num_sta;
464 bss->disassoc_low_ack = wpa_s->conf->disassoc_low_ack;
466 if (wpa_s->conf->ap_vendor_elements) {
467 bss->vendor_elements =
468 wpabuf_dup(wpa_s->conf->ap_vendor_elements);
475 static void ap_public_action_rx(void *ctx, const u8 *buf, size_t len, int freq)
478 struct wpa_supplicant *wpa_s = ctx;
479 const struct ieee80211_mgmt *mgmt;
481 mgmt = (const struct ieee80211_mgmt *) buf;
482 if (len < IEEE80211_HDRLEN + 1)
484 if (mgmt->u.action.category != WLAN_ACTION_PUBLIC)
486 wpas_p2p_rx_action(wpa_s, mgmt->da, mgmt->sa, mgmt->bssid,
487 mgmt->u.action.category,
488 buf + IEEE80211_HDRLEN + 1,
489 len - IEEE80211_HDRLEN - 1, freq);
490 #endif /* CONFIG_P2P */
494 static void ap_wps_event_cb(void *ctx, enum wps_event event,
495 union wps_event_data *data)
498 struct wpa_supplicant *wpa_s = ctx;
500 if (event == WPS_EV_FAIL) {
501 struct wps_event_fail *fail = &data->fail;
503 if (wpa_s->p2pdev && wpa_s->p2pdev != wpa_s &&
504 wpa_s == wpa_s->global->p2p_group_formation) {
506 * src/ap/wps_hostapd.c has already sent this on the
507 * main interface, so only send on the parent interface
510 wpa_msg(wpa_s->p2pdev, MSG_INFO, WPS_EVENT_FAIL
511 "msg=%d config_error=%d",
512 fail->msg, fail->config_error);
514 wpas_p2p_wps_failed(wpa_s, fail);
516 #endif /* CONFIG_P2P */
520 static void ap_sta_authorized_cb(void *ctx, const u8 *mac_addr,
521 int authorized, const u8 *p2p_dev_addr)
523 wpas_notify_sta_authorized(ctx, mac_addr, authorized, p2p_dev_addr);
528 static void ap_new_psk_cb(void *ctx, const u8 *mac_addr, const u8 *p2p_dev_addr,
529 const u8 *psk, size_t psk_len)
532 struct wpa_supplicant *wpa_s = ctx;
533 if (wpa_s->ap_iface == NULL || wpa_s->current_ssid == NULL)
535 wpas_p2p_new_psk_cb(wpa_s, mac_addr, p2p_dev_addr, psk, psk_len);
537 #endif /* CONFIG_P2P */
540 static int ap_vendor_action_rx(void *ctx, const u8 *buf, size_t len, int freq)
543 struct wpa_supplicant *wpa_s = ctx;
544 const struct ieee80211_mgmt *mgmt;
546 mgmt = (const struct ieee80211_mgmt *) buf;
547 if (len < IEEE80211_HDRLEN + 1)
549 wpas_p2p_rx_action(wpa_s, mgmt->da, mgmt->sa, mgmt->bssid,
550 mgmt->u.action.category,
551 buf + IEEE80211_HDRLEN + 1,
552 len - IEEE80211_HDRLEN - 1, freq);
553 #endif /* CONFIG_P2P */
558 static int ap_probe_req_rx(void *ctx, const u8 *sa, const u8 *da,
559 const u8 *bssid, const u8 *ie, size_t ie_len,
562 struct wpa_supplicant *wpa_s = ctx;
563 unsigned int freq = 0;
566 freq = wpa_s->ap_iface->freq;
568 return wpas_p2p_probe_req_rx(wpa_s, sa, da, bssid, ie, ie_len,
573 static void ap_wps_reg_success_cb(void *ctx, const u8 *mac_addr,
576 struct wpa_supplicant *wpa_s = ctx;
577 wpas_p2p_wps_success(wpa_s, mac_addr, 1);
581 static void wpas_ap_configured_cb(void *ctx)
583 struct wpa_supplicant *wpa_s = ctx;
586 if (wpa_s->current_ssid && wpa_s->current_ssid->acs)
587 wpa_s->assoc_freq = wpa_s->ap_iface->freq;
588 #endif /* CONFIG_ACS */
590 wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
592 if (wpa_s->ap_configured_cb)
593 wpa_s->ap_configured_cb(wpa_s->ap_configured_cb_ctx,
594 wpa_s->ap_configured_cb_data);
598 int wpa_supplicant_create_ap(struct wpa_supplicant *wpa_s,
599 struct wpa_ssid *ssid)
601 struct wpa_driver_associate_params params;
602 struct hostapd_iface *hapd_iface;
603 struct hostapd_config *conf;
606 if (ssid->ssid == NULL || ssid->ssid_len == 0) {
607 wpa_printf(MSG_ERROR, "No SSID configured for AP mode");
611 wpa_supplicant_ap_deinit(wpa_s);
613 wpa_printf(MSG_DEBUG, "Setting up AP (SSID='%s')",
614 wpa_ssid_txt(ssid->ssid, ssid->ssid_len));
616 os_memset(¶ms, 0, sizeof(params));
617 params.ssid = ssid->ssid;
618 params.ssid_len = ssid->ssid_len;
619 switch (ssid->mode) {
621 case WPAS_MODE_P2P_GO:
622 case WPAS_MODE_P2P_GROUP_FORMATION:
623 params.mode = IEEE80211_MODE_AP;
628 if (ssid->frequency == 0)
629 ssid->frequency = 2462; /* default channel 11 */
630 params.freq.freq = ssid->frequency;
632 params.wpa_proto = ssid->proto;
633 if (ssid->key_mgmt & WPA_KEY_MGMT_PSK)
634 wpa_s->key_mgmt = WPA_KEY_MGMT_PSK;
636 wpa_s->key_mgmt = WPA_KEY_MGMT_NONE;
637 params.key_mgmt_suite = wpa_s->key_mgmt;
639 wpa_s->pairwise_cipher = wpa_pick_pairwise_cipher(ssid->pairwise_cipher,
641 if (wpa_s->pairwise_cipher < 0) {
642 wpa_printf(MSG_WARNING, "WPA: Failed to select pairwise "
646 params.pairwise_suite = wpa_s->pairwise_cipher;
647 params.group_suite = params.pairwise_suite;
650 if (ssid->mode == WPAS_MODE_P2P_GO ||
651 ssid->mode == WPAS_MODE_P2P_GROUP_FORMATION)
653 #endif /* CONFIG_P2P */
655 if (wpa_s->p2pdev->set_ap_uapsd)
656 params.uapsd = wpa_s->p2pdev->ap_uapsd;
657 else if (params.p2p && (wpa_s->drv_flags & WPA_DRIVER_FLAGS_AP_UAPSD))
658 params.uapsd = 1; /* mandatory for P2P GO */
662 if (ieee80211_is_dfs(params.freq.freq))
663 params.freq.freq = 0; /* set channel after CAC */
666 wpa_drv_get_ext_capa(wpa_s, WPA_IF_P2P_GO);
668 wpa_drv_get_ext_capa(wpa_s, WPA_IF_AP_BSS);
670 if (wpa_drv_associate(wpa_s, ¶ms) < 0) {
671 wpa_msg(wpa_s, MSG_INFO, "Failed to start AP functionality");
675 wpa_s->ap_iface = hapd_iface = os_zalloc(sizeof(*wpa_s->ap_iface));
676 if (hapd_iface == NULL)
678 hapd_iface->owner = wpa_s;
679 hapd_iface->drv_flags = wpa_s->drv_flags;
680 hapd_iface->smps_modes = wpa_s->drv_smps_modes;
681 hapd_iface->probe_resp_offloads = wpa_s->probe_resp_offloads;
682 hapd_iface->extended_capa = wpa_s->extended_capa;
683 hapd_iface->extended_capa_mask = wpa_s->extended_capa_mask;
684 hapd_iface->extended_capa_len = wpa_s->extended_capa_len;
686 wpa_s->ap_iface->conf = conf = hostapd_config_defaults();
688 wpa_supplicant_ap_deinit(wpa_s);
692 /* Use the maximum oper channel width if it's given. */
693 if (ssid->max_oper_chwidth)
694 conf->vht_oper_chwidth = ssid->max_oper_chwidth;
696 ieee80211_freq_to_chan(ssid->vht_center_freq2,
697 &conf->vht_oper_centr_freq_seg1_idx);
699 os_memcpy(wpa_s->ap_iface->conf->wmm_ac_params,
700 wpa_s->conf->wmm_ac_params,
701 sizeof(wpa_s->conf->wmm_ac_params));
703 if (params.uapsd > 0) {
704 conf->bss[0]->wmm_enabled = 1;
705 conf->bss[0]->wmm_uapsd = 1;
708 if (wpa_supplicant_conf_ap(wpa_s, ssid, conf)) {
709 wpa_printf(MSG_ERROR, "Failed to create AP configuration");
710 wpa_supplicant_ap_deinit(wpa_s);
715 if (ssid->mode == WPAS_MODE_P2P_GO)
716 conf->bss[0]->p2p = P2P_ENABLED | P2P_GROUP_OWNER;
717 else if (ssid->mode == WPAS_MODE_P2P_GROUP_FORMATION)
718 conf->bss[0]->p2p = P2P_ENABLED | P2P_GROUP_OWNER |
720 #endif /* CONFIG_P2P */
722 hapd_iface->num_bss = conf->num_bss;
723 hapd_iface->bss = os_calloc(conf->num_bss,
724 sizeof(struct hostapd_data *));
725 if (hapd_iface->bss == NULL) {
726 wpa_supplicant_ap_deinit(wpa_s);
730 for (i = 0; i < conf->num_bss; i++) {
732 hostapd_alloc_bss_data(hapd_iface, conf,
734 if (hapd_iface->bss[i] == NULL) {
735 wpa_supplicant_ap_deinit(wpa_s);
739 hapd_iface->bss[i]->msg_ctx = wpa_s;
740 hapd_iface->bss[i]->msg_ctx_parent = wpa_s->p2pdev;
741 hapd_iface->bss[i]->public_action_cb = ap_public_action_rx;
742 hapd_iface->bss[i]->public_action_cb_ctx = wpa_s;
743 hapd_iface->bss[i]->vendor_action_cb = ap_vendor_action_rx;
744 hapd_iface->bss[i]->vendor_action_cb_ctx = wpa_s;
745 hostapd_register_probereq_cb(hapd_iface->bss[i],
746 ap_probe_req_rx, wpa_s);
747 hapd_iface->bss[i]->wps_reg_success_cb = ap_wps_reg_success_cb;
748 hapd_iface->bss[i]->wps_reg_success_cb_ctx = wpa_s;
749 hapd_iface->bss[i]->wps_event_cb = ap_wps_event_cb;
750 hapd_iface->bss[i]->wps_event_cb_ctx = wpa_s;
751 hapd_iface->bss[i]->sta_authorized_cb = ap_sta_authorized_cb;
752 hapd_iface->bss[i]->sta_authorized_cb_ctx = wpa_s;
754 hapd_iface->bss[i]->new_psk_cb = ap_new_psk_cb;
755 hapd_iface->bss[i]->new_psk_cb_ctx = wpa_s;
756 hapd_iface->bss[i]->p2p = wpa_s->global->p2p;
757 hapd_iface->bss[i]->p2p_group = wpas_p2p_group_init(wpa_s,
759 #endif /* CONFIG_P2P */
760 hapd_iface->bss[i]->setup_complete_cb = wpas_ap_configured_cb;
761 hapd_iface->bss[i]->setup_complete_cb_ctx = wpa_s;
762 #ifdef CONFIG_TESTING_OPTIONS
763 hapd_iface->bss[i]->ext_eapol_frame_io =
764 wpa_s->ext_eapol_frame_io;
765 #endif /* CONFIG_TESTING_OPTIONS */
768 os_memcpy(hapd_iface->bss[0]->own_addr, wpa_s->own_addr, ETH_ALEN);
769 hapd_iface->bss[0]->driver = wpa_s->driver;
770 hapd_iface->bss[0]->drv_priv = wpa_s->drv_priv;
772 wpa_s->current_ssid = ssid;
773 eapol_sm_notify_config(wpa_s->eapol, NULL, NULL);
774 os_memcpy(wpa_s->bssid, wpa_s->own_addr, ETH_ALEN);
775 wpa_s->assoc_freq = ssid->frequency;
777 if (hostapd_setup_interface(wpa_s->ap_iface)) {
778 wpa_printf(MSG_ERROR, "Failed to initialize AP interface");
779 wpa_supplicant_ap_deinit(wpa_s);
787 void wpa_supplicant_ap_deinit(struct wpa_supplicant *wpa_s)
790 eloop_cancel_timeout(wpas_wps_ap_pin_timeout, wpa_s, NULL);
791 #endif /* CONFIG_WPS */
793 if (wpa_s->ap_iface == NULL)
796 wpa_s->current_ssid = NULL;
797 eapol_sm_notify_config(wpa_s->eapol, NULL, NULL);
798 wpa_s->assoc_freq = 0;
799 wpas_p2p_ap_deinit(wpa_s);
800 wpa_s->ap_iface->driver_ap_teardown =
801 !!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_AP_TEARDOWN_SUPPORT);
803 hostapd_interface_deinit(wpa_s->ap_iface);
804 hostapd_interface_free(wpa_s->ap_iface);
805 wpa_s->ap_iface = NULL;
806 wpa_drv_deinit_ap(wpa_s);
807 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_DISCONNECTED "bssid=" MACSTR
808 " reason=%d locally_generated=1",
809 MAC2STR(wpa_s->own_addr), WLAN_REASON_DEAUTH_LEAVING);
813 void ap_tx_status(void *ctx, const u8 *addr,
814 const u8 *buf, size_t len, int ack)
817 struct wpa_supplicant *wpa_s = ctx;
818 hostapd_tx_status(wpa_s->ap_iface->bss[0], addr, buf, len, ack);
819 #endif /* NEED_AP_MLME */
823 void ap_eapol_tx_status(void *ctx, const u8 *dst,
824 const u8 *data, size_t len, int ack)
827 struct wpa_supplicant *wpa_s = ctx;
828 if (!wpa_s->ap_iface)
830 hostapd_tx_status(wpa_s->ap_iface->bss[0], dst, data, len, ack);
831 #endif /* NEED_AP_MLME */
835 void ap_client_poll_ok(void *ctx, const u8 *addr)
838 struct wpa_supplicant *wpa_s = ctx;
840 hostapd_client_poll_ok(wpa_s->ap_iface->bss[0], addr);
841 #endif /* NEED_AP_MLME */
845 void ap_rx_from_unknown_sta(void *ctx, const u8 *addr, int wds)
848 struct wpa_supplicant *wpa_s = ctx;
849 ieee802_11_rx_from_unknown(wpa_s->ap_iface->bss[0], addr, wds);
850 #endif /* NEED_AP_MLME */
854 void ap_mgmt_rx(void *ctx, struct rx_mgmt *rx_mgmt)
857 struct wpa_supplicant *wpa_s = ctx;
858 struct hostapd_frame_info fi;
859 os_memset(&fi, 0, sizeof(fi));
860 fi.datarate = rx_mgmt->datarate;
861 fi.ssi_signal = rx_mgmt->ssi_signal;
862 ieee802_11_mgmt(wpa_s->ap_iface->bss[0], rx_mgmt->frame,
863 rx_mgmt->frame_len, &fi);
864 #endif /* NEED_AP_MLME */
868 void ap_mgmt_tx_cb(void *ctx, const u8 *buf, size_t len, u16 stype, int ok)
871 struct wpa_supplicant *wpa_s = ctx;
872 ieee802_11_mgmt_cb(wpa_s->ap_iface->bss[0], buf, len, stype, ok);
873 #endif /* NEED_AP_MLME */
877 void wpa_supplicant_ap_rx_eapol(struct wpa_supplicant *wpa_s,
878 const u8 *src_addr, const u8 *buf, size_t len)
880 ieee802_1x_receive(wpa_s->ap_iface->bss[0], src_addr, buf, len);
886 int wpa_supplicant_ap_wps_pbc(struct wpa_supplicant *wpa_s, const u8 *bssid,
887 const u8 *p2p_dev_addr)
889 if (!wpa_s->ap_iface)
891 return hostapd_wps_button_pushed(wpa_s->ap_iface->bss[0],
896 int wpa_supplicant_ap_wps_cancel(struct wpa_supplicant *wpa_s)
898 struct wps_registrar *reg;
899 int reg_sel = 0, wps_sta = 0;
901 if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0]->wps)
904 reg = wpa_s->ap_iface->bss[0]->wps->registrar;
905 reg_sel = wps_registrar_wps_cancel(reg);
906 wps_sta = ap_for_each_sta(wpa_s->ap_iface->bss[0],
907 ap_sta_wps_cancel, NULL);
909 if (!reg_sel && !wps_sta) {
910 wpa_printf(MSG_DEBUG, "No WPS operation in progress at this "
916 * There are 2 cases to return wps cancel as success:
917 * 1. When wps cancel was initiated but no connection has been
918 * established with client yet.
919 * 2. Client is in the middle of exchanging WPS messages.
926 int wpa_supplicant_ap_wps_pin(struct wpa_supplicant *wpa_s, const u8 *bssid,
927 const char *pin, char *buf, size_t buflen,
930 int ret, ret_len = 0;
932 if (!wpa_s->ap_iface)
938 if (wps_generate_pin(&rpin) < 0)
940 ret_len = os_snprintf(buf, buflen, "%08d", rpin);
941 if (os_snprintf_error(buflen, ret_len))
945 ret_len = os_snprintf(buf, buflen, "%s", pin);
946 if (os_snprintf_error(buflen, ret_len))
950 ret = hostapd_wps_add_pin(wpa_s->ap_iface->bss[0], bssid, "any", pin,
958 static void wpas_wps_ap_pin_timeout(void *eloop_data, void *user_ctx)
960 struct wpa_supplicant *wpa_s = eloop_data;
961 wpa_printf(MSG_DEBUG, "WPS: AP PIN timed out");
962 wpas_wps_ap_pin_disable(wpa_s);
966 static void wpas_wps_ap_pin_enable(struct wpa_supplicant *wpa_s, int timeout)
968 struct hostapd_data *hapd;
970 if (wpa_s->ap_iface == NULL)
972 hapd = wpa_s->ap_iface->bss[0];
973 wpa_printf(MSG_DEBUG, "WPS: Enabling AP PIN (timeout=%d)", timeout);
974 hapd->ap_pin_failures = 0;
975 eloop_cancel_timeout(wpas_wps_ap_pin_timeout, wpa_s, NULL);
977 eloop_register_timeout(timeout, 0,
978 wpas_wps_ap_pin_timeout, wpa_s, NULL);
982 void wpas_wps_ap_pin_disable(struct wpa_supplicant *wpa_s)
984 struct hostapd_data *hapd;
986 if (wpa_s->ap_iface == NULL)
988 wpa_printf(MSG_DEBUG, "WPS: Disabling AP PIN");
989 hapd = wpa_s->ap_iface->bss[0];
990 os_free(hapd->conf->ap_pin);
991 hapd->conf->ap_pin = NULL;
992 eloop_cancel_timeout(wpas_wps_ap_pin_timeout, wpa_s, NULL);
996 const char * wpas_wps_ap_pin_random(struct wpa_supplicant *wpa_s, int timeout)
998 struct hostapd_data *hapd;
1002 if (wpa_s->ap_iface == NULL)
1004 hapd = wpa_s->ap_iface->bss[0];
1005 if (wps_generate_pin(&pin) < 0)
1007 os_snprintf(pin_txt, sizeof(pin_txt), "%08u", pin);
1008 os_free(hapd->conf->ap_pin);
1009 hapd->conf->ap_pin = os_strdup(pin_txt);
1010 if (hapd->conf->ap_pin == NULL)
1012 wpas_wps_ap_pin_enable(wpa_s, timeout);
1014 return hapd->conf->ap_pin;
1018 const char * wpas_wps_ap_pin_get(struct wpa_supplicant *wpa_s)
1020 struct hostapd_data *hapd;
1021 if (wpa_s->ap_iface == NULL)
1023 hapd = wpa_s->ap_iface->bss[0];
1024 return hapd->conf->ap_pin;
1028 int wpas_wps_ap_pin_set(struct wpa_supplicant *wpa_s, const char *pin,
1031 struct hostapd_data *hapd;
1035 if (wpa_s->ap_iface == NULL)
1037 hapd = wpa_s->ap_iface->bss[0];
1038 ret = os_snprintf(pin_txt, sizeof(pin_txt), "%s", pin);
1039 if (os_snprintf_error(sizeof(pin_txt), ret))
1041 os_free(hapd->conf->ap_pin);
1042 hapd->conf->ap_pin = os_strdup(pin_txt);
1043 if (hapd->conf->ap_pin == NULL)
1045 wpas_wps_ap_pin_enable(wpa_s, timeout);
1051 void wpa_supplicant_ap_pwd_auth_fail(struct wpa_supplicant *wpa_s)
1053 struct hostapd_data *hapd;
1055 if (wpa_s->ap_iface == NULL)
1057 hapd = wpa_s->ap_iface->bss[0];
1060 * Registrar failed to prove its knowledge of the AP PIN. Disable AP
1061 * PIN if this happens multiple times to slow down brute force attacks.
1063 hapd->ap_pin_failures++;
1064 wpa_printf(MSG_DEBUG, "WPS: AP PIN authentication failure number %u",
1065 hapd->ap_pin_failures);
1066 if (hapd->ap_pin_failures < 3)
1069 wpa_printf(MSG_DEBUG, "WPS: Disable AP PIN");
1070 hapd->ap_pin_failures = 0;
1071 os_free(hapd->conf->ap_pin);
1072 hapd->conf->ap_pin = NULL;
1076 #ifdef CONFIG_WPS_NFC
1078 struct wpabuf * wpas_ap_wps_nfc_config_token(struct wpa_supplicant *wpa_s,
1081 struct hostapd_data *hapd;
1083 if (wpa_s->ap_iface == NULL)
1085 hapd = wpa_s->ap_iface->bss[0];
1086 return hostapd_wps_nfc_config_token(hapd, ndef);
1090 struct wpabuf * wpas_ap_wps_nfc_handover_sel(struct wpa_supplicant *wpa_s,
1093 struct hostapd_data *hapd;
1095 if (wpa_s->ap_iface == NULL)
1097 hapd = wpa_s->ap_iface->bss[0];
1098 return hostapd_wps_nfc_hs_cr(hapd, ndef);
1102 int wpas_ap_wps_nfc_report_handover(struct wpa_supplicant *wpa_s,
1103 const struct wpabuf *req,
1104 const struct wpabuf *sel)
1106 struct hostapd_data *hapd;
1108 if (wpa_s->ap_iface == NULL)
1110 hapd = wpa_s->ap_iface->bss[0];
1111 return hostapd_wps_nfc_report_handover(hapd, req, sel);
1114 #endif /* CONFIG_WPS_NFC */
1116 #endif /* CONFIG_WPS */
1119 #ifdef CONFIG_CTRL_IFACE
1121 int ap_ctrl_iface_sta_first(struct wpa_supplicant *wpa_s,
1122 char *buf, size_t buflen)
1124 struct hostapd_data *hapd;
1126 if (wpa_s->ap_iface)
1127 hapd = wpa_s->ap_iface->bss[0];
1128 else if (wpa_s->ifmsh)
1129 hapd = wpa_s->ifmsh->bss[0];
1132 return hostapd_ctrl_iface_sta_first(hapd, buf, buflen);
1136 int ap_ctrl_iface_sta(struct wpa_supplicant *wpa_s, const char *txtaddr,
1137 char *buf, size_t buflen)
1139 struct hostapd_data *hapd;
1141 if (wpa_s->ap_iface)
1142 hapd = wpa_s->ap_iface->bss[0];
1143 else if (wpa_s->ifmsh)
1144 hapd = wpa_s->ifmsh->bss[0];
1147 return hostapd_ctrl_iface_sta(hapd, txtaddr, buf, buflen);
1151 int ap_ctrl_iface_sta_next(struct wpa_supplicant *wpa_s, const char *txtaddr,
1152 char *buf, size_t buflen)
1154 struct hostapd_data *hapd;
1156 if (wpa_s->ap_iface)
1157 hapd = wpa_s->ap_iface->bss[0];
1158 else if (wpa_s->ifmsh)
1159 hapd = wpa_s->ifmsh->bss[0];
1162 return hostapd_ctrl_iface_sta_next(hapd, txtaddr, buf, buflen);
1166 int ap_ctrl_iface_sta_disassociate(struct wpa_supplicant *wpa_s,
1167 const char *txtaddr)
1169 if (wpa_s->ap_iface == NULL)
1171 return hostapd_ctrl_iface_disassociate(wpa_s->ap_iface->bss[0],
1176 int ap_ctrl_iface_sta_deauthenticate(struct wpa_supplicant *wpa_s,
1177 const char *txtaddr)
1179 if (wpa_s->ap_iface == NULL)
1181 return hostapd_ctrl_iface_deauthenticate(wpa_s->ap_iface->bss[0],
1186 int ap_ctrl_iface_wpa_get_status(struct wpa_supplicant *wpa_s, char *buf,
1187 size_t buflen, int verbose)
1189 char *pos = buf, *end = buf + buflen;
1191 struct hostapd_bss_config *conf;
1193 if (wpa_s->ap_iface == NULL)
1196 conf = wpa_s->ap_iface->bss[0]->conf;
1200 ret = os_snprintf(pos, end - pos,
1201 "pairwise_cipher=%s\n"
1204 wpa_cipher_txt(conf->rsn_pairwise),
1205 wpa_cipher_txt(conf->wpa_group),
1206 wpa_key_mgmt_txt(conf->wpa_key_mgmt,
1208 if (os_snprintf_error(end - pos, ret))
1214 #endif /* CONFIG_CTRL_IFACE */
1217 int wpa_supplicant_ap_update_beacon(struct wpa_supplicant *wpa_s)
1219 struct hostapd_iface *iface = wpa_s->ap_iface;
1220 struct wpa_ssid *ssid = wpa_s->current_ssid;
1221 struct hostapd_data *hapd;
1223 if (ssid == NULL || wpa_s->ap_iface == NULL ||
1224 ssid->mode == WPAS_MODE_INFRA ||
1225 ssid->mode == WPAS_MODE_IBSS)
1229 if (ssid->mode == WPAS_MODE_P2P_GO)
1230 iface->conf->bss[0]->p2p = P2P_ENABLED | P2P_GROUP_OWNER;
1231 else if (ssid->mode == WPAS_MODE_P2P_GROUP_FORMATION)
1232 iface->conf->bss[0]->p2p = P2P_ENABLED | P2P_GROUP_OWNER |
1233 P2P_GROUP_FORMATION;
1234 #endif /* CONFIG_P2P */
1236 hapd = iface->bss[0];
1237 if (hapd->drv_priv == NULL)
1239 ieee802_11_set_beacons(iface);
1240 hostapd_set_ap_wps_ie(hapd);
1246 int ap_switch_channel(struct wpa_supplicant *wpa_s,
1247 struct csa_settings *settings)
1250 if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0])
1253 return hostapd_switch_channel(wpa_s->ap_iface->bss[0], settings);
1254 #else /* NEED_AP_MLME */
1256 #endif /* NEED_AP_MLME */
1260 #ifdef CONFIG_CTRL_IFACE
1261 int ap_ctrl_iface_chanswitch(struct wpa_supplicant *wpa_s, const char *pos)
1263 struct csa_settings settings;
1264 int ret = hostapd_parse_csa_settings(pos, &settings);
1269 return ap_switch_channel(wpa_s, &settings);
1271 #endif /* CONFIG_CTRL_IFACE */
1274 void wpas_ap_ch_switch(struct wpa_supplicant *wpa_s, int freq, int ht,
1275 int offset, int width, int cf1, int cf2)
1277 if (!wpa_s->ap_iface)
1280 wpa_s->assoc_freq = freq;
1281 if (wpa_s->current_ssid)
1282 wpa_s->current_ssid->frequency = freq;
1283 hostapd_event_ch_switch(wpa_s->ap_iface->bss[0], freq, ht,
1284 offset, width, cf1, cf2);
1288 int wpa_supplicant_ap_mac_addr_filter(struct wpa_supplicant *wpa_s,
1291 struct hostapd_data *hapd;
1292 struct hostapd_bss_config *conf;
1294 if (!wpa_s->ap_iface)
1298 wpa_printf(MSG_DEBUG, "AP: Set MAC address filter: " MACSTR,
1301 wpa_printf(MSG_DEBUG, "AP: Clear MAC address filter");
1303 hapd = wpa_s->ap_iface->bss[0];
1306 os_free(conf->accept_mac);
1307 conf->accept_mac = NULL;
1308 conf->num_accept_mac = 0;
1309 os_free(conf->deny_mac);
1310 conf->deny_mac = NULL;
1311 conf->num_deny_mac = 0;
1314 conf->macaddr_acl = ACCEPT_UNLESS_DENIED;
1318 conf->macaddr_acl = DENY_UNLESS_ACCEPTED;
1319 conf->accept_mac = os_zalloc(sizeof(struct mac_acl_entry));
1320 if (conf->accept_mac == NULL)
1322 os_memcpy(conf->accept_mac[0].addr, addr, ETH_ALEN);
1323 conf->num_accept_mac = 1;
1329 #ifdef CONFIG_WPS_NFC
1330 int wpas_ap_wps_add_nfc_pw(struct wpa_supplicant *wpa_s, u16 pw_id,
1331 const struct wpabuf *pw, const u8 *pubkey_hash)
1333 struct hostapd_data *hapd;
1334 struct wps_context *wps;
1336 if (!wpa_s->ap_iface)
1338 hapd = wpa_s->ap_iface->bss[0];
1341 if (wpa_s->p2pdev->conf->wps_nfc_dh_pubkey == NULL ||
1342 wpa_s->p2pdev->conf->wps_nfc_dh_privkey == NULL) {
1343 wpa_printf(MSG_DEBUG, "P2P: No NFC DH key known");
1347 dh5_free(wps->dh_ctx);
1348 wpabuf_free(wps->dh_pubkey);
1349 wpabuf_free(wps->dh_privkey);
1350 wps->dh_privkey = wpabuf_dup(
1351 wpa_s->p2pdev->conf->wps_nfc_dh_privkey);
1352 wps->dh_pubkey = wpabuf_dup(
1353 wpa_s->p2pdev->conf->wps_nfc_dh_pubkey);
1354 if (wps->dh_privkey == NULL || wps->dh_pubkey == NULL) {
1356 wpabuf_free(wps->dh_pubkey);
1357 wps->dh_pubkey = NULL;
1358 wpabuf_free(wps->dh_privkey);
1359 wps->dh_privkey = NULL;
1362 wps->dh_ctx = dh5_init_fixed(wps->dh_privkey, wps->dh_pubkey);
1363 if (wps->dh_ctx == NULL)
1366 return wps_registrar_add_nfc_pw_token(hapd->wps->registrar, pubkey_hash,
1368 pw ? wpabuf_head(pw) : NULL,
1369 pw ? wpabuf_len(pw) : 0, 1);
1371 #endif /* CONFIG_WPS_NFC */
1374 #ifdef CONFIG_CTRL_IFACE
1375 int wpas_ap_stop_ap(struct wpa_supplicant *wpa_s)
1377 struct hostapd_data *hapd;
1379 if (!wpa_s->ap_iface)
1381 hapd = wpa_s->ap_iface->bss[0];
1382 return hostapd_ctrl_iface_stop_ap(hapd);
1386 int wpas_ap_pmksa_cache_list(struct wpa_supplicant *wpa_s, char *buf,
1389 size_t reply_len = 0, i;
1390 char ap_delimiter[] = "---- AP ----\n";
1391 char mesh_delimiter[] = "---- mesh ----\n";
1394 if (wpa_s->ap_iface) {
1395 dlen = os_strlen(ap_delimiter);
1396 if (dlen > len - reply_len)
1398 os_memcpy(&buf[reply_len], ap_delimiter, dlen);
1401 for (i = 0; i < wpa_s->ap_iface->num_bss; i++) {
1402 reply_len += hostapd_ctrl_iface_pmksa_list(
1403 wpa_s->ap_iface->bss[i],
1404 &buf[reply_len], len - reply_len);
1409 dlen = os_strlen(mesh_delimiter);
1410 if (dlen > len - reply_len)
1412 os_memcpy(&buf[reply_len], mesh_delimiter, dlen);
1415 reply_len += hostapd_ctrl_iface_pmksa_list(
1416 wpa_s->ifmsh->bss[0], &buf[reply_len],
1424 void wpas_ap_pmksa_cache_flush(struct wpa_supplicant *wpa_s)
1428 if (wpa_s->ap_iface) {
1429 for (i = 0; i < wpa_s->ap_iface->num_bss; i++)
1430 hostapd_ctrl_iface_pmksa_flush(wpa_s->ap_iface->bss[i]);
1434 hostapd_ctrl_iface_pmksa_flush(wpa_s->ifmsh->bss[0]);
1436 #endif /* CONFIG_CTRL_IFACE */
1440 void wpas_event_dfs_radar_detected(struct wpa_supplicant *wpa_s,
1441 struct dfs_event *radar)
1443 if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0])
1445 wpa_printf(MSG_DEBUG, "DFS radar detected on %d MHz", radar->freq);
1446 hostapd_dfs_radar_detected(wpa_s->ap_iface, radar->freq,
1447 radar->ht_enabled, radar->chan_offset,
1449 radar->cf1, radar->cf2);
1453 void wpas_event_dfs_cac_started(struct wpa_supplicant *wpa_s,
1454 struct dfs_event *radar)
1456 if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0])
1458 wpa_printf(MSG_DEBUG, "DFS CAC started on %d MHz", radar->freq);
1459 hostapd_dfs_start_cac(wpa_s->ap_iface, radar->freq,
1460 radar->ht_enabled, radar->chan_offset,
1461 radar->chan_width, radar->cf1, radar->cf2);
1465 void wpas_event_dfs_cac_finished(struct wpa_supplicant *wpa_s,
1466 struct dfs_event *radar)
1468 if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0])
1470 wpa_printf(MSG_DEBUG, "DFS CAC finished on %d MHz", radar->freq);
1471 hostapd_dfs_complete_cac(wpa_s->ap_iface, 1, radar->freq,
1472 radar->ht_enabled, radar->chan_offset,
1473 radar->chan_width, radar->cf1, radar->cf2);
1477 void wpas_event_dfs_cac_aborted(struct wpa_supplicant *wpa_s,
1478 struct dfs_event *radar)
1480 if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0])
1482 wpa_printf(MSG_DEBUG, "DFS CAC aborted on %d MHz", radar->freq);
1483 hostapd_dfs_complete_cac(wpa_s->ap_iface, 0, radar->freq,
1484 radar->ht_enabled, radar->chan_offset,
1485 radar->chan_width, radar->cf1, radar->cf2);
1489 void wpas_event_dfs_cac_nop_finished(struct wpa_supplicant *wpa_s,
1490 struct dfs_event *radar)
1492 if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0])
1494 wpa_printf(MSG_DEBUG, "DFS NOP finished on %d MHz", radar->freq);
1495 hostapd_dfs_nop_finished(wpa_s->ap_iface, radar->freq,
1496 radar->ht_enabled, radar->chan_offset,
1497 radar->chan_width, radar->cf1, radar->cf2);
1499 #endif /* NEED_AP_MLME */
1502 void ap_periodic(struct wpa_supplicant *wpa_s)
1504 if (wpa_s->ap_iface)
1505 hostapd_periodic_iface(wpa_s->ap_iface);