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 (locally_generated)
1765 wpa_s->disconnect_reason = -reason_code;
1767 wpa_s->disconnect_reason = reason_code;
1768 wpas_notify_disconnect_reason(wpa_s);
1769 if (!is_zero_ether_addr(bssid) ||
1770 wpa_s->wpa_state >= WPA_AUTHENTICATING) {
1771 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_DISCONNECTED "bssid=" MACSTR
1773 MAC2STR(bssid), reason_code,
1774 locally_generated ? " locally_generated=1" : "");
1776 if (wpa_supplicant_dynamic_keys(wpa_s)) {
1777 wpa_dbg(wpa_s, MSG_DEBUG, "Disconnect event - remove keys");
1778 wpa_s->keys_cleared = 0;
1779 wpa_clear_keys(wpa_s, wpa_s->bssid);
1781 wpa_supplicant_mark_disassoc(wpa_s);
1783 if (authenticating && (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME))
1784 sme_disassoc_while_authenticating(wpa_s, prev_pending_bssid);
1786 if (fast_reconnect) {
1787 #ifndef CONFIG_NO_SCAN_PROCESSING
1788 wpa_dbg(wpa_s, MSG_DEBUG, "Try to reconnect to the same BSS");
1789 if (wpa_supplicant_connect(wpa_s, fast_reconnect,
1790 fast_reconnect_ssid) < 0) {
1791 /* Recover through full scan */
1792 wpa_supplicant_req_scan(wpa_s, 0, 100000);
1794 #endif /* CONFIG_NO_SCAN_PROCESSING */
1799 #ifdef CONFIG_DELAYED_MIC_ERROR_REPORT
1800 void wpa_supplicant_delayed_mic_error_report(void *eloop_ctx, void *sock_ctx)
1802 struct wpa_supplicant *wpa_s = eloop_ctx;
1804 if (!wpa_s->pending_mic_error_report)
1807 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: Sending pending MIC error report");
1808 wpa_sm_key_request(wpa_s->wpa, 1, wpa_s->pending_mic_error_pairwise);
1809 wpa_s->pending_mic_error_report = 0;
1811 #endif /* CONFIG_DELAYED_MIC_ERROR_REPORT */
1815 wpa_supplicant_event_michael_mic_failure(struct wpa_supplicant *wpa_s,
1816 union wpa_event_data *data)
1821 wpa_msg(wpa_s, MSG_WARNING, "Michael MIC failure detected");
1822 pairwise = (data && data->michael_mic_failure.unicast);
1824 if ((wpa_s->last_michael_mic_error &&
1825 t.sec - wpa_s->last_michael_mic_error <= 60) ||
1826 wpa_s->pending_mic_error_report) {
1827 if (wpa_s->pending_mic_error_report) {
1829 * Send the pending MIC error report immediately since
1830 * we are going to start countermeasures and AP better
1833 wpa_sm_key_request(wpa_s->wpa, 1,
1834 wpa_s->pending_mic_error_pairwise);
1837 /* Send the new MIC error report immediately since we are going
1838 * to start countermeasures and AP better do the same.
1840 wpa_sm_key_request(wpa_s->wpa, 1, pairwise);
1842 /* initialize countermeasures */
1843 wpa_s->countermeasures = 1;
1845 wpa_blacklist_add(wpa_s, wpa_s->bssid);
1847 wpa_msg(wpa_s, MSG_WARNING, "TKIP countermeasures started");
1850 * Need to wait for completion of request frame. We do not get
1851 * any callback for the message completion, so just wait a
1852 * short while and hope for the best. */
1855 wpa_drv_set_countermeasures(wpa_s, 1);
1856 wpa_supplicant_deauthenticate(wpa_s,
1857 WLAN_REASON_MICHAEL_MIC_FAILURE);
1858 eloop_cancel_timeout(wpa_supplicant_stop_countermeasures,
1860 eloop_register_timeout(60, 0,
1861 wpa_supplicant_stop_countermeasures,
1863 /* TODO: mark the AP rejected for 60 second. STA is
1864 * allowed to associate with another AP.. */
1866 #ifdef CONFIG_DELAYED_MIC_ERROR_REPORT
1867 if (wpa_s->mic_errors_seen) {
1869 * Reduce the effectiveness of Michael MIC error
1870 * reports as a means for attacking against TKIP if
1871 * more than one MIC failure is noticed with the same
1872 * PTK. We delay the transmission of the reports by a
1873 * random time between 0 and 60 seconds in order to
1874 * force the attacker wait 60 seconds before getting
1875 * the information on whether a frame resulted in a MIC
1881 if (os_get_random(rval, sizeof(rval)) < 0)
1882 sec = os_random() % 60;
1884 sec = WPA_GET_BE32(rval) % 60;
1885 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: Delay MIC error "
1886 "report %d seconds", sec);
1887 wpa_s->pending_mic_error_report = 1;
1888 wpa_s->pending_mic_error_pairwise = pairwise;
1889 eloop_cancel_timeout(
1890 wpa_supplicant_delayed_mic_error_report,
1892 eloop_register_timeout(
1893 sec, os_random() % 1000000,
1894 wpa_supplicant_delayed_mic_error_report,
1897 wpa_sm_key_request(wpa_s->wpa, 1, pairwise);
1899 #else /* CONFIG_DELAYED_MIC_ERROR_REPORT */
1900 wpa_sm_key_request(wpa_s->wpa, 1, pairwise);
1901 #endif /* CONFIG_DELAYED_MIC_ERROR_REPORT */
1903 wpa_s->last_michael_mic_error = t.sec;
1904 wpa_s->mic_errors_seen++;
1908 #ifdef CONFIG_TERMINATE_ONLASTIF
1909 static int any_interfaces(struct wpa_supplicant *head)
1911 struct wpa_supplicant *wpa_s;
1913 for (wpa_s = head; wpa_s != NULL; wpa_s = wpa_s->next)
1914 if (!wpa_s->interface_removed)
1918 #endif /* CONFIG_TERMINATE_ONLASTIF */
1922 wpa_supplicant_event_interface_status(struct wpa_supplicant *wpa_s,
1923 union wpa_event_data *data)
1925 if (os_strcmp(wpa_s->ifname, data->interface_status.ifname) != 0)
1928 switch (data->interface_status.ievent) {
1929 case EVENT_INTERFACE_ADDED:
1930 if (!wpa_s->interface_removed)
1932 wpa_s->interface_removed = 0;
1933 wpa_dbg(wpa_s, MSG_DEBUG, "Configured interface was added");
1934 if (wpa_supplicant_driver_init(wpa_s) < 0) {
1935 wpa_msg(wpa_s, MSG_INFO, "Failed to initialize the "
1936 "driver after interface was added");
1938 wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
1940 case EVENT_INTERFACE_REMOVED:
1941 wpa_dbg(wpa_s, MSG_DEBUG, "Configured interface was removed");
1942 wpa_s->interface_removed = 1;
1943 wpa_supplicant_mark_disassoc(wpa_s);
1944 wpa_supplicant_set_state(wpa_s, WPA_INTERFACE_DISABLED);
1945 l2_packet_deinit(wpa_s->l2);
1947 #ifdef CONFIG_IBSS_RSN
1948 ibss_rsn_deinit(wpa_s->ibss_rsn);
1949 wpa_s->ibss_rsn = NULL;
1950 #endif /* CONFIG_IBSS_RSN */
1951 #ifdef CONFIG_TERMINATE_ONLASTIF
1952 /* check if last interface */
1953 if (!any_interfaces(wpa_s->global->ifaces))
1955 #endif /* CONFIG_TERMINATE_ONLASTIF */
1961 #ifdef CONFIG_PEERKEY
1963 wpa_supplicant_event_stkstart(struct wpa_supplicant *wpa_s,
1964 union wpa_event_data *data)
1968 wpa_sm_stkstart(wpa_s->wpa, data->stkstart.peer);
1970 #endif /* CONFIG_PEERKEY */
1974 static void wpa_supplicant_event_tdls(struct wpa_supplicant *wpa_s,
1975 union wpa_event_data *data)
1979 switch (data->tdls.oper) {
1980 case TDLS_REQUEST_SETUP:
1981 wpa_tdls_start(wpa_s->wpa, data->tdls.peer);
1983 case TDLS_REQUEST_TEARDOWN:
1984 wpa_tdls_send_teardown(wpa_s->wpa, data->tdls.peer,
1985 data->tdls.reason_code);
1989 #endif /* CONFIG_TDLS */
1992 #ifdef CONFIG_IEEE80211R
1994 wpa_supplicant_event_ft_response(struct wpa_supplicant *wpa_s,
1995 union wpa_event_data *data)
2000 if (wpa_ft_process_response(wpa_s->wpa, data->ft_ies.ies,
2001 data->ft_ies.ies_len,
2002 data->ft_ies.ft_action,
2003 data->ft_ies.target_ap,
2004 data->ft_ies.ric_ies,
2005 data->ft_ies.ric_ies_len) < 0) {
2006 /* TODO: prevent MLME/driver from trying to associate? */
2009 #endif /* CONFIG_IEEE80211R */
2012 #ifdef CONFIG_IBSS_RSN
2013 static void wpa_supplicant_event_ibss_rsn_start(struct wpa_supplicant *wpa_s,
2014 union wpa_event_data *data)
2016 struct wpa_ssid *ssid;
2017 if (wpa_s->wpa_state < WPA_ASSOCIATED)
2021 ssid = wpa_s->current_ssid;
2024 if (ssid->mode != WPAS_MODE_IBSS || !wpa_key_mgmt_wpa(ssid->key_mgmt))
2027 ibss_rsn_start(wpa_s->ibss_rsn, data->ibss_rsn_start.peer);
2029 #endif /* CONFIG_IBSS_RSN */
2032 #ifdef CONFIG_IEEE80211R
2033 static void ft_rx_action(struct wpa_supplicant *wpa_s, const u8 *data,
2036 const u8 *sta_addr, *target_ap_addr;
2039 wpa_hexdump(MSG_MSGDUMP, "FT: RX Action", data, len);
2040 if (!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME))
2041 return; /* only SME case supported for now */
2042 if (len < 1 + 2 * ETH_ALEN + 2)
2045 return; /* Only FT Action Response is supported for now */
2046 sta_addr = data + 1;
2047 target_ap_addr = data + 1 + ETH_ALEN;
2048 status = WPA_GET_LE16(data + 1 + 2 * ETH_ALEN);
2049 wpa_dbg(wpa_s, MSG_DEBUG, "FT: Received FT Action Response: STA "
2050 MACSTR " TargetAP " MACSTR " status %u",
2051 MAC2STR(sta_addr), MAC2STR(target_ap_addr), status);
2053 if (os_memcmp(sta_addr, wpa_s->own_addr, ETH_ALEN) != 0) {
2054 wpa_dbg(wpa_s, MSG_DEBUG, "FT: Foreign STA Address " MACSTR
2055 " in FT Action Response", MAC2STR(sta_addr));
2060 wpa_dbg(wpa_s, MSG_DEBUG, "FT: FT Action Response indicates "
2061 "failure (status code %d)", status);
2062 /* TODO: report error to FT code(?) */
2066 if (wpa_ft_process_response(wpa_s->wpa, data + 1 + 2 * ETH_ALEN + 2,
2067 len - (1 + 2 * ETH_ALEN + 2), 1,
2068 target_ap_addr, NULL, 0) < 0)
2073 struct wpa_bss *bss;
2074 bss = wpa_bss_get_bssid(wpa_s, target_ap_addr);
2076 wpa_s->sme.freq = bss->freq;
2077 wpa_s->sme.auth_alg = WPA_AUTH_ALG_FT;
2078 sme_associate(wpa_s, WPAS_MODE_INFRA, target_ap_addr,
2081 #endif /* CONFIG_SME */
2083 #endif /* CONFIG_IEEE80211R */
2086 static void wpa_supplicant_event_unprot_deauth(struct wpa_supplicant *wpa_s,
2087 struct unprot_deauth *e)
2089 #ifdef CONFIG_IEEE80211W
2090 wpa_printf(MSG_DEBUG, "Unprotected Deauthentication frame "
2091 "dropped: " MACSTR " -> " MACSTR
2092 " (reason code %u)",
2093 MAC2STR(e->sa), MAC2STR(e->da), e->reason_code);
2094 sme_event_unprot_disconnect(wpa_s, e->sa, e->da, e->reason_code);
2095 #endif /* CONFIG_IEEE80211W */
2099 static void wpa_supplicant_event_unprot_disassoc(struct wpa_supplicant *wpa_s,
2100 struct unprot_disassoc *e)
2102 #ifdef CONFIG_IEEE80211W
2103 wpa_printf(MSG_DEBUG, "Unprotected Disassociation frame "
2104 "dropped: " MACSTR " -> " MACSTR
2105 " (reason code %u)",
2106 MAC2STR(e->sa), MAC2STR(e->da), e->reason_code);
2107 sme_event_unprot_disconnect(wpa_s, e->sa, e->da, e->reason_code);
2108 #endif /* CONFIG_IEEE80211W */
2112 static void wnm_action_rx(struct wpa_supplicant *wpa_s, struct rx_action *rx)
2115 const u8 *pos, *end;
2117 if (rx->data == NULL || rx->len == 0)
2121 end = pos + rx->len;
2124 wpa_printf(MSG_DEBUG, "WNM: RX action %u from " MACSTR,
2125 action, MAC2STR(rx->sa));
2127 case WNM_BSS_TRANS_MGMT_REQ:
2130 wpa_printf(MSG_DEBUG, "WNM: BSS Transition Management "
2131 "Request: dialog_token=%u request_mode=0x%x "
2132 "disassoc_timer=%u validity_interval=%u",
2133 pos[0], pos[1], WPA_GET_LE16(pos + 2), pos[4]);
2137 pos += 12; /* BSS Termination Duration */
2140 if (pos + 1 > end || pos + 1 + pos[0] > end) {
2141 wpa_printf(MSG_DEBUG, "WNM: Invalid BSS "
2142 "Transition Management Request "
2146 os_memcpy(url, pos + 1, pos[0]);
2148 wpa_msg(wpa_s, MSG_INFO, "WNM: ESS Disassociation "
2149 "Imminent - session_info_url=%s", url);
2156 void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
2157 union wpa_event_data *data)
2159 struct wpa_supplicant *wpa_s = ctx;
2160 u16 reason_code = 0;
2161 int locally_generated = 0;
2163 if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED &&
2164 event != EVENT_INTERFACE_ENABLED &&
2165 event != EVENT_INTERFACE_STATUS &&
2166 event != EVENT_SCHED_SCAN_STOPPED) {
2167 wpa_dbg(wpa_s, MSG_DEBUG,
2168 "Ignore event %s (%d) while interface is disabled",
2169 event_to_string(event), event);
2173 #ifndef CONFIG_NO_STDOUT_DEBUG
2175 int level = MSG_DEBUG;
2177 if (event == EVENT_RX_MGMT && data->rx_mgmt.frame_len >= 24) {
2178 const struct ieee80211_hdr *hdr;
2180 hdr = (const struct ieee80211_hdr *) data->rx_mgmt.frame;
2181 fc = le_to_host16(hdr->frame_control);
2182 if (WLAN_FC_GET_TYPE(fc) == WLAN_FC_TYPE_MGMT &&
2183 WLAN_FC_GET_STYPE(fc) == WLAN_FC_STYPE_BEACON)
2184 level = MSG_EXCESSIVE;
2187 wpa_dbg(wpa_s, level, "Event %s (%d) received",
2188 event_to_string(event), event);
2190 #endif /* CONFIG_NO_STDOUT_DEBUG */
2194 sme_event_auth(wpa_s, data);
2197 wpa_supplicant_event_assoc(wpa_s, data);
2199 case EVENT_DISASSOC:
2200 wpa_dbg(wpa_s, MSG_DEBUG, "Disassociation notification");
2202 wpa_dbg(wpa_s, MSG_DEBUG, " * reason %u%s",
2203 data->disassoc_info.reason_code,
2204 data->disassoc_info.locally_generated ?
2205 " (locally generated)" : "");
2206 if (data->disassoc_info.addr)
2207 wpa_dbg(wpa_s, MSG_DEBUG, " * address " MACSTR,
2208 MAC2STR(data->disassoc_info.addr));
2211 if (wpa_s->ap_iface && data && data->disassoc_info.addr) {
2212 hostapd_notif_disassoc(wpa_s->ap_iface->bss[0],
2213 data->disassoc_info.addr);
2216 if (wpa_s->ap_iface) {
2217 wpa_dbg(wpa_s, MSG_DEBUG, "Ignore disassoc event in "
2221 #endif /* CONFIG_AP */
2223 reason_code = data->disassoc_info.reason_code;
2225 data->disassoc_info.locally_generated;
2226 wpa_hexdump(MSG_DEBUG, "Disassociation frame IE(s)",
2227 data->disassoc_info.ie,
2228 data->disassoc_info.ie_len);
2230 wpas_p2p_disassoc_notif(
2231 wpa_s, data->disassoc_info.addr, reason_code,
2232 data->disassoc_info.ie,
2233 data->disassoc_info.ie_len,
2235 #endif /* CONFIG_P2P */
2237 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
2238 sme_event_disassoc(wpa_s, data);
2241 if (event == EVENT_DEAUTH) {
2242 wpa_dbg(wpa_s, MSG_DEBUG,
2243 "Deauthentication notification");
2245 reason_code = data->deauth_info.reason_code;
2247 data->deauth_info.locally_generated;
2248 wpa_dbg(wpa_s, MSG_DEBUG, " * reason %u%s",
2249 data->deauth_info.reason_code,
2250 data->deauth_info.locally_generated ?
2251 " (locally generated)" : "");
2252 if (data->deauth_info.addr) {
2253 wpa_dbg(wpa_s, MSG_DEBUG, " * address "
2255 MAC2STR(data->deauth_info.
2258 wpa_hexdump(MSG_DEBUG,
2259 "Deauthentication frame IE(s)",
2260 data->deauth_info.ie,
2261 data->deauth_info.ie_len);
2265 if (wpa_s->ap_iface && data && data->deauth_info.addr) {
2266 hostapd_notif_disassoc(wpa_s->ap_iface->bss[0],
2267 data->deauth_info.addr);
2270 if (wpa_s->ap_iface) {
2271 wpa_dbg(wpa_s, MSG_DEBUG, "Ignore deauth event in "
2275 #endif /* CONFIG_AP */
2276 wpa_supplicant_event_disassoc(wpa_s, reason_code,
2279 if (event == EVENT_DEAUTH && data) {
2280 wpas_p2p_deauth_notif(wpa_s, data->deauth_info.addr,
2282 data->deauth_info.ie,
2283 data->deauth_info.ie_len,
2286 #endif /* CONFIG_P2P */
2288 case EVENT_MICHAEL_MIC_FAILURE:
2289 wpa_supplicant_event_michael_mic_failure(wpa_s, data);
2291 #ifndef CONFIG_NO_SCAN_PROCESSING
2292 case EVENT_SCAN_RESULTS:
2293 wpa_supplicant_event_scan_results(wpa_s, data);
2295 #endif /* CONFIG_NO_SCAN_PROCESSING */
2296 case EVENT_ASSOCINFO:
2297 wpa_supplicant_event_associnfo(wpa_s, data);
2299 case EVENT_INTERFACE_STATUS:
2300 wpa_supplicant_event_interface_status(wpa_s, data);
2302 case EVENT_PMKID_CANDIDATE:
2303 wpa_supplicant_event_pmkid_candidate(wpa_s, data);
2305 #ifdef CONFIG_PEERKEY
2306 case EVENT_STKSTART:
2307 wpa_supplicant_event_stkstart(wpa_s, data);
2309 #endif /* CONFIG_PEERKEY */
2312 wpa_supplicant_event_tdls(wpa_s, data);
2314 #endif /* CONFIG_TDLS */
2315 #ifdef CONFIG_IEEE80211R
2316 case EVENT_FT_RESPONSE:
2317 wpa_supplicant_event_ft_response(wpa_s, data);
2319 #endif /* CONFIG_IEEE80211R */
2320 #ifdef CONFIG_IBSS_RSN
2321 case EVENT_IBSS_RSN_START:
2322 wpa_supplicant_event_ibss_rsn_start(wpa_s, data);
2324 #endif /* CONFIG_IBSS_RSN */
2325 case EVENT_ASSOC_REJECT:
2326 if (data->assoc_reject.bssid)
2327 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_ASSOC_REJECT
2328 "bssid=" MACSTR " status_code=%u",
2329 MAC2STR(data->assoc_reject.bssid),
2330 data->assoc_reject.status_code);
2332 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_ASSOC_REJECT
2334 data->assoc_reject.status_code);
2335 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
2336 sme_event_assoc_reject(wpa_s, data);
2338 case EVENT_AUTH_TIMED_OUT:
2339 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
2340 sme_event_auth_timed_out(wpa_s, data);
2342 case EVENT_ASSOC_TIMED_OUT:
2343 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
2344 sme_event_assoc_timed_out(wpa_s, data);
2346 case EVENT_TX_STATUS:
2347 wpa_dbg(wpa_s, MSG_DEBUG, "EVENT_TX_STATUS dst=" MACSTR
2348 " type=%d stype=%d",
2349 MAC2STR(data->tx_status.dst),
2350 data->tx_status.type, data->tx_status.stype);
2352 if (wpa_s->ap_iface == NULL) {
2353 #ifdef CONFIG_OFFCHANNEL
2354 if (data->tx_status.type == WLAN_FC_TYPE_MGMT &&
2355 data->tx_status.stype == WLAN_FC_STYPE_ACTION)
2356 offchannel_send_action_tx_status(
2357 wpa_s, data->tx_status.dst,
2358 data->tx_status.data,
2359 data->tx_status.data_len,
2360 data->tx_status.ack ?
2361 OFFCHANNEL_SEND_ACTION_SUCCESS :
2362 OFFCHANNEL_SEND_ACTION_NO_ACK);
2363 #endif /* CONFIG_OFFCHANNEL */
2366 #endif /* CONFIG_AP */
2367 #ifdef CONFIG_OFFCHANNEL
2368 wpa_dbg(wpa_s, MSG_DEBUG, "EVENT_TX_STATUS pending_dst="
2369 MACSTR, MAC2STR(wpa_s->parent->pending_action_dst));
2371 * Catch TX status events for Action frames we sent via group
2372 * interface in GO mode.
2374 if (data->tx_status.type == WLAN_FC_TYPE_MGMT &&
2375 data->tx_status.stype == WLAN_FC_STYPE_ACTION &&
2376 os_memcmp(wpa_s->parent->pending_action_dst,
2377 data->tx_status.dst, ETH_ALEN) == 0) {
2378 offchannel_send_action_tx_status(
2379 wpa_s->parent, data->tx_status.dst,
2380 data->tx_status.data,
2381 data->tx_status.data_len,
2382 data->tx_status.ack ?
2383 OFFCHANNEL_SEND_ACTION_SUCCESS :
2384 OFFCHANNEL_SEND_ACTION_NO_ACK);
2387 #endif /* CONFIG_OFFCHANNEL */
2389 switch (data->tx_status.type) {
2390 case WLAN_FC_TYPE_MGMT:
2391 ap_mgmt_tx_cb(wpa_s, data->tx_status.data,
2392 data->tx_status.data_len,
2393 data->tx_status.stype,
2394 data->tx_status.ack);
2396 case WLAN_FC_TYPE_DATA:
2397 ap_tx_status(wpa_s, data->tx_status.dst,
2398 data->tx_status.data,
2399 data->tx_status.data_len,
2400 data->tx_status.ack);
2403 #endif /* CONFIG_AP */
2406 case EVENT_EAPOL_TX_STATUS:
2407 ap_eapol_tx_status(wpa_s, data->eapol_tx_status.dst,
2408 data->eapol_tx_status.data,
2409 data->eapol_tx_status.data_len,
2410 data->eapol_tx_status.ack);
2412 case EVENT_DRIVER_CLIENT_POLL_OK:
2413 ap_client_poll_ok(wpa_s, data->client_poll.addr);
2415 case EVENT_RX_FROM_UNKNOWN:
2416 if (wpa_s->ap_iface == NULL)
2418 ap_rx_from_unknown_sta(wpa_s, data->rx_from_unknown.addr,
2419 data->rx_from_unknown.wds);
2421 case EVENT_CH_SWITCH:
2424 if (!wpa_s->ap_iface) {
2425 wpa_dbg(wpa_s, MSG_DEBUG, "AP: Ignore channel switch "
2426 "event in non-AP mode");
2431 wpas_ap_ch_switch(wpa_s, data->ch_switch.freq,
2432 data->ch_switch.ht_enabled,
2433 data->ch_switch.ch_offset);
2434 #endif /* CONFIG_AP */
2436 case EVENT_RX_MGMT: {
2438 const struct ieee80211_mgmt *mgmt;
2440 mgmt = (const struct ieee80211_mgmt *)
2441 data->rx_mgmt.frame;
2442 fc = le_to_host16(mgmt->frame_control);
2443 stype = WLAN_FC_GET_STYPE(fc);
2445 if (wpa_s->ap_iface == NULL) {
2447 if (stype == WLAN_FC_STYPE_PROBE_REQ &&
2448 data->rx_mgmt.frame_len > 24) {
2449 const u8 *src = mgmt->sa;
2450 const u8 *ie = mgmt->u.probe_req.variable;
2451 size_t ie_len = data->rx_mgmt.frame_len -
2452 (mgmt->u.probe_req.variable -
2453 data->rx_mgmt.frame);
2454 wpas_p2p_probe_req_rx(
2455 wpa_s, src, mgmt->da,
2456 mgmt->bssid, ie, ie_len,
2457 data->rx_mgmt.ssi_signal);
2460 #endif /* CONFIG_P2P */
2461 wpa_dbg(wpa_s, MSG_DEBUG, "AP: ignore received "
2462 "management frame in non-AP mode");
2466 if (stype == WLAN_FC_STYPE_PROBE_REQ &&
2467 data->rx_mgmt.frame_len > 24) {
2468 const u8 *ie = mgmt->u.probe_req.variable;
2469 size_t ie_len = data->rx_mgmt.frame_len -
2470 (mgmt->u.probe_req.variable -
2471 data->rx_mgmt.frame);
2473 wpas_notify_preq(wpa_s, mgmt->sa, mgmt->da,
2474 mgmt->bssid, ie, ie_len,
2475 data->rx_mgmt.ssi_signal);
2478 ap_mgmt_rx(wpa_s, &data->rx_mgmt);
2481 #endif /* CONFIG_AP */
2482 case EVENT_RX_ACTION:
2483 wpa_dbg(wpa_s, MSG_DEBUG, "Received Action frame: SA=" MACSTR
2484 " Category=%u DataLen=%d freq=%d MHz",
2485 MAC2STR(data->rx_action.sa),
2486 data->rx_action.category, (int) data->rx_action.len,
2487 data->rx_action.freq);
2488 #ifdef CONFIG_IEEE80211R
2489 if (data->rx_action.category == WLAN_ACTION_FT) {
2490 ft_rx_action(wpa_s, data->rx_action.data,
2491 data->rx_action.len);
2494 #endif /* CONFIG_IEEE80211R */
2495 #ifdef CONFIG_IEEE80211W
2497 if (data->rx_action.category == WLAN_ACTION_SA_QUERY) {
2498 sme_sa_query_rx(wpa_s, data->rx_action.sa,
2499 data->rx_action.data,
2500 data->rx_action.len);
2503 #endif /* CONFIG_SME */
2504 #endif /* CONFIG_IEEE80211W */
2506 if (data->rx_action.category == WLAN_ACTION_PUBLIC &&
2507 gas_query_rx(wpa_s->gas, data->rx_action.da,
2508 data->rx_action.sa, data->rx_action.bssid,
2509 data->rx_action.data, data->rx_action.len,
2510 data->rx_action.freq) == 0)
2512 #endif /* CONFIG_GAS */
2513 if (data->rx_action.category == WLAN_ACTION_WNM) {
2514 wnm_action_rx(wpa_s, &data->rx_action);
2518 if (data->rx_action.category == WLAN_ACTION_PUBLIC &&
2519 data->rx_action.len >= 4 &&
2520 data->rx_action.data[0] == WLAN_TDLS_DISCOVERY_RESPONSE) {
2521 wpa_dbg(wpa_s, MSG_DEBUG, "TDLS: Received Discovery "
2522 "Response from " MACSTR,
2523 MAC2STR(data->rx_action.sa));
2526 #endif /* CONFIG_TDLS */
2528 wpas_p2p_rx_action(wpa_s, data->rx_action.da,
2530 data->rx_action.bssid,
2531 data->rx_action.category,
2532 data->rx_action.data,
2533 data->rx_action.len, data->rx_action.freq);
2534 #endif /* CONFIG_P2P */
2536 case EVENT_RX_PROBE_REQ:
2537 if (data->rx_probe_req.sa == NULL ||
2538 data->rx_probe_req.ie == NULL)
2541 if (wpa_s->ap_iface) {
2542 hostapd_probe_req_rx(wpa_s->ap_iface->bss[0],
2543 data->rx_probe_req.sa,
2544 data->rx_probe_req.da,
2545 data->rx_probe_req.bssid,
2546 data->rx_probe_req.ie,
2547 data->rx_probe_req.ie_len,
2548 data->rx_probe_req.ssi_signal);
2551 #endif /* CONFIG_AP */
2553 wpas_p2p_probe_req_rx(wpa_s, data->rx_probe_req.sa,
2554 data->rx_probe_req.da,
2555 data->rx_probe_req.bssid,
2556 data->rx_probe_req.ie,
2557 data->rx_probe_req.ie_len,
2558 data->rx_probe_req.ssi_signal);
2559 #endif /* CONFIG_P2P */
2561 case EVENT_REMAIN_ON_CHANNEL:
2562 #ifdef CONFIG_OFFCHANNEL
2563 offchannel_remain_on_channel_cb(
2564 wpa_s, data->remain_on_channel.freq,
2565 data->remain_on_channel.duration);
2566 #endif /* CONFIG_OFFCHANNEL */
2568 wpas_p2p_remain_on_channel_cb(
2569 wpa_s, data->remain_on_channel.freq,
2570 data->remain_on_channel.duration);
2571 #endif /* CONFIG_P2P */
2573 case EVENT_CANCEL_REMAIN_ON_CHANNEL:
2574 #ifdef CONFIG_OFFCHANNEL
2575 offchannel_cancel_remain_on_channel_cb(
2576 wpa_s, data->remain_on_channel.freq);
2577 #endif /* CONFIG_OFFCHANNEL */
2579 wpas_p2p_cancel_remain_on_channel_cb(
2580 wpa_s, data->remain_on_channel.freq);
2581 #endif /* CONFIG_P2P */
2584 case EVENT_P2P_DEV_FOUND: {
2585 struct p2p_peer_info peer_info;
2587 os_memset(&peer_info, 0, sizeof(peer_info));
2588 if (data->p2p_dev_found.dev_addr)
2589 os_memcpy(peer_info.p2p_device_addr,
2590 data->p2p_dev_found.dev_addr, ETH_ALEN);
2591 if (data->p2p_dev_found.pri_dev_type)
2592 os_memcpy(peer_info.pri_dev_type,
2593 data->p2p_dev_found.pri_dev_type,
2594 sizeof(peer_info.pri_dev_type));
2595 if (data->p2p_dev_found.dev_name)
2596 os_strlcpy(peer_info.device_name,
2597 data->p2p_dev_found.dev_name,
2598 sizeof(peer_info.device_name));
2599 peer_info.config_methods = data->p2p_dev_found.config_methods;
2600 peer_info.dev_capab = data->p2p_dev_found.dev_capab;
2601 peer_info.group_capab = data->p2p_dev_found.group_capab;
2604 * FIX: new_device=1 is not necessarily correct. We should
2605 * maintain a P2P peer database in wpa_supplicant and update
2606 * this information based on whether the peer is truly new.
2608 wpas_dev_found(wpa_s, data->p2p_dev_found.addr, &peer_info, 1);
2611 case EVENT_P2P_GO_NEG_REQ_RX:
2612 wpas_go_neg_req_rx(wpa_s, data->p2p_go_neg_req_rx.src,
2613 data->p2p_go_neg_req_rx.dev_passwd_id);
2615 case EVENT_P2P_GO_NEG_COMPLETED:
2616 wpas_go_neg_completed(wpa_s, data->p2p_go_neg_completed.res);
2618 case EVENT_P2P_PROV_DISC_REQUEST:
2619 wpas_prov_disc_req(wpa_s, data->p2p_prov_disc_req.peer,
2620 data->p2p_prov_disc_req.config_methods,
2621 data->p2p_prov_disc_req.dev_addr,
2622 data->p2p_prov_disc_req.pri_dev_type,
2623 data->p2p_prov_disc_req.dev_name,
2624 data->p2p_prov_disc_req.supp_config_methods,
2625 data->p2p_prov_disc_req.dev_capab,
2626 data->p2p_prov_disc_req.group_capab,
2629 case EVENT_P2P_PROV_DISC_RESPONSE:
2630 wpas_prov_disc_resp(wpa_s, data->p2p_prov_disc_resp.peer,
2631 data->p2p_prov_disc_resp.config_methods);
2633 case EVENT_P2P_SD_REQUEST:
2634 wpas_sd_request(wpa_s, data->p2p_sd_req.freq,
2635 data->p2p_sd_req.sa,
2636 data->p2p_sd_req.dialog_token,
2637 data->p2p_sd_req.update_indic,
2638 data->p2p_sd_req.tlvs,
2639 data->p2p_sd_req.tlvs_len);
2641 case EVENT_P2P_SD_RESPONSE:
2642 wpas_sd_response(wpa_s, data->p2p_sd_resp.sa,
2643 data->p2p_sd_resp.update_indic,
2644 data->p2p_sd_resp.tlvs,
2645 data->p2p_sd_resp.tlvs_len);
2647 #endif /* CONFIG_P2P */
2648 case EVENT_EAPOL_RX:
2649 wpa_supplicant_rx_eapol(wpa_s, data->eapol_rx.src,
2650 data->eapol_rx.data,
2651 data->eapol_rx.data_len);
2653 case EVENT_SIGNAL_CHANGE:
2654 bgscan_notify_signal_change(
2655 wpa_s, data->signal_change.above_threshold,
2656 data->signal_change.current_signal,
2657 data->signal_change.current_noise,
2658 data->signal_change.current_txrate);
2660 case EVENT_INTERFACE_ENABLED:
2661 wpa_dbg(wpa_s, MSG_DEBUG, "Interface was enabled");
2662 if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) {
2663 wpa_supplicant_update_mac_addr(wpa_s);
2665 if (!wpa_s->ap_iface) {
2666 wpa_supplicant_set_state(wpa_s,
2668 wpa_supplicant_req_scan(wpa_s, 0, 0);
2670 wpa_supplicant_set_state(wpa_s,
2672 #else /* CONFIG_AP */
2673 wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
2674 wpa_supplicant_req_scan(wpa_s, 0, 0);
2675 #endif /* CONFIG_AP */
2678 case EVENT_INTERFACE_DISABLED:
2679 wpa_dbg(wpa_s, MSG_DEBUG, "Interface was disabled");
2680 wpa_supplicant_mark_disassoc(wpa_s);
2681 wpa_supplicant_set_state(wpa_s, WPA_INTERFACE_DISABLED);
2683 case EVENT_CHANNEL_LIST_CHANGED:
2684 if (wpa_s->drv_priv == NULL)
2685 break; /* Ignore event during drv initialization */
2687 free_hw_features(wpa_s);
2688 wpa_s->hw.modes = wpa_drv_get_hw_feature_data(
2689 wpa_s, &wpa_s->hw.num_modes, &wpa_s->hw.flags);
2692 wpas_p2p_update_channel_list(wpa_s);
2693 #endif /* CONFIG_P2P */
2695 case EVENT_INTERFACE_UNAVAILABLE:
2697 wpas_p2p_interface_unavailable(wpa_s);
2698 #endif /* CONFIG_P2P */
2700 case EVENT_BEST_CHANNEL:
2701 wpa_dbg(wpa_s, MSG_DEBUG, "Best channel event received "
2703 data->best_chan.freq_24, data->best_chan.freq_5,
2704 data->best_chan.freq_overall);
2705 wpa_s->best_24_freq = data->best_chan.freq_24;
2706 wpa_s->best_5_freq = data->best_chan.freq_5;
2707 wpa_s->best_overall_freq = data->best_chan.freq_overall;
2709 wpas_p2p_update_best_channels(wpa_s, data->best_chan.freq_24,
2710 data->best_chan.freq_5,
2711 data->best_chan.freq_overall);
2712 #endif /* CONFIG_P2P */
2714 case EVENT_UNPROT_DEAUTH:
2715 wpa_supplicant_event_unprot_deauth(wpa_s,
2716 &data->unprot_deauth);
2718 case EVENT_UNPROT_DISASSOC:
2719 wpa_supplicant_event_unprot_disassoc(wpa_s,
2720 &data->unprot_disassoc);
2722 case EVENT_STATION_LOW_ACK:
2724 if (wpa_s->ap_iface && data)
2725 hostapd_event_sta_low_ack(wpa_s->ap_iface->bss[0],
2726 data->low_ack.addr);
2727 #endif /* CONFIG_AP */
2730 wpa_tdls_disable_link(wpa_s->wpa, data->low_ack.addr);
2731 #endif /* CONFIG_TDLS */
2733 case EVENT_IBSS_PEER_LOST:
2734 #ifdef CONFIG_IBSS_RSN
2735 ibss_rsn_stop(wpa_s->ibss_rsn, data->ibss_peer_lost.peer);
2736 #endif /* CONFIG_IBSS_RSN */
2738 case EVENT_DRIVER_GTK_REKEY:
2739 if (os_memcmp(data->driver_gtk_rekey.bssid,
2740 wpa_s->bssid, ETH_ALEN))
2744 wpa_sm_update_replay_ctr(wpa_s->wpa,
2745 data->driver_gtk_rekey.replay_ctr);
2747 case EVENT_SCHED_SCAN_STOPPED:
2748 wpa_s->sched_scanning = 0;
2749 wpa_supplicant_notify_scanning(wpa_s, 0);
2751 if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED)
2755 * If we timed out, start a new sched scan to continue
2756 * searching for more SSIDs.
2758 if (wpa_s->sched_scan_timed_out)
2759 wpa_supplicant_req_sched_scan(wpa_s);
2761 case EVENT_WPS_BUTTON_PUSHED:
2763 wpas_wps_start_pbc(wpa_s, NULL, 0);
2764 #endif /* CONFIG_WPS */
2767 wpa_msg(wpa_s, MSG_INFO, "Unknown event %d", event);