2 * WPA Supplicant - Driver event processing
3 * Copyright (c) 2003-2014, Jouni Malinen <j@w1.fi>
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
12 #include "eapol_supp/eapol_supp_sm.h"
13 #include "rsn_supp/wpa.h"
16 #include "l2_packet/l2_packet.h"
17 #include "wpa_supplicant_i.h"
19 #include "pcsc_funcs.h"
20 #include "rsn_supp/preauth.h"
21 #include "rsn_supp/pmksa_cache.h"
22 #include "common/wpa_ctrl.h"
23 #include "eap_peer/eap.h"
24 #include "ap/hostapd.h"
28 #include "common/ieee802_11_defs.h"
29 #include "common/ieee802_11_common.h"
30 #include "crypto/random.h"
31 #include "blacklist.h"
32 #include "wpas_glue.h"
33 #include "wps_supplicant.h"
36 #include "gas_query.h"
37 #include "p2p_supplicant.h"
43 #include "offchannel.h"
44 #include "interworking.h"
47 #ifndef CONFIG_NO_SCAN_PROCESSING
48 static int wpas_select_network_from_last_scan(struct wpa_supplicant *wpa_s,
49 int new_scan, int own_request);
50 #endif /* CONFIG_NO_SCAN_PROCESSING */
53 static int wpas_temp_disabled(struct wpa_supplicant *wpa_s,
54 struct wpa_ssid *ssid)
56 struct os_reltime now;
58 if (ssid == NULL || ssid->disabled_until.sec == 0)
62 if (ssid->disabled_until.sec > now.sec)
63 return ssid->disabled_until.sec - now.sec;
65 wpas_clear_temp_disabled(wpa_s, ssid, 0);
71 static struct wpa_bss * wpa_supplicant_get_new_bss(
72 struct wpa_supplicant *wpa_s, const u8 *bssid)
74 struct wpa_bss *bss = NULL;
75 struct wpa_ssid *ssid = wpa_s->current_ssid;
77 if (ssid->ssid_len > 0)
78 bss = wpa_bss_get(wpa_s, bssid, ssid->ssid, ssid->ssid_len);
80 bss = wpa_bss_get_bssid(wpa_s, bssid);
86 static void wpa_supplicant_update_current_bss(struct wpa_supplicant *wpa_s)
88 struct wpa_bss *bss = wpa_supplicant_get_new_bss(wpa_s, wpa_s->bssid);
91 wpa_supplicant_update_scan_results(wpa_s);
93 /* Get the BSS from the new scan results */
94 bss = wpa_supplicant_get_new_bss(wpa_s, wpa_s->bssid);
98 wpa_s->current_bss = bss;
102 static int wpa_supplicant_select_config(struct wpa_supplicant *wpa_s)
104 struct wpa_ssid *ssid, *old_ssid;
107 if (wpa_s->conf->ap_scan == 1 && wpa_s->current_ssid) {
108 wpa_supplicant_update_current_bss(wpa_s);
112 wpa_dbg(wpa_s, MSG_DEBUG, "Select network based on association "
114 ssid = wpa_supplicant_get_ssid(wpa_s);
116 wpa_msg(wpa_s, MSG_INFO,
117 "No network configuration found for the current AP");
121 if (wpas_network_disabled(wpa_s, ssid)) {
122 wpa_dbg(wpa_s, MSG_DEBUG, "Selected network is disabled");
126 if (disallowed_bssid(wpa_s, wpa_s->bssid) ||
127 disallowed_ssid(wpa_s, ssid->ssid, ssid->ssid_len)) {
128 wpa_dbg(wpa_s, MSG_DEBUG, "Selected BSS is disallowed");
132 res = wpas_temp_disabled(wpa_s, ssid);
134 wpa_dbg(wpa_s, MSG_DEBUG, "Selected network is temporarily "
135 "disabled for %d second(s)", res);
139 wpa_dbg(wpa_s, MSG_DEBUG, "Network configuration found for the "
141 if (wpa_key_mgmt_wpa_any(ssid->key_mgmt)) {
143 size_t wpa_ie_len = sizeof(wpa_ie);
144 if (wpa_supplicant_set_suites(wpa_s, NULL, ssid,
145 wpa_ie, &wpa_ie_len) < 0)
146 wpa_dbg(wpa_s, MSG_DEBUG, "Could not set WPA suites");
148 wpa_supplicant_set_non_wpa_policy(wpa_s, ssid);
151 if (wpa_s->current_ssid && wpa_s->current_ssid != ssid)
152 eapol_sm_invalidate_cached_session(wpa_s->eapol);
153 old_ssid = wpa_s->current_ssid;
154 wpa_s->current_ssid = ssid;
156 wpa_supplicant_update_current_bss(wpa_s);
158 wpa_supplicant_rsn_supp_set_config(wpa_s, wpa_s->current_ssid);
159 wpa_supplicant_initiate_eapol(wpa_s);
160 if (old_ssid != wpa_s->current_ssid)
161 wpas_notify_network_changed(wpa_s);
167 void wpa_supplicant_stop_countermeasures(void *eloop_ctx, void *sock_ctx)
169 struct wpa_supplicant *wpa_s = eloop_ctx;
171 if (wpa_s->countermeasures) {
172 wpa_s->countermeasures = 0;
173 wpa_drv_set_countermeasures(wpa_s, 0);
174 wpa_msg(wpa_s, MSG_INFO, "WPA: TKIP countermeasures stopped");
175 wpa_supplicant_req_scan(wpa_s, 0, 0);
180 void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s)
184 wnm_bss_keep_alive_deinit(wpa_s);
186 #ifdef CONFIG_IBSS_RSN
187 ibss_rsn_deinit(wpa_s->ibss_rsn);
188 wpa_s->ibss_rsn = NULL;
189 #endif /* CONFIG_IBSS_RSN */
192 wpa_supplicant_ap_deinit(wpa_s);
193 #endif /* CONFIG_AP */
195 if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED)
198 wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
199 bssid_changed = !is_zero_ether_addr(wpa_s->bssid);
200 os_memset(wpa_s->bssid, 0, ETH_ALEN);
201 os_memset(wpa_s->pending_bssid, 0, ETH_ALEN);
203 wpa_s->sme.prev_bssid_set = 0;
204 #endif /* CONFIG_SME */
206 os_memset(wpa_s->go_dev_addr, 0, ETH_ALEN);
207 #endif /* CONFIG_P2P */
208 wpa_s->current_bss = NULL;
209 wpa_s->assoc_freq = 0;
210 #ifdef CONFIG_IEEE80211R
212 if (wpa_s->sme.ft_ies)
213 sme_update_ft_ies(wpa_s, NULL, NULL, 0);
214 #endif /* CONFIG_SME */
215 #endif /* CONFIG_IEEE80211R */
218 wpas_notify_bssid_changed(wpa_s);
220 eapol_sm_notify_portEnabled(wpa_s->eapol, FALSE);
221 eapol_sm_notify_portValid(wpa_s->eapol, FALSE);
222 if (wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt))
223 eapol_sm_notify_eap_success(wpa_s->eapol, FALSE);
224 wpa_s->ap_ies_from_associnfo = 0;
225 wpa_s->current_ssid = NULL;
226 eapol_sm_notify_config(wpa_s->eapol, NULL, NULL);
231 static void wpa_find_assoc_pmkid(struct wpa_supplicant *wpa_s)
233 struct wpa_ie_data ie;
237 if (wpa_sm_parse_own_wpa_ie(wpa_s->wpa, &ie) < 0 ||
241 for (i = 0; i < ie.num_pmkid; i++) {
242 pmksa_set = pmksa_cache_set_current(wpa_s->wpa,
243 ie.pmkid + i * PMKID_LEN,
245 if (pmksa_set == 0) {
246 eapol_sm_notify_pmkid_attempt(wpa_s->eapol, 1);
251 wpa_dbg(wpa_s, MSG_DEBUG, "RSN: PMKID from assoc IE %sfound from "
252 "PMKSA cache", pmksa_set == 0 ? "" : "not ");
256 static void wpa_supplicant_event_pmkid_candidate(struct wpa_supplicant *wpa_s,
257 union wpa_event_data *data)
260 wpa_dbg(wpa_s, MSG_DEBUG, "RSN: No data in PMKID candidate "
264 wpa_dbg(wpa_s, MSG_DEBUG, "RSN: PMKID candidate event - bssid=" MACSTR
265 " index=%d preauth=%d",
266 MAC2STR(data->pmkid_candidate.bssid),
267 data->pmkid_candidate.index,
268 data->pmkid_candidate.preauth);
270 pmksa_candidate_add(wpa_s->wpa, data->pmkid_candidate.bssid,
271 data->pmkid_candidate.index,
272 data->pmkid_candidate.preauth);
276 static int wpa_supplicant_dynamic_keys(struct wpa_supplicant *wpa_s)
278 if (wpa_s->key_mgmt == WPA_KEY_MGMT_NONE ||
279 wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE)
282 #ifdef IEEE8021X_EAPOL
283 if (wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA &&
284 wpa_s->current_ssid &&
285 !(wpa_s->current_ssid->eapol_flags &
286 (EAPOL_FLAG_REQUIRE_KEY_UNICAST |
287 EAPOL_FLAG_REQUIRE_KEY_BROADCAST))) {
288 /* IEEE 802.1X, but not using dynamic WEP keys (i.e., either
289 * plaintext or static WEP keys). */
292 #endif /* IEEE8021X_EAPOL */
299 * wpa_supplicant_scard_init - Initialize SIM/USIM access with PC/SC
300 * @wpa_s: pointer to wpa_supplicant data
301 * @ssid: Configuration data for the network
302 * Returns: 0 on success, -1 on failure
304 * This function is called when starting authentication with a network that is
305 * configured to use PC/SC for SIM/USIM access (EAP-SIM or EAP-AKA).
307 int wpa_supplicant_scard_init(struct wpa_supplicant *wpa_s,
308 struct wpa_ssid *ssid)
310 #ifdef IEEE8021X_EAPOL
312 int aka = 0, sim = 0;
314 if ((ssid != NULL && ssid->eap.pcsc == NULL) ||
315 wpa_s->scard != NULL || wpa_s->conf->external_sim)
318 if (ssid == NULL || ssid->eap.eap_methods == NULL) {
322 struct eap_method_type *eap = ssid->eap.eap_methods;
323 while (eap->vendor != EAP_VENDOR_IETF ||
324 eap->method != EAP_TYPE_NONE) {
325 if (eap->vendor == EAP_VENDOR_IETF) {
326 if (eap->method == EAP_TYPE_SIM)
328 else if (eap->method == EAP_TYPE_AKA ||
329 eap->method == EAP_TYPE_AKA_PRIME)
336 if (eap_peer_get_eap_method(EAP_VENDOR_IETF, EAP_TYPE_SIM) == NULL)
338 if (eap_peer_get_eap_method(EAP_VENDOR_IETF, EAP_TYPE_AKA) == NULL &&
339 eap_peer_get_eap_method(EAP_VENDOR_IETF, EAP_TYPE_AKA_PRIME) ==
344 wpa_dbg(wpa_s, MSG_DEBUG, "Selected network is configured to "
345 "use SIM, but neither EAP-SIM nor EAP-AKA are "
350 wpa_dbg(wpa_s, MSG_DEBUG, "Selected network is configured to use SIM "
351 "(sim=%d aka=%d) - initialize PCSC", sim, aka);
353 wpa_s->scard = scard_init(wpa_s->conf->pcsc_reader);
354 if (wpa_s->scard == NULL) {
355 wpa_msg(wpa_s, MSG_WARNING, "Failed to initialize SIM "
359 wpa_sm_set_scard_ctx(wpa_s->wpa, wpa_s->scard);
360 eapol_sm_register_scard_ctx(wpa_s->eapol, wpa_s->scard);
361 #endif /* PCSC_FUNCS */
362 #endif /* IEEE8021X_EAPOL */
368 #ifndef CONFIG_NO_SCAN_PROCESSING
370 static int has_wep_key(struct wpa_ssid *ssid)
374 for (i = 0; i < NUM_WEP_KEYS; i++) {
375 if (ssid->wep_key_len[i])
383 static int wpa_supplicant_match_privacy(struct wpa_bss *bss,
384 struct wpa_ssid *ssid)
388 if (ssid->mixed_cell)
392 if (ssid->key_mgmt & WPA_KEY_MGMT_WPS)
394 #endif /* CONFIG_WPS */
396 if (has_wep_key(ssid))
399 #ifdef IEEE8021X_EAPOL
400 if ((ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X_NO_WPA) &&
401 ssid->eapol_flags & (EAPOL_FLAG_REQUIRE_KEY_UNICAST |
402 EAPOL_FLAG_REQUIRE_KEY_BROADCAST))
404 #endif /* IEEE8021X_EAPOL */
406 if (wpa_key_mgmt_wpa(ssid->key_mgmt))
409 if (ssid->key_mgmt & WPA_KEY_MGMT_OSEN)
412 if (bss->caps & IEEE80211_CAP_PRIVACY)
418 static int wpa_supplicant_ssid_bss_match(struct wpa_supplicant *wpa_s,
419 struct wpa_ssid *ssid,
422 struct wpa_ie_data ie;
424 const u8 *rsn_ie, *wpa_ie;
428 ret = wpas_wps_ssid_bss_match(wpa_s, ssid, bss);
432 /* Allow TSN if local configuration accepts WEP use without WPA/WPA2 */
433 wep_ok = !wpa_key_mgmt_wpa(ssid->key_mgmt) &&
434 (((ssid->key_mgmt & WPA_KEY_MGMT_NONE) &&
435 ssid->wep_key_len[ssid->wep_tx_keyidx] > 0) ||
436 (ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X_NO_WPA));
438 rsn_ie = wpa_bss_get_ie(bss, WLAN_EID_RSN);
439 while ((ssid->proto & WPA_PROTO_RSN) && rsn_ie) {
442 if (wpa_parse_wpa_ie(rsn_ie, 2 + rsn_ie[1], &ie)) {
443 wpa_dbg(wpa_s, MSG_DEBUG, " skip RSN IE - parse "
449 (ie.group_cipher & (WPA_CIPHER_WEP40 | WPA_CIPHER_WEP104)))
451 wpa_dbg(wpa_s, MSG_DEBUG, " selected based on TSN "
456 if (!(ie.proto & ssid->proto)) {
457 wpa_dbg(wpa_s, MSG_DEBUG, " skip RSN IE - proto "
462 if (!(ie.pairwise_cipher & ssid->pairwise_cipher)) {
463 wpa_dbg(wpa_s, MSG_DEBUG, " skip RSN IE - PTK "
468 if (!(ie.group_cipher & ssid->group_cipher)) {
469 wpa_dbg(wpa_s, MSG_DEBUG, " skip RSN IE - GTK "
474 if (!(ie.key_mgmt & ssid->key_mgmt)) {
475 wpa_dbg(wpa_s, MSG_DEBUG, " skip RSN IE - key mgmt "
480 #ifdef CONFIG_IEEE80211W
481 if (!(ie.capabilities & WPA_CAPABILITY_MFPC) &&
482 (ssid->ieee80211w == MGMT_FRAME_PROTECTION_DEFAULT ?
483 wpa_s->conf->pmf : ssid->ieee80211w) ==
484 MGMT_FRAME_PROTECTION_REQUIRED) {
485 wpa_dbg(wpa_s, MSG_DEBUG, " skip RSN IE - no mgmt "
489 #endif /* CONFIG_IEEE80211W */
491 wpa_dbg(wpa_s, MSG_DEBUG, " selected based on RSN IE");
495 wpa_ie = wpa_bss_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE);
496 while ((ssid->proto & WPA_PROTO_WPA) && wpa_ie) {
499 if (wpa_parse_wpa_ie(wpa_ie, 2 + wpa_ie[1], &ie)) {
500 wpa_dbg(wpa_s, MSG_DEBUG, " skip WPA IE - parse "
506 (ie.group_cipher & (WPA_CIPHER_WEP40 | WPA_CIPHER_WEP104)))
508 wpa_dbg(wpa_s, MSG_DEBUG, " selected based on TSN "
513 if (!(ie.proto & ssid->proto)) {
514 wpa_dbg(wpa_s, MSG_DEBUG, " skip WPA IE - proto "
519 if (!(ie.pairwise_cipher & ssid->pairwise_cipher)) {
520 wpa_dbg(wpa_s, MSG_DEBUG, " skip WPA IE - PTK "
525 if (!(ie.group_cipher & ssid->group_cipher)) {
526 wpa_dbg(wpa_s, MSG_DEBUG, " skip WPA IE - GTK "
531 if (!(ie.key_mgmt & ssid->key_mgmt)) {
532 wpa_dbg(wpa_s, MSG_DEBUG, " skip WPA IE - key mgmt "
537 wpa_dbg(wpa_s, MSG_DEBUG, " selected based on WPA IE");
541 if ((ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X_NO_WPA) && !wpa_ie &&
543 wpa_dbg(wpa_s, MSG_DEBUG, " allow for non-WPA IEEE 802.1X");
547 if ((ssid->proto & (WPA_PROTO_WPA | WPA_PROTO_RSN)) &&
548 wpa_key_mgmt_wpa(ssid->key_mgmt) && proto_match == 0) {
549 wpa_dbg(wpa_s, MSG_DEBUG, " skip - no WPA/RSN proto match");
553 if ((ssid->key_mgmt & WPA_KEY_MGMT_OSEN) &&
554 wpa_bss_get_vendor_ie(bss, OSEN_IE_VENDOR_TYPE)) {
555 wpa_dbg(wpa_s, MSG_DEBUG, " allow in OSEN");
559 if (!wpa_key_mgmt_wpa(ssid->key_mgmt)) {
560 wpa_dbg(wpa_s, MSG_DEBUG, " allow in non-WPA/WPA2");
564 wpa_dbg(wpa_s, MSG_DEBUG, " reject due to mismatch with "
571 static int freq_allowed(int *freqs, int freq)
578 for (i = 0; freqs[i]; i++)
579 if (freqs[i] == freq)
585 static int ht_supported(const struct hostapd_hw_modes *mode)
587 if (!(mode->flags & HOSTAPD_MODE_FLAG_HT_INFO_KNOWN)) {
589 * The driver did not indicate whether it supports HT. Assume
590 * it does to avoid connection issues.
596 * IEEE Std 802.11n-2009 20.1.1:
597 * An HT non-AP STA shall support all EQM rates for one spatial stream.
599 return mode->mcs_set[0] == 0xff;
603 static int vht_supported(const struct hostapd_hw_modes *mode)
605 if (!(mode->flags & HOSTAPD_MODE_FLAG_VHT_INFO_KNOWN)) {
607 * The driver did not indicate whether it supports VHT. Assume
608 * it does to avoid connection issues.
614 * A VHT non-AP STA shall support MCS 0-7 for one spatial stream.
615 * TODO: Verify if this complies with the standard
617 return (mode->vht_mcs_set[0] & 0x3) != 3;
621 static int rate_match(struct wpa_supplicant *wpa_s, struct wpa_bss *bss)
623 const struct hostapd_hw_modes *mode = NULL, *modes;
624 const u8 scan_ie[2] = { WLAN_EID_SUPP_RATES, WLAN_EID_EXT_SUPP_RATES };
629 return 1; /* Cannot do matching without knowing band */
631 modes = wpa_s->hw.modes;
634 * The driver does not provide any additional information
635 * about the utilized hardware, so allow the connection attempt
641 for (i = 0; i < wpa_s->hw.num_modes; i++) {
642 for (j = 0; j < modes[i].num_channels; j++) {
643 int freq = modes[i].channels[j].freq;
644 if (freq == bss->freq) {
646 mode->mode == HOSTAPD_MODE_IEEE80211G)
647 break; /* do not allow 802.11b replace
658 for (i = 0; i < (int) sizeof(scan_ie); i++) {
659 rate_ie = wpa_bss_get_ie(bss, scan_ie[i]);
663 for (j = 2; j < rate_ie[1] + 2; j++) {
664 int flagged = !!(rate_ie[j] & 0x80);
665 int r = (rate_ie[j] & 0x7f) * 5;
668 * IEEE Std 802.11n-2009 7.3.2.2:
669 * The new BSS Membership selector value is encoded
670 * like a legacy basic rate, but it is not a rate and
671 * only indicates if the BSS members are required to
672 * support the mandatory features of Clause 20 [HT PHY]
673 * in order to join the BSS.
675 if (flagged && ((rate_ie[j] & 0x7f) ==
676 BSS_MEMBERSHIP_SELECTOR_HT_PHY)) {
677 if (!ht_supported(mode)) {
678 wpa_dbg(wpa_s, MSG_DEBUG,
679 " hardware does not support "
686 /* There's also a VHT selector for 802.11ac */
687 if (flagged && ((rate_ie[j] & 0x7f) ==
688 BSS_MEMBERSHIP_SELECTOR_VHT_PHY)) {
689 if (!vht_supported(mode)) {
690 wpa_dbg(wpa_s, MSG_DEBUG,
691 " hardware does not support "
701 /* check for legacy basic rates */
702 for (k = 0; k < mode->num_rates; k++) {
703 if (mode->rates[k] == r)
706 if (k == mode->num_rates) {
708 * IEEE Std 802.11-2007 7.3.2.2 demands that in
709 * order to join a BSS all required rates
710 * have to be supported by the hardware.
712 wpa_dbg(wpa_s, MSG_DEBUG, " hardware does "
713 "not support required rate %d.%d Mbps",
725 * Test whether BSS is in an ESS.
726 * This is done differently in DMG (60 GHz) and non-DMG bands
728 static int bss_is_ess(struct wpa_bss *bss)
730 if (bss_is_dmg(bss)) {
731 return (bss->caps & IEEE80211_CAP_DMG_MASK) ==
732 IEEE80211_CAP_DMG_AP;
735 return ((bss->caps & (IEEE80211_CAP_ESS | IEEE80211_CAP_IBSS)) ==
740 static struct wpa_ssid * wpa_scan_res_match(struct wpa_supplicant *wpa_s,
741 int i, struct wpa_bss *bss,
742 struct wpa_ssid *group,
745 u8 wpa_ie_len, rsn_ie_len;
747 struct wpa_blacklist *e;
749 struct wpa_ssid *ssid;
752 ie = wpa_bss_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE);
753 wpa_ie_len = ie ? ie[1] : 0;
755 ie = wpa_bss_get_ie(bss, WLAN_EID_RSN);
756 rsn_ie_len = ie ? ie[1] : 0;
758 ie = wpa_bss_get_vendor_ie(bss, OSEN_IE_VENDOR_TYPE);
761 wpa_dbg(wpa_s, MSG_DEBUG, "%d: " MACSTR " ssid='%s' "
762 "wpa_ie_len=%u rsn_ie_len=%u caps=0x%x level=%d%s%s%s",
763 i, MAC2STR(bss->bssid), wpa_ssid_txt(bss->ssid, bss->ssid_len),
764 wpa_ie_len, rsn_ie_len, bss->caps, bss->level,
765 wpa_bss_get_vendor_ie(bss, WPS_IE_VENDOR_TYPE) ? " wps" : "",
766 (wpa_bss_get_vendor_ie(bss, P2P_IE_VENDOR_TYPE) ||
767 wpa_bss_get_vendor_ie_beacon(bss, P2P_IE_VENDOR_TYPE)) ?
769 osen ? " osen=1" : "");
771 e = wpa_blacklist_get(wpa_s, bss->bssid);
774 if (wpa_supplicant_enabled_networks(wpa_s) == 1) {
776 * When only a single network is enabled, we can
777 * trigger blacklisting on the first failure. This
778 * should not be done with multiple enabled networks to
779 * avoid getting forced to move into a worse ESS on
780 * single error if there are no other BSSes of the
785 if (e->count > limit) {
786 wpa_dbg(wpa_s, MSG_DEBUG, " skip - blacklisted "
787 "(count=%d limit=%d)", e->count, limit);
792 if (bss->ssid_len == 0) {
793 wpa_dbg(wpa_s, MSG_DEBUG, " skip - SSID not known");
797 if (disallowed_bssid(wpa_s, bss->bssid)) {
798 wpa_dbg(wpa_s, MSG_DEBUG, " skip - BSSID disallowed");
802 if (disallowed_ssid(wpa_s, bss->ssid, bss->ssid_len)) {
803 wpa_dbg(wpa_s, MSG_DEBUG, " skip - SSID disallowed");
807 wpa = wpa_ie_len > 0 || rsn_ie_len > 0;
809 for (ssid = group; ssid; ssid = only_first_ssid ? NULL : ssid->pnext) {
810 int check_ssid = wpa ? 1 : (ssid->ssid_len != 0);
813 if (wpas_network_disabled(wpa_s, ssid)) {
814 wpa_dbg(wpa_s, MSG_DEBUG, " skip - disabled");
818 res = wpas_temp_disabled(wpa_s, ssid);
820 wpa_dbg(wpa_s, MSG_DEBUG, " skip - disabled "
821 "temporarily for %d second(s)", res);
826 if ((ssid->key_mgmt & WPA_KEY_MGMT_WPS) && e && e->count > 0) {
827 wpa_dbg(wpa_s, MSG_DEBUG, " skip - blacklisted "
832 if (wpa && ssid->ssid_len == 0 &&
833 wpas_wps_ssid_wildcard_ok(wpa_s, ssid, bss))
836 if (!wpa && (ssid->key_mgmt & WPA_KEY_MGMT_WPS)) {
837 /* Only allow wildcard SSID match if an AP
838 * advertises active WPS operation that matches
841 if (ssid->ssid_len == 0 &&
842 wpas_wps_ssid_wildcard_ok(wpa_s, ssid, bss))
845 #endif /* CONFIG_WPS */
847 if (ssid->bssid_set && ssid->ssid_len == 0 &&
848 os_memcmp(bss->bssid, ssid->bssid, ETH_ALEN) == 0)
852 (bss->ssid_len != ssid->ssid_len ||
853 os_memcmp(bss->ssid, ssid->ssid, bss->ssid_len) != 0)) {
854 wpa_dbg(wpa_s, MSG_DEBUG, " skip - SSID mismatch");
858 if (ssid->bssid_set &&
859 os_memcmp(bss->bssid, ssid->bssid, ETH_ALEN) != 0) {
860 wpa_dbg(wpa_s, MSG_DEBUG, " skip - BSSID mismatch");
864 if (!wpa_supplicant_ssid_bss_match(wpa_s, ssid, bss))
868 !(ssid->key_mgmt & WPA_KEY_MGMT_NONE) &&
869 !(ssid->key_mgmt & WPA_KEY_MGMT_WPS) &&
870 !(ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X_NO_WPA)) {
871 wpa_dbg(wpa_s, MSG_DEBUG, " skip - non-WPA network "
876 if (wpa && !wpa_key_mgmt_wpa(ssid->key_mgmt) &&
878 wpa_dbg(wpa_s, MSG_DEBUG, " skip - ignore WPA/WPA2 AP for WEP network block");
882 if ((ssid->key_mgmt & WPA_KEY_MGMT_OSEN) && !osen) {
883 wpa_dbg(wpa_s, MSG_DEBUG, " skip - non-OSEN network "
888 if (!wpa_supplicant_match_privacy(bss, ssid)) {
889 wpa_dbg(wpa_s, MSG_DEBUG, " skip - privacy "
894 if (!bss_is_ess(bss)) {
895 wpa_dbg(wpa_s, MSG_DEBUG, " skip - not ESS network");
899 if (!freq_allowed(ssid->freq_list, bss->freq)) {
900 wpa_dbg(wpa_s, MSG_DEBUG, " skip - frequency not "
905 if (!rate_match(wpa_s, bss)) {
906 wpa_dbg(wpa_s, MSG_DEBUG, " skip - rate sets do "
912 if (ssid->p2p_group &&
913 !wpa_bss_get_vendor_ie(bss, P2P_IE_VENDOR_TYPE) &&
914 !wpa_bss_get_vendor_ie_beacon(bss, P2P_IE_VENDOR_TYPE)) {
915 wpa_dbg(wpa_s, MSG_DEBUG, " skip - no P2P IE seen");
919 if (!is_zero_ether_addr(ssid->go_p2p_dev_addr)) {
920 struct wpabuf *p2p_ie;
921 u8 dev_addr[ETH_ALEN];
923 ie = wpa_bss_get_vendor_ie(bss, P2P_IE_VENDOR_TYPE);
925 wpa_dbg(wpa_s, MSG_DEBUG, " skip - no P2P element");
928 p2p_ie = wpa_bss_get_vendor_ie_multi(
929 bss, P2P_IE_VENDOR_TYPE);
930 if (p2p_ie == NULL) {
931 wpa_dbg(wpa_s, MSG_DEBUG, " skip - could not fetch P2P element");
935 if (p2p_parse_dev_addr_in_p2p_ie(p2p_ie, dev_addr) < 0
936 || os_memcmp(dev_addr, ssid->go_p2p_dev_addr,
938 wpa_dbg(wpa_s, MSG_DEBUG, " skip - no matching GO P2P Device Address in P2P element");
946 * TODO: skip the AP if its P2P IE has Group Formation
947 * bit set in the P2P Group Capability Bitmap and we
948 * are not in Group Formation with that device.
950 #endif /* CONFIG_P2P */
952 /* Matching configuration found */
956 /* No matching configuration found */
961 static struct wpa_bss *
962 wpa_supplicant_select_bss(struct wpa_supplicant *wpa_s,
963 struct wpa_ssid *group,
964 struct wpa_ssid **selected_ssid,
970 wpa_dbg(wpa_s, MSG_DEBUG, "Try to find BSS matching pre-selected network id=%d",
973 wpa_dbg(wpa_s, MSG_DEBUG, "Selecting BSS from priority group %d",
976 for (i = 0; i < wpa_s->last_scan_res_used; i++) {
977 struct wpa_bss *bss = wpa_s->last_scan_res[i];
978 *selected_ssid = wpa_scan_res_match(wpa_s, i, bss, group,
982 wpa_dbg(wpa_s, MSG_DEBUG, " selected BSS " MACSTR
985 wpa_ssid_txt(bss->ssid, bss->ssid_len));
993 struct wpa_bss * wpa_supplicant_pick_network(struct wpa_supplicant *wpa_s,
994 struct wpa_ssid **selected_ssid)
996 struct wpa_bss *selected = NULL;
998 struct wpa_ssid *next_ssid = NULL;
1000 if (wpa_s->last_scan_res == NULL ||
1001 wpa_s->last_scan_res_used == 0)
1002 return NULL; /* no scan results from last update */
1004 if (wpa_s->next_ssid) {
1005 struct wpa_ssid *ssid;
1007 /* check that next_ssid is still valid */
1008 for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next) {
1009 if (ssid == wpa_s->next_ssid)
1013 wpa_s->next_ssid = NULL;
1016 while (selected == NULL) {
1017 for (prio = 0; prio < wpa_s->conf->num_prio; prio++) {
1018 if (next_ssid && next_ssid->priority ==
1019 wpa_s->conf->pssid[prio]->priority) {
1020 selected = wpa_supplicant_select_bss(
1021 wpa_s, next_ssid, selected_ssid, 1);
1025 selected = wpa_supplicant_select_bss(
1026 wpa_s, wpa_s->conf->pssid[prio],
1032 if (selected == NULL && wpa_s->blacklist &&
1033 !wpa_s->countermeasures) {
1034 wpa_dbg(wpa_s, MSG_DEBUG, "No APs found - clear "
1035 "blacklist and try again");
1036 wpa_blacklist_clear(wpa_s);
1037 wpa_s->blacklist_cleared++;
1038 } else if (selected == NULL)
1046 static void wpa_supplicant_req_new_scan(struct wpa_supplicant *wpa_s,
1047 int timeout_sec, int timeout_usec)
1049 if (!wpa_supplicant_enabled_networks(wpa_s)) {
1051 * No networks are enabled; short-circuit request so
1052 * we don't wait timeout seconds before transitioning
1053 * to INACTIVE state.
1055 wpa_dbg(wpa_s, MSG_DEBUG, "Short-circuit new scan request "
1056 "since there are no enabled networks");
1057 wpa_supplicant_set_state(wpa_s, WPA_INACTIVE);
1061 wpa_s->scan_for_connection = 1;
1062 wpa_supplicant_req_scan(wpa_s, timeout_sec, timeout_usec);
1066 int wpa_supplicant_connect(struct wpa_supplicant *wpa_s,
1067 struct wpa_bss *selected,
1068 struct wpa_ssid *ssid)
1070 if (wpas_wps_scan_pbc_overlap(wpa_s, selected, ssid)) {
1071 wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_OVERLAP
1072 "PBC session overlap");
1074 if (wpa_s->p2p_group_interface == P2P_GROUP_INTERFACE_CLIENT ||
1075 wpa_s->p2p_in_provisioning) {
1076 eloop_register_timeout(0, 0, wpas_p2p_pbc_overlap_cb,
1080 #endif /* CONFIG_P2P */
1083 wpas_wps_cancel(wpa_s);
1084 #endif /* CONFIG_WPS */
1088 wpa_msg(wpa_s, MSG_DEBUG,
1089 "Considering connect request: reassociate: %d selected: "
1090 MACSTR " bssid: " MACSTR " pending: " MACSTR
1091 " wpa_state: %s ssid=%p current_ssid=%p",
1092 wpa_s->reassociate, MAC2STR(selected->bssid),
1093 MAC2STR(wpa_s->bssid), MAC2STR(wpa_s->pending_bssid),
1094 wpa_supplicant_state_txt(wpa_s->wpa_state),
1095 ssid, wpa_s->current_ssid);
1098 * Do not trigger new association unless the BSSID has changed or if
1099 * reassociation is requested. If we are in process of associating with
1100 * the selected BSSID, do not trigger new attempt.
1102 if (wpa_s->reassociate ||
1103 (os_memcmp(selected->bssid, wpa_s->bssid, ETH_ALEN) != 0 &&
1104 ((wpa_s->wpa_state != WPA_ASSOCIATING &&
1105 wpa_s->wpa_state != WPA_AUTHENTICATING) ||
1106 (!is_zero_ether_addr(wpa_s->pending_bssid) &&
1107 os_memcmp(selected->bssid, wpa_s->pending_bssid, ETH_ALEN) !=
1109 (is_zero_ether_addr(wpa_s->pending_bssid) &&
1110 ssid != wpa_s->current_ssid)))) {
1111 if (wpa_supplicant_scard_init(wpa_s, ssid)) {
1112 wpa_supplicant_req_new_scan(wpa_s, 10, 0);
1115 wpa_msg(wpa_s, MSG_DEBUG, "Request association with " MACSTR,
1116 MAC2STR(selected->bssid));
1117 wpa_supplicant_associate(wpa_s, selected, ssid);
1119 wpa_dbg(wpa_s, MSG_DEBUG, "Already associated or trying to "
1120 "connect with the selected AP");
1127 static struct wpa_ssid *
1128 wpa_supplicant_pick_new_network(struct wpa_supplicant *wpa_s)
1131 struct wpa_ssid *ssid;
1133 for (prio = 0; prio < wpa_s->conf->num_prio; prio++) {
1134 for (ssid = wpa_s->conf->pssid[prio]; ssid; ssid = ssid->pnext)
1136 if (wpas_network_disabled(wpa_s, ssid))
1138 if (ssid->mode == IEEE80211_MODE_IBSS ||
1139 ssid->mode == IEEE80211_MODE_AP)
1147 /* TODO: move the rsn_preauth_scan_result*() to be called from notify.c based
1148 * on BSS added and BSS changed events */
1149 static void wpa_supplicant_rsn_preauth_scan_results(
1150 struct wpa_supplicant *wpa_s)
1152 struct wpa_bss *bss;
1154 if (rsn_preauth_scan_results(wpa_s->wpa) < 0)
1157 dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) {
1158 const u8 *ssid, *rsn;
1160 ssid = wpa_bss_get_ie(bss, WLAN_EID_SSID);
1164 rsn = wpa_bss_get_ie(bss, WLAN_EID_RSN);
1168 rsn_preauth_scan_result(wpa_s->wpa, bss->bssid, ssid, rsn);
1174 static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s,
1175 struct wpa_bss *selected,
1176 struct wpa_ssid *ssid)
1178 struct wpa_bss *current_bss = NULL;
1181 if (wpa_s->reassociate)
1182 return 1; /* explicit request to reassociate */
1183 if (wpa_s->wpa_state < WPA_ASSOCIATED)
1184 return 1; /* we are not associated; continue */
1185 if (wpa_s->current_ssid == NULL)
1186 return 1; /* unknown current SSID */
1187 if (wpa_s->current_ssid != ssid)
1188 return 1; /* different network block */
1190 if (wpas_driver_bss_selection(wpa_s))
1191 return 0; /* Driver-based roaming */
1193 if (wpa_s->current_ssid->ssid)
1194 current_bss = wpa_bss_get(wpa_s, wpa_s->bssid,
1195 wpa_s->current_ssid->ssid,
1196 wpa_s->current_ssid->ssid_len);
1198 current_bss = wpa_bss_get_bssid(wpa_s, wpa_s->bssid);
1201 return 1; /* current BSS not seen in scan results */
1203 if (current_bss == selected)
1206 if (selected->last_update_idx > current_bss->last_update_idx)
1207 return 1; /* current BSS not seen in the last scan */
1209 #ifndef CONFIG_NO_ROAMING
1210 wpa_dbg(wpa_s, MSG_DEBUG, "Considering within-ESS reassociation");
1211 wpa_dbg(wpa_s, MSG_DEBUG, "Current BSS: " MACSTR " level=%d",
1212 MAC2STR(current_bss->bssid), current_bss->level);
1213 wpa_dbg(wpa_s, MSG_DEBUG, "Selected BSS: " MACSTR " level=%d",
1214 MAC2STR(selected->bssid), selected->level);
1216 if (wpa_s->current_ssid->bssid_set &&
1217 os_memcmp(selected->bssid, wpa_s->current_ssid->bssid, ETH_ALEN) ==
1219 wpa_dbg(wpa_s, MSG_DEBUG, "Allow reassociation - selected BSS "
1220 "has preferred BSSID");
1224 if (current_bss->level < 0 && current_bss->level > selected->level) {
1225 wpa_dbg(wpa_s, MSG_DEBUG, "Skip roam - Current BSS has better "
1231 if (current_bss->level < 0) {
1232 if (current_bss->level < -85)
1234 else if (current_bss->level < -80)
1236 else if (current_bss->level < -75)
1238 else if (current_bss->level < -70)
1243 if (abs(current_bss->level - selected->level) < min_diff) {
1244 wpa_dbg(wpa_s, MSG_DEBUG, "Skip roam - too small difference "
1250 #else /* CONFIG_NO_ROAMING */
1252 #endif /* CONFIG_NO_ROAMING */
1256 /* Return != 0 if no scan results could be fetched or if scan results should not
1257 * be shared with other virtual interfaces. */
1258 static int _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s,
1259 union wpa_event_data *data,
1262 struct wpa_scan_results *scan_res = NULL;
1265 #ifndef CONFIG_NO_RANDOM_POOL
1267 #endif /* CONFIG_NO_RANDOM_POOL */
1270 if (wpa_s->ap_iface)
1272 #endif /* CONFIG_AP */
1274 wpa_supplicant_notify_scanning(wpa_s, 0);
1276 scan_res = wpa_supplicant_get_scan_results(wpa_s,
1277 data ? &data->scan_info :
1279 if (scan_res == NULL) {
1280 if (wpa_s->conf->ap_scan == 2 || ap ||
1281 wpa_s->scan_res_handler == scan_only_handler)
1285 wpa_dbg(wpa_s, MSG_DEBUG, "Failed to get scan results - try "
1287 wpa_supplicant_req_new_scan(wpa_s, 1, 0);
1289 goto scan_work_done;
1292 #ifndef CONFIG_NO_RANDOM_POOL
1293 num = scan_res->num;
1296 for (i = 0; i < num; i++) {
1298 struct wpa_scan_res *res = scan_res->res[i];
1299 buf[0] = res->bssid[5];
1300 buf[1] = res->qual & 0xff;
1301 buf[2] = res->noise & 0xff;
1302 buf[3] = res->level & 0xff;
1303 buf[4] = res->tsf & 0xff;
1304 random_add_randomness(buf, sizeof(buf));
1306 #endif /* CONFIG_NO_RANDOM_POOL */
1308 if (own_request && wpa_s->scan_res_handler &&
1309 (wpa_s->own_scan_running || !wpa_s->external_scan_running)) {
1310 void (*scan_res_handler)(struct wpa_supplicant *wpa_s,
1311 struct wpa_scan_results *scan_res);
1313 scan_res_handler = wpa_s->scan_res_handler;
1314 wpa_s->scan_res_handler = NULL;
1315 scan_res_handler(wpa_s, scan_res);
1317 goto scan_work_done;
1321 wpa_dbg(wpa_s, MSG_DEBUG, "Ignore scan results in AP mode");
1323 if (wpa_s->ap_iface->scan_cb)
1324 wpa_s->ap_iface->scan_cb(wpa_s->ap_iface);
1325 #endif /* CONFIG_AP */
1326 goto scan_work_done;
1329 wpa_dbg(wpa_s, MSG_DEBUG, "New scan results available (own=%u ext=%u)",
1330 wpa_s->own_scan_running, wpa_s->external_scan_running);
1331 if (wpa_s->last_scan_req == MANUAL_SCAN_REQ &&
1332 wpa_s->manual_scan_use_id && wpa_s->own_scan_running) {
1333 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_SCAN_RESULTS "id=%u",
1334 wpa_s->manual_scan_id);
1335 wpa_s->manual_scan_use_id = 0;
1337 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_SCAN_RESULTS);
1339 wpas_notify_scan_results(wpa_s);
1341 wpas_notify_scan_done(wpa_s, 1);
1343 if (!wpa_s->own_scan_running && wpa_s->external_scan_running) {
1344 wpa_dbg(wpa_s, MSG_DEBUG, "Do not use results from externally requested scan operation for network selection");
1345 wpa_scan_results_free(scan_res);
1349 if (sme_proc_obss_scan(wpa_s) > 0)
1350 goto scan_work_done;
1352 if ((wpa_s->conf->ap_scan == 2 && !wpas_wps_searching(wpa_s)))
1353 goto scan_work_done;
1355 if (autoscan_notify_scan(wpa_s, scan_res))
1356 goto scan_work_done;
1358 if (wpa_s->disconnected) {
1359 wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
1360 goto scan_work_done;
1363 if (!wpas_driver_bss_selection(wpa_s) &&
1364 bgscan_notify_scan(wpa_s, scan_res) == 1)
1365 goto scan_work_done;
1367 wpas_wps_update_ap_info(wpa_s, scan_res);
1369 wpa_scan_results_free(scan_res);
1371 if (wpa_s->scan_work) {
1372 struct wpa_radio_work *work = wpa_s->scan_work;
1373 wpa_s->scan_work = NULL;
1374 radio_work_done(work);
1377 return wpas_select_network_from_last_scan(wpa_s, 1, own_request);
1380 wpa_scan_results_free(scan_res);
1381 if (wpa_s->scan_work) {
1382 struct wpa_radio_work *work = wpa_s->scan_work;
1383 wpa_s->scan_work = NULL;
1384 radio_work_done(work);
1390 static int wpas_select_network_from_last_scan(struct wpa_supplicant *wpa_s,
1391 int new_scan, int own_request)
1393 struct wpa_bss *selected;
1394 struct wpa_ssid *ssid = NULL;
1396 selected = wpa_supplicant_pick_network(wpa_s, &ssid);
1400 skip = !wpa_supplicant_need_to_roam(wpa_s, selected, ssid);
1403 wpa_supplicant_rsn_preauth_scan_results(wpa_s);
1407 if (wpa_supplicant_connect(wpa_s, selected, ssid) < 0) {
1408 wpa_dbg(wpa_s, MSG_DEBUG, "Connect failed");
1412 wpa_supplicant_rsn_preauth_scan_results(wpa_s);
1414 * Do not notify other virtual radios of scan results since we do not
1415 * want them to start other associations at the same time.
1419 wpa_dbg(wpa_s, MSG_DEBUG, "No suitable network found");
1420 ssid = wpa_supplicant_pick_new_network(wpa_s);
1422 wpa_dbg(wpa_s, MSG_DEBUG, "Setup a new network");
1423 wpa_supplicant_associate(wpa_s, NULL, ssid);
1425 wpa_supplicant_rsn_preauth_scan_results(wpa_s);
1426 } else if (own_request) {
1428 * No SSID found. If SCAN results are as a result of
1429 * own scan request and not due to a scan request on
1430 * another shared interface, try another scan.
1432 int timeout_sec = wpa_s->scan_interval;
1433 int timeout_usec = 0;
1435 if (wpas_p2p_scan_no_go_seen(wpa_s) == 1)
1438 if (wpa_s->p2p_in_provisioning ||
1439 wpa_s->show_group_started ||
1440 wpa_s->p2p_in_invitation) {
1442 * Use shorter wait during P2P Provisioning
1443 * state and during P2P join-a-group operation
1444 * to speed up group formation.
1447 timeout_usec = 250000;
1448 wpa_supplicant_req_new_scan(wpa_s, timeout_sec,
1452 #endif /* CONFIG_P2P */
1453 #ifdef CONFIG_INTERWORKING
1454 if (wpa_s->conf->auto_interworking &&
1455 wpa_s->conf->interworking &&
1456 wpa_s->conf->cred) {
1457 wpa_dbg(wpa_s, MSG_DEBUG, "Interworking: "
1458 "start ANQP fetch since no matching "
1460 wpa_s->network_select = 1;
1461 wpa_s->auto_network_select = 1;
1462 interworking_start_fetch_anqp(wpa_s);
1465 #endif /* CONFIG_INTERWORKING */
1467 if (wpa_s->after_wps > 0 || wpas_wps_searching(wpa_s)) {
1468 wpa_dbg(wpa_s, MSG_DEBUG, "Use shorter wait during WPS processing");
1470 timeout_usec = 500000;
1471 wpa_supplicant_req_new_scan(wpa_s, timeout_sec,
1475 #endif /* CONFIG_WPS */
1476 if (wpa_supplicant_req_sched_scan(wpa_s))
1477 wpa_supplicant_req_new_scan(wpa_s, timeout_sec,
1485 static void wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s,
1486 union wpa_event_data *data)
1488 struct wpa_supplicant *ifs;
1490 if (_wpa_supplicant_event_scan_results(wpa_s, data, 1) != 0) {
1492 * If no scan results could be fetched, then no need to
1493 * notify those interfaces that did not actually request
1494 * this scan. Similarly, if scan results started a new operation on this
1495 * interface, do not notify other interfaces to avoid concurrent
1496 * operations during a connection attempt.
1502 * Check other interfaces to see if they share the same radio. If
1503 * so, they get updated with this same scan info.
1505 dl_list_for_each(ifs, &wpa_s->radio->ifaces, struct wpa_supplicant,
1508 wpa_printf(MSG_DEBUG, "%s: Updating scan results from "
1509 "sibling", ifs->ifname);
1510 _wpa_supplicant_event_scan_results(ifs, data, 0);
1515 #endif /* CONFIG_NO_SCAN_PROCESSING */
1518 int wpa_supplicant_fast_associate(struct wpa_supplicant *wpa_s)
1520 #ifdef CONFIG_NO_SCAN_PROCESSING
1522 #else /* CONFIG_NO_SCAN_PROCESSING */
1523 struct os_reltime now;
1525 if (wpa_s->last_scan_res_used <= 0)
1528 os_get_reltime(&now);
1529 if (os_reltime_expired(&now, &wpa_s->last_scan, 5)) {
1530 wpa_printf(MSG_DEBUG, "Fast associate: Old scan results");
1534 return wpas_select_network_from_last_scan(wpa_s, 0, 1);
1535 #endif /* CONFIG_NO_SCAN_PROCESSING */
1540 static void wnm_bss_keep_alive(void *eloop_ctx, void *sock_ctx)
1542 struct wpa_supplicant *wpa_s = eloop_ctx;
1544 if (wpa_s->wpa_state < WPA_ASSOCIATED)
1547 if (!wpa_s->no_keep_alive) {
1548 wpa_printf(MSG_DEBUG, "WNM: Send keep-alive to AP " MACSTR,
1549 MAC2STR(wpa_s->bssid));
1550 /* TODO: could skip this if normal data traffic has been sent */
1551 /* TODO: Consider using some more appropriate data frame for
1554 l2_packet_send(wpa_s->l2, wpa_s->bssid, 0x0800,
1559 if (wpa_s->sme.bss_max_idle_period) {
1561 msec = wpa_s->sme.bss_max_idle_period * 1024; /* times 1000 */
1564 eloop_register_timeout(msec / 1000, msec % 1000 * 1000,
1565 wnm_bss_keep_alive, wpa_s, NULL);
1567 #endif /* CONFIG_SME */
1571 static void wnm_process_assoc_resp(struct wpa_supplicant *wpa_s,
1572 const u8 *ies, size_t ies_len)
1574 struct ieee802_11_elems elems;
1579 if (ieee802_11_parse_elems(ies, ies_len, &elems, 1) == ParseFailed)
1583 if (elems.bss_max_idle_period) {
1585 wpa_s->sme.bss_max_idle_period =
1586 WPA_GET_LE16(elems.bss_max_idle_period);
1587 wpa_printf(MSG_DEBUG, "WNM: BSS Max Idle Period: %u (* 1000 "
1588 "TU)%s", wpa_s->sme.bss_max_idle_period,
1589 (elems.bss_max_idle_period[2] & 0x01) ?
1590 " (protected keep-live required)" : "");
1591 if (wpa_s->sme.bss_max_idle_period == 0)
1592 wpa_s->sme.bss_max_idle_period = 1;
1593 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME) {
1594 eloop_cancel_timeout(wnm_bss_keep_alive, wpa_s, NULL);
1595 /* msec times 1000 */
1596 msec = wpa_s->sme.bss_max_idle_period * 1024;
1599 eloop_register_timeout(msec / 1000, msec % 1000 * 1000,
1600 wnm_bss_keep_alive, wpa_s,
1604 #endif /* CONFIG_SME */
1607 #endif /* CONFIG_WNM */
1610 void wnm_bss_keep_alive_deinit(struct wpa_supplicant *wpa_s)
1613 eloop_cancel_timeout(wnm_bss_keep_alive, wpa_s, NULL);
1614 #endif /* CONFIG_WNM */
1618 #ifdef CONFIG_INTERWORKING
1620 static int wpas_qos_map_set(struct wpa_supplicant *wpa_s, const u8 *qos_map,
1625 wpa_hexdump(MSG_DEBUG, "Interworking: QoS Map Set", qos_map, len);
1626 res = wpa_drv_set_qos_map(wpa_s, qos_map, len);
1628 wpa_printf(MSG_DEBUG, "Interworking: Failed to configure QoS Map Set to the driver");
1635 static void interworking_process_assoc_resp(struct wpa_supplicant *wpa_s,
1636 const u8 *ies, size_t ies_len)
1638 struct ieee802_11_elems elems;
1643 if (ieee802_11_parse_elems(ies, ies_len, &elems, 1) == ParseFailed)
1646 if (elems.qos_map_set) {
1647 wpas_qos_map_set(wpa_s, elems.qos_map_set,
1648 elems.qos_map_set_len);
1652 #endif /* CONFIG_INTERWORKING */
1655 static int wpa_supplicant_event_associnfo(struct wpa_supplicant *wpa_s,
1656 union wpa_event_data *data)
1658 int l, len, found = 0, wpa_found, rsn_found;
1660 #ifdef CONFIG_IEEE80211R
1662 #endif /* CONFIG_IEEE80211R */
1664 wpa_dbg(wpa_s, MSG_DEBUG, "Association info event");
1665 if (data->assoc_info.req_ies)
1666 wpa_hexdump(MSG_DEBUG, "req_ies", data->assoc_info.req_ies,
1667 data->assoc_info.req_ies_len);
1668 if (data->assoc_info.resp_ies) {
1669 wpa_hexdump(MSG_DEBUG, "resp_ies", data->assoc_info.resp_ies,
1670 data->assoc_info.resp_ies_len);
1672 wpa_tdls_assoc_resp_ies(wpa_s->wpa, data->assoc_info.resp_ies,
1673 data->assoc_info.resp_ies_len);
1674 #endif /* CONFIG_TDLS */
1676 wnm_process_assoc_resp(wpa_s, data->assoc_info.resp_ies,
1677 data->assoc_info.resp_ies_len);
1678 #endif /* CONFIG_WNM */
1679 #ifdef CONFIG_INTERWORKING
1680 interworking_process_assoc_resp(wpa_s, data->assoc_info.resp_ies,
1681 data->assoc_info.resp_ies_len);
1682 #endif /* CONFIG_INTERWORKING */
1684 if (data->assoc_info.beacon_ies)
1685 wpa_hexdump(MSG_DEBUG, "beacon_ies",
1686 data->assoc_info.beacon_ies,
1687 data->assoc_info.beacon_ies_len);
1688 if (data->assoc_info.freq)
1689 wpa_dbg(wpa_s, MSG_DEBUG, "freq=%u MHz",
1690 data->assoc_info.freq);
1692 p = data->assoc_info.req_ies;
1693 l = data->assoc_info.req_ies_len;
1695 /* Go through the IEs and make a copy of the WPA/RSN IE, if present. */
1696 while (p && l >= 2) {
1699 wpa_hexdump(MSG_DEBUG, "Truncated IE in assoc_info",
1703 if ((p[0] == WLAN_EID_VENDOR_SPECIFIC && p[1] >= 6 &&
1704 (os_memcmp(&p[2], "\x00\x50\xF2\x01\x01\x00", 6) == 0)) ||
1705 (p[0] == WLAN_EID_RSN && p[1] >= 2)) {
1706 if (wpa_sm_set_assoc_wpa_ie(wpa_s->wpa, p, len))
1709 wpa_find_assoc_pmkid(wpa_s);
1715 if (!found && data->assoc_info.req_ies)
1716 wpa_sm_set_assoc_wpa_ie(wpa_s->wpa, NULL, 0);
1718 #ifdef CONFIG_IEEE80211R
1720 if (wpa_s->sme.auth_alg == WPA_AUTH_ALG_FT) {
1721 if (wpa_drv_get_bssid(wpa_s, bssid) < 0 ||
1722 wpa_ft_validate_reassoc_resp(wpa_s->wpa,
1723 data->assoc_info.resp_ies,
1724 data->assoc_info.resp_ies_len,
1726 wpa_dbg(wpa_s, MSG_DEBUG, "FT: Validation of "
1727 "Reassociation Response failed");
1728 wpa_supplicant_deauthenticate(
1729 wpa_s, WLAN_REASON_INVALID_IE);
1734 p = data->assoc_info.resp_ies;
1735 l = data->assoc_info.resp_ies_len;
1737 #ifdef CONFIG_WPS_STRICT
1738 if (p && wpa_s->current_ssid &&
1739 wpa_s->current_ssid->key_mgmt == WPA_KEY_MGMT_WPS) {
1741 wps = ieee802_11_vendor_ie_concat(p, l, WPS_IE_VENDOR_TYPE);
1743 wpa_msg(wpa_s, MSG_INFO, "WPS-STRICT: AP did not "
1744 "include WPS IE in (Re)Association Response");
1748 if (wps_validate_assoc_resp(wps) < 0) {
1750 wpa_supplicant_deauthenticate(
1751 wpa_s, WLAN_REASON_INVALID_IE);
1756 #endif /* CONFIG_WPS_STRICT */
1758 /* Go through the IEs and make a copy of the MDIE, if present. */
1759 while (p && l >= 2) {
1762 wpa_hexdump(MSG_DEBUG, "Truncated IE in assoc_info",
1766 if (p[0] == WLAN_EID_MOBILITY_DOMAIN &&
1767 p[1] >= MOBILITY_DOMAIN_ID_LEN) {
1768 wpa_s->sme.ft_used = 1;
1769 os_memcpy(wpa_s->sme.mobility_domain, p + 2,
1770 MOBILITY_DOMAIN_ID_LEN);
1776 #endif /* CONFIG_SME */
1778 /* Process FT when SME is in the driver */
1779 if (!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME) &&
1780 wpa_ft_is_completed(wpa_s->wpa)) {
1781 if (wpa_drv_get_bssid(wpa_s, bssid) < 0 ||
1782 wpa_ft_validate_reassoc_resp(wpa_s->wpa,
1783 data->assoc_info.resp_ies,
1784 data->assoc_info.resp_ies_len,
1786 wpa_dbg(wpa_s, MSG_DEBUG, "FT: Validation of "
1787 "Reassociation Response failed");
1788 wpa_supplicant_deauthenticate(
1789 wpa_s, WLAN_REASON_INVALID_IE);
1792 wpa_dbg(wpa_s, MSG_DEBUG, "FT: Reassociation Response done");
1795 wpa_sm_set_ft_params(wpa_s->wpa, data->assoc_info.resp_ies,
1796 data->assoc_info.resp_ies_len);
1797 #endif /* CONFIG_IEEE80211R */
1799 /* WPA/RSN IE from Beacon/ProbeResp */
1800 p = data->assoc_info.beacon_ies;
1801 l = data->assoc_info.beacon_ies_len;
1803 /* Go through the IEs and make a copy of the WPA/RSN IEs, if present.
1805 wpa_found = rsn_found = 0;
1806 while (p && l >= 2) {
1809 wpa_hexdump(MSG_DEBUG, "Truncated IE in beacon_ies",
1814 p[0] == WLAN_EID_VENDOR_SPECIFIC && p[1] >= 6 &&
1815 os_memcmp(&p[2], "\x00\x50\xF2\x01\x01\x00", 6) == 0) {
1817 wpa_sm_set_ap_wpa_ie(wpa_s->wpa, p, len);
1821 p[0] == WLAN_EID_RSN && p[1] >= 2) {
1823 wpa_sm_set_ap_rsn_ie(wpa_s->wpa, p, len);
1830 if (!wpa_found && data->assoc_info.beacon_ies)
1831 wpa_sm_set_ap_wpa_ie(wpa_s->wpa, NULL, 0);
1832 if (!rsn_found && data->assoc_info.beacon_ies)
1833 wpa_sm_set_ap_rsn_ie(wpa_s->wpa, NULL, 0);
1834 if (wpa_found || rsn_found)
1835 wpa_s->ap_ies_from_associnfo = 1;
1837 if (wpa_s->assoc_freq && data->assoc_info.freq &&
1838 wpa_s->assoc_freq != data->assoc_info.freq) {
1839 wpa_printf(MSG_DEBUG, "Operating frequency changed from "
1841 wpa_s->assoc_freq, data->assoc_info.freq);
1842 wpa_supplicant_update_scan_results(wpa_s);
1845 wpa_s->assoc_freq = data->assoc_info.freq;
1851 static int wpa_supplicant_assoc_update_ie(struct wpa_supplicant *wpa_s)
1853 const u8 *bss_wpa = NULL, *bss_rsn = NULL;
1855 if (!wpa_s->current_bss || !wpa_s->current_ssid)
1858 if (!wpa_key_mgmt_wpa_any(wpa_s->current_ssid->key_mgmt))
1861 bss_wpa = wpa_bss_get_vendor_ie(wpa_s->current_bss,
1862 WPA_IE_VENDOR_TYPE);
1863 bss_rsn = wpa_bss_get_ie(wpa_s->current_bss, WLAN_EID_RSN);
1865 if (wpa_sm_set_ap_wpa_ie(wpa_s->wpa, bss_wpa,
1866 bss_wpa ? 2 + bss_wpa[1] : 0) ||
1867 wpa_sm_set_ap_rsn_ie(wpa_s->wpa, bss_rsn,
1868 bss_rsn ? 2 + bss_rsn[1] : 0))
1875 static void wpa_supplicant_event_assoc(struct wpa_supplicant *wpa_s,
1876 union wpa_event_data *data)
1882 if (wpa_s->ap_iface) {
1885 hostapd_notif_assoc(wpa_s->ap_iface->bss[0],
1886 data->assoc_info.addr,
1887 data->assoc_info.req_ies,
1888 data->assoc_info.req_ies_len,
1889 data->assoc_info.reassoc);
1892 #endif /* CONFIG_AP */
1894 ft_completed = wpa_ft_is_completed(wpa_s->wpa);
1895 if (data && wpa_supplicant_event_associnfo(wpa_s, data) < 0)
1898 if (wpa_drv_get_bssid(wpa_s, bssid) < 0) {
1899 wpa_dbg(wpa_s, MSG_ERROR, "Failed to get BSSID");
1900 wpa_supplicant_deauthenticate(
1901 wpa_s, WLAN_REASON_DEAUTH_LEAVING);
1905 wpa_supplicant_set_state(wpa_s, WPA_ASSOCIATED);
1906 if (os_memcmp(bssid, wpa_s->bssid, ETH_ALEN) != 0) {
1907 wpa_dbg(wpa_s, MSG_DEBUG, "Associated to a new BSS: BSSID="
1908 MACSTR, MAC2STR(bssid));
1909 random_add_randomness(bssid, ETH_ALEN);
1910 os_memcpy(wpa_s->bssid, bssid, ETH_ALEN);
1911 os_memset(wpa_s->pending_bssid, 0, ETH_ALEN);
1912 wpas_notify_bssid_changed(wpa_s);
1914 if (wpa_supplicant_dynamic_keys(wpa_s) && !ft_completed) {
1915 wpa_clear_keys(wpa_s, bssid);
1917 if (wpa_supplicant_select_config(wpa_s) < 0) {
1918 wpa_supplicant_deauthenticate(
1919 wpa_s, WLAN_REASON_DEAUTH_LEAVING);
1923 if (wpa_s->conf->ap_scan == 1 &&
1924 wpa_s->drv_flags & WPA_DRIVER_FLAGS_BSS_SELECTION) {
1925 if (wpa_supplicant_assoc_update_ie(wpa_s) < 0)
1926 wpa_msg(wpa_s, MSG_WARNING,
1927 "WPA/RSN IEs not updated");
1932 os_memcpy(wpa_s->sme.prev_bssid, bssid, ETH_ALEN);
1933 wpa_s->sme.prev_bssid_set = 1;
1934 wpa_s->sme.last_unprot_disconnect.sec = 0;
1935 #endif /* CONFIG_SME */
1937 wpa_msg(wpa_s, MSG_INFO, "Associated with " MACSTR, MAC2STR(bssid));
1938 if (wpa_s->current_ssid) {
1939 /* When using scanning (ap_scan=1), SIM PC/SC interface can be
1940 * initialized before association, but for other modes,
1941 * initialize PC/SC here, if the current configuration needs
1942 * smartcard or SIM/USIM. */
1943 wpa_supplicant_scard_init(wpa_s, wpa_s->current_ssid);
1945 wpa_sm_notify_assoc(wpa_s->wpa, bssid);
1947 l2_packet_notify_auth_start(wpa_s->l2);
1950 * Set portEnabled first to FALSE in order to get EAP state machine out
1951 * of the SUCCESS state and eapSuccess cleared. Without this, EAPOL PAE
1952 * state machine may transit to AUTHENTICATING state based on obsolete
1953 * eapSuccess and then trigger BE_AUTH to SUCCESS and PAE to
1954 * AUTHENTICATED without ever giving chance to EAP state machine to
1957 if (!ft_completed) {
1958 eapol_sm_notify_portEnabled(wpa_s->eapol, FALSE);
1959 eapol_sm_notify_portValid(wpa_s->eapol, FALSE);
1961 if (wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt) || ft_completed)
1962 eapol_sm_notify_eap_success(wpa_s->eapol, FALSE);
1963 /* 802.1X::portControl = Auto */
1964 eapol_sm_notify_portEnabled(wpa_s->eapol, TRUE);
1965 wpa_s->eapol_received = 0;
1966 if (wpa_s->key_mgmt == WPA_KEY_MGMT_NONE ||
1967 wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE ||
1968 (wpa_s->current_ssid &&
1969 wpa_s->current_ssid->mode == IEEE80211_MODE_IBSS)) {
1970 if (wpa_s->current_ssid &&
1971 wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE &&
1973 WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC_DONE)) {
1975 * Set the key after having received joined-IBSS event
1978 wpa_supplicant_set_wpa_none_key(wpa_s,
1979 wpa_s->current_ssid);
1981 wpa_supplicant_cancel_auth_timeout(wpa_s);
1982 wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
1983 } else if (!ft_completed) {
1984 /* Timeout for receiving the first EAPOL packet */
1985 wpa_supplicant_req_auth_timeout(wpa_s, 10, 0);
1987 wpa_supplicant_cancel_scan(wpa_s);
1989 if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE) &&
1990 wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt)) {
1992 * We are done; the driver will take care of RSN 4-way
1995 wpa_supplicant_cancel_auth_timeout(wpa_s);
1996 wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
1997 eapol_sm_notify_portValid(wpa_s->eapol, TRUE);
1998 eapol_sm_notify_eap_success(wpa_s->eapol, TRUE);
1999 } else if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE) &&
2000 wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt)) {
2002 * The driver will take care of RSN 4-way handshake, so we need
2003 * to allow EAPOL supplicant to complete its work without
2004 * waiting for WPA supplicant.
2006 eapol_sm_notify_portValid(wpa_s->eapol, TRUE);
2007 } else if (ft_completed) {
2009 * FT protocol completed - make sure EAPOL state machine ends
2010 * up in authenticated.
2012 wpa_supplicant_cancel_auth_timeout(wpa_s);
2013 wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
2014 eapol_sm_notify_portValid(wpa_s->eapol, TRUE);
2015 eapol_sm_notify_eap_success(wpa_s->eapol, TRUE);
2018 wpa_s->last_eapol_matches_bssid = 0;
2020 if (wpa_s->pending_eapol_rx) {
2021 struct os_reltime now, age;
2022 os_get_reltime(&now);
2023 os_reltime_sub(&now, &wpa_s->pending_eapol_rx_time, &age);
2024 if (age.sec == 0 && age.usec < 100000 &&
2025 os_memcmp(wpa_s->pending_eapol_rx_src, bssid, ETH_ALEN) ==
2027 wpa_dbg(wpa_s, MSG_DEBUG, "Process pending EAPOL "
2028 "frame that was received just before "
2029 "association notification");
2030 wpa_supplicant_rx_eapol(
2031 wpa_s, wpa_s->pending_eapol_rx_src,
2032 wpabuf_head(wpa_s->pending_eapol_rx),
2033 wpabuf_len(wpa_s->pending_eapol_rx));
2035 wpabuf_free(wpa_s->pending_eapol_rx);
2036 wpa_s->pending_eapol_rx = NULL;
2039 if ((wpa_s->key_mgmt == WPA_KEY_MGMT_NONE ||
2040 wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA) &&
2041 wpa_s->current_ssid &&
2042 (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC_DONE)) {
2043 /* Set static WEP keys again */
2044 wpa_set_wep_keys(wpa_s, wpa_s->current_ssid);
2047 #ifdef CONFIG_IBSS_RSN
2048 if (wpa_s->current_ssid &&
2049 wpa_s->current_ssid->mode == WPAS_MODE_IBSS &&
2050 wpa_s->key_mgmt != WPA_KEY_MGMT_NONE &&
2051 wpa_s->key_mgmt != WPA_KEY_MGMT_WPA_NONE &&
2052 wpa_s->ibss_rsn == NULL) {
2053 wpa_s->ibss_rsn = ibss_rsn_init(wpa_s);
2054 if (!wpa_s->ibss_rsn) {
2055 wpa_msg(wpa_s, MSG_INFO, "Failed to init IBSS RSN");
2056 wpa_supplicant_deauthenticate(
2057 wpa_s, WLAN_REASON_DEAUTH_LEAVING);
2061 ibss_rsn_set_psk(wpa_s->ibss_rsn, wpa_s->current_ssid->psk);
2063 #endif /* CONFIG_IBSS_RSN */
2065 wpas_wps_notify_assoc(wpa_s, bssid);
2069 static int disconnect_reason_recoverable(u16 reason_code)
2071 return reason_code == WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY ||
2072 reason_code == WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA ||
2073 reason_code == WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA;
2077 static void wpa_supplicant_event_disassoc(struct wpa_supplicant *wpa_s,
2079 int locally_generated)
2083 if (wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE) {
2085 * At least Host AP driver and a Prism3 card seemed to be
2086 * generating streams of disconnected events when configuring
2087 * IBSS for WPA-None. Ignore them for now.
2092 bssid = wpa_s->bssid;
2093 if (is_zero_ether_addr(bssid))
2094 bssid = wpa_s->pending_bssid;
2096 if (!is_zero_ether_addr(bssid) ||
2097 wpa_s->wpa_state >= WPA_AUTHENTICATING) {
2098 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_DISCONNECTED "bssid=" MACSTR
2100 MAC2STR(bssid), reason_code,
2101 locally_generated ? " locally_generated=1" : "");
2106 static int could_be_psk_mismatch(struct wpa_supplicant *wpa_s, u16 reason_code,
2107 int locally_generated)
2109 if (wpa_s->wpa_state != WPA_4WAY_HANDSHAKE ||
2110 !wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt))
2111 return 0; /* Not in 4-way handshake with PSK */
2114 * It looks like connection was lost while trying to go through PSK
2115 * 4-way handshake. Filter out known disconnection cases that are caused
2116 * by something else than PSK mismatch to avoid confusing reports.
2119 if (locally_generated) {
2120 if (reason_code == WLAN_REASON_IE_IN_4WAY_DIFFERS)
2128 static void wpa_supplicant_event_disassoc_finish(struct wpa_supplicant *wpa_s,
2130 int locally_generated)
2134 u8 prev_pending_bssid[ETH_ALEN];
2135 struct wpa_bss *fast_reconnect = NULL;
2136 struct wpa_ssid *fast_reconnect_ssid = NULL;
2137 struct wpa_ssid *last_ssid;
2139 authenticating = wpa_s->wpa_state == WPA_AUTHENTICATING;
2140 os_memcpy(prev_pending_bssid, wpa_s->pending_bssid, ETH_ALEN);
2142 if (wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE) {
2144 * At least Host AP driver and a Prism3 card seemed to be
2145 * generating streams of disconnected events when configuring
2146 * IBSS for WPA-None. Ignore them for now.
2148 wpa_dbg(wpa_s, MSG_DEBUG, "Disconnect event - ignore in "
2149 "IBSS/WPA-None mode");
2153 if (could_be_psk_mismatch(wpa_s, reason_code, locally_generated)) {
2154 wpa_msg(wpa_s, MSG_INFO, "WPA: 4-Way Handshake failed - "
2155 "pre-shared key may be incorrect");
2156 if (wpas_p2p_4way_hs_failed(wpa_s) > 0)
2157 return; /* P2P group removed */
2158 wpas_auth_failed(wpa_s, "WRONG_KEY");
2160 if (!wpa_s->disconnected &&
2161 (!wpa_s->auto_reconnect_disabled ||
2162 wpa_s->key_mgmt == WPA_KEY_MGMT_WPS)) {
2163 wpa_dbg(wpa_s, MSG_DEBUG, "Auto connect enabled: try to "
2164 "reconnect (wps=%d wpa_state=%d)",
2165 wpa_s->key_mgmt == WPA_KEY_MGMT_WPS,
2167 if (wpa_s->wpa_state == WPA_COMPLETED &&
2168 wpa_s->current_ssid &&
2169 wpa_s->current_ssid->mode == WPAS_MODE_INFRA &&
2170 !locally_generated &&
2171 disconnect_reason_recoverable(reason_code)) {
2173 * It looks like the AP has dropped association with
2174 * us, but could allow us to get back in. Try to
2175 * reconnect to the same BSS without full scan to save
2176 * time for some common cases.
2178 fast_reconnect = wpa_s->current_bss;
2179 fast_reconnect_ssid = wpa_s->current_ssid;
2180 } else if (wpa_s->wpa_state >= WPA_ASSOCIATING)
2181 wpa_supplicant_req_scan(wpa_s, 0, 100000);
2183 wpa_dbg(wpa_s, MSG_DEBUG, "Do not request new "
2186 wpa_dbg(wpa_s, MSG_DEBUG, "Auto connect disabled: do not "
2187 "try to re-connect");
2188 wpa_s->reassociate = 0;
2189 wpa_s->disconnected = 1;
2190 wpa_supplicant_cancel_sched_scan(wpa_s);
2192 bssid = wpa_s->bssid;
2193 if (is_zero_ether_addr(bssid))
2194 bssid = wpa_s->pending_bssid;
2195 if (wpa_s->wpa_state >= WPA_AUTHENTICATING)
2196 wpas_connection_failed(wpa_s, bssid);
2197 wpa_sm_notify_disassoc(wpa_s->wpa);
2198 if (locally_generated)
2199 wpa_s->disconnect_reason = -reason_code;
2201 wpa_s->disconnect_reason = reason_code;
2202 wpas_notify_disconnect_reason(wpa_s);
2203 if (wpa_supplicant_dynamic_keys(wpa_s)) {
2204 wpa_dbg(wpa_s, MSG_DEBUG, "Disconnect event - remove keys");
2205 wpa_clear_keys(wpa_s, wpa_s->bssid);
2207 last_ssid = wpa_s->current_ssid;
2208 wpa_supplicant_mark_disassoc(wpa_s);
2210 if (authenticating && (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)) {
2211 sme_disassoc_while_authenticating(wpa_s, prev_pending_bssid);
2212 wpa_s->current_ssid = last_ssid;
2215 if (fast_reconnect &&
2216 !wpas_network_disabled(wpa_s, fast_reconnect_ssid) &&
2217 !disallowed_bssid(wpa_s, fast_reconnect->bssid) &&
2218 !disallowed_ssid(wpa_s, fast_reconnect->ssid,
2219 fast_reconnect->ssid_len) &&
2220 !wpas_temp_disabled(wpa_s, fast_reconnect_ssid)) {
2221 #ifndef CONFIG_NO_SCAN_PROCESSING
2222 wpa_dbg(wpa_s, MSG_DEBUG, "Try to reconnect to the same BSS");
2223 if (wpa_supplicant_connect(wpa_s, fast_reconnect,
2224 fast_reconnect_ssid) < 0) {
2225 /* Recover through full scan */
2226 wpa_supplicant_req_scan(wpa_s, 0, 100000);
2228 #endif /* CONFIG_NO_SCAN_PROCESSING */
2229 } else if (fast_reconnect) {
2231 * Could not reconnect to the same BSS due to network being
2232 * disabled. Use a new scan to match the alternative behavior
2233 * above, i.e., to continue automatic reconnection attempt in a
2234 * way that enforces disabled network rules.
2236 wpa_supplicant_req_scan(wpa_s, 0, 100000);
2241 #ifdef CONFIG_DELAYED_MIC_ERROR_REPORT
2242 void wpa_supplicant_delayed_mic_error_report(void *eloop_ctx, void *sock_ctx)
2244 struct wpa_supplicant *wpa_s = eloop_ctx;
2246 if (!wpa_s->pending_mic_error_report)
2249 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: Sending pending MIC error report");
2250 wpa_sm_key_request(wpa_s->wpa, 1, wpa_s->pending_mic_error_pairwise);
2251 wpa_s->pending_mic_error_report = 0;
2253 #endif /* CONFIG_DELAYED_MIC_ERROR_REPORT */
2257 wpa_supplicant_event_michael_mic_failure(struct wpa_supplicant *wpa_s,
2258 union wpa_event_data *data)
2261 struct os_reltime t;
2263 wpa_msg(wpa_s, MSG_WARNING, "Michael MIC failure detected");
2264 pairwise = (data && data->michael_mic_failure.unicast);
2266 if ((wpa_s->last_michael_mic_error.sec &&
2267 !os_reltime_expired(&t, &wpa_s->last_michael_mic_error, 60)) ||
2268 wpa_s->pending_mic_error_report) {
2269 if (wpa_s->pending_mic_error_report) {
2271 * Send the pending MIC error report immediately since
2272 * we are going to start countermeasures and AP better
2275 wpa_sm_key_request(wpa_s->wpa, 1,
2276 wpa_s->pending_mic_error_pairwise);
2279 /* Send the new MIC error report immediately since we are going
2280 * to start countermeasures and AP better do the same.
2282 wpa_sm_key_request(wpa_s->wpa, 1, pairwise);
2284 /* initialize countermeasures */
2285 wpa_s->countermeasures = 1;
2287 wpa_blacklist_add(wpa_s, wpa_s->bssid);
2289 wpa_msg(wpa_s, MSG_WARNING, "TKIP countermeasures started");
2292 * Need to wait for completion of request frame. We do not get
2293 * any callback for the message completion, so just wait a
2294 * short while and hope for the best. */
2297 wpa_drv_set_countermeasures(wpa_s, 1);
2298 wpa_supplicant_deauthenticate(wpa_s,
2299 WLAN_REASON_MICHAEL_MIC_FAILURE);
2300 eloop_cancel_timeout(wpa_supplicant_stop_countermeasures,
2302 eloop_register_timeout(60, 0,
2303 wpa_supplicant_stop_countermeasures,
2305 /* TODO: mark the AP rejected for 60 second. STA is
2306 * allowed to associate with another AP.. */
2308 #ifdef CONFIG_DELAYED_MIC_ERROR_REPORT
2309 if (wpa_s->mic_errors_seen) {
2311 * Reduce the effectiveness of Michael MIC error
2312 * reports as a means for attacking against TKIP if
2313 * more than one MIC failure is noticed with the same
2314 * PTK. We delay the transmission of the reports by a
2315 * random time between 0 and 60 seconds in order to
2316 * force the attacker wait 60 seconds before getting
2317 * the information on whether a frame resulted in a MIC
2323 if (os_get_random(rval, sizeof(rval)) < 0)
2324 sec = os_random() % 60;
2326 sec = WPA_GET_BE32(rval) % 60;
2327 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: Delay MIC error "
2328 "report %d seconds", sec);
2329 wpa_s->pending_mic_error_report = 1;
2330 wpa_s->pending_mic_error_pairwise = pairwise;
2331 eloop_cancel_timeout(
2332 wpa_supplicant_delayed_mic_error_report,
2334 eloop_register_timeout(
2335 sec, os_random() % 1000000,
2336 wpa_supplicant_delayed_mic_error_report,
2339 wpa_sm_key_request(wpa_s->wpa, 1, pairwise);
2341 #else /* CONFIG_DELAYED_MIC_ERROR_REPORT */
2342 wpa_sm_key_request(wpa_s->wpa, 1, pairwise);
2343 #endif /* CONFIG_DELAYED_MIC_ERROR_REPORT */
2345 wpa_s->last_michael_mic_error = t;
2346 wpa_s->mic_errors_seen++;
2350 #ifdef CONFIG_TERMINATE_ONLASTIF
2351 static int any_interfaces(struct wpa_supplicant *head)
2353 struct wpa_supplicant *wpa_s;
2355 for (wpa_s = head; wpa_s != NULL; wpa_s = wpa_s->next)
2356 if (!wpa_s->interface_removed)
2360 #endif /* CONFIG_TERMINATE_ONLASTIF */
2364 wpa_supplicant_event_interface_status(struct wpa_supplicant *wpa_s,
2365 union wpa_event_data *data)
2367 if (os_strcmp(wpa_s->ifname, data->interface_status.ifname) != 0)
2370 switch (data->interface_status.ievent) {
2371 case EVENT_INTERFACE_ADDED:
2372 if (!wpa_s->interface_removed)
2374 wpa_s->interface_removed = 0;
2375 wpa_dbg(wpa_s, MSG_DEBUG, "Configured interface was added");
2376 if (wpa_supplicant_driver_init(wpa_s) < 0) {
2377 wpa_msg(wpa_s, MSG_INFO, "Failed to initialize the "
2378 "driver after interface was added");
2381 case EVENT_INTERFACE_REMOVED:
2382 wpa_dbg(wpa_s, MSG_DEBUG, "Configured interface was removed");
2383 wpa_s->interface_removed = 1;
2384 wpa_supplicant_mark_disassoc(wpa_s);
2385 wpa_supplicant_set_state(wpa_s, WPA_INTERFACE_DISABLED);
2386 l2_packet_deinit(wpa_s->l2);
2388 #ifdef CONFIG_TERMINATE_ONLASTIF
2389 /* check if last interface */
2390 if (!any_interfaces(wpa_s->global->ifaces))
2392 #endif /* CONFIG_TERMINATE_ONLASTIF */
2398 #ifdef CONFIG_PEERKEY
2400 wpa_supplicant_event_stkstart(struct wpa_supplicant *wpa_s,
2401 union wpa_event_data *data)
2405 wpa_sm_stkstart(wpa_s->wpa, data->stkstart.peer);
2407 #endif /* CONFIG_PEERKEY */
2411 static void wpa_supplicant_event_tdls(struct wpa_supplicant *wpa_s,
2412 union wpa_event_data *data)
2416 switch (data->tdls.oper) {
2417 case TDLS_REQUEST_SETUP:
2418 wpa_tdls_remove(wpa_s->wpa, data->tdls.peer);
2419 if (wpa_tdls_is_external_setup(wpa_s->wpa))
2420 wpa_tdls_start(wpa_s->wpa, data->tdls.peer);
2422 wpa_drv_tdls_oper(wpa_s, TDLS_SETUP, data->tdls.peer);
2424 case TDLS_REQUEST_TEARDOWN:
2425 if (wpa_tdls_is_external_setup(wpa_s->wpa))
2426 wpa_tdls_teardown_link(wpa_s->wpa, data->tdls.peer,
2427 data->tdls.reason_code);
2429 wpa_drv_tdls_oper(wpa_s, TDLS_TEARDOWN,
2434 #endif /* CONFIG_TDLS */
2438 static void wpa_supplicant_event_wnm(struct wpa_supplicant *wpa_s,
2439 union wpa_event_data *data)
2443 switch (data->wnm.oper) {
2444 case WNM_OPER_SLEEP:
2445 wpa_printf(MSG_DEBUG, "Start sending WNM-Sleep Request "
2446 "(action=%d, intval=%d)",
2447 data->wnm.sleep_action, data->wnm.sleep_intval);
2448 ieee802_11_send_wnmsleep_req(wpa_s, data->wnm.sleep_action,
2449 data->wnm.sleep_intval, NULL);
2453 #endif /* CONFIG_WNM */
2456 #ifdef CONFIG_IEEE80211R
2458 wpa_supplicant_event_ft_response(struct wpa_supplicant *wpa_s,
2459 union wpa_event_data *data)
2464 if (wpa_ft_process_response(wpa_s->wpa, data->ft_ies.ies,
2465 data->ft_ies.ies_len,
2466 data->ft_ies.ft_action,
2467 data->ft_ies.target_ap,
2468 data->ft_ies.ric_ies,
2469 data->ft_ies.ric_ies_len) < 0) {
2470 /* TODO: prevent MLME/driver from trying to associate? */
2473 #endif /* CONFIG_IEEE80211R */
2476 #ifdef CONFIG_IBSS_RSN
2477 static void wpa_supplicant_event_ibss_rsn_start(struct wpa_supplicant *wpa_s,
2478 union wpa_event_data *data)
2480 struct wpa_ssid *ssid;
2481 if (wpa_s->wpa_state < WPA_ASSOCIATED)
2485 ssid = wpa_s->current_ssid;
2488 if (ssid->mode != WPAS_MODE_IBSS || !wpa_key_mgmt_wpa(ssid->key_mgmt))
2491 ibss_rsn_start(wpa_s->ibss_rsn, data->ibss_rsn_start.peer);
2495 static void wpa_supplicant_event_ibss_auth(struct wpa_supplicant *wpa_s,
2496 union wpa_event_data *data)
2498 struct wpa_ssid *ssid = wpa_s->current_ssid;
2503 /* check if the ssid is correctly configured as IBSS/RSN */
2504 if (ssid->mode != WPAS_MODE_IBSS || !wpa_key_mgmt_wpa(ssid->key_mgmt))
2507 ibss_rsn_handle_auth(wpa_s->ibss_rsn, data->rx_mgmt.frame,
2508 data->rx_mgmt.frame_len);
2510 #endif /* CONFIG_IBSS_RSN */
2513 #ifdef CONFIG_IEEE80211R
2514 static void ft_rx_action(struct wpa_supplicant *wpa_s, const u8 *data,
2517 const u8 *sta_addr, *target_ap_addr;
2520 wpa_hexdump(MSG_MSGDUMP, "FT: RX Action", data, len);
2521 if (!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME))
2522 return; /* only SME case supported for now */
2523 if (len < 1 + 2 * ETH_ALEN + 2)
2526 return; /* Only FT Action Response is supported for now */
2527 sta_addr = data + 1;
2528 target_ap_addr = data + 1 + ETH_ALEN;
2529 status = WPA_GET_LE16(data + 1 + 2 * ETH_ALEN);
2530 wpa_dbg(wpa_s, MSG_DEBUG, "FT: Received FT Action Response: STA "
2531 MACSTR " TargetAP " MACSTR " status %u",
2532 MAC2STR(sta_addr), MAC2STR(target_ap_addr), status);
2534 if (os_memcmp(sta_addr, wpa_s->own_addr, ETH_ALEN) != 0) {
2535 wpa_dbg(wpa_s, MSG_DEBUG, "FT: Foreign STA Address " MACSTR
2536 " in FT Action Response", MAC2STR(sta_addr));
2541 wpa_dbg(wpa_s, MSG_DEBUG, "FT: FT Action Response indicates "
2542 "failure (status code %d)", status);
2543 /* TODO: report error to FT code(?) */
2547 if (wpa_ft_process_response(wpa_s->wpa, data + 1 + 2 * ETH_ALEN + 2,
2548 len - (1 + 2 * ETH_ALEN + 2), 1,
2549 target_ap_addr, NULL, 0) < 0)
2554 struct wpa_bss *bss;
2555 bss = wpa_bss_get_bssid(wpa_s, target_ap_addr);
2557 wpa_s->sme.freq = bss->freq;
2558 wpa_s->sme.auth_alg = WPA_AUTH_ALG_FT;
2559 sme_associate(wpa_s, WPAS_MODE_INFRA, target_ap_addr,
2562 #endif /* CONFIG_SME */
2564 #endif /* CONFIG_IEEE80211R */
2567 static void wpa_supplicant_event_unprot_deauth(struct wpa_supplicant *wpa_s,
2568 struct unprot_deauth *e)
2570 #ifdef CONFIG_IEEE80211W
2571 wpa_printf(MSG_DEBUG, "Unprotected Deauthentication frame "
2572 "dropped: " MACSTR " -> " MACSTR
2573 " (reason code %u)",
2574 MAC2STR(e->sa), MAC2STR(e->da), e->reason_code);
2575 sme_event_unprot_disconnect(wpa_s, e->sa, e->da, e->reason_code);
2576 #endif /* CONFIG_IEEE80211W */
2580 static void wpa_supplicant_event_unprot_disassoc(struct wpa_supplicant *wpa_s,
2581 struct unprot_disassoc *e)
2583 #ifdef CONFIG_IEEE80211W
2584 wpa_printf(MSG_DEBUG, "Unprotected Disassociation frame "
2585 "dropped: " MACSTR " -> " MACSTR
2586 " (reason code %u)",
2587 MAC2STR(e->sa), MAC2STR(e->da), e->reason_code);
2588 sme_event_unprot_disconnect(wpa_s, e->sa, e->da, e->reason_code);
2589 #endif /* CONFIG_IEEE80211W */
2593 static void wpas_event_disconnect(struct wpa_supplicant *wpa_s, const u8 *addr,
2594 u16 reason_code, int locally_generated,
2595 const u8 *ie, size_t ie_len, int deauth)
2598 if (wpa_s->ap_iface && addr) {
2599 hostapd_notif_disassoc(wpa_s->ap_iface->bss[0], addr);
2603 if (wpa_s->ap_iface) {
2604 wpa_dbg(wpa_s, MSG_DEBUG, "Ignore deauth event in AP mode");
2607 #endif /* CONFIG_AP */
2609 wpa_supplicant_event_disassoc(wpa_s, reason_code, locally_generated);
2611 if (((reason_code == WLAN_REASON_IEEE_802_1X_AUTH_FAILED ||
2612 ((wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt) ||
2613 (wpa_s->key_mgmt & WPA_KEY_MGMT_IEEE8021X_NO_WPA)) &&
2614 eapol_sm_failed(wpa_s->eapol))) &&
2615 !wpa_s->eap_expected_failure))
2616 wpas_auth_failed(wpa_s, "AUTH_FAILED");
2619 if (deauth && reason_code > 0) {
2620 if (wpas_p2p_deauth_notif(wpa_s, addr, reason_code, ie, ie_len,
2621 locally_generated) > 0) {
2623 * The interface was removed, so cannot continue
2624 * processing any additional operations after this.
2629 #endif /* CONFIG_P2P */
2631 wpa_supplicant_event_disassoc_finish(wpa_s, reason_code,
2636 static void wpas_event_disassoc(struct wpa_supplicant *wpa_s,
2637 struct disassoc_info *info)
2639 u16 reason_code = 0;
2640 int locally_generated = 0;
2641 const u8 *addr = NULL;
2642 const u8 *ie = NULL;
2645 wpa_dbg(wpa_s, MSG_DEBUG, "Disassociation notification");
2650 ie_len = info->ie_len;
2651 reason_code = info->reason_code;
2652 locally_generated = info->locally_generated;
2653 wpa_dbg(wpa_s, MSG_DEBUG, " * reason %u%s", reason_code,
2654 locally_generated ? " (locally generated)" : "");
2656 wpa_dbg(wpa_s, MSG_DEBUG, " * address " MACSTR,
2658 wpa_hexdump(MSG_DEBUG, "Disassociation frame IE(s)",
2663 if (wpa_s->ap_iface && info && info->addr) {
2664 hostapd_notif_disassoc(wpa_s->ap_iface->bss[0], info->addr);
2668 if (wpa_s->ap_iface) {
2669 wpa_dbg(wpa_s, MSG_DEBUG, "Ignore disassoc event in AP mode");
2672 #endif /* CONFIG_AP */
2676 wpas_p2p_disassoc_notif(
2677 wpa_s, info->addr, reason_code, info->ie, info->ie_len,
2680 #endif /* CONFIG_P2P */
2682 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
2683 sme_event_disassoc(wpa_s, info);
2685 wpas_event_disconnect(wpa_s, addr, reason_code, locally_generated,
2690 static void wpas_event_deauth(struct wpa_supplicant *wpa_s,
2691 struct deauth_info *info)
2693 u16 reason_code = 0;
2694 int locally_generated = 0;
2695 const u8 *addr = NULL;
2696 const u8 *ie = NULL;
2699 wpa_dbg(wpa_s, MSG_DEBUG, "Deauthentication notification");
2704 ie_len = info->ie_len;
2705 reason_code = info->reason_code;
2706 locally_generated = info->locally_generated;
2707 wpa_dbg(wpa_s, MSG_DEBUG, " * reason %u%s",
2709 locally_generated ? " (locally generated)" : "");
2711 wpa_dbg(wpa_s, MSG_DEBUG, " * address " MACSTR,
2714 wpa_hexdump(MSG_DEBUG, "Deauthentication frame IE(s)",
2718 wpa_reset_ft_completed(wpa_s->wpa);
2720 wpas_event_disconnect(wpa_s, addr, reason_code,
2721 locally_generated, ie, ie_len, 1);
2725 static const char * reg_init_str(enum reg_change_initiator init)
2728 case REGDOM_SET_BY_CORE:
2730 case REGDOM_SET_BY_USER:
2732 case REGDOM_SET_BY_DRIVER:
2734 case REGDOM_SET_BY_COUNTRY_IE:
2735 return "COUNTRY_IE";
2736 case REGDOM_BEACON_HINT:
2737 return "BEACON_HINT";
2743 static const char * reg_type_str(enum reg_type type)
2746 case REGDOM_TYPE_UNKNOWN:
2748 case REGDOM_TYPE_COUNTRY:
2750 case REGDOM_TYPE_WORLD:
2752 case REGDOM_TYPE_CUSTOM_WORLD:
2753 return "CUSTOM_WORLD";
2754 case REGDOM_TYPE_INTERSECTION:
2755 return "INTERSECTION";
2761 static void wpa_supplicant_update_channel_list(
2762 struct wpa_supplicant *wpa_s, struct channel_list_changed *info)
2764 struct wpa_supplicant *ifs;
2766 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_REGDOM_CHANGE "init=%s type=%s%s%s",
2767 reg_init_str(info->initiator), reg_type_str(info->type),
2768 info->alpha2[0] ? " alpha2=" : "",
2769 info->alpha2[0] ? info->alpha2 : "");
2771 if (wpa_s->drv_priv == NULL)
2772 return; /* Ignore event during drv initialization */
2774 free_hw_features(wpa_s);
2775 wpa_s->hw.modes = wpa_drv_get_hw_feature_data(
2776 wpa_s, &wpa_s->hw.num_modes, &wpa_s->hw.flags);
2778 wpas_p2p_update_channel_list(wpa_s);
2781 * Check other interfaces to see if they share the same radio. If
2782 * so, they get updated with this same hw mode info.
2784 dl_list_for_each(ifs, &wpa_s->radio->ifaces, struct wpa_supplicant,
2787 wpa_printf(MSG_DEBUG, "%s: Updating hw mode",
2789 free_hw_features(ifs);
2790 ifs->hw.modes = wpa_drv_get_hw_feature_data(
2791 ifs, &ifs->hw.num_modes, &ifs->hw.flags);
2797 static void wpas_event_rx_mgmt_action(struct wpa_supplicant *wpa_s,
2798 const u8 *frame, size_t len, int freq)
2800 const struct ieee80211_mgmt *mgmt;
2805 if (len < IEEE80211_HDRLEN + 2)
2808 mgmt = (const struct ieee80211_mgmt *) frame;
2809 payload = frame + IEEE80211_HDRLEN;
2810 category = *payload++;
2811 plen = len - IEEE80211_HDRLEN - 1;
2813 wpa_dbg(wpa_s, MSG_DEBUG, "Received Action frame: SA=" MACSTR
2814 " Category=%u DataLen=%d freq=%d MHz",
2815 MAC2STR(mgmt->sa), category, (int) plen, freq);
2817 #ifdef CONFIG_IEEE80211R
2818 if (category == WLAN_ACTION_FT) {
2819 ft_rx_action(wpa_s, payload, plen);
2822 #endif /* CONFIG_IEEE80211R */
2824 #ifdef CONFIG_IEEE80211W
2826 if (category == WLAN_ACTION_SA_QUERY) {
2827 sme_sa_query_rx(wpa_s, mgmt->sa, payload, plen);
2830 #endif /* CONFIG_SME */
2831 #endif /* CONFIG_IEEE80211W */
2834 if (mgmt->u.action.category == WLAN_ACTION_WNM) {
2835 ieee802_11_rx_wnm_action(wpa_s, mgmt, len);
2838 #endif /* CONFIG_WNM */
2841 if ((mgmt->u.action.category == WLAN_ACTION_PUBLIC ||
2842 mgmt->u.action.category == WLAN_ACTION_PROTECTED_DUAL) &&
2843 gas_query_rx(wpa_s->gas, mgmt->da, mgmt->sa, mgmt->bssid,
2844 mgmt->u.action.category,
2845 payload, plen, freq) == 0)
2847 #endif /* CONFIG_GAS */
2850 if (category == WLAN_ACTION_PUBLIC && plen >= 4 &&
2851 payload[0] == WLAN_TDLS_DISCOVERY_RESPONSE) {
2852 wpa_dbg(wpa_s, MSG_DEBUG,
2853 "TDLS: Received Discovery Response from " MACSTR,
2857 #endif /* CONFIG_TDLS */
2859 #ifdef CONFIG_INTERWORKING
2860 if (category == WLAN_ACTION_QOS && plen >= 1 &&
2861 payload[0] == QOS_QOS_MAP_CONFIG) {
2862 const u8 *pos = payload + 1;
2863 size_t qlen = plen - 1;
2864 wpa_dbg(wpa_s, MSG_DEBUG, "Interworking: Received QoS Map Configure frame from "
2865 MACSTR, MAC2STR(mgmt->sa));
2866 if (os_memcmp(mgmt->sa, wpa_s->bssid, ETH_ALEN) == 0 &&
2867 qlen > 2 && pos[0] == WLAN_EID_QOS_MAP_SET &&
2868 pos[1] <= qlen - 2 && pos[1] >= 16)
2869 wpas_qos_map_set(wpa_s, pos + 2, pos[1]);
2872 #endif /* CONFIG_INTERWORKING */
2874 wpas_p2p_rx_action(wpa_s, mgmt->da, mgmt->sa, mgmt->bssid,
2875 category, payload, plen, freq);
2879 static void wpa_supplicant_notify_avoid_freq(struct wpa_supplicant *wpa_s,
2880 union wpa_event_data *event)
2883 struct wpa_supplicant *ifs;
2884 #endif /* CONFIG_P2P */
2885 struct wpa_freq_range_list *list;
2888 list = &event->freq_range;
2891 str = freq_range_list_str(list);
2892 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_AVOID_FREQ "ranges=%s",
2896 if (freq_range_list_parse(&wpa_s->global->p2p_go_avoid_freq, str)) {
2897 wpa_dbg(wpa_s, MSG_ERROR, "%s: Failed to parse freq range",
2900 wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Update channel list based on frequency avoid event");
2901 wpas_p2p_update_channel_list(wpa_s);
2904 for (ifs = wpa_s->global->ifaces; ifs; ifs = ifs->next) {
2906 if (!ifs->current_ssid ||
2907 !ifs->current_ssid->p2p_group ||
2908 (ifs->current_ssid->mode != WPAS_MODE_P2P_GO &&
2909 ifs->current_ssid->mode != WPAS_MODE_P2P_GROUP_FORMATION))
2912 freq = ifs->current_ssid->frequency;
2913 if (!freq_range_list_includes(list, freq)) {
2914 wpa_dbg(ifs, MSG_DEBUG, "P2P GO operating frequency %d MHz in safe range",
2919 wpa_dbg(ifs, MSG_DEBUG, "P2P GO operating in unsafe frequency %d MHz",
2921 /* TODO: Consider using CSA or removing the group within
2923 wpa_msg(ifs, MSG_INFO, P2P_EVENT_REMOVE_AND_REFORM_GROUP);
2925 #endif /* CONFIG_P2P */
2931 void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
2932 union wpa_event_data *data)
2934 struct wpa_supplicant *wpa_s = ctx;
2936 if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED &&
2937 event != EVENT_INTERFACE_ENABLED &&
2938 event != EVENT_INTERFACE_STATUS &&
2939 event != EVENT_SCHED_SCAN_STOPPED) {
2940 wpa_dbg(wpa_s, MSG_DEBUG,
2941 "Ignore event %s (%d) while interface is disabled",
2942 event_to_string(event), event);
2946 #ifndef CONFIG_NO_STDOUT_DEBUG
2948 int level = MSG_DEBUG;
2950 if (event == EVENT_RX_MGMT && data->rx_mgmt.frame_len >= 24) {
2951 const struct ieee80211_hdr *hdr;
2953 hdr = (const struct ieee80211_hdr *) data->rx_mgmt.frame;
2954 fc = le_to_host16(hdr->frame_control);
2955 if (WLAN_FC_GET_TYPE(fc) == WLAN_FC_TYPE_MGMT &&
2956 WLAN_FC_GET_STYPE(fc) == WLAN_FC_STYPE_BEACON)
2957 level = MSG_EXCESSIVE;
2960 wpa_dbg(wpa_s, level, "Event %s (%d) received",
2961 event_to_string(event), event);
2963 #endif /* CONFIG_NO_STDOUT_DEBUG */
2967 sme_event_auth(wpa_s, data);
2970 wpa_supplicant_event_assoc(wpa_s, data);
2972 case EVENT_DISASSOC:
2973 wpas_event_disassoc(wpa_s,
2974 data ? &data->disassoc_info : NULL);
2977 wpas_event_deauth(wpa_s,
2978 data ? &data->deauth_info : NULL);
2980 case EVENT_MICHAEL_MIC_FAILURE:
2981 wpa_supplicant_event_michael_mic_failure(wpa_s, data);
2983 #ifndef CONFIG_NO_SCAN_PROCESSING
2984 case EVENT_SCAN_STARTED:
2985 os_get_reltime(&wpa_s->scan_start_time);
2986 if (wpa_s->own_scan_requested) {
2987 struct os_reltime diff;
2989 os_reltime_sub(&wpa_s->scan_start_time,
2990 &wpa_s->scan_trigger_time, &diff);
2991 wpa_dbg(wpa_s, MSG_DEBUG, "Own scan request started a scan in %ld.%06ld seconds",
2992 diff.sec, diff.usec);
2993 wpa_s->own_scan_requested = 0;
2994 wpa_s->own_scan_running = 1;
2995 if (wpa_s->last_scan_req == MANUAL_SCAN_REQ &&
2996 wpa_s->manual_scan_use_id) {
2997 wpa_msg_ctrl(wpa_s, MSG_INFO,
2998 WPA_EVENT_SCAN_STARTED "id=%u",
2999 wpa_s->manual_scan_id);
3001 wpa_msg_ctrl(wpa_s, MSG_INFO,
3002 WPA_EVENT_SCAN_STARTED);
3005 wpa_dbg(wpa_s, MSG_DEBUG, "External program started a scan");
3006 wpa_s->external_scan_running = 1;
3007 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_SCAN_STARTED);
3010 case EVENT_SCAN_RESULTS:
3011 if (os_reltime_initialized(&wpa_s->scan_start_time)) {
3012 struct os_reltime now, diff;
3013 os_get_reltime(&now);
3014 os_reltime_sub(&now, &wpa_s->scan_start_time, &diff);
3015 wpa_s->scan_start_time.sec = 0;
3016 wpa_s->scan_start_time.usec = 0;
3017 wpa_dbg(wpa_s, MSG_DEBUG, "Scan completed in %ld.%06ld seconds",
3018 diff.sec, diff.usec);
3020 wpa_supplicant_event_scan_results(wpa_s, data);
3021 wpa_s->own_scan_running = 0;
3022 wpa_s->external_scan_running = 0;
3023 radio_work_check_next(wpa_s);
3025 #endif /* CONFIG_NO_SCAN_PROCESSING */
3026 case EVENT_ASSOCINFO:
3027 wpa_supplicant_event_associnfo(wpa_s, data);
3029 case EVENT_INTERFACE_STATUS:
3030 wpa_supplicant_event_interface_status(wpa_s, data);
3032 case EVENT_PMKID_CANDIDATE:
3033 wpa_supplicant_event_pmkid_candidate(wpa_s, data);
3035 #ifdef CONFIG_PEERKEY
3036 case EVENT_STKSTART:
3037 wpa_supplicant_event_stkstart(wpa_s, data);
3039 #endif /* CONFIG_PEERKEY */
3042 wpa_supplicant_event_tdls(wpa_s, data);
3044 #endif /* CONFIG_TDLS */
3047 wpa_supplicant_event_wnm(wpa_s, data);
3049 #endif /* CONFIG_WNM */
3050 #ifdef CONFIG_IEEE80211R
3051 case EVENT_FT_RESPONSE:
3052 wpa_supplicant_event_ft_response(wpa_s, data);
3054 #endif /* CONFIG_IEEE80211R */
3055 #ifdef CONFIG_IBSS_RSN
3056 case EVENT_IBSS_RSN_START:
3057 wpa_supplicant_event_ibss_rsn_start(wpa_s, data);
3059 #endif /* CONFIG_IBSS_RSN */
3060 case EVENT_ASSOC_REJECT:
3061 if (data->assoc_reject.bssid)
3062 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_ASSOC_REJECT
3063 "bssid=" MACSTR " status_code=%u",
3064 MAC2STR(data->assoc_reject.bssid),
3065 data->assoc_reject.status_code);
3067 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_ASSOC_REJECT
3069 data->assoc_reject.status_code);
3070 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
3071 sme_event_assoc_reject(wpa_s, data);
3073 const u8 *bssid = data->assoc_reject.bssid;
3074 if (bssid == NULL || is_zero_ether_addr(bssid))
3075 bssid = wpa_s->pending_bssid;
3076 wpas_connection_failed(wpa_s, bssid);
3077 wpa_supplicant_mark_disassoc(wpa_s);
3080 case EVENT_AUTH_TIMED_OUT:
3081 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
3082 sme_event_auth_timed_out(wpa_s, data);
3084 case EVENT_ASSOC_TIMED_OUT:
3085 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
3086 sme_event_assoc_timed_out(wpa_s, data);
3088 case EVENT_TX_STATUS:
3089 wpa_dbg(wpa_s, MSG_DEBUG, "EVENT_TX_STATUS dst=" MACSTR
3090 " type=%d stype=%d",
3091 MAC2STR(data->tx_status.dst),
3092 data->tx_status.type, data->tx_status.stype);
3094 if (wpa_s->ap_iface == NULL) {
3095 #ifdef CONFIG_OFFCHANNEL
3096 if (data->tx_status.type == WLAN_FC_TYPE_MGMT &&
3097 data->tx_status.stype == WLAN_FC_STYPE_ACTION)
3098 offchannel_send_action_tx_status(
3099 wpa_s, data->tx_status.dst,
3100 data->tx_status.data,
3101 data->tx_status.data_len,
3102 data->tx_status.ack ?
3103 OFFCHANNEL_SEND_ACTION_SUCCESS :
3104 OFFCHANNEL_SEND_ACTION_NO_ACK);
3105 #endif /* CONFIG_OFFCHANNEL */
3108 #endif /* CONFIG_AP */
3109 #ifdef CONFIG_OFFCHANNEL
3110 wpa_dbg(wpa_s, MSG_DEBUG, "EVENT_TX_STATUS pending_dst="
3111 MACSTR, MAC2STR(wpa_s->parent->pending_action_dst));
3113 * Catch TX status events for Action frames we sent via group
3114 * interface in GO mode.
3116 if (data->tx_status.type == WLAN_FC_TYPE_MGMT &&
3117 data->tx_status.stype == WLAN_FC_STYPE_ACTION &&
3118 os_memcmp(wpa_s->parent->pending_action_dst,
3119 data->tx_status.dst, ETH_ALEN) == 0) {
3120 offchannel_send_action_tx_status(
3121 wpa_s->parent, data->tx_status.dst,
3122 data->tx_status.data,
3123 data->tx_status.data_len,
3124 data->tx_status.ack ?
3125 OFFCHANNEL_SEND_ACTION_SUCCESS :
3126 OFFCHANNEL_SEND_ACTION_NO_ACK);
3129 #endif /* CONFIG_OFFCHANNEL */
3131 switch (data->tx_status.type) {
3132 case WLAN_FC_TYPE_MGMT:
3133 ap_mgmt_tx_cb(wpa_s, data->tx_status.data,
3134 data->tx_status.data_len,
3135 data->tx_status.stype,
3136 data->tx_status.ack);
3138 case WLAN_FC_TYPE_DATA:
3139 ap_tx_status(wpa_s, data->tx_status.dst,
3140 data->tx_status.data,
3141 data->tx_status.data_len,
3142 data->tx_status.ack);
3145 #endif /* CONFIG_AP */
3148 case EVENT_EAPOL_TX_STATUS:
3149 ap_eapol_tx_status(wpa_s, data->eapol_tx_status.dst,
3150 data->eapol_tx_status.data,
3151 data->eapol_tx_status.data_len,
3152 data->eapol_tx_status.ack);
3154 case EVENT_DRIVER_CLIENT_POLL_OK:
3155 ap_client_poll_ok(wpa_s, data->client_poll.addr);
3157 case EVENT_RX_FROM_UNKNOWN:
3158 if (wpa_s->ap_iface == NULL)
3160 ap_rx_from_unknown_sta(wpa_s, data->rx_from_unknown.addr,
3161 data->rx_from_unknown.wds);
3163 case EVENT_CH_SWITCH:
3166 if (!wpa_s->ap_iface) {
3167 wpa_dbg(wpa_s, MSG_DEBUG, "AP: Ignore channel switch "
3168 "event in non-AP mode");
3172 wpas_ap_ch_switch(wpa_s, data->ch_switch.freq,
3173 data->ch_switch.ht_enabled,
3174 data->ch_switch.ch_offset,
3175 data->ch_switch.ch_width,
3176 data->ch_switch.cf1,
3177 data->ch_switch.cf2);
3179 #endif /* CONFIG_AP */
3180 case EVENT_RX_MGMT: {
3182 const struct ieee80211_mgmt *mgmt;
3184 #ifdef CONFIG_TESTING_OPTIONS
3185 if (wpa_s->ext_mgmt_frame_handling) {
3186 struct rx_mgmt *rx = &data->rx_mgmt;
3187 size_t hex_len = 2 * rx->frame_len + 1;
3188 char *hex = os_malloc(hex_len);
3190 wpa_snprintf_hex(hex, hex_len,
3191 rx->frame, rx->frame_len);
3192 wpa_msg(wpa_s, MSG_INFO, "MGMT-RX freq=%d datarate=%u ssi_signal=%d %s",
3193 rx->freq, rx->datarate, rx->ssi_signal,
3199 #endif /* CONFIG_TESTING_OPTIONS */
3201 mgmt = (const struct ieee80211_mgmt *)
3202 data->rx_mgmt.frame;
3203 fc = le_to_host16(mgmt->frame_control);
3204 stype = WLAN_FC_GET_STYPE(fc);
3207 if (wpa_s->ap_iface == NULL) {
3208 #endif /* CONFIG_AP */
3210 if (stype == WLAN_FC_STYPE_PROBE_REQ &&
3211 data->rx_mgmt.frame_len > 24) {
3212 const u8 *src = mgmt->sa;
3213 const u8 *ie = mgmt->u.probe_req.variable;
3214 size_t ie_len = data->rx_mgmt.frame_len -
3215 (mgmt->u.probe_req.variable -
3216 data->rx_mgmt.frame);
3217 wpas_p2p_probe_req_rx(
3218 wpa_s, src, mgmt->da,
3219 mgmt->bssid, ie, ie_len,
3220 data->rx_mgmt.ssi_signal);
3223 #endif /* CONFIG_P2P */
3224 #ifdef CONFIG_IBSS_RSN
3225 if (stype == WLAN_FC_STYPE_AUTH &&
3226 data->rx_mgmt.frame_len >= 30) {
3227 wpa_supplicant_event_ibss_auth(wpa_s, data);
3230 #endif /* CONFIG_IBSS_RSN */
3232 if (stype == WLAN_FC_STYPE_ACTION) {
3233 wpas_event_rx_mgmt_action(
3234 wpa_s, data->rx_mgmt.frame,
3235 data->rx_mgmt.frame_len,
3236 data->rx_mgmt.freq);
3240 wpa_dbg(wpa_s, MSG_DEBUG, "AP: ignore received "
3241 "management frame in non-AP mode");
3246 if (stype == WLAN_FC_STYPE_PROBE_REQ &&
3247 data->rx_mgmt.frame_len > 24) {
3248 const u8 *ie = mgmt->u.probe_req.variable;
3249 size_t ie_len = data->rx_mgmt.frame_len -
3250 (mgmt->u.probe_req.variable -
3251 data->rx_mgmt.frame);
3253 wpas_notify_preq(wpa_s, mgmt->sa, mgmt->da,
3254 mgmt->bssid, ie, ie_len,
3255 data->rx_mgmt.ssi_signal);
3258 ap_mgmt_rx(wpa_s, &data->rx_mgmt);
3259 #endif /* CONFIG_AP */
3262 case EVENT_RX_PROBE_REQ:
3263 if (data->rx_probe_req.sa == NULL ||
3264 data->rx_probe_req.ie == NULL)
3267 if (wpa_s->ap_iface) {
3268 hostapd_probe_req_rx(wpa_s->ap_iface->bss[0],
3269 data->rx_probe_req.sa,
3270 data->rx_probe_req.da,
3271 data->rx_probe_req.bssid,
3272 data->rx_probe_req.ie,
3273 data->rx_probe_req.ie_len,
3274 data->rx_probe_req.ssi_signal);
3277 #endif /* CONFIG_AP */
3278 wpas_p2p_probe_req_rx(wpa_s, data->rx_probe_req.sa,
3279 data->rx_probe_req.da,
3280 data->rx_probe_req.bssid,
3281 data->rx_probe_req.ie,
3282 data->rx_probe_req.ie_len,
3283 data->rx_probe_req.ssi_signal);
3285 case EVENT_REMAIN_ON_CHANNEL:
3286 #ifdef CONFIG_OFFCHANNEL
3287 offchannel_remain_on_channel_cb(
3288 wpa_s, data->remain_on_channel.freq,
3289 data->remain_on_channel.duration);
3290 #endif /* CONFIG_OFFCHANNEL */
3291 wpas_p2p_remain_on_channel_cb(
3292 wpa_s, data->remain_on_channel.freq,
3293 data->remain_on_channel.duration);
3295 case EVENT_CANCEL_REMAIN_ON_CHANNEL:
3296 #ifdef CONFIG_OFFCHANNEL
3297 offchannel_cancel_remain_on_channel_cb(
3298 wpa_s, data->remain_on_channel.freq);
3299 #endif /* CONFIG_OFFCHANNEL */
3300 wpas_p2p_cancel_remain_on_channel_cb(
3301 wpa_s, data->remain_on_channel.freq);
3303 case EVENT_EAPOL_RX:
3304 wpa_supplicant_rx_eapol(wpa_s, data->eapol_rx.src,
3305 data->eapol_rx.data,
3306 data->eapol_rx.data_len);
3308 case EVENT_SIGNAL_CHANGE:
3309 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_SIGNAL_CHANGE
3310 "above=%d signal=%d noise=%d txrate=%d",
3311 data->signal_change.above_threshold,
3312 data->signal_change.current_signal,
3313 data->signal_change.current_noise,
3314 data->signal_change.current_txrate);
3315 bgscan_notify_signal_change(
3316 wpa_s, data->signal_change.above_threshold,
3317 data->signal_change.current_signal,
3318 data->signal_change.current_noise,
3319 data->signal_change.current_txrate);
3321 case EVENT_INTERFACE_ENABLED:
3322 wpa_dbg(wpa_s, MSG_DEBUG, "Interface was enabled");
3323 if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) {
3324 wpa_supplicant_update_mac_addr(wpa_s);
3325 if (wpa_s->p2p_mgmt) {
3326 wpa_supplicant_set_state(wpa_s,
3332 if (!wpa_s->ap_iface) {
3333 wpa_supplicant_set_state(wpa_s,
3335 wpa_supplicant_req_scan(wpa_s, 0, 0);
3337 wpa_supplicant_set_state(wpa_s,
3339 #else /* CONFIG_AP */
3340 wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
3341 wpa_supplicant_req_scan(wpa_s, 0, 0);
3342 #endif /* CONFIG_AP */
3345 case EVENT_INTERFACE_DISABLED:
3346 wpa_dbg(wpa_s, MSG_DEBUG, "Interface was disabled");
3348 if (wpa_s->p2p_group_interface == P2P_GROUP_INTERFACE_GO ||
3349 (wpa_s->current_ssid && wpa_s->current_ssid->p2p_group &&
3350 wpa_s->current_ssid->mode == WPAS_MODE_P2P_GO)) {
3352 * The interface was externally disabled. Remove
3353 * it assuming an external entity will start a
3354 * new session if needed.
3356 wpas_p2p_disconnect(wpa_s);
3359 if (wpa_s->p2p_scan_work && wpa_s->global->p2p &&
3360 p2p_in_progress(wpa_s->global->p2p) > 1) {
3361 /* This radio work will be cancelled, so clear P2P
3364 p2p_stop_find(wpa_s->global->p2p);
3366 #endif /* CONFIG_P2P */
3368 if (wpa_s->wpa_state >= WPA_AUTHENTICATING) {
3370 * Indicate disconnection to keep ctrl_iface events
3373 wpa_supplicant_event_disassoc(
3374 wpa_s, WLAN_REASON_DEAUTH_LEAVING, 1);
3376 wpa_supplicant_mark_disassoc(wpa_s);
3377 radio_remove_works(wpa_s, NULL, 0);
3379 wpa_supplicant_set_state(wpa_s, WPA_INTERFACE_DISABLED);
3381 case EVENT_CHANNEL_LIST_CHANGED:
3382 wpa_supplicant_update_channel_list(
3383 wpa_s, &data->channel_list_changed);
3385 case EVENT_INTERFACE_UNAVAILABLE:
3386 wpas_p2p_interface_unavailable(wpa_s);
3388 case EVENT_BEST_CHANNEL:
3389 wpa_dbg(wpa_s, MSG_DEBUG, "Best channel event received "
3391 data->best_chan.freq_24, data->best_chan.freq_5,
3392 data->best_chan.freq_overall);
3393 wpa_s->best_24_freq = data->best_chan.freq_24;
3394 wpa_s->best_5_freq = data->best_chan.freq_5;
3395 wpa_s->best_overall_freq = data->best_chan.freq_overall;
3396 wpas_p2p_update_best_channels(wpa_s, data->best_chan.freq_24,
3397 data->best_chan.freq_5,
3398 data->best_chan.freq_overall);
3400 case EVENT_UNPROT_DEAUTH:
3401 wpa_supplicant_event_unprot_deauth(wpa_s,
3402 &data->unprot_deauth);
3404 case EVENT_UNPROT_DISASSOC:
3405 wpa_supplicant_event_unprot_disassoc(wpa_s,
3406 &data->unprot_disassoc);
3408 case EVENT_STATION_LOW_ACK:
3410 if (wpa_s->ap_iface && data)
3411 hostapd_event_sta_low_ack(wpa_s->ap_iface->bss[0],
3412 data->low_ack.addr);
3413 #endif /* CONFIG_AP */
3416 wpa_tdls_disable_unreachable_link(wpa_s->wpa,
3417 data->low_ack.addr);
3418 #endif /* CONFIG_TDLS */
3420 case EVENT_IBSS_PEER_LOST:
3421 #ifdef CONFIG_IBSS_RSN
3422 ibss_rsn_stop(wpa_s->ibss_rsn, data->ibss_peer_lost.peer);
3423 #endif /* CONFIG_IBSS_RSN */
3425 case EVENT_DRIVER_GTK_REKEY:
3426 if (os_memcmp(data->driver_gtk_rekey.bssid,
3427 wpa_s->bssid, ETH_ALEN))
3431 wpa_sm_update_replay_ctr(wpa_s->wpa,
3432 data->driver_gtk_rekey.replay_ctr);
3434 case EVENT_SCHED_SCAN_STOPPED:
3436 wpa_s->sched_scanning = 0;
3437 wpa_supplicant_notify_scanning(wpa_s, 0);
3439 if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED)
3443 * Start a new sched scan to continue searching for more SSIDs
3444 * either if timed out or PNO schedule scan is pending.
3446 if (wpa_s->sched_scan_timed_out) {
3447 wpa_supplicant_req_sched_scan(wpa_s);
3448 } else if (wpa_s->pno_sched_pending) {
3449 wpa_s->pno_sched_pending = 0;
3450 wpas_start_pno(wpa_s);
3454 case EVENT_WPS_BUTTON_PUSHED:
3456 wpas_wps_start_pbc(wpa_s, NULL, 0);
3457 #endif /* CONFIG_WPS */
3459 case EVENT_AVOID_FREQUENCIES:
3460 wpa_supplicant_notify_avoid_freq(wpa_s, data);
3462 case EVENT_CONNECT_FAILED_REASON:
3464 if (!wpa_s->ap_iface || !data)
3466 hostapd_event_connect_failed_reason(
3467 wpa_s->ap_iface->bss[0],
3468 data->connect_failed_reason.addr,
3469 data->connect_failed_reason.code);
3470 #endif /* CONFIG_AP */
3473 wpa_msg(wpa_s, MSG_INFO, "Unknown event %d", event);