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 rate_match(struct wpa_supplicant *wpa_s, struct wpa_bss *bss)
587 const struct hostapd_hw_modes *mode = NULL, *modes;
588 const u8 scan_ie[2] = { WLAN_EID_SUPP_RATES, WLAN_EID_EXT_SUPP_RATES };
593 return 1; /* Cannot do matching without knowing band */
595 modes = wpa_s->hw.modes;
598 * The driver does not provide any additional information
599 * about the utilized hardware, so allow the connection attempt
605 for (i = 0; i < wpa_s->hw.num_modes; i++) {
606 for (j = 0; j < modes[i].num_channels; j++) {
607 int freq = modes[i].channels[j].freq;
608 if (freq == bss->freq) {
610 mode->mode == HOSTAPD_MODE_IEEE80211G)
611 break; /* do not allow 802.11b replace
622 for (i = 0; i < (int) sizeof(scan_ie); i++) {
623 rate_ie = wpa_bss_get_ie(bss, scan_ie[i]);
627 for (j = 2; j < rate_ie[1] + 2; j++) {
628 int flagged = !!(rate_ie[j] & 0x80);
629 int r = (rate_ie[j] & 0x7f) * 5;
632 * IEEE Std 802.11n-2009 7.3.2.2:
633 * The new BSS Membership selector value is encoded
634 * like a legacy basic rate, but it is not a rate and
635 * only indicates if the BSS members are required to
636 * support the mandatory features of Clause 20 [HT PHY]
637 * in order to join the BSS.
639 if (flagged && ((rate_ie[j] & 0x7f) ==
640 BSS_MEMBERSHIP_SELECTOR_HT_PHY)) {
641 if (!ht_supported(mode)) {
642 wpa_dbg(wpa_s, MSG_DEBUG,
643 " hardware does not support "
650 /* There's also a VHT selector for 802.11ac */
651 if (flagged && ((rate_ie[j] & 0x7f) ==
652 BSS_MEMBERSHIP_SELECTOR_VHT_PHY)) {
653 if (!vht_supported(mode)) {
654 wpa_dbg(wpa_s, MSG_DEBUG,
655 " hardware does not support "
665 /* check for legacy basic rates */
666 for (k = 0; k < mode->num_rates; k++) {
667 if (mode->rates[k] == r)
670 if (k == mode->num_rates) {
672 * IEEE Std 802.11-2007 7.3.2.2 demands that in
673 * order to join a BSS all required rates
674 * have to be supported by the hardware.
676 wpa_dbg(wpa_s, MSG_DEBUG, " hardware does "
677 "not support required rate %d.%d Mbps",
689 * Test whether BSS is in an ESS.
690 * This is done differently in DMG (60 GHz) and non-DMG bands
692 static int bss_is_ess(struct wpa_bss *bss)
694 if (bss_is_dmg(bss)) {
695 return (bss->caps & IEEE80211_CAP_DMG_MASK) ==
696 IEEE80211_CAP_DMG_AP;
699 return ((bss->caps & (IEEE80211_CAP_ESS | IEEE80211_CAP_IBSS)) ==
704 static struct wpa_ssid * wpa_scan_res_match(struct wpa_supplicant *wpa_s,
705 int i, struct wpa_bss *bss,
706 struct wpa_ssid *group,
709 u8 wpa_ie_len, rsn_ie_len;
711 struct wpa_blacklist *e;
713 struct wpa_ssid *ssid;
716 ie = wpa_bss_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE);
717 wpa_ie_len = ie ? ie[1] : 0;
719 ie = wpa_bss_get_ie(bss, WLAN_EID_RSN);
720 rsn_ie_len = ie ? ie[1] : 0;
722 ie = wpa_bss_get_vendor_ie(bss, OSEN_IE_VENDOR_TYPE);
725 wpa_dbg(wpa_s, MSG_DEBUG, "%d: " MACSTR " ssid='%s' "
726 "wpa_ie_len=%u rsn_ie_len=%u caps=0x%x level=%d%s%s%s",
727 i, MAC2STR(bss->bssid), wpa_ssid_txt(bss->ssid, bss->ssid_len),
728 wpa_ie_len, rsn_ie_len, bss->caps, bss->level,
729 wpa_bss_get_vendor_ie(bss, WPS_IE_VENDOR_TYPE) ? " wps" : "",
730 (wpa_bss_get_vendor_ie(bss, P2P_IE_VENDOR_TYPE) ||
731 wpa_bss_get_vendor_ie_beacon(bss, P2P_IE_VENDOR_TYPE)) ?
733 osen ? " osen=1" : "");
735 e = wpa_blacklist_get(wpa_s, bss->bssid);
738 if (wpa_supplicant_enabled_networks(wpa_s) == 1) {
740 * When only a single network is enabled, we can
741 * trigger blacklisting on the first failure. This
742 * should not be done with multiple enabled networks to
743 * avoid getting forced to move into a worse ESS on
744 * single error if there are no other BSSes of the
749 if (e->count > limit) {
750 wpa_dbg(wpa_s, MSG_DEBUG, " skip - blacklisted "
751 "(count=%d limit=%d)", e->count, limit);
756 if (bss->ssid_len == 0) {
757 wpa_dbg(wpa_s, MSG_DEBUG, " skip - SSID not known");
761 if (disallowed_bssid(wpa_s, bss->bssid)) {
762 wpa_dbg(wpa_s, MSG_DEBUG, " skip - BSSID disallowed");
766 if (disallowed_ssid(wpa_s, bss->ssid, bss->ssid_len)) {
767 wpa_dbg(wpa_s, MSG_DEBUG, " skip - SSID disallowed");
771 wpa = wpa_ie_len > 0 || rsn_ie_len > 0;
773 for (ssid = group; ssid; ssid = only_first_ssid ? NULL : ssid->pnext) {
774 int check_ssid = wpa ? 1 : (ssid->ssid_len != 0);
777 if (wpas_network_disabled(wpa_s, ssid)) {
778 wpa_dbg(wpa_s, MSG_DEBUG, " skip - disabled");
782 res = wpas_temp_disabled(wpa_s, ssid);
784 wpa_dbg(wpa_s, MSG_DEBUG, " skip - disabled "
785 "temporarily for %d second(s)", res);
790 if ((ssid->key_mgmt & WPA_KEY_MGMT_WPS) && e && e->count > 0) {
791 wpa_dbg(wpa_s, MSG_DEBUG, " skip - blacklisted "
796 if (wpa && ssid->ssid_len == 0 &&
797 wpas_wps_ssid_wildcard_ok(wpa_s, ssid, bss))
800 if (!wpa && (ssid->key_mgmt & WPA_KEY_MGMT_WPS)) {
801 /* Only allow wildcard SSID match if an AP
802 * advertises active WPS operation that matches
805 if (ssid->ssid_len == 0 &&
806 wpas_wps_ssid_wildcard_ok(wpa_s, ssid, bss))
809 #endif /* CONFIG_WPS */
811 if (ssid->bssid_set && ssid->ssid_len == 0 &&
812 os_memcmp(bss->bssid, ssid->bssid, ETH_ALEN) == 0)
816 (bss->ssid_len != ssid->ssid_len ||
817 os_memcmp(bss->ssid, ssid->ssid, bss->ssid_len) != 0)) {
818 wpa_dbg(wpa_s, MSG_DEBUG, " skip - SSID mismatch");
822 if (ssid->bssid_set &&
823 os_memcmp(bss->bssid, ssid->bssid, ETH_ALEN) != 0) {
824 wpa_dbg(wpa_s, MSG_DEBUG, " skip - BSSID mismatch");
828 if (!wpa_supplicant_ssid_bss_match(wpa_s, ssid, bss))
832 !(ssid->key_mgmt & WPA_KEY_MGMT_NONE) &&
833 !(ssid->key_mgmt & WPA_KEY_MGMT_WPS) &&
834 !(ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X_NO_WPA)) {
835 wpa_dbg(wpa_s, MSG_DEBUG, " skip - non-WPA network "
840 if (wpa && !wpa_key_mgmt_wpa(ssid->key_mgmt) &&
842 wpa_dbg(wpa_s, MSG_DEBUG, " skip - ignore WPA/WPA2 AP for WEP network block");
846 if ((ssid->key_mgmt & WPA_KEY_MGMT_OSEN) && !osen) {
847 wpa_dbg(wpa_s, MSG_DEBUG, " skip - non-OSEN network "
852 if (!wpa_supplicant_match_privacy(bss, ssid)) {
853 wpa_dbg(wpa_s, MSG_DEBUG, " skip - privacy "
858 if (!bss_is_ess(bss)) {
859 wpa_dbg(wpa_s, MSG_DEBUG, " skip - not ESS network");
863 if (!freq_allowed(ssid->freq_list, bss->freq)) {
864 wpa_dbg(wpa_s, MSG_DEBUG, " skip - frequency not "
869 if (!rate_match(wpa_s, bss)) {
870 wpa_dbg(wpa_s, MSG_DEBUG, " skip - rate sets do "
876 if (ssid->p2p_group &&
877 !wpa_bss_get_vendor_ie(bss, P2P_IE_VENDOR_TYPE) &&
878 !wpa_bss_get_vendor_ie_beacon(bss, P2P_IE_VENDOR_TYPE)) {
879 wpa_dbg(wpa_s, MSG_DEBUG, " skip - no P2P IE seen");
883 if (!is_zero_ether_addr(ssid->go_p2p_dev_addr)) {
884 struct wpabuf *p2p_ie;
885 u8 dev_addr[ETH_ALEN];
887 ie = wpa_bss_get_vendor_ie(bss, P2P_IE_VENDOR_TYPE);
889 wpa_dbg(wpa_s, MSG_DEBUG, " skip - no P2P element");
892 p2p_ie = wpa_bss_get_vendor_ie_multi(
893 bss, P2P_IE_VENDOR_TYPE);
894 if (p2p_ie == NULL) {
895 wpa_dbg(wpa_s, MSG_DEBUG, " skip - could not fetch P2P element");
899 if (p2p_parse_dev_addr_in_p2p_ie(p2p_ie, dev_addr) < 0
900 || os_memcmp(dev_addr, ssid->go_p2p_dev_addr,
902 wpa_dbg(wpa_s, MSG_DEBUG, " skip - no matching GO P2P Device Address in P2P element");
910 * TODO: skip the AP if its P2P IE has Group Formation
911 * bit set in the P2P Group Capability Bitmap and we
912 * are not in Group Formation with that device.
914 #endif /* CONFIG_P2P */
916 /* Matching configuration found */
920 /* No matching configuration found */
925 static struct wpa_bss *
926 wpa_supplicant_select_bss(struct wpa_supplicant *wpa_s,
927 struct wpa_ssid *group,
928 struct wpa_ssid **selected_ssid,
934 wpa_dbg(wpa_s, MSG_DEBUG, "Try to find BSS matching pre-selected network id=%d",
937 wpa_dbg(wpa_s, MSG_DEBUG, "Selecting BSS from priority group %d",
940 for (i = 0; i < wpa_s->last_scan_res_used; i++) {
941 struct wpa_bss *bss = wpa_s->last_scan_res[i];
942 *selected_ssid = wpa_scan_res_match(wpa_s, i, bss, group,
946 wpa_dbg(wpa_s, MSG_DEBUG, " selected BSS " MACSTR
949 wpa_ssid_txt(bss->ssid, bss->ssid_len));
957 struct wpa_bss * wpa_supplicant_pick_network(struct wpa_supplicant *wpa_s,
958 struct wpa_ssid **selected_ssid)
960 struct wpa_bss *selected = NULL;
962 struct wpa_ssid *next_ssid = NULL;
964 if (wpa_s->last_scan_res == NULL ||
965 wpa_s->last_scan_res_used == 0)
966 return NULL; /* no scan results from last update */
968 if (wpa_s->next_ssid) {
969 struct wpa_ssid *ssid;
971 /* check that next_ssid is still valid */
972 for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next) {
973 if (ssid == wpa_s->next_ssid)
977 wpa_s->next_ssid = NULL;
980 while (selected == NULL) {
981 for (prio = 0; prio < wpa_s->conf->num_prio; prio++) {
982 if (next_ssid && next_ssid->priority ==
983 wpa_s->conf->pssid[prio]->priority) {
984 selected = wpa_supplicant_select_bss(
985 wpa_s, next_ssid, selected_ssid, 1);
989 selected = wpa_supplicant_select_bss(
990 wpa_s, wpa_s->conf->pssid[prio],
996 if (selected == NULL && wpa_s->blacklist &&
997 !wpa_s->countermeasures) {
998 wpa_dbg(wpa_s, MSG_DEBUG, "No APs found - clear "
999 "blacklist and try again");
1000 wpa_blacklist_clear(wpa_s);
1001 wpa_s->blacklist_cleared++;
1002 } else if (selected == NULL)
1010 static void wpa_supplicant_req_new_scan(struct wpa_supplicant *wpa_s,
1011 int timeout_sec, int timeout_usec)
1013 if (!wpa_supplicant_enabled_networks(wpa_s)) {
1015 * No networks are enabled; short-circuit request so
1016 * we don't wait timeout seconds before transitioning
1017 * to INACTIVE state.
1019 wpa_dbg(wpa_s, MSG_DEBUG, "Short-circuit new scan request "
1020 "since there are no enabled networks");
1021 wpa_supplicant_set_state(wpa_s, WPA_INACTIVE);
1025 wpa_s->scan_for_connection = 1;
1026 wpa_supplicant_req_scan(wpa_s, timeout_sec, timeout_usec);
1030 int wpa_supplicant_connect(struct wpa_supplicant *wpa_s,
1031 struct wpa_bss *selected,
1032 struct wpa_ssid *ssid)
1034 if (wpas_wps_scan_pbc_overlap(wpa_s, selected, ssid)) {
1035 wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_OVERLAP
1036 "PBC session overlap");
1038 if (wpa_s->p2p_group_interface == P2P_GROUP_INTERFACE_CLIENT ||
1039 wpa_s->p2p_in_provisioning) {
1040 eloop_register_timeout(0, 0, wpas_p2p_pbc_overlap_cb,
1044 #endif /* CONFIG_P2P */
1047 wpas_wps_cancel(wpa_s);
1048 #endif /* CONFIG_WPS */
1052 wpa_msg(wpa_s, MSG_DEBUG,
1053 "Considering connect request: reassociate: %d selected: "
1054 MACSTR " bssid: " MACSTR " pending: " MACSTR
1055 " wpa_state: %s ssid=%p current_ssid=%p",
1056 wpa_s->reassociate, MAC2STR(selected->bssid),
1057 MAC2STR(wpa_s->bssid), MAC2STR(wpa_s->pending_bssid),
1058 wpa_supplicant_state_txt(wpa_s->wpa_state),
1059 ssid, wpa_s->current_ssid);
1062 * Do not trigger new association unless the BSSID has changed or if
1063 * reassociation is requested. If we are in process of associating with
1064 * the selected BSSID, do not trigger new attempt.
1066 if (wpa_s->reassociate ||
1067 (os_memcmp(selected->bssid, wpa_s->bssid, ETH_ALEN) != 0 &&
1068 ((wpa_s->wpa_state != WPA_ASSOCIATING &&
1069 wpa_s->wpa_state != WPA_AUTHENTICATING) ||
1070 (!is_zero_ether_addr(wpa_s->pending_bssid) &&
1071 os_memcmp(selected->bssid, wpa_s->pending_bssid, ETH_ALEN) !=
1073 (is_zero_ether_addr(wpa_s->pending_bssid) &&
1074 ssid != wpa_s->current_ssid)))) {
1075 if (wpa_supplicant_scard_init(wpa_s, ssid)) {
1076 wpa_supplicant_req_new_scan(wpa_s, 10, 0);
1079 wpa_msg(wpa_s, MSG_DEBUG, "Request association with " MACSTR,
1080 MAC2STR(selected->bssid));
1081 wpa_supplicant_associate(wpa_s, selected, ssid);
1083 wpa_dbg(wpa_s, MSG_DEBUG, "Already associated or trying to "
1084 "connect with the selected AP");
1091 static struct wpa_ssid *
1092 wpa_supplicant_pick_new_network(struct wpa_supplicant *wpa_s)
1095 struct wpa_ssid *ssid;
1097 for (prio = 0; prio < wpa_s->conf->num_prio; prio++) {
1098 for (ssid = wpa_s->conf->pssid[prio]; ssid; ssid = ssid->pnext)
1100 if (wpas_network_disabled(wpa_s, ssid))
1102 if (ssid->mode == IEEE80211_MODE_IBSS ||
1103 ssid->mode == IEEE80211_MODE_AP)
1111 /* TODO: move the rsn_preauth_scan_result*() to be called from notify.c based
1112 * on BSS added and BSS changed events */
1113 static void wpa_supplicant_rsn_preauth_scan_results(
1114 struct wpa_supplicant *wpa_s)
1116 struct wpa_bss *bss;
1118 if (rsn_preauth_scan_results(wpa_s->wpa) < 0)
1121 dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) {
1122 const u8 *ssid, *rsn;
1124 ssid = wpa_bss_get_ie(bss, WLAN_EID_SSID);
1128 rsn = wpa_bss_get_ie(bss, WLAN_EID_RSN);
1132 rsn_preauth_scan_result(wpa_s->wpa, bss->bssid, ssid, rsn);
1138 static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s,
1139 struct wpa_bss *selected,
1140 struct wpa_ssid *ssid)
1142 struct wpa_bss *current_bss = NULL;
1145 if (wpa_s->reassociate)
1146 return 1; /* explicit request to reassociate */
1147 if (wpa_s->wpa_state < WPA_ASSOCIATED)
1148 return 1; /* we are not associated; continue */
1149 if (wpa_s->current_ssid == NULL)
1150 return 1; /* unknown current SSID */
1151 if (wpa_s->current_ssid != ssid)
1152 return 1; /* different network block */
1154 if (wpas_driver_bss_selection(wpa_s))
1155 return 0; /* Driver-based roaming */
1157 if (wpa_s->current_ssid->ssid)
1158 current_bss = wpa_bss_get(wpa_s, wpa_s->bssid,
1159 wpa_s->current_ssid->ssid,
1160 wpa_s->current_ssid->ssid_len);
1162 current_bss = wpa_bss_get_bssid(wpa_s, wpa_s->bssid);
1165 return 1; /* current BSS not seen in scan results */
1167 if (current_bss == selected)
1170 if (selected->last_update_idx > current_bss->last_update_idx)
1171 return 1; /* current BSS not seen in the last scan */
1173 #ifndef CONFIG_NO_ROAMING
1174 wpa_dbg(wpa_s, MSG_DEBUG, "Considering within-ESS reassociation");
1175 wpa_dbg(wpa_s, MSG_DEBUG, "Current BSS: " MACSTR " level=%d",
1176 MAC2STR(current_bss->bssid), current_bss->level);
1177 wpa_dbg(wpa_s, MSG_DEBUG, "Selected BSS: " MACSTR " level=%d",
1178 MAC2STR(selected->bssid), selected->level);
1180 if (wpa_s->current_ssid->bssid_set &&
1181 os_memcmp(selected->bssid, wpa_s->current_ssid->bssid, ETH_ALEN) ==
1183 wpa_dbg(wpa_s, MSG_DEBUG, "Allow reassociation - selected BSS "
1184 "has preferred BSSID");
1188 if (current_bss->level < 0 && current_bss->level > selected->level) {
1189 wpa_dbg(wpa_s, MSG_DEBUG, "Skip roam - Current BSS has better "
1195 if (current_bss->level < 0) {
1196 if (current_bss->level < -85)
1198 else if (current_bss->level < -80)
1200 else if (current_bss->level < -75)
1202 else if (current_bss->level < -70)
1207 if (abs(current_bss->level - selected->level) < min_diff) {
1208 wpa_dbg(wpa_s, MSG_DEBUG, "Skip roam - too small difference "
1214 #else /* CONFIG_NO_ROAMING */
1216 #endif /* CONFIG_NO_ROAMING */
1220 /* Return != 0 if no scan results could be fetched or if scan results should not
1221 * be shared with other virtual interfaces. */
1222 static int _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s,
1223 union wpa_event_data *data,
1226 struct wpa_scan_results *scan_res = NULL;
1229 #ifndef CONFIG_NO_RANDOM_POOL
1231 #endif /* CONFIG_NO_RANDOM_POOL */
1234 if (wpa_s->ap_iface)
1236 #endif /* CONFIG_AP */
1238 wpa_supplicant_notify_scanning(wpa_s, 0);
1240 scan_res = wpa_supplicant_get_scan_results(wpa_s,
1241 data ? &data->scan_info :
1243 if (scan_res == NULL) {
1244 if (wpa_s->conf->ap_scan == 2 || ap ||
1245 wpa_s->scan_res_handler == scan_only_handler)
1249 wpa_dbg(wpa_s, MSG_DEBUG, "Failed to get scan results - try "
1251 wpa_supplicant_req_new_scan(wpa_s, 1, 0);
1253 goto scan_work_done;
1256 #ifndef CONFIG_NO_RANDOM_POOL
1257 num = scan_res->num;
1260 for (i = 0; i < num; i++) {
1262 struct wpa_scan_res *res = scan_res->res[i];
1263 buf[0] = res->bssid[5];
1264 buf[1] = res->qual & 0xff;
1265 buf[2] = res->noise & 0xff;
1266 buf[3] = res->level & 0xff;
1267 buf[4] = res->tsf & 0xff;
1268 random_add_randomness(buf, sizeof(buf));
1270 #endif /* CONFIG_NO_RANDOM_POOL */
1272 if (own_request && wpa_s->scan_res_handler &&
1273 (wpa_s->own_scan_running || !wpa_s->external_scan_running)) {
1274 void (*scan_res_handler)(struct wpa_supplicant *wpa_s,
1275 struct wpa_scan_results *scan_res);
1277 scan_res_handler = wpa_s->scan_res_handler;
1278 wpa_s->scan_res_handler = NULL;
1279 scan_res_handler(wpa_s, scan_res);
1281 goto scan_work_done;
1285 wpa_dbg(wpa_s, MSG_DEBUG, "Ignore scan results in AP mode");
1287 if (wpa_s->ap_iface->scan_cb)
1288 wpa_s->ap_iface->scan_cb(wpa_s->ap_iface);
1289 #endif /* CONFIG_AP */
1290 goto scan_work_done;
1293 wpa_dbg(wpa_s, MSG_DEBUG, "New scan results available (own=%u ext=%u)",
1294 wpa_s->own_scan_running, wpa_s->external_scan_running);
1295 if (wpa_s->last_scan_req == MANUAL_SCAN_REQ &&
1296 wpa_s->manual_scan_use_id && wpa_s->own_scan_running) {
1297 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_SCAN_RESULTS "id=%u",
1298 wpa_s->manual_scan_id);
1299 wpa_s->manual_scan_use_id = 0;
1301 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_SCAN_RESULTS);
1303 wpas_notify_scan_results(wpa_s);
1305 wpas_notify_scan_done(wpa_s, 1);
1307 if (!wpa_s->own_scan_running && wpa_s->external_scan_running) {
1308 wpa_dbg(wpa_s, MSG_DEBUG, "Do not use results from externally requested scan operation for network selection");
1309 wpa_scan_results_free(scan_res);
1313 if (sme_proc_obss_scan(wpa_s) > 0)
1314 goto scan_work_done;
1316 if ((wpa_s->conf->ap_scan == 2 && !wpas_wps_searching(wpa_s)))
1317 goto scan_work_done;
1319 if (autoscan_notify_scan(wpa_s, scan_res))
1320 goto scan_work_done;
1322 if (wpa_s->disconnected) {
1323 wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
1324 goto scan_work_done;
1327 if (!wpas_driver_bss_selection(wpa_s) &&
1328 bgscan_notify_scan(wpa_s, scan_res) == 1)
1329 goto scan_work_done;
1331 wpas_wps_update_ap_info(wpa_s, scan_res);
1333 wpa_scan_results_free(scan_res);
1335 if (wpa_s->scan_work) {
1336 struct wpa_radio_work *work = wpa_s->scan_work;
1337 wpa_s->scan_work = NULL;
1338 radio_work_done(work);
1341 return wpas_select_network_from_last_scan(wpa_s, 1, own_request);
1344 wpa_scan_results_free(scan_res);
1345 if (wpa_s->scan_work) {
1346 struct wpa_radio_work *work = wpa_s->scan_work;
1347 wpa_s->scan_work = NULL;
1348 radio_work_done(work);
1354 static int wpas_select_network_from_last_scan(struct wpa_supplicant *wpa_s,
1355 int new_scan, int own_request)
1357 struct wpa_bss *selected;
1358 struct wpa_ssid *ssid = NULL;
1360 selected = wpa_supplicant_pick_network(wpa_s, &ssid);
1364 skip = !wpa_supplicant_need_to_roam(wpa_s, selected, ssid);
1367 wpa_supplicant_rsn_preauth_scan_results(wpa_s);
1371 if (wpa_supplicant_connect(wpa_s, selected, ssid) < 0) {
1372 wpa_dbg(wpa_s, MSG_DEBUG, "Connect failed");
1376 wpa_supplicant_rsn_preauth_scan_results(wpa_s);
1378 * Do not notify other virtual radios of scan results since we do not
1379 * want them to start other associations at the same time.
1383 wpa_dbg(wpa_s, MSG_DEBUG, "No suitable network found");
1384 ssid = wpa_supplicant_pick_new_network(wpa_s);
1386 wpa_dbg(wpa_s, MSG_DEBUG, "Setup a new network");
1387 wpa_supplicant_associate(wpa_s, NULL, ssid);
1389 wpa_supplicant_rsn_preauth_scan_results(wpa_s);
1390 } else if (own_request) {
1392 * No SSID found. If SCAN results are as a result of
1393 * own scan request and not due to a scan request on
1394 * another shared interface, try another scan.
1396 int timeout_sec = wpa_s->scan_interval;
1397 int timeout_usec = 0;
1399 if (wpas_p2p_scan_no_go_seen(wpa_s) == 1)
1402 if (wpa_s->p2p_in_provisioning ||
1403 wpa_s->show_group_started ||
1404 wpa_s->p2p_in_invitation) {
1406 * Use shorter wait during P2P Provisioning
1407 * state and during P2P join-a-group operation
1408 * to speed up group formation.
1411 timeout_usec = 250000;
1412 wpa_supplicant_req_new_scan(wpa_s, timeout_sec,
1416 #endif /* CONFIG_P2P */
1417 #ifdef CONFIG_INTERWORKING
1418 if (wpa_s->conf->auto_interworking &&
1419 wpa_s->conf->interworking &&
1420 wpa_s->conf->cred) {
1421 wpa_dbg(wpa_s, MSG_DEBUG, "Interworking: "
1422 "start ANQP fetch since no matching "
1424 wpa_s->network_select = 1;
1425 wpa_s->auto_network_select = 1;
1426 interworking_start_fetch_anqp(wpa_s);
1429 #endif /* CONFIG_INTERWORKING */
1431 if (wpa_s->after_wps > 0 || wpas_wps_searching(wpa_s)) {
1432 wpa_dbg(wpa_s, MSG_DEBUG, "Use shorter wait during WPS processing");
1434 timeout_usec = 500000;
1435 wpa_supplicant_req_new_scan(wpa_s, timeout_sec,
1439 #endif /* CONFIG_WPS */
1440 if (wpa_supplicant_req_sched_scan(wpa_s))
1441 wpa_supplicant_req_new_scan(wpa_s, timeout_sec,
1449 static void wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s,
1450 union wpa_event_data *data)
1452 struct wpa_supplicant *ifs;
1454 if (_wpa_supplicant_event_scan_results(wpa_s, data, 1) != 0) {
1456 * If no scan results could be fetched, then no need to
1457 * notify those interfaces that did not actually request
1458 * this scan. Similarly, if scan results started a new operation on this
1459 * interface, do not notify other interfaces to avoid concurrent
1460 * operations during a connection attempt.
1466 * Check other interfaces to see if they share the same radio. If
1467 * so, they get updated with this same scan info.
1469 dl_list_for_each(ifs, &wpa_s->radio->ifaces, struct wpa_supplicant,
1472 wpa_printf(MSG_DEBUG, "%s: Updating scan results from "
1473 "sibling", ifs->ifname);
1474 _wpa_supplicant_event_scan_results(ifs, data, 0);
1479 #endif /* CONFIG_NO_SCAN_PROCESSING */
1482 int wpa_supplicant_fast_associate(struct wpa_supplicant *wpa_s)
1484 #ifdef CONFIG_NO_SCAN_PROCESSING
1486 #else /* CONFIG_NO_SCAN_PROCESSING */
1487 struct os_reltime now;
1489 if (wpa_s->last_scan_res_used <= 0)
1492 os_get_reltime(&now);
1493 if (os_reltime_expired(&now, &wpa_s->last_scan, 5)) {
1494 wpa_printf(MSG_DEBUG, "Fast associate: Old scan results");
1498 return wpas_select_network_from_last_scan(wpa_s, 0, 1);
1499 #endif /* CONFIG_NO_SCAN_PROCESSING */
1504 static void wnm_bss_keep_alive(void *eloop_ctx, void *sock_ctx)
1506 struct wpa_supplicant *wpa_s = eloop_ctx;
1508 if (wpa_s->wpa_state < WPA_ASSOCIATED)
1511 if (!wpa_s->no_keep_alive) {
1512 wpa_printf(MSG_DEBUG, "WNM: Send keep-alive to AP " MACSTR,
1513 MAC2STR(wpa_s->bssid));
1514 /* TODO: could skip this if normal data traffic has been sent */
1515 /* TODO: Consider using some more appropriate data frame for
1518 l2_packet_send(wpa_s->l2, wpa_s->bssid, 0x0800,
1523 if (wpa_s->sme.bss_max_idle_period) {
1525 msec = wpa_s->sme.bss_max_idle_period * 1024; /* times 1000 */
1528 eloop_register_timeout(msec / 1000, msec % 1000 * 1000,
1529 wnm_bss_keep_alive, wpa_s, NULL);
1531 #endif /* CONFIG_SME */
1535 static void wnm_process_assoc_resp(struct wpa_supplicant *wpa_s,
1536 const u8 *ies, size_t ies_len)
1538 struct ieee802_11_elems elems;
1543 if (ieee802_11_parse_elems(ies, ies_len, &elems, 1) == ParseFailed)
1547 if (elems.bss_max_idle_period) {
1549 wpa_s->sme.bss_max_idle_period =
1550 WPA_GET_LE16(elems.bss_max_idle_period);
1551 wpa_printf(MSG_DEBUG, "WNM: BSS Max Idle Period: %u (* 1000 "
1552 "TU)%s", wpa_s->sme.bss_max_idle_period,
1553 (elems.bss_max_idle_period[2] & 0x01) ?
1554 " (protected keep-live required)" : "");
1555 if (wpa_s->sme.bss_max_idle_period == 0)
1556 wpa_s->sme.bss_max_idle_period = 1;
1557 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME) {
1558 eloop_cancel_timeout(wnm_bss_keep_alive, wpa_s, NULL);
1559 /* msec times 1000 */
1560 msec = wpa_s->sme.bss_max_idle_period * 1024;
1563 eloop_register_timeout(msec / 1000, msec % 1000 * 1000,
1564 wnm_bss_keep_alive, wpa_s,
1568 #endif /* CONFIG_SME */
1571 #endif /* CONFIG_WNM */
1574 void wnm_bss_keep_alive_deinit(struct wpa_supplicant *wpa_s)
1577 eloop_cancel_timeout(wnm_bss_keep_alive, wpa_s, NULL);
1578 #endif /* CONFIG_WNM */
1582 #ifdef CONFIG_INTERWORKING
1584 static int wpas_qos_map_set(struct wpa_supplicant *wpa_s, const u8 *qos_map,
1589 wpa_hexdump(MSG_DEBUG, "Interworking: QoS Map Set", qos_map, len);
1590 res = wpa_drv_set_qos_map(wpa_s, qos_map, len);
1592 wpa_printf(MSG_DEBUG, "Interworking: Failed to configure QoS Map Set to the driver");
1599 static void interworking_process_assoc_resp(struct wpa_supplicant *wpa_s,
1600 const u8 *ies, size_t ies_len)
1602 struct ieee802_11_elems elems;
1607 if (ieee802_11_parse_elems(ies, ies_len, &elems, 1) == ParseFailed)
1610 if (elems.qos_map_set) {
1611 wpas_qos_map_set(wpa_s, elems.qos_map_set,
1612 elems.qos_map_set_len);
1616 #endif /* CONFIG_INTERWORKING */
1619 static int wpa_supplicant_event_associnfo(struct wpa_supplicant *wpa_s,
1620 union wpa_event_data *data)
1622 int l, len, found = 0, wpa_found, rsn_found;
1624 #ifdef CONFIG_IEEE80211R
1626 #endif /* CONFIG_IEEE80211R */
1628 wpa_dbg(wpa_s, MSG_DEBUG, "Association info event");
1629 if (data->assoc_info.req_ies)
1630 wpa_hexdump(MSG_DEBUG, "req_ies", data->assoc_info.req_ies,
1631 data->assoc_info.req_ies_len);
1632 if (data->assoc_info.resp_ies) {
1633 wpa_hexdump(MSG_DEBUG, "resp_ies", data->assoc_info.resp_ies,
1634 data->assoc_info.resp_ies_len);
1636 wpa_tdls_assoc_resp_ies(wpa_s->wpa, data->assoc_info.resp_ies,
1637 data->assoc_info.resp_ies_len);
1638 #endif /* CONFIG_TDLS */
1640 wnm_process_assoc_resp(wpa_s, data->assoc_info.resp_ies,
1641 data->assoc_info.resp_ies_len);
1642 #endif /* CONFIG_WNM */
1643 #ifdef CONFIG_INTERWORKING
1644 interworking_process_assoc_resp(wpa_s, data->assoc_info.resp_ies,
1645 data->assoc_info.resp_ies_len);
1646 #endif /* CONFIG_INTERWORKING */
1648 if (data->assoc_info.beacon_ies)
1649 wpa_hexdump(MSG_DEBUG, "beacon_ies",
1650 data->assoc_info.beacon_ies,
1651 data->assoc_info.beacon_ies_len);
1652 if (data->assoc_info.freq)
1653 wpa_dbg(wpa_s, MSG_DEBUG, "freq=%u MHz",
1654 data->assoc_info.freq);
1656 p = data->assoc_info.req_ies;
1657 l = data->assoc_info.req_ies_len;
1659 /* Go through the IEs and make a copy of the WPA/RSN IE, if present. */
1660 while (p && l >= 2) {
1663 wpa_hexdump(MSG_DEBUG, "Truncated IE in assoc_info",
1667 if ((p[0] == WLAN_EID_VENDOR_SPECIFIC && p[1] >= 6 &&
1668 (os_memcmp(&p[2], "\x00\x50\xF2\x01\x01\x00", 6) == 0)) ||
1669 (p[0] == WLAN_EID_RSN && p[1] >= 2)) {
1670 if (wpa_sm_set_assoc_wpa_ie(wpa_s->wpa, p, len))
1673 wpa_find_assoc_pmkid(wpa_s);
1679 if (!found && data->assoc_info.req_ies)
1680 wpa_sm_set_assoc_wpa_ie(wpa_s->wpa, NULL, 0);
1682 #ifdef CONFIG_IEEE80211R
1684 if (wpa_s->sme.auth_alg == WPA_AUTH_ALG_FT) {
1685 if (wpa_drv_get_bssid(wpa_s, bssid) < 0 ||
1686 wpa_ft_validate_reassoc_resp(wpa_s->wpa,
1687 data->assoc_info.resp_ies,
1688 data->assoc_info.resp_ies_len,
1690 wpa_dbg(wpa_s, MSG_DEBUG, "FT: Validation of "
1691 "Reassociation Response failed");
1692 wpa_supplicant_deauthenticate(
1693 wpa_s, WLAN_REASON_INVALID_IE);
1698 p = data->assoc_info.resp_ies;
1699 l = data->assoc_info.resp_ies_len;
1701 #ifdef CONFIG_WPS_STRICT
1702 if (p && wpa_s->current_ssid &&
1703 wpa_s->current_ssid->key_mgmt == WPA_KEY_MGMT_WPS) {
1705 wps = ieee802_11_vendor_ie_concat(p, l, WPS_IE_VENDOR_TYPE);
1707 wpa_msg(wpa_s, MSG_INFO, "WPS-STRICT: AP did not "
1708 "include WPS IE in (Re)Association Response");
1712 if (wps_validate_assoc_resp(wps) < 0) {
1714 wpa_supplicant_deauthenticate(
1715 wpa_s, WLAN_REASON_INVALID_IE);
1720 #endif /* CONFIG_WPS_STRICT */
1722 /* Go through the IEs and make a copy of the MDIE, if present. */
1723 while (p && l >= 2) {
1726 wpa_hexdump(MSG_DEBUG, "Truncated IE in assoc_info",
1730 if (p[0] == WLAN_EID_MOBILITY_DOMAIN &&
1731 p[1] >= MOBILITY_DOMAIN_ID_LEN) {
1732 wpa_s->sme.ft_used = 1;
1733 os_memcpy(wpa_s->sme.mobility_domain, p + 2,
1734 MOBILITY_DOMAIN_ID_LEN);
1740 #endif /* CONFIG_SME */
1742 /* Process FT when SME is in the driver */
1743 if (!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME) &&
1744 wpa_ft_is_completed(wpa_s->wpa)) {
1745 if (wpa_drv_get_bssid(wpa_s, bssid) < 0 ||
1746 wpa_ft_validate_reassoc_resp(wpa_s->wpa,
1747 data->assoc_info.resp_ies,
1748 data->assoc_info.resp_ies_len,
1750 wpa_dbg(wpa_s, MSG_DEBUG, "FT: Validation of "
1751 "Reassociation Response failed");
1752 wpa_supplicant_deauthenticate(
1753 wpa_s, WLAN_REASON_INVALID_IE);
1756 wpa_dbg(wpa_s, MSG_DEBUG, "FT: Reassociation Response done");
1759 wpa_sm_set_ft_params(wpa_s->wpa, data->assoc_info.resp_ies,
1760 data->assoc_info.resp_ies_len);
1761 #endif /* CONFIG_IEEE80211R */
1763 /* WPA/RSN IE from Beacon/ProbeResp */
1764 p = data->assoc_info.beacon_ies;
1765 l = data->assoc_info.beacon_ies_len;
1767 /* Go through the IEs and make a copy of the WPA/RSN IEs, if present.
1769 wpa_found = rsn_found = 0;
1770 while (p && l >= 2) {
1773 wpa_hexdump(MSG_DEBUG, "Truncated IE in beacon_ies",
1778 p[0] == WLAN_EID_VENDOR_SPECIFIC && p[1] >= 6 &&
1779 os_memcmp(&p[2], "\x00\x50\xF2\x01\x01\x00", 6) == 0) {
1781 wpa_sm_set_ap_wpa_ie(wpa_s->wpa, p, len);
1785 p[0] == WLAN_EID_RSN && p[1] >= 2) {
1787 wpa_sm_set_ap_rsn_ie(wpa_s->wpa, p, len);
1794 if (!wpa_found && data->assoc_info.beacon_ies)
1795 wpa_sm_set_ap_wpa_ie(wpa_s->wpa, NULL, 0);
1796 if (!rsn_found && data->assoc_info.beacon_ies)
1797 wpa_sm_set_ap_rsn_ie(wpa_s->wpa, NULL, 0);
1798 if (wpa_found || rsn_found)
1799 wpa_s->ap_ies_from_associnfo = 1;
1801 if (wpa_s->assoc_freq && data->assoc_info.freq &&
1802 wpa_s->assoc_freq != data->assoc_info.freq) {
1803 wpa_printf(MSG_DEBUG, "Operating frequency changed from "
1805 wpa_s->assoc_freq, data->assoc_info.freq);
1806 wpa_supplicant_update_scan_results(wpa_s);
1809 wpa_s->assoc_freq = data->assoc_info.freq;
1815 static int wpa_supplicant_assoc_update_ie(struct wpa_supplicant *wpa_s)
1817 const u8 *bss_wpa = NULL, *bss_rsn = NULL;
1819 if (!wpa_s->current_bss || !wpa_s->current_ssid)
1822 if (!wpa_key_mgmt_wpa_any(wpa_s->current_ssid->key_mgmt))
1825 bss_wpa = wpa_bss_get_vendor_ie(wpa_s->current_bss,
1826 WPA_IE_VENDOR_TYPE);
1827 bss_rsn = wpa_bss_get_ie(wpa_s->current_bss, WLAN_EID_RSN);
1829 if (wpa_sm_set_ap_wpa_ie(wpa_s->wpa, bss_wpa,
1830 bss_wpa ? 2 + bss_wpa[1] : 0) ||
1831 wpa_sm_set_ap_rsn_ie(wpa_s->wpa, bss_rsn,
1832 bss_rsn ? 2 + bss_rsn[1] : 0))
1839 static void wpa_supplicant_event_assoc(struct wpa_supplicant *wpa_s,
1840 union wpa_event_data *data)
1846 if (wpa_s->ap_iface) {
1849 hostapd_notif_assoc(wpa_s->ap_iface->bss[0],
1850 data->assoc_info.addr,
1851 data->assoc_info.req_ies,
1852 data->assoc_info.req_ies_len,
1853 data->assoc_info.reassoc);
1856 #endif /* CONFIG_AP */
1858 ft_completed = wpa_ft_is_completed(wpa_s->wpa);
1859 if (data && wpa_supplicant_event_associnfo(wpa_s, data) < 0)
1862 if (wpa_drv_get_bssid(wpa_s, bssid) < 0) {
1863 wpa_dbg(wpa_s, MSG_ERROR, "Failed to get BSSID");
1864 wpa_supplicant_deauthenticate(
1865 wpa_s, WLAN_REASON_DEAUTH_LEAVING);
1869 wpa_supplicant_set_state(wpa_s, WPA_ASSOCIATED);
1870 if (os_memcmp(bssid, wpa_s->bssid, ETH_ALEN) != 0) {
1871 wpa_dbg(wpa_s, MSG_DEBUG, "Associated to a new BSS: BSSID="
1872 MACSTR, MAC2STR(bssid));
1873 random_add_randomness(bssid, ETH_ALEN);
1874 os_memcpy(wpa_s->bssid, bssid, ETH_ALEN);
1875 os_memset(wpa_s->pending_bssid, 0, ETH_ALEN);
1876 wpas_notify_bssid_changed(wpa_s);
1878 if (wpa_supplicant_dynamic_keys(wpa_s) && !ft_completed) {
1879 wpa_clear_keys(wpa_s, bssid);
1881 if (wpa_supplicant_select_config(wpa_s) < 0) {
1882 wpa_supplicant_deauthenticate(
1883 wpa_s, WLAN_REASON_DEAUTH_LEAVING);
1887 if (wpa_s->conf->ap_scan == 1 &&
1888 wpa_s->drv_flags & WPA_DRIVER_FLAGS_BSS_SELECTION) {
1889 if (wpa_supplicant_assoc_update_ie(wpa_s) < 0)
1890 wpa_msg(wpa_s, MSG_WARNING,
1891 "WPA/RSN IEs not updated");
1896 os_memcpy(wpa_s->sme.prev_bssid, bssid, ETH_ALEN);
1897 wpa_s->sme.prev_bssid_set = 1;
1898 wpa_s->sme.last_unprot_disconnect.sec = 0;
1899 #endif /* CONFIG_SME */
1901 wpa_msg(wpa_s, MSG_INFO, "Associated with " MACSTR, MAC2STR(bssid));
1902 if (wpa_s->current_ssid) {
1903 /* When using scanning (ap_scan=1), SIM PC/SC interface can be
1904 * initialized before association, but for other modes,
1905 * initialize PC/SC here, if the current configuration needs
1906 * smartcard or SIM/USIM. */
1907 wpa_supplicant_scard_init(wpa_s, wpa_s->current_ssid);
1909 wpa_sm_notify_assoc(wpa_s->wpa, bssid);
1911 l2_packet_notify_auth_start(wpa_s->l2);
1914 * Set portEnabled first to FALSE in order to get EAP state machine out
1915 * of the SUCCESS state and eapSuccess cleared. Without this, EAPOL PAE
1916 * state machine may transit to AUTHENTICATING state based on obsolete
1917 * eapSuccess and then trigger BE_AUTH to SUCCESS and PAE to
1918 * AUTHENTICATED without ever giving chance to EAP state machine to
1921 if (!ft_completed) {
1922 eapol_sm_notify_portEnabled(wpa_s->eapol, FALSE);
1923 eapol_sm_notify_portValid(wpa_s->eapol, FALSE);
1925 if (wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt) || ft_completed)
1926 eapol_sm_notify_eap_success(wpa_s->eapol, FALSE);
1927 /* 802.1X::portControl = Auto */
1928 eapol_sm_notify_portEnabled(wpa_s->eapol, TRUE);
1929 wpa_s->eapol_received = 0;
1930 if (wpa_s->key_mgmt == WPA_KEY_MGMT_NONE ||
1931 wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE ||
1932 (wpa_s->current_ssid &&
1933 wpa_s->current_ssid->mode == IEEE80211_MODE_IBSS)) {
1934 if (wpa_s->current_ssid &&
1935 wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE &&
1937 WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC_DONE)) {
1939 * Set the key after having received joined-IBSS event
1942 wpa_supplicant_set_wpa_none_key(wpa_s,
1943 wpa_s->current_ssid);
1945 wpa_supplicant_cancel_auth_timeout(wpa_s);
1946 wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
1947 } else if (!ft_completed) {
1948 /* Timeout for receiving the first EAPOL packet */
1949 wpa_supplicant_req_auth_timeout(wpa_s, 10, 0);
1951 wpa_supplicant_cancel_scan(wpa_s);
1953 if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE) &&
1954 wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt)) {
1956 * We are done; the driver will take care of RSN 4-way
1959 wpa_supplicant_cancel_auth_timeout(wpa_s);
1960 wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
1961 eapol_sm_notify_portValid(wpa_s->eapol, TRUE);
1962 eapol_sm_notify_eap_success(wpa_s->eapol, TRUE);
1963 } else if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE) &&
1964 wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt)) {
1966 * The driver will take care of RSN 4-way handshake, so we need
1967 * to allow EAPOL supplicant to complete its work without
1968 * waiting for WPA supplicant.
1970 eapol_sm_notify_portValid(wpa_s->eapol, TRUE);
1971 } else if (ft_completed) {
1973 * FT protocol completed - make sure EAPOL state machine ends
1974 * up in authenticated.
1976 wpa_supplicant_cancel_auth_timeout(wpa_s);
1977 wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
1978 eapol_sm_notify_portValid(wpa_s->eapol, TRUE);
1979 eapol_sm_notify_eap_success(wpa_s->eapol, TRUE);
1982 wpa_s->last_eapol_matches_bssid = 0;
1984 if (wpa_s->pending_eapol_rx) {
1985 struct os_reltime now, age;
1986 os_get_reltime(&now);
1987 os_reltime_sub(&now, &wpa_s->pending_eapol_rx_time, &age);
1988 if (age.sec == 0 && age.usec < 100000 &&
1989 os_memcmp(wpa_s->pending_eapol_rx_src, bssid, ETH_ALEN) ==
1991 wpa_dbg(wpa_s, MSG_DEBUG, "Process pending EAPOL "
1992 "frame that was received just before "
1993 "association notification");
1994 wpa_supplicant_rx_eapol(
1995 wpa_s, wpa_s->pending_eapol_rx_src,
1996 wpabuf_head(wpa_s->pending_eapol_rx),
1997 wpabuf_len(wpa_s->pending_eapol_rx));
1999 wpabuf_free(wpa_s->pending_eapol_rx);
2000 wpa_s->pending_eapol_rx = NULL;
2003 if ((wpa_s->key_mgmt == WPA_KEY_MGMT_NONE ||
2004 wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA) &&
2005 wpa_s->current_ssid &&
2006 (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC_DONE)) {
2007 /* Set static WEP keys again */
2008 wpa_set_wep_keys(wpa_s, wpa_s->current_ssid);
2011 #ifdef CONFIG_IBSS_RSN
2012 if (wpa_s->current_ssid &&
2013 wpa_s->current_ssid->mode == WPAS_MODE_IBSS &&
2014 wpa_s->key_mgmt != WPA_KEY_MGMT_NONE &&
2015 wpa_s->key_mgmt != WPA_KEY_MGMT_WPA_NONE &&
2016 wpa_s->ibss_rsn == NULL) {
2017 wpa_s->ibss_rsn = ibss_rsn_init(wpa_s);
2018 if (!wpa_s->ibss_rsn) {
2019 wpa_msg(wpa_s, MSG_INFO, "Failed to init IBSS RSN");
2020 wpa_supplicant_deauthenticate(
2021 wpa_s, WLAN_REASON_DEAUTH_LEAVING);
2025 ibss_rsn_set_psk(wpa_s->ibss_rsn, wpa_s->current_ssid->psk);
2027 #endif /* CONFIG_IBSS_RSN */
2029 wpas_wps_notify_assoc(wpa_s, bssid);
2033 static int disconnect_reason_recoverable(u16 reason_code)
2035 return reason_code == WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY ||
2036 reason_code == WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA ||
2037 reason_code == WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA;
2041 static void wpa_supplicant_event_disassoc(struct wpa_supplicant *wpa_s,
2043 int locally_generated)
2047 if (wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE) {
2049 * At least Host AP driver and a Prism3 card seemed to be
2050 * generating streams of disconnected events when configuring
2051 * IBSS for WPA-None. Ignore them for now.
2056 bssid = wpa_s->bssid;
2057 if (is_zero_ether_addr(bssid))
2058 bssid = wpa_s->pending_bssid;
2060 if (!is_zero_ether_addr(bssid) ||
2061 wpa_s->wpa_state >= WPA_AUTHENTICATING) {
2062 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_DISCONNECTED "bssid=" MACSTR
2064 MAC2STR(bssid), reason_code,
2065 locally_generated ? " locally_generated=1" : "");
2070 static int could_be_psk_mismatch(struct wpa_supplicant *wpa_s, u16 reason_code,
2071 int locally_generated)
2073 if (wpa_s->wpa_state != WPA_4WAY_HANDSHAKE ||
2074 !wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt))
2075 return 0; /* Not in 4-way handshake with PSK */
2078 * It looks like connection was lost while trying to go through PSK
2079 * 4-way handshake. Filter out known disconnection cases that are caused
2080 * by something else than PSK mismatch to avoid confusing reports.
2083 if (locally_generated) {
2084 if (reason_code == WLAN_REASON_IE_IN_4WAY_DIFFERS)
2092 static void wpa_supplicant_event_disassoc_finish(struct wpa_supplicant *wpa_s,
2094 int locally_generated)
2098 u8 prev_pending_bssid[ETH_ALEN];
2099 struct wpa_bss *fast_reconnect = NULL;
2100 struct wpa_ssid *fast_reconnect_ssid = NULL;
2101 struct wpa_ssid *last_ssid;
2103 authenticating = wpa_s->wpa_state == WPA_AUTHENTICATING;
2104 os_memcpy(prev_pending_bssid, wpa_s->pending_bssid, ETH_ALEN);
2106 if (wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE) {
2108 * At least Host AP driver and a Prism3 card seemed to be
2109 * generating streams of disconnected events when configuring
2110 * IBSS for WPA-None. Ignore them for now.
2112 wpa_dbg(wpa_s, MSG_DEBUG, "Disconnect event - ignore in "
2113 "IBSS/WPA-None mode");
2117 if (could_be_psk_mismatch(wpa_s, reason_code, locally_generated)) {
2118 wpa_msg(wpa_s, MSG_INFO, "WPA: 4-Way Handshake failed - "
2119 "pre-shared key may be incorrect");
2120 if (wpas_p2p_4way_hs_failed(wpa_s) > 0)
2121 return; /* P2P group removed */
2122 wpas_auth_failed(wpa_s, "WRONG_KEY");
2124 if (!wpa_s->disconnected &&
2125 (!wpa_s->auto_reconnect_disabled ||
2126 wpa_s->key_mgmt == WPA_KEY_MGMT_WPS ||
2127 wpas_wps_searching(wpa_s))) {
2128 wpa_dbg(wpa_s, MSG_DEBUG, "Auto connect enabled: try to "
2129 "reconnect (wps=%d/%d wpa_state=%d)",
2130 wpa_s->key_mgmt == WPA_KEY_MGMT_WPS,
2131 wpas_wps_searching(wpa_s),
2133 if (wpa_s->wpa_state == WPA_COMPLETED &&
2134 wpa_s->current_ssid &&
2135 wpa_s->current_ssid->mode == WPAS_MODE_INFRA &&
2136 !locally_generated &&
2137 disconnect_reason_recoverable(reason_code)) {
2139 * It looks like the AP has dropped association with
2140 * us, but could allow us to get back in. Try to
2141 * reconnect to the same BSS without full scan to save
2142 * time for some common cases.
2144 fast_reconnect = wpa_s->current_bss;
2145 fast_reconnect_ssid = wpa_s->current_ssid;
2146 } else if (wpa_s->wpa_state >= WPA_ASSOCIATING)
2147 wpa_supplicant_req_scan(wpa_s, 0, 100000);
2149 wpa_dbg(wpa_s, MSG_DEBUG, "Do not request new "
2152 wpa_dbg(wpa_s, MSG_DEBUG, "Auto connect disabled: do not "
2153 "try to re-connect");
2154 wpa_s->reassociate = 0;
2155 wpa_s->disconnected = 1;
2156 wpa_supplicant_cancel_sched_scan(wpa_s);
2158 bssid = wpa_s->bssid;
2159 if (is_zero_ether_addr(bssid))
2160 bssid = wpa_s->pending_bssid;
2161 if (wpa_s->wpa_state >= WPA_AUTHENTICATING)
2162 wpas_connection_failed(wpa_s, bssid);
2163 wpa_sm_notify_disassoc(wpa_s->wpa);
2164 if (locally_generated)
2165 wpa_s->disconnect_reason = -reason_code;
2167 wpa_s->disconnect_reason = reason_code;
2168 wpas_notify_disconnect_reason(wpa_s);
2169 if (wpa_supplicant_dynamic_keys(wpa_s)) {
2170 wpa_dbg(wpa_s, MSG_DEBUG, "Disconnect event - remove keys");
2171 wpa_clear_keys(wpa_s, wpa_s->bssid);
2173 last_ssid = wpa_s->current_ssid;
2174 wpa_supplicant_mark_disassoc(wpa_s);
2176 if (authenticating && (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)) {
2177 sme_disassoc_while_authenticating(wpa_s, prev_pending_bssid);
2178 wpa_s->current_ssid = last_ssid;
2181 if (fast_reconnect &&
2182 !wpas_network_disabled(wpa_s, fast_reconnect_ssid) &&
2183 !disallowed_bssid(wpa_s, fast_reconnect->bssid) &&
2184 !disallowed_ssid(wpa_s, fast_reconnect->ssid,
2185 fast_reconnect->ssid_len) &&
2186 !wpas_temp_disabled(wpa_s, fast_reconnect_ssid)) {
2187 #ifndef CONFIG_NO_SCAN_PROCESSING
2188 wpa_dbg(wpa_s, MSG_DEBUG, "Try to reconnect to the same BSS");
2189 if (wpa_supplicant_connect(wpa_s, fast_reconnect,
2190 fast_reconnect_ssid) < 0) {
2191 /* Recover through full scan */
2192 wpa_supplicant_req_scan(wpa_s, 0, 100000);
2194 #endif /* CONFIG_NO_SCAN_PROCESSING */
2195 } else if (fast_reconnect) {
2197 * Could not reconnect to the same BSS due to network being
2198 * disabled. Use a new scan to match the alternative behavior
2199 * above, i.e., to continue automatic reconnection attempt in a
2200 * way that enforces disabled network rules.
2202 wpa_supplicant_req_scan(wpa_s, 0, 100000);
2207 #ifdef CONFIG_DELAYED_MIC_ERROR_REPORT
2208 void wpa_supplicant_delayed_mic_error_report(void *eloop_ctx, void *sock_ctx)
2210 struct wpa_supplicant *wpa_s = eloop_ctx;
2212 if (!wpa_s->pending_mic_error_report)
2215 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: Sending pending MIC error report");
2216 wpa_sm_key_request(wpa_s->wpa, 1, wpa_s->pending_mic_error_pairwise);
2217 wpa_s->pending_mic_error_report = 0;
2219 #endif /* CONFIG_DELAYED_MIC_ERROR_REPORT */
2223 wpa_supplicant_event_michael_mic_failure(struct wpa_supplicant *wpa_s,
2224 union wpa_event_data *data)
2227 struct os_reltime t;
2229 wpa_msg(wpa_s, MSG_WARNING, "Michael MIC failure detected");
2230 pairwise = (data && data->michael_mic_failure.unicast);
2232 if ((wpa_s->last_michael_mic_error.sec &&
2233 !os_reltime_expired(&t, &wpa_s->last_michael_mic_error, 60)) ||
2234 wpa_s->pending_mic_error_report) {
2235 if (wpa_s->pending_mic_error_report) {
2237 * Send the pending MIC error report immediately since
2238 * we are going to start countermeasures and AP better
2241 wpa_sm_key_request(wpa_s->wpa, 1,
2242 wpa_s->pending_mic_error_pairwise);
2245 /* Send the new MIC error report immediately since we are going
2246 * to start countermeasures and AP better do the same.
2248 wpa_sm_key_request(wpa_s->wpa, 1, pairwise);
2250 /* initialize countermeasures */
2251 wpa_s->countermeasures = 1;
2253 wpa_blacklist_add(wpa_s, wpa_s->bssid);
2255 wpa_msg(wpa_s, MSG_WARNING, "TKIP countermeasures started");
2258 * Need to wait for completion of request frame. We do not get
2259 * any callback for the message completion, so just wait a
2260 * short while and hope for the best. */
2263 wpa_drv_set_countermeasures(wpa_s, 1);
2264 wpa_supplicant_deauthenticate(wpa_s,
2265 WLAN_REASON_MICHAEL_MIC_FAILURE);
2266 eloop_cancel_timeout(wpa_supplicant_stop_countermeasures,
2268 eloop_register_timeout(60, 0,
2269 wpa_supplicant_stop_countermeasures,
2271 /* TODO: mark the AP rejected for 60 second. STA is
2272 * allowed to associate with another AP.. */
2274 #ifdef CONFIG_DELAYED_MIC_ERROR_REPORT
2275 if (wpa_s->mic_errors_seen) {
2277 * Reduce the effectiveness of Michael MIC error
2278 * reports as a means for attacking against TKIP if
2279 * more than one MIC failure is noticed with the same
2280 * PTK. We delay the transmission of the reports by a
2281 * random time between 0 and 60 seconds in order to
2282 * force the attacker wait 60 seconds before getting
2283 * the information on whether a frame resulted in a MIC
2289 if (os_get_random(rval, sizeof(rval)) < 0)
2290 sec = os_random() % 60;
2292 sec = WPA_GET_BE32(rval) % 60;
2293 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: Delay MIC error "
2294 "report %d seconds", sec);
2295 wpa_s->pending_mic_error_report = 1;
2296 wpa_s->pending_mic_error_pairwise = pairwise;
2297 eloop_cancel_timeout(
2298 wpa_supplicant_delayed_mic_error_report,
2300 eloop_register_timeout(
2301 sec, os_random() % 1000000,
2302 wpa_supplicant_delayed_mic_error_report,
2305 wpa_sm_key_request(wpa_s->wpa, 1, pairwise);
2307 #else /* CONFIG_DELAYED_MIC_ERROR_REPORT */
2308 wpa_sm_key_request(wpa_s->wpa, 1, pairwise);
2309 #endif /* CONFIG_DELAYED_MIC_ERROR_REPORT */
2311 wpa_s->last_michael_mic_error = t;
2312 wpa_s->mic_errors_seen++;
2316 #ifdef CONFIG_TERMINATE_ONLASTIF
2317 static int any_interfaces(struct wpa_supplicant *head)
2319 struct wpa_supplicant *wpa_s;
2321 for (wpa_s = head; wpa_s != NULL; wpa_s = wpa_s->next)
2322 if (!wpa_s->interface_removed)
2326 #endif /* CONFIG_TERMINATE_ONLASTIF */
2330 wpa_supplicant_event_interface_status(struct wpa_supplicant *wpa_s,
2331 union wpa_event_data *data)
2333 if (os_strcmp(wpa_s->ifname, data->interface_status.ifname) != 0)
2336 switch (data->interface_status.ievent) {
2337 case EVENT_INTERFACE_ADDED:
2338 if (!wpa_s->interface_removed)
2340 wpa_s->interface_removed = 0;
2341 wpa_dbg(wpa_s, MSG_DEBUG, "Configured interface was added");
2342 if (wpa_supplicant_driver_init(wpa_s) < 0) {
2343 wpa_msg(wpa_s, MSG_INFO, "Failed to initialize the "
2344 "driver after interface was added");
2347 case EVENT_INTERFACE_REMOVED:
2348 wpa_dbg(wpa_s, MSG_DEBUG, "Configured interface was removed");
2349 wpa_s->interface_removed = 1;
2350 wpa_supplicant_mark_disassoc(wpa_s);
2351 wpa_supplicant_set_state(wpa_s, WPA_INTERFACE_DISABLED);
2352 l2_packet_deinit(wpa_s->l2);
2354 #ifdef CONFIG_TERMINATE_ONLASTIF
2355 /* check if last interface */
2356 if (!any_interfaces(wpa_s->global->ifaces))
2358 #endif /* CONFIG_TERMINATE_ONLASTIF */
2364 #ifdef CONFIG_PEERKEY
2366 wpa_supplicant_event_stkstart(struct wpa_supplicant *wpa_s,
2367 union wpa_event_data *data)
2371 wpa_sm_stkstart(wpa_s->wpa, data->stkstart.peer);
2373 #endif /* CONFIG_PEERKEY */
2377 static void wpa_supplicant_event_tdls(struct wpa_supplicant *wpa_s,
2378 union wpa_event_data *data)
2382 switch (data->tdls.oper) {
2383 case TDLS_REQUEST_SETUP:
2384 wpa_tdls_remove(wpa_s->wpa, data->tdls.peer);
2385 if (wpa_tdls_is_external_setup(wpa_s->wpa))
2386 wpa_tdls_start(wpa_s->wpa, data->tdls.peer);
2388 wpa_drv_tdls_oper(wpa_s, TDLS_SETUP, data->tdls.peer);
2390 case TDLS_REQUEST_TEARDOWN:
2391 if (wpa_tdls_is_external_setup(wpa_s->wpa))
2392 wpa_tdls_teardown_link(wpa_s->wpa, data->tdls.peer,
2393 data->tdls.reason_code);
2395 wpa_drv_tdls_oper(wpa_s, TDLS_TEARDOWN,
2400 #endif /* CONFIG_TDLS */
2404 static void wpa_supplicant_event_wnm(struct wpa_supplicant *wpa_s,
2405 union wpa_event_data *data)
2409 switch (data->wnm.oper) {
2410 case WNM_OPER_SLEEP:
2411 wpa_printf(MSG_DEBUG, "Start sending WNM-Sleep Request "
2412 "(action=%d, intval=%d)",
2413 data->wnm.sleep_action, data->wnm.sleep_intval);
2414 ieee802_11_send_wnmsleep_req(wpa_s, data->wnm.sleep_action,
2415 data->wnm.sleep_intval, NULL);
2419 #endif /* CONFIG_WNM */
2422 #ifdef CONFIG_IEEE80211R
2424 wpa_supplicant_event_ft_response(struct wpa_supplicant *wpa_s,
2425 union wpa_event_data *data)
2430 if (wpa_ft_process_response(wpa_s->wpa, data->ft_ies.ies,
2431 data->ft_ies.ies_len,
2432 data->ft_ies.ft_action,
2433 data->ft_ies.target_ap,
2434 data->ft_ies.ric_ies,
2435 data->ft_ies.ric_ies_len) < 0) {
2436 /* TODO: prevent MLME/driver from trying to associate? */
2439 #endif /* CONFIG_IEEE80211R */
2442 #ifdef CONFIG_IBSS_RSN
2443 static void wpa_supplicant_event_ibss_rsn_start(struct wpa_supplicant *wpa_s,
2444 union wpa_event_data *data)
2446 struct wpa_ssid *ssid;
2447 if (wpa_s->wpa_state < WPA_ASSOCIATED)
2451 ssid = wpa_s->current_ssid;
2454 if (ssid->mode != WPAS_MODE_IBSS || !wpa_key_mgmt_wpa(ssid->key_mgmt))
2457 ibss_rsn_start(wpa_s->ibss_rsn, data->ibss_rsn_start.peer);
2461 static void wpa_supplicant_event_ibss_auth(struct wpa_supplicant *wpa_s,
2462 union wpa_event_data *data)
2464 struct wpa_ssid *ssid = wpa_s->current_ssid;
2469 /* check if the ssid is correctly configured as IBSS/RSN */
2470 if (ssid->mode != WPAS_MODE_IBSS || !wpa_key_mgmt_wpa(ssid->key_mgmt))
2473 ibss_rsn_handle_auth(wpa_s->ibss_rsn, data->rx_mgmt.frame,
2474 data->rx_mgmt.frame_len);
2476 #endif /* CONFIG_IBSS_RSN */
2479 #ifdef CONFIG_IEEE80211R
2480 static void ft_rx_action(struct wpa_supplicant *wpa_s, const u8 *data,
2483 const u8 *sta_addr, *target_ap_addr;
2486 wpa_hexdump(MSG_MSGDUMP, "FT: RX Action", data, len);
2487 if (!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME))
2488 return; /* only SME case supported for now */
2489 if (len < 1 + 2 * ETH_ALEN + 2)
2492 return; /* Only FT Action Response is supported for now */
2493 sta_addr = data + 1;
2494 target_ap_addr = data + 1 + ETH_ALEN;
2495 status = WPA_GET_LE16(data + 1 + 2 * ETH_ALEN);
2496 wpa_dbg(wpa_s, MSG_DEBUG, "FT: Received FT Action Response: STA "
2497 MACSTR " TargetAP " MACSTR " status %u",
2498 MAC2STR(sta_addr), MAC2STR(target_ap_addr), status);
2500 if (os_memcmp(sta_addr, wpa_s->own_addr, ETH_ALEN) != 0) {
2501 wpa_dbg(wpa_s, MSG_DEBUG, "FT: Foreign STA Address " MACSTR
2502 " in FT Action Response", MAC2STR(sta_addr));
2507 wpa_dbg(wpa_s, MSG_DEBUG, "FT: FT Action Response indicates "
2508 "failure (status code %d)", status);
2509 /* TODO: report error to FT code(?) */
2513 if (wpa_ft_process_response(wpa_s->wpa, data + 1 + 2 * ETH_ALEN + 2,
2514 len - (1 + 2 * ETH_ALEN + 2), 1,
2515 target_ap_addr, NULL, 0) < 0)
2520 struct wpa_bss *bss;
2521 bss = wpa_bss_get_bssid(wpa_s, target_ap_addr);
2523 wpa_s->sme.freq = bss->freq;
2524 wpa_s->sme.auth_alg = WPA_AUTH_ALG_FT;
2525 sme_associate(wpa_s, WPAS_MODE_INFRA, target_ap_addr,
2528 #endif /* CONFIG_SME */
2530 #endif /* CONFIG_IEEE80211R */
2533 static void wpa_supplicant_event_unprot_deauth(struct wpa_supplicant *wpa_s,
2534 struct unprot_deauth *e)
2536 #ifdef CONFIG_IEEE80211W
2537 wpa_printf(MSG_DEBUG, "Unprotected Deauthentication frame "
2538 "dropped: " MACSTR " -> " MACSTR
2539 " (reason code %u)",
2540 MAC2STR(e->sa), MAC2STR(e->da), e->reason_code);
2541 sme_event_unprot_disconnect(wpa_s, e->sa, e->da, e->reason_code);
2542 #endif /* CONFIG_IEEE80211W */
2546 static void wpa_supplicant_event_unprot_disassoc(struct wpa_supplicant *wpa_s,
2547 struct unprot_disassoc *e)
2549 #ifdef CONFIG_IEEE80211W
2550 wpa_printf(MSG_DEBUG, "Unprotected Disassociation frame "
2551 "dropped: " MACSTR " -> " MACSTR
2552 " (reason code %u)",
2553 MAC2STR(e->sa), MAC2STR(e->da), e->reason_code);
2554 sme_event_unprot_disconnect(wpa_s, e->sa, e->da, e->reason_code);
2555 #endif /* CONFIG_IEEE80211W */
2559 static void wpas_event_disconnect(struct wpa_supplicant *wpa_s, const u8 *addr,
2560 u16 reason_code, int locally_generated,
2561 const u8 *ie, size_t ie_len, int deauth)
2564 if (wpa_s->ap_iface && addr) {
2565 hostapd_notif_disassoc(wpa_s->ap_iface->bss[0], addr);
2569 if (wpa_s->ap_iface) {
2570 wpa_dbg(wpa_s, MSG_DEBUG, "Ignore deauth event in AP mode");
2573 #endif /* CONFIG_AP */
2575 wpa_supplicant_event_disassoc(wpa_s, reason_code, locally_generated);
2577 if (((reason_code == WLAN_REASON_IEEE_802_1X_AUTH_FAILED ||
2578 ((wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt) ||
2579 (wpa_s->key_mgmt & WPA_KEY_MGMT_IEEE8021X_NO_WPA)) &&
2580 eapol_sm_failed(wpa_s->eapol))) &&
2581 !wpa_s->eap_expected_failure))
2582 wpas_auth_failed(wpa_s, "AUTH_FAILED");
2585 if (deauth && reason_code > 0) {
2586 if (wpas_p2p_deauth_notif(wpa_s, addr, reason_code, ie, ie_len,
2587 locally_generated) > 0) {
2589 * The interface was removed, so cannot continue
2590 * processing any additional operations after this.
2595 #endif /* CONFIG_P2P */
2597 wpa_supplicant_event_disassoc_finish(wpa_s, reason_code,
2602 static void wpas_event_disassoc(struct wpa_supplicant *wpa_s,
2603 struct disassoc_info *info)
2605 u16 reason_code = 0;
2606 int locally_generated = 0;
2607 const u8 *addr = NULL;
2608 const u8 *ie = NULL;
2611 wpa_dbg(wpa_s, MSG_DEBUG, "Disassociation notification");
2616 ie_len = info->ie_len;
2617 reason_code = info->reason_code;
2618 locally_generated = info->locally_generated;
2619 wpa_dbg(wpa_s, MSG_DEBUG, " * reason %u%s", reason_code,
2620 locally_generated ? " (locally generated)" : "");
2622 wpa_dbg(wpa_s, MSG_DEBUG, " * address " MACSTR,
2624 wpa_hexdump(MSG_DEBUG, "Disassociation frame IE(s)",
2629 if (wpa_s->ap_iface && info && info->addr) {
2630 hostapd_notif_disassoc(wpa_s->ap_iface->bss[0], info->addr);
2634 if (wpa_s->ap_iface) {
2635 wpa_dbg(wpa_s, MSG_DEBUG, "Ignore disassoc event in AP mode");
2638 #endif /* CONFIG_AP */
2642 wpas_p2p_disassoc_notif(
2643 wpa_s, info->addr, reason_code, info->ie, info->ie_len,
2646 #endif /* CONFIG_P2P */
2648 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
2649 sme_event_disassoc(wpa_s, info);
2651 wpas_event_disconnect(wpa_s, addr, reason_code, locally_generated,
2656 static void wpas_event_deauth(struct wpa_supplicant *wpa_s,
2657 struct deauth_info *info)
2659 u16 reason_code = 0;
2660 int locally_generated = 0;
2661 const u8 *addr = NULL;
2662 const u8 *ie = NULL;
2665 wpa_dbg(wpa_s, MSG_DEBUG, "Deauthentication notification");
2670 ie_len = info->ie_len;
2671 reason_code = info->reason_code;
2672 locally_generated = info->locally_generated;
2673 wpa_dbg(wpa_s, MSG_DEBUG, " * reason %u%s",
2675 locally_generated ? " (locally generated)" : "");
2677 wpa_dbg(wpa_s, MSG_DEBUG, " * address " MACSTR,
2680 wpa_hexdump(MSG_DEBUG, "Deauthentication frame IE(s)",
2684 wpa_reset_ft_completed(wpa_s->wpa);
2686 wpas_event_disconnect(wpa_s, addr, reason_code,
2687 locally_generated, ie, ie_len, 1);
2691 static const char * reg_init_str(enum reg_change_initiator init)
2694 case REGDOM_SET_BY_CORE:
2696 case REGDOM_SET_BY_USER:
2698 case REGDOM_SET_BY_DRIVER:
2700 case REGDOM_SET_BY_COUNTRY_IE:
2701 return "COUNTRY_IE";
2702 case REGDOM_BEACON_HINT:
2703 return "BEACON_HINT";
2709 static const char * reg_type_str(enum reg_type type)
2712 case REGDOM_TYPE_UNKNOWN:
2714 case REGDOM_TYPE_COUNTRY:
2716 case REGDOM_TYPE_WORLD:
2718 case REGDOM_TYPE_CUSTOM_WORLD:
2719 return "CUSTOM_WORLD";
2720 case REGDOM_TYPE_INTERSECTION:
2721 return "INTERSECTION";
2727 static void wpa_supplicant_update_channel_list(
2728 struct wpa_supplicant *wpa_s, struct channel_list_changed *info)
2730 struct wpa_supplicant *ifs;
2732 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_REGDOM_CHANGE "init=%s type=%s%s%s",
2733 reg_init_str(info->initiator), reg_type_str(info->type),
2734 info->alpha2[0] ? " alpha2=" : "",
2735 info->alpha2[0] ? info->alpha2 : "");
2737 if (wpa_s->drv_priv == NULL)
2738 return; /* Ignore event during drv initialization */
2740 free_hw_features(wpa_s);
2741 wpa_s->hw.modes = wpa_drv_get_hw_feature_data(
2742 wpa_s, &wpa_s->hw.num_modes, &wpa_s->hw.flags);
2744 wpas_p2p_update_channel_list(wpa_s);
2747 * Check other interfaces to see if they share the same radio. If
2748 * so, they get updated with this same hw mode info.
2750 dl_list_for_each(ifs, &wpa_s->radio->ifaces, struct wpa_supplicant,
2753 wpa_printf(MSG_DEBUG, "%s: Updating hw mode",
2755 free_hw_features(ifs);
2756 ifs->hw.modes = wpa_drv_get_hw_feature_data(
2757 ifs, &ifs->hw.num_modes, &ifs->hw.flags);
2763 static void wpas_event_rx_mgmt_action(struct wpa_supplicant *wpa_s,
2764 const u8 *frame, size_t len, int freq)
2766 const struct ieee80211_mgmt *mgmt;
2771 if (len < IEEE80211_HDRLEN + 2)
2774 mgmt = (const struct ieee80211_mgmt *) frame;
2775 payload = frame + IEEE80211_HDRLEN;
2776 category = *payload++;
2777 plen = len - IEEE80211_HDRLEN - 1;
2779 wpa_dbg(wpa_s, MSG_DEBUG, "Received Action frame: SA=" MACSTR
2780 " Category=%u DataLen=%d freq=%d MHz",
2781 MAC2STR(mgmt->sa), category, (int) plen, freq);
2783 #ifdef CONFIG_IEEE80211R
2784 if (category == WLAN_ACTION_FT) {
2785 ft_rx_action(wpa_s, payload, plen);
2788 #endif /* CONFIG_IEEE80211R */
2790 #ifdef CONFIG_IEEE80211W
2792 if (category == WLAN_ACTION_SA_QUERY) {
2793 sme_sa_query_rx(wpa_s, mgmt->sa, payload, plen);
2796 #endif /* CONFIG_SME */
2797 #endif /* CONFIG_IEEE80211W */
2800 if (mgmt->u.action.category == WLAN_ACTION_WNM) {
2801 ieee802_11_rx_wnm_action(wpa_s, mgmt, len);
2804 #endif /* CONFIG_WNM */
2807 if ((mgmt->u.action.category == WLAN_ACTION_PUBLIC ||
2808 mgmt->u.action.category == WLAN_ACTION_PROTECTED_DUAL) &&
2809 gas_query_rx(wpa_s->gas, mgmt->da, mgmt->sa, mgmt->bssid,
2810 mgmt->u.action.category,
2811 payload, plen, freq) == 0)
2813 #endif /* CONFIG_GAS */
2816 if (category == WLAN_ACTION_PUBLIC && plen >= 4 &&
2817 payload[0] == WLAN_TDLS_DISCOVERY_RESPONSE) {
2818 wpa_dbg(wpa_s, MSG_DEBUG,
2819 "TDLS: Received Discovery Response from " MACSTR,
2823 #endif /* CONFIG_TDLS */
2825 #ifdef CONFIG_INTERWORKING
2826 if (category == WLAN_ACTION_QOS && plen >= 1 &&
2827 payload[0] == QOS_QOS_MAP_CONFIG) {
2828 const u8 *pos = payload + 1;
2829 size_t qlen = plen - 1;
2830 wpa_dbg(wpa_s, MSG_DEBUG, "Interworking: Received QoS Map Configure frame from "
2831 MACSTR, MAC2STR(mgmt->sa));
2832 if (os_memcmp(mgmt->sa, wpa_s->bssid, ETH_ALEN) == 0 &&
2833 qlen > 2 && pos[0] == WLAN_EID_QOS_MAP_SET &&
2834 pos[1] <= qlen - 2 && pos[1] >= 16)
2835 wpas_qos_map_set(wpa_s, pos + 2, pos[1]);
2838 #endif /* CONFIG_INTERWORKING */
2840 wpas_p2p_rx_action(wpa_s, mgmt->da, mgmt->sa, mgmt->bssid,
2841 category, payload, plen, freq);
2845 static void wpa_supplicant_notify_avoid_freq(struct wpa_supplicant *wpa_s,
2846 union wpa_event_data *event)
2849 struct wpa_supplicant *ifs;
2850 #endif /* CONFIG_P2P */
2851 struct wpa_freq_range_list *list;
2854 list = &event->freq_range;
2857 str = freq_range_list_str(list);
2858 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_AVOID_FREQ "ranges=%s",
2862 if (freq_range_list_parse(&wpa_s->global->p2p_go_avoid_freq, str)) {
2863 wpa_dbg(wpa_s, MSG_ERROR, "%s: Failed to parse freq range",
2866 wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Update channel list based on frequency avoid event");
2867 wpas_p2p_update_channel_list(wpa_s);
2870 for (ifs = wpa_s->global->ifaces; ifs; ifs = ifs->next) {
2872 if (!ifs->current_ssid ||
2873 !ifs->current_ssid->p2p_group ||
2874 (ifs->current_ssid->mode != WPAS_MODE_P2P_GO &&
2875 ifs->current_ssid->mode != WPAS_MODE_P2P_GROUP_FORMATION))
2878 freq = ifs->current_ssid->frequency;
2879 if (!freq_range_list_includes(list, freq)) {
2880 wpa_dbg(ifs, MSG_DEBUG, "P2P GO operating frequency %d MHz in safe range",
2885 wpa_dbg(ifs, MSG_DEBUG, "P2P GO operating in unsafe frequency %d MHz",
2887 /* TODO: Consider using CSA or removing the group within
2889 wpa_msg(ifs, MSG_INFO, P2P_EVENT_REMOVE_AND_REFORM_GROUP);
2891 #endif /* CONFIG_P2P */
2897 static void wpa_supplicant_event_assoc_auth(struct wpa_supplicant *wpa_s,
2898 union wpa_event_data *data)
2900 wpa_dbg(wpa_s, MSG_DEBUG,
2901 "Connection authorized by device, previous state %d",
2903 if (wpa_s->wpa_state == WPA_ASSOCIATED) {
2904 wpa_supplicant_cancel_auth_timeout(wpa_s);
2905 wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
2906 eapol_sm_notify_portValid(wpa_s->eapol, TRUE);
2907 eapol_sm_notify_eap_success(wpa_s->eapol, TRUE);
2909 wpa_sm_set_rx_replay_ctr(wpa_s->wpa, data->assoc_info.key_replay_ctr);
2910 wpa_sm_set_ptk_kck_kek(wpa_s->wpa, data->assoc_info.ptk_kck,
2911 data->assoc_info.ptk_kek);
2915 void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
2916 union wpa_event_data *data)
2918 struct wpa_supplicant *wpa_s = ctx;
2920 if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED &&
2921 event != EVENT_INTERFACE_ENABLED &&
2922 event != EVENT_INTERFACE_STATUS &&
2923 event != EVENT_SCHED_SCAN_STOPPED) {
2924 wpa_dbg(wpa_s, MSG_DEBUG,
2925 "Ignore event %s (%d) while interface is disabled",
2926 event_to_string(event), event);
2930 #ifndef CONFIG_NO_STDOUT_DEBUG
2932 int level = MSG_DEBUG;
2934 if (event == EVENT_RX_MGMT && data->rx_mgmt.frame_len >= 24) {
2935 const struct ieee80211_hdr *hdr;
2937 hdr = (const struct ieee80211_hdr *) data->rx_mgmt.frame;
2938 fc = le_to_host16(hdr->frame_control);
2939 if (WLAN_FC_GET_TYPE(fc) == WLAN_FC_TYPE_MGMT &&
2940 WLAN_FC_GET_STYPE(fc) == WLAN_FC_STYPE_BEACON)
2941 level = MSG_EXCESSIVE;
2944 wpa_dbg(wpa_s, level, "Event %s (%d) received",
2945 event_to_string(event), event);
2947 #endif /* CONFIG_NO_STDOUT_DEBUG */
2951 sme_event_auth(wpa_s, data);
2954 wpa_supplicant_event_assoc(wpa_s, data);
2955 if (data && data->assoc_info.authorized)
2956 wpa_supplicant_event_assoc_auth(wpa_s, data);
2958 case EVENT_DISASSOC:
2959 wpas_event_disassoc(wpa_s,
2960 data ? &data->disassoc_info : NULL);
2963 wpas_event_deauth(wpa_s,
2964 data ? &data->deauth_info : NULL);
2966 case EVENT_MICHAEL_MIC_FAILURE:
2967 wpa_supplicant_event_michael_mic_failure(wpa_s, data);
2969 #ifndef CONFIG_NO_SCAN_PROCESSING
2970 case EVENT_SCAN_STARTED:
2971 os_get_reltime(&wpa_s->scan_start_time);
2972 if (wpa_s->own_scan_requested) {
2973 struct os_reltime diff;
2975 os_reltime_sub(&wpa_s->scan_start_time,
2976 &wpa_s->scan_trigger_time, &diff);
2977 wpa_dbg(wpa_s, MSG_DEBUG, "Own scan request started a scan in %ld.%06ld seconds",
2978 diff.sec, diff.usec);
2979 wpa_s->own_scan_requested = 0;
2980 wpa_s->own_scan_running = 1;
2981 if (wpa_s->last_scan_req == MANUAL_SCAN_REQ &&
2982 wpa_s->manual_scan_use_id) {
2983 wpa_msg_ctrl(wpa_s, MSG_INFO,
2984 WPA_EVENT_SCAN_STARTED "id=%u",
2985 wpa_s->manual_scan_id);
2987 wpa_msg_ctrl(wpa_s, MSG_INFO,
2988 WPA_EVENT_SCAN_STARTED);
2991 wpa_dbg(wpa_s, MSG_DEBUG, "External program started a scan");
2992 wpa_s->external_scan_running = 1;
2993 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_SCAN_STARTED);
2996 case EVENT_SCAN_RESULTS:
2997 if (os_reltime_initialized(&wpa_s->scan_start_time)) {
2998 struct os_reltime now, diff;
2999 os_get_reltime(&now);
3000 os_reltime_sub(&now, &wpa_s->scan_start_time, &diff);
3001 wpa_s->scan_start_time.sec = 0;
3002 wpa_s->scan_start_time.usec = 0;
3003 wpa_dbg(wpa_s, MSG_DEBUG, "Scan completed in %ld.%06ld seconds",
3004 diff.sec, diff.usec);
3006 wpa_supplicant_event_scan_results(wpa_s, data);
3007 wpa_s->own_scan_running = 0;
3008 wpa_s->external_scan_running = 0;
3009 radio_work_check_next(wpa_s);
3011 #endif /* CONFIG_NO_SCAN_PROCESSING */
3012 case EVENT_ASSOCINFO:
3013 wpa_supplicant_event_associnfo(wpa_s, data);
3015 case EVENT_INTERFACE_STATUS:
3016 wpa_supplicant_event_interface_status(wpa_s, data);
3018 case EVENT_PMKID_CANDIDATE:
3019 wpa_supplicant_event_pmkid_candidate(wpa_s, data);
3021 #ifdef CONFIG_PEERKEY
3022 case EVENT_STKSTART:
3023 wpa_supplicant_event_stkstart(wpa_s, data);
3025 #endif /* CONFIG_PEERKEY */
3028 wpa_supplicant_event_tdls(wpa_s, data);
3030 #endif /* CONFIG_TDLS */
3033 wpa_supplicant_event_wnm(wpa_s, data);
3035 #endif /* CONFIG_WNM */
3036 #ifdef CONFIG_IEEE80211R
3037 case EVENT_FT_RESPONSE:
3038 wpa_supplicant_event_ft_response(wpa_s, data);
3040 #endif /* CONFIG_IEEE80211R */
3041 #ifdef CONFIG_IBSS_RSN
3042 case EVENT_IBSS_RSN_START:
3043 wpa_supplicant_event_ibss_rsn_start(wpa_s, data);
3045 #endif /* CONFIG_IBSS_RSN */
3046 case EVENT_ASSOC_REJECT:
3047 if (data->assoc_reject.bssid)
3048 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_ASSOC_REJECT
3049 "bssid=" MACSTR " status_code=%u",
3050 MAC2STR(data->assoc_reject.bssid),
3051 data->assoc_reject.status_code);
3053 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_ASSOC_REJECT
3055 data->assoc_reject.status_code);
3056 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
3057 sme_event_assoc_reject(wpa_s, data);
3059 const u8 *bssid = data->assoc_reject.bssid;
3060 if (bssid == NULL || is_zero_ether_addr(bssid))
3061 bssid = wpa_s->pending_bssid;
3062 wpas_connection_failed(wpa_s, bssid);
3063 wpa_supplicant_mark_disassoc(wpa_s);
3066 case EVENT_AUTH_TIMED_OUT:
3067 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
3068 sme_event_auth_timed_out(wpa_s, data);
3070 case EVENT_ASSOC_TIMED_OUT:
3071 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
3072 sme_event_assoc_timed_out(wpa_s, data);
3074 case EVENT_TX_STATUS:
3075 wpa_dbg(wpa_s, MSG_DEBUG, "EVENT_TX_STATUS dst=" MACSTR
3076 " type=%d stype=%d",
3077 MAC2STR(data->tx_status.dst),
3078 data->tx_status.type, data->tx_status.stype);
3080 if (wpa_s->ap_iface == NULL) {
3081 #ifdef CONFIG_OFFCHANNEL
3082 if (data->tx_status.type == WLAN_FC_TYPE_MGMT &&
3083 data->tx_status.stype == WLAN_FC_STYPE_ACTION)
3084 offchannel_send_action_tx_status(
3085 wpa_s, data->tx_status.dst,
3086 data->tx_status.data,
3087 data->tx_status.data_len,
3088 data->tx_status.ack ?
3089 OFFCHANNEL_SEND_ACTION_SUCCESS :
3090 OFFCHANNEL_SEND_ACTION_NO_ACK);
3091 #endif /* CONFIG_OFFCHANNEL */
3094 #endif /* CONFIG_AP */
3095 #ifdef CONFIG_OFFCHANNEL
3096 wpa_dbg(wpa_s, MSG_DEBUG, "EVENT_TX_STATUS pending_dst="
3097 MACSTR, MAC2STR(wpa_s->parent->pending_action_dst));
3099 * Catch TX status events for Action frames we sent via group
3100 * interface in GO mode.
3102 if (data->tx_status.type == WLAN_FC_TYPE_MGMT &&
3103 data->tx_status.stype == WLAN_FC_STYPE_ACTION &&
3104 os_memcmp(wpa_s->parent->pending_action_dst,
3105 data->tx_status.dst, ETH_ALEN) == 0) {
3106 offchannel_send_action_tx_status(
3107 wpa_s->parent, data->tx_status.dst,
3108 data->tx_status.data,
3109 data->tx_status.data_len,
3110 data->tx_status.ack ?
3111 OFFCHANNEL_SEND_ACTION_SUCCESS :
3112 OFFCHANNEL_SEND_ACTION_NO_ACK);
3115 #endif /* CONFIG_OFFCHANNEL */
3117 switch (data->tx_status.type) {
3118 case WLAN_FC_TYPE_MGMT:
3119 ap_mgmt_tx_cb(wpa_s, data->tx_status.data,
3120 data->tx_status.data_len,
3121 data->tx_status.stype,
3122 data->tx_status.ack);
3124 case WLAN_FC_TYPE_DATA:
3125 ap_tx_status(wpa_s, data->tx_status.dst,
3126 data->tx_status.data,
3127 data->tx_status.data_len,
3128 data->tx_status.ack);
3131 #endif /* CONFIG_AP */
3134 case EVENT_EAPOL_TX_STATUS:
3135 ap_eapol_tx_status(wpa_s, data->eapol_tx_status.dst,
3136 data->eapol_tx_status.data,
3137 data->eapol_tx_status.data_len,
3138 data->eapol_tx_status.ack);
3140 case EVENT_DRIVER_CLIENT_POLL_OK:
3141 ap_client_poll_ok(wpa_s, data->client_poll.addr);
3143 case EVENT_RX_FROM_UNKNOWN:
3144 if (wpa_s->ap_iface == NULL)
3146 ap_rx_from_unknown_sta(wpa_s, data->rx_from_unknown.addr,
3147 data->rx_from_unknown.wds);
3149 case EVENT_CH_SWITCH:
3152 if (!wpa_s->ap_iface) {
3153 wpa_dbg(wpa_s, MSG_DEBUG, "AP: Ignore channel switch "
3154 "event in non-AP mode");
3158 wpas_ap_ch_switch(wpa_s, data->ch_switch.freq,
3159 data->ch_switch.ht_enabled,
3160 data->ch_switch.ch_offset,
3161 data->ch_switch.ch_width,
3162 data->ch_switch.cf1,
3163 data->ch_switch.cf2);
3165 #endif /* CONFIG_AP */
3166 case EVENT_RX_MGMT: {
3168 const struct ieee80211_mgmt *mgmt;
3170 #ifdef CONFIG_TESTING_OPTIONS
3171 if (wpa_s->ext_mgmt_frame_handling) {
3172 struct rx_mgmt *rx = &data->rx_mgmt;
3173 size_t hex_len = 2 * rx->frame_len + 1;
3174 char *hex = os_malloc(hex_len);
3176 wpa_snprintf_hex(hex, hex_len,
3177 rx->frame, rx->frame_len);
3178 wpa_msg(wpa_s, MSG_INFO, "MGMT-RX freq=%d datarate=%u ssi_signal=%d %s",
3179 rx->freq, rx->datarate, rx->ssi_signal,
3185 #endif /* CONFIG_TESTING_OPTIONS */
3187 mgmt = (const struct ieee80211_mgmt *)
3188 data->rx_mgmt.frame;
3189 fc = le_to_host16(mgmt->frame_control);
3190 stype = WLAN_FC_GET_STYPE(fc);
3193 if (wpa_s->ap_iface == NULL) {
3194 #endif /* CONFIG_AP */
3196 if (stype == WLAN_FC_STYPE_PROBE_REQ &&
3197 data->rx_mgmt.frame_len > 24) {
3198 const u8 *src = mgmt->sa;
3199 const u8 *ie = mgmt->u.probe_req.variable;
3200 size_t ie_len = data->rx_mgmt.frame_len -
3201 (mgmt->u.probe_req.variable -
3202 data->rx_mgmt.frame);
3203 wpas_p2p_probe_req_rx(
3204 wpa_s, src, mgmt->da,
3205 mgmt->bssid, ie, ie_len,
3206 data->rx_mgmt.ssi_signal);
3209 #endif /* CONFIG_P2P */
3210 #ifdef CONFIG_IBSS_RSN
3211 if (stype == WLAN_FC_STYPE_AUTH &&
3212 data->rx_mgmt.frame_len >= 30) {
3213 wpa_supplicant_event_ibss_auth(wpa_s, data);
3216 #endif /* CONFIG_IBSS_RSN */
3218 if (stype == WLAN_FC_STYPE_ACTION) {
3219 wpas_event_rx_mgmt_action(
3220 wpa_s, data->rx_mgmt.frame,
3221 data->rx_mgmt.frame_len,
3222 data->rx_mgmt.freq);
3226 wpa_dbg(wpa_s, MSG_DEBUG, "AP: ignore received "
3227 "management frame in non-AP mode");
3232 if (stype == WLAN_FC_STYPE_PROBE_REQ &&
3233 data->rx_mgmt.frame_len > 24) {
3234 const u8 *ie = mgmt->u.probe_req.variable;
3235 size_t ie_len = data->rx_mgmt.frame_len -
3236 (mgmt->u.probe_req.variable -
3237 data->rx_mgmt.frame);
3239 wpas_notify_preq(wpa_s, mgmt->sa, mgmt->da,
3240 mgmt->bssid, ie, ie_len,
3241 data->rx_mgmt.ssi_signal);
3244 ap_mgmt_rx(wpa_s, &data->rx_mgmt);
3245 #endif /* CONFIG_AP */
3248 case EVENT_RX_PROBE_REQ:
3249 if (data->rx_probe_req.sa == NULL ||
3250 data->rx_probe_req.ie == NULL)
3253 if (wpa_s->ap_iface) {
3254 hostapd_probe_req_rx(wpa_s->ap_iface->bss[0],
3255 data->rx_probe_req.sa,
3256 data->rx_probe_req.da,
3257 data->rx_probe_req.bssid,
3258 data->rx_probe_req.ie,
3259 data->rx_probe_req.ie_len,
3260 data->rx_probe_req.ssi_signal);
3263 #endif /* CONFIG_AP */
3264 wpas_p2p_probe_req_rx(wpa_s, data->rx_probe_req.sa,
3265 data->rx_probe_req.da,
3266 data->rx_probe_req.bssid,
3267 data->rx_probe_req.ie,
3268 data->rx_probe_req.ie_len,
3269 data->rx_probe_req.ssi_signal);
3271 case EVENT_REMAIN_ON_CHANNEL:
3272 #ifdef CONFIG_OFFCHANNEL
3273 offchannel_remain_on_channel_cb(
3274 wpa_s, data->remain_on_channel.freq,
3275 data->remain_on_channel.duration);
3276 #endif /* CONFIG_OFFCHANNEL */
3277 wpas_p2p_remain_on_channel_cb(
3278 wpa_s, data->remain_on_channel.freq,
3279 data->remain_on_channel.duration);
3281 case EVENT_CANCEL_REMAIN_ON_CHANNEL:
3282 #ifdef CONFIG_OFFCHANNEL
3283 offchannel_cancel_remain_on_channel_cb(
3284 wpa_s, data->remain_on_channel.freq);
3285 #endif /* CONFIG_OFFCHANNEL */
3286 wpas_p2p_cancel_remain_on_channel_cb(
3287 wpa_s, data->remain_on_channel.freq);
3289 case EVENT_EAPOL_RX:
3290 wpa_supplicant_rx_eapol(wpa_s, data->eapol_rx.src,
3291 data->eapol_rx.data,
3292 data->eapol_rx.data_len);
3294 case EVENT_SIGNAL_CHANGE:
3295 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_SIGNAL_CHANGE
3296 "above=%d signal=%d noise=%d txrate=%d",
3297 data->signal_change.above_threshold,
3298 data->signal_change.current_signal,
3299 data->signal_change.current_noise,
3300 data->signal_change.current_txrate);
3301 bgscan_notify_signal_change(
3302 wpa_s, data->signal_change.above_threshold,
3303 data->signal_change.current_signal,
3304 data->signal_change.current_noise,
3305 data->signal_change.current_txrate);
3307 case EVENT_INTERFACE_ENABLED:
3308 wpa_dbg(wpa_s, MSG_DEBUG, "Interface was enabled");
3309 if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) {
3310 wpa_supplicant_update_mac_addr(wpa_s);
3311 if (wpa_s->p2p_mgmt) {
3312 wpa_supplicant_set_state(wpa_s,
3318 if (!wpa_s->ap_iface) {
3319 wpa_supplicant_set_state(wpa_s,
3321 wpa_supplicant_req_scan(wpa_s, 0, 0);
3323 wpa_supplicant_set_state(wpa_s,
3325 #else /* CONFIG_AP */
3326 wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
3327 wpa_supplicant_req_scan(wpa_s, 0, 0);
3328 #endif /* CONFIG_AP */
3331 case EVENT_INTERFACE_DISABLED:
3332 wpa_dbg(wpa_s, MSG_DEBUG, "Interface was disabled");
3334 if (wpa_s->p2p_group_interface == P2P_GROUP_INTERFACE_GO ||
3335 (wpa_s->current_ssid && wpa_s->current_ssid->p2p_group &&
3336 wpa_s->current_ssid->mode == WPAS_MODE_P2P_GO)) {
3338 * The interface was externally disabled. Remove
3339 * it assuming an external entity will start a
3340 * new session if needed.
3342 wpas_p2p_disconnect(wpa_s);
3345 if (wpa_s->p2p_scan_work && wpa_s->global->p2p &&
3346 p2p_in_progress(wpa_s->global->p2p) > 1) {
3347 /* This radio work will be cancelled, so clear P2P
3350 p2p_stop_find(wpa_s->global->p2p);
3352 #endif /* CONFIG_P2P */
3354 if (wpa_s->wpa_state >= WPA_AUTHENTICATING) {
3356 * Indicate disconnection to keep ctrl_iface events
3359 wpa_supplicant_event_disassoc(
3360 wpa_s, WLAN_REASON_DEAUTH_LEAVING, 1);
3362 wpa_supplicant_mark_disassoc(wpa_s);
3363 radio_remove_works(wpa_s, NULL, 0);
3365 wpa_supplicant_set_state(wpa_s, WPA_INTERFACE_DISABLED);
3367 case EVENT_CHANNEL_LIST_CHANGED:
3368 wpa_supplicant_update_channel_list(
3369 wpa_s, &data->channel_list_changed);
3371 case EVENT_INTERFACE_UNAVAILABLE:
3372 wpas_p2p_interface_unavailable(wpa_s);
3374 case EVENT_BEST_CHANNEL:
3375 wpa_dbg(wpa_s, MSG_DEBUG, "Best channel event received "
3377 data->best_chan.freq_24, data->best_chan.freq_5,
3378 data->best_chan.freq_overall);
3379 wpa_s->best_24_freq = data->best_chan.freq_24;
3380 wpa_s->best_5_freq = data->best_chan.freq_5;
3381 wpa_s->best_overall_freq = data->best_chan.freq_overall;
3382 wpas_p2p_update_best_channels(wpa_s, data->best_chan.freq_24,
3383 data->best_chan.freq_5,
3384 data->best_chan.freq_overall);
3386 case EVENT_UNPROT_DEAUTH:
3387 wpa_supplicant_event_unprot_deauth(wpa_s,
3388 &data->unprot_deauth);
3390 case EVENT_UNPROT_DISASSOC:
3391 wpa_supplicant_event_unprot_disassoc(wpa_s,
3392 &data->unprot_disassoc);
3394 case EVENT_STATION_LOW_ACK:
3396 if (wpa_s->ap_iface && data)
3397 hostapd_event_sta_low_ack(wpa_s->ap_iface->bss[0],
3398 data->low_ack.addr);
3399 #endif /* CONFIG_AP */
3402 wpa_tdls_disable_unreachable_link(wpa_s->wpa,
3403 data->low_ack.addr);
3404 #endif /* CONFIG_TDLS */
3406 case EVENT_IBSS_PEER_LOST:
3407 #ifdef CONFIG_IBSS_RSN
3408 ibss_rsn_stop(wpa_s->ibss_rsn, data->ibss_peer_lost.peer);
3409 #endif /* CONFIG_IBSS_RSN */
3411 case EVENT_DRIVER_GTK_REKEY:
3412 if (os_memcmp(data->driver_gtk_rekey.bssid,
3413 wpa_s->bssid, ETH_ALEN))
3417 wpa_sm_update_replay_ctr(wpa_s->wpa,
3418 data->driver_gtk_rekey.replay_ctr);
3420 case EVENT_SCHED_SCAN_STOPPED:
3422 wpa_s->sched_scanning = 0;
3423 wpa_supplicant_notify_scanning(wpa_s, 0);
3425 if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED)
3429 * Start a new sched scan to continue searching for more SSIDs
3430 * either if timed out or PNO schedule scan is pending.
3432 if (wpa_s->sched_scan_timed_out) {
3433 wpa_supplicant_req_sched_scan(wpa_s);
3434 } else if (wpa_s->pno_sched_pending) {
3435 wpa_s->pno_sched_pending = 0;
3436 wpas_start_pno(wpa_s);
3440 case EVENT_WPS_BUTTON_PUSHED:
3442 wpas_wps_start_pbc(wpa_s, NULL, 0);
3443 #endif /* CONFIG_WPS */
3445 case EVENT_AVOID_FREQUENCIES:
3446 wpa_supplicant_notify_avoid_freq(wpa_s, data);
3448 case EVENT_CONNECT_FAILED_REASON:
3450 if (!wpa_s->ap_iface || !data)
3452 hostapd_event_connect_failed_reason(
3453 wpa_s->ap_iface->bss[0],
3454 data->connect_failed_reason.addr,
3455 data->connect_failed_reason.code);
3456 #endif /* CONFIG_AP */
3459 wpa_msg(wpa_s, MSG_INFO, "Unknown event %d", event);