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 to AP " MACSTR,
1215 MAC2STR(wpa_s->bssid));
1216 /* TODO: could skip this if normal data traffic has been sent */
1217 /* TODO: Consider using some more appropriate data frame for this */
1219 l2_packet_send(wpa_s->l2, wpa_s->bssid, 0x0800, (u8 *) "", 0);
1222 if (wpa_s->sme.bss_max_idle_period) {
1224 msec = wpa_s->sme.bss_max_idle_period * 1024; /* times 1000 */
1227 eloop_register_timeout(msec / 1000, msec % 1000 * 1000,
1228 wnm_bss_keep_alive, wpa_s, NULL);
1230 #endif /* CONFIG_SME */
1234 static void wnm_process_assoc_resp(struct wpa_supplicant *wpa_s,
1235 const u8 *ies, size_t ies_len)
1237 struct ieee802_11_elems elems;
1242 if (ieee802_11_parse_elems(ies, ies_len, &elems, 1) == ParseFailed)
1246 if (elems.bss_max_idle_period) {
1248 wpa_s->sme.bss_max_idle_period =
1249 WPA_GET_LE16(elems.bss_max_idle_period);
1250 wpa_printf(MSG_DEBUG, "WNM: BSS Max Idle Period: %u (* 1000 "
1251 "TU)%s", wpa_s->sme.bss_max_idle_period,
1252 (elems.bss_max_idle_period[2] & 0x01) ?
1253 " (protected keep-live required)" : "");
1254 if (wpa_s->sme.bss_max_idle_period == 0)
1255 wpa_s->sme.bss_max_idle_period = 1;
1256 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME) {
1257 eloop_cancel_timeout(wnm_bss_keep_alive, wpa_s, NULL);
1258 /* msec times 1000 */
1259 msec = wpa_s->sme.bss_max_idle_period * 1024;
1262 eloop_register_timeout(msec / 1000, msec % 1000 * 1000,
1263 wnm_bss_keep_alive, wpa_s,
1267 #endif /* CONFIG_SME */
1270 #endif /* CONFIG_WNM */
1273 void wnm_bss_keep_alive_deinit(struct wpa_supplicant *wpa_s)
1276 eloop_cancel_timeout(wnm_bss_keep_alive, wpa_s, NULL);
1277 #endif /* CONFIG_WNM */
1281 static int wpa_supplicant_event_associnfo(struct wpa_supplicant *wpa_s,
1282 union wpa_event_data *data)
1284 int l, len, found = 0, wpa_found, rsn_found;
1287 wpa_dbg(wpa_s, MSG_DEBUG, "Association info event");
1288 if (data->assoc_info.req_ies)
1289 wpa_hexdump(MSG_DEBUG, "req_ies", data->assoc_info.req_ies,
1290 data->assoc_info.req_ies_len);
1291 if (data->assoc_info.resp_ies) {
1292 wpa_hexdump(MSG_DEBUG, "resp_ies", data->assoc_info.resp_ies,
1293 data->assoc_info.resp_ies_len);
1295 wpa_tdls_assoc_resp_ies(wpa_s->wpa, data->assoc_info.resp_ies,
1296 data->assoc_info.resp_ies_len);
1297 #endif /* CONFIG_TDLS */
1299 wnm_process_assoc_resp(wpa_s, data->assoc_info.resp_ies,
1300 data->assoc_info.resp_ies_len);
1301 #endif /* CONFIG_WNM */
1303 if (data->assoc_info.beacon_ies)
1304 wpa_hexdump(MSG_DEBUG, "beacon_ies",
1305 data->assoc_info.beacon_ies,
1306 data->assoc_info.beacon_ies_len);
1307 if (data->assoc_info.freq)
1308 wpa_dbg(wpa_s, MSG_DEBUG, "freq=%u MHz",
1309 data->assoc_info.freq);
1311 p = data->assoc_info.req_ies;
1312 l = data->assoc_info.req_ies_len;
1314 /* Go through the IEs and make a copy of the WPA/RSN IE, if present. */
1315 while (p && l >= 2) {
1318 wpa_hexdump(MSG_DEBUG, "Truncated IE in assoc_info",
1322 if ((p[0] == WLAN_EID_VENDOR_SPECIFIC && p[1] >= 6 &&
1323 (os_memcmp(&p[2], "\x00\x50\xF2\x01\x01\x00", 6) == 0)) ||
1324 (p[0] == WLAN_EID_RSN && p[1] >= 2)) {
1325 if (wpa_sm_set_assoc_wpa_ie(wpa_s->wpa, p, len))
1328 wpa_find_assoc_pmkid(wpa_s);
1334 if (!found && data->assoc_info.req_ies)
1335 wpa_sm_set_assoc_wpa_ie(wpa_s->wpa, NULL, 0);
1337 #ifdef CONFIG_IEEE80211R
1339 if (wpa_s->sme.auth_alg == WPA_AUTH_ALG_FT) {
1341 if (wpa_drv_get_bssid(wpa_s, bssid) < 0 ||
1342 wpa_ft_validate_reassoc_resp(wpa_s->wpa,
1343 data->assoc_info.resp_ies,
1344 data->assoc_info.resp_ies_len,
1346 wpa_dbg(wpa_s, MSG_DEBUG, "FT: Validation of "
1347 "Reassociation Response failed");
1348 wpa_supplicant_deauthenticate(
1349 wpa_s, WLAN_REASON_INVALID_IE);
1354 p = data->assoc_info.resp_ies;
1355 l = data->assoc_info.resp_ies_len;
1357 #ifdef CONFIG_WPS_STRICT
1358 if (p && wpa_s->current_ssid &&
1359 wpa_s->current_ssid->key_mgmt == WPA_KEY_MGMT_WPS) {
1361 wps = ieee802_11_vendor_ie_concat(p, l, WPS_IE_VENDOR_TYPE);
1363 wpa_msg(wpa_s, MSG_INFO, "WPS-STRICT: AP did not "
1364 "include WPS IE in (Re)Association Response");
1368 if (wps_validate_assoc_resp(wps) < 0) {
1370 wpa_supplicant_deauthenticate(
1371 wpa_s, WLAN_REASON_INVALID_IE);
1376 #endif /* CONFIG_WPS_STRICT */
1378 /* Go through the IEs and make a copy of the MDIE, if present. */
1379 while (p && l >= 2) {
1382 wpa_hexdump(MSG_DEBUG, "Truncated IE in assoc_info",
1386 if (p[0] == WLAN_EID_MOBILITY_DOMAIN &&
1387 p[1] >= MOBILITY_DOMAIN_ID_LEN) {
1388 wpa_s->sme.ft_used = 1;
1389 os_memcpy(wpa_s->sme.mobility_domain, p + 2,
1390 MOBILITY_DOMAIN_ID_LEN);
1396 #endif /* CONFIG_SME */
1398 wpa_sm_set_ft_params(wpa_s->wpa, data->assoc_info.resp_ies,
1399 data->assoc_info.resp_ies_len);
1400 #endif /* CONFIG_IEEE80211R */
1402 /* WPA/RSN IE from Beacon/ProbeResp */
1403 p = data->assoc_info.beacon_ies;
1404 l = data->assoc_info.beacon_ies_len;
1406 /* Go through the IEs and make a copy of the WPA/RSN IEs, if present.
1408 wpa_found = rsn_found = 0;
1409 while (p && l >= 2) {
1412 wpa_hexdump(MSG_DEBUG, "Truncated IE in beacon_ies",
1417 p[0] == WLAN_EID_VENDOR_SPECIFIC && p[1] >= 6 &&
1418 os_memcmp(&p[2], "\x00\x50\xF2\x01\x01\x00", 6) == 0) {
1420 wpa_sm_set_ap_wpa_ie(wpa_s->wpa, p, len);
1424 p[0] == WLAN_EID_RSN && p[1] >= 2) {
1426 wpa_sm_set_ap_rsn_ie(wpa_s->wpa, p, len);
1433 if (!wpa_found && data->assoc_info.beacon_ies)
1434 wpa_sm_set_ap_wpa_ie(wpa_s->wpa, NULL, 0);
1435 if (!rsn_found && data->assoc_info.beacon_ies)
1436 wpa_sm_set_ap_rsn_ie(wpa_s->wpa, NULL, 0);
1437 if (wpa_found || rsn_found)
1438 wpa_s->ap_ies_from_associnfo = 1;
1440 if (wpa_s->assoc_freq && data->assoc_info.freq &&
1441 wpa_s->assoc_freq != data->assoc_info.freq) {
1442 wpa_printf(MSG_DEBUG, "Operating frequency changed from "
1444 wpa_s->assoc_freq, data->assoc_info.freq);
1445 wpa_supplicant_update_scan_results(wpa_s);
1448 wpa_s->assoc_freq = data->assoc_info.freq;
1454 static struct wpa_bss * wpa_supplicant_get_new_bss(
1455 struct wpa_supplicant *wpa_s, const u8 *bssid)
1457 struct wpa_bss *bss = NULL;
1458 struct wpa_ssid *ssid = wpa_s->current_ssid;
1460 if (ssid->ssid_len > 0)
1461 bss = wpa_bss_get(wpa_s, bssid, ssid->ssid, ssid->ssid_len);
1463 bss = wpa_bss_get_bssid(wpa_s, bssid);
1469 static int wpa_supplicant_assoc_update_ie(struct wpa_supplicant *wpa_s)
1471 const u8 *bss_wpa = NULL, *bss_rsn = NULL;
1473 if (!wpa_s->current_bss || !wpa_s->current_ssid)
1476 if (!wpa_key_mgmt_wpa_any(wpa_s->current_ssid->key_mgmt))
1479 bss_wpa = wpa_bss_get_vendor_ie(wpa_s->current_bss,
1480 WPA_IE_VENDOR_TYPE);
1481 bss_rsn = wpa_bss_get_ie(wpa_s->current_bss, WLAN_EID_RSN);
1483 if (wpa_sm_set_ap_wpa_ie(wpa_s->wpa, bss_wpa,
1484 bss_wpa ? 2 + bss_wpa[1] : 0) ||
1485 wpa_sm_set_ap_rsn_ie(wpa_s->wpa, bss_rsn,
1486 bss_rsn ? 2 + bss_rsn[1] : 0))
1493 static void wpa_supplicant_event_assoc(struct wpa_supplicant *wpa_s,
1494 union wpa_event_data *data)
1499 struct wpa_driver_capa capa;
1502 if (wpa_s->ap_iface) {
1503 hostapd_notif_assoc(wpa_s->ap_iface->bss[0],
1504 data->assoc_info.addr,
1505 data->assoc_info.req_ies,
1506 data->assoc_info.req_ies_len,
1507 data->assoc_info.reassoc);
1510 #endif /* CONFIG_AP */
1512 ft_completed = wpa_ft_is_completed(wpa_s->wpa);
1513 if (data && wpa_supplicant_event_associnfo(wpa_s, data) < 0)
1516 wpa_supplicant_set_state(wpa_s, WPA_ASSOCIATED);
1517 if (wpa_drv_get_bssid(wpa_s, bssid) >= 0 &&
1518 os_memcmp(bssid, wpa_s->bssid, ETH_ALEN) != 0) {
1519 wpa_dbg(wpa_s, MSG_DEBUG, "Associated to a new BSS: BSSID="
1520 MACSTR, MAC2STR(bssid));
1521 random_add_randomness(bssid, ETH_ALEN);
1522 bssid_changed = os_memcmp(wpa_s->bssid, bssid, ETH_ALEN);
1523 os_memcpy(wpa_s->bssid, bssid, ETH_ALEN);
1524 os_memset(wpa_s->pending_bssid, 0, ETH_ALEN);
1526 wpas_notify_bssid_changed(wpa_s);
1528 if (wpa_supplicant_dynamic_keys(wpa_s) && !ft_completed) {
1529 wpa_clear_keys(wpa_s, bssid);
1531 if (wpa_supplicant_select_config(wpa_s) < 0) {
1532 wpa_supplicant_disassociate(
1533 wpa_s, WLAN_REASON_DEAUTH_LEAVING);
1536 if (wpa_s->current_ssid) {
1537 struct wpa_bss *bss = NULL;
1539 bss = wpa_supplicant_get_new_bss(wpa_s, bssid);
1541 wpa_supplicant_update_scan_results(wpa_s);
1543 /* Get the BSS from the new scan results */
1544 bss = wpa_supplicant_get_new_bss(wpa_s, bssid);
1548 wpa_s->current_bss = bss;
1551 if (wpa_s->conf->ap_scan == 1 &&
1552 wpa_s->drv_flags & WPA_DRIVER_FLAGS_BSS_SELECTION) {
1553 if (wpa_supplicant_assoc_update_ie(wpa_s) < 0)
1554 wpa_msg(wpa_s, MSG_WARNING,
1555 "WPA/RSN IEs not updated");
1560 os_memcpy(wpa_s->sme.prev_bssid, bssid, ETH_ALEN);
1561 wpa_s->sme.prev_bssid_set = 1;
1562 #endif /* CONFIG_SME */
1564 wpa_msg(wpa_s, MSG_INFO, "Associated with " MACSTR, MAC2STR(bssid));
1565 if (wpa_s->current_ssid) {
1566 /* When using scanning (ap_scan=1), SIM PC/SC interface can be
1567 * initialized before association, but for other modes,
1568 * initialize PC/SC here, if the current configuration needs
1569 * smartcard or SIM/USIM. */
1570 wpa_supplicant_scard_init(wpa_s, wpa_s->current_ssid);
1572 wpa_sm_notify_assoc(wpa_s->wpa, bssid);
1574 l2_packet_notify_auth_start(wpa_s->l2);
1577 * Set portEnabled first to FALSE in order to get EAP state machine out
1578 * of the SUCCESS state and eapSuccess cleared. Without this, EAPOL PAE
1579 * state machine may transit to AUTHENTICATING state based on obsolete
1580 * eapSuccess and then trigger BE_AUTH to SUCCESS and PAE to
1581 * AUTHENTICATED without ever giving chance to EAP state machine to
1584 if (!ft_completed) {
1585 eapol_sm_notify_portEnabled(wpa_s->eapol, FALSE);
1586 eapol_sm_notify_portValid(wpa_s->eapol, FALSE);
1588 if (wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt) || ft_completed)
1589 eapol_sm_notify_eap_success(wpa_s->eapol, FALSE);
1590 /* 802.1X::portControl = Auto */
1591 eapol_sm_notify_portEnabled(wpa_s->eapol, TRUE);
1592 wpa_s->eapol_received = 0;
1593 if (wpa_s->key_mgmt == WPA_KEY_MGMT_NONE ||
1594 wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE ||
1595 (wpa_s->current_ssid &&
1596 wpa_s->current_ssid->mode == IEEE80211_MODE_IBSS)) {
1597 wpa_supplicant_cancel_auth_timeout(wpa_s);
1598 wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
1599 } else if (!ft_completed) {
1600 /* Timeout for receiving the first EAPOL packet */
1601 wpa_supplicant_req_auth_timeout(wpa_s, 10, 0);
1603 wpa_supplicant_cancel_scan(wpa_s);
1605 if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE) &&
1606 wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt)) {
1608 * We are done; the driver will take care of RSN 4-way
1611 wpa_supplicant_cancel_auth_timeout(wpa_s);
1612 wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
1613 eapol_sm_notify_portValid(wpa_s->eapol, TRUE);
1614 eapol_sm_notify_eap_success(wpa_s->eapol, TRUE);
1615 } else if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE) &&
1616 wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt)) {
1618 * The driver will take care of RSN 4-way handshake, so we need
1619 * to allow EAPOL supplicant to complete its work without
1620 * waiting for WPA supplicant.
1622 eapol_sm_notify_portValid(wpa_s->eapol, TRUE);
1623 } else if (ft_completed) {
1625 * FT protocol completed - make sure EAPOL state machine ends
1626 * up in authenticated.
1628 wpa_supplicant_cancel_auth_timeout(wpa_s);
1629 wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
1630 eapol_sm_notify_portValid(wpa_s->eapol, TRUE);
1631 eapol_sm_notify_eap_success(wpa_s->eapol, TRUE);
1634 if (wpa_s->pending_eapol_rx) {
1635 struct os_time now, age;
1637 os_time_sub(&now, &wpa_s->pending_eapol_rx_time, &age);
1638 if (age.sec == 0 && age.usec < 100000 &&
1639 os_memcmp(wpa_s->pending_eapol_rx_src, bssid, ETH_ALEN) ==
1641 wpa_dbg(wpa_s, MSG_DEBUG, "Process pending EAPOL "
1642 "frame that was received just before "
1643 "association notification");
1644 wpa_supplicant_rx_eapol(
1645 wpa_s, wpa_s->pending_eapol_rx_src,
1646 wpabuf_head(wpa_s->pending_eapol_rx),
1647 wpabuf_len(wpa_s->pending_eapol_rx));
1649 wpabuf_free(wpa_s->pending_eapol_rx);
1650 wpa_s->pending_eapol_rx = NULL;
1653 if ((wpa_s->key_mgmt == WPA_KEY_MGMT_NONE ||
1654 wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA) &&
1655 wpa_s->current_ssid && wpa_drv_get_capa(wpa_s, &capa) == 0 &&
1656 capa.flags & WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC_DONE) {
1657 /* Set static WEP keys again */
1658 wpa_set_wep_keys(wpa_s, wpa_s->current_ssid);
1661 #ifdef CONFIG_IBSS_RSN
1662 if (wpa_s->current_ssid &&
1663 wpa_s->current_ssid->mode == WPAS_MODE_IBSS &&
1664 wpa_s->key_mgmt != WPA_KEY_MGMT_NONE &&
1665 wpa_s->key_mgmt != WPA_KEY_MGMT_WPA_NONE &&
1666 wpa_s->ibss_rsn == NULL) {
1667 wpa_s->ibss_rsn = ibss_rsn_init(wpa_s);
1668 if (!wpa_s->ibss_rsn) {
1669 wpa_msg(wpa_s, MSG_INFO, "Failed to init IBSS RSN");
1670 wpa_supplicant_deauthenticate(
1671 wpa_s, WLAN_REASON_DEAUTH_LEAVING);
1675 ibss_rsn_set_psk(wpa_s->ibss_rsn, wpa_s->current_ssid->psk);
1677 #endif /* CONFIG_IBSS_RSN */
1681 static int disconnect_reason_recoverable(u16 reason_code)
1683 return reason_code == WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY ||
1684 reason_code == WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA ||
1685 reason_code == WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA;
1689 static void wpa_supplicant_event_disassoc(struct wpa_supplicant *wpa_s,
1691 int locally_generated)
1695 u8 prev_pending_bssid[ETH_ALEN];
1696 struct wpa_bss *fast_reconnect = NULL;
1697 struct wpa_ssid *fast_reconnect_ssid = NULL;
1699 authenticating = wpa_s->wpa_state == WPA_AUTHENTICATING;
1700 os_memcpy(prev_pending_bssid, wpa_s->pending_bssid, ETH_ALEN);
1702 if (wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE) {
1704 * At least Host AP driver and a Prism3 card seemed to be
1705 * generating streams of disconnected events when configuring
1706 * IBSS for WPA-None. Ignore them for now.
1708 wpa_dbg(wpa_s, MSG_DEBUG, "Disconnect event - ignore in "
1709 "IBSS/WPA-None mode");
1713 if (wpa_s->wpa_state == WPA_4WAY_HANDSHAKE &&
1714 wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt)) {
1715 wpa_msg(wpa_s, MSG_INFO, "WPA: 4-Way Handshake failed - "
1716 "pre-shared key may be incorrect");
1718 if (!wpa_s->auto_reconnect_disabled ||
1719 wpa_s->key_mgmt == WPA_KEY_MGMT_WPS) {
1720 wpa_dbg(wpa_s, MSG_DEBUG, "Auto connect enabled: try to "
1721 "reconnect (wps=%d wpa_state=%d)",
1722 wpa_s->key_mgmt == WPA_KEY_MGMT_WPS,
1724 if (wpa_s->wpa_state == WPA_COMPLETED &&
1725 wpa_s->current_ssid &&
1726 wpa_s->current_ssid->mode == WPAS_MODE_INFRA &&
1727 !locally_generated &&
1728 disconnect_reason_recoverable(reason_code)) {
1730 * It looks like the AP has dropped association with
1731 * us, but could allow us to get back in. Try to
1732 * reconnect to the same BSS without full scan to save
1733 * time for some common cases.
1735 fast_reconnect = wpa_s->current_bss;
1736 fast_reconnect_ssid = wpa_s->current_ssid;
1737 } else if (wpa_s->wpa_state >= WPA_ASSOCIATING)
1738 wpa_supplicant_req_scan(wpa_s, 0, 100000);
1740 wpa_dbg(wpa_s, MSG_DEBUG, "Do not request new "
1743 wpa_dbg(wpa_s, MSG_DEBUG, "Auto connect disabled: do not "
1744 "try to re-connect");
1745 wpa_s->reassociate = 0;
1746 wpa_s->disconnected = 1;
1747 wpa_supplicant_cancel_sched_scan(wpa_s);
1749 bssid = wpa_s->bssid;
1750 if (is_zero_ether_addr(bssid))
1751 bssid = wpa_s->pending_bssid;
1752 if (wpa_s->wpa_state >= WPA_AUTHENTICATING)
1753 wpas_connection_failed(wpa_s, bssid);
1754 wpa_sm_notify_disassoc(wpa_s->wpa);
1755 if (!is_zero_ether_addr(bssid) ||
1756 wpa_s->wpa_state >= WPA_AUTHENTICATING) {
1757 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_DISCONNECTED "bssid=" MACSTR
1759 MAC2STR(bssid), reason_code,
1760 locally_generated ? " locally_generated=1" : "");
1762 if (wpa_supplicant_dynamic_keys(wpa_s)) {
1763 wpa_dbg(wpa_s, MSG_DEBUG, "Disconnect event - remove keys");
1764 wpa_s->keys_cleared = 0;
1765 wpa_clear_keys(wpa_s, wpa_s->bssid);
1767 wpa_supplicant_mark_disassoc(wpa_s);
1769 if (authenticating && (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME))
1770 sme_disassoc_while_authenticating(wpa_s, prev_pending_bssid);
1772 if (fast_reconnect) {
1773 #ifndef CONFIG_NO_SCAN_PROCESSING
1774 wpa_dbg(wpa_s, MSG_DEBUG, "Try to reconnect to the same BSS");
1775 if (wpa_supplicant_connect(wpa_s, fast_reconnect,
1776 fast_reconnect_ssid) < 0) {
1777 /* Recover through full scan */
1778 wpa_supplicant_req_scan(wpa_s, 0, 100000);
1780 #endif /* CONFIG_NO_SCAN_PROCESSING */
1785 #ifdef CONFIG_DELAYED_MIC_ERROR_REPORT
1786 void wpa_supplicant_delayed_mic_error_report(void *eloop_ctx, void *sock_ctx)
1788 struct wpa_supplicant *wpa_s = eloop_ctx;
1790 if (!wpa_s->pending_mic_error_report)
1793 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: Sending pending MIC error report");
1794 wpa_sm_key_request(wpa_s->wpa, 1, wpa_s->pending_mic_error_pairwise);
1795 wpa_s->pending_mic_error_report = 0;
1797 #endif /* CONFIG_DELAYED_MIC_ERROR_REPORT */
1801 wpa_supplicant_event_michael_mic_failure(struct wpa_supplicant *wpa_s,
1802 union wpa_event_data *data)
1807 wpa_msg(wpa_s, MSG_WARNING, "Michael MIC failure detected");
1808 pairwise = (data && data->michael_mic_failure.unicast);
1810 if ((wpa_s->last_michael_mic_error &&
1811 t.sec - wpa_s->last_michael_mic_error <= 60) ||
1812 wpa_s->pending_mic_error_report) {
1813 if (wpa_s->pending_mic_error_report) {
1815 * Send the pending MIC error report immediately since
1816 * we are going to start countermeasures and AP better
1819 wpa_sm_key_request(wpa_s->wpa, 1,
1820 wpa_s->pending_mic_error_pairwise);
1823 /* Send the new MIC error report immediately since we are going
1824 * to start countermeasures and AP better do the same.
1826 wpa_sm_key_request(wpa_s->wpa, 1, pairwise);
1828 /* initialize countermeasures */
1829 wpa_s->countermeasures = 1;
1831 wpa_blacklist_add(wpa_s, wpa_s->bssid);
1833 wpa_msg(wpa_s, MSG_WARNING, "TKIP countermeasures started");
1836 * Need to wait for completion of request frame. We do not get
1837 * any callback for the message completion, so just wait a
1838 * short while and hope for the best. */
1841 wpa_drv_set_countermeasures(wpa_s, 1);
1842 wpa_supplicant_deauthenticate(wpa_s,
1843 WLAN_REASON_MICHAEL_MIC_FAILURE);
1844 eloop_cancel_timeout(wpa_supplicant_stop_countermeasures,
1846 eloop_register_timeout(60, 0,
1847 wpa_supplicant_stop_countermeasures,
1849 /* TODO: mark the AP rejected for 60 second. STA is
1850 * allowed to associate with another AP.. */
1852 #ifdef CONFIG_DELAYED_MIC_ERROR_REPORT
1853 if (wpa_s->mic_errors_seen) {
1855 * Reduce the effectiveness of Michael MIC error
1856 * reports as a means for attacking against TKIP if
1857 * more than one MIC failure is noticed with the same
1858 * PTK. We delay the transmission of the reports by a
1859 * random time between 0 and 60 seconds in order to
1860 * force the attacker wait 60 seconds before getting
1861 * the information on whether a frame resulted in a MIC
1867 if (os_get_random(rval, sizeof(rval)) < 0)
1868 sec = os_random() % 60;
1870 sec = WPA_GET_BE32(rval) % 60;
1871 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: Delay MIC error "
1872 "report %d seconds", sec);
1873 wpa_s->pending_mic_error_report = 1;
1874 wpa_s->pending_mic_error_pairwise = pairwise;
1875 eloop_cancel_timeout(
1876 wpa_supplicant_delayed_mic_error_report,
1878 eloop_register_timeout(
1879 sec, os_random() % 1000000,
1880 wpa_supplicant_delayed_mic_error_report,
1883 wpa_sm_key_request(wpa_s->wpa, 1, pairwise);
1885 #else /* CONFIG_DELAYED_MIC_ERROR_REPORT */
1886 wpa_sm_key_request(wpa_s->wpa, 1, pairwise);
1887 #endif /* CONFIG_DELAYED_MIC_ERROR_REPORT */
1889 wpa_s->last_michael_mic_error = t.sec;
1890 wpa_s->mic_errors_seen++;
1894 #ifdef CONFIG_TERMINATE_ONLASTIF
1895 static int any_interfaces(struct wpa_supplicant *head)
1897 struct wpa_supplicant *wpa_s;
1899 for (wpa_s = head; wpa_s != NULL; wpa_s = wpa_s->next)
1900 if (!wpa_s->interface_removed)
1904 #endif /* CONFIG_TERMINATE_ONLASTIF */
1908 wpa_supplicant_event_interface_status(struct wpa_supplicant *wpa_s,
1909 union wpa_event_data *data)
1911 if (os_strcmp(wpa_s->ifname, data->interface_status.ifname) != 0)
1914 switch (data->interface_status.ievent) {
1915 case EVENT_INTERFACE_ADDED:
1916 if (!wpa_s->interface_removed)
1918 wpa_s->interface_removed = 0;
1919 wpa_dbg(wpa_s, MSG_DEBUG, "Configured interface was added");
1920 if (wpa_supplicant_driver_init(wpa_s) < 0) {
1921 wpa_msg(wpa_s, MSG_INFO, "Failed to initialize the "
1922 "driver after interface was added");
1924 wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
1926 case EVENT_INTERFACE_REMOVED:
1927 wpa_dbg(wpa_s, MSG_DEBUG, "Configured interface was removed");
1928 wpa_s->interface_removed = 1;
1929 wpa_supplicant_mark_disassoc(wpa_s);
1930 wpa_supplicant_set_state(wpa_s, WPA_INTERFACE_DISABLED);
1931 l2_packet_deinit(wpa_s->l2);
1933 #ifdef CONFIG_IBSS_RSN
1934 ibss_rsn_deinit(wpa_s->ibss_rsn);
1935 wpa_s->ibss_rsn = NULL;
1936 #endif /* CONFIG_IBSS_RSN */
1937 #ifdef CONFIG_TERMINATE_ONLASTIF
1938 /* check if last interface */
1939 if (!any_interfaces(wpa_s->global->ifaces))
1941 #endif /* CONFIG_TERMINATE_ONLASTIF */
1947 #ifdef CONFIG_PEERKEY
1949 wpa_supplicant_event_stkstart(struct wpa_supplicant *wpa_s,
1950 union wpa_event_data *data)
1954 wpa_sm_stkstart(wpa_s->wpa, data->stkstart.peer);
1956 #endif /* CONFIG_PEERKEY */
1960 static void wpa_supplicant_event_tdls(struct wpa_supplicant *wpa_s,
1961 union wpa_event_data *data)
1965 switch (data->tdls.oper) {
1966 case TDLS_REQUEST_SETUP:
1967 wpa_tdls_start(wpa_s->wpa, data->tdls.peer);
1969 case TDLS_REQUEST_TEARDOWN:
1970 wpa_tdls_send_teardown(wpa_s->wpa, data->tdls.peer,
1971 data->tdls.reason_code);
1975 #endif /* CONFIG_TDLS */
1978 #ifdef CONFIG_IEEE80211R
1980 wpa_supplicant_event_ft_response(struct wpa_supplicant *wpa_s,
1981 union wpa_event_data *data)
1986 if (wpa_ft_process_response(wpa_s->wpa, data->ft_ies.ies,
1987 data->ft_ies.ies_len,
1988 data->ft_ies.ft_action,
1989 data->ft_ies.target_ap,
1990 data->ft_ies.ric_ies,
1991 data->ft_ies.ric_ies_len) < 0) {
1992 /* TODO: prevent MLME/driver from trying to associate? */
1995 #endif /* CONFIG_IEEE80211R */
1998 #ifdef CONFIG_IBSS_RSN
1999 static void wpa_supplicant_event_ibss_rsn_start(struct wpa_supplicant *wpa_s,
2000 union wpa_event_data *data)
2002 struct wpa_ssid *ssid;
2003 if (wpa_s->wpa_state < WPA_ASSOCIATED)
2007 ssid = wpa_s->current_ssid;
2010 if (ssid->mode != WPAS_MODE_IBSS || !wpa_key_mgmt_wpa(ssid->key_mgmt))
2013 ibss_rsn_start(wpa_s->ibss_rsn, data->ibss_rsn_start.peer);
2015 #endif /* CONFIG_IBSS_RSN */
2018 #ifdef CONFIG_IEEE80211R
2019 static void ft_rx_action(struct wpa_supplicant *wpa_s, const u8 *data,
2022 const u8 *sta_addr, *target_ap_addr;
2025 wpa_hexdump(MSG_MSGDUMP, "FT: RX Action", data, len);
2026 if (!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME))
2027 return; /* only SME case supported for now */
2028 if (len < 1 + 2 * ETH_ALEN + 2)
2031 return; /* Only FT Action Response is supported for now */
2032 sta_addr = data + 1;
2033 target_ap_addr = data + 1 + ETH_ALEN;
2034 status = WPA_GET_LE16(data + 1 + 2 * ETH_ALEN);
2035 wpa_dbg(wpa_s, MSG_DEBUG, "FT: Received FT Action Response: STA "
2036 MACSTR " TargetAP " MACSTR " status %u",
2037 MAC2STR(sta_addr), MAC2STR(target_ap_addr), status);
2039 if (os_memcmp(sta_addr, wpa_s->own_addr, ETH_ALEN) != 0) {
2040 wpa_dbg(wpa_s, MSG_DEBUG, "FT: Foreign STA Address " MACSTR
2041 " in FT Action Response", MAC2STR(sta_addr));
2046 wpa_dbg(wpa_s, MSG_DEBUG, "FT: FT Action Response indicates "
2047 "failure (status code %d)", status);
2048 /* TODO: report error to FT code(?) */
2052 if (wpa_ft_process_response(wpa_s->wpa, data + 1 + 2 * ETH_ALEN + 2,
2053 len - (1 + 2 * ETH_ALEN + 2), 1,
2054 target_ap_addr, NULL, 0) < 0)
2059 struct wpa_bss *bss;
2060 bss = wpa_bss_get_bssid(wpa_s, target_ap_addr);
2062 wpa_s->sme.freq = bss->freq;
2063 wpa_s->sme.auth_alg = WPA_AUTH_ALG_FT;
2064 sme_associate(wpa_s, WPAS_MODE_INFRA, target_ap_addr,
2067 #endif /* CONFIG_SME */
2069 #endif /* CONFIG_IEEE80211R */
2072 static void wpa_supplicant_event_unprot_deauth(struct wpa_supplicant *wpa_s,
2073 struct unprot_deauth *e)
2075 #ifdef CONFIG_IEEE80211W
2076 wpa_printf(MSG_DEBUG, "Unprotected Deauthentication frame "
2077 "dropped: " MACSTR " -> " MACSTR
2078 " (reason code %u)",
2079 MAC2STR(e->sa), MAC2STR(e->da), e->reason_code);
2080 sme_event_unprot_disconnect(wpa_s, e->sa, e->da, e->reason_code);
2081 #endif /* CONFIG_IEEE80211W */
2085 static void wpa_supplicant_event_unprot_disassoc(struct wpa_supplicant *wpa_s,
2086 struct unprot_disassoc *e)
2088 #ifdef CONFIG_IEEE80211W
2089 wpa_printf(MSG_DEBUG, "Unprotected Disassociation frame "
2090 "dropped: " MACSTR " -> " MACSTR
2091 " (reason code %u)",
2092 MAC2STR(e->sa), MAC2STR(e->da), e->reason_code);
2093 sme_event_unprot_disconnect(wpa_s, e->sa, e->da, e->reason_code);
2094 #endif /* CONFIG_IEEE80211W */
2098 static void wnm_action_rx(struct wpa_supplicant *wpa_s, struct rx_action *rx)
2101 const u8 *pos, *end;
2103 if (rx->data == NULL || rx->len == 0)
2107 end = pos + rx->len;
2110 wpa_printf(MSG_DEBUG, "WNM: RX action %u from " MACSTR,
2111 action, MAC2STR(rx->sa));
2113 case WNM_BSS_TRANS_MGMT_REQ:
2116 wpa_printf(MSG_DEBUG, "WNM: BSS Transition Management "
2117 "Request: dialog_token=%u request_mode=0x%x "
2118 "disassoc_timer=%u validity_interval=%u",
2119 pos[0], pos[1], WPA_GET_LE16(pos + 2), pos[4]);
2123 pos += 12; /* BSS Termination Duration */
2126 if (pos + 1 > end || pos + 1 + pos[0] > end) {
2127 wpa_printf(MSG_DEBUG, "WNM: Invalid BSS "
2128 "Transition Management Request "
2132 os_memcpy(url, pos + 1, pos[0]);
2134 wpa_msg(wpa_s, MSG_INFO, "WNM: ESS Disassociation "
2135 "Imminent - session_info_url=%s", url);
2142 void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
2143 union wpa_event_data *data)
2145 struct wpa_supplicant *wpa_s = ctx;
2146 u16 reason_code = 0;
2147 int locally_generated = 0;
2149 if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED &&
2150 event != EVENT_INTERFACE_ENABLED &&
2151 event != EVENT_INTERFACE_STATUS &&
2152 event != EVENT_SCHED_SCAN_STOPPED) {
2153 wpa_dbg(wpa_s, MSG_DEBUG,
2154 "Ignore event %s (%d) while interface is disabled",
2155 event_to_string(event), event);
2159 #ifndef CONFIG_NO_STDOUT_DEBUG
2161 int level = MSG_DEBUG;
2163 if (event == EVENT_RX_MGMT && data->rx_mgmt.frame_len >= 24) {
2164 const struct ieee80211_hdr *hdr;
2166 hdr = (const struct ieee80211_hdr *) data->rx_mgmt.frame;
2167 fc = le_to_host16(hdr->frame_control);
2168 if (WLAN_FC_GET_TYPE(fc) == WLAN_FC_TYPE_MGMT &&
2169 WLAN_FC_GET_STYPE(fc) == WLAN_FC_STYPE_BEACON)
2170 level = MSG_EXCESSIVE;
2173 wpa_dbg(wpa_s, level, "Event %s (%d) received",
2174 event_to_string(event), event);
2176 #endif /* CONFIG_NO_STDOUT_DEBUG */
2180 sme_event_auth(wpa_s, data);
2183 wpa_supplicant_event_assoc(wpa_s, data);
2185 case EVENT_DISASSOC:
2186 wpa_dbg(wpa_s, MSG_DEBUG, "Disassociation notification");
2188 wpa_dbg(wpa_s, MSG_DEBUG, " * reason %u%s",
2189 data->disassoc_info.reason_code,
2190 data->disassoc_info.locally_generated ?
2191 " (locally generated)" : "");
2192 if (data->disassoc_info.addr)
2193 wpa_dbg(wpa_s, MSG_DEBUG, " * address " MACSTR,
2194 MAC2STR(data->disassoc_info.addr));
2197 if (wpa_s->ap_iface && data && data->disassoc_info.addr) {
2198 hostapd_notif_disassoc(wpa_s->ap_iface->bss[0],
2199 data->disassoc_info.addr);
2202 if (wpa_s->ap_iface) {
2203 wpa_dbg(wpa_s, MSG_DEBUG, "Ignore disassoc event in "
2207 #endif /* CONFIG_AP */
2209 reason_code = data->disassoc_info.reason_code;
2211 data->disassoc_info.locally_generated;
2212 wpa_hexdump(MSG_DEBUG, "Disassociation frame IE(s)",
2213 data->disassoc_info.ie,
2214 data->disassoc_info.ie_len);
2216 wpas_p2p_disassoc_notif(
2217 wpa_s, data->disassoc_info.addr, reason_code,
2218 data->disassoc_info.ie,
2219 data->disassoc_info.ie_len,
2221 #endif /* CONFIG_P2P */
2223 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
2224 sme_event_disassoc(wpa_s, data);
2227 if (event == EVENT_DEAUTH) {
2228 wpa_dbg(wpa_s, MSG_DEBUG,
2229 "Deauthentication notification");
2231 reason_code = data->deauth_info.reason_code;
2233 data->deauth_info.locally_generated;
2234 wpa_dbg(wpa_s, MSG_DEBUG, " * reason %u%s",
2235 data->deauth_info.reason_code,
2236 data->deauth_info.locally_generated ?
2237 " (locally generated)" : "");
2238 if (data->deauth_info.addr) {
2239 wpa_dbg(wpa_s, MSG_DEBUG, " * address "
2241 MAC2STR(data->deauth_info.
2244 wpa_hexdump(MSG_DEBUG,
2245 "Deauthentication frame IE(s)",
2246 data->deauth_info.ie,
2247 data->deauth_info.ie_len);
2251 if (wpa_s->ap_iface && data && data->deauth_info.addr) {
2252 hostapd_notif_disassoc(wpa_s->ap_iface->bss[0],
2253 data->deauth_info.addr);
2256 if (wpa_s->ap_iface) {
2257 wpa_dbg(wpa_s, MSG_DEBUG, "Ignore deauth event in "
2261 #endif /* CONFIG_AP */
2262 wpa_supplicant_event_disassoc(wpa_s, reason_code,
2265 if (event == EVENT_DEAUTH && data) {
2266 wpas_p2p_deauth_notif(wpa_s, data->deauth_info.addr,
2268 data->deauth_info.ie,
2269 data->deauth_info.ie_len,
2272 #endif /* CONFIG_P2P */
2274 case EVENT_MICHAEL_MIC_FAILURE:
2275 wpa_supplicant_event_michael_mic_failure(wpa_s, data);
2277 #ifndef CONFIG_NO_SCAN_PROCESSING
2278 case EVENT_SCAN_RESULTS:
2279 wpa_supplicant_event_scan_results(wpa_s, data);
2281 #endif /* CONFIG_NO_SCAN_PROCESSING */
2282 case EVENT_ASSOCINFO:
2283 wpa_supplicant_event_associnfo(wpa_s, data);
2285 case EVENT_INTERFACE_STATUS:
2286 wpa_supplicant_event_interface_status(wpa_s, data);
2288 case EVENT_PMKID_CANDIDATE:
2289 wpa_supplicant_event_pmkid_candidate(wpa_s, data);
2291 #ifdef CONFIG_PEERKEY
2292 case EVENT_STKSTART:
2293 wpa_supplicant_event_stkstart(wpa_s, data);
2295 #endif /* CONFIG_PEERKEY */
2298 wpa_supplicant_event_tdls(wpa_s, data);
2300 #endif /* CONFIG_TDLS */
2301 #ifdef CONFIG_IEEE80211R
2302 case EVENT_FT_RESPONSE:
2303 wpa_supplicant_event_ft_response(wpa_s, data);
2305 #endif /* CONFIG_IEEE80211R */
2306 #ifdef CONFIG_IBSS_RSN
2307 case EVENT_IBSS_RSN_START:
2308 wpa_supplicant_event_ibss_rsn_start(wpa_s, data);
2310 #endif /* CONFIG_IBSS_RSN */
2311 case EVENT_ASSOC_REJECT:
2312 if (data->assoc_reject.bssid)
2313 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_ASSOC_REJECT
2314 "bssid=" MACSTR " status_code=%u",
2315 MAC2STR(data->assoc_reject.bssid),
2316 data->assoc_reject.status_code);
2318 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_ASSOC_REJECT
2320 data->assoc_reject.status_code);
2321 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
2322 sme_event_assoc_reject(wpa_s, data);
2324 case EVENT_AUTH_TIMED_OUT:
2325 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
2326 sme_event_auth_timed_out(wpa_s, data);
2328 case EVENT_ASSOC_TIMED_OUT:
2329 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
2330 sme_event_assoc_timed_out(wpa_s, data);
2332 case EVENT_TX_STATUS:
2333 wpa_dbg(wpa_s, MSG_DEBUG, "EVENT_TX_STATUS dst=" MACSTR
2334 " type=%d stype=%d",
2335 MAC2STR(data->tx_status.dst),
2336 data->tx_status.type, data->tx_status.stype);
2338 if (wpa_s->ap_iface == NULL) {
2339 #ifdef CONFIG_OFFCHANNEL
2340 if (data->tx_status.type == WLAN_FC_TYPE_MGMT &&
2341 data->tx_status.stype == WLAN_FC_STYPE_ACTION)
2342 offchannel_send_action_tx_status(
2343 wpa_s, data->tx_status.dst,
2344 data->tx_status.data,
2345 data->tx_status.data_len,
2346 data->tx_status.ack ?
2347 OFFCHANNEL_SEND_ACTION_SUCCESS :
2348 OFFCHANNEL_SEND_ACTION_NO_ACK);
2349 #endif /* CONFIG_OFFCHANNEL */
2352 #endif /* CONFIG_AP */
2353 #ifdef CONFIG_OFFCHANNEL
2354 wpa_dbg(wpa_s, MSG_DEBUG, "EVENT_TX_STATUS pending_dst="
2355 MACSTR, MAC2STR(wpa_s->parent->pending_action_dst));
2357 * Catch TX status events for Action frames we sent via group
2358 * interface in GO mode.
2360 if (data->tx_status.type == WLAN_FC_TYPE_MGMT &&
2361 data->tx_status.stype == WLAN_FC_STYPE_ACTION &&
2362 os_memcmp(wpa_s->parent->pending_action_dst,
2363 data->tx_status.dst, ETH_ALEN) == 0) {
2364 offchannel_send_action_tx_status(
2365 wpa_s->parent, data->tx_status.dst,
2366 data->tx_status.data,
2367 data->tx_status.data_len,
2368 data->tx_status.ack ?
2369 OFFCHANNEL_SEND_ACTION_SUCCESS :
2370 OFFCHANNEL_SEND_ACTION_NO_ACK);
2373 #endif /* CONFIG_OFFCHANNEL */
2375 switch (data->tx_status.type) {
2376 case WLAN_FC_TYPE_MGMT:
2377 ap_mgmt_tx_cb(wpa_s, data->tx_status.data,
2378 data->tx_status.data_len,
2379 data->tx_status.stype,
2380 data->tx_status.ack);
2382 case WLAN_FC_TYPE_DATA:
2383 ap_tx_status(wpa_s, data->tx_status.dst,
2384 data->tx_status.data,
2385 data->tx_status.data_len,
2386 data->tx_status.ack);
2389 #endif /* CONFIG_AP */
2392 case EVENT_EAPOL_TX_STATUS:
2393 ap_eapol_tx_status(wpa_s, data->eapol_tx_status.dst,
2394 data->eapol_tx_status.data,
2395 data->eapol_tx_status.data_len,
2396 data->eapol_tx_status.ack);
2398 case EVENT_DRIVER_CLIENT_POLL_OK:
2399 ap_client_poll_ok(wpa_s, data->client_poll.addr);
2401 case EVENT_RX_FROM_UNKNOWN:
2402 if (wpa_s->ap_iface == NULL)
2404 ap_rx_from_unknown_sta(wpa_s, data->rx_from_unknown.addr,
2405 data->rx_from_unknown.wds);
2407 case EVENT_RX_MGMT: {
2409 const struct ieee80211_mgmt *mgmt;
2411 mgmt = (const struct ieee80211_mgmt *)
2412 data->rx_mgmt.frame;
2413 fc = le_to_host16(mgmt->frame_control);
2414 stype = WLAN_FC_GET_STYPE(fc);
2416 if (wpa_s->ap_iface == NULL) {
2418 if (stype == WLAN_FC_STYPE_PROBE_REQ &&
2419 data->rx_mgmt.frame_len > 24) {
2420 const u8 *src = mgmt->sa;
2421 const u8 *ie = mgmt->u.probe_req.variable;
2422 size_t ie_len = data->rx_mgmt.frame_len -
2423 (mgmt->u.probe_req.variable -
2424 data->rx_mgmt.frame);
2425 wpas_p2p_probe_req_rx(
2426 wpa_s, src, mgmt->da,
2427 mgmt->bssid, ie, ie_len,
2428 data->rx_mgmt.ssi_signal);
2431 #endif /* CONFIG_P2P */
2432 wpa_dbg(wpa_s, MSG_DEBUG, "AP: ignore received "
2433 "management frame in non-AP mode");
2437 if (stype == WLAN_FC_STYPE_PROBE_REQ &&
2438 data->rx_mgmt.frame_len > 24) {
2439 const u8 *ie = mgmt->u.probe_req.variable;
2440 size_t ie_len = data->rx_mgmt.frame_len -
2441 (mgmt->u.probe_req.variable -
2442 data->rx_mgmt.frame);
2444 wpas_notify_preq(wpa_s, mgmt->sa, mgmt->da,
2445 mgmt->bssid, ie, ie_len,
2446 data->rx_mgmt.ssi_signal);
2449 ap_mgmt_rx(wpa_s, &data->rx_mgmt);
2452 #endif /* CONFIG_AP */
2453 case EVENT_RX_ACTION:
2454 wpa_dbg(wpa_s, MSG_DEBUG, "Received Action frame: SA=" MACSTR
2455 " Category=%u DataLen=%d freq=%d MHz",
2456 MAC2STR(data->rx_action.sa),
2457 data->rx_action.category, (int) data->rx_action.len,
2458 data->rx_action.freq);
2459 #ifdef CONFIG_IEEE80211R
2460 if (data->rx_action.category == WLAN_ACTION_FT) {
2461 ft_rx_action(wpa_s, data->rx_action.data,
2462 data->rx_action.len);
2465 #endif /* CONFIG_IEEE80211R */
2466 #ifdef CONFIG_IEEE80211W
2468 if (data->rx_action.category == WLAN_ACTION_SA_QUERY) {
2469 sme_sa_query_rx(wpa_s, data->rx_action.sa,
2470 data->rx_action.data,
2471 data->rx_action.len);
2474 #endif /* CONFIG_SME */
2475 #endif /* CONFIG_IEEE80211W */
2477 if (data->rx_action.category == WLAN_ACTION_PUBLIC &&
2478 gas_query_rx(wpa_s->gas, data->rx_action.da,
2479 data->rx_action.sa, data->rx_action.bssid,
2480 data->rx_action.data, data->rx_action.len,
2481 data->rx_action.freq) == 0)
2483 #endif /* CONFIG_GAS */
2484 if (data->rx_action.category == WLAN_ACTION_WNM) {
2485 wnm_action_rx(wpa_s, &data->rx_action);
2489 if (data->rx_action.category == WLAN_ACTION_PUBLIC &&
2490 data->rx_action.len >= 4 &&
2491 data->rx_action.data[0] == WLAN_TDLS_DISCOVERY_RESPONSE) {
2492 wpa_dbg(wpa_s, MSG_DEBUG, "TDLS: Received Discovery "
2493 "Response from " MACSTR,
2494 MAC2STR(data->rx_action.sa));
2497 #endif /* CONFIG_TDLS */
2499 wpas_p2p_rx_action(wpa_s, data->rx_action.da,
2501 data->rx_action.bssid,
2502 data->rx_action.category,
2503 data->rx_action.data,
2504 data->rx_action.len, data->rx_action.freq);
2505 #endif /* CONFIG_P2P */
2507 case EVENT_RX_PROBE_REQ:
2508 if (data->rx_probe_req.sa == NULL ||
2509 data->rx_probe_req.ie == NULL)
2512 if (wpa_s->ap_iface) {
2513 hostapd_probe_req_rx(wpa_s->ap_iface->bss[0],
2514 data->rx_probe_req.sa,
2515 data->rx_probe_req.da,
2516 data->rx_probe_req.bssid,
2517 data->rx_probe_req.ie,
2518 data->rx_probe_req.ie_len,
2519 data->rx_probe_req.ssi_signal);
2522 #endif /* CONFIG_AP */
2524 wpas_p2p_probe_req_rx(wpa_s, data->rx_probe_req.sa,
2525 data->rx_probe_req.da,
2526 data->rx_probe_req.bssid,
2527 data->rx_probe_req.ie,
2528 data->rx_probe_req.ie_len,
2529 data->rx_probe_req.ssi_signal);
2530 #endif /* CONFIG_P2P */
2532 case EVENT_REMAIN_ON_CHANNEL:
2533 #ifdef CONFIG_OFFCHANNEL
2534 offchannel_remain_on_channel_cb(
2535 wpa_s, data->remain_on_channel.freq,
2536 data->remain_on_channel.duration);
2537 #endif /* CONFIG_OFFCHANNEL */
2539 wpas_p2p_remain_on_channel_cb(
2540 wpa_s, data->remain_on_channel.freq,
2541 data->remain_on_channel.duration);
2542 #endif /* CONFIG_P2P */
2544 case EVENT_CANCEL_REMAIN_ON_CHANNEL:
2545 #ifdef CONFIG_OFFCHANNEL
2546 offchannel_cancel_remain_on_channel_cb(
2547 wpa_s, data->remain_on_channel.freq);
2548 #endif /* CONFIG_OFFCHANNEL */
2550 wpas_p2p_cancel_remain_on_channel_cb(
2551 wpa_s, data->remain_on_channel.freq);
2552 #endif /* CONFIG_P2P */
2555 case EVENT_P2P_DEV_FOUND: {
2556 struct p2p_peer_info peer_info;
2558 os_memset(&peer_info, 0, sizeof(peer_info));
2559 if (data->p2p_dev_found.dev_addr)
2560 os_memcpy(peer_info.p2p_device_addr,
2561 data->p2p_dev_found.dev_addr, ETH_ALEN);
2562 if (data->p2p_dev_found.pri_dev_type)
2563 os_memcpy(peer_info.pri_dev_type,
2564 data->p2p_dev_found.pri_dev_type,
2565 sizeof(peer_info.pri_dev_type));
2566 if (data->p2p_dev_found.dev_name)
2567 os_strlcpy(peer_info.device_name,
2568 data->p2p_dev_found.dev_name,
2569 sizeof(peer_info.device_name));
2570 peer_info.config_methods = data->p2p_dev_found.config_methods;
2571 peer_info.dev_capab = data->p2p_dev_found.dev_capab;
2572 peer_info.group_capab = data->p2p_dev_found.group_capab;
2575 * FIX: new_device=1 is not necessarily correct. We should
2576 * maintain a P2P peer database in wpa_supplicant and update
2577 * this information based on whether the peer is truly new.
2579 wpas_dev_found(wpa_s, data->p2p_dev_found.addr, &peer_info, 1);
2582 case EVENT_P2P_GO_NEG_REQ_RX:
2583 wpas_go_neg_req_rx(wpa_s, data->p2p_go_neg_req_rx.src,
2584 data->p2p_go_neg_req_rx.dev_passwd_id);
2586 case EVENT_P2P_GO_NEG_COMPLETED:
2587 wpas_go_neg_completed(wpa_s, data->p2p_go_neg_completed.res);
2589 case EVENT_P2P_PROV_DISC_REQUEST:
2590 wpas_prov_disc_req(wpa_s, data->p2p_prov_disc_req.peer,
2591 data->p2p_prov_disc_req.config_methods,
2592 data->p2p_prov_disc_req.dev_addr,
2593 data->p2p_prov_disc_req.pri_dev_type,
2594 data->p2p_prov_disc_req.dev_name,
2595 data->p2p_prov_disc_req.supp_config_methods,
2596 data->p2p_prov_disc_req.dev_capab,
2597 data->p2p_prov_disc_req.group_capab,
2600 case EVENT_P2P_PROV_DISC_RESPONSE:
2601 wpas_prov_disc_resp(wpa_s, data->p2p_prov_disc_resp.peer,
2602 data->p2p_prov_disc_resp.config_methods);
2604 case EVENT_P2P_SD_REQUEST:
2605 wpas_sd_request(wpa_s, data->p2p_sd_req.freq,
2606 data->p2p_sd_req.sa,
2607 data->p2p_sd_req.dialog_token,
2608 data->p2p_sd_req.update_indic,
2609 data->p2p_sd_req.tlvs,
2610 data->p2p_sd_req.tlvs_len);
2612 case EVENT_P2P_SD_RESPONSE:
2613 wpas_sd_response(wpa_s, data->p2p_sd_resp.sa,
2614 data->p2p_sd_resp.update_indic,
2615 data->p2p_sd_resp.tlvs,
2616 data->p2p_sd_resp.tlvs_len);
2618 #endif /* CONFIG_P2P */
2619 case EVENT_EAPOL_RX:
2620 wpa_supplicant_rx_eapol(wpa_s, data->eapol_rx.src,
2621 data->eapol_rx.data,
2622 data->eapol_rx.data_len);
2624 case EVENT_SIGNAL_CHANGE:
2625 bgscan_notify_signal_change(
2626 wpa_s, data->signal_change.above_threshold,
2627 data->signal_change.current_signal,
2628 data->signal_change.current_noise,
2629 data->signal_change.current_txrate);
2631 case EVENT_INTERFACE_ENABLED:
2632 wpa_dbg(wpa_s, MSG_DEBUG, "Interface was enabled");
2633 if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) {
2634 wpa_supplicant_update_mac_addr(wpa_s);
2636 if (!wpa_s->ap_iface) {
2637 wpa_supplicant_set_state(wpa_s,
2639 wpa_supplicant_req_scan(wpa_s, 0, 0);
2641 wpa_supplicant_set_state(wpa_s,
2643 #else /* CONFIG_AP */
2644 wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
2645 wpa_supplicant_req_scan(wpa_s, 0, 0);
2646 #endif /* CONFIG_AP */
2649 case EVENT_INTERFACE_DISABLED:
2650 wpa_dbg(wpa_s, MSG_DEBUG, "Interface was disabled");
2651 wpa_supplicant_mark_disassoc(wpa_s);
2652 wpa_supplicant_set_state(wpa_s, WPA_INTERFACE_DISABLED);
2654 case EVENT_CHANNEL_LIST_CHANGED:
2655 if (wpa_s->drv_priv == NULL)
2656 break; /* Ignore event during drv initialization */
2658 free_hw_features(wpa_s);
2659 wpa_s->hw.modes = wpa_drv_get_hw_feature_data(
2660 wpa_s, &wpa_s->hw.num_modes, &wpa_s->hw.flags);
2663 wpas_p2p_update_channel_list(wpa_s);
2664 #endif /* CONFIG_P2P */
2666 case EVENT_INTERFACE_UNAVAILABLE:
2668 wpas_p2p_interface_unavailable(wpa_s);
2669 #endif /* CONFIG_P2P */
2671 case EVENT_BEST_CHANNEL:
2672 wpa_dbg(wpa_s, MSG_DEBUG, "Best channel event received "
2674 data->best_chan.freq_24, data->best_chan.freq_5,
2675 data->best_chan.freq_overall);
2676 wpa_s->best_24_freq = data->best_chan.freq_24;
2677 wpa_s->best_5_freq = data->best_chan.freq_5;
2678 wpa_s->best_overall_freq = data->best_chan.freq_overall;
2680 wpas_p2p_update_best_channels(wpa_s, data->best_chan.freq_24,
2681 data->best_chan.freq_5,
2682 data->best_chan.freq_overall);
2683 #endif /* CONFIG_P2P */
2685 case EVENT_UNPROT_DEAUTH:
2686 wpa_supplicant_event_unprot_deauth(wpa_s,
2687 &data->unprot_deauth);
2689 case EVENT_UNPROT_DISASSOC:
2690 wpa_supplicant_event_unprot_disassoc(wpa_s,
2691 &data->unprot_disassoc);
2693 case EVENT_STATION_LOW_ACK:
2695 if (wpa_s->ap_iface && data)
2696 hostapd_event_sta_low_ack(wpa_s->ap_iface->bss[0],
2697 data->low_ack.addr);
2698 #endif /* CONFIG_AP */
2701 wpa_tdls_disable_link(wpa_s->wpa, data->low_ack.addr);
2702 #endif /* CONFIG_TDLS */
2704 case EVENT_IBSS_PEER_LOST:
2705 #ifdef CONFIG_IBSS_RSN
2706 ibss_rsn_stop(wpa_s->ibss_rsn, data->ibss_peer_lost.peer);
2707 #endif /* CONFIG_IBSS_RSN */
2709 case EVENT_DRIVER_GTK_REKEY:
2710 if (os_memcmp(data->driver_gtk_rekey.bssid,
2711 wpa_s->bssid, ETH_ALEN))
2715 wpa_sm_update_replay_ctr(wpa_s->wpa,
2716 data->driver_gtk_rekey.replay_ctr);
2718 case EVENT_SCHED_SCAN_STOPPED:
2719 wpa_s->sched_scanning = 0;
2720 wpa_supplicant_notify_scanning(wpa_s, 0);
2722 if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED)
2726 * If we timed out, start a new sched scan to continue
2727 * searching for more SSIDs.
2729 if (wpa_s->sched_scan_timed_out)
2730 wpa_supplicant_req_sched_scan(wpa_s);
2732 case EVENT_WPS_BUTTON_PUSHED:
2734 wpas_wps_start_pbc(wpa_s, NULL, 0);
2735 #endif /* CONFIG_WPS */
2738 wpa_msg(wpa_s, MSG_INFO, "Unknown event %d", event);