2 * WPA Supplicant - Driver event processing
3 * Copyright (c) 2003-2012, 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"
27 #include "common/ieee802_11_defs.h"
28 #include "common/ieee802_11_common.h"
29 #include "crypto/random.h"
30 #include "blacklist.h"
31 #include "wpas_glue.h"
32 #include "wps_supplicant.h"
35 #include "gas_query.h"
36 #include "p2p_supplicant.h"
41 #include "offchannel.h"
44 static int wpa_supplicant_select_config(struct wpa_supplicant *wpa_s)
46 struct wpa_ssid *ssid, *old_ssid;
48 if (wpa_s->conf->ap_scan == 1 && wpa_s->current_ssid)
51 wpa_dbg(wpa_s, MSG_DEBUG, "Select network based on association "
53 ssid = wpa_supplicant_get_ssid(wpa_s);
55 wpa_msg(wpa_s, MSG_INFO,
56 "No network configuration found for the current AP");
60 if (wpas_network_disabled(wpa_s, ssid)) {
61 wpa_dbg(wpa_s, MSG_DEBUG, "Selected network is disabled");
65 wpa_dbg(wpa_s, MSG_DEBUG, "Network configuration found for the "
67 if (wpa_key_mgmt_wpa_any(ssid->key_mgmt)) {
69 size_t wpa_ie_len = sizeof(wpa_ie);
70 wpa_supplicant_set_suites(wpa_s, NULL, ssid,
73 wpa_supplicant_set_non_wpa_policy(wpa_s, ssid);
76 if (wpa_s->current_ssid && wpa_s->current_ssid != ssid)
77 eapol_sm_invalidate_cached_session(wpa_s->eapol);
78 old_ssid = wpa_s->current_ssid;
79 wpa_s->current_ssid = ssid;
80 wpa_supplicant_rsn_supp_set_config(wpa_s, wpa_s->current_ssid);
81 wpa_supplicant_initiate_eapol(wpa_s);
82 if (old_ssid != wpa_s->current_ssid)
83 wpas_notify_network_changed(wpa_s);
89 void wpa_supplicant_stop_countermeasures(void *eloop_ctx, void *sock_ctx)
91 struct wpa_supplicant *wpa_s = eloop_ctx;
93 if (wpa_s->countermeasures) {
94 wpa_s->countermeasures = 0;
95 wpa_drv_set_countermeasures(wpa_s, 0);
96 wpa_msg(wpa_s, MSG_INFO, "WPA: TKIP countermeasures stopped");
97 wpa_supplicant_req_scan(wpa_s, 0, 0);
102 void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s)
106 wnm_bss_keep_alive_deinit(wpa_s);
108 #ifdef CONFIG_IBSS_RSN
109 ibss_rsn_deinit(wpa_s->ibss_rsn);
110 wpa_s->ibss_rsn = NULL;
111 #endif /* CONFIG_IBSS_RSN */
114 wpa_supplicant_ap_deinit(wpa_s);
115 #endif /* CONFIG_AP */
117 if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED)
120 wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
121 bssid_changed = !is_zero_ether_addr(wpa_s->bssid);
122 os_memset(wpa_s->bssid, 0, ETH_ALEN);
123 os_memset(wpa_s->pending_bssid, 0, ETH_ALEN);
125 os_memset(wpa_s->go_dev_addr, 0, ETH_ALEN);
126 #endif /* CONFIG_P2P */
127 wpa_s->current_bss = NULL;
128 wpa_s->assoc_freq = 0;
129 #ifdef CONFIG_IEEE80211R
131 if (wpa_s->sme.ft_ies)
132 sme_update_ft_ies(wpa_s, NULL, NULL, 0);
133 #endif /* CONFIG_SME */
134 #endif /* CONFIG_IEEE80211R */
137 wpas_notify_bssid_changed(wpa_s);
139 eapol_sm_notify_portEnabled(wpa_s->eapol, FALSE);
140 eapol_sm_notify_portValid(wpa_s->eapol, FALSE);
141 if (wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt))
142 eapol_sm_notify_eap_success(wpa_s->eapol, FALSE);
143 wpa_s->ap_ies_from_associnfo = 0;
147 static void wpa_find_assoc_pmkid(struct wpa_supplicant *wpa_s)
149 struct wpa_ie_data ie;
153 if (wpa_sm_parse_own_wpa_ie(wpa_s->wpa, &ie) < 0 ||
157 for (i = 0; i < ie.num_pmkid; i++) {
158 pmksa_set = pmksa_cache_set_current(wpa_s->wpa,
159 ie.pmkid + i * PMKID_LEN,
161 if (pmksa_set == 0) {
162 eapol_sm_notify_pmkid_attempt(wpa_s->eapol, 1);
167 wpa_dbg(wpa_s, MSG_DEBUG, "RSN: PMKID from assoc IE %sfound from "
168 "PMKSA cache", pmksa_set == 0 ? "" : "not ");
172 static void wpa_supplicant_event_pmkid_candidate(struct wpa_supplicant *wpa_s,
173 union wpa_event_data *data)
176 wpa_dbg(wpa_s, MSG_DEBUG, "RSN: No data in PMKID candidate "
180 wpa_dbg(wpa_s, MSG_DEBUG, "RSN: PMKID candidate event - bssid=" MACSTR
181 " index=%d preauth=%d",
182 MAC2STR(data->pmkid_candidate.bssid),
183 data->pmkid_candidate.index,
184 data->pmkid_candidate.preauth);
186 pmksa_candidate_add(wpa_s->wpa, data->pmkid_candidate.bssid,
187 data->pmkid_candidate.index,
188 data->pmkid_candidate.preauth);
192 static int wpa_supplicant_dynamic_keys(struct wpa_supplicant *wpa_s)
194 if (wpa_s->key_mgmt == WPA_KEY_MGMT_NONE ||
195 wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE)
198 #ifdef IEEE8021X_EAPOL
199 if (wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA &&
200 wpa_s->current_ssid &&
201 !(wpa_s->current_ssid->eapol_flags &
202 (EAPOL_FLAG_REQUIRE_KEY_UNICAST |
203 EAPOL_FLAG_REQUIRE_KEY_BROADCAST))) {
204 /* IEEE 802.1X, but not using dynamic WEP keys (i.e., either
205 * plaintext or static WEP keys). */
208 #endif /* IEEE8021X_EAPOL */
215 * wpa_supplicant_scard_init - Initialize SIM/USIM access with PC/SC
216 * @wpa_s: pointer to wpa_supplicant data
217 * @ssid: Configuration data for the network
218 * Returns: 0 on success, -1 on failure
220 * This function is called when starting authentication with a network that is
221 * configured to use PC/SC for SIM/USIM access (EAP-SIM or EAP-AKA).
223 int wpa_supplicant_scard_init(struct wpa_supplicant *wpa_s,
224 struct wpa_ssid *ssid)
226 #ifdef IEEE8021X_EAPOL
228 int aka = 0, sim = 0, type;
230 if (ssid->eap.pcsc == NULL || wpa_s->scard != NULL)
233 if (ssid->eap.eap_methods == NULL) {
237 struct eap_method_type *eap = ssid->eap.eap_methods;
238 while (eap->vendor != EAP_VENDOR_IETF ||
239 eap->method != EAP_TYPE_NONE) {
240 if (eap->vendor == EAP_VENDOR_IETF) {
241 if (eap->method == EAP_TYPE_SIM)
243 else if (eap->method == EAP_TYPE_AKA ||
244 eap->method == EAP_TYPE_AKA_PRIME)
251 if (eap_peer_get_eap_method(EAP_VENDOR_IETF, EAP_TYPE_SIM) == NULL)
253 if (eap_peer_get_eap_method(EAP_VENDOR_IETF, EAP_TYPE_AKA) == NULL &&
254 eap_peer_get_eap_method(EAP_VENDOR_IETF, EAP_TYPE_AKA_PRIME) ==
259 wpa_dbg(wpa_s, MSG_DEBUG, "Selected network is configured to "
260 "use SIM, but neither EAP-SIM nor EAP-AKA are "
265 wpa_dbg(wpa_s, MSG_DEBUG, "Selected network is configured to use SIM "
266 "(sim=%d aka=%d) - initialize PCSC", sim, aka);
268 type = SCARD_TRY_BOTH;
270 type = SCARD_USIM_ONLY;
272 type = SCARD_GSM_SIM_ONLY;
274 wpa_s->scard = scard_init(type, NULL);
275 if (wpa_s->scard == NULL) {
276 wpa_msg(wpa_s, MSG_WARNING, "Failed to initialize SIM "
280 wpa_sm_set_scard_ctx(wpa_s->wpa, wpa_s->scard);
281 eapol_sm_register_scard_ctx(wpa_s->eapol, wpa_s->scard);
282 #endif /* PCSC_FUNCS */
283 #endif /* IEEE8021X_EAPOL */
289 #ifndef CONFIG_NO_SCAN_PROCESSING
290 static int wpa_supplicant_match_privacy(struct wpa_scan_res *bss,
291 struct wpa_ssid *ssid)
295 if (ssid->mixed_cell)
299 if (ssid->key_mgmt & WPA_KEY_MGMT_WPS)
301 #endif /* CONFIG_WPS */
303 for (i = 0; i < NUM_WEP_KEYS; i++) {
304 if (ssid->wep_key_len[i]) {
309 #ifdef IEEE8021X_EAPOL
310 if ((ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X_NO_WPA) &&
311 ssid->eapol_flags & (EAPOL_FLAG_REQUIRE_KEY_UNICAST |
312 EAPOL_FLAG_REQUIRE_KEY_BROADCAST))
314 #endif /* IEEE8021X_EAPOL */
316 if (wpa_key_mgmt_wpa(ssid->key_mgmt))
319 if (bss->caps & IEEE80211_CAP_PRIVACY)
325 static int wpa_supplicant_ssid_bss_match(struct wpa_supplicant *wpa_s,
326 struct wpa_ssid *ssid,
327 struct wpa_scan_res *bss)
329 struct wpa_ie_data ie;
331 const u8 *rsn_ie, *wpa_ie;
335 ret = wpas_wps_ssid_bss_match(wpa_s, ssid, bss);
339 /* Allow TSN if local configuration accepts WEP use without WPA/WPA2 */
340 wep_ok = !wpa_key_mgmt_wpa(ssid->key_mgmt) &&
341 (((ssid->key_mgmt & WPA_KEY_MGMT_NONE) &&
342 ssid->wep_key_len[ssid->wep_tx_keyidx] > 0) ||
343 (ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X_NO_WPA));
345 rsn_ie = wpa_scan_get_ie(bss, WLAN_EID_RSN);
346 while ((ssid->proto & WPA_PROTO_RSN) && rsn_ie) {
349 if (wpa_parse_wpa_ie(rsn_ie, 2 + rsn_ie[1], &ie)) {
350 wpa_dbg(wpa_s, MSG_DEBUG, " skip RSN IE - parse "
356 (ie.group_cipher & (WPA_CIPHER_WEP40 | WPA_CIPHER_WEP104)))
358 wpa_dbg(wpa_s, MSG_DEBUG, " selected based on TSN "
363 if (!(ie.proto & ssid->proto)) {
364 wpa_dbg(wpa_s, MSG_DEBUG, " skip RSN IE - proto "
369 if (!(ie.pairwise_cipher & ssid->pairwise_cipher)) {
370 wpa_dbg(wpa_s, MSG_DEBUG, " skip RSN IE - PTK "
375 if (!(ie.group_cipher & ssid->group_cipher)) {
376 wpa_dbg(wpa_s, MSG_DEBUG, " skip RSN IE - GTK "
381 if (!(ie.key_mgmt & ssid->key_mgmt)) {
382 wpa_dbg(wpa_s, MSG_DEBUG, " skip RSN IE - key mgmt "
387 #ifdef CONFIG_IEEE80211W
388 if (!(ie.capabilities & WPA_CAPABILITY_MFPC) &&
389 ssid->ieee80211w == MGMT_FRAME_PROTECTION_REQUIRED) {
390 wpa_dbg(wpa_s, MSG_DEBUG, " skip RSN IE - no mgmt "
394 #endif /* CONFIG_IEEE80211W */
396 wpa_dbg(wpa_s, MSG_DEBUG, " selected based on RSN IE");
400 wpa_ie = wpa_scan_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE);
401 while ((ssid->proto & WPA_PROTO_WPA) && wpa_ie) {
404 if (wpa_parse_wpa_ie(wpa_ie, 2 + wpa_ie[1], &ie)) {
405 wpa_dbg(wpa_s, MSG_DEBUG, " skip WPA IE - parse "
411 (ie.group_cipher & (WPA_CIPHER_WEP40 | WPA_CIPHER_WEP104)))
413 wpa_dbg(wpa_s, MSG_DEBUG, " selected based on TSN "
418 if (!(ie.proto & ssid->proto)) {
419 wpa_dbg(wpa_s, MSG_DEBUG, " skip WPA IE - proto "
424 if (!(ie.pairwise_cipher & ssid->pairwise_cipher)) {
425 wpa_dbg(wpa_s, MSG_DEBUG, " skip WPA IE - PTK "
430 if (!(ie.group_cipher & ssid->group_cipher)) {
431 wpa_dbg(wpa_s, MSG_DEBUG, " skip WPA IE - GTK "
436 if (!(ie.key_mgmt & ssid->key_mgmt)) {
437 wpa_dbg(wpa_s, MSG_DEBUG, " skip WPA IE - key mgmt "
442 wpa_dbg(wpa_s, MSG_DEBUG, " selected based on WPA IE");
446 if ((ssid->proto & (WPA_PROTO_WPA | WPA_PROTO_RSN)) &&
447 wpa_key_mgmt_wpa(ssid->key_mgmt) && proto_match == 0) {
448 wpa_dbg(wpa_s, MSG_DEBUG, " skip - no WPA/RSN proto match");
452 if (!wpa_key_mgmt_wpa(ssid->key_mgmt)) {
453 wpa_dbg(wpa_s, MSG_DEBUG, " allow in non-WPA/WPA2");
457 wpa_dbg(wpa_s, MSG_DEBUG, " reject due to mismatch with "
464 static int freq_allowed(int *freqs, int freq)
471 for (i = 0; freqs[i]; i++)
472 if (freqs[i] == freq)
478 static int ht_supported(const struct hostapd_hw_modes *mode)
480 if (!(mode->flags & HOSTAPD_MODE_FLAG_HT_INFO_KNOWN)) {
482 * The driver did not indicate whether it supports HT. Assume
483 * it does to avoid connection issues.
489 * IEEE Std 802.11n-2009 20.1.1:
490 * An HT non-AP STA shall support all EQM rates for one spatial stream.
492 return mode->mcs_set[0] == 0xff;
496 static int rate_match(struct wpa_supplicant *wpa_s, struct wpa_scan_res *bss)
498 const struct hostapd_hw_modes *mode = NULL, *modes;
499 const u8 scan_ie[2] = { WLAN_EID_SUPP_RATES, WLAN_EID_EXT_SUPP_RATES };
504 return 1; /* Cannot do matching without knowing band */
506 modes = wpa_s->hw.modes;
509 * The driver does not provide any additional information
510 * about the utilized hardware, so allow the connection attempt
516 for (i = 0; i < wpa_s->hw.num_modes; i++) {
517 for (j = 0; j < modes[i].num_channels; j++) {
518 int freq = modes[i].channels[j].freq;
519 if (freq == bss->freq) {
521 mode->mode == HOSTAPD_MODE_IEEE80211G)
522 break; /* do not allow 802.11b replace
533 for (i = 0; i < (int) sizeof(scan_ie); i++) {
534 rate_ie = wpa_scan_get_ie(bss, scan_ie[i]);
538 for (j = 2; j < rate_ie[1] + 2; j++) {
539 int flagged = !!(rate_ie[j] & 0x80);
540 int r = (rate_ie[j] & 0x7f) * 5;
543 * IEEE Std 802.11n-2009 7.3.2.2:
544 * The new BSS Membership selector value is encoded
545 * like a legacy basic rate, but it is not a rate and
546 * only indicates if the BSS members are required to
547 * support the mandatory features of Clause 20 [HT PHY]
548 * in order to join the BSS.
550 if (flagged && ((rate_ie[j] & 0x7f) ==
551 BSS_MEMBERSHIP_SELECTOR_HT_PHY)) {
552 if (!ht_supported(mode)) {
553 wpa_dbg(wpa_s, MSG_DEBUG,
554 " hardware does not support "
564 /* check for legacy basic rates */
565 for (k = 0; k < mode->num_rates; k++) {
566 if (mode->rates[k] == r)
569 if (k == mode->num_rates) {
571 * IEEE Std 802.11-2007 7.3.2.2 demands that in
572 * order to join a BSS all required rates
573 * have to be supported by the hardware.
575 wpa_dbg(wpa_s, MSG_DEBUG, " hardware does "
576 "not support required rate %d.%d Mbps",
587 static struct wpa_ssid * wpa_scan_res_match(struct wpa_supplicant *wpa_s,
588 int i, struct wpa_scan_res *bss,
589 struct wpa_ssid *group)
592 u8 wpa_ie_len, rsn_ie_len, ssid_len;
594 struct wpa_blacklist *e;
596 struct wpa_ssid *ssid;
598 ie = wpa_scan_get_ie(bss, WLAN_EID_SSID);
599 ssid_ = ie ? ie + 2 : (u8 *) "";
600 ssid_len = ie ? ie[1] : 0;
602 ie = wpa_scan_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE);
603 wpa_ie_len = ie ? ie[1] : 0;
605 ie = wpa_scan_get_ie(bss, WLAN_EID_RSN);
606 rsn_ie_len = ie ? ie[1] : 0;
608 wpa_dbg(wpa_s, MSG_DEBUG, "%d: " MACSTR " ssid='%s' "
609 "wpa_ie_len=%u rsn_ie_len=%u caps=0x%x level=%d%s",
610 i, MAC2STR(bss->bssid), wpa_ssid_txt(ssid_, ssid_len),
611 wpa_ie_len, rsn_ie_len, bss->caps, bss->level,
612 wpa_scan_get_vendor_ie(bss, WPS_IE_VENDOR_TYPE) ? " wps" : "");
614 e = wpa_blacklist_get(wpa_s, bss->bssid);
617 if (wpa_supplicant_enabled_networks(wpa_s) == 1) {
619 * When only a single network is enabled, we can
620 * trigger blacklisting on the first failure. This
621 * should not be done with multiple enabled networks to
622 * avoid getting forced to move into a worse ESS on
623 * single error if there are no other BSSes of the
628 if (e->count > limit) {
629 wpa_dbg(wpa_s, MSG_DEBUG, " skip - blacklisted "
630 "(count=%d limit=%d)", e->count, limit);
636 wpa_dbg(wpa_s, MSG_DEBUG, " skip - SSID not known");
640 wpa = wpa_ie_len > 0 || rsn_ie_len > 0;
642 for (ssid = group; ssid; ssid = ssid->pnext) {
643 int check_ssid = wpa ? 1 : (ssid->ssid_len != 0);
645 if (wpas_network_disabled(wpa_s, ssid)) {
646 wpa_dbg(wpa_s, MSG_DEBUG, " skip - disabled");
651 if ((ssid->key_mgmt & WPA_KEY_MGMT_WPS) && e && e->count > 0) {
652 wpa_dbg(wpa_s, MSG_DEBUG, " skip - blacklisted "
657 if (wpa && ssid->ssid_len == 0 &&
658 wpas_wps_ssid_wildcard_ok(wpa_s, ssid, bss))
661 if (!wpa && (ssid->key_mgmt & WPA_KEY_MGMT_WPS)) {
662 /* Only allow wildcard SSID match if an AP
663 * advertises active WPS operation that matches
666 if (ssid->ssid_len == 0 &&
667 wpas_wps_ssid_wildcard_ok(wpa_s, ssid, bss))
670 #endif /* CONFIG_WPS */
672 if (ssid->bssid_set && ssid->ssid_len == 0 &&
673 os_memcmp(bss->bssid, ssid->bssid, ETH_ALEN) == 0)
677 (ssid_len != ssid->ssid_len ||
678 os_memcmp(ssid_, ssid->ssid, ssid_len) != 0)) {
679 wpa_dbg(wpa_s, MSG_DEBUG, " skip - SSID mismatch");
683 if (ssid->bssid_set &&
684 os_memcmp(bss->bssid, ssid->bssid, ETH_ALEN) != 0) {
685 wpa_dbg(wpa_s, MSG_DEBUG, " skip - BSSID mismatch");
689 if (!wpa_supplicant_ssid_bss_match(wpa_s, ssid, bss))
693 !(ssid->key_mgmt & WPA_KEY_MGMT_NONE) &&
694 !(ssid->key_mgmt & WPA_KEY_MGMT_WPS) &&
695 !(ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X_NO_WPA)) {
696 wpa_dbg(wpa_s, MSG_DEBUG, " skip - non-WPA network "
701 if (!wpa_supplicant_match_privacy(bss, ssid)) {
702 wpa_dbg(wpa_s, MSG_DEBUG, " skip - privacy "
707 if (bss->caps & IEEE80211_CAP_IBSS) {
708 wpa_dbg(wpa_s, MSG_DEBUG, " skip - IBSS (adhoc) "
713 if (!freq_allowed(ssid->freq_list, bss->freq)) {
714 wpa_dbg(wpa_s, MSG_DEBUG, " skip - frequency not "
719 if (!rate_match(wpa_s, bss)) {
720 wpa_dbg(wpa_s, MSG_DEBUG, " skip - rate sets do "
727 * TODO: skip the AP if its P2P IE has Group Formation
728 * bit set in the P2P Group Capability Bitmap and we
729 * are not in Group Formation with that device.
731 #endif /* CONFIG_P2P */
733 /* Matching configuration found */
737 /* No matching configuration found */
742 static struct wpa_bss *
743 wpa_supplicant_select_bss(struct wpa_supplicant *wpa_s,
744 struct wpa_scan_results *scan_res,
745 struct wpa_ssid *group,
746 struct wpa_ssid **selected_ssid)
750 wpa_dbg(wpa_s, MSG_DEBUG, "Selecting BSS from priority group %d",
753 for (i = 0; i < scan_res->num; i++) {
754 struct wpa_scan_res *bss = scan_res->res[i];
758 *selected_ssid = wpa_scan_res_match(wpa_s, i, bss, group);
762 ie = wpa_scan_get_ie(bss, WLAN_EID_SSID);
763 ssid = ie ? ie + 2 : (u8 *) "";
764 ssid_len = ie ? ie[1] : 0;
766 wpa_dbg(wpa_s, MSG_DEBUG, " selected BSS " MACSTR
768 MAC2STR(bss->bssid), wpa_ssid_txt(ssid, ssid_len));
769 return wpa_bss_get(wpa_s, bss->bssid, ssid, ssid_len);
776 static struct wpa_bss *
777 wpa_supplicant_pick_network(struct wpa_supplicant *wpa_s,
778 struct wpa_scan_results *scan_res,
779 struct wpa_ssid **selected_ssid)
781 struct wpa_bss *selected = NULL;
784 while (selected == NULL) {
785 for (prio = 0; prio < wpa_s->conf->num_prio; prio++) {
786 selected = wpa_supplicant_select_bss(
787 wpa_s, scan_res, wpa_s->conf->pssid[prio],
793 if (selected == NULL && wpa_s->blacklist &&
794 !wpa_s->countermeasures) {
795 wpa_dbg(wpa_s, MSG_DEBUG, "No APs found - clear "
796 "blacklist and try again");
797 wpa_blacklist_clear(wpa_s);
798 wpa_s->blacklist_cleared++;
799 } else if (selected == NULL)
807 static void wpa_supplicant_req_new_scan(struct wpa_supplicant *wpa_s,
808 int timeout_sec, int timeout_usec)
810 if (!wpa_supplicant_enabled_networks(wpa_s)) {
812 * No networks are enabled; short-circuit request so
813 * we don't wait timeout seconds before transitioning
816 wpa_supplicant_set_state(wpa_s, WPA_INACTIVE);
819 wpa_supplicant_req_scan(wpa_s, timeout_sec, timeout_usec);
823 int wpa_supplicant_connect(struct wpa_supplicant *wpa_s,
824 struct wpa_bss *selected,
825 struct wpa_ssid *ssid)
827 if (wpas_wps_scan_pbc_overlap(wpa_s, selected, ssid)) {
828 wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_OVERLAP
829 "PBC session overlap");
831 if (wpas_p2p_notif_pbc_overlap(wpa_s) == 1)
833 #endif /* CONFIG_P2P */
836 wpas_wps_cancel(wpa_s);
837 #endif /* CONFIG_WPS */
842 * Do not trigger new association unless the BSSID has changed or if
843 * reassociation is requested. If we are in process of associating with
844 * the selected BSSID, do not trigger new attempt.
846 if (wpa_s->reassociate ||
847 (os_memcmp(selected->bssid, wpa_s->bssid, ETH_ALEN) != 0 &&
848 ((wpa_s->wpa_state != WPA_ASSOCIATING &&
849 wpa_s->wpa_state != WPA_AUTHENTICATING) ||
850 os_memcmp(selected->bssid, wpa_s->pending_bssid, ETH_ALEN) !=
852 if (wpa_supplicant_scard_init(wpa_s, ssid)) {
853 wpa_supplicant_req_new_scan(wpa_s, 10, 0);
856 wpa_msg(wpa_s, MSG_DEBUG, "Request association: "
857 "reassociate: %d selected: "MACSTR " bssid: " MACSTR
858 " pending: " MACSTR " wpa_state: %s",
859 wpa_s->reassociate, MAC2STR(selected->bssid),
860 MAC2STR(wpa_s->bssid), MAC2STR(wpa_s->pending_bssid),
861 wpa_supplicant_state_txt(wpa_s->wpa_state));
862 wpa_supplicant_associate(wpa_s, selected, ssid);
864 wpa_dbg(wpa_s, MSG_DEBUG, "Already associated with the "
872 static struct wpa_ssid *
873 wpa_supplicant_pick_new_network(struct wpa_supplicant *wpa_s)
876 struct wpa_ssid *ssid;
878 for (prio = 0; prio < wpa_s->conf->num_prio; prio++) {
879 for (ssid = wpa_s->conf->pssid[prio]; ssid; ssid = ssid->pnext)
881 if (wpas_network_disabled(wpa_s, ssid))
883 if (ssid->mode == IEEE80211_MODE_IBSS ||
884 ssid->mode == IEEE80211_MODE_AP)
892 /* TODO: move the rsn_preauth_scan_result*() to be called from notify.c based
893 * on BSS added and BSS changed events */
894 static void wpa_supplicant_rsn_preauth_scan_results(
895 struct wpa_supplicant *wpa_s)
899 if (rsn_preauth_scan_results(wpa_s->wpa) < 0)
902 dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) {
903 const u8 *ssid, *rsn;
905 ssid = wpa_bss_get_ie(bss, WLAN_EID_SSID);
909 rsn = wpa_bss_get_ie(bss, WLAN_EID_RSN);
913 rsn_preauth_scan_result(wpa_s->wpa, bss->bssid, ssid, rsn);
919 static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s,
920 struct wpa_bss *selected,
921 struct wpa_ssid *ssid,
922 struct wpa_scan_results *scan_res)
925 struct wpa_scan_res *current_bss = NULL;
928 if (wpa_s->reassociate)
929 return 1; /* explicit request to reassociate */
930 if (wpa_s->wpa_state < WPA_ASSOCIATED)
931 return 1; /* we are not associated; continue */
932 if (wpa_s->current_ssid == NULL)
933 return 1; /* unknown current SSID */
934 if (wpa_s->current_ssid != ssid)
935 return 1; /* different network block */
937 if (wpas_driver_bss_selection(wpa_s))
938 return 0; /* Driver-based roaming */
940 for (i = 0; i < scan_res->num; i++) {
941 struct wpa_scan_res *res = scan_res->res[i];
943 if (os_memcmp(res->bssid, wpa_s->bssid, ETH_ALEN) != 0)
946 ie = wpa_scan_get_ie(res, WLAN_EID_SSID);
949 if (ie[1] != wpa_s->current_ssid->ssid_len ||
950 os_memcmp(ie + 2, wpa_s->current_ssid->ssid, ie[1]) != 0)
957 return 1; /* current BSS not seen in scan results */
959 #ifndef CONFIG_NO_ROAMING
960 wpa_dbg(wpa_s, MSG_DEBUG, "Considering within-ESS reassociation");
961 wpa_dbg(wpa_s, MSG_DEBUG, "Current BSS: " MACSTR " level=%d",
962 MAC2STR(current_bss->bssid), current_bss->level);
963 wpa_dbg(wpa_s, MSG_DEBUG, "Selected BSS: " MACSTR " level=%d",
964 MAC2STR(selected->bssid), selected->level);
966 if (wpa_s->current_ssid->bssid_set &&
967 os_memcmp(selected->bssid, wpa_s->current_ssid->bssid, ETH_ALEN) ==
969 wpa_dbg(wpa_s, MSG_DEBUG, "Allow reassociation - selected BSS "
970 "has preferred BSSID");
975 if (current_bss->level < 0) {
976 if (current_bss->level < -85)
978 else if (current_bss->level < -80)
980 else if (current_bss->level < -75)
982 else if (current_bss->level < -70)
987 if (abs(current_bss->level - selected->level) < min_diff) {
988 wpa_dbg(wpa_s, MSG_DEBUG, "Skip roam - too small difference "
994 #else /* CONFIG_NO_ROAMING */
996 #endif /* CONFIG_NO_ROAMING */
1000 /* Return < 0 if no scan results could be fetched. */
1001 static int _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s,
1002 union wpa_event_data *data)
1004 struct wpa_bss *selected;
1005 struct wpa_ssid *ssid = NULL;
1006 struct wpa_scan_results *scan_res;
1010 if (wpa_s->ap_iface)
1012 #endif /* CONFIG_AP */
1014 wpa_supplicant_notify_scanning(wpa_s, 0);
1017 if (wpa_s->p2p_cb_on_scan_complete && !wpa_s->global->p2p_disabled &&
1018 wpa_s->global->p2p != NULL) {
1019 wpa_s->p2p_cb_on_scan_complete = 0;
1020 if (p2p_other_scan_completed(wpa_s->global->p2p) == 1) {
1021 wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Pending P2P operation "
1022 "stopped scan processing");
1026 #endif /* CONFIG_P2P */
1028 scan_res = wpa_supplicant_get_scan_results(wpa_s,
1029 data ? &data->scan_info :
1031 if (scan_res == NULL) {
1032 if (wpa_s->conf->ap_scan == 2 || ap)
1034 wpa_dbg(wpa_s, MSG_DEBUG, "Failed to get scan results - try "
1036 wpa_supplicant_req_new_scan(wpa_s, 1, 0);
1040 #ifndef CONFIG_NO_RANDOM_POOL
1042 num = scan_res->num;
1045 for (i = 0; i < num; i++) {
1047 struct wpa_scan_res *res = scan_res->res[i];
1048 buf[0] = res->bssid[5];
1049 buf[1] = res->qual & 0xff;
1050 buf[2] = res->noise & 0xff;
1051 buf[3] = res->level & 0xff;
1052 buf[4] = res->tsf & 0xff;
1053 random_add_randomness(buf, sizeof(buf));
1055 #endif /* CONFIG_NO_RANDOM_POOL */
1057 if (wpa_s->scan_res_handler) {
1058 void (*scan_res_handler)(struct wpa_supplicant *wpa_s,
1059 struct wpa_scan_results *scan_res);
1061 scan_res_handler = wpa_s->scan_res_handler;
1062 wpa_s->scan_res_handler = NULL;
1063 scan_res_handler(wpa_s, scan_res);
1065 wpa_scan_results_free(scan_res);
1070 wpa_dbg(wpa_s, MSG_DEBUG, "Ignore scan results in AP mode");
1072 if (wpa_s->ap_iface->scan_cb)
1073 wpa_s->ap_iface->scan_cb(wpa_s->ap_iface);
1074 #endif /* CONFIG_AP */
1075 wpa_scan_results_free(scan_res);
1079 wpa_dbg(wpa_s, MSG_DEBUG, "New scan results available");
1080 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_SCAN_RESULTS);
1081 wpas_notify_scan_results(wpa_s);
1083 wpas_notify_scan_done(wpa_s, 1);
1085 if (sme_proc_obss_scan(wpa_s) > 0) {
1086 wpa_scan_results_free(scan_res);
1090 if ((wpa_s->conf->ap_scan == 2 && !wpas_wps_searching(wpa_s))) {
1091 wpa_scan_results_free(scan_res);
1095 if (wpa_s->disconnected) {
1096 wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
1097 wpa_scan_results_free(scan_res);
1101 if (!wpas_driver_bss_selection(wpa_s) &&
1102 bgscan_notify_scan(wpa_s, scan_res) == 1) {
1103 wpa_scan_results_free(scan_res);
1107 selected = wpa_supplicant_pick_network(wpa_s, scan_res, &ssid);
1111 skip = !wpa_supplicant_need_to_roam(wpa_s, selected, ssid,
1113 wpa_scan_results_free(scan_res);
1115 wpa_supplicant_rsn_preauth_scan_results(wpa_s);
1119 if (wpa_supplicant_connect(wpa_s, selected, ssid) < 0) {
1120 wpa_dbg(wpa_s, MSG_DEBUG, "Connect failed");
1123 wpa_supplicant_rsn_preauth_scan_results(wpa_s);
1125 wpa_scan_results_free(scan_res);
1126 wpa_dbg(wpa_s, MSG_DEBUG, "No suitable network found");
1127 ssid = wpa_supplicant_pick_new_network(wpa_s);
1129 wpa_dbg(wpa_s, MSG_DEBUG, "Setup a new network");
1130 wpa_supplicant_associate(wpa_s, NULL, ssid);
1131 wpa_supplicant_rsn_preauth_scan_results(wpa_s);
1133 int timeout_sec = wpa_s->scan_interval;
1134 int timeout_usec = 0;
1136 if (wpas_p2p_scan_no_go_seen(wpa_s) == 1)
1139 if (wpa_s->p2p_in_provisioning) {
1141 * Use shorter wait during P2P Provisioning
1142 * state to speed up group formation.
1145 timeout_usec = 250000;
1146 wpa_supplicant_req_new_scan(wpa_s, timeout_sec,
1150 #endif /* CONFIG_P2P */
1151 if (wpa_supplicant_req_sched_scan(wpa_s))
1152 wpa_supplicant_req_new_scan(wpa_s, timeout_sec,
1160 static void wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s,
1161 union wpa_event_data *data)
1163 const char *rn, *rn2;
1164 struct wpa_supplicant *ifs;
1166 if (_wpa_supplicant_event_scan_results(wpa_s, data) < 0) {
1168 * If no scan results could be fetched, then no need to
1169 * notify those interfaces that did not actually request
1176 * Check other interfaces to see if they have the same radio-name. If
1177 * so, they get updated with this same scan info.
1179 if (!wpa_s->driver->get_radio_name)
1182 rn = wpa_s->driver->get_radio_name(wpa_s->drv_priv);
1183 if (rn == NULL || rn[0] == '\0')
1186 wpa_dbg(wpa_s, MSG_DEBUG, "Checking for other virtual interfaces "
1187 "sharing same radio (%s) in event_scan_results", rn);
1189 for (ifs = wpa_s->global->ifaces; ifs; ifs = ifs->next) {
1190 if (ifs == wpa_s || !ifs->driver->get_radio_name)
1193 rn2 = ifs->driver->get_radio_name(ifs->drv_priv);
1194 if (rn2 && os_strcmp(rn, rn2) == 0) {
1195 wpa_printf(MSG_DEBUG, "%s: Updating scan results from "
1196 "sibling", ifs->ifname);
1197 _wpa_supplicant_event_scan_results(ifs, data);
1202 #endif /* CONFIG_NO_SCAN_PROCESSING */
1207 static void wnm_bss_keep_alive(void *eloop_ctx, void *sock_ctx)
1209 struct wpa_supplicant *wpa_s = eloop_ctx;
1211 if (wpa_s->wpa_state < WPA_ASSOCIATED)
1214 wpa_printf(MSG_DEBUG, "WNM: Send keep-alive");
1215 /* TODO: could skip this if normal data traffic has been sent */
1216 /* TODO: send keep alive frame - better use some short unicast data
1217 * frame that gets protected if PTK is set */
1220 if (wpa_s->sme.bss_max_idle_period) {
1222 msec = wpa_s->sme.bss_max_idle_period * 1024; /* times 1000 */
1225 eloop_register_timeout(msec / 1000, msec % 1000 * 1000,
1226 wnm_bss_keep_alive, wpa_s, NULL);
1228 #endif /* CONFIG_SME */
1232 static void wnm_process_assoc_resp(struct wpa_supplicant *wpa_s,
1233 const u8 *ies, size_t ies_len)
1235 struct ieee802_11_elems elems;
1240 if (ieee802_11_parse_elems(ies, ies_len, &elems, 1) == ParseFailed)
1244 if (elems.bss_max_idle_period) {
1246 wpa_s->sme.bss_max_idle_period =
1247 WPA_GET_LE16(elems.bss_max_idle_period);
1248 wpa_printf(MSG_DEBUG, "WNM: BSS Max Idle Period: %u (* 1000 "
1249 "TU)%s", wpa_s->sme.bss_max_idle_period,
1250 (elems.bss_max_idle_period[2] & 0x01) ?
1251 " (protected keep-live required)" : "");
1252 if (wpa_s->sme.bss_max_idle_period == 0)
1253 wpa_s->sme.bss_max_idle_period = 1;
1254 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME) {
1255 eloop_cancel_timeout(wnm_bss_keep_alive, wpa_s, NULL);
1256 /* msec times 1000 */
1257 msec = wpa_s->sme.bss_max_idle_period * 1024;
1260 eloop_register_timeout(msec / 1000, msec % 1000 * 1000,
1261 wnm_bss_keep_alive, wpa_s,
1265 #endif /* CONFIG_SME */
1268 #endif /* CONFIG_WNM */
1271 void wnm_bss_keep_alive_deinit(struct wpa_supplicant *wpa_s)
1274 eloop_cancel_timeout(wnm_bss_keep_alive, wpa_s, NULL);
1275 #endif /* CONFIG_WNM */
1279 static int wpa_supplicant_event_associnfo(struct wpa_supplicant *wpa_s,
1280 union wpa_event_data *data)
1282 int l, len, found = 0, wpa_found, rsn_found;
1285 wpa_dbg(wpa_s, MSG_DEBUG, "Association info event");
1286 if (data->assoc_info.req_ies)
1287 wpa_hexdump(MSG_DEBUG, "req_ies", data->assoc_info.req_ies,
1288 data->assoc_info.req_ies_len);
1289 if (data->assoc_info.resp_ies) {
1290 wpa_hexdump(MSG_DEBUG, "resp_ies", data->assoc_info.resp_ies,
1291 data->assoc_info.resp_ies_len);
1293 wpa_tdls_assoc_resp_ies(wpa_s->wpa, data->assoc_info.resp_ies,
1294 data->assoc_info.resp_ies_len);
1295 #endif /* CONFIG_TDLS */
1297 wnm_process_assoc_resp(wpa_s, data->assoc_info.resp_ies,
1298 data->assoc_info.resp_ies_len);
1299 #endif /* CONFIG_WNM */
1301 if (data->assoc_info.beacon_ies)
1302 wpa_hexdump(MSG_DEBUG, "beacon_ies",
1303 data->assoc_info.beacon_ies,
1304 data->assoc_info.beacon_ies_len);
1305 if (data->assoc_info.freq)
1306 wpa_dbg(wpa_s, MSG_DEBUG, "freq=%u MHz",
1307 data->assoc_info.freq);
1309 p = data->assoc_info.req_ies;
1310 l = data->assoc_info.req_ies_len;
1312 /* Go through the IEs and make a copy of the WPA/RSN IE, if present. */
1313 while (p && l >= 2) {
1316 wpa_hexdump(MSG_DEBUG, "Truncated IE in assoc_info",
1320 if ((p[0] == WLAN_EID_VENDOR_SPECIFIC && p[1] >= 6 &&
1321 (os_memcmp(&p[2], "\x00\x50\xF2\x01\x01\x00", 6) == 0)) ||
1322 (p[0] == WLAN_EID_RSN && p[1] >= 2)) {
1323 if (wpa_sm_set_assoc_wpa_ie(wpa_s->wpa, p, len))
1326 wpa_find_assoc_pmkid(wpa_s);
1332 if (!found && data->assoc_info.req_ies)
1333 wpa_sm_set_assoc_wpa_ie(wpa_s->wpa, NULL, 0);
1335 #ifdef CONFIG_IEEE80211R
1337 if (wpa_s->sme.auth_alg == WPA_AUTH_ALG_FT) {
1339 if (wpa_drv_get_bssid(wpa_s, bssid) < 0 ||
1340 wpa_ft_validate_reassoc_resp(wpa_s->wpa,
1341 data->assoc_info.resp_ies,
1342 data->assoc_info.resp_ies_len,
1344 wpa_dbg(wpa_s, MSG_DEBUG, "FT: Validation of "
1345 "Reassociation Response failed");
1346 wpa_supplicant_deauthenticate(
1347 wpa_s, WLAN_REASON_INVALID_IE);
1352 p = data->assoc_info.resp_ies;
1353 l = data->assoc_info.resp_ies_len;
1355 #ifdef CONFIG_WPS_STRICT
1356 if (p && wpa_s->current_ssid &&
1357 wpa_s->current_ssid->key_mgmt == WPA_KEY_MGMT_WPS) {
1359 wps = ieee802_11_vendor_ie_concat(p, l, WPS_IE_VENDOR_TYPE);
1361 wpa_msg(wpa_s, MSG_INFO, "WPS-STRICT: AP did not "
1362 "include WPS IE in (Re)Association Response");
1366 if (wps_validate_assoc_resp(wps) < 0) {
1368 wpa_supplicant_deauthenticate(
1369 wpa_s, WLAN_REASON_INVALID_IE);
1374 #endif /* CONFIG_WPS_STRICT */
1376 /* Go through the IEs and make a copy of the MDIE, if present. */
1377 while (p && l >= 2) {
1380 wpa_hexdump(MSG_DEBUG, "Truncated IE in assoc_info",
1384 if (p[0] == WLAN_EID_MOBILITY_DOMAIN &&
1385 p[1] >= MOBILITY_DOMAIN_ID_LEN) {
1386 wpa_s->sme.ft_used = 1;
1387 os_memcpy(wpa_s->sme.mobility_domain, p + 2,
1388 MOBILITY_DOMAIN_ID_LEN);
1394 #endif /* CONFIG_SME */
1396 wpa_sm_set_ft_params(wpa_s->wpa, data->assoc_info.resp_ies,
1397 data->assoc_info.resp_ies_len);
1398 #endif /* CONFIG_IEEE80211R */
1400 /* WPA/RSN IE from Beacon/ProbeResp */
1401 p = data->assoc_info.beacon_ies;
1402 l = data->assoc_info.beacon_ies_len;
1404 /* Go through the IEs and make a copy of the WPA/RSN IEs, if present.
1406 wpa_found = rsn_found = 0;
1407 while (p && l >= 2) {
1410 wpa_hexdump(MSG_DEBUG, "Truncated IE in beacon_ies",
1415 p[0] == WLAN_EID_VENDOR_SPECIFIC && p[1] >= 6 &&
1416 os_memcmp(&p[2], "\x00\x50\xF2\x01\x01\x00", 6) == 0) {
1418 wpa_sm_set_ap_wpa_ie(wpa_s->wpa, p, len);
1422 p[0] == WLAN_EID_RSN && p[1] >= 2) {
1424 wpa_sm_set_ap_rsn_ie(wpa_s->wpa, p, len);
1431 if (!wpa_found && data->assoc_info.beacon_ies)
1432 wpa_sm_set_ap_wpa_ie(wpa_s->wpa, NULL, 0);
1433 if (!rsn_found && data->assoc_info.beacon_ies)
1434 wpa_sm_set_ap_rsn_ie(wpa_s->wpa, NULL, 0);
1435 if (wpa_found || rsn_found)
1436 wpa_s->ap_ies_from_associnfo = 1;
1438 if (wpa_s->assoc_freq && data->assoc_info.freq &&
1439 wpa_s->assoc_freq != data->assoc_info.freq) {
1440 wpa_printf(MSG_DEBUG, "Operating frequency changed from "
1442 wpa_s->assoc_freq, data->assoc_info.freq);
1443 wpa_supplicant_update_scan_results(wpa_s);
1446 wpa_s->assoc_freq = data->assoc_info.freq;
1452 static struct wpa_bss * wpa_supplicant_get_new_bss(
1453 struct wpa_supplicant *wpa_s, const u8 *bssid)
1455 struct wpa_bss *bss = NULL;
1456 struct wpa_ssid *ssid = wpa_s->current_ssid;
1458 if (ssid->ssid_len > 0)
1459 bss = wpa_bss_get(wpa_s, bssid, ssid->ssid, ssid->ssid_len);
1461 bss = wpa_bss_get_bssid(wpa_s, bssid);
1467 static int wpa_supplicant_assoc_update_ie(struct wpa_supplicant *wpa_s)
1469 const u8 *bss_wpa = NULL, *bss_rsn = NULL;
1471 if (!wpa_s->current_bss || !wpa_s->current_ssid)
1474 if (!wpa_key_mgmt_wpa_any(wpa_s->current_ssid->key_mgmt))
1477 bss_wpa = wpa_bss_get_vendor_ie(wpa_s->current_bss,
1478 WPA_IE_VENDOR_TYPE);
1479 bss_rsn = wpa_bss_get_ie(wpa_s->current_bss, WLAN_EID_RSN);
1481 if (wpa_sm_set_ap_wpa_ie(wpa_s->wpa, bss_wpa,
1482 bss_wpa ? 2 + bss_wpa[1] : 0) ||
1483 wpa_sm_set_ap_rsn_ie(wpa_s->wpa, bss_rsn,
1484 bss_rsn ? 2 + bss_rsn[1] : 0))
1491 static void wpa_supplicant_event_assoc(struct wpa_supplicant *wpa_s,
1492 union wpa_event_data *data)
1497 struct wpa_driver_capa capa;
1500 if (wpa_s->ap_iface) {
1501 hostapd_notif_assoc(wpa_s->ap_iface->bss[0],
1502 data->assoc_info.addr,
1503 data->assoc_info.req_ies,
1504 data->assoc_info.req_ies_len,
1505 data->assoc_info.reassoc);
1508 #endif /* CONFIG_AP */
1510 ft_completed = wpa_ft_is_completed(wpa_s->wpa);
1511 if (data && wpa_supplicant_event_associnfo(wpa_s, data) < 0)
1514 wpa_supplicant_set_state(wpa_s, WPA_ASSOCIATED);
1515 if (wpa_drv_get_bssid(wpa_s, bssid) >= 0 &&
1516 os_memcmp(bssid, wpa_s->bssid, ETH_ALEN) != 0) {
1517 wpa_dbg(wpa_s, MSG_DEBUG, "Associated to a new BSS: BSSID="
1518 MACSTR, MAC2STR(bssid));
1519 random_add_randomness(bssid, ETH_ALEN);
1520 bssid_changed = os_memcmp(wpa_s->bssid, bssid, ETH_ALEN);
1521 os_memcpy(wpa_s->bssid, bssid, ETH_ALEN);
1522 os_memset(wpa_s->pending_bssid, 0, ETH_ALEN);
1524 wpas_notify_bssid_changed(wpa_s);
1526 if (wpa_supplicant_dynamic_keys(wpa_s) && !ft_completed) {
1527 wpa_clear_keys(wpa_s, bssid);
1529 if (wpa_supplicant_select_config(wpa_s) < 0) {
1530 wpa_supplicant_disassociate(
1531 wpa_s, WLAN_REASON_DEAUTH_LEAVING);
1534 if (wpa_s->current_ssid) {
1535 struct wpa_bss *bss = NULL;
1537 bss = wpa_supplicant_get_new_bss(wpa_s, bssid);
1539 wpa_supplicant_update_scan_results(wpa_s);
1541 /* Get the BSS from the new scan results */
1542 bss = wpa_supplicant_get_new_bss(wpa_s, bssid);
1546 wpa_s->current_bss = bss;
1549 if (wpa_s->conf->ap_scan == 1 &&
1550 wpa_s->drv_flags & WPA_DRIVER_FLAGS_BSS_SELECTION) {
1551 if (wpa_supplicant_assoc_update_ie(wpa_s) < 0)
1552 wpa_msg(wpa_s, MSG_WARNING,
1553 "WPA/RSN IEs not updated");
1558 os_memcpy(wpa_s->sme.prev_bssid, bssid, ETH_ALEN);
1559 wpa_s->sme.prev_bssid_set = 1;
1560 #endif /* CONFIG_SME */
1562 wpa_msg(wpa_s, MSG_INFO, "Associated with " MACSTR, MAC2STR(bssid));
1563 if (wpa_s->current_ssid) {
1564 /* When using scanning (ap_scan=1), SIM PC/SC interface can be
1565 * initialized before association, but for other modes,
1566 * initialize PC/SC here, if the current configuration needs
1567 * smartcard or SIM/USIM. */
1568 wpa_supplicant_scard_init(wpa_s, wpa_s->current_ssid);
1570 wpa_sm_notify_assoc(wpa_s->wpa, bssid);
1572 l2_packet_notify_auth_start(wpa_s->l2);
1575 * Set portEnabled first to FALSE in order to get EAP state machine out
1576 * of the SUCCESS state and eapSuccess cleared. Without this, EAPOL PAE
1577 * state machine may transit to AUTHENTICATING state based on obsolete
1578 * eapSuccess and then trigger BE_AUTH to SUCCESS and PAE to
1579 * AUTHENTICATED without ever giving chance to EAP state machine to
1582 if (!ft_completed) {
1583 eapol_sm_notify_portEnabled(wpa_s->eapol, FALSE);
1584 eapol_sm_notify_portValid(wpa_s->eapol, FALSE);
1586 if (wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt) || ft_completed)
1587 eapol_sm_notify_eap_success(wpa_s->eapol, FALSE);
1588 /* 802.1X::portControl = Auto */
1589 eapol_sm_notify_portEnabled(wpa_s->eapol, TRUE);
1590 wpa_s->eapol_received = 0;
1591 if (wpa_s->key_mgmt == WPA_KEY_MGMT_NONE ||
1592 wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE ||
1593 (wpa_s->current_ssid &&
1594 wpa_s->current_ssid->mode == IEEE80211_MODE_IBSS)) {
1595 wpa_supplicant_cancel_auth_timeout(wpa_s);
1596 wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
1597 } else if (!ft_completed) {
1598 /* Timeout for receiving the first EAPOL packet */
1599 wpa_supplicant_req_auth_timeout(wpa_s, 10, 0);
1601 wpa_supplicant_cancel_scan(wpa_s);
1603 if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE) &&
1604 wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt)) {
1606 * We are done; the driver will take care of RSN 4-way
1609 wpa_supplicant_cancel_auth_timeout(wpa_s);
1610 wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
1611 eapol_sm_notify_portValid(wpa_s->eapol, TRUE);
1612 eapol_sm_notify_eap_success(wpa_s->eapol, TRUE);
1613 } else if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE) &&
1614 wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt)) {
1616 * The driver will take care of RSN 4-way handshake, so we need
1617 * to allow EAPOL supplicant to complete its work without
1618 * waiting for WPA supplicant.
1620 eapol_sm_notify_portValid(wpa_s->eapol, TRUE);
1621 } else if (ft_completed) {
1623 * FT protocol completed - make sure EAPOL state machine ends
1624 * up in authenticated.
1626 wpa_supplicant_cancel_auth_timeout(wpa_s);
1627 wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
1628 eapol_sm_notify_portValid(wpa_s->eapol, TRUE);
1629 eapol_sm_notify_eap_success(wpa_s->eapol, TRUE);
1632 if (wpa_s->pending_eapol_rx) {
1633 struct os_time now, age;
1635 os_time_sub(&now, &wpa_s->pending_eapol_rx_time, &age);
1636 if (age.sec == 0 && age.usec < 100000 &&
1637 os_memcmp(wpa_s->pending_eapol_rx_src, bssid, ETH_ALEN) ==
1639 wpa_dbg(wpa_s, MSG_DEBUG, "Process pending EAPOL "
1640 "frame that was received just before "
1641 "association notification");
1642 wpa_supplicant_rx_eapol(
1643 wpa_s, wpa_s->pending_eapol_rx_src,
1644 wpabuf_head(wpa_s->pending_eapol_rx),
1645 wpabuf_len(wpa_s->pending_eapol_rx));
1647 wpabuf_free(wpa_s->pending_eapol_rx);
1648 wpa_s->pending_eapol_rx = NULL;
1651 if ((wpa_s->key_mgmt == WPA_KEY_MGMT_NONE ||
1652 wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA) &&
1653 wpa_s->current_ssid && wpa_drv_get_capa(wpa_s, &capa) == 0 &&
1654 capa.flags & WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC_DONE) {
1655 /* Set static WEP keys again */
1656 wpa_set_wep_keys(wpa_s, wpa_s->current_ssid);
1659 #ifdef CONFIG_IBSS_RSN
1660 if (wpa_s->current_ssid &&
1661 wpa_s->current_ssid->mode == WPAS_MODE_IBSS &&
1662 wpa_s->key_mgmt != WPA_KEY_MGMT_NONE &&
1663 wpa_s->key_mgmt != WPA_KEY_MGMT_WPA_NONE &&
1664 wpa_s->ibss_rsn == NULL) {
1665 wpa_s->ibss_rsn = ibss_rsn_init(wpa_s);
1666 if (!wpa_s->ibss_rsn) {
1667 wpa_msg(wpa_s, MSG_INFO, "Failed to init IBSS RSN");
1668 wpa_supplicant_deauthenticate(
1669 wpa_s, WLAN_REASON_DEAUTH_LEAVING);
1673 ibss_rsn_set_psk(wpa_s->ibss_rsn, wpa_s->current_ssid->psk);
1675 #endif /* CONFIG_IBSS_RSN */
1679 static int disconnect_reason_recoverable(u16 reason_code)
1681 return reason_code == WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY ||
1682 reason_code == WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA ||
1683 reason_code == WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA;
1687 static void wpa_supplicant_event_disassoc(struct wpa_supplicant *wpa_s,
1689 int locally_generated)
1693 u8 prev_pending_bssid[ETH_ALEN];
1694 struct wpa_bss *fast_reconnect = NULL;
1695 struct wpa_ssid *fast_reconnect_ssid = NULL;
1697 authenticating = wpa_s->wpa_state == WPA_AUTHENTICATING;
1698 os_memcpy(prev_pending_bssid, wpa_s->pending_bssid, ETH_ALEN);
1700 if (wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE) {
1702 * At least Host AP driver and a Prism3 card seemed to be
1703 * generating streams of disconnected events when configuring
1704 * IBSS for WPA-None. Ignore them for now.
1706 wpa_dbg(wpa_s, MSG_DEBUG, "Disconnect event - ignore in "
1707 "IBSS/WPA-None mode");
1711 if (wpa_s->wpa_state == WPA_4WAY_HANDSHAKE &&
1712 wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt)) {
1713 wpa_msg(wpa_s, MSG_INFO, "WPA: 4-Way Handshake failed - "
1714 "pre-shared key may be incorrect");
1716 if (!wpa_s->auto_reconnect_disabled ||
1717 wpa_s->key_mgmt == WPA_KEY_MGMT_WPS) {
1718 wpa_dbg(wpa_s, MSG_DEBUG, "Auto connect enabled: try to "
1719 "reconnect (wps=%d wpa_state=%d)",
1720 wpa_s->key_mgmt == WPA_KEY_MGMT_WPS,
1722 if (wpa_s->wpa_state == WPA_COMPLETED &&
1723 wpa_s->current_ssid &&
1724 wpa_s->current_ssid->mode == WPAS_MODE_INFRA &&
1725 !locally_generated &&
1726 disconnect_reason_recoverable(reason_code)) {
1728 * It looks like the AP has dropped association with
1729 * us, but could allow us to get back in. Try to
1730 * reconnect to the same BSS without full scan to save
1731 * time for some common cases.
1733 fast_reconnect = wpa_s->current_bss;
1734 fast_reconnect_ssid = wpa_s->current_ssid;
1735 } else if (wpa_s->wpa_state >= WPA_ASSOCIATING)
1736 wpa_supplicant_req_scan(wpa_s, 0, 100000);
1738 wpa_dbg(wpa_s, MSG_DEBUG, "Do not request new "
1741 wpa_dbg(wpa_s, MSG_DEBUG, "Auto connect disabled: do not "
1742 "try to re-connect");
1743 wpa_s->reassociate = 0;
1744 wpa_s->disconnected = 1;
1745 wpa_supplicant_cancel_sched_scan(wpa_s);
1747 bssid = wpa_s->bssid;
1748 if (is_zero_ether_addr(bssid))
1749 bssid = wpa_s->pending_bssid;
1750 if (wpa_s->wpa_state >= WPA_AUTHENTICATING)
1751 wpas_connection_failed(wpa_s, bssid);
1752 wpa_sm_notify_disassoc(wpa_s->wpa);
1753 if (!is_zero_ether_addr(bssid) ||
1754 wpa_s->wpa_state >= WPA_AUTHENTICATING) {
1755 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_DISCONNECTED "bssid=" MACSTR
1757 MAC2STR(bssid), reason_code,
1758 locally_generated ? " locally_generated=1" : "");
1760 if (wpa_supplicant_dynamic_keys(wpa_s)) {
1761 wpa_dbg(wpa_s, MSG_DEBUG, "Disconnect event - remove keys");
1762 wpa_s->keys_cleared = 0;
1763 wpa_clear_keys(wpa_s, wpa_s->bssid);
1765 wpa_supplicant_mark_disassoc(wpa_s);
1767 if (authenticating && (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME))
1768 sme_disassoc_while_authenticating(wpa_s, prev_pending_bssid);
1770 if (fast_reconnect) {
1771 #ifndef CONFIG_NO_SCAN_PROCESSING
1772 wpa_dbg(wpa_s, MSG_DEBUG, "Try to reconnect to the same BSS");
1773 if (wpa_supplicant_connect(wpa_s, fast_reconnect,
1774 fast_reconnect_ssid) < 0) {
1775 /* Recover through full scan */
1776 wpa_supplicant_req_scan(wpa_s, 0, 100000);
1778 #endif /* CONFIG_NO_SCAN_PROCESSING */
1783 #ifdef CONFIG_DELAYED_MIC_ERROR_REPORT
1784 void wpa_supplicant_delayed_mic_error_report(void *eloop_ctx, void *sock_ctx)
1786 struct wpa_supplicant *wpa_s = eloop_ctx;
1788 if (!wpa_s->pending_mic_error_report)
1791 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: Sending pending MIC error report");
1792 wpa_sm_key_request(wpa_s->wpa, 1, wpa_s->pending_mic_error_pairwise);
1793 wpa_s->pending_mic_error_report = 0;
1795 #endif /* CONFIG_DELAYED_MIC_ERROR_REPORT */
1799 wpa_supplicant_event_michael_mic_failure(struct wpa_supplicant *wpa_s,
1800 union wpa_event_data *data)
1805 wpa_msg(wpa_s, MSG_WARNING, "Michael MIC failure detected");
1806 pairwise = (data && data->michael_mic_failure.unicast);
1808 if ((wpa_s->last_michael_mic_error &&
1809 t.sec - wpa_s->last_michael_mic_error <= 60) ||
1810 wpa_s->pending_mic_error_report) {
1811 if (wpa_s->pending_mic_error_report) {
1813 * Send the pending MIC error report immediately since
1814 * we are going to start countermeasures and AP better
1817 wpa_sm_key_request(wpa_s->wpa, 1,
1818 wpa_s->pending_mic_error_pairwise);
1821 /* Send the new MIC error report immediately since we are going
1822 * to start countermeasures and AP better do the same.
1824 wpa_sm_key_request(wpa_s->wpa, 1, pairwise);
1826 /* initialize countermeasures */
1827 wpa_s->countermeasures = 1;
1829 wpa_blacklist_add(wpa_s, wpa_s->bssid);
1831 wpa_msg(wpa_s, MSG_WARNING, "TKIP countermeasures started");
1834 * Need to wait for completion of request frame. We do not get
1835 * any callback for the message completion, so just wait a
1836 * short while and hope for the best. */
1839 wpa_drv_set_countermeasures(wpa_s, 1);
1840 wpa_supplicant_deauthenticate(wpa_s,
1841 WLAN_REASON_MICHAEL_MIC_FAILURE);
1842 eloop_cancel_timeout(wpa_supplicant_stop_countermeasures,
1844 eloop_register_timeout(60, 0,
1845 wpa_supplicant_stop_countermeasures,
1847 /* TODO: mark the AP rejected for 60 second. STA is
1848 * allowed to associate with another AP.. */
1850 #ifdef CONFIG_DELAYED_MIC_ERROR_REPORT
1851 if (wpa_s->mic_errors_seen) {
1853 * Reduce the effectiveness of Michael MIC error
1854 * reports as a means for attacking against TKIP if
1855 * more than one MIC failure is noticed with the same
1856 * PTK. We delay the transmission of the reports by a
1857 * random time between 0 and 60 seconds in order to
1858 * force the attacker wait 60 seconds before getting
1859 * the information on whether a frame resulted in a MIC
1865 if (os_get_random(rval, sizeof(rval)) < 0)
1866 sec = os_random() % 60;
1868 sec = WPA_GET_BE32(rval) % 60;
1869 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: Delay MIC error "
1870 "report %d seconds", sec);
1871 wpa_s->pending_mic_error_report = 1;
1872 wpa_s->pending_mic_error_pairwise = pairwise;
1873 eloop_cancel_timeout(
1874 wpa_supplicant_delayed_mic_error_report,
1876 eloop_register_timeout(
1877 sec, os_random() % 1000000,
1878 wpa_supplicant_delayed_mic_error_report,
1881 wpa_sm_key_request(wpa_s->wpa, 1, pairwise);
1883 #else /* CONFIG_DELAYED_MIC_ERROR_REPORT */
1884 wpa_sm_key_request(wpa_s->wpa, 1, pairwise);
1885 #endif /* CONFIG_DELAYED_MIC_ERROR_REPORT */
1887 wpa_s->last_michael_mic_error = t.sec;
1888 wpa_s->mic_errors_seen++;
1892 #ifdef CONFIG_TERMINATE_ONLASTIF
1893 static int any_interfaces(struct wpa_supplicant *head)
1895 struct wpa_supplicant *wpa_s;
1897 for (wpa_s = head; wpa_s != NULL; wpa_s = wpa_s->next)
1898 if (!wpa_s->interface_removed)
1902 #endif /* CONFIG_TERMINATE_ONLASTIF */
1906 wpa_supplicant_event_interface_status(struct wpa_supplicant *wpa_s,
1907 union wpa_event_data *data)
1909 if (os_strcmp(wpa_s->ifname, data->interface_status.ifname) != 0)
1912 switch (data->interface_status.ievent) {
1913 case EVENT_INTERFACE_ADDED:
1914 if (!wpa_s->interface_removed)
1916 wpa_s->interface_removed = 0;
1917 wpa_dbg(wpa_s, MSG_DEBUG, "Configured interface was added");
1918 if (wpa_supplicant_driver_init(wpa_s) < 0) {
1919 wpa_msg(wpa_s, MSG_INFO, "Failed to initialize the "
1920 "driver after interface was added");
1922 wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
1924 case EVENT_INTERFACE_REMOVED:
1925 wpa_dbg(wpa_s, MSG_DEBUG, "Configured interface was removed");
1926 wpa_s->interface_removed = 1;
1927 wpa_supplicant_mark_disassoc(wpa_s);
1928 wpa_supplicant_set_state(wpa_s, WPA_INTERFACE_DISABLED);
1929 l2_packet_deinit(wpa_s->l2);
1931 #ifdef CONFIG_IBSS_RSN
1932 ibss_rsn_deinit(wpa_s->ibss_rsn);
1933 wpa_s->ibss_rsn = NULL;
1934 #endif /* CONFIG_IBSS_RSN */
1935 #ifdef CONFIG_TERMINATE_ONLASTIF
1936 /* check if last interface */
1937 if (!any_interfaces(wpa_s->global->ifaces))
1939 #endif /* CONFIG_TERMINATE_ONLASTIF */
1945 #ifdef CONFIG_PEERKEY
1947 wpa_supplicant_event_stkstart(struct wpa_supplicant *wpa_s,
1948 union wpa_event_data *data)
1952 wpa_sm_stkstart(wpa_s->wpa, data->stkstart.peer);
1954 #endif /* CONFIG_PEERKEY */
1958 static void wpa_supplicant_event_tdls(struct wpa_supplicant *wpa_s,
1959 union wpa_event_data *data)
1963 switch (data->tdls.oper) {
1964 case TDLS_REQUEST_SETUP:
1965 wpa_tdls_start(wpa_s->wpa, data->tdls.peer);
1967 case TDLS_REQUEST_TEARDOWN:
1968 wpa_tdls_send_teardown(wpa_s->wpa, data->tdls.peer,
1969 data->tdls.reason_code);
1973 #endif /* CONFIG_TDLS */
1976 #ifdef CONFIG_IEEE80211R
1978 wpa_supplicant_event_ft_response(struct wpa_supplicant *wpa_s,
1979 union wpa_event_data *data)
1984 if (wpa_ft_process_response(wpa_s->wpa, data->ft_ies.ies,
1985 data->ft_ies.ies_len,
1986 data->ft_ies.ft_action,
1987 data->ft_ies.target_ap,
1988 data->ft_ies.ric_ies,
1989 data->ft_ies.ric_ies_len) < 0) {
1990 /* TODO: prevent MLME/driver from trying to associate? */
1993 #endif /* CONFIG_IEEE80211R */
1996 #ifdef CONFIG_IBSS_RSN
1997 static void wpa_supplicant_event_ibss_rsn_start(struct wpa_supplicant *wpa_s,
1998 union wpa_event_data *data)
2000 struct wpa_ssid *ssid;
2001 if (wpa_s->wpa_state < WPA_ASSOCIATED)
2005 ssid = wpa_s->current_ssid;
2008 if (ssid->mode != WPAS_MODE_IBSS || !wpa_key_mgmt_wpa(ssid->key_mgmt))
2011 ibss_rsn_start(wpa_s->ibss_rsn, data->ibss_rsn_start.peer);
2013 #endif /* CONFIG_IBSS_RSN */
2016 #ifdef CONFIG_IEEE80211R
2017 static void ft_rx_action(struct wpa_supplicant *wpa_s, const u8 *data,
2020 const u8 *sta_addr, *target_ap_addr;
2023 wpa_hexdump(MSG_MSGDUMP, "FT: RX Action", data, len);
2024 if (!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME))
2025 return; /* only SME case supported for now */
2026 if (len < 1 + 2 * ETH_ALEN + 2)
2029 return; /* Only FT Action Response is supported for now */
2030 sta_addr = data + 1;
2031 target_ap_addr = data + 1 + ETH_ALEN;
2032 status = WPA_GET_LE16(data + 1 + 2 * ETH_ALEN);
2033 wpa_dbg(wpa_s, MSG_DEBUG, "FT: Received FT Action Response: STA "
2034 MACSTR " TargetAP " MACSTR " status %u",
2035 MAC2STR(sta_addr), MAC2STR(target_ap_addr), status);
2037 if (os_memcmp(sta_addr, wpa_s->own_addr, ETH_ALEN) != 0) {
2038 wpa_dbg(wpa_s, MSG_DEBUG, "FT: Foreign STA Address " MACSTR
2039 " in FT Action Response", MAC2STR(sta_addr));
2044 wpa_dbg(wpa_s, MSG_DEBUG, "FT: FT Action Response indicates "
2045 "failure (status code %d)", status);
2046 /* TODO: report error to FT code(?) */
2050 if (wpa_ft_process_response(wpa_s->wpa, data + 1 + 2 * ETH_ALEN + 2,
2051 len - (1 + 2 * ETH_ALEN + 2), 1,
2052 target_ap_addr, NULL, 0) < 0)
2057 struct wpa_bss *bss;
2058 bss = wpa_bss_get_bssid(wpa_s, target_ap_addr);
2060 wpa_s->sme.freq = bss->freq;
2061 wpa_s->sme.auth_alg = WPA_AUTH_ALG_FT;
2062 sme_associate(wpa_s, WPAS_MODE_INFRA, target_ap_addr,
2065 #endif /* CONFIG_SME */
2067 #endif /* CONFIG_IEEE80211R */
2070 static void wpa_supplicant_event_unprot_deauth(struct wpa_supplicant *wpa_s,
2071 struct unprot_deauth *e)
2073 #ifdef CONFIG_IEEE80211W
2074 wpa_printf(MSG_DEBUG, "Unprotected Deauthentication frame "
2075 "dropped: " MACSTR " -> " MACSTR
2076 " (reason code %u)",
2077 MAC2STR(e->sa), MAC2STR(e->da), e->reason_code);
2078 sme_event_unprot_disconnect(wpa_s, e->sa, e->da, e->reason_code);
2079 #endif /* CONFIG_IEEE80211W */
2083 static void wpa_supplicant_event_unprot_disassoc(struct wpa_supplicant *wpa_s,
2084 struct unprot_disassoc *e)
2086 #ifdef CONFIG_IEEE80211W
2087 wpa_printf(MSG_DEBUG, "Unprotected Disassociation frame "
2088 "dropped: " MACSTR " -> " MACSTR
2089 " (reason code %u)",
2090 MAC2STR(e->sa), MAC2STR(e->da), e->reason_code);
2091 sme_event_unprot_disconnect(wpa_s, e->sa, e->da, e->reason_code);
2092 #endif /* CONFIG_IEEE80211W */
2096 static void wnm_action_rx(struct wpa_supplicant *wpa_s, struct rx_action *rx)
2099 const u8 *pos, *end;
2101 if (rx->data == NULL || rx->len == 0)
2105 end = pos + rx->len;
2108 wpa_printf(MSG_DEBUG, "WNM: RX action %u from " MACSTR,
2109 action, MAC2STR(rx->sa));
2111 case WNM_BSS_TRANS_MGMT_REQ:
2114 wpa_printf(MSG_DEBUG, "WNM: BSS Transition Management "
2115 "Request: dialog_token=%u request_mode=0x%x "
2116 "disassoc_timer=%u validity_interval=%u",
2117 pos[0], pos[1], WPA_GET_LE16(pos + 2), pos[4]);
2121 pos += 12; /* BSS Termination Duration */
2124 if (pos + 1 > end || pos + 1 + pos[0] > end) {
2125 wpa_printf(MSG_DEBUG, "WNM: Invalid BSS "
2126 "Transition Management Request "
2130 os_memcpy(url, pos + 1, pos[0]);
2132 wpa_msg(wpa_s, MSG_INFO, "WNM: ESS Disassociation "
2133 "Imminent - session_info_url=%s", url);
2140 void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
2141 union wpa_event_data *data)
2143 struct wpa_supplicant *wpa_s = ctx;
2144 u16 reason_code = 0;
2145 int locally_generated = 0;
2147 if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED &&
2148 event != EVENT_INTERFACE_ENABLED &&
2149 event != EVENT_INTERFACE_STATUS &&
2150 event != EVENT_SCHED_SCAN_STOPPED) {
2151 wpa_dbg(wpa_s, MSG_DEBUG,
2152 "Ignore event %s (%d) while interface is disabled",
2153 event_to_string(event), event);
2157 #ifndef CONFIG_NO_STDOUT_DEBUG
2159 int level = MSG_DEBUG;
2161 if (event == EVENT_RX_MGMT && data->rx_mgmt.frame_len >= 24) {
2162 const struct ieee80211_hdr *hdr;
2164 hdr = (const struct ieee80211_hdr *) data->rx_mgmt.frame;
2165 fc = le_to_host16(hdr->frame_control);
2166 if (WLAN_FC_GET_TYPE(fc) == WLAN_FC_TYPE_MGMT &&
2167 WLAN_FC_GET_STYPE(fc) == WLAN_FC_STYPE_BEACON)
2168 level = MSG_EXCESSIVE;
2171 wpa_dbg(wpa_s, level, "Event %s (%d) received",
2172 event_to_string(event), event);
2174 #endif /* CONFIG_NO_STDOUT_DEBUG */
2178 sme_event_auth(wpa_s, data);
2181 wpa_supplicant_event_assoc(wpa_s, data);
2183 case EVENT_DISASSOC:
2184 wpa_dbg(wpa_s, MSG_DEBUG, "Disassociation notification");
2186 wpa_dbg(wpa_s, MSG_DEBUG, " * reason %u%s",
2187 data->disassoc_info.reason_code,
2188 data->disassoc_info.locally_generated ?
2189 " (locally generated)" : "");
2190 if (data->disassoc_info.addr)
2191 wpa_dbg(wpa_s, MSG_DEBUG, " * address " MACSTR,
2192 MAC2STR(data->disassoc_info.addr));
2195 if (wpa_s->ap_iface && data && data->disassoc_info.addr) {
2196 hostapd_notif_disassoc(wpa_s->ap_iface->bss[0],
2197 data->disassoc_info.addr);
2200 if (wpa_s->ap_iface) {
2201 wpa_dbg(wpa_s, MSG_DEBUG, "Ignore disassoc event in "
2205 #endif /* CONFIG_AP */
2207 reason_code = data->disassoc_info.reason_code;
2209 data->disassoc_info.locally_generated;
2210 wpa_hexdump(MSG_DEBUG, "Disassociation frame IE(s)",
2211 data->disassoc_info.ie,
2212 data->disassoc_info.ie_len);
2214 wpas_p2p_disassoc_notif(
2215 wpa_s, data->disassoc_info.addr, reason_code,
2216 data->disassoc_info.ie,
2217 data->disassoc_info.ie_len,
2219 #endif /* CONFIG_P2P */
2221 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
2222 sme_event_disassoc(wpa_s, data);
2225 if (event == EVENT_DEAUTH) {
2226 wpa_dbg(wpa_s, MSG_DEBUG,
2227 "Deauthentication notification");
2229 reason_code = data->deauth_info.reason_code;
2231 data->deauth_info.locally_generated;
2232 wpa_dbg(wpa_s, MSG_DEBUG, " * reason %u%s",
2233 data->deauth_info.reason_code,
2234 data->deauth_info.locally_generated ?
2235 " (locally generated)" : "");
2236 if (data->deauth_info.addr) {
2237 wpa_dbg(wpa_s, MSG_DEBUG, " * address "
2239 MAC2STR(data->deauth_info.
2242 wpa_hexdump(MSG_DEBUG,
2243 "Deauthentication frame IE(s)",
2244 data->deauth_info.ie,
2245 data->deauth_info.ie_len);
2249 if (wpa_s->ap_iface && data && data->deauth_info.addr) {
2250 hostapd_notif_disassoc(wpa_s->ap_iface->bss[0],
2251 data->deauth_info.addr);
2254 if (wpa_s->ap_iface) {
2255 wpa_dbg(wpa_s, MSG_DEBUG, "Ignore deauth event in "
2259 #endif /* CONFIG_AP */
2260 wpa_supplicant_event_disassoc(wpa_s, reason_code,
2263 if (event == EVENT_DEAUTH && data) {
2264 wpas_p2p_deauth_notif(wpa_s, data->deauth_info.addr,
2266 data->deauth_info.ie,
2267 data->deauth_info.ie_len,
2270 #endif /* CONFIG_P2P */
2272 case EVENT_MICHAEL_MIC_FAILURE:
2273 wpa_supplicant_event_michael_mic_failure(wpa_s, data);
2275 #ifndef CONFIG_NO_SCAN_PROCESSING
2276 case EVENT_SCAN_RESULTS:
2277 wpa_supplicant_event_scan_results(wpa_s, data);
2279 #endif /* CONFIG_NO_SCAN_PROCESSING */
2280 case EVENT_ASSOCINFO:
2281 wpa_supplicant_event_associnfo(wpa_s, data);
2283 case EVENT_INTERFACE_STATUS:
2284 wpa_supplicant_event_interface_status(wpa_s, data);
2286 case EVENT_PMKID_CANDIDATE:
2287 wpa_supplicant_event_pmkid_candidate(wpa_s, data);
2289 #ifdef CONFIG_PEERKEY
2290 case EVENT_STKSTART:
2291 wpa_supplicant_event_stkstart(wpa_s, data);
2293 #endif /* CONFIG_PEERKEY */
2296 wpa_supplicant_event_tdls(wpa_s, data);
2298 #endif /* CONFIG_TDLS */
2299 #ifdef CONFIG_IEEE80211R
2300 case EVENT_FT_RESPONSE:
2301 wpa_supplicant_event_ft_response(wpa_s, data);
2303 #endif /* CONFIG_IEEE80211R */
2304 #ifdef CONFIG_IBSS_RSN
2305 case EVENT_IBSS_RSN_START:
2306 wpa_supplicant_event_ibss_rsn_start(wpa_s, data);
2308 #endif /* CONFIG_IBSS_RSN */
2309 case EVENT_ASSOC_REJECT:
2310 if (data->assoc_reject.bssid)
2311 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_ASSOC_REJECT
2312 "bssid=" MACSTR " status_code=%u",
2313 MAC2STR(data->assoc_reject.bssid),
2314 data->assoc_reject.status_code);
2316 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_ASSOC_REJECT
2318 data->assoc_reject.status_code);
2319 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
2320 sme_event_assoc_reject(wpa_s, data);
2322 case EVENT_AUTH_TIMED_OUT:
2323 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
2324 sme_event_auth_timed_out(wpa_s, data);
2326 case EVENT_ASSOC_TIMED_OUT:
2327 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
2328 sme_event_assoc_timed_out(wpa_s, data);
2330 case EVENT_TX_STATUS:
2331 wpa_dbg(wpa_s, MSG_DEBUG, "EVENT_TX_STATUS dst=" MACSTR
2332 " type=%d stype=%d",
2333 MAC2STR(data->tx_status.dst),
2334 data->tx_status.type, data->tx_status.stype);
2336 if (wpa_s->ap_iface == NULL) {
2337 #ifdef CONFIG_OFFCHANNEL
2338 if (data->tx_status.type == WLAN_FC_TYPE_MGMT &&
2339 data->tx_status.stype == WLAN_FC_STYPE_ACTION)
2340 offchannel_send_action_tx_status(
2341 wpa_s, data->tx_status.dst,
2342 data->tx_status.data,
2343 data->tx_status.data_len,
2344 data->tx_status.ack ?
2345 OFFCHANNEL_SEND_ACTION_SUCCESS :
2346 OFFCHANNEL_SEND_ACTION_NO_ACK);
2347 #endif /* CONFIG_OFFCHANNEL */
2350 #endif /* CONFIG_AP */
2351 #ifdef CONFIG_OFFCHANNEL
2352 wpa_dbg(wpa_s, MSG_DEBUG, "EVENT_TX_STATUS pending_dst="
2353 MACSTR, MAC2STR(wpa_s->parent->pending_action_dst));
2355 * Catch TX status events for Action frames we sent via group
2356 * interface in GO mode.
2358 if (data->tx_status.type == WLAN_FC_TYPE_MGMT &&
2359 data->tx_status.stype == WLAN_FC_STYPE_ACTION &&
2360 os_memcmp(wpa_s->parent->pending_action_dst,
2361 data->tx_status.dst, ETH_ALEN) == 0) {
2362 offchannel_send_action_tx_status(
2363 wpa_s->parent, data->tx_status.dst,
2364 data->tx_status.data,
2365 data->tx_status.data_len,
2366 data->tx_status.ack ?
2367 OFFCHANNEL_SEND_ACTION_SUCCESS :
2368 OFFCHANNEL_SEND_ACTION_NO_ACK);
2371 #endif /* CONFIG_OFFCHANNEL */
2373 switch (data->tx_status.type) {
2374 case WLAN_FC_TYPE_MGMT:
2375 ap_mgmt_tx_cb(wpa_s, data->tx_status.data,
2376 data->tx_status.data_len,
2377 data->tx_status.stype,
2378 data->tx_status.ack);
2380 case WLAN_FC_TYPE_DATA:
2381 ap_tx_status(wpa_s, data->tx_status.dst,
2382 data->tx_status.data,
2383 data->tx_status.data_len,
2384 data->tx_status.ack);
2387 #endif /* CONFIG_AP */
2390 case EVENT_EAPOL_TX_STATUS:
2391 ap_eapol_tx_status(wpa_s, data->eapol_tx_status.dst,
2392 data->eapol_tx_status.data,
2393 data->eapol_tx_status.data_len,
2394 data->eapol_tx_status.ack);
2396 case EVENT_DRIVER_CLIENT_POLL_OK:
2397 ap_client_poll_ok(wpa_s, data->client_poll.addr);
2399 case EVENT_RX_FROM_UNKNOWN:
2400 if (wpa_s->ap_iface == NULL)
2402 ap_rx_from_unknown_sta(wpa_s, data->rx_from_unknown.addr,
2403 data->rx_from_unknown.wds);
2405 case EVENT_RX_MGMT: {
2407 const struct ieee80211_mgmt *mgmt;
2409 mgmt = (const struct ieee80211_mgmt *)
2410 data->rx_mgmt.frame;
2411 fc = le_to_host16(mgmt->frame_control);
2412 stype = WLAN_FC_GET_STYPE(fc);
2414 if (wpa_s->ap_iface == NULL) {
2416 if (stype == WLAN_FC_STYPE_PROBE_REQ &&
2417 data->rx_mgmt.frame_len > 24) {
2418 const u8 *src = mgmt->sa;
2419 const u8 *ie = mgmt->u.probe_req.variable;
2420 size_t ie_len = data->rx_mgmt.frame_len -
2421 (mgmt->u.probe_req.variable -
2422 data->rx_mgmt.frame);
2423 wpas_p2p_probe_req_rx(
2424 wpa_s, src, mgmt->da,
2425 mgmt->bssid, ie, ie_len,
2426 data->rx_mgmt.ssi_signal);
2429 #endif /* CONFIG_P2P */
2430 wpa_dbg(wpa_s, MSG_DEBUG, "AP: ignore received "
2431 "management frame in non-AP mode");
2435 if (stype == WLAN_FC_STYPE_PROBE_REQ &&
2436 data->rx_mgmt.frame_len > 24) {
2437 const u8 *ie = mgmt->u.probe_req.variable;
2438 size_t ie_len = data->rx_mgmt.frame_len -
2439 (mgmt->u.probe_req.variable -
2440 data->rx_mgmt.frame);
2442 wpas_notify_preq(wpa_s, mgmt->sa, mgmt->da,
2443 mgmt->bssid, ie, ie_len,
2444 data->rx_mgmt.ssi_signal);
2447 ap_mgmt_rx(wpa_s, &data->rx_mgmt);
2450 #endif /* CONFIG_AP */
2451 case EVENT_RX_ACTION:
2452 wpa_dbg(wpa_s, MSG_DEBUG, "Received Action frame: SA=" MACSTR
2453 " Category=%u DataLen=%d freq=%d MHz",
2454 MAC2STR(data->rx_action.sa),
2455 data->rx_action.category, (int) data->rx_action.len,
2456 data->rx_action.freq);
2457 #ifdef CONFIG_IEEE80211R
2458 if (data->rx_action.category == WLAN_ACTION_FT) {
2459 ft_rx_action(wpa_s, data->rx_action.data,
2460 data->rx_action.len);
2463 #endif /* CONFIG_IEEE80211R */
2464 #ifdef CONFIG_IEEE80211W
2466 if (data->rx_action.category == WLAN_ACTION_SA_QUERY) {
2467 sme_sa_query_rx(wpa_s, data->rx_action.sa,
2468 data->rx_action.data,
2469 data->rx_action.len);
2472 #endif /* CONFIG_SME */
2473 #endif /* CONFIG_IEEE80211W */
2475 if (data->rx_action.category == WLAN_ACTION_PUBLIC &&
2476 gas_query_rx(wpa_s->gas, data->rx_action.da,
2477 data->rx_action.sa, data->rx_action.bssid,
2478 data->rx_action.data, data->rx_action.len,
2479 data->rx_action.freq) == 0)
2481 #endif /* CONFIG_GAS */
2482 if (data->rx_action.category == WLAN_ACTION_WNM) {
2483 wnm_action_rx(wpa_s, &data->rx_action);
2487 if (data->rx_action.category == WLAN_ACTION_PUBLIC &&
2488 data->rx_action.len >= 4 &&
2489 data->rx_action.data[0] == WLAN_TDLS_DISCOVERY_RESPONSE) {
2490 wpa_dbg(wpa_s, MSG_DEBUG, "TDLS: Received Discovery "
2491 "Response from " MACSTR,
2492 MAC2STR(data->rx_action.sa));
2495 #endif /* CONFIG_TDLS */
2497 wpas_p2p_rx_action(wpa_s, data->rx_action.da,
2499 data->rx_action.bssid,
2500 data->rx_action.category,
2501 data->rx_action.data,
2502 data->rx_action.len, data->rx_action.freq);
2503 #endif /* CONFIG_P2P */
2505 case EVENT_RX_PROBE_REQ:
2506 if (data->rx_probe_req.sa == NULL ||
2507 data->rx_probe_req.ie == NULL)
2510 if (wpa_s->ap_iface) {
2511 hostapd_probe_req_rx(wpa_s->ap_iface->bss[0],
2512 data->rx_probe_req.sa,
2513 data->rx_probe_req.da,
2514 data->rx_probe_req.bssid,
2515 data->rx_probe_req.ie,
2516 data->rx_probe_req.ie_len,
2517 data->rx_probe_req.ssi_signal);
2520 #endif /* CONFIG_AP */
2522 wpas_p2p_probe_req_rx(wpa_s, data->rx_probe_req.sa,
2523 data->rx_probe_req.da,
2524 data->rx_probe_req.bssid,
2525 data->rx_probe_req.ie,
2526 data->rx_probe_req.ie_len,
2527 data->rx_probe_req.ssi_signal);
2528 #endif /* CONFIG_P2P */
2530 case EVENT_REMAIN_ON_CHANNEL:
2531 #ifdef CONFIG_OFFCHANNEL
2532 offchannel_remain_on_channel_cb(
2533 wpa_s, data->remain_on_channel.freq,
2534 data->remain_on_channel.duration);
2535 #endif /* CONFIG_OFFCHANNEL */
2537 wpas_p2p_remain_on_channel_cb(
2538 wpa_s, data->remain_on_channel.freq,
2539 data->remain_on_channel.duration);
2540 #endif /* CONFIG_P2P */
2542 case EVENT_CANCEL_REMAIN_ON_CHANNEL:
2543 #ifdef CONFIG_OFFCHANNEL
2544 offchannel_cancel_remain_on_channel_cb(
2545 wpa_s, data->remain_on_channel.freq);
2546 #endif /* CONFIG_OFFCHANNEL */
2548 wpas_p2p_cancel_remain_on_channel_cb(
2549 wpa_s, data->remain_on_channel.freq);
2550 #endif /* CONFIG_P2P */
2553 case EVENT_P2P_DEV_FOUND: {
2554 struct p2p_peer_info peer_info;
2556 os_memset(&peer_info, 0, sizeof(peer_info));
2557 if (data->p2p_dev_found.dev_addr)
2558 os_memcpy(peer_info.p2p_device_addr,
2559 data->p2p_dev_found.dev_addr, ETH_ALEN);
2560 if (data->p2p_dev_found.pri_dev_type)
2561 os_memcpy(peer_info.pri_dev_type,
2562 data->p2p_dev_found.pri_dev_type,
2563 sizeof(peer_info.pri_dev_type));
2564 if (data->p2p_dev_found.dev_name)
2565 os_strlcpy(peer_info.device_name,
2566 data->p2p_dev_found.dev_name,
2567 sizeof(peer_info.device_name));
2568 peer_info.config_methods = data->p2p_dev_found.config_methods;
2569 peer_info.dev_capab = data->p2p_dev_found.dev_capab;
2570 peer_info.group_capab = data->p2p_dev_found.group_capab;
2573 * FIX: new_device=1 is not necessarily correct. We should
2574 * maintain a P2P peer database in wpa_supplicant and update
2575 * this information based on whether the peer is truly new.
2577 wpas_dev_found(wpa_s, data->p2p_dev_found.addr, &peer_info, 1);
2580 case EVENT_P2P_GO_NEG_REQ_RX:
2581 wpas_go_neg_req_rx(wpa_s, data->p2p_go_neg_req_rx.src,
2582 data->p2p_go_neg_req_rx.dev_passwd_id);
2584 case EVENT_P2P_GO_NEG_COMPLETED:
2585 wpas_go_neg_completed(wpa_s, data->p2p_go_neg_completed.res);
2587 case EVENT_P2P_PROV_DISC_REQUEST:
2588 wpas_prov_disc_req(wpa_s, data->p2p_prov_disc_req.peer,
2589 data->p2p_prov_disc_req.config_methods,
2590 data->p2p_prov_disc_req.dev_addr,
2591 data->p2p_prov_disc_req.pri_dev_type,
2592 data->p2p_prov_disc_req.dev_name,
2593 data->p2p_prov_disc_req.supp_config_methods,
2594 data->p2p_prov_disc_req.dev_capab,
2595 data->p2p_prov_disc_req.group_capab,
2598 case EVENT_P2P_PROV_DISC_RESPONSE:
2599 wpas_prov_disc_resp(wpa_s, data->p2p_prov_disc_resp.peer,
2600 data->p2p_prov_disc_resp.config_methods);
2602 case EVENT_P2P_SD_REQUEST:
2603 wpas_sd_request(wpa_s, data->p2p_sd_req.freq,
2604 data->p2p_sd_req.sa,
2605 data->p2p_sd_req.dialog_token,
2606 data->p2p_sd_req.update_indic,
2607 data->p2p_sd_req.tlvs,
2608 data->p2p_sd_req.tlvs_len);
2610 case EVENT_P2P_SD_RESPONSE:
2611 wpas_sd_response(wpa_s, data->p2p_sd_resp.sa,
2612 data->p2p_sd_resp.update_indic,
2613 data->p2p_sd_resp.tlvs,
2614 data->p2p_sd_resp.tlvs_len);
2616 #endif /* CONFIG_P2P */
2617 case EVENT_EAPOL_RX:
2618 wpa_supplicant_rx_eapol(wpa_s, data->eapol_rx.src,
2619 data->eapol_rx.data,
2620 data->eapol_rx.data_len);
2622 case EVENT_SIGNAL_CHANGE:
2623 bgscan_notify_signal_change(
2624 wpa_s, data->signal_change.above_threshold,
2625 data->signal_change.current_signal,
2626 data->signal_change.current_noise,
2627 data->signal_change.current_txrate);
2629 case EVENT_INTERFACE_ENABLED:
2630 wpa_dbg(wpa_s, MSG_DEBUG, "Interface was enabled");
2631 if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) {
2632 wpa_supplicant_update_mac_addr(wpa_s);
2634 if (!wpa_s->ap_iface) {
2635 wpa_supplicant_set_state(wpa_s,
2637 wpa_supplicant_req_scan(wpa_s, 0, 0);
2639 wpa_supplicant_set_state(wpa_s,
2641 #else /* CONFIG_AP */
2642 wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
2643 wpa_supplicant_req_scan(wpa_s, 0, 0);
2644 #endif /* CONFIG_AP */
2647 case EVENT_INTERFACE_DISABLED:
2648 wpa_dbg(wpa_s, MSG_DEBUG, "Interface was disabled");
2649 wpa_supplicant_mark_disassoc(wpa_s);
2650 wpa_supplicant_set_state(wpa_s, WPA_INTERFACE_DISABLED);
2652 case EVENT_CHANNEL_LIST_CHANGED:
2653 if (wpa_s->drv_priv == NULL)
2654 break; /* Ignore event during drv initialization */
2656 free_hw_features(wpa_s);
2657 wpa_s->hw.modes = wpa_drv_get_hw_feature_data(
2658 wpa_s, &wpa_s->hw.num_modes, &wpa_s->hw.flags);
2661 wpas_p2p_update_channel_list(wpa_s);
2662 #endif /* CONFIG_P2P */
2664 case EVENT_INTERFACE_UNAVAILABLE:
2666 wpas_p2p_interface_unavailable(wpa_s);
2667 #endif /* CONFIG_P2P */
2669 case EVENT_BEST_CHANNEL:
2670 wpa_dbg(wpa_s, MSG_DEBUG, "Best channel event received "
2672 data->best_chan.freq_24, data->best_chan.freq_5,
2673 data->best_chan.freq_overall);
2674 wpa_s->best_24_freq = data->best_chan.freq_24;
2675 wpa_s->best_5_freq = data->best_chan.freq_5;
2676 wpa_s->best_overall_freq = data->best_chan.freq_overall;
2678 wpas_p2p_update_best_channels(wpa_s, data->best_chan.freq_24,
2679 data->best_chan.freq_5,
2680 data->best_chan.freq_overall);
2681 #endif /* CONFIG_P2P */
2683 case EVENT_UNPROT_DEAUTH:
2684 wpa_supplicant_event_unprot_deauth(wpa_s,
2685 &data->unprot_deauth);
2687 case EVENT_UNPROT_DISASSOC:
2688 wpa_supplicant_event_unprot_disassoc(wpa_s,
2689 &data->unprot_disassoc);
2691 case EVENT_STATION_LOW_ACK:
2693 if (wpa_s->ap_iface && data)
2694 hostapd_event_sta_low_ack(wpa_s->ap_iface->bss[0],
2695 data->low_ack.addr);
2696 #endif /* CONFIG_AP */
2699 wpa_tdls_disable_link(wpa_s->wpa, data->low_ack.addr);
2700 #endif /* CONFIG_TDLS */
2702 case EVENT_IBSS_PEER_LOST:
2703 #ifdef CONFIG_IBSS_RSN
2704 ibss_rsn_stop(wpa_s->ibss_rsn, data->ibss_peer_lost.peer);
2705 #endif /* CONFIG_IBSS_RSN */
2707 case EVENT_DRIVER_GTK_REKEY:
2708 if (os_memcmp(data->driver_gtk_rekey.bssid,
2709 wpa_s->bssid, ETH_ALEN))
2713 wpa_sm_update_replay_ctr(wpa_s->wpa,
2714 data->driver_gtk_rekey.replay_ctr);
2716 case EVENT_SCHED_SCAN_STOPPED:
2717 wpa_s->sched_scanning = 0;
2718 wpa_supplicant_notify_scanning(wpa_s, 0);
2720 if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED)
2724 * If we timed out, start a new sched scan to continue
2725 * searching for more SSIDs.
2727 if (wpa_s->sched_scan_timed_out)
2728 wpa_supplicant_req_sched_scan(wpa_s);
2730 case EVENT_WPS_BUTTON_PUSHED:
2732 wpas_wps_start_pbc(wpa_s, NULL, 0);
2733 #endif /* CONFIG_WPS */
2736 wpa_msg(wpa_s, MSG_INFO, "Unknown event %d", event);