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"
42 #include "offchannel.h"
45 static int wpa_supplicant_select_config(struct wpa_supplicant *wpa_s)
47 struct wpa_ssid *ssid, *old_ssid;
49 if (wpa_s->conf->ap_scan == 1 && wpa_s->current_ssid)
52 wpa_dbg(wpa_s, MSG_DEBUG, "Select network based on association "
54 ssid = wpa_supplicant_get_ssid(wpa_s);
56 wpa_msg(wpa_s, MSG_INFO,
57 "No network configuration found for the current AP");
61 if (wpas_network_disabled(wpa_s, ssid)) {
62 wpa_dbg(wpa_s, MSG_DEBUG, "Selected network is disabled");
66 wpa_dbg(wpa_s, MSG_DEBUG, "Network configuration found for the "
68 if (wpa_key_mgmt_wpa_any(ssid->key_mgmt)) {
70 size_t wpa_ie_len = sizeof(wpa_ie);
71 wpa_supplicant_set_suites(wpa_s, NULL, ssid,
74 wpa_supplicant_set_non_wpa_policy(wpa_s, ssid);
77 if (wpa_s->current_ssid && wpa_s->current_ssid != ssid)
78 eapol_sm_invalidate_cached_session(wpa_s->eapol);
79 old_ssid = wpa_s->current_ssid;
80 wpa_s->current_ssid = ssid;
81 wpa_supplicant_rsn_supp_set_config(wpa_s, wpa_s->current_ssid);
82 wpa_supplicant_initiate_eapol(wpa_s);
83 if (old_ssid != wpa_s->current_ssid)
84 wpas_notify_network_changed(wpa_s);
90 void wpa_supplicant_stop_countermeasures(void *eloop_ctx, void *sock_ctx)
92 struct wpa_supplicant *wpa_s = eloop_ctx;
94 if (wpa_s->countermeasures) {
95 wpa_s->countermeasures = 0;
96 wpa_drv_set_countermeasures(wpa_s, 0);
97 wpa_msg(wpa_s, MSG_INFO, "WPA: TKIP countermeasures stopped");
98 wpa_supplicant_req_scan(wpa_s, 0, 0);
103 void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s)
107 wnm_bss_keep_alive_deinit(wpa_s);
109 #ifdef CONFIG_IBSS_RSN
110 ibss_rsn_deinit(wpa_s->ibss_rsn);
111 wpa_s->ibss_rsn = NULL;
112 #endif /* CONFIG_IBSS_RSN */
115 wpa_supplicant_ap_deinit(wpa_s);
116 #endif /* CONFIG_AP */
118 if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED)
121 wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
122 bssid_changed = !is_zero_ether_addr(wpa_s->bssid);
123 os_memset(wpa_s->bssid, 0, ETH_ALEN);
124 os_memset(wpa_s->pending_bssid, 0, ETH_ALEN);
126 wpa_s->sme.prev_bssid_set = 0;
127 #endif /* CONFIG_SME */
129 os_memset(wpa_s->go_dev_addr, 0, ETH_ALEN);
130 #endif /* CONFIG_P2P */
131 wpa_s->current_bss = NULL;
132 wpa_s->assoc_freq = 0;
133 #ifdef CONFIG_IEEE80211R
135 if (wpa_s->sme.ft_ies)
136 sme_update_ft_ies(wpa_s, NULL, NULL, 0);
137 #endif /* CONFIG_SME */
138 #endif /* CONFIG_IEEE80211R */
141 wpas_notify_bssid_changed(wpa_s);
143 eapol_sm_notify_portEnabled(wpa_s->eapol, FALSE);
144 eapol_sm_notify_portValid(wpa_s->eapol, FALSE);
145 if (wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt))
146 eapol_sm_notify_eap_success(wpa_s->eapol, FALSE);
147 wpa_s->ap_ies_from_associnfo = 0;
151 static void wpa_find_assoc_pmkid(struct wpa_supplicant *wpa_s)
153 struct wpa_ie_data ie;
157 if (wpa_sm_parse_own_wpa_ie(wpa_s->wpa, &ie) < 0 ||
161 for (i = 0; i < ie.num_pmkid; i++) {
162 pmksa_set = pmksa_cache_set_current(wpa_s->wpa,
163 ie.pmkid + i * PMKID_LEN,
165 if (pmksa_set == 0) {
166 eapol_sm_notify_pmkid_attempt(wpa_s->eapol, 1);
171 wpa_dbg(wpa_s, MSG_DEBUG, "RSN: PMKID from assoc IE %sfound from "
172 "PMKSA cache", pmksa_set == 0 ? "" : "not ");
176 static void wpa_supplicant_event_pmkid_candidate(struct wpa_supplicant *wpa_s,
177 union wpa_event_data *data)
180 wpa_dbg(wpa_s, MSG_DEBUG, "RSN: No data in PMKID candidate "
184 wpa_dbg(wpa_s, MSG_DEBUG, "RSN: PMKID candidate event - bssid=" MACSTR
185 " index=%d preauth=%d",
186 MAC2STR(data->pmkid_candidate.bssid),
187 data->pmkid_candidate.index,
188 data->pmkid_candidate.preauth);
190 pmksa_candidate_add(wpa_s->wpa, data->pmkid_candidate.bssid,
191 data->pmkid_candidate.index,
192 data->pmkid_candidate.preauth);
196 static int wpa_supplicant_dynamic_keys(struct wpa_supplicant *wpa_s)
198 if (wpa_s->key_mgmt == WPA_KEY_MGMT_NONE ||
199 wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE)
202 #ifdef IEEE8021X_EAPOL
203 if (wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA &&
204 wpa_s->current_ssid &&
205 !(wpa_s->current_ssid->eapol_flags &
206 (EAPOL_FLAG_REQUIRE_KEY_UNICAST |
207 EAPOL_FLAG_REQUIRE_KEY_BROADCAST))) {
208 /* IEEE 802.1X, but not using dynamic WEP keys (i.e., either
209 * plaintext or static WEP keys). */
212 #endif /* IEEE8021X_EAPOL */
219 * wpa_supplicant_scard_init - Initialize SIM/USIM access with PC/SC
220 * @wpa_s: pointer to wpa_supplicant data
221 * @ssid: Configuration data for the network
222 * Returns: 0 on success, -1 on failure
224 * This function is called when starting authentication with a network that is
225 * configured to use PC/SC for SIM/USIM access (EAP-SIM or EAP-AKA).
227 int wpa_supplicant_scard_init(struct wpa_supplicant *wpa_s,
228 struct wpa_ssid *ssid)
230 #ifdef IEEE8021X_EAPOL
232 int aka = 0, sim = 0, type;
234 if (ssid->eap.pcsc == NULL || wpa_s->scard != NULL)
237 if (ssid->eap.eap_methods == NULL) {
241 struct eap_method_type *eap = ssid->eap.eap_methods;
242 while (eap->vendor != EAP_VENDOR_IETF ||
243 eap->method != EAP_TYPE_NONE) {
244 if (eap->vendor == EAP_VENDOR_IETF) {
245 if (eap->method == EAP_TYPE_SIM)
247 else if (eap->method == EAP_TYPE_AKA ||
248 eap->method == EAP_TYPE_AKA_PRIME)
255 if (eap_peer_get_eap_method(EAP_VENDOR_IETF, EAP_TYPE_SIM) == NULL)
257 if (eap_peer_get_eap_method(EAP_VENDOR_IETF, EAP_TYPE_AKA) == NULL &&
258 eap_peer_get_eap_method(EAP_VENDOR_IETF, EAP_TYPE_AKA_PRIME) ==
263 wpa_dbg(wpa_s, MSG_DEBUG, "Selected network is configured to "
264 "use SIM, but neither EAP-SIM nor EAP-AKA are "
269 wpa_dbg(wpa_s, MSG_DEBUG, "Selected network is configured to use SIM "
270 "(sim=%d aka=%d) - initialize PCSC", sim, aka);
272 type = SCARD_TRY_BOTH;
274 type = SCARD_USIM_ONLY;
276 type = SCARD_GSM_SIM_ONLY;
278 wpa_s->scard = scard_init(type, NULL);
279 if (wpa_s->scard == NULL) {
280 wpa_msg(wpa_s, MSG_WARNING, "Failed to initialize SIM "
284 wpa_sm_set_scard_ctx(wpa_s->wpa, wpa_s->scard);
285 eapol_sm_register_scard_ctx(wpa_s->eapol, wpa_s->scard);
286 #endif /* PCSC_FUNCS */
287 #endif /* IEEE8021X_EAPOL */
293 #ifndef CONFIG_NO_SCAN_PROCESSING
294 static int wpa_supplicant_match_privacy(struct wpa_scan_res *bss,
295 struct wpa_ssid *ssid)
299 if (ssid->mixed_cell)
303 if (ssid->key_mgmt & WPA_KEY_MGMT_WPS)
305 #endif /* CONFIG_WPS */
307 for (i = 0; i < NUM_WEP_KEYS; i++) {
308 if (ssid->wep_key_len[i]) {
313 #ifdef IEEE8021X_EAPOL
314 if ((ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X_NO_WPA) &&
315 ssid->eapol_flags & (EAPOL_FLAG_REQUIRE_KEY_UNICAST |
316 EAPOL_FLAG_REQUIRE_KEY_BROADCAST))
318 #endif /* IEEE8021X_EAPOL */
320 if (wpa_key_mgmt_wpa(ssid->key_mgmt))
323 if (bss->caps & IEEE80211_CAP_PRIVACY)
329 static int wpa_supplicant_ssid_bss_match(struct wpa_supplicant *wpa_s,
330 struct wpa_ssid *ssid,
331 struct wpa_scan_res *bss)
333 struct wpa_ie_data ie;
335 const u8 *rsn_ie, *wpa_ie;
339 ret = wpas_wps_ssid_bss_match(wpa_s, ssid, bss);
343 /* Allow TSN if local configuration accepts WEP use without WPA/WPA2 */
344 wep_ok = !wpa_key_mgmt_wpa(ssid->key_mgmt) &&
345 (((ssid->key_mgmt & WPA_KEY_MGMT_NONE) &&
346 ssid->wep_key_len[ssid->wep_tx_keyidx] > 0) ||
347 (ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X_NO_WPA));
349 rsn_ie = wpa_scan_get_ie(bss, WLAN_EID_RSN);
350 while ((ssid->proto & WPA_PROTO_RSN) && rsn_ie) {
353 if (wpa_parse_wpa_ie(rsn_ie, 2 + rsn_ie[1], &ie)) {
354 wpa_dbg(wpa_s, MSG_DEBUG, " skip RSN IE - parse "
360 (ie.group_cipher & (WPA_CIPHER_WEP40 | WPA_CIPHER_WEP104)))
362 wpa_dbg(wpa_s, MSG_DEBUG, " selected based on TSN "
367 if (!(ie.proto & ssid->proto)) {
368 wpa_dbg(wpa_s, MSG_DEBUG, " skip RSN IE - proto "
373 if (!(ie.pairwise_cipher & ssid->pairwise_cipher)) {
374 wpa_dbg(wpa_s, MSG_DEBUG, " skip RSN IE - PTK "
379 if (!(ie.group_cipher & ssid->group_cipher)) {
380 wpa_dbg(wpa_s, MSG_DEBUG, " skip RSN IE - GTK "
385 if (!(ie.key_mgmt & ssid->key_mgmt)) {
386 wpa_dbg(wpa_s, MSG_DEBUG, " skip RSN IE - key mgmt "
391 #ifdef CONFIG_IEEE80211W
392 if (!(ie.capabilities & WPA_CAPABILITY_MFPC) &&
393 ssid->ieee80211w == MGMT_FRAME_PROTECTION_REQUIRED) {
394 wpa_dbg(wpa_s, MSG_DEBUG, " skip RSN IE - no mgmt "
398 #endif /* CONFIG_IEEE80211W */
400 wpa_dbg(wpa_s, MSG_DEBUG, " selected based on RSN IE");
404 wpa_ie = wpa_scan_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE);
405 while ((ssid->proto & WPA_PROTO_WPA) && wpa_ie) {
408 if (wpa_parse_wpa_ie(wpa_ie, 2 + wpa_ie[1], &ie)) {
409 wpa_dbg(wpa_s, MSG_DEBUG, " skip WPA IE - parse "
415 (ie.group_cipher & (WPA_CIPHER_WEP40 | WPA_CIPHER_WEP104)))
417 wpa_dbg(wpa_s, MSG_DEBUG, " selected based on TSN "
422 if (!(ie.proto & ssid->proto)) {
423 wpa_dbg(wpa_s, MSG_DEBUG, " skip WPA IE - proto "
428 if (!(ie.pairwise_cipher & ssid->pairwise_cipher)) {
429 wpa_dbg(wpa_s, MSG_DEBUG, " skip WPA IE - PTK "
434 if (!(ie.group_cipher & ssid->group_cipher)) {
435 wpa_dbg(wpa_s, MSG_DEBUG, " skip WPA IE - GTK "
440 if (!(ie.key_mgmt & ssid->key_mgmt)) {
441 wpa_dbg(wpa_s, MSG_DEBUG, " skip WPA IE - key mgmt "
446 wpa_dbg(wpa_s, MSG_DEBUG, " selected based on WPA IE");
450 if ((ssid->proto & (WPA_PROTO_WPA | WPA_PROTO_RSN)) &&
451 wpa_key_mgmt_wpa(ssid->key_mgmt) && proto_match == 0) {
452 wpa_dbg(wpa_s, MSG_DEBUG, " skip - no WPA/RSN proto match");
456 if (!wpa_key_mgmt_wpa(ssid->key_mgmt)) {
457 wpa_dbg(wpa_s, MSG_DEBUG, " allow in non-WPA/WPA2");
461 wpa_dbg(wpa_s, MSG_DEBUG, " reject due to mismatch with "
468 static int freq_allowed(int *freqs, int freq)
475 for (i = 0; freqs[i]; i++)
476 if (freqs[i] == freq)
482 static int ht_supported(const struct hostapd_hw_modes *mode)
484 if (!(mode->flags & HOSTAPD_MODE_FLAG_HT_INFO_KNOWN)) {
486 * The driver did not indicate whether it supports HT. Assume
487 * it does to avoid connection issues.
493 * IEEE Std 802.11n-2009 20.1.1:
494 * An HT non-AP STA shall support all EQM rates for one spatial stream.
496 return mode->mcs_set[0] == 0xff;
500 static int rate_match(struct wpa_supplicant *wpa_s, struct wpa_scan_res *bss)
502 const struct hostapd_hw_modes *mode = NULL, *modes;
503 const u8 scan_ie[2] = { WLAN_EID_SUPP_RATES, WLAN_EID_EXT_SUPP_RATES };
508 return 1; /* Cannot do matching without knowing band */
510 modes = wpa_s->hw.modes;
513 * The driver does not provide any additional information
514 * about the utilized hardware, so allow the connection attempt
520 for (i = 0; i < wpa_s->hw.num_modes; i++) {
521 for (j = 0; j < modes[i].num_channels; j++) {
522 int freq = modes[i].channels[j].freq;
523 if (freq == bss->freq) {
525 mode->mode == HOSTAPD_MODE_IEEE80211G)
526 break; /* do not allow 802.11b replace
537 for (i = 0; i < (int) sizeof(scan_ie); i++) {
538 rate_ie = wpa_scan_get_ie(bss, scan_ie[i]);
542 for (j = 2; j < rate_ie[1] + 2; j++) {
543 int flagged = !!(rate_ie[j] & 0x80);
544 int r = (rate_ie[j] & 0x7f) * 5;
547 * IEEE Std 802.11n-2009 7.3.2.2:
548 * The new BSS Membership selector value is encoded
549 * like a legacy basic rate, but it is not a rate and
550 * only indicates if the BSS members are required to
551 * support the mandatory features of Clause 20 [HT PHY]
552 * in order to join the BSS.
554 if (flagged && ((rate_ie[j] & 0x7f) ==
555 BSS_MEMBERSHIP_SELECTOR_HT_PHY)) {
556 if (!ht_supported(mode)) {
557 wpa_dbg(wpa_s, MSG_DEBUG,
558 " hardware does not support "
568 /* check for legacy basic rates */
569 for (k = 0; k < mode->num_rates; k++) {
570 if (mode->rates[k] == r)
573 if (k == mode->num_rates) {
575 * IEEE Std 802.11-2007 7.3.2.2 demands that in
576 * order to join a BSS all required rates
577 * have to be supported by the hardware.
579 wpa_dbg(wpa_s, MSG_DEBUG, " hardware does "
580 "not support required rate %d.%d Mbps",
591 static struct wpa_ssid * wpa_scan_res_match(struct wpa_supplicant *wpa_s,
592 int i, struct wpa_scan_res *bss,
593 struct wpa_ssid *group)
596 u8 wpa_ie_len, rsn_ie_len, ssid_len;
598 struct wpa_blacklist *e;
600 struct wpa_ssid *ssid;
602 ie = wpa_scan_get_ie(bss, WLAN_EID_SSID);
603 ssid_ = ie ? ie + 2 : (u8 *) "";
604 ssid_len = ie ? ie[1] : 0;
606 ie = wpa_scan_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE);
607 wpa_ie_len = ie ? ie[1] : 0;
609 ie = wpa_scan_get_ie(bss, WLAN_EID_RSN);
610 rsn_ie_len = ie ? ie[1] : 0;
612 wpa_dbg(wpa_s, MSG_DEBUG, "%d: " MACSTR " ssid='%s' "
613 "wpa_ie_len=%u rsn_ie_len=%u caps=0x%x level=%d%s",
614 i, MAC2STR(bss->bssid), wpa_ssid_txt(ssid_, ssid_len),
615 wpa_ie_len, rsn_ie_len, bss->caps, bss->level,
616 wpa_scan_get_vendor_ie(bss, WPS_IE_VENDOR_TYPE) ? " wps" : "");
618 e = wpa_blacklist_get(wpa_s, bss->bssid);
621 if (wpa_supplicant_enabled_networks(wpa_s) == 1) {
623 * When only a single network is enabled, we can
624 * trigger blacklisting on the first failure. This
625 * should not be done with multiple enabled networks to
626 * avoid getting forced to move into a worse ESS on
627 * single error if there are no other BSSes of the
632 if (e->count > limit) {
633 wpa_dbg(wpa_s, MSG_DEBUG, " skip - blacklisted "
634 "(count=%d limit=%d)", e->count, limit);
640 wpa_dbg(wpa_s, MSG_DEBUG, " skip - SSID not known");
644 wpa = wpa_ie_len > 0 || rsn_ie_len > 0;
646 for (ssid = group; ssid; ssid = ssid->pnext) {
647 int check_ssid = wpa ? 1 : (ssid->ssid_len != 0);
649 if (wpas_network_disabled(wpa_s, ssid)) {
650 wpa_dbg(wpa_s, MSG_DEBUG, " skip - disabled");
655 if ((ssid->key_mgmt & WPA_KEY_MGMT_WPS) && e && e->count > 0) {
656 wpa_dbg(wpa_s, MSG_DEBUG, " skip - blacklisted "
661 if (wpa && ssid->ssid_len == 0 &&
662 wpas_wps_ssid_wildcard_ok(wpa_s, ssid, bss))
665 if (!wpa && (ssid->key_mgmt & WPA_KEY_MGMT_WPS)) {
666 /* Only allow wildcard SSID match if an AP
667 * advertises active WPS operation that matches
670 if (ssid->ssid_len == 0 &&
671 wpas_wps_ssid_wildcard_ok(wpa_s, ssid, bss))
674 #endif /* CONFIG_WPS */
676 if (ssid->bssid_set && ssid->ssid_len == 0 &&
677 os_memcmp(bss->bssid, ssid->bssid, ETH_ALEN) == 0)
681 (ssid_len != ssid->ssid_len ||
682 os_memcmp(ssid_, ssid->ssid, ssid_len) != 0)) {
683 wpa_dbg(wpa_s, MSG_DEBUG, " skip - SSID mismatch");
687 if (ssid->bssid_set &&
688 os_memcmp(bss->bssid, ssid->bssid, ETH_ALEN) != 0) {
689 wpa_dbg(wpa_s, MSG_DEBUG, " skip - BSSID mismatch");
693 if (!wpa_supplicant_ssid_bss_match(wpa_s, ssid, bss))
697 !(ssid->key_mgmt & WPA_KEY_MGMT_NONE) &&
698 !(ssid->key_mgmt & WPA_KEY_MGMT_WPS) &&
699 !(ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X_NO_WPA)) {
700 wpa_dbg(wpa_s, MSG_DEBUG, " skip - non-WPA network "
705 if (!wpa_supplicant_match_privacy(bss, ssid)) {
706 wpa_dbg(wpa_s, MSG_DEBUG, " skip - privacy "
711 if (bss->caps & IEEE80211_CAP_IBSS) {
712 wpa_dbg(wpa_s, MSG_DEBUG, " skip - IBSS (adhoc) "
717 if (!freq_allowed(ssid->freq_list, bss->freq)) {
718 wpa_dbg(wpa_s, MSG_DEBUG, " skip - frequency not "
723 if (!rate_match(wpa_s, bss)) {
724 wpa_dbg(wpa_s, MSG_DEBUG, " skip - rate sets do "
731 * TODO: skip the AP if its P2P IE has Group Formation
732 * bit set in the P2P Group Capability Bitmap and we
733 * are not in Group Formation with that device.
735 #endif /* CONFIG_P2P */
737 /* Matching configuration found */
741 /* No matching configuration found */
746 static struct wpa_bss *
747 wpa_supplicant_select_bss(struct wpa_supplicant *wpa_s,
748 struct wpa_scan_results *scan_res,
749 struct wpa_ssid *group,
750 struct wpa_ssid **selected_ssid)
754 wpa_dbg(wpa_s, MSG_DEBUG, "Selecting BSS from priority group %d",
757 for (i = 0; i < scan_res->num; i++) {
758 struct wpa_scan_res *bss = scan_res->res[i];
762 *selected_ssid = wpa_scan_res_match(wpa_s, i, bss, group);
766 ie = wpa_scan_get_ie(bss, WLAN_EID_SSID);
767 ssid = ie ? ie + 2 : (u8 *) "";
768 ssid_len = ie ? ie[1] : 0;
770 wpa_dbg(wpa_s, MSG_DEBUG, " selected BSS " MACSTR
772 MAC2STR(bss->bssid), wpa_ssid_txt(ssid, ssid_len));
773 return wpa_bss_get(wpa_s, bss->bssid, ssid, ssid_len);
780 static struct wpa_bss *
781 wpa_supplicant_pick_network(struct wpa_supplicant *wpa_s,
782 struct wpa_scan_results *scan_res,
783 struct wpa_ssid **selected_ssid)
785 struct wpa_bss *selected = NULL;
788 while (selected == NULL) {
789 for (prio = 0; prio < wpa_s->conf->num_prio; prio++) {
790 selected = wpa_supplicant_select_bss(
791 wpa_s, scan_res, wpa_s->conf->pssid[prio],
797 if (selected == NULL && wpa_s->blacklist &&
798 !wpa_s->countermeasures) {
799 wpa_dbg(wpa_s, MSG_DEBUG, "No APs found - clear "
800 "blacklist and try again");
801 wpa_blacklist_clear(wpa_s);
802 wpa_s->blacklist_cleared++;
803 } else if (selected == NULL)
811 static void wpa_supplicant_req_new_scan(struct wpa_supplicant *wpa_s,
812 int timeout_sec, int timeout_usec)
814 if (!wpa_supplicant_enabled_networks(wpa_s)) {
816 * No networks are enabled; short-circuit request so
817 * we don't wait timeout seconds before transitioning
820 wpa_supplicant_set_state(wpa_s, WPA_INACTIVE);
823 wpa_supplicant_req_scan(wpa_s, timeout_sec, timeout_usec);
827 int wpa_supplicant_connect(struct wpa_supplicant *wpa_s,
828 struct wpa_bss *selected,
829 struct wpa_ssid *ssid)
831 if (wpas_wps_scan_pbc_overlap(wpa_s, selected, ssid)) {
832 wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_OVERLAP
833 "PBC session overlap");
835 if (wpas_p2p_notif_pbc_overlap(wpa_s) == 1)
837 #endif /* CONFIG_P2P */
840 wpas_wps_cancel(wpa_s);
841 #endif /* CONFIG_WPS */
846 * Do not trigger new association unless the BSSID has changed or if
847 * reassociation is requested. If we are in process of associating with
848 * the selected BSSID, do not trigger new attempt.
850 if (wpa_s->reassociate ||
851 (os_memcmp(selected->bssid, wpa_s->bssid, ETH_ALEN) != 0 &&
852 ((wpa_s->wpa_state != WPA_ASSOCIATING &&
853 wpa_s->wpa_state != WPA_AUTHENTICATING) ||
854 os_memcmp(selected->bssid, wpa_s->pending_bssid, ETH_ALEN) !=
856 if (wpa_supplicant_scard_init(wpa_s, ssid)) {
857 wpa_supplicant_req_new_scan(wpa_s, 10, 0);
860 wpa_msg(wpa_s, MSG_DEBUG, "Request association: "
861 "reassociate: %d selected: "MACSTR " bssid: " MACSTR
862 " pending: " MACSTR " wpa_state: %s",
863 wpa_s->reassociate, MAC2STR(selected->bssid),
864 MAC2STR(wpa_s->bssid), MAC2STR(wpa_s->pending_bssid),
865 wpa_supplicant_state_txt(wpa_s->wpa_state));
866 wpa_supplicant_associate(wpa_s, selected, ssid);
868 wpa_dbg(wpa_s, MSG_DEBUG, "Already associated with the "
876 static struct wpa_ssid *
877 wpa_supplicant_pick_new_network(struct wpa_supplicant *wpa_s)
880 struct wpa_ssid *ssid;
882 for (prio = 0; prio < wpa_s->conf->num_prio; prio++) {
883 for (ssid = wpa_s->conf->pssid[prio]; ssid; ssid = ssid->pnext)
885 if (wpas_network_disabled(wpa_s, ssid))
887 if (ssid->mode == IEEE80211_MODE_IBSS ||
888 ssid->mode == IEEE80211_MODE_AP)
896 /* TODO: move the rsn_preauth_scan_result*() to be called from notify.c based
897 * on BSS added and BSS changed events */
898 static void wpa_supplicant_rsn_preauth_scan_results(
899 struct wpa_supplicant *wpa_s)
903 if (rsn_preauth_scan_results(wpa_s->wpa) < 0)
906 dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) {
907 const u8 *ssid, *rsn;
909 ssid = wpa_bss_get_ie(bss, WLAN_EID_SSID);
913 rsn = wpa_bss_get_ie(bss, WLAN_EID_RSN);
917 rsn_preauth_scan_result(wpa_s->wpa, bss->bssid, ssid, rsn);
923 static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s,
924 struct wpa_bss *selected,
925 struct wpa_ssid *ssid,
926 struct wpa_scan_results *scan_res)
929 struct wpa_scan_res *current_bss = NULL;
932 if (wpa_s->reassociate)
933 return 1; /* explicit request to reassociate */
934 if (wpa_s->wpa_state < WPA_ASSOCIATED)
935 return 1; /* we are not associated; continue */
936 if (wpa_s->current_ssid == NULL)
937 return 1; /* unknown current SSID */
938 if (wpa_s->current_ssid != ssid)
939 return 1; /* different network block */
941 if (wpas_driver_bss_selection(wpa_s))
942 return 0; /* Driver-based roaming */
944 for (i = 0; i < scan_res->num; i++) {
945 struct wpa_scan_res *res = scan_res->res[i];
947 if (os_memcmp(res->bssid, wpa_s->bssid, ETH_ALEN) != 0)
950 ie = wpa_scan_get_ie(res, WLAN_EID_SSID);
953 if (ie[1] != wpa_s->current_ssid->ssid_len ||
954 os_memcmp(ie + 2, wpa_s->current_ssid->ssid, ie[1]) != 0)
961 return 1; /* current BSS not seen in scan results */
963 #ifndef CONFIG_NO_ROAMING
964 wpa_dbg(wpa_s, MSG_DEBUG, "Considering within-ESS reassociation");
965 wpa_dbg(wpa_s, MSG_DEBUG, "Current BSS: " MACSTR " level=%d",
966 MAC2STR(current_bss->bssid), current_bss->level);
967 wpa_dbg(wpa_s, MSG_DEBUG, "Selected BSS: " MACSTR " level=%d",
968 MAC2STR(selected->bssid), selected->level);
970 if (wpa_s->current_ssid->bssid_set &&
971 os_memcmp(selected->bssid, wpa_s->current_ssid->bssid, ETH_ALEN) ==
973 wpa_dbg(wpa_s, MSG_DEBUG, "Allow reassociation - selected BSS "
974 "has preferred BSSID");
979 if (current_bss->level < 0) {
980 if (current_bss->level < -85)
982 else if (current_bss->level < -80)
984 else if (current_bss->level < -75)
986 else if (current_bss->level < -70)
991 if (abs(current_bss->level - selected->level) < min_diff) {
992 wpa_dbg(wpa_s, MSG_DEBUG, "Skip roam - too small difference "
998 #else /* CONFIG_NO_ROAMING */
1000 #endif /* CONFIG_NO_ROAMING */
1004 /* Return < 0 if no scan results could be fetched. */
1005 static int _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s,
1006 union wpa_event_data *data)
1008 struct wpa_bss *selected;
1009 struct wpa_ssid *ssid = NULL;
1010 struct wpa_scan_results *scan_res;
1014 if (wpa_s->ap_iface)
1016 #endif /* CONFIG_AP */
1018 wpa_supplicant_notify_scanning(wpa_s, 0);
1021 if (wpa_s->p2p_cb_on_scan_complete && !wpa_s->global->p2p_disabled &&
1022 wpa_s->global->p2p != NULL) {
1023 wpa_s->p2p_cb_on_scan_complete = 0;
1024 if (p2p_other_scan_completed(wpa_s->global->p2p) == 1) {
1025 wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Pending P2P operation "
1026 "stopped scan processing");
1030 #endif /* CONFIG_P2P */
1032 scan_res = wpa_supplicant_get_scan_results(wpa_s,
1033 data ? &data->scan_info :
1035 if (scan_res == NULL) {
1036 if (wpa_s->conf->ap_scan == 2 || ap)
1038 wpa_dbg(wpa_s, MSG_DEBUG, "Failed to get scan results - try "
1040 wpa_supplicant_req_new_scan(wpa_s, 1, 0);
1044 #ifndef CONFIG_NO_RANDOM_POOL
1046 num = scan_res->num;
1049 for (i = 0; i < num; i++) {
1051 struct wpa_scan_res *res = scan_res->res[i];
1052 buf[0] = res->bssid[5];
1053 buf[1] = res->qual & 0xff;
1054 buf[2] = res->noise & 0xff;
1055 buf[3] = res->level & 0xff;
1056 buf[4] = res->tsf & 0xff;
1057 random_add_randomness(buf, sizeof(buf));
1059 #endif /* CONFIG_NO_RANDOM_POOL */
1061 if (wpa_s->scan_res_handler) {
1062 void (*scan_res_handler)(struct wpa_supplicant *wpa_s,
1063 struct wpa_scan_results *scan_res);
1065 scan_res_handler = wpa_s->scan_res_handler;
1066 wpa_s->scan_res_handler = NULL;
1067 scan_res_handler(wpa_s, scan_res);
1069 wpa_scan_results_free(scan_res);
1074 wpa_dbg(wpa_s, MSG_DEBUG, "Ignore scan results in AP mode");
1076 if (wpa_s->ap_iface->scan_cb)
1077 wpa_s->ap_iface->scan_cb(wpa_s->ap_iface);
1078 #endif /* CONFIG_AP */
1079 wpa_scan_results_free(scan_res);
1083 wpa_dbg(wpa_s, MSG_DEBUG, "New scan results available");
1084 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_SCAN_RESULTS);
1085 wpas_notify_scan_results(wpa_s);
1087 wpas_notify_scan_done(wpa_s, 1);
1089 if (sme_proc_obss_scan(wpa_s) > 0) {
1090 wpa_scan_results_free(scan_res);
1094 if ((wpa_s->conf->ap_scan == 2 && !wpas_wps_searching(wpa_s))) {
1095 wpa_scan_results_free(scan_res);
1099 if (autoscan_notify_scan(wpa_s, scan_res)) {
1100 wpa_scan_results_free(scan_res);
1104 if (wpa_s->disconnected) {
1105 wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
1106 wpa_scan_results_free(scan_res);
1110 if (!wpas_driver_bss_selection(wpa_s) &&
1111 bgscan_notify_scan(wpa_s, scan_res) == 1) {
1112 wpa_scan_results_free(scan_res);
1116 selected = wpa_supplicant_pick_network(wpa_s, scan_res, &ssid);
1120 skip = !wpa_supplicant_need_to_roam(wpa_s, selected, ssid,
1122 wpa_scan_results_free(scan_res);
1124 wpa_supplicant_rsn_preauth_scan_results(wpa_s);
1128 if (wpa_supplicant_connect(wpa_s, selected, ssid) < 0) {
1129 wpa_dbg(wpa_s, MSG_DEBUG, "Connect failed");
1132 wpa_supplicant_rsn_preauth_scan_results(wpa_s);
1134 wpa_scan_results_free(scan_res);
1135 wpa_dbg(wpa_s, MSG_DEBUG, "No suitable network found");
1136 ssid = wpa_supplicant_pick_new_network(wpa_s);
1138 wpa_dbg(wpa_s, MSG_DEBUG, "Setup a new network");
1139 wpa_supplicant_associate(wpa_s, NULL, ssid);
1140 wpa_supplicant_rsn_preauth_scan_results(wpa_s);
1142 int timeout_sec = wpa_s->scan_interval;
1143 int timeout_usec = 0;
1145 if (wpas_p2p_scan_no_go_seen(wpa_s) == 1)
1148 if (wpa_s->p2p_in_provisioning) {
1150 * Use shorter wait during P2P Provisioning
1151 * state to speed up group formation.
1154 timeout_usec = 250000;
1155 wpa_supplicant_req_new_scan(wpa_s, timeout_sec,
1159 #endif /* CONFIG_P2P */
1160 if (wpa_supplicant_req_sched_scan(wpa_s))
1161 wpa_supplicant_req_new_scan(wpa_s, timeout_sec,
1169 static void wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s,
1170 union wpa_event_data *data)
1172 const char *rn, *rn2;
1173 struct wpa_supplicant *ifs;
1175 if (_wpa_supplicant_event_scan_results(wpa_s, data) < 0) {
1177 * If no scan results could be fetched, then no need to
1178 * notify those interfaces that did not actually request
1185 * Check other interfaces to see if they have the same radio-name. If
1186 * so, they get updated with this same scan info.
1188 if (!wpa_s->driver->get_radio_name)
1191 rn = wpa_s->driver->get_radio_name(wpa_s->drv_priv);
1192 if (rn == NULL || rn[0] == '\0')
1195 wpa_dbg(wpa_s, MSG_DEBUG, "Checking for other virtual interfaces "
1196 "sharing same radio (%s) in event_scan_results", rn);
1198 for (ifs = wpa_s->global->ifaces; ifs; ifs = ifs->next) {
1199 if (ifs == wpa_s || !ifs->driver->get_radio_name)
1202 rn2 = ifs->driver->get_radio_name(ifs->drv_priv);
1203 if (rn2 && os_strcmp(rn, rn2) == 0) {
1204 wpa_printf(MSG_DEBUG, "%s: Updating scan results from "
1205 "sibling", ifs->ifname);
1206 _wpa_supplicant_event_scan_results(ifs, data);
1211 #endif /* CONFIG_NO_SCAN_PROCESSING */
1216 static void wnm_bss_keep_alive(void *eloop_ctx, void *sock_ctx)
1218 struct wpa_supplicant *wpa_s = eloop_ctx;
1220 if (wpa_s->wpa_state < WPA_ASSOCIATED)
1223 wpa_printf(MSG_DEBUG, "WNM: Send keep-alive to AP " MACSTR,
1224 MAC2STR(wpa_s->bssid));
1225 /* TODO: could skip this if normal data traffic has been sent */
1226 /* TODO: Consider using some more appropriate data frame for this */
1228 l2_packet_send(wpa_s->l2, wpa_s->bssid, 0x0800, (u8 *) "", 0);
1231 if (wpa_s->sme.bss_max_idle_period) {
1233 msec = wpa_s->sme.bss_max_idle_period * 1024; /* times 1000 */
1236 eloop_register_timeout(msec / 1000, msec % 1000 * 1000,
1237 wnm_bss_keep_alive, wpa_s, NULL);
1239 #endif /* CONFIG_SME */
1243 static void wnm_process_assoc_resp(struct wpa_supplicant *wpa_s,
1244 const u8 *ies, size_t ies_len)
1246 struct ieee802_11_elems elems;
1251 if (ieee802_11_parse_elems(ies, ies_len, &elems, 1) == ParseFailed)
1255 if (elems.bss_max_idle_period) {
1257 wpa_s->sme.bss_max_idle_period =
1258 WPA_GET_LE16(elems.bss_max_idle_period);
1259 wpa_printf(MSG_DEBUG, "WNM: BSS Max Idle Period: %u (* 1000 "
1260 "TU)%s", wpa_s->sme.bss_max_idle_period,
1261 (elems.bss_max_idle_period[2] & 0x01) ?
1262 " (protected keep-live required)" : "");
1263 if (wpa_s->sme.bss_max_idle_period == 0)
1264 wpa_s->sme.bss_max_idle_period = 1;
1265 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME) {
1266 eloop_cancel_timeout(wnm_bss_keep_alive, wpa_s, NULL);
1267 /* msec times 1000 */
1268 msec = wpa_s->sme.bss_max_idle_period * 1024;
1271 eloop_register_timeout(msec / 1000, msec % 1000 * 1000,
1272 wnm_bss_keep_alive, wpa_s,
1276 #endif /* CONFIG_SME */
1279 #endif /* CONFIG_WNM */
1282 void wnm_bss_keep_alive_deinit(struct wpa_supplicant *wpa_s)
1285 eloop_cancel_timeout(wnm_bss_keep_alive, wpa_s, NULL);
1286 #endif /* CONFIG_WNM */
1290 static int wpa_supplicant_event_associnfo(struct wpa_supplicant *wpa_s,
1291 union wpa_event_data *data)
1293 int l, len, found = 0, wpa_found, rsn_found;
1296 wpa_dbg(wpa_s, MSG_DEBUG, "Association info event");
1297 if (data->assoc_info.req_ies)
1298 wpa_hexdump(MSG_DEBUG, "req_ies", data->assoc_info.req_ies,
1299 data->assoc_info.req_ies_len);
1300 if (data->assoc_info.resp_ies) {
1301 wpa_hexdump(MSG_DEBUG, "resp_ies", data->assoc_info.resp_ies,
1302 data->assoc_info.resp_ies_len);
1304 wpa_tdls_assoc_resp_ies(wpa_s->wpa, data->assoc_info.resp_ies,
1305 data->assoc_info.resp_ies_len);
1306 #endif /* CONFIG_TDLS */
1308 wnm_process_assoc_resp(wpa_s, data->assoc_info.resp_ies,
1309 data->assoc_info.resp_ies_len);
1310 #endif /* CONFIG_WNM */
1312 if (data->assoc_info.beacon_ies)
1313 wpa_hexdump(MSG_DEBUG, "beacon_ies",
1314 data->assoc_info.beacon_ies,
1315 data->assoc_info.beacon_ies_len);
1316 if (data->assoc_info.freq)
1317 wpa_dbg(wpa_s, MSG_DEBUG, "freq=%u MHz",
1318 data->assoc_info.freq);
1320 p = data->assoc_info.req_ies;
1321 l = data->assoc_info.req_ies_len;
1323 /* Go through the IEs and make a copy of the WPA/RSN IE, if present. */
1324 while (p && l >= 2) {
1327 wpa_hexdump(MSG_DEBUG, "Truncated IE in assoc_info",
1331 if ((p[0] == WLAN_EID_VENDOR_SPECIFIC && p[1] >= 6 &&
1332 (os_memcmp(&p[2], "\x00\x50\xF2\x01\x01\x00", 6) == 0)) ||
1333 (p[0] == WLAN_EID_RSN && p[1] >= 2)) {
1334 if (wpa_sm_set_assoc_wpa_ie(wpa_s->wpa, p, len))
1337 wpa_find_assoc_pmkid(wpa_s);
1343 if (!found && data->assoc_info.req_ies)
1344 wpa_sm_set_assoc_wpa_ie(wpa_s->wpa, NULL, 0);
1346 #ifdef CONFIG_IEEE80211R
1348 if (wpa_s->sme.auth_alg == WPA_AUTH_ALG_FT) {
1350 if (wpa_drv_get_bssid(wpa_s, bssid) < 0 ||
1351 wpa_ft_validate_reassoc_resp(wpa_s->wpa,
1352 data->assoc_info.resp_ies,
1353 data->assoc_info.resp_ies_len,
1355 wpa_dbg(wpa_s, MSG_DEBUG, "FT: Validation of "
1356 "Reassociation Response failed");
1357 wpa_supplicant_deauthenticate(
1358 wpa_s, WLAN_REASON_INVALID_IE);
1363 p = data->assoc_info.resp_ies;
1364 l = data->assoc_info.resp_ies_len;
1366 #ifdef CONFIG_WPS_STRICT
1367 if (p && wpa_s->current_ssid &&
1368 wpa_s->current_ssid->key_mgmt == WPA_KEY_MGMT_WPS) {
1370 wps = ieee802_11_vendor_ie_concat(p, l, WPS_IE_VENDOR_TYPE);
1372 wpa_msg(wpa_s, MSG_INFO, "WPS-STRICT: AP did not "
1373 "include WPS IE in (Re)Association Response");
1377 if (wps_validate_assoc_resp(wps) < 0) {
1379 wpa_supplicant_deauthenticate(
1380 wpa_s, WLAN_REASON_INVALID_IE);
1385 #endif /* CONFIG_WPS_STRICT */
1387 /* Go through the IEs and make a copy of the MDIE, if present. */
1388 while (p && l >= 2) {
1391 wpa_hexdump(MSG_DEBUG, "Truncated IE in assoc_info",
1395 if (p[0] == WLAN_EID_MOBILITY_DOMAIN &&
1396 p[1] >= MOBILITY_DOMAIN_ID_LEN) {
1397 wpa_s->sme.ft_used = 1;
1398 os_memcpy(wpa_s->sme.mobility_domain, p + 2,
1399 MOBILITY_DOMAIN_ID_LEN);
1405 #endif /* CONFIG_SME */
1407 wpa_sm_set_ft_params(wpa_s->wpa, data->assoc_info.resp_ies,
1408 data->assoc_info.resp_ies_len);
1409 #endif /* CONFIG_IEEE80211R */
1411 /* WPA/RSN IE from Beacon/ProbeResp */
1412 p = data->assoc_info.beacon_ies;
1413 l = data->assoc_info.beacon_ies_len;
1415 /* Go through the IEs and make a copy of the WPA/RSN IEs, if present.
1417 wpa_found = rsn_found = 0;
1418 while (p && l >= 2) {
1421 wpa_hexdump(MSG_DEBUG, "Truncated IE in beacon_ies",
1426 p[0] == WLAN_EID_VENDOR_SPECIFIC && p[1] >= 6 &&
1427 os_memcmp(&p[2], "\x00\x50\xF2\x01\x01\x00", 6) == 0) {
1429 wpa_sm_set_ap_wpa_ie(wpa_s->wpa, p, len);
1433 p[0] == WLAN_EID_RSN && p[1] >= 2) {
1435 wpa_sm_set_ap_rsn_ie(wpa_s->wpa, p, len);
1442 if (!wpa_found && data->assoc_info.beacon_ies)
1443 wpa_sm_set_ap_wpa_ie(wpa_s->wpa, NULL, 0);
1444 if (!rsn_found && data->assoc_info.beacon_ies)
1445 wpa_sm_set_ap_rsn_ie(wpa_s->wpa, NULL, 0);
1446 if (wpa_found || rsn_found)
1447 wpa_s->ap_ies_from_associnfo = 1;
1449 if (wpa_s->assoc_freq && data->assoc_info.freq &&
1450 wpa_s->assoc_freq != data->assoc_info.freq) {
1451 wpa_printf(MSG_DEBUG, "Operating frequency changed from "
1453 wpa_s->assoc_freq, data->assoc_info.freq);
1454 wpa_supplicant_update_scan_results(wpa_s);
1457 wpa_s->assoc_freq = data->assoc_info.freq;
1463 static struct wpa_bss * wpa_supplicant_get_new_bss(
1464 struct wpa_supplicant *wpa_s, const u8 *bssid)
1466 struct wpa_bss *bss = NULL;
1467 struct wpa_ssid *ssid = wpa_s->current_ssid;
1469 if (ssid->ssid_len > 0)
1470 bss = wpa_bss_get(wpa_s, bssid, ssid->ssid, ssid->ssid_len);
1472 bss = wpa_bss_get_bssid(wpa_s, bssid);
1478 static int wpa_supplicant_assoc_update_ie(struct wpa_supplicant *wpa_s)
1480 const u8 *bss_wpa = NULL, *bss_rsn = NULL;
1482 if (!wpa_s->current_bss || !wpa_s->current_ssid)
1485 if (!wpa_key_mgmt_wpa_any(wpa_s->current_ssid->key_mgmt))
1488 bss_wpa = wpa_bss_get_vendor_ie(wpa_s->current_bss,
1489 WPA_IE_VENDOR_TYPE);
1490 bss_rsn = wpa_bss_get_ie(wpa_s->current_bss, WLAN_EID_RSN);
1492 if (wpa_sm_set_ap_wpa_ie(wpa_s->wpa, bss_wpa,
1493 bss_wpa ? 2 + bss_wpa[1] : 0) ||
1494 wpa_sm_set_ap_rsn_ie(wpa_s->wpa, bss_rsn,
1495 bss_rsn ? 2 + bss_rsn[1] : 0))
1502 static void wpa_supplicant_event_assoc(struct wpa_supplicant *wpa_s,
1503 union wpa_event_data *data)
1508 struct wpa_driver_capa capa;
1511 if (wpa_s->ap_iface) {
1512 hostapd_notif_assoc(wpa_s->ap_iface->bss[0],
1513 data->assoc_info.addr,
1514 data->assoc_info.req_ies,
1515 data->assoc_info.req_ies_len,
1516 data->assoc_info.reassoc);
1519 #endif /* CONFIG_AP */
1521 ft_completed = wpa_ft_is_completed(wpa_s->wpa);
1522 if (data && wpa_supplicant_event_associnfo(wpa_s, data) < 0)
1525 wpa_supplicant_set_state(wpa_s, WPA_ASSOCIATED);
1526 if (wpa_drv_get_bssid(wpa_s, bssid) >= 0 &&
1527 os_memcmp(bssid, wpa_s->bssid, ETH_ALEN) != 0) {
1528 wpa_dbg(wpa_s, MSG_DEBUG, "Associated to a new BSS: BSSID="
1529 MACSTR, MAC2STR(bssid));
1530 random_add_randomness(bssid, ETH_ALEN);
1531 bssid_changed = os_memcmp(wpa_s->bssid, bssid, ETH_ALEN);
1532 os_memcpy(wpa_s->bssid, bssid, ETH_ALEN);
1533 os_memset(wpa_s->pending_bssid, 0, ETH_ALEN);
1535 wpas_notify_bssid_changed(wpa_s);
1537 if (wpa_supplicant_dynamic_keys(wpa_s) && !ft_completed) {
1538 wpa_clear_keys(wpa_s, bssid);
1540 if (wpa_supplicant_select_config(wpa_s) < 0) {
1541 wpa_supplicant_disassociate(
1542 wpa_s, WLAN_REASON_DEAUTH_LEAVING);
1545 if (wpa_s->current_ssid) {
1546 struct wpa_bss *bss = NULL;
1548 bss = wpa_supplicant_get_new_bss(wpa_s, bssid);
1550 wpa_supplicant_update_scan_results(wpa_s);
1552 /* Get the BSS from the new scan results */
1553 bss = wpa_supplicant_get_new_bss(wpa_s, bssid);
1557 wpa_s->current_bss = bss;
1560 if (wpa_s->conf->ap_scan == 1 &&
1561 wpa_s->drv_flags & WPA_DRIVER_FLAGS_BSS_SELECTION) {
1562 if (wpa_supplicant_assoc_update_ie(wpa_s) < 0)
1563 wpa_msg(wpa_s, MSG_WARNING,
1564 "WPA/RSN IEs not updated");
1569 os_memcpy(wpa_s->sme.prev_bssid, bssid, ETH_ALEN);
1570 wpa_s->sme.prev_bssid_set = 1;
1571 #endif /* CONFIG_SME */
1573 wpa_msg(wpa_s, MSG_INFO, "Associated with " MACSTR, MAC2STR(bssid));
1574 if (wpa_s->current_ssid) {
1575 /* When using scanning (ap_scan=1), SIM PC/SC interface can be
1576 * initialized before association, but for other modes,
1577 * initialize PC/SC here, if the current configuration needs
1578 * smartcard or SIM/USIM. */
1579 wpa_supplicant_scard_init(wpa_s, wpa_s->current_ssid);
1581 wpa_sm_notify_assoc(wpa_s->wpa, bssid);
1583 l2_packet_notify_auth_start(wpa_s->l2);
1586 * Set portEnabled first to FALSE in order to get EAP state machine out
1587 * of the SUCCESS state and eapSuccess cleared. Without this, EAPOL PAE
1588 * state machine may transit to AUTHENTICATING state based on obsolete
1589 * eapSuccess and then trigger BE_AUTH to SUCCESS and PAE to
1590 * AUTHENTICATED without ever giving chance to EAP state machine to
1593 if (!ft_completed) {
1594 eapol_sm_notify_portEnabled(wpa_s->eapol, FALSE);
1595 eapol_sm_notify_portValid(wpa_s->eapol, FALSE);
1597 if (wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt) || ft_completed)
1598 eapol_sm_notify_eap_success(wpa_s->eapol, FALSE);
1599 /* 802.1X::portControl = Auto */
1600 eapol_sm_notify_portEnabled(wpa_s->eapol, TRUE);
1601 wpa_s->eapol_received = 0;
1602 if (wpa_s->key_mgmt == WPA_KEY_MGMT_NONE ||
1603 wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE ||
1604 (wpa_s->current_ssid &&
1605 wpa_s->current_ssid->mode == IEEE80211_MODE_IBSS)) {
1606 wpa_supplicant_cancel_auth_timeout(wpa_s);
1607 wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
1608 } else if (!ft_completed) {
1609 /* Timeout for receiving the first EAPOL packet */
1610 wpa_supplicant_req_auth_timeout(wpa_s, 10, 0);
1612 wpa_supplicant_cancel_scan(wpa_s);
1614 if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE) &&
1615 wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt)) {
1617 * We are done; the driver will take care of RSN 4-way
1620 wpa_supplicant_cancel_auth_timeout(wpa_s);
1621 wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
1622 eapol_sm_notify_portValid(wpa_s->eapol, TRUE);
1623 eapol_sm_notify_eap_success(wpa_s->eapol, TRUE);
1624 } else if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE) &&
1625 wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt)) {
1627 * The driver will take care of RSN 4-way handshake, so we need
1628 * to allow EAPOL supplicant to complete its work without
1629 * waiting for WPA supplicant.
1631 eapol_sm_notify_portValid(wpa_s->eapol, TRUE);
1632 } else if (ft_completed) {
1634 * FT protocol completed - make sure EAPOL state machine ends
1635 * up in authenticated.
1637 wpa_supplicant_cancel_auth_timeout(wpa_s);
1638 wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
1639 eapol_sm_notify_portValid(wpa_s->eapol, TRUE);
1640 eapol_sm_notify_eap_success(wpa_s->eapol, TRUE);
1643 if (wpa_s->pending_eapol_rx) {
1644 struct os_time now, age;
1646 os_time_sub(&now, &wpa_s->pending_eapol_rx_time, &age);
1647 if (age.sec == 0 && age.usec < 100000 &&
1648 os_memcmp(wpa_s->pending_eapol_rx_src, bssid, ETH_ALEN) ==
1650 wpa_dbg(wpa_s, MSG_DEBUG, "Process pending EAPOL "
1651 "frame that was received just before "
1652 "association notification");
1653 wpa_supplicant_rx_eapol(
1654 wpa_s, wpa_s->pending_eapol_rx_src,
1655 wpabuf_head(wpa_s->pending_eapol_rx),
1656 wpabuf_len(wpa_s->pending_eapol_rx));
1658 wpabuf_free(wpa_s->pending_eapol_rx);
1659 wpa_s->pending_eapol_rx = NULL;
1662 if ((wpa_s->key_mgmt == WPA_KEY_MGMT_NONE ||
1663 wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA) &&
1664 wpa_s->current_ssid && wpa_drv_get_capa(wpa_s, &capa) == 0 &&
1665 capa.flags & WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC_DONE) {
1666 /* Set static WEP keys again */
1667 wpa_set_wep_keys(wpa_s, wpa_s->current_ssid);
1670 #ifdef CONFIG_IBSS_RSN
1671 if (wpa_s->current_ssid &&
1672 wpa_s->current_ssid->mode == WPAS_MODE_IBSS &&
1673 wpa_s->key_mgmt != WPA_KEY_MGMT_NONE &&
1674 wpa_s->key_mgmt != WPA_KEY_MGMT_WPA_NONE &&
1675 wpa_s->ibss_rsn == NULL) {
1676 wpa_s->ibss_rsn = ibss_rsn_init(wpa_s);
1677 if (!wpa_s->ibss_rsn) {
1678 wpa_msg(wpa_s, MSG_INFO, "Failed to init IBSS RSN");
1679 wpa_supplicant_deauthenticate(
1680 wpa_s, WLAN_REASON_DEAUTH_LEAVING);
1684 ibss_rsn_set_psk(wpa_s->ibss_rsn, wpa_s->current_ssid->psk);
1686 #endif /* CONFIG_IBSS_RSN */
1690 static int disconnect_reason_recoverable(u16 reason_code)
1692 return reason_code == WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY ||
1693 reason_code == WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA ||
1694 reason_code == WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA;
1698 static void wpa_supplicant_event_disassoc(struct wpa_supplicant *wpa_s,
1700 int locally_generated)
1704 u8 prev_pending_bssid[ETH_ALEN];
1705 struct wpa_bss *fast_reconnect = NULL;
1706 struct wpa_ssid *fast_reconnect_ssid = NULL;
1708 authenticating = wpa_s->wpa_state == WPA_AUTHENTICATING;
1709 os_memcpy(prev_pending_bssid, wpa_s->pending_bssid, ETH_ALEN);
1711 if (wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE) {
1713 * At least Host AP driver and a Prism3 card seemed to be
1714 * generating streams of disconnected events when configuring
1715 * IBSS for WPA-None. Ignore them for now.
1717 wpa_dbg(wpa_s, MSG_DEBUG, "Disconnect event - ignore in "
1718 "IBSS/WPA-None mode");
1722 if (wpa_s->wpa_state == WPA_4WAY_HANDSHAKE &&
1723 wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt)) {
1724 wpa_msg(wpa_s, MSG_INFO, "WPA: 4-Way Handshake failed - "
1725 "pre-shared key may be incorrect");
1727 if (!wpa_s->auto_reconnect_disabled ||
1728 wpa_s->key_mgmt == WPA_KEY_MGMT_WPS) {
1729 wpa_dbg(wpa_s, MSG_DEBUG, "Auto connect enabled: try to "
1730 "reconnect (wps=%d wpa_state=%d)",
1731 wpa_s->key_mgmt == WPA_KEY_MGMT_WPS,
1733 if (wpa_s->wpa_state == WPA_COMPLETED &&
1734 wpa_s->current_ssid &&
1735 wpa_s->current_ssid->mode == WPAS_MODE_INFRA &&
1736 !locally_generated &&
1737 disconnect_reason_recoverable(reason_code)) {
1739 * It looks like the AP has dropped association with
1740 * us, but could allow us to get back in. Try to
1741 * reconnect to the same BSS without full scan to save
1742 * time for some common cases.
1744 fast_reconnect = wpa_s->current_bss;
1745 fast_reconnect_ssid = wpa_s->current_ssid;
1746 } else if (wpa_s->wpa_state >= WPA_ASSOCIATING)
1747 wpa_supplicant_req_scan(wpa_s, 0, 100000);
1749 wpa_dbg(wpa_s, MSG_DEBUG, "Do not request new "
1752 wpa_dbg(wpa_s, MSG_DEBUG, "Auto connect disabled: do not "
1753 "try to re-connect");
1754 wpa_s->reassociate = 0;
1755 wpa_s->disconnected = 1;
1756 wpa_supplicant_cancel_sched_scan(wpa_s);
1758 bssid = wpa_s->bssid;
1759 if (is_zero_ether_addr(bssid))
1760 bssid = wpa_s->pending_bssid;
1761 if (wpa_s->wpa_state >= WPA_AUTHENTICATING)
1762 wpas_connection_failed(wpa_s, bssid);
1763 wpa_sm_notify_disassoc(wpa_s->wpa);
1764 if (!is_zero_ether_addr(bssid) ||
1765 wpa_s->wpa_state >= WPA_AUTHENTICATING) {
1766 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_DISCONNECTED "bssid=" MACSTR
1768 MAC2STR(bssid), reason_code,
1769 locally_generated ? " locally_generated=1" : "");
1771 if (wpa_supplicant_dynamic_keys(wpa_s)) {
1772 wpa_dbg(wpa_s, MSG_DEBUG, "Disconnect event - remove keys");
1773 wpa_s->keys_cleared = 0;
1774 wpa_clear_keys(wpa_s, wpa_s->bssid);
1776 wpa_supplicant_mark_disassoc(wpa_s);
1778 if (authenticating && (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME))
1779 sme_disassoc_while_authenticating(wpa_s, prev_pending_bssid);
1781 if (fast_reconnect) {
1782 #ifndef CONFIG_NO_SCAN_PROCESSING
1783 wpa_dbg(wpa_s, MSG_DEBUG, "Try to reconnect to the same BSS");
1784 if (wpa_supplicant_connect(wpa_s, fast_reconnect,
1785 fast_reconnect_ssid) < 0) {
1786 /* Recover through full scan */
1787 wpa_supplicant_req_scan(wpa_s, 0, 100000);
1789 #endif /* CONFIG_NO_SCAN_PROCESSING */
1794 #ifdef CONFIG_DELAYED_MIC_ERROR_REPORT
1795 void wpa_supplicant_delayed_mic_error_report(void *eloop_ctx, void *sock_ctx)
1797 struct wpa_supplicant *wpa_s = eloop_ctx;
1799 if (!wpa_s->pending_mic_error_report)
1802 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: Sending pending MIC error report");
1803 wpa_sm_key_request(wpa_s->wpa, 1, wpa_s->pending_mic_error_pairwise);
1804 wpa_s->pending_mic_error_report = 0;
1806 #endif /* CONFIG_DELAYED_MIC_ERROR_REPORT */
1810 wpa_supplicant_event_michael_mic_failure(struct wpa_supplicant *wpa_s,
1811 union wpa_event_data *data)
1816 wpa_msg(wpa_s, MSG_WARNING, "Michael MIC failure detected");
1817 pairwise = (data && data->michael_mic_failure.unicast);
1819 if ((wpa_s->last_michael_mic_error &&
1820 t.sec - wpa_s->last_michael_mic_error <= 60) ||
1821 wpa_s->pending_mic_error_report) {
1822 if (wpa_s->pending_mic_error_report) {
1824 * Send the pending MIC error report immediately since
1825 * we are going to start countermeasures and AP better
1828 wpa_sm_key_request(wpa_s->wpa, 1,
1829 wpa_s->pending_mic_error_pairwise);
1832 /* Send the new MIC error report immediately since we are going
1833 * to start countermeasures and AP better do the same.
1835 wpa_sm_key_request(wpa_s->wpa, 1, pairwise);
1837 /* initialize countermeasures */
1838 wpa_s->countermeasures = 1;
1840 wpa_blacklist_add(wpa_s, wpa_s->bssid);
1842 wpa_msg(wpa_s, MSG_WARNING, "TKIP countermeasures started");
1845 * Need to wait for completion of request frame. We do not get
1846 * any callback for the message completion, so just wait a
1847 * short while and hope for the best. */
1850 wpa_drv_set_countermeasures(wpa_s, 1);
1851 wpa_supplicant_deauthenticate(wpa_s,
1852 WLAN_REASON_MICHAEL_MIC_FAILURE);
1853 eloop_cancel_timeout(wpa_supplicant_stop_countermeasures,
1855 eloop_register_timeout(60, 0,
1856 wpa_supplicant_stop_countermeasures,
1858 /* TODO: mark the AP rejected for 60 second. STA is
1859 * allowed to associate with another AP.. */
1861 #ifdef CONFIG_DELAYED_MIC_ERROR_REPORT
1862 if (wpa_s->mic_errors_seen) {
1864 * Reduce the effectiveness of Michael MIC error
1865 * reports as a means for attacking against TKIP if
1866 * more than one MIC failure is noticed with the same
1867 * PTK. We delay the transmission of the reports by a
1868 * random time between 0 and 60 seconds in order to
1869 * force the attacker wait 60 seconds before getting
1870 * the information on whether a frame resulted in a MIC
1876 if (os_get_random(rval, sizeof(rval)) < 0)
1877 sec = os_random() % 60;
1879 sec = WPA_GET_BE32(rval) % 60;
1880 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: Delay MIC error "
1881 "report %d seconds", sec);
1882 wpa_s->pending_mic_error_report = 1;
1883 wpa_s->pending_mic_error_pairwise = pairwise;
1884 eloop_cancel_timeout(
1885 wpa_supplicant_delayed_mic_error_report,
1887 eloop_register_timeout(
1888 sec, os_random() % 1000000,
1889 wpa_supplicant_delayed_mic_error_report,
1892 wpa_sm_key_request(wpa_s->wpa, 1, pairwise);
1894 #else /* CONFIG_DELAYED_MIC_ERROR_REPORT */
1895 wpa_sm_key_request(wpa_s->wpa, 1, pairwise);
1896 #endif /* CONFIG_DELAYED_MIC_ERROR_REPORT */
1898 wpa_s->last_michael_mic_error = t.sec;
1899 wpa_s->mic_errors_seen++;
1903 #ifdef CONFIG_TERMINATE_ONLASTIF
1904 static int any_interfaces(struct wpa_supplicant *head)
1906 struct wpa_supplicant *wpa_s;
1908 for (wpa_s = head; wpa_s != NULL; wpa_s = wpa_s->next)
1909 if (!wpa_s->interface_removed)
1913 #endif /* CONFIG_TERMINATE_ONLASTIF */
1917 wpa_supplicant_event_interface_status(struct wpa_supplicant *wpa_s,
1918 union wpa_event_data *data)
1920 if (os_strcmp(wpa_s->ifname, data->interface_status.ifname) != 0)
1923 switch (data->interface_status.ievent) {
1924 case EVENT_INTERFACE_ADDED:
1925 if (!wpa_s->interface_removed)
1927 wpa_s->interface_removed = 0;
1928 wpa_dbg(wpa_s, MSG_DEBUG, "Configured interface was added");
1929 if (wpa_supplicant_driver_init(wpa_s) < 0) {
1930 wpa_msg(wpa_s, MSG_INFO, "Failed to initialize the "
1931 "driver after interface was added");
1933 wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
1935 case EVENT_INTERFACE_REMOVED:
1936 wpa_dbg(wpa_s, MSG_DEBUG, "Configured interface was removed");
1937 wpa_s->interface_removed = 1;
1938 wpa_supplicant_mark_disassoc(wpa_s);
1939 wpa_supplicant_set_state(wpa_s, WPA_INTERFACE_DISABLED);
1940 l2_packet_deinit(wpa_s->l2);
1942 #ifdef CONFIG_IBSS_RSN
1943 ibss_rsn_deinit(wpa_s->ibss_rsn);
1944 wpa_s->ibss_rsn = NULL;
1945 #endif /* CONFIG_IBSS_RSN */
1946 #ifdef CONFIG_TERMINATE_ONLASTIF
1947 /* check if last interface */
1948 if (!any_interfaces(wpa_s->global->ifaces))
1950 #endif /* CONFIG_TERMINATE_ONLASTIF */
1956 #ifdef CONFIG_PEERKEY
1958 wpa_supplicant_event_stkstart(struct wpa_supplicant *wpa_s,
1959 union wpa_event_data *data)
1963 wpa_sm_stkstart(wpa_s->wpa, data->stkstart.peer);
1965 #endif /* CONFIG_PEERKEY */
1969 static void wpa_supplicant_event_tdls(struct wpa_supplicant *wpa_s,
1970 union wpa_event_data *data)
1974 switch (data->tdls.oper) {
1975 case TDLS_REQUEST_SETUP:
1976 wpa_tdls_start(wpa_s->wpa, data->tdls.peer);
1978 case TDLS_REQUEST_TEARDOWN:
1979 wpa_tdls_send_teardown(wpa_s->wpa, data->tdls.peer,
1980 data->tdls.reason_code);
1984 #endif /* CONFIG_TDLS */
1987 #ifdef CONFIG_IEEE80211R
1989 wpa_supplicant_event_ft_response(struct wpa_supplicant *wpa_s,
1990 union wpa_event_data *data)
1995 if (wpa_ft_process_response(wpa_s->wpa, data->ft_ies.ies,
1996 data->ft_ies.ies_len,
1997 data->ft_ies.ft_action,
1998 data->ft_ies.target_ap,
1999 data->ft_ies.ric_ies,
2000 data->ft_ies.ric_ies_len) < 0) {
2001 /* TODO: prevent MLME/driver from trying to associate? */
2004 #endif /* CONFIG_IEEE80211R */
2007 #ifdef CONFIG_IBSS_RSN
2008 static void wpa_supplicant_event_ibss_rsn_start(struct wpa_supplicant *wpa_s,
2009 union wpa_event_data *data)
2011 struct wpa_ssid *ssid;
2012 if (wpa_s->wpa_state < WPA_ASSOCIATED)
2016 ssid = wpa_s->current_ssid;
2019 if (ssid->mode != WPAS_MODE_IBSS || !wpa_key_mgmt_wpa(ssid->key_mgmt))
2022 ibss_rsn_start(wpa_s->ibss_rsn, data->ibss_rsn_start.peer);
2024 #endif /* CONFIG_IBSS_RSN */
2027 #ifdef CONFIG_IEEE80211R
2028 static void ft_rx_action(struct wpa_supplicant *wpa_s, const u8 *data,
2031 const u8 *sta_addr, *target_ap_addr;
2034 wpa_hexdump(MSG_MSGDUMP, "FT: RX Action", data, len);
2035 if (!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME))
2036 return; /* only SME case supported for now */
2037 if (len < 1 + 2 * ETH_ALEN + 2)
2040 return; /* Only FT Action Response is supported for now */
2041 sta_addr = data + 1;
2042 target_ap_addr = data + 1 + ETH_ALEN;
2043 status = WPA_GET_LE16(data + 1 + 2 * ETH_ALEN);
2044 wpa_dbg(wpa_s, MSG_DEBUG, "FT: Received FT Action Response: STA "
2045 MACSTR " TargetAP " MACSTR " status %u",
2046 MAC2STR(sta_addr), MAC2STR(target_ap_addr), status);
2048 if (os_memcmp(sta_addr, wpa_s->own_addr, ETH_ALEN) != 0) {
2049 wpa_dbg(wpa_s, MSG_DEBUG, "FT: Foreign STA Address " MACSTR
2050 " in FT Action Response", MAC2STR(sta_addr));
2055 wpa_dbg(wpa_s, MSG_DEBUG, "FT: FT Action Response indicates "
2056 "failure (status code %d)", status);
2057 /* TODO: report error to FT code(?) */
2061 if (wpa_ft_process_response(wpa_s->wpa, data + 1 + 2 * ETH_ALEN + 2,
2062 len - (1 + 2 * ETH_ALEN + 2), 1,
2063 target_ap_addr, NULL, 0) < 0)
2068 struct wpa_bss *bss;
2069 bss = wpa_bss_get_bssid(wpa_s, target_ap_addr);
2071 wpa_s->sme.freq = bss->freq;
2072 wpa_s->sme.auth_alg = WPA_AUTH_ALG_FT;
2073 sme_associate(wpa_s, WPAS_MODE_INFRA, target_ap_addr,
2076 #endif /* CONFIG_SME */
2078 #endif /* CONFIG_IEEE80211R */
2081 static void wpa_supplicant_event_unprot_deauth(struct wpa_supplicant *wpa_s,
2082 struct unprot_deauth *e)
2084 #ifdef CONFIG_IEEE80211W
2085 wpa_printf(MSG_DEBUG, "Unprotected Deauthentication frame "
2086 "dropped: " MACSTR " -> " MACSTR
2087 " (reason code %u)",
2088 MAC2STR(e->sa), MAC2STR(e->da), e->reason_code);
2089 sme_event_unprot_disconnect(wpa_s, e->sa, e->da, e->reason_code);
2090 #endif /* CONFIG_IEEE80211W */
2094 static void wpa_supplicant_event_unprot_disassoc(struct wpa_supplicant *wpa_s,
2095 struct unprot_disassoc *e)
2097 #ifdef CONFIG_IEEE80211W
2098 wpa_printf(MSG_DEBUG, "Unprotected Disassociation frame "
2099 "dropped: " MACSTR " -> " MACSTR
2100 " (reason code %u)",
2101 MAC2STR(e->sa), MAC2STR(e->da), e->reason_code);
2102 sme_event_unprot_disconnect(wpa_s, e->sa, e->da, e->reason_code);
2103 #endif /* CONFIG_IEEE80211W */
2107 static void wnm_action_rx(struct wpa_supplicant *wpa_s, struct rx_action *rx)
2110 const u8 *pos, *end;
2112 if (rx->data == NULL || rx->len == 0)
2116 end = pos + rx->len;
2119 wpa_printf(MSG_DEBUG, "WNM: RX action %u from " MACSTR,
2120 action, MAC2STR(rx->sa));
2122 case WNM_BSS_TRANS_MGMT_REQ:
2125 wpa_printf(MSG_DEBUG, "WNM: BSS Transition Management "
2126 "Request: dialog_token=%u request_mode=0x%x "
2127 "disassoc_timer=%u validity_interval=%u",
2128 pos[0], pos[1], WPA_GET_LE16(pos + 2), pos[4]);
2132 pos += 12; /* BSS Termination Duration */
2135 if (pos + 1 > end || pos + 1 + pos[0] > end) {
2136 wpa_printf(MSG_DEBUG, "WNM: Invalid BSS "
2137 "Transition Management Request "
2141 os_memcpy(url, pos + 1, pos[0]);
2143 wpa_msg(wpa_s, MSG_INFO, "WNM: ESS Disassociation "
2144 "Imminent - session_info_url=%s", url);
2151 void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
2152 union wpa_event_data *data)
2154 struct wpa_supplicant *wpa_s = ctx;
2155 u16 reason_code = 0;
2156 int locally_generated = 0;
2158 if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED &&
2159 event != EVENT_INTERFACE_ENABLED &&
2160 event != EVENT_INTERFACE_STATUS &&
2161 event != EVENT_SCHED_SCAN_STOPPED) {
2162 wpa_dbg(wpa_s, MSG_DEBUG,
2163 "Ignore event %s (%d) while interface is disabled",
2164 event_to_string(event), event);
2168 #ifndef CONFIG_NO_STDOUT_DEBUG
2170 int level = MSG_DEBUG;
2172 if (event == EVENT_RX_MGMT && data->rx_mgmt.frame_len >= 24) {
2173 const struct ieee80211_hdr *hdr;
2175 hdr = (const struct ieee80211_hdr *) data->rx_mgmt.frame;
2176 fc = le_to_host16(hdr->frame_control);
2177 if (WLAN_FC_GET_TYPE(fc) == WLAN_FC_TYPE_MGMT &&
2178 WLAN_FC_GET_STYPE(fc) == WLAN_FC_STYPE_BEACON)
2179 level = MSG_EXCESSIVE;
2182 wpa_dbg(wpa_s, level, "Event %s (%d) received",
2183 event_to_string(event), event);
2185 #endif /* CONFIG_NO_STDOUT_DEBUG */
2189 sme_event_auth(wpa_s, data);
2192 wpa_supplicant_event_assoc(wpa_s, data);
2194 case EVENT_DISASSOC:
2195 wpa_dbg(wpa_s, MSG_DEBUG, "Disassociation notification");
2197 wpa_dbg(wpa_s, MSG_DEBUG, " * reason %u%s",
2198 data->disassoc_info.reason_code,
2199 data->disassoc_info.locally_generated ?
2200 " (locally generated)" : "");
2201 if (data->disassoc_info.addr)
2202 wpa_dbg(wpa_s, MSG_DEBUG, " * address " MACSTR,
2203 MAC2STR(data->disassoc_info.addr));
2206 if (wpa_s->ap_iface && data && data->disassoc_info.addr) {
2207 hostapd_notif_disassoc(wpa_s->ap_iface->bss[0],
2208 data->disassoc_info.addr);
2211 if (wpa_s->ap_iface) {
2212 wpa_dbg(wpa_s, MSG_DEBUG, "Ignore disassoc event in "
2216 #endif /* CONFIG_AP */
2218 reason_code = data->disassoc_info.reason_code;
2220 data->disassoc_info.locally_generated;
2221 wpa_hexdump(MSG_DEBUG, "Disassociation frame IE(s)",
2222 data->disassoc_info.ie,
2223 data->disassoc_info.ie_len);
2225 wpas_p2p_disassoc_notif(
2226 wpa_s, data->disassoc_info.addr, reason_code,
2227 data->disassoc_info.ie,
2228 data->disassoc_info.ie_len,
2230 #endif /* CONFIG_P2P */
2232 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
2233 sme_event_disassoc(wpa_s, data);
2236 if (event == EVENT_DEAUTH) {
2237 wpa_dbg(wpa_s, MSG_DEBUG,
2238 "Deauthentication notification");
2240 reason_code = data->deauth_info.reason_code;
2242 data->deauth_info.locally_generated;
2243 wpa_dbg(wpa_s, MSG_DEBUG, " * reason %u%s",
2244 data->deauth_info.reason_code,
2245 data->deauth_info.locally_generated ?
2246 " (locally generated)" : "");
2247 if (data->deauth_info.addr) {
2248 wpa_dbg(wpa_s, MSG_DEBUG, " * address "
2250 MAC2STR(data->deauth_info.
2253 wpa_hexdump(MSG_DEBUG,
2254 "Deauthentication frame IE(s)",
2255 data->deauth_info.ie,
2256 data->deauth_info.ie_len);
2260 if (wpa_s->ap_iface && data && data->deauth_info.addr) {
2261 hostapd_notif_disassoc(wpa_s->ap_iface->bss[0],
2262 data->deauth_info.addr);
2265 if (wpa_s->ap_iface) {
2266 wpa_dbg(wpa_s, MSG_DEBUG, "Ignore deauth event in "
2270 #endif /* CONFIG_AP */
2271 wpa_supplicant_event_disassoc(wpa_s, reason_code,
2274 if (event == EVENT_DEAUTH && data) {
2275 wpas_p2p_deauth_notif(wpa_s, data->deauth_info.addr,
2277 data->deauth_info.ie,
2278 data->deauth_info.ie_len,
2281 #endif /* CONFIG_P2P */
2283 case EVENT_MICHAEL_MIC_FAILURE:
2284 wpa_supplicant_event_michael_mic_failure(wpa_s, data);
2286 #ifndef CONFIG_NO_SCAN_PROCESSING
2287 case EVENT_SCAN_RESULTS:
2288 wpa_supplicant_event_scan_results(wpa_s, data);
2290 #endif /* CONFIG_NO_SCAN_PROCESSING */
2291 case EVENT_ASSOCINFO:
2292 wpa_supplicant_event_associnfo(wpa_s, data);
2294 case EVENT_INTERFACE_STATUS:
2295 wpa_supplicant_event_interface_status(wpa_s, data);
2297 case EVENT_PMKID_CANDIDATE:
2298 wpa_supplicant_event_pmkid_candidate(wpa_s, data);
2300 #ifdef CONFIG_PEERKEY
2301 case EVENT_STKSTART:
2302 wpa_supplicant_event_stkstart(wpa_s, data);
2304 #endif /* CONFIG_PEERKEY */
2307 wpa_supplicant_event_tdls(wpa_s, data);
2309 #endif /* CONFIG_TDLS */
2310 #ifdef CONFIG_IEEE80211R
2311 case EVENT_FT_RESPONSE:
2312 wpa_supplicant_event_ft_response(wpa_s, data);
2314 #endif /* CONFIG_IEEE80211R */
2315 #ifdef CONFIG_IBSS_RSN
2316 case EVENT_IBSS_RSN_START:
2317 wpa_supplicant_event_ibss_rsn_start(wpa_s, data);
2319 #endif /* CONFIG_IBSS_RSN */
2320 case EVENT_ASSOC_REJECT:
2321 if (data->assoc_reject.bssid)
2322 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_ASSOC_REJECT
2323 "bssid=" MACSTR " status_code=%u",
2324 MAC2STR(data->assoc_reject.bssid),
2325 data->assoc_reject.status_code);
2327 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_ASSOC_REJECT
2329 data->assoc_reject.status_code);
2330 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
2331 sme_event_assoc_reject(wpa_s, data);
2333 case EVENT_AUTH_TIMED_OUT:
2334 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
2335 sme_event_auth_timed_out(wpa_s, data);
2337 case EVENT_ASSOC_TIMED_OUT:
2338 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
2339 sme_event_assoc_timed_out(wpa_s, data);
2341 case EVENT_TX_STATUS:
2342 wpa_dbg(wpa_s, MSG_DEBUG, "EVENT_TX_STATUS dst=" MACSTR
2343 " type=%d stype=%d",
2344 MAC2STR(data->tx_status.dst),
2345 data->tx_status.type, data->tx_status.stype);
2347 if (wpa_s->ap_iface == NULL) {
2348 #ifdef CONFIG_OFFCHANNEL
2349 if (data->tx_status.type == WLAN_FC_TYPE_MGMT &&
2350 data->tx_status.stype == WLAN_FC_STYPE_ACTION)
2351 offchannel_send_action_tx_status(
2352 wpa_s, data->tx_status.dst,
2353 data->tx_status.data,
2354 data->tx_status.data_len,
2355 data->tx_status.ack ?
2356 OFFCHANNEL_SEND_ACTION_SUCCESS :
2357 OFFCHANNEL_SEND_ACTION_NO_ACK);
2358 #endif /* CONFIG_OFFCHANNEL */
2361 #endif /* CONFIG_AP */
2362 #ifdef CONFIG_OFFCHANNEL
2363 wpa_dbg(wpa_s, MSG_DEBUG, "EVENT_TX_STATUS pending_dst="
2364 MACSTR, MAC2STR(wpa_s->parent->pending_action_dst));
2366 * Catch TX status events for Action frames we sent via group
2367 * interface in GO mode.
2369 if (data->tx_status.type == WLAN_FC_TYPE_MGMT &&
2370 data->tx_status.stype == WLAN_FC_STYPE_ACTION &&
2371 os_memcmp(wpa_s->parent->pending_action_dst,
2372 data->tx_status.dst, ETH_ALEN) == 0) {
2373 offchannel_send_action_tx_status(
2374 wpa_s->parent, data->tx_status.dst,
2375 data->tx_status.data,
2376 data->tx_status.data_len,
2377 data->tx_status.ack ?
2378 OFFCHANNEL_SEND_ACTION_SUCCESS :
2379 OFFCHANNEL_SEND_ACTION_NO_ACK);
2382 #endif /* CONFIG_OFFCHANNEL */
2384 switch (data->tx_status.type) {
2385 case WLAN_FC_TYPE_MGMT:
2386 ap_mgmt_tx_cb(wpa_s, data->tx_status.data,
2387 data->tx_status.data_len,
2388 data->tx_status.stype,
2389 data->tx_status.ack);
2391 case WLAN_FC_TYPE_DATA:
2392 ap_tx_status(wpa_s, data->tx_status.dst,
2393 data->tx_status.data,
2394 data->tx_status.data_len,
2395 data->tx_status.ack);
2398 #endif /* CONFIG_AP */
2401 case EVENT_EAPOL_TX_STATUS:
2402 ap_eapol_tx_status(wpa_s, data->eapol_tx_status.dst,
2403 data->eapol_tx_status.data,
2404 data->eapol_tx_status.data_len,
2405 data->eapol_tx_status.ack);
2407 case EVENT_DRIVER_CLIENT_POLL_OK:
2408 ap_client_poll_ok(wpa_s, data->client_poll.addr);
2410 case EVENT_RX_FROM_UNKNOWN:
2411 if (wpa_s->ap_iface == NULL)
2413 ap_rx_from_unknown_sta(wpa_s, data->rx_from_unknown.addr,
2414 data->rx_from_unknown.wds);
2416 case EVENT_CH_SWITCH:
2419 if (!wpa_s->ap_iface) {
2420 wpa_dbg(wpa_s, MSG_DEBUG, "AP: Ignore channel switch "
2421 "event in non-AP mode");
2426 wpas_ap_ch_switch(wpa_s, data->ch_switch.freq,
2427 data->ch_switch.ht_enabled,
2428 data->ch_switch.ch_offset);
2429 #endif /* CONFIG_AP */
2431 case EVENT_RX_MGMT: {
2433 const struct ieee80211_mgmt *mgmt;
2435 mgmt = (const struct ieee80211_mgmt *)
2436 data->rx_mgmt.frame;
2437 fc = le_to_host16(mgmt->frame_control);
2438 stype = WLAN_FC_GET_STYPE(fc);
2440 if (wpa_s->ap_iface == NULL) {
2442 if (stype == WLAN_FC_STYPE_PROBE_REQ &&
2443 data->rx_mgmt.frame_len > 24) {
2444 const u8 *src = mgmt->sa;
2445 const u8 *ie = mgmt->u.probe_req.variable;
2446 size_t ie_len = data->rx_mgmt.frame_len -
2447 (mgmt->u.probe_req.variable -
2448 data->rx_mgmt.frame);
2449 wpas_p2p_probe_req_rx(
2450 wpa_s, src, mgmt->da,
2451 mgmt->bssid, ie, ie_len,
2452 data->rx_mgmt.ssi_signal);
2455 #endif /* CONFIG_P2P */
2456 wpa_dbg(wpa_s, MSG_DEBUG, "AP: ignore received "
2457 "management frame in non-AP mode");
2461 if (stype == WLAN_FC_STYPE_PROBE_REQ &&
2462 data->rx_mgmt.frame_len > 24) {
2463 const u8 *ie = mgmt->u.probe_req.variable;
2464 size_t ie_len = data->rx_mgmt.frame_len -
2465 (mgmt->u.probe_req.variable -
2466 data->rx_mgmt.frame);
2468 wpas_notify_preq(wpa_s, mgmt->sa, mgmt->da,
2469 mgmt->bssid, ie, ie_len,
2470 data->rx_mgmt.ssi_signal);
2473 ap_mgmt_rx(wpa_s, &data->rx_mgmt);
2476 #endif /* CONFIG_AP */
2477 case EVENT_RX_ACTION:
2478 wpa_dbg(wpa_s, MSG_DEBUG, "Received Action frame: SA=" MACSTR
2479 " Category=%u DataLen=%d freq=%d MHz",
2480 MAC2STR(data->rx_action.sa),
2481 data->rx_action.category, (int) data->rx_action.len,
2482 data->rx_action.freq);
2483 #ifdef CONFIG_IEEE80211R
2484 if (data->rx_action.category == WLAN_ACTION_FT) {
2485 ft_rx_action(wpa_s, data->rx_action.data,
2486 data->rx_action.len);
2489 #endif /* CONFIG_IEEE80211R */
2490 #ifdef CONFIG_IEEE80211W
2492 if (data->rx_action.category == WLAN_ACTION_SA_QUERY) {
2493 sme_sa_query_rx(wpa_s, data->rx_action.sa,
2494 data->rx_action.data,
2495 data->rx_action.len);
2498 #endif /* CONFIG_SME */
2499 #endif /* CONFIG_IEEE80211W */
2501 if (data->rx_action.category == WLAN_ACTION_PUBLIC &&
2502 gas_query_rx(wpa_s->gas, data->rx_action.da,
2503 data->rx_action.sa, data->rx_action.bssid,
2504 data->rx_action.data, data->rx_action.len,
2505 data->rx_action.freq) == 0)
2507 #endif /* CONFIG_GAS */
2508 if (data->rx_action.category == WLAN_ACTION_WNM) {
2509 wnm_action_rx(wpa_s, &data->rx_action);
2513 if (data->rx_action.category == WLAN_ACTION_PUBLIC &&
2514 data->rx_action.len >= 4 &&
2515 data->rx_action.data[0] == WLAN_TDLS_DISCOVERY_RESPONSE) {
2516 wpa_dbg(wpa_s, MSG_DEBUG, "TDLS: Received Discovery "
2517 "Response from " MACSTR,
2518 MAC2STR(data->rx_action.sa));
2521 #endif /* CONFIG_TDLS */
2523 wpas_p2p_rx_action(wpa_s, data->rx_action.da,
2525 data->rx_action.bssid,
2526 data->rx_action.category,
2527 data->rx_action.data,
2528 data->rx_action.len, data->rx_action.freq);
2529 #endif /* CONFIG_P2P */
2531 case EVENT_RX_PROBE_REQ:
2532 if (data->rx_probe_req.sa == NULL ||
2533 data->rx_probe_req.ie == NULL)
2536 if (wpa_s->ap_iface) {
2537 hostapd_probe_req_rx(wpa_s->ap_iface->bss[0],
2538 data->rx_probe_req.sa,
2539 data->rx_probe_req.da,
2540 data->rx_probe_req.bssid,
2541 data->rx_probe_req.ie,
2542 data->rx_probe_req.ie_len,
2543 data->rx_probe_req.ssi_signal);
2546 #endif /* CONFIG_AP */
2548 wpas_p2p_probe_req_rx(wpa_s, data->rx_probe_req.sa,
2549 data->rx_probe_req.da,
2550 data->rx_probe_req.bssid,
2551 data->rx_probe_req.ie,
2552 data->rx_probe_req.ie_len,
2553 data->rx_probe_req.ssi_signal);
2554 #endif /* CONFIG_P2P */
2556 case EVENT_REMAIN_ON_CHANNEL:
2557 #ifdef CONFIG_OFFCHANNEL
2558 offchannel_remain_on_channel_cb(
2559 wpa_s, data->remain_on_channel.freq,
2560 data->remain_on_channel.duration);
2561 #endif /* CONFIG_OFFCHANNEL */
2563 wpas_p2p_remain_on_channel_cb(
2564 wpa_s, data->remain_on_channel.freq,
2565 data->remain_on_channel.duration);
2566 #endif /* CONFIG_P2P */
2568 case EVENT_CANCEL_REMAIN_ON_CHANNEL:
2569 #ifdef CONFIG_OFFCHANNEL
2570 offchannel_cancel_remain_on_channel_cb(
2571 wpa_s, data->remain_on_channel.freq);
2572 #endif /* CONFIG_OFFCHANNEL */
2574 wpas_p2p_cancel_remain_on_channel_cb(
2575 wpa_s, data->remain_on_channel.freq);
2576 #endif /* CONFIG_P2P */
2579 case EVENT_P2P_DEV_FOUND: {
2580 struct p2p_peer_info peer_info;
2582 os_memset(&peer_info, 0, sizeof(peer_info));
2583 if (data->p2p_dev_found.dev_addr)
2584 os_memcpy(peer_info.p2p_device_addr,
2585 data->p2p_dev_found.dev_addr, ETH_ALEN);
2586 if (data->p2p_dev_found.pri_dev_type)
2587 os_memcpy(peer_info.pri_dev_type,
2588 data->p2p_dev_found.pri_dev_type,
2589 sizeof(peer_info.pri_dev_type));
2590 if (data->p2p_dev_found.dev_name)
2591 os_strlcpy(peer_info.device_name,
2592 data->p2p_dev_found.dev_name,
2593 sizeof(peer_info.device_name));
2594 peer_info.config_methods = data->p2p_dev_found.config_methods;
2595 peer_info.dev_capab = data->p2p_dev_found.dev_capab;
2596 peer_info.group_capab = data->p2p_dev_found.group_capab;
2599 * FIX: new_device=1 is not necessarily correct. We should
2600 * maintain a P2P peer database in wpa_supplicant and update
2601 * this information based on whether the peer is truly new.
2603 wpas_dev_found(wpa_s, data->p2p_dev_found.addr, &peer_info, 1);
2606 case EVENT_P2P_GO_NEG_REQ_RX:
2607 wpas_go_neg_req_rx(wpa_s, data->p2p_go_neg_req_rx.src,
2608 data->p2p_go_neg_req_rx.dev_passwd_id);
2610 case EVENT_P2P_GO_NEG_COMPLETED:
2611 wpas_go_neg_completed(wpa_s, data->p2p_go_neg_completed.res);
2613 case EVENT_P2P_PROV_DISC_REQUEST:
2614 wpas_prov_disc_req(wpa_s, data->p2p_prov_disc_req.peer,
2615 data->p2p_prov_disc_req.config_methods,
2616 data->p2p_prov_disc_req.dev_addr,
2617 data->p2p_prov_disc_req.pri_dev_type,
2618 data->p2p_prov_disc_req.dev_name,
2619 data->p2p_prov_disc_req.supp_config_methods,
2620 data->p2p_prov_disc_req.dev_capab,
2621 data->p2p_prov_disc_req.group_capab,
2624 case EVENT_P2P_PROV_DISC_RESPONSE:
2625 wpas_prov_disc_resp(wpa_s, data->p2p_prov_disc_resp.peer,
2626 data->p2p_prov_disc_resp.config_methods);
2628 case EVENT_P2P_SD_REQUEST:
2629 wpas_sd_request(wpa_s, data->p2p_sd_req.freq,
2630 data->p2p_sd_req.sa,
2631 data->p2p_sd_req.dialog_token,
2632 data->p2p_sd_req.update_indic,
2633 data->p2p_sd_req.tlvs,
2634 data->p2p_sd_req.tlvs_len);
2636 case EVENT_P2P_SD_RESPONSE:
2637 wpas_sd_response(wpa_s, data->p2p_sd_resp.sa,
2638 data->p2p_sd_resp.update_indic,
2639 data->p2p_sd_resp.tlvs,
2640 data->p2p_sd_resp.tlvs_len);
2642 #endif /* CONFIG_P2P */
2643 case EVENT_EAPOL_RX:
2644 wpa_supplicant_rx_eapol(wpa_s, data->eapol_rx.src,
2645 data->eapol_rx.data,
2646 data->eapol_rx.data_len);
2648 case EVENT_SIGNAL_CHANGE:
2649 bgscan_notify_signal_change(
2650 wpa_s, data->signal_change.above_threshold,
2651 data->signal_change.current_signal,
2652 data->signal_change.current_noise,
2653 data->signal_change.current_txrate);
2655 case EVENT_INTERFACE_ENABLED:
2656 wpa_dbg(wpa_s, MSG_DEBUG, "Interface was enabled");
2657 if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) {
2658 wpa_supplicant_update_mac_addr(wpa_s);
2660 if (!wpa_s->ap_iface) {
2661 wpa_supplicant_set_state(wpa_s,
2663 wpa_supplicant_req_scan(wpa_s, 0, 0);
2665 wpa_supplicant_set_state(wpa_s,
2667 #else /* CONFIG_AP */
2668 wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
2669 wpa_supplicant_req_scan(wpa_s, 0, 0);
2670 #endif /* CONFIG_AP */
2673 case EVENT_INTERFACE_DISABLED:
2674 wpa_dbg(wpa_s, MSG_DEBUG, "Interface was disabled");
2675 wpa_supplicant_mark_disassoc(wpa_s);
2676 wpa_supplicant_set_state(wpa_s, WPA_INTERFACE_DISABLED);
2678 case EVENT_CHANNEL_LIST_CHANGED:
2679 if (wpa_s->drv_priv == NULL)
2680 break; /* Ignore event during drv initialization */
2682 free_hw_features(wpa_s);
2683 wpa_s->hw.modes = wpa_drv_get_hw_feature_data(
2684 wpa_s, &wpa_s->hw.num_modes, &wpa_s->hw.flags);
2687 wpas_p2p_update_channel_list(wpa_s);
2688 #endif /* CONFIG_P2P */
2690 case EVENT_INTERFACE_UNAVAILABLE:
2692 wpas_p2p_interface_unavailable(wpa_s);
2693 #endif /* CONFIG_P2P */
2695 case EVENT_BEST_CHANNEL:
2696 wpa_dbg(wpa_s, MSG_DEBUG, "Best channel event received "
2698 data->best_chan.freq_24, data->best_chan.freq_5,
2699 data->best_chan.freq_overall);
2700 wpa_s->best_24_freq = data->best_chan.freq_24;
2701 wpa_s->best_5_freq = data->best_chan.freq_5;
2702 wpa_s->best_overall_freq = data->best_chan.freq_overall;
2704 wpas_p2p_update_best_channels(wpa_s, data->best_chan.freq_24,
2705 data->best_chan.freq_5,
2706 data->best_chan.freq_overall);
2707 #endif /* CONFIG_P2P */
2709 case EVENT_UNPROT_DEAUTH:
2710 wpa_supplicant_event_unprot_deauth(wpa_s,
2711 &data->unprot_deauth);
2713 case EVENT_UNPROT_DISASSOC:
2714 wpa_supplicant_event_unprot_disassoc(wpa_s,
2715 &data->unprot_disassoc);
2717 case EVENT_STATION_LOW_ACK:
2719 if (wpa_s->ap_iface && data)
2720 hostapd_event_sta_low_ack(wpa_s->ap_iface->bss[0],
2721 data->low_ack.addr);
2722 #endif /* CONFIG_AP */
2725 wpa_tdls_disable_link(wpa_s->wpa, data->low_ack.addr);
2726 #endif /* CONFIG_TDLS */
2728 case EVENT_IBSS_PEER_LOST:
2729 #ifdef CONFIG_IBSS_RSN
2730 ibss_rsn_stop(wpa_s->ibss_rsn, data->ibss_peer_lost.peer);
2731 #endif /* CONFIG_IBSS_RSN */
2733 case EVENT_DRIVER_GTK_REKEY:
2734 if (os_memcmp(data->driver_gtk_rekey.bssid,
2735 wpa_s->bssid, ETH_ALEN))
2739 wpa_sm_update_replay_ctr(wpa_s->wpa,
2740 data->driver_gtk_rekey.replay_ctr);
2742 case EVENT_SCHED_SCAN_STOPPED:
2743 wpa_s->sched_scanning = 0;
2744 wpa_supplicant_notify_scanning(wpa_s, 0);
2746 if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED)
2750 * If we timed out, start a new sched scan to continue
2751 * searching for more SSIDs.
2753 if (wpa_s->sched_scan_timed_out)
2754 wpa_supplicant_req_sched_scan(wpa_s);
2756 case EVENT_WPS_BUTTON_PUSHED:
2758 wpas_wps_start_pbc(wpa_s, NULL, 0);
2759 #endif /* CONFIG_WPS */
2762 wpa_msg(wpa_s, MSG_INFO, "Unknown event %d", event);