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 int wpa_supplicant_select_config(struct wpa_supplicant *wpa_s)
88 struct wpa_ssid *ssid, *old_ssid;
92 if (wpa_s->conf->ap_scan == 1 && wpa_s->current_ssid)
95 wpa_dbg(wpa_s, MSG_DEBUG, "Select network based on association "
97 ssid = wpa_supplicant_get_ssid(wpa_s);
99 wpa_msg(wpa_s, MSG_INFO,
100 "No network configuration found for the current AP");
104 if (wpas_network_disabled(wpa_s, ssid)) {
105 wpa_dbg(wpa_s, MSG_DEBUG, "Selected network is disabled");
109 if (disallowed_bssid(wpa_s, wpa_s->bssid) ||
110 disallowed_ssid(wpa_s, ssid->ssid, ssid->ssid_len)) {
111 wpa_dbg(wpa_s, MSG_DEBUG, "Selected BSS is disallowed");
115 res = wpas_temp_disabled(wpa_s, ssid);
117 wpa_dbg(wpa_s, MSG_DEBUG, "Selected network is temporarily "
118 "disabled for %d second(s)", res);
122 wpa_dbg(wpa_s, MSG_DEBUG, "Network configuration found for the "
124 if (wpa_key_mgmt_wpa_any(ssid->key_mgmt)) {
126 size_t wpa_ie_len = sizeof(wpa_ie);
127 if (wpa_supplicant_set_suites(wpa_s, NULL, ssid,
128 wpa_ie, &wpa_ie_len) < 0)
129 wpa_dbg(wpa_s, MSG_DEBUG, "Could not set WPA suites");
131 wpa_supplicant_set_non_wpa_policy(wpa_s, ssid);
134 if (wpa_s->current_ssid && wpa_s->current_ssid != ssid)
135 eapol_sm_invalidate_cached_session(wpa_s->eapol);
136 old_ssid = wpa_s->current_ssid;
137 wpa_s->current_ssid = ssid;
139 bss = wpa_supplicant_get_new_bss(wpa_s, wpa_s->bssid);
141 wpa_supplicant_update_scan_results(wpa_s);
143 /* Get the BSS from the new scan results */
144 bss = wpa_supplicant_get_new_bss(wpa_s, wpa_s->bssid);
148 wpa_s->current_bss = bss;
150 wpa_supplicant_rsn_supp_set_config(wpa_s, wpa_s->current_ssid);
151 wpa_supplicant_initiate_eapol(wpa_s);
152 if (old_ssid != wpa_s->current_ssid)
153 wpas_notify_network_changed(wpa_s);
159 void wpa_supplicant_stop_countermeasures(void *eloop_ctx, void *sock_ctx)
161 struct wpa_supplicant *wpa_s = eloop_ctx;
163 if (wpa_s->countermeasures) {
164 wpa_s->countermeasures = 0;
165 wpa_drv_set_countermeasures(wpa_s, 0);
166 wpa_msg(wpa_s, MSG_INFO, "WPA: TKIP countermeasures stopped");
167 wpa_supplicant_req_scan(wpa_s, 0, 0);
172 void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s)
176 wnm_bss_keep_alive_deinit(wpa_s);
178 #ifdef CONFIG_IBSS_RSN
179 ibss_rsn_deinit(wpa_s->ibss_rsn);
180 wpa_s->ibss_rsn = NULL;
181 #endif /* CONFIG_IBSS_RSN */
184 wpa_supplicant_ap_deinit(wpa_s);
185 #endif /* CONFIG_AP */
187 if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED)
190 wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
191 bssid_changed = !is_zero_ether_addr(wpa_s->bssid);
192 os_memset(wpa_s->bssid, 0, ETH_ALEN);
193 os_memset(wpa_s->pending_bssid, 0, ETH_ALEN);
195 wpa_s->sme.prev_bssid_set = 0;
196 #endif /* CONFIG_SME */
198 os_memset(wpa_s->go_dev_addr, 0, ETH_ALEN);
199 #endif /* CONFIG_P2P */
200 wpa_s->current_bss = NULL;
201 wpa_s->assoc_freq = 0;
202 #ifdef CONFIG_IEEE80211R
204 if (wpa_s->sme.ft_ies)
205 sme_update_ft_ies(wpa_s, NULL, NULL, 0);
206 #endif /* CONFIG_SME */
207 #endif /* CONFIG_IEEE80211R */
210 wpas_notify_bssid_changed(wpa_s);
212 eapol_sm_notify_portEnabled(wpa_s->eapol, FALSE);
213 eapol_sm_notify_portValid(wpa_s->eapol, FALSE);
214 if (wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt))
215 eapol_sm_notify_eap_success(wpa_s->eapol, FALSE);
216 wpa_s->ap_ies_from_associnfo = 0;
217 wpa_s->current_ssid = NULL;
218 eapol_sm_notify_config(wpa_s->eapol, NULL, NULL);
223 static void wpa_find_assoc_pmkid(struct wpa_supplicant *wpa_s)
225 struct wpa_ie_data ie;
229 if (wpa_sm_parse_own_wpa_ie(wpa_s->wpa, &ie) < 0 ||
233 for (i = 0; i < ie.num_pmkid; i++) {
234 pmksa_set = pmksa_cache_set_current(wpa_s->wpa,
235 ie.pmkid + i * PMKID_LEN,
237 if (pmksa_set == 0) {
238 eapol_sm_notify_pmkid_attempt(wpa_s->eapol, 1);
243 wpa_dbg(wpa_s, MSG_DEBUG, "RSN: PMKID from assoc IE %sfound from "
244 "PMKSA cache", pmksa_set == 0 ? "" : "not ");
248 static void wpa_supplicant_event_pmkid_candidate(struct wpa_supplicant *wpa_s,
249 union wpa_event_data *data)
252 wpa_dbg(wpa_s, MSG_DEBUG, "RSN: No data in PMKID candidate "
256 wpa_dbg(wpa_s, MSG_DEBUG, "RSN: PMKID candidate event - bssid=" MACSTR
257 " index=%d preauth=%d",
258 MAC2STR(data->pmkid_candidate.bssid),
259 data->pmkid_candidate.index,
260 data->pmkid_candidate.preauth);
262 pmksa_candidate_add(wpa_s->wpa, data->pmkid_candidate.bssid,
263 data->pmkid_candidate.index,
264 data->pmkid_candidate.preauth);
268 static int wpa_supplicant_dynamic_keys(struct wpa_supplicant *wpa_s)
270 if (wpa_s->key_mgmt == WPA_KEY_MGMT_NONE ||
271 wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE)
274 #ifdef IEEE8021X_EAPOL
275 if (wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA &&
276 wpa_s->current_ssid &&
277 !(wpa_s->current_ssid->eapol_flags &
278 (EAPOL_FLAG_REQUIRE_KEY_UNICAST |
279 EAPOL_FLAG_REQUIRE_KEY_BROADCAST))) {
280 /* IEEE 802.1X, but not using dynamic WEP keys (i.e., either
281 * plaintext or static WEP keys). */
284 #endif /* IEEE8021X_EAPOL */
291 * wpa_supplicant_scard_init - Initialize SIM/USIM access with PC/SC
292 * @wpa_s: pointer to wpa_supplicant data
293 * @ssid: Configuration data for the network
294 * Returns: 0 on success, -1 on failure
296 * This function is called when starting authentication with a network that is
297 * configured to use PC/SC for SIM/USIM access (EAP-SIM or EAP-AKA).
299 int wpa_supplicant_scard_init(struct wpa_supplicant *wpa_s,
300 struct wpa_ssid *ssid)
302 #ifdef IEEE8021X_EAPOL
304 int aka = 0, sim = 0;
306 if ((ssid != NULL && ssid->eap.pcsc == NULL) ||
307 wpa_s->scard != NULL || wpa_s->conf->external_sim)
310 if (ssid == NULL || ssid->eap.eap_methods == NULL) {
314 struct eap_method_type *eap = ssid->eap.eap_methods;
315 while (eap->vendor != EAP_VENDOR_IETF ||
316 eap->method != EAP_TYPE_NONE) {
317 if (eap->vendor == EAP_VENDOR_IETF) {
318 if (eap->method == EAP_TYPE_SIM)
320 else if (eap->method == EAP_TYPE_AKA ||
321 eap->method == EAP_TYPE_AKA_PRIME)
328 if (eap_peer_get_eap_method(EAP_VENDOR_IETF, EAP_TYPE_SIM) == NULL)
330 if (eap_peer_get_eap_method(EAP_VENDOR_IETF, EAP_TYPE_AKA) == NULL &&
331 eap_peer_get_eap_method(EAP_VENDOR_IETF, EAP_TYPE_AKA_PRIME) ==
336 wpa_dbg(wpa_s, MSG_DEBUG, "Selected network is configured to "
337 "use SIM, but neither EAP-SIM nor EAP-AKA are "
342 wpa_dbg(wpa_s, MSG_DEBUG, "Selected network is configured to use SIM "
343 "(sim=%d aka=%d) - initialize PCSC", sim, aka);
345 wpa_s->scard = scard_init(NULL);
346 if (wpa_s->scard == NULL) {
347 wpa_msg(wpa_s, MSG_WARNING, "Failed to initialize SIM "
351 wpa_sm_set_scard_ctx(wpa_s->wpa, wpa_s->scard);
352 eapol_sm_register_scard_ctx(wpa_s->eapol, wpa_s->scard);
353 #endif /* PCSC_FUNCS */
354 #endif /* IEEE8021X_EAPOL */
360 #ifndef CONFIG_NO_SCAN_PROCESSING
362 static int has_wep_key(struct wpa_ssid *ssid)
366 for (i = 0; i < NUM_WEP_KEYS; i++) {
367 if (ssid->wep_key_len[i])
375 static int wpa_supplicant_match_privacy(struct wpa_bss *bss,
376 struct wpa_ssid *ssid)
380 if (ssid->mixed_cell)
384 if (ssid->key_mgmt & WPA_KEY_MGMT_WPS)
386 #endif /* CONFIG_WPS */
388 if (has_wep_key(ssid))
391 #ifdef IEEE8021X_EAPOL
392 if ((ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X_NO_WPA) &&
393 ssid->eapol_flags & (EAPOL_FLAG_REQUIRE_KEY_UNICAST |
394 EAPOL_FLAG_REQUIRE_KEY_BROADCAST))
396 #endif /* IEEE8021X_EAPOL */
398 if (wpa_key_mgmt_wpa(ssid->key_mgmt))
401 if (ssid->key_mgmt & WPA_KEY_MGMT_OSEN)
404 if (bss->caps & IEEE80211_CAP_PRIVACY)
410 static int wpa_supplicant_ssid_bss_match(struct wpa_supplicant *wpa_s,
411 struct wpa_ssid *ssid,
414 struct wpa_ie_data ie;
416 const u8 *rsn_ie, *wpa_ie;
420 ret = wpas_wps_ssid_bss_match(wpa_s, ssid, bss);
424 /* Allow TSN if local configuration accepts WEP use without WPA/WPA2 */
425 wep_ok = !wpa_key_mgmt_wpa(ssid->key_mgmt) &&
426 (((ssid->key_mgmt & WPA_KEY_MGMT_NONE) &&
427 ssid->wep_key_len[ssid->wep_tx_keyidx] > 0) ||
428 (ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X_NO_WPA));
430 rsn_ie = wpa_bss_get_ie(bss, WLAN_EID_RSN);
431 while ((ssid->proto & WPA_PROTO_RSN) && rsn_ie) {
434 if (wpa_parse_wpa_ie(rsn_ie, 2 + rsn_ie[1], &ie)) {
435 wpa_dbg(wpa_s, MSG_DEBUG, " skip RSN IE - parse "
441 (ie.group_cipher & (WPA_CIPHER_WEP40 | WPA_CIPHER_WEP104)))
443 wpa_dbg(wpa_s, MSG_DEBUG, " selected based on TSN "
448 if (!(ie.proto & ssid->proto)) {
449 wpa_dbg(wpa_s, MSG_DEBUG, " skip RSN IE - proto "
454 if (!(ie.pairwise_cipher & ssid->pairwise_cipher)) {
455 wpa_dbg(wpa_s, MSG_DEBUG, " skip RSN IE - PTK "
460 if (!(ie.group_cipher & ssid->group_cipher)) {
461 wpa_dbg(wpa_s, MSG_DEBUG, " skip RSN IE - GTK "
466 if (!(ie.key_mgmt & ssid->key_mgmt)) {
467 wpa_dbg(wpa_s, MSG_DEBUG, " skip RSN IE - key mgmt "
472 #ifdef CONFIG_IEEE80211W
473 if (!(ie.capabilities & WPA_CAPABILITY_MFPC) &&
474 (ssid->ieee80211w == MGMT_FRAME_PROTECTION_DEFAULT ?
475 wpa_s->conf->pmf : ssid->ieee80211w) ==
476 MGMT_FRAME_PROTECTION_REQUIRED) {
477 wpa_dbg(wpa_s, MSG_DEBUG, " skip RSN IE - no mgmt "
481 #endif /* CONFIG_IEEE80211W */
483 wpa_dbg(wpa_s, MSG_DEBUG, " selected based on RSN IE");
487 wpa_ie = wpa_bss_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE);
488 while ((ssid->proto & WPA_PROTO_WPA) && wpa_ie) {
491 if (wpa_parse_wpa_ie(wpa_ie, 2 + wpa_ie[1], &ie)) {
492 wpa_dbg(wpa_s, MSG_DEBUG, " skip WPA IE - parse "
498 (ie.group_cipher & (WPA_CIPHER_WEP40 | WPA_CIPHER_WEP104)))
500 wpa_dbg(wpa_s, MSG_DEBUG, " selected based on TSN "
505 if (!(ie.proto & ssid->proto)) {
506 wpa_dbg(wpa_s, MSG_DEBUG, " skip WPA IE - proto "
511 if (!(ie.pairwise_cipher & ssid->pairwise_cipher)) {
512 wpa_dbg(wpa_s, MSG_DEBUG, " skip WPA IE - PTK "
517 if (!(ie.group_cipher & ssid->group_cipher)) {
518 wpa_dbg(wpa_s, MSG_DEBUG, " skip WPA IE - GTK "
523 if (!(ie.key_mgmt & ssid->key_mgmt)) {
524 wpa_dbg(wpa_s, MSG_DEBUG, " skip WPA IE - key mgmt "
529 wpa_dbg(wpa_s, MSG_DEBUG, " selected based on WPA IE");
533 if ((ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X_NO_WPA) && !wpa_ie &&
535 wpa_dbg(wpa_s, MSG_DEBUG, " allow for non-WPA IEEE 802.1X");
539 if ((ssid->proto & (WPA_PROTO_WPA | WPA_PROTO_RSN)) &&
540 wpa_key_mgmt_wpa(ssid->key_mgmt) && proto_match == 0) {
541 wpa_dbg(wpa_s, MSG_DEBUG, " skip - no WPA/RSN proto match");
545 if ((ssid->key_mgmt & WPA_KEY_MGMT_OSEN) &&
546 wpa_bss_get_vendor_ie(bss, OSEN_IE_VENDOR_TYPE)) {
547 wpa_dbg(wpa_s, MSG_DEBUG, " allow in OSEN");
551 if (!wpa_key_mgmt_wpa(ssid->key_mgmt)) {
552 wpa_dbg(wpa_s, MSG_DEBUG, " allow in non-WPA/WPA2");
556 wpa_dbg(wpa_s, MSG_DEBUG, " reject due to mismatch with "
563 static int freq_allowed(int *freqs, int freq)
570 for (i = 0; freqs[i]; i++)
571 if (freqs[i] == freq)
577 static int ht_supported(const struct hostapd_hw_modes *mode)
579 if (!(mode->flags & HOSTAPD_MODE_FLAG_HT_INFO_KNOWN)) {
581 * The driver did not indicate whether it supports HT. Assume
582 * it does to avoid connection issues.
588 * IEEE Std 802.11n-2009 20.1.1:
589 * An HT non-AP STA shall support all EQM rates for one spatial stream.
591 return mode->mcs_set[0] == 0xff;
595 static int vht_supported(const struct hostapd_hw_modes *mode)
597 if (!(mode->flags & HOSTAPD_MODE_FLAG_VHT_INFO_KNOWN)) {
599 * The driver did not indicate whether it supports VHT. Assume
600 * it does to avoid connection issues.
606 * A VHT non-AP STA shall support MCS 0-7 for one spatial stream.
607 * TODO: Verify if this complies with the standard
609 return (mode->vht_mcs_set[0] & 0x3) != 3;
613 static int rate_match(struct wpa_supplicant *wpa_s, struct wpa_bss *bss)
615 const struct hostapd_hw_modes *mode = NULL, *modes;
616 const u8 scan_ie[2] = { WLAN_EID_SUPP_RATES, WLAN_EID_EXT_SUPP_RATES };
621 return 1; /* Cannot do matching without knowing band */
623 modes = wpa_s->hw.modes;
626 * The driver does not provide any additional information
627 * about the utilized hardware, so allow the connection attempt
633 for (i = 0; i < wpa_s->hw.num_modes; i++) {
634 for (j = 0; j < modes[i].num_channels; j++) {
635 int freq = modes[i].channels[j].freq;
636 if (freq == bss->freq) {
638 mode->mode == HOSTAPD_MODE_IEEE80211G)
639 break; /* do not allow 802.11b replace
650 for (i = 0; i < (int) sizeof(scan_ie); i++) {
651 rate_ie = wpa_bss_get_ie(bss, scan_ie[i]);
655 for (j = 2; j < rate_ie[1] + 2; j++) {
656 int flagged = !!(rate_ie[j] & 0x80);
657 int r = (rate_ie[j] & 0x7f) * 5;
660 * IEEE Std 802.11n-2009 7.3.2.2:
661 * The new BSS Membership selector value is encoded
662 * like a legacy basic rate, but it is not a rate and
663 * only indicates if the BSS members are required to
664 * support the mandatory features of Clause 20 [HT PHY]
665 * in order to join the BSS.
667 if (flagged && ((rate_ie[j] & 0x7f) ==
668 BSS_MEMBERSHIP_SELECTOR_HT_PHY)) {
669 if (!ht_supported(mode)) {
670 wpa_dbg(wpa_s, MSG_DEBUG,
671 " hardware does not support "
678 /* There's also a VHT selector for 802.11ac */
679 if (flagged && ((rate_ie[j] & 0x7f) ==
680 BSS_MEMBERSHIP_SELECTOR_VHT_PHY)) {
681 if (!vht_supported(mode)) {
682 wpa_dbg(wpa_s, MSG_DEBUG,
683 " hardware does not support "
693 /* check for legacy basic rates */
694 for (k = 0; k < mode->num_rates; k++) {
695 if (mode->rates[k] == r)
698 if (k == mode->num_rates) {
700 * IEEE Std 802.11-2007 7.3.2.2 demands that in
701 * order to join a BSS all required rates
702 * have to be supported by the hardware.
704 wpa_dbg(wpa_s, MSG_DEBUG, " hardware does "
705 "not support required rate %d.%d Mbps",
717 * Test whether BSS is in an ESS.
718 * This is done differently in DMG (60 GHz) and non-DMG bands
720 static int bss_is_ess(struct wpa_bss *bss)
722 if (bss_is_dmg(bss)) {
723 return (bss->caps & IEEE80211_CAP_DMG_MASK) ==
724 IEEE80211_CAP_DMG_AP;
727 return ((bss->caps & (IEEE80211_CAP_ESS | IEEE80211_CAP_IBSS)) ==
732 static struct wpa_ssid * wpa_scan_res_match(struct wpa_supplicant *wpa_s,
733 int i, struct wpa_bss *bss,
734 struct wpa_ssid *group,
737 u8 wpa_ie_len, rsn_ie_len;
739 struct wpa_blacklist *e;
741 struct wpa_ssid *ssid;
744 ie = wpa_bss_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE);
745 wpa_ie_len = ie ? ie[1] : 0;
747 ie = wpa_bss_get_ie(bss, WLAN_EID_RSN);
748 rsn_ie_len = ie ? ie[1] : 0;
750 ie = wpa_bss_get_vendor_ie(bss, OSEN_IE_VENDOR_TYPE);
753 wpa_dbg(wpa_s, MSG_DEBUG, "%d: " MACSTR " ssid='%s' "
754 "wpa_ie_len=%u rsn_ie_len=%u caps=0x%x level=%d%s%s%s",
755 i, MAC2STR(bss->bssid), wpa_ssid_txt(bss->ssid, bss->ssid_len),
756 wpa_ie_len, rsn_ie_len, bss->caps, bss->level,
757 wpa_bss_get_vendor_ie(bss, WPS_IE_VENDOR_TYPE) ? " wps" : "",
758 (wpa_bss_get_vendor_ie(bss, P2P_IE_VENDOR_TYPE) ||
759 wpa_bss_get_vendor_ie_beacon(bss, P2P_IE_VENDOR_TYPE)) ?
761 osen ? " osen=1" : "");
763 e = wpa_blacklist_get(wpa_s, bss->bssid);
766 if (wpa_supplicant_enabled_networks(wpa_s) == 1) {
768 * When only a single network is enabled, we can
769 * trigger blacklisting on the first failure. This
770 * should not be done with multiple enabled networks to
771 * avoid getting forced to move into a worse ESS on
772 * single error if there are no other BSSes of the
777 if (e->count > limit) {
778 wpa_dbg(wpa_s, MSG_DEBUG, " skip - blacklisted "
779 "(count=%d limit=%d)", e->count, limit);
784 if (bss->ssid_len == 0) {
785 wpa_dbg(wpa_s, MSG_DEBUG, " skip - SSID not known");
789 if (disallowed_bssid(wpa_s, bss->bssid)) {
790 wpa_dbg(wpa_s, MSG_DEBUG, " skip - BSSID disallowed");
794 if (disallowed_ssid(wpa_s, bss->ssid, bss->ssid_len)) {
795 wpa_dbg(wpa_s, MSG_DEBUG, " skip - SSID disallowed");
799 wpa = wpa_ie_len > 0 || rsn_ie_len > 0;
801 for (ssid = group; ssid; ssid = only_first_ssid ? NULL : ssid->pnext) {
802 int check_ssid = wpa ? 1 : (ssid->ssid_len != 0);
805 if (wpas_network_disabled(wpa_s, ssid)) {
806 wpa_dbg(wpa_s, MSG_DEBUG, " skip - disabled");
810 res = wpas_temp_disabled(wpa_s, ssid);
812 wpa_dbg(wpa_s, MSG_DEBUG, " skip - disabled "
813 "temporarily for %d second(s)", res);
818 if ((ssid->key_mgmt & WPA_KEY_MGMT_WPS) && e && e->count > 0) {
819 wpa_dbg(wpa_s, MSG_DEBUG, " skip - blacklisted "
824 if (wpa && ssid->ssid_len == 0 &&
825 wpas_wps_ssid_wildcard_ok(wpa_s, ssid, bss))
828 if (!wpa && (ssid->key_mgmt & WPA_KEY_MGMT_WPS)) {
829 /* Only allow wildcard SSID match if an AP
830 * advertises active WPS operation that matches
833 if (ssid->ssid_len == 0 &&
834 wpas_wps_ssid_wildcard_ok(wpa_s, ssid, bss))
837 #endif /* CONFIG_WPS */
839 if (ssid->bssid_set && ssid->ssid_len == 0 &&
840 os_memcmp(bss->bssid, ssid->bssid, ETH_ALEN) == 0)
844 (bss->ssid_len != ssid->ssid_len ||
845 os_memcmp(bss->ssid, ssid->ssid, bss->ssid_len) != 0)) {
846 wpa_dbg(wpa_s, MSG_DEBUG, " skip - SSID mismatch");
850 if (ssid->bssid_set &&
851 os_memcmp(bss->bssid, ssid->bssid, ETH_ALEN) != 0) {
852 wpa_dbg(wpa_s, MSG_DEBUG, " skip - BSSID mismatch");
856 if (!wpa_supplicant_ssid_bss_match(wpa_s, ssid, bss))
860 !(ssid->key_mgmt & WPA_KEY_MGMT_NONE) &&
861 !(ssid->key_mgmt & WPA_KEY_MGMT_WPS) &&
862 !(ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X_NO_WPA)) {
863 wpa_dbg(wpa_s, MSG_DEBUG, " skip - non-WPA network "
868 if (wpa && !wpa_key_mgmt_wpa(ssid->key_mgmt) &&
870 wpa_dbg(wpa_s, MSG_DEBUG, " skip - ignore WPA/WPA2 AP for WEP network block");
874 if ((ssid->key_mgmt & WPA_KEY_MGMT_OSEN) && !osen) {
875 wpa_dbg(wpa_s, MSG_DEBUG, " skip - non-OSEN network "
880 if (!wpa_supplicant_match_privacy(bss, ssid)) {
881 wpa_dbg(wpa_s, MSG_DEBUG, " skip - privacy "
886 if (!bss_is_ess(bss)) {
887 wpa_dbg(wpa_s, MSG_DEBUG, " skip - not ESS network");
891 if (!freq_allowed(ssid->freq_list, bss->freq)) {
892 wpa_dbg(wpa_s, MSG_DEBUG, " skip - frequency not "
897 if (!rate_match(wpa_s, bss)) {
898 wpa_dbg(wpa_s, MSG_DEBUG, " skip - rate sets do "
904 if (ssid->p2p_group &&
905 !wpa_bss_get_vendor_ie(bss, P2P_IE_VENDOR_TYPE) &&
906 !wpa_bss_get_vendor_ie_beacon(bss, P2P_IE_VENDOR_TYPE)) {
907 wpa_dbg(wpa_s, MSG_DEBUG, " skip - no P2P IE seen");
911 if (!is_zero_ether_addr(ssid->go_p2p_dev_addr)) {
912 struct wpabuf *p2p_ie;
913 u8 dev_addr[ETH_ALEN];
915 ie = wpa_bss_get_vendor_ie(bss, P2P_IE_VENDOR_TYPE);
917 wpa_dbg(wpa_s, MSG_DEBUG, " skip - no P2P element");
920 p2p_ie = wpa_bss_get_vendor_ie_multi(
921 bss, P2P_IE_VENDOR_TYPE);
922 if (p2p_ie == NULL) {
923 wpa_dbg(wpa_s, MSG_DEBUG, " skip - could not fetch P2P element");
927 if (p2p_parse_dev_addr_in_p2p_ie(p2p_ie, dev_addr) < 0
928 || os_memcmp(dev_addr, ssid->go_p2p_dev_addr,
930 wpa_dbg(wpa_s, MSG_DEBUG, " skip - no matching GO P2P Device Address in P2P element");
938 * TODO: skip the AP if its P2P IE has Group Formation
939 * bit set in the P2P Group Capability Bitmap and we
940 * are not in Group Formation with that device.
942 #endif /* CONFIG_P2P */
944 /* Matching configuration found */
948 /* No matching configuration found */
953 static struct wpa_bss *
954 wpa_supplicant_select_bss(struct wpa_supplicant *wpa_s,
955 struct wpa_ssid *group,
956 struct wpa_ssid **selected_ssid,
962 wpa_dbg(wpa_s, MSG_DEBUG, "Try to find BSS matching pre-selected network id=%d",
965 wpa_dbg(wpa_s, MSG_DEBUG, "Selecting BSS from priority group %d",
968 for (i = 0; i < wpa_s->last_scan_res_used; i++) {
969 struct wpa_bss *bss = wpa_s->last_scan_res[i];
970 *selected_ssid = wpa_scan_res_match(wpa_s, i, bss, group,
974 wpa_dbg(wpa_s, MSG_DEBUG, " selected BSS " MACSTR
977 wpa_ssid_txt(bss->ssid, bss->ssid_len));
985 struct wpa_bss * wpa_supplicant_pick_network(struct wpa_supplicant *wpa_s,
986 struct wpa_ssid **selected_ssid)
988 struct wpa_bss *selected = NULL;
990 struct wpa_ssid *next_ssid = NULL;
992 if (wpa_s->last_scan_res == NULL ||
993 wpa_s->last_scan_res_used == 0)
994 return NULL; /* no scan results from last update */
996 if (wpa_s->next_ssid) {
997 struct wpa_ssid *ssid;
999 /* check that next_ssid is still valid */
1000 for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next) {
1001 if (ssid == wpa_s->next_ssid)
1005 wpa_s->next_ssid = NULL;
1008 while (selected == NULL) {
1009 for (prio = 0; prio < wpa_s->conf->num_prio; prio++) {
1010 if (next_ssid && next_ssid->priority ==
1011 wpa_s->conf->pssid[prio]->priority) {
1012 selected = wpa_supplicant_select_bss(
1013 wpa_s, next_ssid, selected_ssid, 1);
1017 selected = wpa_supplicant_select_bss(
1018 wpa_s, wpa_s->conf->pssid[prio],
1024 if (selected == NULL && wpa_s->blacklist &&
1025 !wpa_s->countermeasures) {
1026 wpa_dbg(wpa_s, MSG_DEBUG, "No APs found - clear "
1027 "blacklist and try again");
1028 wpa_blacklist_clear(wpa_s);
1029 wpa_s->blacklist_cleared++;
1030 } else if (selected == NULL)
1038 static void wpa_supplicant_req_new_scan(struct wpa_supplicant *wpa_s,
1039 int timeout_sec, int timeout_usec)
1041 if (!wpa_supplicant_enabled_networks(wpa_s)) {
1043 * No networks are enabled; short-circuit request so
1044 * we don't wait timeout seconds before transitioning
1045 * to INACTIVE state.
1047 wpa_dbg(wpa_s, MSG_DEBUG, "Short-circuit new scan request "
1048 "since there are no enabled networks");
1049 wpa_supplicant_set_state(wpa_s, WPA_INACTIVE);
1053 wpa_s->scan_for_connection = 1;
1054 wpa_supplicant_req_scan(wpa_s, timeout_sec, timeout_usec);
1058 int wpa_supplicant_connect(struct wpa_supplicant *wpa_s,
1059 struct wpa_bss *selected,
1060 struct wpa_ssid *ssid)
1062 if (wpas_wps_scan_pbc_overlap(wpa_s, selected, ssid)) {
1063 wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_OVERLAP
1064 "PBC session overlap");
1066 if (wpa_s->p2p_group_interface == P2P_GROUP_INTERFACE_CLIENT ||
1067 wpa_s->p2p_in_provisioning) {
1068 eloop_register_timeout(0, 0, wpas_p2p_pbc_overlap_cb,
1072 #endif /* CONFIG_P2P */
1075 wpas_wps_cancel(wpa_s);
1076 #endif /* CONFIG_WPS */
1080 wpa_msg(wpa_s, MSG_DEBUG,
1081 "Considering connect request: reassociate: %d selected: "
1082 MACSTR " bssid: " MACSTR " pending: " MACSTR
1083 " wpa_state: %s ssid=%p current_ssid=%p",
1084 wpa_s->reassociate, MAC2STR(selected->bssid),
1085 MAC2STR(wpa_s->bssid), MAC2STR(wpa_s->pending_bssid),
1086 wpa_supplicant_state_txt(wpa_s->wpa_state),
1087 ssid, wpa_s->current_ssid);
1090 * Do not trigger new association unless the BSSID has changed or if
1091 * reassociation is requested. If we are in process of associating with
1092 * the selected BSSID, do not trigger new attempt.
1094 if (wpa_s->reassociate ||
1095 (os_memcmp(selected->bssid, wpa_s->bssid, ETH_ALEN) != 0 &&
1096 ((wpa_s->wpa_state != WPA_ASSOCIATING &&
1097 wpa_s->wpa_state != WPA_AUTHENTICATING) ||
1098 (!is_zero_ether_addr(wpa_s->pending_bssid) &&
1099 os_memcmp(selected->bssid, wpa_s->pending_bssid, ETH_ALEN) !=
1101 (is_zero_ether_addr(wpa_s->pending_bssid) &&
1102 ssid != wpa_s->current_ssid)))) {
1103 if (wpa_supplicant_scard_init(wpa_s, ssid)) {
1104 wpa_supplicant_req_new_scan(wpa_s, 10, 0);
1107 wpa_msg(wpa_s, MSG_DEBUG, "Request association with " MACSTR,
1108 MAC2STR(selected->bssid));
1109 wpa_supplicant_associate(wpa_s, selected, ssid);
1111 wpa_dbg(wpa_s, MSG_DEBUG, "Already associated or trying to "
1112 "connect with the selected AP");
1119 static struct wpa_ssid *
1120 wpa_supplicant_pick_new_network(struct wpa_supplicant *wpa_s)
1123 struct wpa_ssid *ssid;
1125 for (prio = 0; prio < wpa_s->conf->num_prio; prio++) {
1126 for (ssid = wpa_s->conf->pssid[prio]; ssid; ssid = ssid->pnext)
1128 if (wpas_network_disabled(wpa_s, ssid))
1130 if (ssid->mode == IEEE80211_MODE_IBSS ||
1131 ssid->mode == IEEE80211_MODE_AP)
1139 /* TODO: move the rsn_preauth_scan_result*() to be called from notify.c based
1140 * on BSS added and BSS changed events */
1141 static void wpa_supplicant_rsn_preauth_scan_results(
1142 struct wpa_supplicant *wpa_s)
1144 struct wpa_bss *bss;
1146 if (rsn_preauth_scan_results(wpa_s->wpa) < 0)
1149 dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) {
1150 const u8 *ssid, *rsn;
1152 ssid = wpa_bss_get_ie(bss, WLAN_EID_SSID);
1156 rsn = wpa_bss_get_ie(bss, WLAN_EID_RSN);
1160 rsn_preauth_scan_result(wpa_s->wpa, bss->bssid, ssid, rsn);
1166 static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s,
1167 struct wpa_bss *selected,
1168 struct wpa_ssid *ssid)
1170 struct wpa_bss *current_bss = NULL;
1173 if (wpa_s->reassociate)
1174 return 1; /* explicit request to reassociate */
1175 if (wpa_s->wpa_state < WPA_ASSOCIATED)
1176 return 1; /* we are not associated; continue */
1177 if (wpa_s->current_ssid == NULL)
1178 return 1; /* unknown current SSID */
1179 if (wpa_s->current_ssid != ssid)
1180 return 1; /* different network block */
1182 if (wpas_driver_bss_selection(wpa_s))
1183 return 0; /* Driver-based roaming */
1185 if (wpa_s->current_ssid->ssid)
1186 current_bss = wpa_bss_get(wpa_s, wpa_s->bssid,
1187 wpa_s->current_ssid->ssid,
1188 wpa_s->current_ssid->ssid_len);
1190 current_bss = wpa_bss_get_bssid(wpa_s, wpa_s->bssid);
1193 return 1; /* current BSS not seen in scan results */
1195 if (current_bss == selected)
1198 if (selected->last_update_idx > current_bss->last_update_idx)
1199 return 1; /* current BSS not seen in the last scan */
1201 #ifndef CONFIG_NO_ROAMING
1202 wpa_dbg(wpa_s, MSG_DEBUG, "Considering within-ESS reassociation");
1203 wpa_dbg(wpa_s, MSG_DEBUG, "Current BSS: " MACSTR " level=%d",
1204 MAC2STR(current_bss->bssid), current_bss->level);
1205 wpa_dbg(wpa_s, MSG_DEBUG, "Selected BSS: " MACSTR " level=%d",
1206 MAC2STR(selected->bssid), selected->level);
1208 if (wpa_s->current_ssid->bssid_set &&
1209 os_memcmp(selected->bssid, wpa_s->current_ssid->bssid, ETH_ALEN) ==
1211 wpa_dbg(wpa_s, MSG_DEBUG, "Allow reassociation - selected BSS "
1212 "has preferred BSSID");
1216 if (current_bss->level < 0 && current_bss->level > selected->level) {
1217 wpa_dbg(wpa_s, MSG_DEBUG, "Skip roam - Current BSS has better "
1223 if (current_bss->level < 0) {
1224 if (current_bss->level < -85)
1226 else if (current_bss->level < -80)
1228 else if (current_bss->level < -75)
1230 else if (current_bss->level < -70)
1235 if (abs(current_bss->level - selected->level) < min_diff) {
1236 wpa_dbg(wpa_s, MSG_DEBUG, "Skip roam - too small difference "
1242 #else /* CONFIG_NO_ROAMING */
1244 #endif /* CONFIG_NO_ROAMING */
1248 /* Return != 0 if no scan results could be fetched or if scan results should not
1249 * be shared with other virtual interfaces. */
1250 static int _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s,
1251 union wpa_event_data *data,
1254 struct wpa_scan_results *scan_res = NULL;
1257 #ifndef CONFIG_NO_RANDOM_POOL
1259 #endif /* CONFIG_NO_RANDOM_POOL */
1262 if (wpa_s->ap_iface)
1264 #endif /* CONFIG_AP */
1266 wpa_supplicant_notify_scanning(wpa_s, 0);
1268 scan_res = wpa_supplicant_get_scan_results(wpa_s,
1269 data ? &data->scan_info :
1271 if (scan_res == NULL) {
1272 if (wpa_s->conf->ap_scan == 2 || ap ||
1273 wpa_s->scan_res_handler == scan_only_handler)
1277 wpa_dbg(wpa_s, MSG_DEBUG, "Failed to get scan results - try "
1279 wpa_supplicant_req_new_scan(wpa_s, 1, 0);
1281 goto scan_work_done;
1284 #ifndef CONFIG_NO_RANDOM_POOL
1285 num = scan_res->num;
1288 for (i = 0; i < num; i++) {
1290 struct wpa_scan_res *res = scan_res->res[i];
1291 buf[0] = res->bssid[5];
1292 buf[1] = res->qual & 0xff;
1293 buf[2] = res->noise & 0xff;
1294 buf[3] = res->level & 0xff;
1295 buf[4] = res->tsf & 0xff;
1296 random_add_randomness(buf, sizeof(buf));
1298 #endif /* CONFIG_NO_RANDOM_POOL */
1300 if (own_request && wpa_s->scan_res_handler &&
1301 (wpa_s->own_scan_running || !wpa_s->external_scan_running)) {
1302 void (*scan_res_handler)(struct wpa_supplicant *wpa_s,
1303 struct wpa_scan_results *scan_res);
1305 scan_res_handler = wpa_s->scan_res_handler;
1306 wpa_s->scan_res_handler = NULL;
1307 scan_res_handler(wpa_s, scan_res);
1309 goto scan_work_done;
1313 wpa_dbg(wpa_s, MSG_DEBUG, "Ignore scan results in AP mode");
1315 if (wpa_s->ap_iface->scan_cb)
1316 wpa_s->ap_iface->scan_cb(wpa_s->ap_iface);
1317 #endif /* CONFIG_AP */
1318 goto scan_work_done;
1321 wpa_dbg(wpa_s, MSG_DEBUG, "New scan results available (own=%u ext=%u)",
1322 wpa_s->own_scan_running, wpa_s->external_scan_running);
1323 if (wpa_s->last_scan_req == MANUAL_SCAN_REQ &&
1324 wpa_s->manual_scan_use_id && wpa_s->own_scan_running) {
1325 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_SCAN_RESULTS "id=%u",
1326 wpa_s->manual_scan_id);
1327 wpa_s->manual_scan_use_id = 0;
1329 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_SCAN_RESULTS);
1331 wpas_notify_scan_results(wpa_s);
1333 wpas_notify_scan_done(wpa_s, 1);
1335 if (!wpa_s->own_scan_running && wpa_s->external_scan_running) {
1336 wpa_dbg(wpa_s, MSG_DEBUG, "Do not use results from externally requested scan operation for network selection");
1337 wpa_scan_results_free(scan_res);
1341 if (sme_proc_obss_scan(wpa_s) > 0)
1342 goto scan_work_done;
1344 if ((wpa_s->conf->ap_scan == 2 && !wpas_wps_searching(wpa_s)))
1345 goto scan_work_done;
1347 if (autoscan_notify_scan(wpa_s, scan_res))
1348 goto scan_work_done;
1350 if (wpa_s->disconnected) {
1351 wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
1352 goto scan_work_done;
1355 if (!wpas_driver_bss_selection(wpa_s) &&
1356 bgscan_notify_scan(wpa_s, scan_res) == 1)
1357 goto scan_work_done;
1359 wpas_wps_update_ap_info(wpa_s, scan_res);
1361 wpa_scan_results_free(scan_res);
1363 if (wpa_s->scan_work) {
1364 struct wpa_radio_work *work = wpa_s->scan_work;
1365 wpa_s->scan_work = NULL;
1366 radio_work_done(work);
1369 return wpas_select_network_from_last_scan(wpa_s, 1, own_request);
1372 wpa_scan_results_free(scan_res);
1373 if (wpa_s->scan_work) {
1374 struct wpa_radio_work *work = wpa_s->scan_work;
1375 wpa_s->scan_work = NULL;
1376 radio_work_done(work);
1382 static int wpas_select_network_from_last_scan(struct wpa_supplicant *wpa_s,
1383 int new_scan, int own_request)
1385 struct wpa_bss *selected;
1386 struct wpa_ssid *ssid = NULL;
1388 selected = wpa_supplicant_pick_network(wpa_s, &ssid);
1392 skip = !wpa_supplicant_need_to_roam(wpa_s, selected, ssid);
1395 wpa_supplicant_rsn_preauth_scan_results(wpa_s);
1399 if (wpa_supplicant_connect(wpa_s, selected, ssid) < 0) {
1400 wpa_dbg(wpa_s, MSG_DEBUG, "Connect failed");
1404 wpa_supplicant_rsn_preauth_scan_results(wpa_s);
1406 * Do not notify other virtual radios of scan results since we do not
1407 * want them to start other associations at the same time.
1411 wpa_dbg(wpa_s, MSG_DEBUG, "No suitable network found");
1412 ssid = wpa_supplicant_pick_new_network(wpa_s);
1414 wpa_dbg(wpa_s, MSG_DEBUG, "Setup a new network");
1415 wpa_supplicant_associate(wpa_s, NULL, ssid);
1417 wpa_supplicant_rsn_preauth_scan_results(wpa_s);
1418 } else if (own_request) {
1420 * No SSID found. If SCAN results are as a result of
1421 * own scan request and not due to a scan request on
1422 * another shared interface, try another scan.
1424 int timeout_sec = wpa_s->scan_interval;
1425 int timeout_usec = 0;
1427 if (wpas_p2p_scan_no_go_seen(wpa_s) == 1)
1430 if (wpa_s->p2p_in_provisioning ||
1431 wpa_s->show_group_started ||
1432 wpa_s->p2p_in_invitation) {
1434 * Use shorter wait during P2P Provisioning
1435 * state and during P2P join-a-group operation
1436 * to speed up group formation.
1439 timeout_usec = 250000;
1440 wpa_supplicant_req_new_scan(wpa_s, timeout_sec,
1444 #endif /* CONFIG_P2P */
1445 #ifdef CONFIG_INTERWORKING
1446 if (wpa_s->conf->auto_interworking &&
1447 wpa_s->conf->interworking &&
1448 wpa_s->conf->cred) {
1449 wpa_dbg(wpa_s, MSG_DEBUG, "Interworking: "
1450 "start ANQP fetch since no matching "
1452 wpa_s->network_select = 1;
1453 wpa_s->auto_network_select = 1;
1454 interworking_start_fetch_anqp(wpa_s);
1457 #endif /* CONFIG_INTERWORKING */
1459 if (wpa_s->after_wps > 0 || wpas_wps_searching(wpa_s)) {
1460 wpa_dbg(wpa_s, MSG_DEBUG, "Use shorter wait during WPS processing");
1462 timeout_usec = 500000;
1463 wpa_supplicant_req_new_scan(wpa_s, timeout_sec,
1467 #endif /* CONFIG_WPS */
1468 if (wpa_supplicant_req_sched_scan(wpa_s))
1469 wpa_supplicant_req_new_scan(wpa_s, timeout_sec,
1477 static void wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s,
1478 union wpa_event_data *data)
1480 struct wpa_supplicant *ifs;
1482 if (_wpa_supplicant_event_scan_results(wpa_s, data, 1) != 0) {
1484 * If no scan results could be fetched, then no need to
1485 * notify those interfaces that did not actually request
1486 * this scan. Similarly, if scan results started a new operation on this
1487 * interface, do not notify other interfaces to avoid concurrent
1488 * operations during a connection attempt.
1494 * Check other interfaces to see if they share the same radio. If
1495 * so, they get updated with this same scan info.
1497 dl_list_for_each(ifs, &wpa_s->radio->ifaces, struct wpa_supplicant,
1500 wpa_printf(MSG_DEBUG, "%s: Updating scan results from "
1501 "sibling", ifs->ifname);
1502 _wpa_supplicant_event_scan_results(ifs, data, 0);
1507 #endif /* CONFIG_NO_SCAN_PROCESSING */
1510 int wpa_supplicant_fast_associate(struct wpa_supplicant *wpa_s)
1512 #ifdef CONFIG_NO_SCAN_PROCESSING
1514 #else /* CONFIG_NO_SCAN_PROCESSING */
1515 struct os_reltime now;
1517 if (wpa_s->last_scan_res_used <= 0)
1520 os_get_reltime(&now);
1521 if (os_reltime_expired(&now, &wpa_s->last_scan, 5)) {
1522 wpa_printf(MSG_DEBUG, "Fast associate: Old scan results");
1526 return wpas_select_network_from_last_scan(wpa_s, 0, 1);
1527 #endif /* CONFIG_NO_SCAN_PROCESSING */
1532 static void wnm_bss_keep_alive(void *eloop_ctx, void *sock_ctx)
1534 struct wpa_supplicant *wpa_s = eloop_ctx;
1536 if (wpa_s->wpa_state < WPA_ASSOCIATED)
1539 if (!wpa_s->no_keep_alive) {
1540 wpa_printf(MSG_DEBUG, "WNM: Send keep-alive to AP " MACSTR,
1541 MAC2STR(wpa_s->bssid));
1542 /* TODO: could skip this if normal data traffic has been sent */
1543 /* TODO: Consider using some more appropriate data frame for
1546 l2_packet_send(wpa_s->l2, wpa_s->bssid, 0x0800,
1551 if (wpa_s->sme.bss_max_idle_period) {
1553 msec = wpa_s->sme.bss_max_idle_period * 1024; /* times 1000 */
1556 eloop_register_timeout(msec / 1000, msec % 1000 * 1000,
1557 wnm_bss_keep_alive, wpa_s, NULL);
1559 #endif /* CONFIG_SME */
1563 static void wnm_process_assoc_resp(struct wpa_supplicant *wpa_s,
1564 const u8 *ies, size_t ies_len)
1566 struct ieee802_11_elems elems;
1571 if (ieee802_11_parse_elems(ies, ies_len, &elems, 1) == ParseFailed)
1575 if (elems.bss_max_idle_period) {
1577 wpa_s->sme.bss_max_idle_period =
1578 WPA_GET_LE16(elems.bss_max_idle_period);
1579 wpa_printf(MSG_DEBUG, "WNM: BSS Max Idle Period: %u (* 1000 "
1580 "TU)%s", wpa_s->sme.bss_max_idle_period,
1581 (elems.bss_max_idle_period[2] & 0x01) ?
1582 " (protected keep-live required)" : "");
1583 if (wpa_s->sme.bss_max_idle_period == 0)
1584 wpa_s->sme.bss_max_idle_period = 1;
1585 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME) {
1586 eloop_cancel_timeout(wnm_bss_keep_alive, wpa_s, NULL);
1587 /* msec times 1000 */
1588 msec = wpa_s->sme.bss_max_idle_period * 1024;
1591 eloop_register_timeout(msec / 1000, msec % 1000 * 1000,
1592 wnm_bss_keep_alive, wpa_s,
1596 #endif /* CONFIG_SME */
1599 #endif /* CONFIG_WNM */
1602 void wnm_bss_keep_alive_deinit(struct wpa_supplicant *wpa_s)
1605 eloop_cancel_timeout(wnm_bss_keep_alive, wpa_s, NULL);
1606 #endif /* CONFIG_WNM */
1610 #ifdef CONFIG_INTERWORKING
1612 static int wpas_qos_map_set(struct wpa_supplicant *wpa_s, const u8 *qos_map,
1617 wpa_hexdump(MSG_DEBUG, "Interworking: QoS Map Set", qos_map, len);
1618 res = wpa_drv_set_qos_map(wpa_s, qos_map, len);
1620 wpa_printf(MSG_DEBUG, "Interworking: Failed to configure QoS Map Set to the driver");
1627 static void interworking_process_assoc_resp(struct wpa_supplicant *wpa_s,
1628 const u8 *ies, size_t ies_len)
1630 struct ieee802_11_elems elems;
1635 if (ieee802_11_parse_elems(ies, ies_len, &elems, 1) == ParseFailed)
1638 if (elems.qos_map_set) {
1639 wpas_qos_map_set(wpa_s, elems.qos_map_set,
1640 elems.qos_map_set_len);
1644 #endif /* CONFIG_INTERWORKING */
1647 static int wpa_supplicant_event_associnfo(struct wpa_supplicant *wpa_s,
1648 union wpa_event_data *data)
1650 int l, len, found = 0, wpa_found, rsn_found;
1652 #ifdef CONFIG_IEEE80211R
1654 #endif /* CONFIG_IEEE80211R */
1656 wpa_dbg(wpa_s, MSG_DEBUG, "Association info event");
1657 if (data->assoc_info.req_ies)
1658 wpa_hexdump(MSG_DEBUG, "req_ies", data->assoc_info.req_ies,
1659 data->assoc_info.req_ies_len);
1660 if (data->assoc_info.resp_ies) {
1661 wpa_hexdump(MSG_DEBUG, "resp_ies", data->assoc_info.resp_ies,
1662 data->assoc_info.resp_ies_len);
1664 wpa_tdls_assoc_resp_ies(wpa_s->wpa, data->assoc_info.resp_ies,
1665 data->assoc_info.resp_ies_len);
1666 #endif /* CONFIG_TDLS */
1668 wnm_process_assoc_resp(wpa_s, data->assoc_info.resp_ies,
1669 data->assoc_info.resp_ies_len);
1670 #endif /* CONFIG_WNM */
1671 #ifdef CONFIG_INTERWORKING
1672 interworking_process_assoc_resp(wpa_s, data->assoc_info.resp_ies,
1673 data->assoc_info.resp_ies_len);
1674 #endif /* CONFIG_INTERWORKING */
1676 if (data->assoc_info.beacon_ies)
1677 wpa_hexdump(MSG_DEBUG, "beacon_ies",
1678 data->assoc_info.beacon_ies,
1679 data->assoc_info.beacon_ies_len);
1680 if (data->assoc_info.freq)
1681 wpa_dbg(wpa_s, MSG_DEBUG, "freq=%u MHz",
1682 data->assoc_info.freq);
1684 p = data->assoc_info.req_ies;
1685 l = data->assoc_info.req_ies_len;
1687 /* Go through the IEs and make a copy of the WPA/RSN IE, if present. */
1688 while (p && l >= 2) {
1691 wpa_hexdump(MSG_DEBUG, "Truncated IE in assoc_info",
1695 if ((p[0] == WLAN_EID_VENDOR_SPECIFIC && p[1] >= 6 &&
1696 (os_memcmp(&p[2], "\x00\x50\xF2\x01\x01\x00", 6) == 0)) ||
1697 (p[0] == WLAN_EID_RSN && p[1] >= 2)) {
1698 if (wpa_sm_set_assoc_wpa_ie(wpa_s->wpa, p, len))
1701 wpa_find_assoc_pmkid(wpa_s);
1707 if (!found && data->assoc_info.req_ies)
1708 wpa_sm_set_assoc_wpa_ie(wpa_s->wpa, NULL, 0);
1710 #ifdef CONFIG_IEEE80211R
1712 if (wpa_s->sme.auth_alg == WPA_AUTH_ALG_FT) {
1713 if (wpa_drv_get_bssid(wpa_s, bssid) < 0 ||
1714 wpa_ft_validate_reassoc_resp(wpa_s->wpa,
1715 data->assoc_info.resp_ies,
1716 data->assoc_info.resp_ies_len,
1718 wpa_dbg(wpa_s, MSG_DEBUG, "FT: Validation of "
1719 "Reassociation Response failed");
1720 wpa_supplicant_deauthenticate(
1721 wpa_s, WLAN_REASON_INVALID_IE);
1726 p = data->assoc_info.resp_ies;
1727 l = data->assoc_info.resp_ies_len;
1729 #ifdef CONFIG_WPS_STRICT
1730 if (p && wpa_s->current_ssid &&
1731 wpa_s->current_ssid->key_mgmt == WPA_KEY_MGMT_WPS) {
1733 wps = ieee802_11_vendor_ie_concat(p, l, WPS_IE_VENDOR_TYPE);
1735 wpa_msg(wpa_s, MSG_INFO, "WPS-STRICT: AP did not "
1736 "include WPS IE in (Re)Association Response");
1740 if (wps_validate_assoc_resp(wps) < 0) {
1742 wpa_supplicant_deauthenticate(
1743 wpa_s, WLAN_REASON_INVALID_IE);
1748 #endif /* CONFIG_WPS_STRICT */
1750 /* Go through the IEs and make a copy of the MDIE, if present. */
1751 while (p && l >= 2) {
1754 wpa_hexdump(MSG_DEBUG, "Truncated IE in assoc_info",
1758 if (p[0] == WLAN_EID_MOBILITY_DOMAIN &&
1759 p[1] >= MOBILITY_DOMAIN_ID_LEN) {
1760 wpa_s->sme.ft_used = 1;
1761 os_memcpy(wpa_s->sme.mobility_domain, p + 2,
1762 MOBILITY_DOMAIN_ID_LEN);
1768 #endif /* CONFIG_SME */
1770 /* Process FT when SME is in the driver */
1771 if (!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME) &&
1772 wpa_ft_is_completed(wpa_s->wpa)) {
1773 if (wpa_drv_get_bssid(wpa_s, bssid) < 0 ||
1774 wpa_ft_validate_reassoc_resp(wpa_s->wpa,
1775 data->assoc_info.resp_ies,
1776 data->assoc_info.resp_ies_len,
1778 wpa_dbg(wpa_s, MSG_DEBUG, "FT: Validation of "
1779 "Reassociation Response failed");
1780 wpa_supplicant_deauthenticate(
1781 wpa_s, WLAN_REASON_INVALID_IE);
1784 wpa_dbg(wpa_s, MSG_DEBUG, "FT: Reassociation Response done");
1787 wpa_sm_set_ft_params(wpa_s->wpa, data->assoc_info.resp_ies,
1788 data->assoc_info.resp_ies_len);
1789 #endif /* CONFIG_IEEE80211R */
1791 /* WPA/RSN IE from Beacon/ProbeResp */
1792 p = data->assoc_info.beacon_ies;
1793 l = data->assoc_info.beacon_ies_len;
1795 /* Go through the IEs and make a copy of the WPA/RSN IEs, if present.
1797 wpa_found = rsn_found = 0;
1798 while (p && l >= 2) {
1801 wpa_hexdump(MSG_DEBUG, "Truncated IE in beacon_ies",
1806 p[0] == WLAN_EID_VENDOR_SPECIFIC && p[1] >= 6 &&
1807 os_memcmp(&p[2], "\x00\x50\xF2\x01\x01\x00", 6) == 0) {
1809 wpa_sm_set_ap_wpa_ie(wpa_s->wpa, p, len);
1813 p[0] == WLAN_EID_RSN && p[1] >= 2) {
1815 wpa_sm_set_ap_rsn_ie(wpa_s->wpa, p, len);
1822 if (!wpa_found && data->assoc_info.beacon_ies)
1823 wpa_sm_set_ap_wpa_ie(wpa_s->wpa, NULL, 0);
1824 if (!rsn_found && data->assoc_info.beacon_ies)
1825 wpa_sm_set_ap_rsn_ie(wpa_s->wpa, NULL, 0);
1826 if (wpa_found || rsn_found)
1827 wpa_s->ap_ies_from_associnfo = 1;
1829 if (wpa_s->assoc_freq && data->assoc_info.freq &&
1830 wpa_s->assoc_freq != data->assoc_info.freq) {
1831 wpa_printf(MSG_DEBUG, "Operating frequency changed from "
1833 wpa_s->assoc_freq, data->assoc_info.freq);
1834 wpa_supplicant_update_scan_results(wpa_s);
1837 wpa_s->assoc_freq = data->assoc_info.freq;
1843 static int wpa_supplicant_assoc_update_ie(struct wpa_supplicant *wpa_s)
1845 const u8 *bss_wpa = NULL, *bss_rsn = NULL;
1847 if (!wpa_s->current_bss || !wpa_s->current_ssid)
1850 if (!wpa_key_mgmt_wpa_any(wpa_s->current_ssid->key_mgmt))
1853 bss_wpa = wpa_bss_get_vendor_ie(wpa_s->current_bss,
1854 WPA_IE_VENDOR_TYPE);
1855 bss_rsn = wpa_bss_get_ie(wpa_s->current_bss, WLAN_EID_RSN);
1857 if (wpa_sm_set_ap_wpa_ie(wpa_s->wpa, bss_wpa,
1858 bss_wpa ? 2 + bss_wpa[1] : 0) ||
1859 wpa_sm_set_ap_rsn_ie(wpa_s->wpa, bss_rsn,
1860 bss_rsn ? 2 + bss_rsn[1] : 0))
1867 static void wpa_supplicant_event_assoc(struct wpa_supplicant *wpa_s,
1868 union wpa_event_data *data)
1874 if (wpa_s->ap_iface) {
1877 hostapd_notif_assoc(wpa_s->ap_iface->bss[0],
1878 data->assoc_info.addr,
1879 data->assoc_info.req_ies,
1880 data->assoc_info.req_ies_len,
1881 data->assoc_info.reassoc);
1884 #endif /* CONFIG_AP */
1886 ft_completed = wpa_ft_is_completed(wpa_s->wpa);
1887 if (data && wpa_supplicant_event_associnfo(wpa_s, data) < 0)
1890 if (wpa_drv_get_bssid(wpa_s, bssid) < 0) {
1891 wpa_dbg(wpa_s, MSG_ERROR, "Failed to get BSSID");
1892 wpa_supplicant_deauthenticate(
1893 wpa_s, WLAN_REASON_DEAUTH_LEAVING);
1897 wpa_supplicant_set_state(wpa_s, WPA_ASSOCIATED);
1898 if (os_memcmp(bssid, wpa_s->bssid, ETH_ALEN) != 0) {
1899 wpa_dbg(wpa_s, MSG_DEBUG, "Associated to a new BSS: BSSID="
1900 MACSTR, MAC2STR(bssid));
1901 random_add_randomness(bssid, ETH_ALEN);
1902 os_memcpy(wpa_s->bssid, bssid, ETH_ALEN);
1903 os_memset(wpa_s->pending_bssid, 0, ETH_ALEN);
1904 wpas_notify_bssid_changed(wpa_s);
1906 if (wpa_supplicant_dynamic_keys(wpa_s) && !ft_completed) {
1907 wpa_clear_keys(wpa_s, bssid);
1909 if (wpa_supplicant_select_config(wpa_s) < 0) {
1910 wpa_supplicant_deauthenticate(
1911 wpa_s, WLAN_REASON_DEAUTH_LEAVING);
1915 if (wpa_s->conf->ap_scan == 1 &&
1916 wpa_s->drv_flags & WPA_DRIVER_FLAGS_BSS_SELECTION) {
1917 if (wpa_supplicant_assoc_update_ie(wpa_s) < 0)
1918 wpa_msg(wpa_s, MSG_WARNING,
1919 "WPA/RSN IEs not updated");
1924 os_memcpy(wpa_s->sme.prev_bssid, bssid, ETH_ALEN);
1925 wpa_s->sme.prev_bssid_set = 1;
1926 wpa_s->sme.last_unprot_disconnect.sec = 0;
1927 #endif /* CONFIG_SME */
1929 wpa_msg(wpa_s, MSG_INFO, "Associated with " MACSTR, MAC2STR(bssid));
1930 if (wpa_s->current_ssid) {
1931 /* When using scanning (ap_scan=1), SIM PC/SC interface can be
1932 * initialized before association, but for other modes,
1933 * initialize PC/SC here, if the current configuration needs
1934 * smartcard or SIM/USIM. */
1935 wpa_supplicant_scard_init(wpa_s, wpa_s->current_ssid);
1937 wpa_sm_notify_assoc(wpa_s->wpa, bssid);
1939 l2_packet_notify_auth_start(wpa_s->l2);
1942 * Set portEnabled first to FALSE in order to get EAP state machine out
1943 * of the SUCCESS state and eapSuccess cleared. Without this, EAPOL PAE
1944 * state machine may transit to AUTHENTICATING state based on obsolete
1945 * eapSuccess and then trigger BE_AUTH to SUCCESS and PAE to
1946 * AUTHENTICATED without ever giving chance to EAP state machine to
1949 if (!ft_completed) {
1950 eapol_sm_notify_portEnabled(wpa_s->eapol, FALSE);
1951 eapol_sm_notify_portValid(wpa_s->eapol, FALSE);
1953 if (wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt) || ft_completed)
1954 eapol_sm_notify_eap_success(wpa_s->eapol, FALSE);
1955 /* 802.1X::portControl = Auto */
1956 eapol_sm_notify_portEnabled(wpa_s->eapol, TRUE);
1957 wpa_s->eapol_received = 0;
1958 if (wpa_s->key_mgmt == WPA_KEY_MGMT_NONE ||
1959 wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE ||
1960 (wpa_s->current_ssid &&
1961 wpa_s->current_ssid->mode == IEEE80211_MODE_IBSS)) {
1962 if (wpa_s->current_ssid &&
1963 wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE &&
1965 WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC_DONE)) {
1967 * Set the key after having received joined-IBSS event
1970 wpa_supplicant_set_wpa_none_key(wpa_s,
1971 wpa_s->current_ssid);
1973 wpa_supplicant_cancel_auth_timeout(wpa_s);
1974 wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
1975 } else if (!ft_completed) {
1976 /* Timeout for receiving the first EAPOL packet */
1977 wpa_supplicant_req_auth_timeout(wpa_s, 10, 0);
1979 wpa_supplicant_cancel_scan(wpa_s);
1981 if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE) &&
1982 wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt)) {
1984 * We are done; the driver will take care of RSN 4-way
1987 wpa_supplicant_cancel_auth_timeout(wpa_s);
1988 wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
1989 eapol_sm_notify_portValid(wpa_s->eapol, TRUE);
1990 eapol_sm_notify_eap_success(wpa_s->eapol, TRUE);
1991 } else if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE) &&
1992 wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt)) {
1994 * The driver will take care of RSN 4-way handshake, so we need
1995 * to allow EAPOL supplicant to complete its work without
1996 * waiting for WPA supplicant.
1998 eapol_sm_notify_portValid(wpa_s->eapol, TRUE);
1999 } else if (ft_completed) {
2001 * FT protocol completed - make sure EAPOL state machine ends
2002 * up in authenticated.
2004 wpa_supplicant_cancel_auth_timeout(wpa_s);
2005 wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
2006 eapol_sm_notify_portValid(wpa_s->eapol, TRUE);
2007 eapol_sm_notify_eap_success(wpa_s->eapol, TRUE);
2010 wpa_s->last_eapol_matches_bssid = 0;
2012 if (wpa_s->pending_eapol_rx) {
2013 struct os_reltime now, age;
2014 os_get_reltime(&now);
2015 os_reltime_sub(&now, &wpa_s->pending_eapol_rx_time, &age);
2016 if (age.sec == 0 && age.usec < 100000 &&
2017 os_memcmp(wpa_s->pending_eapol_rx_src, bssid, ETH_ALEN) ==
2019 wpa_dbg(wpa_s, MSG_DEBUG, "Process pending EAPOL "
2020 "frame that was received just before "
2021 "association notification");
2022 wpa_supplicant_rx_eapol(
2023 wpa_s, wpa_s->pending_eapol_rx_src,
2024 wpabuf_head(wpa_s->pending_eapol_rx),
2025 wpabuf_len(wpa_s->pending_eapol_rx));
2027 wpabuf_free(wpa_s->pending_eapol_rx);
2028 wpa_s->pending_eapol_rx = NULL;
2031 if ((wpa_s->key_mgmt == WPA_KEY_MGMT_NONE ||
2032 wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA) &&
2033 wpa_s->current_ssid &&
2034 (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC_DONE)) {
2035 /* Set static WEP keys again */
2036 wpa_set_wep_keys(wpa_s, wpa_s->current_ssid);
2039 #ifdef CONFIG_IBSS_RSN
2040 if (wpa_s->current_ssid &&
2041 wpa_s->current_ssid->mode == WPAS_MODE_IBSS &&
2042 wpa_s->key_mgmt != WPA_KEY_MGMT_NONE &&
2043 wpa_s->key_mgmt != WPA_KEY_MGMT_WPA_NONE &&
2044 wpa_s->ibss_rsn == NULL) {
2045 wpa_s->ibss_rsn = ibss_rsn_init(wpa_s);
2046 if (!wpa_s->ibss_rsn) {
2047 wpa_msg(wpa_s, MSG_INFO, "Failed to init IBSS RSN");
2048 wpa_supplicant_deauthenticate(
2049 wpa_s, WLAN_REASON_DEAUTH_LEAVING);
2053 ibss_rsn_set_psk(wpa_s->ibss_rsn, wpa_s->current_ssid->psk);
2055 #endif /* CONFIG_IBSS_RSN */
2057 wpas_wps_notify_assoc(wpa_s, bssid);
2061 static int disconnect_reason_recoverable(u16 reason_code)
2063 return reason_code == WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY ||
2064 reason_code == WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA ||
2065 reason_code == WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA;
2069 static void wpa_supplicant_event_disassoc(struct wpa_supplicant *wpa_s,
2071 int locally_generated)
2075 if (wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE) {
2077 * At least Host AP driver and a Prism3 card seemed to be
2078 * generating streams of disconnected events when configuring
2079 * IBSS for WPA-None. Ignore them for now.
2084 bssid = wpa_s->bssid;
2085 if (is_zero_ether_addr(bssid))
2086 bssid = wpa_s->pending_bssid;
2088 if (!is_zero_ether_addr(bssid) ||
2089 wpa_s->wpa_state >= WPA_AUTHENTICATING) {
2090 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_DISCONNECTED "bssid=" MACSTR
2092 MAC2STR(bssid), reason_code,
2093 locally_generated ? " locally_generated=1" : "");
2098 static int could_be_psk_mismatch(struct wpa_supplicant *wpa_s, u16 reason_code,
2099 int locally_generated)
2101 if (wpa_s->wpa_state != WPA_4WAY_HANDSHAKE ||
2102 !wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt))
2103 return 0; /* Not in 4-way handshake with PSK */
2106 * It looks like connection was lost while trying to go through PSK
2107 * 4-way handshake. Filter out known disconnection cases that are caused
2108 * by something else than PSK mismatch to avoid confusing reports.
2111 if (locally_generated) {
2112 if (reason_code == WLAN_REASON_IE_IN_4WAY_DIFFERS)
2120 static void wpa_supplicant_event_disassoc_finish(struct wpa_supplicant *wpa_s,
2122 int locally_generated)
2126 u8 prev_pending_bssid[ETH_ALEN];
2127 struct wpa_bss *fast_reconnect = NULL;
2128 struct wpa_ssid *fast_reconnect_ssid = NULL;
2129 struct wpa_ssid *last_ssid;
2131 authenticating = wpa_s->wpa_state == WPA_AUTHENTICATING;
2132 os_memcpy(prev_pending_bssid, wpa_s->pending_bssid, ETH_ALEN);
2134 if (wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE) {
2136 * At least Host AP driver and a Prism3 card seemed to be
2137 * generating streams of disconnected events when configuring
2138 * IBSS for WPA-None. Ignore them for now.
2140 wpa_dbg(wpa_s, MSG_DEBUG, "Disconnect event - ignore in "
2141 "IBSS/WPA-None mode");
2145 if (could_be_psk_mismatch(wpa_s, reason_code, locally_generated)) {
2146 wpa_msg(wpa_s, MSG_INFO, "WPA: 4-Way Handshake failed - "
2147 "pre-shared key may be incorrect");
2148 if (wpas_p2p_4way_hs_failed(wpa_s) > 0)
2149 return; /* P2P group removed */
2150 wpas_auth_failed(wpa_s, "WRONG_KEY");
2152 if (!wpa_s->disconnected &&
2153 (!wpa_s->auto_reconnect_disabled ||
2154 wpa_s->key_mgmt == WPA_KEY_MGMT_WPS)) {
2155 wpa_dbg(wpa_s, MSG_DEBUG, "Auto connect enabled: try to "
2156 "reconnect (wps=%d wpa_state=%d)",
2157 wpa_s->key_mgmt == WPA_KEY_MGMT_WPS,
2159 if (wpa_s->wpa_state == WPA_COMPLETED &&
2160 wpa_s->current_ssid &&
2161 wpa_s->current_ssid->mode == WPAS_MODE_INFRA &&
2162 !locally_generated &&
2163 disconnect_reason_recoverable(reason_code)) {
2165 * It looks like the AP has dropped association with
2166 * us, but could allow us to get back in. Try to
2167 * reconnect to the same BSS without full scan to save
2168 * time for some common cases.
2170 fast_reconnect = wpa_s->current_bss;
2171 fast_reconnect_ssid = wpa_s->current_ssid;
2172 } else if (wpa_s->wpa_state >= WPA_ASSOCIATING)
2173 wpa_supplicant_req_scan(wpa_s, 0, 100000);
2175 wpa_dbg(wpa_s, MSG_DEBUG, "Do not request new "
2178 wpa_dbg(wpa_s, MSG_DEBUG, "Auto connect disabled: do not "
2179 "try to re-connect");
2180 wpa_s->reassociate = 0;
2181 wpa_s->disconnected = 1;
2182 wpa_supplicant_cancel_sched_scan(wpa_s);
2184 bssid = wpa_s->bssid;
2185 if (is_zero_ether_addr(bssid))
2186 bssid = wpa_s->pending_bssid;
2187 if (wpa_s->wpa_state >= WPA_AUTHENTICATING)
2188 wpas_connection_failed(wpa_s, bssid);
2189 wpa_sm_notify_disassoc(wpa_s->wpa);
2190 if (locally_generated)
2191 wpa_s->disconnect_reason = -reason_code;
2193 wpa_s->disconnect_reason = reason_code;
2194 wpas_notify_disconnect_reason(wpa_s);
2195 if (wpa_supplicant_dynamic_keys(wpa_s)) {
2196 wpa_dbg(wpa_s, MSG_DEBUG, "Disconnect event - remove keys");
2197 wpa_clear_keys(wpa_s, wpa_s->bssid);
2199 last_ssid = wpa_s->current_ssid;
2200 wpa_supplicant_mark_disassoc(wpa_s);
2202 if (authenticating && (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)) {
2203 sme_disassoc_while_authenticating(wpa_s, prev_pending_bssid);
2204 wpa_s->current_ssid = last_ssid;
2207 if (fast_reconnect &&
2208 !wpas_network_disabled(wpa_s, fast_reconnect_ssid) &&
2209 !disallowed_bssid(wpa_s, fast_reconnect->bssid) &&
2210 !disallowed_ssid(wpa_s, fast_reconnect->ssid,
2211 fast_reconnect->ssid_len) &&
2212 !wpas_temp_disabled(wpa_s, fast_reconnect_ssid)) {
2213 #ifndef CONFIG_NO_SCAN_PROCESSING
2214 wpa_dbg(wpa_s, MSG_DEBUG, "Try to reconnect to the same BSS");
2215 if (wpa_supplicant_connect(wpa_s, fast_reconnect,
2216 fast_reconnect_ssid) < 0) {
2217 /* Recover through full scan */
2218 wpa_supplicant_req_scan(wpa_s, 0, 100000);
2220 #endif /* CONFIG_NO_SCAN_PROCESSING */
2221 } else if (fast_reconnect) {
2223 * Could not reconnect to the same BSS due to network being
2224 * disabled. Use a new scan to match the alternative behavior
2225 * above, i.e., to continue automatic reconnection attempt in a
2226 * way that enforces disabled network rules.
2228 wpa_supplicant_req_scan(wpa_s, 0, 100000);
2233 #ifdef CONFIG_DELAYED_MIC_ERROR_REPORT
2234 void wpa_supplicant_delayed_mic_error_report(void *eloop_ctx, void *sock_ctx)
2236 struct wpa_supplicant *wpa_s = eloop_ctx;
2238 if (!wpa_s->pending_mic_error_report)
2241 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: Sending pending MIC error report");
2242 wpa_sm_key_request(wpa_s->wpa, 1, wpa_s->pending_mic_error_pairwise);
2243 wpa_s->pending_mic_error_report = 0;
2245 #endif /* CONFIG_DELAYED_MIC_ERROR_REPORT */
2249 wpa_supplicant_event_michael_mic_failure(struct wpa_supplicant *wpa_s,
2250 union wpa_event_data *data)
2253 struct os_reltime t;
2255 wpa_msg(wpa_s, MSG_WARNING, "Michael MIC failure detected");
2256 pairwise = (data && data->michael_mic_failure.unicast);
2258 if ((wpa_s->last_michael_mic_error.sec &&
2259 !os_reltime_expired(&t, &wpa_s->last_michael_mic_error, 60)) ||
2260 wpa_s->pending_mic_error_report) {
2261 if (wpa_s->pending_mic_error_report) {
2263 * Send the pending MIC error report immediately since
2264 * we are going to start countermeasures and AP better
2267 wpa_sm_key_request(wpa_s->wpa, 1,
2268 wpa_s->pending_mic_error_pairwise);
2271 /* Send the new MIC error report immediately since we are going
2272 * to start countermeasures and AP better do the same.
2274 wpa_sm_key_request(wpa_s->wpa, 1, pairwise);
2276 /* initialize countermeasures */
2277 wpa_s->countermeasures = 1;
2279 wpa_blacklist_add(wpa_s, wpa_s->bssid);
2281 wpa_msg(wpa_s, MSG_WARNING, "TKIP countermeasures started");
2284 * Need to wait for completion of request frame. We do not get
2285 * any callback for the message completion, so just wait a
2286 * short while and hope for the best. */
2289 wpa_drv_set_countermeasures(wpa_s, 1);
2290 wpa_supplicant_deauthenticate(wpa_s,
2291 WLAN_REASON_MICHAEL_MIC_FAILURE);
2292 eloop_cancel_timeout(wpa_supplicant_stop_countermeasures,
2294 eloop_register_timeout(60, 0,
2295 wpa_supplicant_stop_countermeasures,
2297 /* TODO: mark the AP rejected for 60 second. STA is
2298 * allowed to associate with another AP.. */
2300 #ifdef CONFIG_DELAYED_MIC_ERROR_REPORT
2301 if (wpa_s->mic_errors_seen) {
2303 * Reduce the effectiveness of Michael MIC error
2304 * reports as a means for attacking against TKIP if
2305 * more than one MIC failure is noticed with the same
2306 * PTK. We delay the transmission of the reports by a
2307 * random time between 0 and 60 seconds in order to
2308 * force the attacker wait 60 seconds before getting
2309 * the information on whether a frame resulted in a MIC
2315 if (os_get_random(rval, sizeof(rval)) < 0)
2316 sec = os_random() % 60;
2318 sec = WPA_GET_BE32(rval) % 60;
2319 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: Delay MIC error "
2320 "report %d seconds", sec);
2321 wpa_s->pending_mic_error_report = 1;
2322 wpa_s->pending_mic_error_pairwise = pairwise;
2323 eloop_cancel_timeout(
2324 wpa_supplicant_delayed_mic_error_report,
2326 eloop_register_timeout(
2327 sec, os_random() % 1000000,
2328 wpa_supplicant_delayed_mic_error_report,
2331 wpa_sm_key_request(wpa_s->wpa, 1, pairwise);
2333 #else /* CONFIG_DELAYED_MIC_ERROR_REPORT */
2334 wpa_sm_key_request(wpa_s->wpa, 1, pairwise);
2335 #endif /* CONFIG_DELAYED_MIC_ERROR_REPORT */
2337 wpa_s->last_michael_mic_error = t;
2338 wpa_s->mic_errors_seen++;
2342 #ifdef CONFIG_TERMINATE_ONLASTIF
2343 static int any_interfaces(struct wpa_supplicant *head)
2345 struct wpa_supplicant *wpa_s;
2347 for (wpa_s = head; wpa_s != NULL; wpa_s = wpa_s->next)
2348 if (!wpa_s->interface_removed)
2352 #endif /* CONFIG_TERMINATE_ONLASTIF */
2356 wpa_supplicant_event_interface_status(struct wpa_supplicant *wpa_s,
2357 union wpa_event_data *data)
2359 if (os_strcmp(wpa_s->ifname, data->interface_status.ifname) != 0)
2362 switch (data->interface_status.ievent) {
2363 case EVENT_INTERFACE_ADDED:
2364 if (!wpa_s->interface_removed)
2366 wpa_s->interface_removed = 0;
2367 wpa_dbg(wpa_s, MSG_DEBUG, "Configured interface was added");
2368 if (wpa_supplicant_driver_init(wpa_s) < 0) {
2369 wpa_msg(wpa_s, MSG_INFO, "Failed to initialize the "
2370 "driver after interface was added");
2373 case EVENT_INTERFACE_REMOVED:
2374 wpa_dbg(wpa_s, MSG_DEBUG, "Configured interface was removed");
2375 wpa_s->interface_removed = 1;
2376 wpa_supplicant_mark_disassoc(wpa_s);
2377 wpa_supplicant_set_state(wpa_s, WPA_INTERFACE_DISABLED);
2378 l2_packet_deinit(wpa_s->l2);
2380 #ifdef CONFIG_TERMINATE_ONLASTIF
2381 /* check if last interface */
2382 if (!any_interfaces(wpa_s->global->ifaces))
2384 #endif /* CONFIG_TERMINATE_ONLASTIF */
2390 #ifdef CONFIG_PEERKEY
2392 wpa_supplicant_event_stkstart(struct wpa_supplicant *wpa_s,
2393 union wpa_event_data *data)
2397 wpa_sm_stkstart(wpa_s->wpa, data->stkstart.peer);
2399 #endif /* CONFIG_PEERKEY */
2403 static void wpa_supplicant_event_tdls(struct wpa_supplicant *wpa_s,
2404 union wpa_event_data *data)
2408 switch (data->tdls.oper) {
2409 case TDLS_REQUEST_SETUP:
2410 wpa_tdls_remove(wpa_s->wpa, data->tdls.peer);
2411 if (wpa_tdls_is_external_setup(wpa_s->wpa))
2412 wpa_tdls_start(wpa_s->wpa, data->tdls.peer);
2414 wpa_drv_tdls_oper(wpa_s, TDLS_SETUP, data->tdls.peer);
2416 case TDLS_REQUEST_TEARDOWN:
2417 if (wpa_tdls_is_external_setup(wpa_s->wpa))
2418 wpa_tdls_teardown_link(wpa_s->wpa, data->tdls.peer,
2419 data->tdls.reason_code);
2421 wpa_drv_tdls_oper(wpa_s, TDLS_TEARDOWN,
2426 #endif /* CONFIG_TDLS */
2430 static void wpa_supplicant_event_wnm(struct wpa_supplicant *wpa_s,
2431 union wpa_event_data *data)
2435 switch (data->wnm.oper) {
2436 case WNM_OPER_SLEEP:
2437 wpa_printf(MSG_DEBUG, "Start sending WNM-Sleep Request "
2438 "(action=%d, intval=%d)",
2439 data->wnm.sleep_action, data->wnm.sleep_intval);
2440 ieee802_11_send_wnmsleep_req(wpa_s, data->wnm.sleep_action,
2441 data->wnm.sleep_intval, NULL);
2445 #endif /* CONFIG_WNM */
2448 #ifdef CONFIG_IEEE80211R
2450 wpa_supplicant_event_ft_response(struct wpa_supplicant *wpa_s,
2451 union wpa_event_data *data)
2456 if (wpa_ft_process_response(wpa_s->wpa, data->ft_ies.ies,
2457 data->ft_ies.ies_len,
2458 data->ft_ies.ft_action,
2459 data->ft_ies.target_ap,
2460 data->ft_ies.ric_ies,
2461 data->ft_ies.ric_ies_len) < 0) {
2462 /* TODO: prevent MLME/driver from trying to associate? */
2465 #endif /* CONFIG_IEEE80211R */
2468 #ifdef CONFIG_IBSS_RSN
2469 static void wpa_supplicant_event_ibss_rsn_start(struct wpa_supplicant *wpa_s,
2470 union wpa_event_data *data)
2472 struct wpa_ssid *ssid;
2473 if (wpa_s->wpa_state < WPA_ASSOCIATED)
2477 ssid = wpa_s->current_ssid;
2480 if (ssid->mode != WPAS_MODE_IBSS || !wpa_key_mgmt_wpa(ssid->key_mgmt))
2483 ibss_rsn_start(wpa_s->ibss_rsn, data->ibss_rsn_start.peer);
2487 static void wpa_supplicant_event_ibss_auth(struct wpa_supplicant *wpa_s,
2488 union wpa_event_data *data)
2490 struct wpa_ssid *ssid = wpa_s->current_ssid;
2495 /* check if the ssid is correctly configured as IBSS/RSN */
2496 if (ssid->mode != WPAS_MODE_IBSS || !wpa_key_mgmt_wpa(ssid->key_mgmt))
2499 ibss_rsn_handle_auth(wpa_s->ibss_rsn, data->rx_mgmt.frame,
2500 data->rx_mgmt.frame_len);
2502 #endif /* CONFIG_IBSS_RSN */
2505 #ifdef CONFIG_IEEE80211R
2506 static void ft_rx_action(struct wpa_supplicant *wpa_s, const u8 *data,
2509 const u8 *sta_addr, *target_ap_addr;
2512 wpa_hexdump(MSG_MSGDUMP, "FT: RX Action", data, len);
2513 if (!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME))
2514 return; /* only SME case supported for now */
2515 if (len < 1 + 2 * ETH_ALEN + 2)
2518 return; /* Only FT Action Response is supported for now */
2519 sta_addr = data + 1;
2520 target_ap_addr = data + 1 + ETH_ALEN;
2521 status = WPA_GET_LE16(data + 1 + 2 * ETH_ALEN);
2522 wpa_dbg(wpa_s, MSG_DEBUG, "FT: Received FT Action Response: STA "
2523 MACSTR " TargetAP " MACSTR " status %u",
2524 MAC2STR(sta_addr), MAC2STR(target_ap_addr), status);
2526 if (os_memcmp(sta_addr, wpa_s->own_addr, ETH_ALEN) != 0) {
2527 wpa_dbg(wpa_s, MSG_DEBUG, "FT: Foreign STA Address " MACSTR
2528 " in FT Action Response", MAC2STR(sta_addr));
2533 wpa_dbg(wpa_s, MSG_DEBUG, "FT: FT Action Response indicates "
2534 "failure (status code %d)", status);
2535 /* TODO: report error to FT code(?) */
2539 if (wpa_ft_process_response(wpa_s->wpa, data + 1 + 2 * ETH_ALEN + 2,
2540 len - (1 + 2 * ETH_ALEN + 2), 1,
2541 target_ap_addr, NULL, 0) < 0)
2546 struct wpa_bss *bss;
2547 bss = wpa_bss_get_bssid(wpa_s, target_ap_addr);
2549 wpa_s->sme.freq = bss->freq;
2550 wpa_s->sme.auth_alg = WPA_AUTH_ALG_FT;
2551 sme_associate(wpa_s, WPAS_MODE_INFRA, target_ap_addr,
2554 #endif /* CONFIG_SME */
2556 #endif /* CONFIG_IEEE80211R */
2559 static void wpa_supplicant_event_unprot_deauth(struct wpa_supplicant *wpa_s,
2560 struct unprot_deauth *e)
2562 #ifdef CONFIG_IEEE80211W
2563 wpa_printf(MSG_DEBUG, "Unprotected Deauthentication frame "
2564 "dropped: " MACSTR " -> " MACSTR
2565 " (reason code %u)",
2566 MAC2STR(e->sa), MAC2STR(e->da), e->reason_code);
2567 sme_event_unprot_disconnect(wpa_s, e->sa, e->da, e->reason_code);
2568 #endif /* CONFIG_IEEE80211W */
2572 static void wpa_supplicant_event_unprot_disassoc(struct wpa_supplicant *wpa_s,
2573 struct unprot_disassoc *e)
2575 #ifdef CONFIG_IEEE80211W
2576 wpa_printf(MSG_DEBUG, "Unprotected Disassociation frame "
2577 "dropped: " MACSTR " -> " MACSTR
2578 " (reason code %u)",
2579 MAC2STR(e->sa), MAC2STR(e->da), e->reason_code);
2580 sme_event_unprot_disconnect(wpa_s, e->sa, e->da, e->reason_code);
2581 #endif /* CONFIG_IEEE80211W */
2585 static void wpas_event_disconnect(struct wpa_supplicant *wpa_s, const u8 *addr,
2586 u16 reason_code, int locally_generated,
2587 const u8 *ie, size_t ie_len, int deauth)
2590 if (wpa_s->ap_iface && addr) {
2591 hostapd_notif_disassoc(wpa_s->ap_iface->bss[0], addr);
2595 if (wpa_s->ap_iface) {
2596 wpa_dbg(wpa_s, MSG_DEBUG, "Ignore deauth event in AP mode");
2599 #endif /* CONFIG_AP */
2601 wpa_supplicant_event_disassoc(wpa_s, reason_code, locally_generated);
2603 if (((reason_code == WLAN_REASON_IEEE_802_1X_AUTH_FAILED ||
2604 ((wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt) ||
2605 (wpa_s->key_mgmt & WPA_KEY_MGMT_IEEE8021X_NO_WPA)) &&
2606 eapol_sm_failed(wpa_s->eapol))) &&
2607 !wpa_s->eap_expected_failure))
2608 wpas_auth_failed(wpa_s, "AUTH_FAILED");
2611 if (deauth && reason_code > 0) {
2612 if (wpas_p2p_deauth_notif(wpa_s, addr, reason_code, ie, ie_len,
2613 locally_generated) > 0) {
2615 * The interface was removed, so cannot continue
2616 * processing any additional operations after this.
2621 #endif /* CONFIG_P2P */
2623 wpa_supplicant_event_disassoc_finish(wpa_s, reason_code,
2628 static void wpas_event_disassoc(struct wpa_supplicant *wpa_s,
2629 struct disassoc_info *info)
2631 u16 reason_code = 0;
2632 int locally_generated = 0;
2633 const u8 *addr = NULL;
2634 const u8 *ie = NULL;
2637 wpa_dbg(wpa_s, MSG_DEBUG, "Disassociation notification");
2642 ie_len = info->ie_len;
2643 reason_code = info->reason_code;
2644 locally_generated = info->locally_generated;
2645 wpa_dbg(wpa_s, MSG_DEBUG, " * reason %u%s", reason_code,
2646 locally_generated ? " (locally generated)" : "");
2648 wpa_dbg(wpa_s, MSG_DEBUG, " * address " MACSTR,
2650 wpa_hexdump(MSG_DEBUG, "Disassociation frame IE(s)",
2655 if (wpa_s->ap_iface && info && info->addr) {
2656 hostapd_notif_disassoc(wpa_s->ap_iface->bss[0], info->addr);
2660 if (wpa_s->ap_iface) {
2661 wpa_dbg(wpa_s, MSG_DEBUG, "Ignore disassoc event in AP mode");
2664 #endif /* CONFIG_AP */
2668 wpas_p2p_disassoc_notif(
2669 wpa_s, info->addr, reason_code, info->ie, info->ie_len,
2672 #endif /* CONFIG_P2P */
2674 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
2675 sme_event_disassoc(wpa_s, info);
2677 wpas_event_disconnect(wpa_s, addr, reason_code, locally_generated,
2682 static void wpas_event_deauth(struct wpa_supplicant *wpa_s,
2683 struct deauth_info *info)
2685 u16 reason_code = 0;
2686 int locally_generated = 0;
2687 const u8 *addr = NULL;
2688 const u8 *ie = NULL;
2691 wpa_dbg(wpa_s, MSG_DEBUG, "Deauthentication notification");
2696 ie_len = info->ie_len;
2697 reason_code = info->reason_code;
2698 locally_generated = info->locally_generated;
2699 wpa_dbg(wpa_s, MSG_DEBUG, " * reason %u%s",
2701 locally_generated ? " (locally generated)" : "");
2703 wpa_dbg(wpa_s, MSG_DEBUG, " * address " MACSTR,
2706 wpa_hexdump(MSG_DEBUG, "Deauthentication frame IE(s)",
2710 wpa_reset_ft_completed(wpa_s->wpa);
2712 wpas_event_disconnect(wpa_s, addr, reason_code,
2713 locally_generated, ie, ie_len, 1);
2717 static const char * reg_init_str(enum reg_change_initiator init)
2720 case REGDOM_SET_BY_CORE:
2722 case REGDOM_SET_BY_USER:
2724 case REGDOM_SET_BY_DRIVER:
2726 case REGDOM_SET_BY_COUNTRY_IE:
2727 return "COUNTRY_IE";
2728 case REGDOM_BEACON_HINT:
2729 return "BEACON_HINT";
2735 static const char * reg_type_str(enum reg_type type)
2738 case REGDOM_TYPE_UNKNOWN:
2740 case REGDOM_TYPE_COUNTRY:
2742 case REGDOM_TYPE_WORLD:
2744 case REGDOM_TYPE_CUSTOM_WORLD:
2745 return "CUSTOM_WORLD";
2746 case REGDOM_TYPE_INTERSECTION:
2747 return "INTERSECTION";
2753 static void wpa_supplicant_update_channel_list(
2754 struct wpa_supplicant *wpa_s, struct channel_list_changed *info)
2756 struct wpa_supplicant *ifs;
2758 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_REGDOM_CHANGE "init=%s type=%s%s%s",
2759 reg_init_str(info->type), reg_type_str(info->type),
2760 info->alpha2[0] ? " alpha2=" : "",
2761 info->alpha2[0] ? info->alpha2 : "");
2763 if (wpa_s->drv_priv == NULL)
2764 return; /* Ignore event during drv initialization */
2766 free_hw_features(wpa_s);
2767 wpa_s->hw.modes = wpa_drv_get_hw_feature_data(
2768 wpa_s, &wpa_s->hw.num_modes, &wpa_s->hw.flags);
2770 wpas_p2p_update_channel_list(wpa_s);
2773 * Check other interfaces to see if they share the same radio. If
2774 * so, they get updated with this same hw mode info.
2776 dl_list_for_each(ifs, &wpa_s->radio->ifaces, struct wpa_supplicant,
2779 wpa_printf(MSG_DEBUG, "%s: Updating hw mode",
2781 free_hw_features(ifs);
2782 ifs->hw.modes = wpa_drv_get_hw_feature_data(
2783 ifs, &ifs->hw.num_modes, &ifs->hw.flags);
2789 static void wpas_event_rx_mgmt_action(struct wpa_supplicant *wpa_s,
2790 const u8 *frame, size_t len, int freq)
2792 const struct ieee80211_mgmt *mgmt;
2797 if (len < IEEE80211_HDRLEN + 2)
2800 mgmt = (const struct ieee80211_mgmt *) frame;
2801 payload = frame + IEEE80211_HDRLEN;
2802 category = *payload++;
2803 plen = len - IEEE80211_HDRLEN - 1;
2805 wpa_dbg(wpa_s, MSG_DEBUG, "Received Action frame: SA=" MACSTR
2806 " Category=%u DataLen=%d freq=%d MHz",
2807 MAC2STR(mgmt->sa), category, (int) plen, freq);
2809 #ifdef CONFIG_IEEE80211R
2810 if (category == WLAN_ACTION_FT) {
2811 ft_rx_action(wpa_s, payload, plen);
2814 #endif /* CONFIG_IEEE80211R */
2816 #ifdef CONFIG_IEEE80211W
2818 if (category == WLAN_ACTION_SA_QUERY) {
2819 sme_sa_query_rx(wpa_s, mgmt->sa, payload, plen);
2822 #endif /* CONFIG_SME */
2823 #endif /* CONFIG_IEEE80211W */
2826 if (mgmt->u.action.category == WLAN_ACTION_WNM) {
2827 ieee802_11_rx_wnm_action(wpa_s, mgmt, len);
2830 #endif /* CONFIG_WNM */
2833 if ((mgmt->u.action.category == WLAN_ACTION_PUBLIC ||
2834 mgmt->u.action.category == WLAN_ACTION_PROTECTED_DUAL) &&
2835 gas_query_rx(wpa_s->gas, mgmt->da, mgmt->sa, mgmt->bssid,
2836 mgmt->u.action.category,
2837 payload, plen, freq) == 0)
2839 #endif /* CONFIG_GAS */
2842 if (category == WLAN_ACTION_PUBLIC && plen >= 4 &&
2843 payload[0] == WLAN_TDLS_DISCOVERY_RESPONSE) {
2844 wpa_dbg(wpa_s, MSG_DEBUG,
2845 "TDLS: Received Discovery Response from " MACSTR,
2849 #endif /* CONFIG_TDLS */
2851 #ifdef CONFIG_INTERWORKING
2852 if (category == WLAN_ACTION_QOS && plen >= 1 &&
2853 payload[0] == QOS_QOS_MAP_CONFIG) {
2854 const u8 *pos = payload + 1;
2855 size_t qlen = plen - 1;
2856 wpa_dbg(wpa_s, MSG_DEBUG, "Interworking: Received QoS Map Configure frame from "
2857 MACSTR, MAC2STR(mgmt->sa));
2858 if (os_memcmp(mgmt->sa, wpa_s->bssid, ETH_ALEN) == 0 &&
2859 qlen > 2 && pos[0] == WLAN_EID_QOS_MAP_SET &&
2860 pos[1] <= qlen - 2 && pos[1] >= 16)
2861 wpas_qos_map_set(wpa_s, pos + 2, pos[1]);
2864 #endif /* CONFIG_INTERWORKING */
2866 wpas_p2p_rx_action(wpa_s, mgmt->da, mgmt->sa, mgmt->bssid,
2867 category, payload, plen, freq);
2871 static void wpa_supplicant_notify_avoid_freq(struct wpa_supplicant *wpa_s,
2872 union wpa_event_data *event)
2875 struct wpa_supplicant *ifs;
2876 #endif /* CONFIG_P2P */
2877 struct wpa_freq_range_list *list;
2880 list = &event->freq_range;
2883 str = freq_range_list_str(list);
2884 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_AVOID_FREQ "ranges=%s",
2888 if (freq_range_list_parse(&wpa_s->global->p2p_go_avoid_freq, str)) {
2889 wpa_dbg(wpa_s, MSG_ERROR, "%s: Failed to parse freq range",
2892 wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Update channel list based on frequency avoid event");
2893 wpas_p2p_update_channel_list(wpa_s);
2896 for (ifs = wpa_s->global->ifaces; ifs; ifs = ifs->next) {
2898 if (!ifs->current_ssid ||
2899 !ifs->current_ssid->p2p_group ||
2900 (ifs->current_ssid->mode != WPAS_MODE_P2P_GO &&
2901 ifs->current_ssid->mode != WPAS_MODE_P2P_GROUP_FORMATION))
2904 freq = ifs->current_ssid->frequency;
2905 if (!freq_range_list_includes(list, freq)) {
2906 wpa_dbg(ifs, MSG_DEBUG, "P2P GO operating frequency %d MHz in safe range",
2911 wpa_dbg(ifs, MSG_DEBUG, "P2P GO operating in unsafe frequency %d MHz",
2913 /* TODO: Consider using CSA or removing the group within
2915 wpa_msg(ifs, MSG_INFO, P2P_EVENT_REMOVE_AND_REFORM_GROUP);
2917 #endif /* CONFIG_P2P */
2923 void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
2924 union wpa_event_data *data)
2926 struct wpa_supplicant *wpa_s = ctx;
2928 if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED &&
2929 event != EVENT_INTERFACE_ENABLED &&
2930 event != EVENT_INTERFACE_STATUS &&
2931 event != EVENT_SCHED_SCAN_STOPPED) {
2932 wpa_dbg(wpa_s, MSG_DEBUG,
2933 "Ignore event %s (%d) while interface is disabled",
2934 event_to_string(event), event);
2938 #ifndef CONFIG_NO_STDOUT_DEBUG
2940 int level = MSG_DEBUG;
2942 if (event == EVENT_RX_MGMT && data->rx_mgmt.frame_len >= 24) {
2943 const struct ieee80211_hdr *hdr;
2945 hdr = (const struct ieee80211_hdr *) data->rx_mgmt.frame;
2946 fc = le_to_host16(hdr->frame_control);
2947 if (WLAN_FC_GET_TYPE(fc) == WLAN_FC_TYPE_MGMT &&
2948 WLAN_FC_GET_STYPE(fc) == WLAN_FC_STYPE_BEACON)
2949 level = MSG_EXCESSIVE;
2952 wpa_dbg(wpa_s, level, "Event %s (%d) received",
2953 event_to_string(event), event);
2955 #endif /* CONFIG_NO_STDOUT_DEBUG */
2959 sme_event_auth(wpa_s, data);
2962 wpa_supplicant_event_assoc(wpa_s, data);
2964 case EVENT_DISASSOC:
2965 wpas_event_disassoc(wpa_s,
2966 data ? &data->disassoc_info : NULL);
2969 wpas_event_deauth(wpa_s,
2970 data ? &data->deauth_info : NULL);
2972 case EVENT_MICHAEL_MIC_FAILURE:
2973 wpa_supplicant_event_michael_mic_failure(wpa_s, data);
2975 #ifndef CONFIG_NO_SCAN_PROCESSING
2976 case EVENT_SCAN_STARTED:
2977 os_get_reltime(&wpa_s->scan_start_time);
2978 if (wpa_s->own_scan_requested) {
2979 struct os_reltime diff;
2981 os_reltime_sub(&wpa_s->scan_start_time,
2982 &wpa_s->scan_trigger_time, &diff);
2983 wpa_dbg(wpa_s, MSG_DEBUG, "Own scan request started a scan in %ld.%06ld seconds",
2984 diff.sec, diff.usec);
2985 wpa_s->own_scan_requested = 0;
2986 wpa_s->own_scan_running = 1;
2987 if (wpa_s->last_scan_req == MANUAL_SCAN_REQ &&
2988 wpa_s->manual_scan_use_id) {
2989 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_SCAN_STARTED "id=%u",
2990 wpa_s->manual_scan_id);
2992 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_SCAN_STARTED);
2995 wpa_dbg(wpa_s, MSG_DEBUG, "External program started a scan");
2996 wpa_s->external_scan_running = 1;
2997 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_SCAN_STARTED);
3000 case EVENT_SCAN_RESULTS:
3001 if (os_reltime_initialized(&wpa_s->scan_start_time)) {
3002 struct os_reltime now, diff;
3003 os_get_reltime(&now);
3004 os_reltime_sub(&now, &wpa_s->scan_start_time, &diff);
3005 wpa_s->scan_start_time.sec = 0;
3006 wpa_s->scan_start_time.usec = 0;
3007 wpa_dbg(wpa_s, MSG_DEBUG, "Scan completed in %ld.%06ld seconds",
3008 diff.sec, diff.usec);
3010 wpa_supplicant_event_scan_results(wpa_s, data);
3011 wpa_s->own_scan_running = 0;
3012 wpa_s->external_scan_running = 0;
3013 radio_work_check_next(wpa_s);
3015 #endif /* CONFIG_NO_SCAN_PROCESSING */
3016 case EVENT_ASSOCINFO:
3017 wpa_supplicant_event_associnfo(wpa_s, data);
3019 case EVENT_INTERFACE_STATUS:
3020 wpa_supplicant_event_interface_status(wpa_s, data);
3022 case EVENT_PMKID_CANDIDATE:
3023 wpa_supplicant_event_pmkid_candidate(wpa_s, data);
3025 #ifdef CONFIG_PEERKEY
3026 case EVENT_STKSTART:
3027 wpa_supplicant_event_stkstart(wpa_s, data);
3029 #endif /* CONFIG_PEERKEY */
3032 wpa_supplicant_event_tdls(wpa_s, data);
3034 #endif /* CONFIG_TDLS */
3037 wpa_supplicant_event_wnm(wpa_s, data);
3039 #endif /* CONFIG_WNM */
3040 #ifdef CONFIG_IEEE80211R
3041 case EVENT_FT_RESPONSE:
3042 wpa_supplicant_event_ft_response(wpa_s, data);
3044 #endif /* CONFIG_IEEE80211R */
3045 #ifdef CONFIG_IBSS_RSN
3046 case EVENT_IBSS_RSN_START:
3047 wpa_supplicant_event_ibss_rsn_start(wpa_s, data);
3049 #endif /* CONFIG_IBSS_RSN */
3050 case EVENT_ASSOC_REJECT:
3051 if (data->assoc_reject.bssid)
3052 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_ASSOC_REJECT
3053 "bssid=" MACSTR " status_code=%u",
3054 MAC2STR(data->assoc_reject.bssid),
3055 data->assoc_reject.status_code);
3057 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_ASSOC_REJECT
3059 data->assoc_reject.status_code);
3060 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
3061 sme_event_assoc_reject(wpa_s, data);
3063 const u8 *bssid = data->assoc_reject.bssid;
3064 if (bssid == NULL || is_zero_ether_addr(bssid))
3065 bssid = wpa_s->pending_bssid;
3066 wpas_connection_failed(wpa_s, bssid);
3067 wpa_supplicant_mark_disassoc(wpa_s);
3070 case EVENT_AUTH_TIMED_OUT:
3071 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
3072 sme_event_auth_timed_out(wpa_s, data);
3074 case EVENT_ASSOC_TIMED_OUT:
3075 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
3076 sme_event_assoc_timed_out(wpa_s, data);
3078 case EVENT_TX_STATUS:
3079 wpa_dbg(wpa_s, MSG_DEBUG, "EVENT_TX_STATUS dst=" MACSTR
3080 " type=%d stype=%d",
3081 MAC2STR(data->tx_status.dst),
3082 data->tx_status.type, data->tx_status.stype);
3084 if (wpa_s->ap_iface == NULL) {
3085 #ifdef CONFIG_OFFCHANNEL
3086 if (data->tx_status.type == WLAN_FC_TYPE_MGMT &&
3087 data->tx_status.stype == WLAN_FC_STYPE_ACTION)
3088 offchannel_send_action_tx_status(
3089 wpa_s, data->tx_status.dst,
3090 data->tx_status.data,
3091 data->tx_status.data_len,
3092 data->tx_status.ack ?
3093 OFFCHANNEL_SEND_ACTION_SUCCESS :
3094 OFFCHANNEL_SEND_ACTION_NO_ACK);
3095 #endif /* CONFIG_OFFCHANNEL */
3098 #endif /* CONFIG_AP */
3099 #ifdef CONFIG_OFFCHANNEL
3100 wpa_dbg(wpa_s, MSG_DEBUG, "EVENT_TX_STATUS pending_dst="
3101 MACSTR, MAC2STR(wpa_s->parent->pending_action_dst));
3103 * Catch TX status events for Action frames we sent via group
3104 * interface in GO mode.
3106 if (data->tx_status.type == WLAN_FC_TYPE_MGMT &&
3107 data->tx_status.stype == WLAN_FC_STYPE_ACTION &&
3108 os_memcmp(wpa_s->parent->pending_action_dst,
3109 data->tx_status.dst, ETH_ALEN) == 0) {
3110 offchannel_send_action_tx_status(
3111 wpa_s->parent, data->tx_status.dst,
3112 data->tx_status.data,
3113 data->tx_status.data_len,
3114 data->tx_status.ack ?
3115 OFFCHANNEL_SEND_ACTION_SUCCESS :
3116 OFFCHANNEL_SEND_ACTION_NO_ACK);
3119 #endif /* CONFIG_OFFCHANNEL */
3121 switch (data->tx_status.type) {
3122 case WLAN_FC_TYPE_MGMT:
3123 ap_mgmt_tx_cb(wpa_s, data->tx_status.data,
3124 data->tx_status.data_len,
3125 data->tx_status.stype,
3126 data->tx_status.ack);
3128 case WLAN_FC_TYPE_DATA:
3129 ap_tx_status(wpa_s, data->tx_status.dst,
3130 data->tx_status.data,
3131 data->tx_status.data_len,
3132 data->tx_status.ack);
3135 #endif /* CONFIG_AP */
3138 case EVENT_EAPOL_TX_STATUS:
3139 ap_eapol_tx_status(wpa_s, data->eapol_tx_status.dst,
3140 data->eapol_tx_status.data,
3141 data->eapol_tx_status.data_len,
3142 data->eapol_tx_status.ack);
3144 case EVENT_DRIVER_CLIENT_POLL_OK:
3145 ap_client_poll_ok(wpa_s, data->client_poll.addr);
3147 case EVENT_RX_FROM_UNKNOWN:
3148 if (wpa_s->ap_iface == NULL)
3150 ap_rx_from_unknown_sta(wpa_s, data->rx_from_unknown.addr,
3151 data->rx_from_unknown.wds);
3153 case EVENT_CH_SWITCH:
3156 if (!wpa_s->ap_iface) {
3157 wpa_dbg(wpa_s, MSG_DEBUG, "AP: Ignore channel switch "
3158 "event in non-AP mode");
3162 wpas_ap_ch_switch(wpa_s, data->ch_switch.freq,
3163 data->ch_switch.ht_enabled,
3164 data->ch_switch.ch_offset,
3165 data->ch_switch.ch_width,
3166 data->ch_switch.cf1,
3167 data->ch_switch.cf2);
3169 #endif /* CONFIG_AP */
3170 case EVENT_RX_MGMT: {
3172 const struct ieee80211_mgmt *mgmt;
3174 #ifdef CONFIG_TESTING_OPTIONS
3175 if (wpa_s->ext_mgmt_frame_handling) {
3176 struct rx_mgmt *rx = &data->rx_mgmt;
3177 size_t hex_len = 2 * rx->frame_len + 1;
3178 char *hex = os_malloc(hex_len);
3180 wpa_snprintf_hex(hex, hex_len,
3181 rx->frame, rx->frame_len);
3182 wpa_msg(wpa_s, MSG_INFO, "MGMT-RX freq=%d datarate=%u ssi_signal=%d %s",
3183 rx->freq, rx->datarate, rx->ssi_signal,
3189 #endif /* CONFIG_TESTING_OPTIONS */
3191 mgmt = (const struct ieee80211_mgmt *)
3192 data->rx_mgmt.frame;
3193 fc = le_to_host16(mgmt->frame_control);
3194 stype = WLAN_FC_GET_STYPE(fc);
3197 if (wpa_s->ap_iface == NULL) {
3198 #endif /* CONFIG_AP */
3200 if (stype == WLAN_FC_STYPE_PROBE_REQ &&
3201 data->rx_mgmt.frame_len > 24) {
3202 const u8 *src = mgmt->sa;
3203 const u8 *ie = mgmt->u.probe_req.variable;
3204 size_t ie_len = data->rx_mgmt.frame_len -
3205 (mgmt->u.probe_req.variable -
3206 data->rx_mgmt.frame);
3207 wpas_p2p_probe_req_rx(
3208 wpa_s, src, mgmt->da,
3209 mgmt->bssid, ie, ie_len,
3210 data->rx_mgmt.ssi_signal);
3213 #endif /* CONFIG_P2P */
3214 #ifdef CONFIG_IBSS_RSN
3215 if (stype == WLAN_FC_STYPE_AUTH &&
3216 data->rx_mgmt.frame_len >= 30) {
3217 wpa_supplicant_event_ibss_auth(wpa_s, data);
3220 #endif /* CONFIG_IBSS_RSN */
3222 if (stype == WLAN_FC_STYPE_ACTION) {
3223 wpas_event_rx_mgmt_action(
3224 wpa_s, data->rx_mgmt.frame,
3225 data->rx_mgmt.frame_len,
3226 data->rx_mgmt.freq);
3230 wpa_dbg(wpa_s, MSG_DEBUG, "AP: ignore received "
3231 "management frame in non-AP mode");
3236 if (stype == WLAN_FC_STYPE_PROBE_REQ &&
3237 data->rx_mgmt.frame_len > 24) {
3238 const u8 *ie = mgmt->u.probe_req.variable;
3239 size_t ie_len = data->rx_mgmt.frame_len -
3240 (mgmt->u.probe_req.variable -
3241 data->rx_mgmt.frame);
3243 wpas_notify_preq(wpa_s, mgmt->sa, mgmt->da,
3244 mgmt->bssid, ie, ie_len,
3245 data->rx_mgmt.ssi_signal);
3248 ap_mgmt_rx(wpa_s, &data->rx_mgmt);
3249 #endif /* CONFIG_AP */
3252 case EVENT_RX_PROBE_REQ:
3253 if (data->rx_probe_req.sa == NULL ||
3254 data->rx_probe_req.ie == NULL)
3257 if (wpa_s->ap_iface) {
3258 hostapd_probe_req_rx(wpa_s->ap_iface->bss[0],
3259 data->rx_probe_req.sa,
3260 data->rx_probe_req.da,
3261 data->rx_probe_req.bssid,
3262 data->rx_probe_req.ie,
3263 data->rx_probe_req.ie_len,
3264 data->rx_probe_req.ssi_signal);
3267 #endif /* CONFIG_AP */
3268 wpas_p2p_probe_req_rx(wpa_s, data->rx_probe_req.sa,
3269 data->rx_probe_req.da,
3270 data->rx_probe_req.bssid,
3271 data->rx_probe_req.ie,
3272 data->rx_probe_req.ie_len,
3273 data->rx_probe_req.ssi_signal);
3275 case EVENT_REMAIN_ON_CHANNEL:
3276 #ifdef CONFIG_OFFCHANNEL
3277 offchannel_remain_on_channel_cb(
3278 wpa_s, data->remain_on_channel.freq,
3279 data->remain_on_channel.duration);
3280 #endif /* CONFIG_OFFCHANNEL */
3281 wpas_p2p_remain_on_channel_cb(
3282 wpa_s, data->remain_on_channel.freq,
3283 data->remain_on_channel.duration);
3285 case EVENT_CANCEL_REMAIN_ON_CHANNEL:
3286 #ifdef CONFIG_OFFCHANNEL
3287 offchannel_cancel_remain_on_channel_cb(
3288 wpa_s, data->remain_on_channel.freq);
3289 #endif /* CONFIG_OFFCHANNEL */
3290 wpas_p2p_cancel_remain_on_channel_cb(
3291 wpa_s, data->remain_on_channel.freq);
3293 case EVENT_EAPOL_RX:
3294 wpa_supplicant_rx_eapol(wpa_s, data->eapol_rx.src,
3295 data->eapol_rx.data,
3296 data->eapol_rx.data_len);
3298 case EVENT_SIGNAL_CHANGE:
3299 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_SIGNAL_CHANGE
3300 "above=%d signal=%d noise=%d txrate=%d",
3301 data->signal_change.above_threshold,
3302 data->signal_change.current_signal,
3303 data->signal_change.current_noise,
3304 data->signal_change.current_txrate);
3305 bgscan_notify_signal_change(
3306 wpa_s, data->signal_change.above_threshold,
3307 data->signal_change.current_signal,
3308 data->signal_change.current_noise,
3309 data->signal_change.current_txrate);
3311 case EVENT_INTERFACE_ENABLED:
3312 wpa_dbg(wpa_s, MSG_DEBUG, "Interface was enabled");
3313 if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) {
3314 wpa_supplicant_update_mac_addr(wpa_s);
3315 if (wpa_s->p2p_mgmt) {
3316 wpa_supplicant_set_state(wpa_s,
3322 if (!wpa_s->ap_iface) {
3323 wpa_supplicant_set_state(wpa_s,
3325 wpa_supplicant_req_scan(wpa_s, 0, 0);
3327 wpa_supplicant_set_state(wpa_s,
3329 #else /* CONFIG_AP */
3330 wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
3331 wpa_supplicant_req_scan(wpa_s, 0, 0);
3332 #endif /* CONFIG_AP */
3335 case EVENT_INTERFACE_DISABLED:
3336 wpa_dbg(wpa_s, MSG_DEBUG, "Interface was disabled");
3338 if (wpa_s->p2p_group_interface == P2P_GROUP_INTERFACE_GO ||
3339 (wpa_s->current_ssid && wpa_s->current_ssid->p2p_group &&
3340 wpa_s->current_ssid->mode == WPAS_MODE_P2P_GO)) {
3342 * The interface was externally disabled. Remove
3343 * it assuming an external entity will start a
3344 * new session if needed.
3346 wpas_p2p_disconnect(wpa_s);
3349 if (wpa_s->p2p_scan_work && wpa_s->global->p2p &&
3350 p2p_in_progress(wpa_s->global->p2p) > 1) {
3351 /* This radio work will be cancelled, so clear P2P
3354 p2p_stop_find(wpa_s->global->p2p);
3356 #endif /* CONFIG_P2P */
3358 if (wpa_s->wpa_state >= WPA_AUTHENTICATING) {
3360 * Indicate disconnection to keep ctrl_iface events
3363 wpa_supplicant_event_disassoc(
3364 wpa_s, WLAN_REASON_DEAUTH_LEAVING, 1);
3366 wpa_supplicant_mark_disassoc(wpa_s);
3367 radio_remove_works(wpa_s, NULL, 0);
3369 wpa_supplicant_set_state(wpa_s, WPA_INTERFACE_DISABLED);
3371 case EVENT_CHANNEL_LIST_CHANGED:
3372 wpa_supplicant_update_channel_list(
3373 wpa_s, &data->channel_list_changed);
3375 case EVENT_INTERFACE_UNAVAILABLE:
3376 wpas_p2p_interface_unavailable(wpa_s);
3378 case EVENT_BEST_CHANNEL:
3379 wpa_dbg(wpa_s, MSG_DEBUG, "Best channel event received "
3381 data->best_chan.freq_24, data->best_chan.freq_5,
3382 data->best_chan.freq_overall);
3383 wpa_s->best_24_freq = data->best_chan.freq_24;
3384 wpa_s->best_5_freq = data->best_chan.freq_5;
3385 wpa_s->best_overall_freq = data->best_chan.freq_overall;
3386 wpas_p2p_update_best_channels(wpa_s, data->best_chan.freq_24,
3387 data->best_chan.freq_5,
3388 data->best_chan.freq_overall);
3390 case EVENT_UNPROT_DEAUTH:
3391 wpa_supplicant_event_unprot_deauth(wpa_s,
3392 &data->unprot_deauth);
3394 case EVENT_UNPROT_DISASSOC:
3395 wpa_supplicant_event_unprot_disassoc(wpa_s,
3396 &data->unprot_disassoc);
3398 case EVENT_STATION_LOW_ACK:
3400 if (wpa_s->ap_iface && data)
3401 hostapd_event_sta_low_ack(wpa_s->ap_iface->bss[0],
3402 data->low_ack.addr);
3403 #endif /* CONFIG_AP */
3406 wpa_tdls_disable_unreachable_link(wpa_s->wpa,
3407 data->low_ack.addr);
3408 #endif /* CONFIG_TDLS */
3410 case EVENT_IBSS_PEER_LOST:
3411 #ifdef CONFIG_IBSS_RSN
3412 ibss_rsn_stop(wpa_s->ibss_rsn, data->ibss_peer_lost.peer);
3413 #endif /* CONFIG_IBSS_RSN */
3415 case EVENT_DRIVER_GTK_REKEY:
3416 if (os_memcmp(data->driver_gtk_rekey.bssid,
3417 wpa_s->bssid, ETH_ALEN))
3421 wpa_sm_update_replay_ctr(wpa_s->wpa,
3422 data->driver_gtk_rekey.replay_ctr);
3424 case EVENT_SCHED_SCAN_STOPPED:
3426 wpa_s->sched_scanning = 0;
3427 wpa_supplicant_notify_scanning(wpa_s, 0);
3429 if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED)
3433 * Start a new sched scan to continue searching for more SSIDs
3434 * either if timed out or PNO schedule scan is pending.
3436 if (wpa_s->sched_scan_timed_out) {
3437 wpa_supplicant_req_sched_scan(wpa_s);
3438 } else if (wpa_s->pno_sched_pending) {
3439 wpa_s->pno_sched_pending = 0;
3440 wpas_start_pno(wpa_s);
3444 case EVENT_WPS_BUTTON_PUSHED:
3446 wpas_wps_start_pbc(wpa_s, NULL, 0);
3447 #endif /* CONFIG_WPS */
3449 case EVENT_AVOID_FREQUENCIES:
3450 wpa_supplicant_notify_avoid_freq(wpa_s, data);
3452 case EVENT_CONNECT_FAILED_REASON:
3454 if (!wpa_s->ap_iface || !data)
3456 hostapd_event_connect_failed_reason(
3457 wpa_s->ap_iface->bss[0],
3458 data->connect_failed_reason.addr,
3459 data->connect_failed_reason.code);
3460 #endif /* CONFIG_AP */
3463 wpa_msg(wpa_s, MSG_INFO, "Unknown event %d", event);