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"
28 #include "common/ieee802_11_defs.h"
29 #include "common/ieee802_11_common.h"
30 #include "crypto/random.h"
31 #include "blacklist.h"
32 #include "wpas_glue.h"
33 #include "wps_supplicant.h"
36 #include "gas_query.h"
37 #include "p2p_supplicant.h"
43 #include "offchannel.h"
44 #include "interworking.h"
47 #ifndef CONFIG_NO_SCAN_PROCESSING
48 static int wpas_select_network_from_last_scan(struct wpa_supplicant
*wpa_s
,
49 int new_scan
, int own_request
);
50 #endif /* CONFIG_NO_SCAN_PROCESSING */
53 static int wpas_temp_disabled(struct wpa_supplicant
*wpa_s
,
54 struct wpa_ssid
*ssid
)
58 if (ssid
== NULL
|| ssid
->disabled_until
.sec
== 0)
62 if (ssid
->disabled_until
.sec
> now
.sec
)
63 return ssid
->disabled_until
.sec
- now
.sec
;
65 wpas_clear_temp_disabled(wpa_s
, ssid
, 0);
71 static int wpa_supplicant_select_config(struct wpa_supplicant
*wpa_s
)
73 struct wpa_ssid
*ssid
, *old_ssid
;
76 if (wpa_s
->conf
->ap_scan
== 1 && wpa_s
->current_ssid
)
79 wpa_dbg(wpa_s
, MSG_DEBUG
, "Select network based on association "
81 ssid
= wpa_supplicant_get_ssid(wpa_s
);
83 wpa_msg(wpa_s
, MSG_INFO
,
84 "No network configuration found for the current AP");
88 if (wpas_network_disabled(wpa_s
, ssid
)) {
89 wpa_dbg(wpa_s
, MSG_DEBUG
, "Selected network is disabled");
93 if (disallowed_bssid(wpa_s
, wpa_s
->bssid
) ||
94 disallowed_ssid(wpa_s
, ssid
->ssid
, ssid
->ssid_len
)) {
95 wpa_dbg(wpa_s
, MSG_DEBUG
, "Selected BSS is disallowed");
99 res
= wpas_temp_disabled(wpa_s
, ssid
);
101 wpa_dbg(wpa_s
, MSG_DEBUG
, "Selected network is temporarily "
102 "disabled for %d second(s)", res
);
106 wpa_dbg(wpa_s
, MSG_DEBUG
, "Network configuration found for the "
108 if (wpa_key_mgmt_wpa_any(ssid
->key_mgmt
)) {
110 size_t wpa_ie_len
= sizeof(wpa_ie
);
111 if (wpa_supplicant_set_suites(wpa_s
, NULL
, ssid
,
112 wpa_ie
, &wpa_ie_len
) < 0)
113 wpa_dbg(wpa_s
, MSG_DEBUG
, "Could not set WPA suites");
115 wpa_supplicant_set_non_wpa_policy(wpa_s
, ssid
);
118 if (wpa_s
->current_ssid
&& wpa_s
->current_ssid
!= ssid
)
119 eapol_sm_invalidate_cached_session(wpa_s
->eapol
);
120 old_ssid
= wpa_s
->current_ssid
;
121 wpa_s
->current_ssid
= ssid
;
122 wpa_supplicant_rsn_supp_set_config(wpa_s
, wpa_s
->current_ssid
);
123 wpa_supplicant_initiate_eapol(wpa_s
);
124 if (old_ssid
!= wpa_s
->current_ssid
)
125 wpas_notify_network_changed(wpa_s
);
131 void wpa_supplicant_stop_countermeasures(void *eloop_ctx
, void *sock_ctx
)
133 struct wpa_supplicant
*wpa_s
= eloop_ctx
;
135 if (wpa_s
->countermeasures
) {
136 wpa_s
->countermeasures
= 0;
137 wpa_drv_set_countermeasures(wpa_s
, 0);
138 wpa_msg(wpa_s
, MSG_INFO
, "WPA: TKIP countermeasures stopped");
139 wpa_supplicant_req_scan(wpa_s
, 0, 0);
144 void wpa_supplicant_mark_disassoc(struct wpa_supplicant
*wpa_s
)
148 wnm_bss_keep_alive_deinit(wpa_s
);
150 #ifdef CONFIG_IBSS_RSN
151 ibss_rsn_deinit(wpa_s
->ibss_rsn
);
152 wpa_s
->ibss_rsn
= NULL
;
153 #endif /* CONFIG_IBSS_RSN */
156 wpa_supplicant_ap_deinit(wpa_s
);
157 #endif /* CONFIG_AP */
159 if (wpa_s
->wpa_state
== WPA_INTERFACE_DISABLED
)
162 wpa_supplicant_set_state(wpa_s
, WPA_DISCONNECTED
);
163 bssid_changed
= !is_zero_ether_addr(wpa_s
->bssid
);
164 os_memset(wpa_s
->bssid
, 0, ETH_ALEN
);
165 os_memset(wpa_s
->pending_bssid
, 0, ETH_ALEN
);
167 wpa_s
->sme
.prev_bssid_set
= 0;
168 #endif /* CONFIG_SME */
170 os_memset(wpa_s
->go_dev_addr
, 0, ETH_ALEN
);
171 #endif /* CONFIG_P2P */
172 wpa_s
->current_bss
= NULL
;
173 wpa_s
->assoc_freq
= 0;
174 #ifdef CONFIG_IEEE80211R
176 if (wpa_s
->sme
.ft_ies
)
177 sme_update_ft_ies(wpa_s
, NULL
, NULL
, 0);
178 #endif /* CONFIG_SME */
179 #endif /* CONFIG_IEEE80211R */
182 wpas_notify_bssid_changed(wpa_s
);
184 eapol_sm_notify_portEnabled(wpa_s
->eapol
, FALSE
);
185 eapol_sm_notify_portValid(wpa_s
->eapol
, FALSE
);
186 if (wpa_key_mgmt_wpa_psk(wpa_s
->key_mgmt
))
187 eapol_sm_notify_eap_success(wpa_s
->eapol
, FALSE
);
188 wpa_s
->ap_ies_from_associnfo
= 0;
189 wpa_s
->current_ssid
= NULL
;
190 eapol_sm_notify_config(wpa_s
->eapol
, NULL
, NULL
);
195 static void wpa_find_assoc_pmkid(struct wpa_supplicant
*wpa_s
)
197 struct wpa_ie_data ie
;
201 if (wpa_sm_parse_own_wpa_ie(wpa_s
->wpa
, &ie
) < 0 ||
205 for (i
= 0; i
< ie
.num_pmkid
; i
++) {
206 pmksa_set
= pmksa_cache_set_current(wpa_s
->wpa
,
207 ie
.pmkid
+ i
* PMKID_LEN
,
209 if (pmksa_set
== 0) {
210 eapol_sm_notify_pmkid_attempt(wpa_s
->eapol
, 1);
215 wpa_dbg(wpa_s
, MSG_DEBUG
, "RSN: PMKID from assoc IE %sfound from "
216 "PMKSA cache", pmksa_set
== 0 ? "" : "not ");
220 static void wpa_supplicant_event_pmkid_candidate(struct wpa_supplicant
*wpa_s
,
221 union wpa_event_data
*data
)
224 wpa_dbg(wpa_s
, MSG_DEBUG
, "RSN: No data in PMKID candidate "
228 wpa_dbg(wpa_s
, MSG_DEBUG
, "RSN: PMKID candidate event - bssid=" MACSTR
229 " index=%d preauth=%d",
230 MAC2STR(data
->pmkid_candidate
.bssid
),
231 data
->pmkid_candidate
.index
,
232 data
->pmkid_candidate
.preauth
);
234 pmksa_candidate_add(wpa_s
->wpa
, data
->pmkid_candidate
.bssid
,
235 data
->pmkid_candidate
.index
,
236 data
->pmkid_candidate
.preauth
);
240 static int wpa_supplicant_dynamic_keys(struct wpa_supplicant
*wpa_s
)
242 if (wpa_s
->key_mgmt
== WPA_KEY_MGMT_NONE
||
243 wpa_s
->key_mgmt
== WPA_KEY_MGMT_WPA_NONE
)
246 #ifdef IEEE8021X_EAPOL
247 if (wpa_s
->key_mgmt
== WPA_KEY_MGMT_IEEE8021X_NO_WPA
&&
248 wpa_s
->current_ssid
&&
249 !(wpa_s
->current_ssid
->eapol_flags
&
250 (EAPOL_FLAG_REQUIRE_KEY_UNICAST
|
251 EAPOL_FLAG_REQUIRE_KEY_BROADCAST
))) {
252 /* IEEE 802.1X, but not using dynamic WEP keys (i.e., either
253 * plaintext or static WEP keys). */
256 #endif /* IEEE8021X_EAPOL */
263 * wpa_supplicant_scard_init - Initialize SIM/USIM access with PC/SC
264 * @wpa_s: pointer to wpa_supplicant data
265 * @ssid: Configuration data for the network
266 * Returns: 0 on success, -1 on failure
268 * This function is called when starting authentication with a network that is
269 * configured to use PC/SC for SIM/USIM access (EAP-SIM or EAP-AKA).
271 int wpa_supplicant_scard_init(struct wpa_supplicant
*wpa_s
,
272 struct wpa_ssid
*ssid
)
274 #ifdef IEEE8021X_EAPOL
276 int aka
= 0, sim
= 0;
278 if (ssid
->eap
.pcsc
== NULL
|| wpa_s
->scard
!= NULL
||
279 wpa_s
->conf
->external_sim
)
282 if (ssid
->eap
.eap_methods
== NULL
) {
286 struct eap_method_type
*eap
= ssid
->eap
.eap_methods
;
287 while (eap
->vendor
!= EAP_VENDOR_IETF
||
288 eap
->method
!= EAP_TYPE_NONE
) {
289 if (eap
->vendor
== EAP_VENDOR_IETF
) {
290 if (eap
->method
== EAP_TYPE_SIM
)
292 else if (eap
->method
== EAP_TYPE_AKA
||
293 eap
->method
== EAP_TYPE_AKA_PRIME
)
300 if (eap_peer_get_eap_method(EAP_VENDOR_IETF
, EAP_TYPE_SIM
) == NULL
)
302 if (eap_peer_get_eap_method(EAP_VENDOR_IETF
, EAP_TYPE_AKA
) == NULL
&&
303 eap_peer_get_eap_method(EAP_VENDOR_IETF
, EAP_TYPE_AKA_PRIME
) ==
308 wpa_dbg(wpa_s
, MSG_DEBUG
, "Selected network is configured to "
309 "use SIM, but neither EAP-SIM nor EAP-AKA are "
314 wpa_dbg(wpa_s
, MSG_DEBUG
, "Selected network is configured to use SIM "
315 "(sim=%d aka=%d) - initialize PCSC", sim
, aka
);
317 wpa_s
->scard
= scard_init((!sim
&& aka
) ? SCARD_USIM_ONLY
:
318 SCARD_TRY_BOTH
, NULL
);
319 if (wpa_s
->scard
== NULL
) {
320 wpa_msg(wpa_s
, MSG_WARNING
, "Failed to initialize SIM "
324 wpa_sm_set_scard_ctx(wpa_s
->wpa
, wpa_s
->scard
);
325 eapol_sm_register_scard_ctx(wpa_s
->eapol
, wpa_s
->scard
);
326 #endif /* PCSC_FUNCS */
327 #endif /* IEEE8021X_EAPOL */
333 #ifndef CONFIG_NO_SCAN_PROCESSING
335 static int has_wep_key(struct wpa_ssid
*ssid
)
339 for (i
= 0; i
< NUM_WEP_KEYS
; i
++) {
340 if (ssid
->wep_key_len
[i
])
348 static int wpa_supplicant_match_privacy(struct wpa_bss
*bss
,
349 struct wpa_ssid
*ssid
)
353 if (ssid
->mixed_cell
)
357 if (ssid
->key_mgmt
& WPA_KEY_MGMT_WPS
)
359 #endif /* CONFIG_WPS */
361 if (has_wep_key(ssid
))
364 #ifdef IEEE8021X_EAPOL
365 if ((ssid
->key_mgmt
& WPA_KEY_MGMT_IEEE8021X_NO_WPA
) &&
366 ssid
->eapol_flags
& (EAPOL_FLAG_REQUIRE_KEY_UNICAST
|
367 EAPOL_FLAG_REQUIRE_KEY_BROADCAST
))
369 #endif /* IEEE8021X_EAPOL */
371 if (wpa_key_mgmt_wpa(ssid
->key_mgmt
))
374 if (bss
->caps
& IEEE80211_CAP_PRIVACY
)
380 static int wpa_supplicant_ssid_bss_match(struct wpa_supplicant
*wpa_s
,
381 struct wpa_ssid
*ssid
,
384 struct wpa_ie_data ie
;
386 const u8
*rsn_ie
, *wpa_ie
;
390 ret
= wpas_wps_ssid_bss_match(wpa_s
, ssid
, bss
);
394 /* Allow TSN if local configuration accepts WEP use without WPA/WPA2 */
395 wep_ok
= !wpa_key_mgmt_wpa(ssid
->key_mgmt
) &&
396 (((ssid
->key_mgmt
& WPA_KEY_MGMT_NONE
) &&
397 ssid
->wep_key_len
[ssid
->wep_tx_keyidx
] > 0) ||
398 (ssid
->key_mgmt
& WPA_KEY_MGMT_IEEE8021X_NO_WPA
));
400 rsn_ie
= wpa_bss_get_ie(bss
, WLAN_EID_RSN
);
401 while ((ssid
->proto
& WPA_PROTO_RSN
) && rsn_ie
) {
404 if (wpa_parse_wpa_ie(rsn_ie
, 2 + rsn_ie
[1], &ie
)) {
405 wpa_dbg(wpa_s
, MSG_DEBUG
, " skip RSN IE - parse "
411 (ie
.group_cipher
& (WPA_CIPHER_WEP40
| WPA_CIPHER_WEP104
)))
413 wpa_dbg(wpa_s
, MSG_DEBUG
, " selected based on TSN "
418 if (!(ie
.proto
& ssid
->proto
)) {
419 wpa_dbg(wpa_s
, MSG_DEBUG
, " skip RSN IE - proto "
424 if (!(ie
.pairwise_cipher
& ssid
->pairwise_cipher
)) {
425 wpa_dbg(wpa_s
, MSG_DEBUG
, " skip RSN IE - PTK "
430 if (!(ie
.group_cipher
& ssid
->group_cipher
)) {
431 wpa_dbg(wpa_s
, MSG_DEBUG
, " skip RSN IE - GTK "
436 if (!(ie
.key_mgmt
& ssid
->key_mgmt
)) {
437 wpa_dbg(wpa_s
, MSG_DEBUG
, " skip RSN IE - key mgmt "
442 #ifdef CONFIG_IEEE80211W
443 if (!(ie
.capabilities
& WPA_CAPABILITY_MFPC
) &&
444 (ssid
->ieee80211w
== MGMT_FRAME_PROTECTION_DEFAULT
?
445 wpa_s
->conf
->pmf
: ssid
->ieee80211w
) ==
446 MGMT_FRAME_PROTECTION_REQUIRED
) {
447 wpa_dbg(wpa_s
, MSG_DEBUG
, " skip RSN IE - no mgmt "
451 #endif /* CONFIG_IEEE80211W */
453 wpa_dbg(wpa_s
, MSG_DEBUG
, " selected based on RSN IE");
457 wpa_ie
= wpa_bss_get_vendor_ie(bss
, WPA_IE_VENDOR_TYPE
);
458 while ((ssid
->proto
& WPA_PROTO_WPA
) && wpa_ie
) {
461 if (wpa_parse_wpa_ie(wpa_ie
, 2 + wpa_ie
[1], &ie
)) {
462 wpa_dbg(wpa_s
, MSG_DEBUG
, " skip WPA IE - parse "
468 (ie
.group_cipher
& (WPA_CIPHER_WEP40
| WPA_CIPHER_WEP104
)))
470 wpa_dbg(wpa_s
, MSG_DEBUG
, " selected based on TSN "
475 if (!(ie
.proto
& ssid
->proto
)) {
476 wpa_dbg(wpa_s
, MSG_DEBUG
, " skip WPA IE - proto "
481 if (!(ie
.pairwise_cipher
& ssid
->pairwise_cipher
)) {
482 wpa_dbg(wpa_s
, MSG_DEBUG
, " skip WPA IE - PTK "
487 if (!(ie
.group_cipher
& ssid
->group_cipher
)) {
488 wpa_dbg(wpa_s
, MSG_DEBUG
, " skip WPA IE - GTK "
493 if (!(ie
.key_mgmt
& ssid
->key_mgmt
)) {
494 wpa_dbg(wpa_s
, MSG_DEBUG
, " skip WPA IE - key mgmt "
499 wpa_dbg(wpa_s
, MSG_DEBUG
, " selected based on WPA IE");
503 if ((ssid
->key_mgmt
& WPA_KEY_MGMT_IEEE8021X_NO_WPA
) && !wpa_ie
&&
505 wpa_dbg(wpa_s
, MSG_DEBUG
, " allow for non-WPA IEEE 802.1X");
509 if ((ssid
->proto
& (WPA_PROTO_WPA
| WPA_PROTO_RSN
)) &&
510 wpa_key_mgmt_wpa(ssid
->key_mgmt
) && proto_match
== 0) {
511 wpa_dbg(wpa_s
, MSG_DEBUG
, " skip - no WPA/RSN proto match");
515 if (!wpa_key_mgmt_wpa(ssid
->key_mgmt
)) {
516 wpa_dbg(wpa_s
, MSG_DEBUG
, " allow in non-WPA/WPA2");
520 wpa_dbg(wpa_s
, MSG_DEBUG
, " reject due to mismatch with "
527 static int freq_allowed(int *freqs
, int freq
)
534 for (i
= 0; freqs
[i
]; i
++)
535 if (freqs
[i
] == freq
)
541 static int ht_supported(const struct hostapd_hw_modes
*mode
)
543 if (!(mode
->flags
& HOSTAPD_MODE_FLAG_HT_INFO_KNOWN
)) {
545 * The driver did not indicate whether it supports HT. Assume
546 * it does to avoid connection issues.
552 * IEEE Std 802.11n-2009 20.1.1:
553 * An HT non-AP STA shall support all EQM rates for one spatial stream.
555 return mode
->mcs_set
[0] == 0xff;
559 static int vht_supported(const struct hostapd_hw_modes
*mode
)
561 if (!(mode
->flags
& HOSTAPD_MODE_FLAG_VHT_INFO_KNOWN
)) {
563 * The driver did not indicate whether it supports VHT. Assume
564 * it does to avoid connection issues.
570 * A VHT non-AP STA shall support MCS 0-7 for one spatial stream.
571 * TODO: Verify if this complies with the standard
573 return (mode
->vht_mcs_set
[0] & 0x3) != 3;
577 static int rate_match(struct wpa_supplicant
*wpa_s
, struct wpa_bss
*bss
)
579 const struct hostapd_hw_modes
*mode
= NULL
, *modes
;
580 const u8 scan_ie
[2] = { WLAN_EID_SUPP_RATES
, WLAN_EID_EXT_SUPP_RATES
};
585 return 1; /* Cannot do matching without knowing band */
587 modes
= wpa_s
->hw
.modes
;
590 * The driver does not provide any additional information
591 * about the utilized hardware, so allow the connection attempt
597 for (i
= 0; i
< wpa_s
->hw
.num_modes
; i
++) {
598 for (j
= 0; j
< modes
[i
].num_channels
; j
++) {
599 int freq
= modes
[i
].channels
[j
].freq
;
600 if (freq
== bss
->freq
) {
602 mode
->mode
== HOSTAPD_MODE_IEEE80211G
)
603 break; /* do not allow 802.11b replace
614 for (i
= 0; i
< (int) sizeof(scan_ie
); i
++) {
615 rate_ie
= wpa_bss_get_ie(bss
, scan_ie
[i
]);
619 for (j
= 2; j
< rate_ie
[1] + 2; j
++) {
620 int flagged
= !!(rate_ie
[j
] & 0x80);
621 int r
= (rate_ie
[j
] & 0x7f) * 5;
624 * IEEE Std 802.11n-2009 7.3.2.2:
625 * The new BSS Membership selector value is encoded
626 * like a legacy basic rate, but it is not a rate and
627 * only indicates if the BSS members are required to
628 * support the mandatory features of Clause 20 [HT PHY]
629 * in order to join the BSS.
631 if (flagged
&& ((rate_ie
[j
] & 0x7f) ==
632 BSS_MEMBERSHIP_SELECTOR_HT_PHY
)) {
633 if (!ht_supported(mode
)) {
634 wpa_dbg(wpa_s
, MSG_DEBUG
,
635 " hardware does not support "
642 /* There's also a VHT selector for 802.11ac */
643 if (flagged
&& ((rate_ie
[j
] & 0x7f) ==
644 BSS_MEMBERSHIP_SELECTOR_VHT_PHY
)) {
645 if (!vht_supported(mode
)) {
646 wpa_dbg(wpa_s
, MSG_DEBUG
,
647 " hardware does not support "
657 /* check for legacy basic rates */
658 for (k
= 0; k
< mode
->num_rates
; k
++) {
659 if (mode
->rates
[k
] == r
)
662 if (k
== mode
->num_rates
) {
664 * IEEE Std 802.11-2007 7.3.2.2 demands that in
665 * order to join a BSS all required rates
666 * have to be supported by the hardware.
668 wpa_dbg(wpa_s
, MSG_DEBUG
, " hardware does "
669 "not support required rate %d.%d Mbps",
680 static int bss_is_dmg(struct wpa_bss
*bss
)
682 return bss
->freq
> 45000;
687 * Test whether BSS is in an ESS.
688 * This is done differently in DMG (60 GHz) and non-DMG bands
690 static int bss_is_ess(struct wpa_bss
*bss
)
692 if (bss_is_dmg(bss
)) {
693 return (bss
->caps
& IEEE80211_CAP_DMG_MASK
) ==
694 IEEE80211_CAP_DMG_AP
;
697 return ((bss
->caps
& (IEEE80211_CAP_ESS
| IEEE80211_CAP_IBSS
)) ==
702 static struct wpa_ssid
* wpa_scan_res_match(struct wpa_supplicant
*wpa_s
,
703 int i
, struct wpa_bss
*bss
,
704 struct wpa_ssid
*group
)
706 u8 wpa_ie_len
, rsn_ie_len
;
708 struct wpa_blacklist
*e
;
710 struct wpa_ssid
*ssid
;
712 ie
= wpa_bss_get_vendor_ie(bss
, WPA_IE_VENDOR_TYPE
);
713 wpa_ie_len
= ie
? ie
[1] : 0;
715 ie
= wpa_bss_get_ie(bss
, WLAN_EID_RSN
);
716 rsn_ie_len
= ie
? ie
[1] : 0;
718 wpa_dbg(wpa_s
, MSG_DEBUG
, "%d: " MACSTR
" ssid='%s' "
719 "wpa_ie_len=%u rsn_ie_len=%u caps=0x%x level=%d%s%s",
720 i
, MAC2STR(bss
->bssid
), wpa_ssid_txt(bss
->ssid
, bss
->ssid_len
),
721 wpa_ie_len
, rsn_ie_len
, bss
->caps
, bss
->level
,
722 wpa_bss_get_vendor_ie(bss
, WPS_IE_VENDOR_TYPE
) ? " wps" : "",
723 (wpa_bss_get_vendor_ie(bss
, P2P_IE_VENDOR_TYPE
) ||
724 wpa_bss_get_vendor_ie_beacon(bss
, P2P_IE_VENDOR_TYPE
)) ?
727 e
= wpa_blacklist_get(wpa_s
, bss
->bssid
);
730 if (wpa_supplicant_enabled_networks(wpa_s
) == 1) {
732 * When only a single network is enabled, we can
733 * trigger blacklisting on the first failure. This
734 * should not be done with multiple enabled networks to
735 * avoid getting forced to move into a worse ESS on
736 * single error if there are no other BSSes of the
741 if (e
->count
> limit
) {
742 wpa_dbg(wpa_s
, MSG_DEBUG
, " skip - blacklisted "
743 "(count=%d limit=%d)", e
->count
, limit
);
748 if (bss
->ssid_len
== 0) {
749 wpa_dbg(wpa_s
, MSG_DEBUG
, " skip - SSID not known");
753 if (disallowed_bssid(wpa_s
, bss
->bssid
)) {
754 wpa_dbg(wpa_s
, MSG_DEBUG
, " skip - BSSID disallowed");
758 if (disallowed_ssid(wpa_s
, bss
->ssid
, bss
->ssid_len
)) {
759 wpa_dbg(wpa_s
, MSG_DEBUG
, " skip - SSID disallowed");
763 wpa
= wpa_ie_len
> 0 || rsn_ie_len
> 0;
765 for (ssid
= group
; ssid
; ssid
= ssid
->pnext
) {
766 int check_ssid
= wpa
? 1 : (ssid
->ssid_len
!= 0);
769 if (wpas_network_disabled(wpa_s
, ssid
)) {
770 wpa_dbg(wpa_s
, MSG_DEBUG
, " skip - disabled");
774 res
= wpas_temp_disabled(wpa_s
, ssid
);
776 wpa_dbg(wpa_s
, MSG_DEBUG
, " skip - disabled "
777 "temporarily for %d second(s)", res
);
782 if ((ssid
->key_mgmt
& WPA_KEY_MGMT_WPS
) && e
&& e
->count
> 0) {
783 wpa_dbg(wpa_s
, MSG_DEBUG
, " skip - blacklisted "
788 if (wpa
&& ssid
->ssid_len
== 0 &&
789 wpas_wps_ssid_wildcard_ok(wpa_s
, ssid
, bss
))
792 if (!wpa
&& (ssid
->key_mgmt
& WPA_KEY_MGMT_WPS
)) {
793 /* Only allow wildcard SSID match if an AP
794 * advertises active WPS operation that matches
797 if (ssid
->ssid_len
== 0 &&
798 wpas_wps_ssid_wildcard_ok(wpa_s
, ssid
, bss
))
801 #endif /* CONFIG_WPS */
803 if (ssid
->bssid_set
&& ssid
->ssid_len
== 0 &&
804 os_memcmp(bss
->bssid
, ssid
->bssid
, ETH_ALEN
) == 0)
808 (bss
->ssid_len
!= ssid
->ssid_len
||
809 os_memcmp(bss
->ssid
, ssid
->ssid
, bss
->ssid_len
) != 0)) {
810 wpa_dbg(wpa_s
, MSG_DEBUG
, " skip - SSID mismatch");
814 if (ssid
->bssid_set
&&
815 os_memcmp(bss
->bssid
, ssid
->bssid
, ETH_ALEN
) != 0) {
816 wpa_dbg(wpa_s
, MSG_DEBUG
, " skip - BSSID mismatch");
820 if (!wpa_supplicant_ssid_bss_match(wpa_s
, ssid
, bss
))
824 !(ssid
->key_mgmt
& WPA_KEY_MGMT_NONE
) &&
825 !(ssid
->key_mgmt
& WPA_KEY_MGMT_WPS
) &&
826 !(ssid
->key_mgmt
& WPA_KEY_MGMT_IEEE8021X_NO_WPA
)) {
827 wpa_dbg(wpa_s
, MSG_DEBUG
, " skip - non-WPA network "
832 if (wpa
&& !wpa_key_mgmt_wpa(ssid
->key_mgmt
) &&
834 wpa_dbg(wpa_s
, MSG_DEBUG
, " skip - ignore WPA/WPA2 AP for WEP network block");
838 if (!wpa_supplicant_match_privacy(bss
, ssid
)) {
839 wpa_dbg(wpa_s
, MSG_DEBUG
, " skip - privacy "
844 if (!bss_is_ess(bss
)) {
845 wpa_dbg(wpa_s
, MSG_DEBUG
, " skip - not ESS network");
849 if (!freq_allowed(ssid
->freq_list
, bss
->freq
)) {
850 wpa_dbg(wpa_s
, MSG_DEBUG
, " skip - frequency not "
855 if (!rate_match(wpa_s
, bss
)) {
856 wpa_dbg(wpa_s
, MSG_DEBUG
, " skip - rate sets do "
862 if (ssid
->p2p_group
&&
863 !wpa_bss_get_vendor_ie(bss
, P2P_IE_VENDOR_TYPE
) &&
864 !wpa_bss_get_vendor_ie_beacon(bss
, P2P_IE_VENDOR_TYPE
)) {
865 wpa_dbg(wpa_s
, MSG_DEBUG
, " skip - no P2P IE seen");
869 if (!is_zero_ether_addr(ssid
->go_p2p_dev_addr
)) {
870 struct wpabuf
*p2p_ie
;
871 u8 dev_addr
[ETH_ALEN
];
873 ie
= wpa_bss_get_vendor_ie(bss
, P2P_IE_VENDOR_TYPE
);
875 wpa_dbg(wpa_s
, MSG_DEBUG
, " skip - no P2P element");
878 p2p_ie
= wpa_bss_get_vendor_ie_multi(
879 bss
, P2P_IE_VENDOR_TYPE
);
880 if (p2p_ie
== NULL
) {
881 wpa_dbg(wpa_s
, MSG_DEBUG
, " skip - could not fetch P2P element");
885 if (p2p_parse_dev_addr_in_p2p_ie(p2p_ie
, dev_addr
) < 0
886 || os_memcmp(dev_addr
, ssid
->go_p2p_dev_addr
,
888 wpa_dbg(wpa_s
, MSG_DEBUG
, " skip - no matching GO P2P Device Address in P2P element");
896 * TODO: skip the AP if its P2P IE has Group Formation
897 * bit set in the P2P Group Capability Bitmap and we
898 * are not in Group Formation with that device.
900 #endif /* CONFIG_P2P */
902 /* Matching configuration found */
906 /* No matching configuration found */
911 static struct wpa_bss
*
912 wpa_supplicant_select_bss(struct wpa_supplicant
*wpa_s
,
913 struct wpa_ssid
*group
,
914 struct wpa_ssid
**selected_ssid
)
918 wpa_dbg(wpa_s
, MSG_DEBUG
, "Selecting BSS from priority group %d",
921 for (i
= 0; i
< wpa_s
->last_scan_res_used
; i
++) {
922 struct wpa_bss
*bss
= wpa_s
->last_scan_res
[i
];
923 *selected_ssid
= wpa_scan_res_match(wpa_s
, i
, bss
, group
);
926 wpa_dbg(wpa_s
, MSG_DEBUG
, " selected BSS " MACSTR
929 wpa_ssid_txt(bss
->ssid
, bss
->ssid_len
));
937 struct wpa_bss
* wpa_supplicant_pick_network(struct wpa_supplicant
*wpa_s
,
938 struct wpa_ssid
**selected_ssid
)
940 struct wpa_bss
*selected
= NULL
;
943 if (wpa_s
->last_scan_res
== NULL
||
944 wpa_s
->last_scan_res_used
== 0)
945 return NULL
; /* no scan results from last update */
947 while (selected
== NULL
) {
948 for (prio
= 0; prio
< wpa_s
->conf
->num_prio
; prio
++) {
949 selected
= wpa_supplicant_select_bss(
950 wpa_s
, wpa_s
->conf
->pssid
[prio
],
956 if (selected
== NULL
&& wpa_s
->blacklist
&&
957 !wpa_s
->countermeasures
) {
958 wpa_dbg(wpa_s
, MSG_DEBUG
, "No APs found - clear "
959 "blacklist and try again");
960 wpa_blacklist_clear(wpa_s
);
961 wpa_s
->blacklist_cleared
++;
962 } else if (selected
== NULL
)
970 static void wpa_supplicant_req_new_scan(struct wpa_supplicant
*wpa_s
,
971 int timeout_sec
, int timeout_usec
)
973 if (!wpa_supplicant_enabled_networks(wpa_s
)) {
975 * No networks are enabled; short-circuit request so
976 * we don't wait timeout seconds before transitioning
979 wpa_dbg(wpa_s
, MSG_DEBUG
, "Short-circuit new scan request "
980 "since there are no enabled networks");
981 wpa_supplicant_set_state(wpa_s
, WPA_INACTIVE
);
983 wpa_s
->sta_scan_pending
= 0;
984 #endif /* CONFIG_P2P */
988 wpa_s
->scan_for_connection
= 1;
989 wpa_supplicant_req_scan(wpa_s
, timeout_sec
, timeout_usec
);
993 int wpa_supplicant_connect(struct wpa_supplicant
*wpa_s
,
994 struct wpa_bss
*selected
,
995 struct wpa_ssid
*ssid
)
997 if (wpas_wps_scan_pbc_overlap(wpa_s
, selected
, ssid
)) {
998 wpa_msg(wpa_s
, MSG_INFO
, WPS_EVENT_OVERLAP
999 "PBC session overlap");
1001 if (wpas_p2p_notif_pbc_overlap(wpa_s
) == 1)
1003 #endif /* CONFIG_P2P */
1006 wpas_wps_cancel(wpa_s
);
1007 #endif /* CONFIG_WPS */
1011 wpa_msg(wpa_s
, MSG_DEBUG
,
1012 "Considering connect request: reassociate: %d selected: "
1013 MACSTR
" bssid: " MACSTR
" pending: " MACSTR
1014 " wpa_state: %s ssid=%p current_ssid=%p",
1015 wpa_s
->reassociate
, MAC2STR(selected
->bssid
),
1016 MAC2STR(wpa_s
->bssid
), MAC2STR(wpa_s
->pending_bssid
),
1017 wpa_supplicant_state_txt(wpa_s
->wpa_state
),
1018 ssid
, wpa_s
->current_ssid
);
1021 * Do not trigger new association unless the BSSID has changed or if
1022 * reassociation is requested. If we are in process of associating with
1023 * the selected BSSID, do not trigger new attempt.
1025 if (wpa_s
->reassociate
||
1026 (os_memcmp(selected
->bssid
, wpa_s
->bssid
, ETH_ALEN
) != 0 &&
1027 ((wpa_s
->wpa_state
!= WPA_ASSOCIATING
&&
1028 wpa_s
->wpa_state
!= WPA_AUTHENTICATING
) ||
1029 (!is_zero_ether_addr(wpa_s
->pending_bssid
) &&
1030 os_memcmp(selected
->bssid
, wpa_s
->pending_bssid
, ETH_ALEN
) !=
1032 (is_zero_ether_addr(wpa_s
->pending_bssid
) &&
1033 ssid
!= wpa_s
->current_ssid
)))) {
1034 if (wpa_supplicant_scard_init(wpa_s
, ssid
)) {
1035 wpa_supplicant_req_new_scan(wpa_s
, 10, 0);
1038 wpa_msg(wpa_s
, MSG_DEBUG
, "Request association with " MACSTR
,
1039 MAC2STR(selected
->bssid
));
1040 wpa_supplicant_associate(wpa_s
, selected
, ssid
);
1042 wpa_dbg(wpa_s
, MSG_DEBUG
, "Already associated or trying to "
1043 "connect with the selected AP");
1050 static struct wpa_ssid
*
1051 wpa_supplicant_pick_new_network(struct wpa_supplicant
*wpa_s
)
1054 struct wpa_ssid
*ssid
;
1056 for (prio
= 0; prio
< wpa_s
->conf
->num_prio
; prio
++) {
1057 for (ssid
= wpa_s
->conf
->pssid
[prio
]; ssid
; ssid
= ssid
->pnext
)
1059 if (wpas_network_disabled(wpa_s
, ssid
))
1061 if (ssid
->mode
== IEEE80211_MODE_IBSS
||
1062 ssid
->mode
== IEEE80211_MODE_AP
)
1070 /* TODO: move the rsn_preauth_scan_result*() to be called from notify.c based
1071 * on BSS added and BSS changed events */
1072 static void wpa_supplicant_rsn_preauth_scan_results(
1073 struct wpa_supplicant
*wpa_s
)
1075 struct wpa_bss
*bss
;
1077 if (rsn_preauth_scan_results(wpa_s
->wpa
) < 0)
1080 dl_list_for_each(bss
, &wpa_s
->bss
, struct wpa_bss
, list
) {
1081 const u8
*ssid
, *rsn
;
1083 ssid
= wpa_bss_get_ie(bss
, WLAN_EID_SSID
);
1087 rsn
= wpa_bss_get_ie(bss
, WLAN_EID_RSN
);
1091 rsn_preauth_scan_result(wpa_s
->wpa
, bss
->bssid
, ssid
, rsn
);
1097 static int wpa_supplicant_need_to_roam(struct wpa_supplicant
*wpa_s
,
1098 struct wpa_bss
*selected
,
1099 struct wpa_ssid
*ssid
)
1101 struct wpa_bss
*current_bss
= NULL
;
1104 if (wpa_s
->reassociate
)
1105 return 1; /* explicit request to reassociate */
1106 if (wpa_s
->wpa_state
< WPA_ASSOCIATED
)
1107 return 1; /* we are not associated; continue */
1108 if (wpa_s
->current_ssid
== NULL
)
1109 return 1; /* unknown current SSID */
1110 if (wpa_s
->current_ssid
!= ssid
)
1111 return 1; /* different network block */
1113 if (wpas_driver_bss_selection(wpa_s
))
1114 return 0; /* Driver-based roaming */
1116 if (wpa_s
->current_ssid
->ssid
)
1117 current_bss
= wpa_bss_get(wpa_s
, wpa_s
->bssid
,
1118 wpa_s
->current_ssid
->ssid
,
1119 wpa_s
->current_ssid
->ssid_len
);
1121 current_bss
= wpa_bss_get_bssid(wpa_s
, wpa_s
->bssid
);
1124 return 1; /* current BSS not seen in scan results */
1126 if (current_bss
== selected
)
1129 if (selected
->last_update_idx
> current_bss
->last_update_idx
)
1130 return 1; /* current BSS not seen in the last scan */
1132 #ifndef CONFIG_NO_ROAMING
1133 wpa_dbg(wpa_s
, MSG_DEBUG
, "Considering within-ESS reassociation");
1134 wpa_dbg(wpa_s
, MSG_DEBUG
, "Current BSS: " MACSTR
" level=%d",
1135 MAC2STR(current_bss
->bssid
), current_bss
->level
);
1136 wpa_dbg(wpa_s
, MSG_DEBUG
, "Selected BSS: " MACSTR
" level=%d",
1137 MAC2STR(selected
->bssid
), selected
->level
);
1139 if (wpa_s
->current_ssid
->bssid_set
&&
1140 os_memcmp(selected
->bssid
, wpa_s
->current_ssid
->bssid
, ETH_ALEN
) ==
1142 wpa_dbg(wpa_s
, MSG_DEBUG
, "Allow reassociation - selected BSS "
1143 "has preferred BSSID");
1147 if (current_bss
->level
< 0 && current_bss
->level
> selected
->level
) {
1148 wpa_dbg(wpa_s
, MSG_DEBUG
, "Skip roam - Current BSS has better "
1154 if (current_bss
->level
< 0) {
1155 if (current_bss
->level
< -85)
1157 else if (current_bss
->level
< -80)
1159 else if (current_bss
->level
< -75)
1161 else if (current_bss
->level
< -70)
1166 if (abs(current_bss
->level
- selected
->level
) < min_diff
) {
1167 wpa_dbg(wpa_s
, MSG_DEBUG
, "Skip roam - too small difference "
1173 #else /* CONFIG_NO_ROAMING */
1175 #endif /* CONFIG_NO_ROAMING */
1179 /* Return != 0 if no scan results could be fetched or if scan results should not
1180 * be shared with other virtual interfaces. */
1181 static int _wpa_supplicant_event_scan_results(struct wpa_supplicant
*wpa_s
,
1182 union wpa_event_data
*data
,
1185 struct wpa_scan_results
*scan_res
;
1187 #ifndef CONFIG_NO_RANDOM_POOL
1189 #endif /* CONFIG_NO_RANDOM_POOL */
1192 if (wpa_s
->ap_iface
)
1194 #endif /* CONFIG_AP */
1196 wpa_supplicant_notify_scanning(wpa_s
, 0);
1199 if (own_request
&& wpa_s
->global
->p2p_cb_on_scan_complete
&&
1200 !wpa_s
->global
->p2p_disabled
&&
1201 wpa_s
->global
->p2p
!= NULL
&& !wpa_s
->sta_scan_pending
&&
1202 !wpa_s
->scan_res_handler
) {
1203 wpa_s
->global
->p2p_cb_on_scan_complete
= 0;
1204 if (p2p_other_scan_completed(wpa_s
->global
->p2p
) == 1) {
1205 wpa_dbg(wpa_s
, MSG_DEBUG
, "P2P: Pending P2P operation "
1206 "stopped scan processing");
1207 wpa_s
->sta_scan_pending
= 1;
1208 wpa_supplicant_req_scan(wpa_s
, 5, 0);
1212 wpa_s
->sta_scan_pending
= 0;
1213 #endif /* CONFIG_P2P */
1215 scan_res
= wpa_supplicant_get_scan_results(wpa_s
,
1216 data
? &data
->scan_info
:
1218 if (scan_res
== NULL
) {
1219 if (wpa_s
->conf
->ap_scan
== 2 || ap
||
1220 wpa_s
->scan_res_handler
== scan_only_handler
)
1224 wpa_dbg(wpa_s
, MSG_DEBUG
, "Failed to get scan results - try "
1226 wpa_supplicant_req_new_scan(wpa_s
, 1, 0);
1230 #ifndef CONFIG_NO_RANDOM_POOL
1231 num
= scan_res
->num
;
1234 for (i
= 0; i
< num
; i
++) {
1236 struct wpa_scan_res
*res
= scan_res
->res
[i
];
1237 buf
[0] = res
->bssid
[5];
1238 buf
[1] = res
->qual
& 0xff;
1239 buf
[2] = res
->noise
& 0xff;
1240 buf
[3] = res
->level
& 0xff;
1241 buf
[4] = res
->tsf
& 0xff;
1242 random_add_randomness(buf
, sizeof(buf
));
1244 #endif /* CONFIG_NO_RANDOM_POOL */
1246 if (own_request
&& wpa_s
->scan_res_handler
) {
1247 void (*scan_res_handler
)(struct wpa_supplicant
*wpa_s
,
1248 struct wpa_scan_results
*scan_res
);
1250 scan_res_handler
= wpa_s
->scan_res_handler
;
1251 wpa_s
->scan_res_handler
= NULL
;
1252 scan_res_handler(wpa_s
, scan_res
);
1254 wpa_scan_results_free(scan_res
);
1259 wpa_dbg(wpa_s
, MSG_DEBUG
, "Ignore scan results in AP mode");
1261 if (wpa_s
->ap_iface
->scan_cb
)
1262 wpa_s
->ap_iface
->scan_cb(wpa_s
->ap_iface
);
1263 #endif /* CONFIG_AP */
1264 wpa_scan_results_free(scan_res
);
1268 wpa_dbg(wpa_s
, MSG_DEBUG
, "New scan results available");
1269 wpa_msg_ctrl(wpa_s
, MSG_INFO
, WPA_EVENT_SCAN_RESULTS
);
1270 wpas_notify_scan_results(wpa_s
);
1272 wpas_notify_scan_done(wpa_s
, 1);
1274 if (sme_proc_obss_scan(wpa_s
) > 0) {
1275 wpa_scan_results_free(scan_res
);
1279 if ((wpa_s
->conf
->ap_scan
== 2 && !wpas_wps_searching(wpa_s
))) {
1280 wpa_scan_results_free(scan_res
);
1284 if (autoscan_notify_scan(wpa_s
, scan_res
)) {
1285 wpa_scan_results_free(scan_res
);
1289 if (wpa_s
->disconnected
) {
1290 wpa_supplicant_set_state(wpa_s
, WPA_DISCONNECTED
);
1291 wpa_scan_results_free(scan_res
);
1295 if (!wpas_driver_bss_selection(wpa_s
) &&
1296 bgscan_notify_scan(wpa_s
, scan_res
) == 1) {
1297 wpa_scan_results_free(scan_res
);
1301 wpas_wps_update_ap_info(wpa_s
, scan_res
);
1303 wpa_scan_results_free(scan_res
);
1305 return wpas_select_network_from_last_scan(wpa_s
, 1, own_request
);
1309 static int wpas_select_network_from_last_scan(struct wpa_supplicant
*wpa_s
,
1310 int new_scan
, int own_request
)
1312 struct wpa_bss
*selected
;
1313 struct wpa_ssid
*ssid
= NULL
;
1315 selected
= wpa_supplicant_pick_network(wpa_s
, &ssid
);
1319 skip
= !wpa_supplicant_need_to_roam(wpa_s
, selected
, ssid
);
1322 wpa_supplicant_rsn_preauth_scan_results(wpa_s
);
1326 if (wpa_supplicant_connect(wpa_s
, selected
, ssid
) < 0) {
1327 wpa_dbg(wpa_s
, MSG_DEBUG
, "Connect failed");
1331 wpa_supplicant_rsn_preauth_scan_results(wpa_s
);
1333 * Do not notify other virtual radios of scan results since we do not
1334 * want them to start other associations at the same time.
1338 wpa_dbg(wpa_s
, MSG_DEBUG
, "No suitable network found");
1339 ssid
= wpa_supplicant_pick_new_network(wpa_s
);
1341 wpa_dbg(wpa_s
, MSG_DEBUG
, "Setup a new network");
1342 wpa_supplicant_associate(wpa_s
, NULL
, ssid
);
1344 wpa_supplicant_rsn_preauth_scan_results(wpa_s
);
1345 } else if (own_request
) {
1347 * No SSID found. If SCAN results are as a result of
1348 * own scan request and not due to a scan request on
1349 * another shared interface, try another scan.
1351 int timeout_sec
= wpa_s
->scan_interval
;
1352 int timeout_usec
= 0;
1354 if (wpas_p2p_scan_no_go_seen(wpa_s
) == 1)
1357 if (wpa_s
->p2p_in_provisioning
) {
1359 * Use shorter wait during P2P Provisioning
1360 * state to speed up group formation.
1363 timeout_usec
= 250000;
1364 wpa_supplicant_req_new_scan(wpa_s
, timeout_sec
,
1368 #endif /* CONFIG_P2P */
1369 #ifdef CONFIG_INTERWORKING
1370 if (wpa_s
->conf
->auto_interworking
&&
1371 wpa_s
->conf
->interworking
&&
1372 wpa_s
->conf
->cred
) {
1373 wpa_dbg(wpa_s
, MSG_DEBUG
, "Interworking: "
1374 "start ANQP fetch since no matching "
1376 wpa_s
->network_select
= 1;
1377 wpa_s
->auto_network_select
= 1;
1378 interworking_start_fetch_anqp(wpa_s
);
1381 #endif /* CONFIG_INTERWORKING */
1382 if (wpa_supplicant_req_sched_scan(wpa_s
))
1383 wpa_supplicant_req_new_scan(wpa_s
, timeout_sec
,
1391 static void wpa_supplicant_event_scan_results(struct wpa_supplicant
*wpa_s
,
1392 union wpa_event_data
*data
)
1394 const char *rn
, *rn2
;
1395 struct wpa_supplicant
*ifs
;
1397 if (_wpa_supplicant_event_scan_results(wpa_s
, data
, 1) != 0) {
1399 * If no scan results could be fetched, then no need to
1400 * notify those interfaces that did not actually request
1401 * this scan. Similarly, if scan results started a new operation on this
1402 * interface, do not notify other interfaces to avoid concurrent
1403 * operations during a connection attempt.
1409 * Check other interfaces to see if they have the same radio-name. If
1410 * so, they get updated with this same scan info.
1412 if (!wpa_s
->driver
->get_radio_name
)
1415 rn
= wpa_s
->driver
->get_radio_name(wpa_s
->drv_priv
);
1416 if (rn
== NULL
|| rn
[0] == '\0')
1419 wpa_dbg(wpa_s
, MSG_DEBUG
, "Checking for other virtual interfaces "
1420 "sharing same radio (%s) in event_scan_results", rn
);
1422 for (ifs
= wpa_s
->global
->ifaces
; ifs
; ifs
= ifs
->next
) {
1423 if (ifs
== wpa_s
|| !ifs
->driver
->get_radio_name
)
1426 rn2
= ifs
->driver
->get_radio_name(ifs
->drv_priv
);
1427 if (rn2
&& os_strcmp(rn
, rn2
) == 0) {
1428 wpa_printf(MSG_DEBUG
, "%s: Updating scan results from "
1429 "sibling", ifs
->ifname
);
1430 _wpa_supplicant_event_scan_results(ifs
, data
, 0);
1435 #endif /* CONFIG_NO_SCAN_PROCESSING */
1438 int wpa_supplicant_fast_associate(struct wpa_supplicant
*wpa_s
)
1440 #ifdef CONFIG_NO_SCAN_PROCESSING
1442 #else /* CONFIG_NO_SCAN_PROCESSING */
1445 if (wpa_s
->last_scan_res_used
<= 0)
1449 if (now
.sec
- wpa_s
->last_scan
.sec
> 5) {
1450 wpa_printf(MSG_DEBUG
, "Fast associate: Old scan results");
1454 return wpas_select_network_from_last_scan(wpa_s
, 0, 1);
1455 #endif /* CONFIG_NO_SCAN_PROCESSING */
1460 static void wnm_bss_keep_alive(void *eloop_ctx
, void *sock_ctx
)
1462 struct wpa_supplicant
*wpa_s
= eloop_ctx
;
1464 if (wpa_s
->wpa_state
< WPA_ASSOCIATED
)
1467 if (!wpa_s
->no_keep_alive
) {
1468 wpa_printf(MSG_DEBUG
, "WNM: Send keep-alive to AP " MACSTR
,
1469 MAC2STR(wpa_s
->bssid
));
1470 /* TODO: could skip this if normal data traffic has been sent */
1471 /* TODO: Consider using some more appropriate data frame for
1474 l2_packet_send(wpa_s
->l2
, wpa_s
->bssid
, 0x0800,
1479 if (wpa_s
->sme
.bss_max_idle_period
) {
1481 msec
= wpa_s
->sme
.bss_max_idle_period
* 1024; /* times 1000 */
1484 eloop_register_timeout(msec
/ 1000, msec
% 1000 * 1000,
1485 wnm_bss_keep_alive
, wpa_s
, NULL
);
1487 #endif /* CONFIG_SME */
1491 static void wnm_process_assoc_resp(struct wpa_supplicant
*wpa_s
,
1492 const u8
*ies
, size_t ies_len
)
1494 struct ieee802_11_elems elems
;
1499 if (ieee802_11_parse_elems(ies
, ies_len
, &elems
, 1) == ParseFailed
)
1503 if (elems
.bss_max_idle_period
) {
1505 wpa_s
->sme
.bss_max_idle_period
=
1506 WPA_GET_LE16(elems
.bss_max_idle_period
);
1507 wpa_printf(MSG_DEBUG
, "WNM: BSS Max Idle Period: %u (* 1000 "
1508 "TU)%s", wpa_s
->sme
.bss_max_idle_period
,
1509 (elems
.bss_max_idle_period
[2] & 0x01) ?
1510 " (protected keep-live required)" : "");
1511 if (wpa_s
->sme
.bss_max_idle_period
== 0)
1512 wpa_s
->sme
.bss_max_idle_period
= 1;
1513 if (wpa_s
->drv_flags
& WPA_DRIVER_FLAGS_SME
) {
1514 eloop_cancel_timeout(wnm_bss_keep_alive
, wpa_s
, NULL
);
1515 /* msec times 1000 */
1516 msec
= wpa_s
->sme
.bss_max_idle_period
* 1024;
1519 eloop_register_timeout(msec
/ 1000, msec
% 1000 * 1000,
1520 wnm_bss_keep_alive
, wpa_s
,
1524 #endif /* CONFIG_SME */
1527 #endif /* CONFIG_WNM */
1530 void wnm_bss_keep_alive_deinit(struct wpa_supplicant
*wpa_s
)
1533 eloop_cancel_timeout(wnm_bss_keep_alive
, wpa_s
, NULL
);
1534 #endif /* CONFIG_WNM */
1538 #ifdef CONFIG_INTERWORKING
1540 static int wpas_qos_map_set(struct wpa_supplicant
*wpa_s
, const u8
*qos_map
,
1545 wpa_hexdump(MSG_DEBUG
, "Interworking: QoS Map Set", qos_map
, len
);
1546 res
= wpa_drv_set_qos_map(wpa_s
, qos_map
, len
);
1548 wpa_printf(MSG_DEBUG
, "Interworking: Failed to configure QoS Map Set to the driver");
1555 static void interworking_process_assoc_resp(struct wpa_supplicant
*wpa_s
,
1556 const u8
*ies
, size_t ies_len
)
1558 struct ieee802_11_elems elems
;
1563 if (ieee802_11_parse_elems(ies
, ies_len
, &elems
, 1) == ParseFailed
)
1566 if (elems
.qos_map_set
) {
1567 wpas_qos_map_set(wpa_s
, elems
.qos_map_set
,
1568 elems
.qos_map_set_len
);
1572 #endif /* CONFIG_INTERWORKING */
1575 static int wpa_supplicant_event_associnfo(struct wpa_supplicant
*wpa_s
,
1576 union wpa_event_data
*data
)
1578 int l
, len
, found
= 0, wpa_found
, rsn_found
;
1580 #ifdef CONFIG_IEEE80211R
1582 #endif /* CONFIG_IEEE80211R */
1584 wpa_dbg(wpa_s
, MSG_DEBUG
, "Association info event");
1585 if (data
->assoc_info
.req_ies
)
1586 wpa_hexdump(MSG_DEBUG
, "req_ies", data
->assoc_info
.req_ies
,
1587 data
->assoc_info
.req_ies_len
);
1588 if (data
->assoc_info
.resp_ies
) {
1589 wpa_hexdump(MSG_DEBUG
, "resp_ies", data
->assoc_info
.resp_ies
,
1590 data
->assoc_info
.resp_ies_len
);
1592 wpa_tdls_assoc_resp_ies(wpa_s
->wpa
, data
->assoc_info
.resp_ies
,
1593 data
->assoc_info
.resp_ies_len
);
1594 #endif /* CONFIG_TDLS */
1596 wnm_process_assoc_resp(wpa_s
, data
->assoc_info
.resp_ies
,
1597 data
->assoc_info
.resp_ies_len
);
1598 #endif /* CONFIG_WNM */
1599 #ifdef CONFIG_INTERWORKING
1600 interworking_process_assoc_resp(wpa_s
, data
->assoc_info
.resp_ies
,
1601 data
->assoc_info
.resp_ies_len
);
1602 #endif /* CONFIG_INTERWORKING */
1604 if (data
->assoc_info
.beacon_ies
)
1605 wpa_hexdump(MSG_DEBUG
, "beacon_ies",
1606 data
->assoc_info
.beacon_ies
,
1607 data
->assoc_info
.beacon_ies_len
);
1608 if (data
->assoc_info
.freq
)
1609 wpa_dbg(wpa_s
, MSG_DEBUG
, "freq=%u MHz",
1610 data
->assoc_info
.freq
);
1612 p
= data
->assoc_info
.req_ies
;
1613 l
= data
->assoc_info
.req_ies_len
;
1615 /* Go through the IEs and make a copy of the WPA/RSN IE, if present. */
1616 while (p
&& l
>= 2) {
1619 wpa_hexdump(MSG_DEBUG
, "Truncated IE in assoc_info",
1623 if ((p
[0] == WLAN_EID_VENDOR_SPECIFIC
&& p
[1] >= 6 &&
1624 (os_memcmp(&p
[2], "\x00\x50\xF2\x01\x01\x00", 6) == 0)) ||
1625 (p
[0] == WLAN_EID_RSN
&& p
[1] >= 2)) {
1626 if (wpa_sm_set_assoc_wpa_ie(wpa_s
->wpa
, p
, len
))
1629 wpa_find_assoc_pmkid(wpa_s
);
1635 if (!found
&& data
->assoc_info
.req_ies
)
1636 wpa_sm_set_assoc_wpa_ie(wpa_s
->wpa
, NULL
, 0);
1638 #ifdef CONFIG_IEEE80211R
1640 if (wpa_s
->sme
.auth_alg
== WPA_AUTH_ALG_FT
) {
1641 if (wpa_drv_get_bssid(wpa_s
, bssid
) < 0 ||
1642 wpa_ft_validate_reassoc_resp(wpa_s
->wpa
,
1643 data
->assoc_info
.resp_ies
,
1644 data
->assoc_info
.resp_ies_len
,
1646 wpa_dbg(wpa_s
, MSG_DEBUG
, "FT: Validation of "
1647 "Reassociation Response failed");
1648 wpa_supplicant_deauthenticate(
1649 wpa_s
, WLAN_REASON_INVALID_IE
);
1654 p
= data
->assoc_info
.resp_ies
;
1655 l
= data
->assoc_info
.resp_ies_len
;
1657 #ifdef CONFIG_WPS_STRICT
1658 if (p
&& wpa_s
->current_ssid
&&
1659 wpa_s
->current_ssid
->key_mgmt
== WPA_KEY_MGMT_WPS
) {
1661 wps
= ieee802_11_vendor_ie_concat(p
, l
, WPS_IE_VENDOR_TYPE
);
1663 wpa_msg(wpa_s
, MSG_INFO
, "WPS-STRICT: AP did not "
1664 "include WPS IE in (Re)Association Response");
1668 if (wps_validate_assoc_resp(wps
) < 0) {
1670 wpa_supplicant_deauthenticate(
1671 wpa_s
, WLAN_REASON_INVALID_IE
);
1676 #endif /* CONFIG_WPS_STRICT */
1678 /* Go through the IEs and make a copy of the MDIE, if present. */
1679 while (p
&& l
>= 2) {
1682 wpa_hexdump(MSG_DEBUG
, "Truncated IE in assoc_info",
1686 if (p
[0] == WLAN_EID_MOBILITY_DOMAIN
&&
1687 p
[1] >= MOBILITY_DOMAIN_ID_LEN
) {
1688 wpa_s
->sme
.ft_used
= 1;
1689 os_memcpy(wpa_s
->sme
.mobility_domain
, p
+ 2,
1690 MOBILITY_DOMAIN_ID_LEN
);
1696 #endif /* CONFIG_SME */
1698 /* Process FT when SME is in the driver */
1699 if (!(wpa_s
->drv_flags
& WPA_DRIVER_FLAGS_SME
) &&
1700 wpa_ft_is_completed(wpa_s
->wpa
)) {
1701 if (wpa_drv_get_bssid(wpa_s
, bssid
) < 0 ||
1702 wpa_ft_validate_reassoc_resp(wpa_s
->wpa
,
1703 data
->assoc_info
.resp_ies
,
1704 data
->assoc_info
.resp_ies_len
,
1706 wpa_dbg(wpa_s
, MSG_DEBUG
, "FT: Validation of "
1707 "Reassociation Response failed");
1708 wpa_supplicant_deauthenticate(
1709 wpa_s
, WLAN_REASON_INVALID_IE
);
1712 wpa_dbg(wpa_s
, MSG_DEBUG
, "FT: Reassociation Response done");
1715 wpa_sm_set_ft_params(wpa_s
->wpa
, data
->assoc_info
.resp_ies
,
1716 data
->assoc_info
.resp_ies_len
);
1717 #endif /* CONFIG_IEEE80211R */
1719 /* WPA/RSN IE from Beacon/ProbeResp */
1720 p
= data
->assoc_info
.beacon_ies
;
1721 l
= data
->assoc_info
.beacon_ies_len
;
1723 /* Go through the IEs and make a copy of the WPA/RSN IEs, if present.
1725 wpa_found
= rsn_found
= 0;
1726 while (p
&& l
>= 2) {
1729 wpa_hexdump(MSG_DEBUG
, "Truncated IE in beacon_ies",
1734 p
[0] == WLAN_EID_VENDOR_SPECIFIC
&& p
[1] >= 6 &&
1735 os_memcmp(&p
[2], "\x00\x50\xF2\x01\x01\x00", 6) == 0) {
1737 wpa_sm_set_ap_wpa_ie(wpa_s
->wpa
, p
, len
);
1741 p
[0] == WLAN_EID_RSN
&& p
[1] >= 2) {
1743 wpa_sm_set_ap_rsn_ie(wpa_s
->wpa
, p
, len
);
1750 if (!wpa_found
&& data
->assoc_info
.beacon_ies
)
1751 wpa_sm_set_ap_wpa_ie(wpa_s
->wpa
, NULL
, 0);
1752 if (!rsn_found
&& data
->assoc_info
.beacon_ies
)
1753 wpa_sm_set_ap_rsn_ie(wpa_s
->wpa
, NULL
, 0);
1754 if (wpa_found
|| rsn_found
)
1755 wpa_s
->ap_ies_from_associnfo
= 1;
1757 if (wpa_s
->assoc_freq
&& data
->assoc_info
.freq
&&
1758 wpa_s
->assoc_freq
!= data
->assoc_info
.freq
) {
1759 wpa_printf(MSG_DEBUG
, "Operating frequency changed from "
1761 wpa_s
->assoc_freq
, data
->assoc_info
.freq
);
1762 wpa_supplicant_update_scan_results(wpa_s
);
1765 wpa_s
->assoc_freq
= data
->assoc_info
.freq
;
1771 static struct wpa_bss
* wpa_supplicant_get_new_bss(
1772 struct wpa_supplicant
*wpa_s
, const u8
*bssid
)
1774 struct wpa_bss
*bss
= NULL
;
1775 struct wpa_ssid
*ssid
= wpa_s
->current_ssid
;
1777 if (ssid
->ssid_len
> 0)
1778 bss
= wpa_bss_get(wpa_s
, bssid
, ssid
->ssid
, ssid
->ssid_len
);
1780 bss
= wpa_bss_get_bssid(wpa_s
, bssid
);
1786 static int wpa_supplicant_assoc_update_ie(struct wpa_supplicant
*wpa_s
)
1788 const u8
*bss_wpa
= NULL
, *bss_rsn
= NULL
;
1790 if (!wpa_s
->current_bss
|| !wpa_s
->current_ssid
)
1793 if (!wpa_key_mgmt_wpa_any(wpa_s
->current_ssid
->key_mgmt
))
1796 bss_wpa
= wpa_bss_get_vendor_ie(wpa_s
->current_bss
,
1797 WPA_IE_VENDOR_TYPE
);
1798 bss_rsn
= wpa_bss_get_ie(wpa_s
->current_bss
, WLAN_EID_RSN
);
1800 if (wpa_sm_set_ap_wpa_ie(wpa_s
->wpa
, bss_wpa
,
1801 bss_wpa
? 2 + bss_wpa
[1] : 0) ||
1802 wpa_sm_set_ap_rsn_ie(wpa_s
->wpa
, bss_rsn
,
1803 bss_rsn
? 2 + bss_rsn
[1] : 0))
1810 static void wpa_supplicant_event_assoc(struct wpa_supplicant
*wpa_s
,
1811 union wpa_event_data
*data
)
1817 if (wpa_s
->ap_iface
) {
1818 hostapd_notif_assoc(wpa_s
->ap_iface
->bss
[0],
1819 data
->assoc_info
.addr
,
1820 data
->assoc_info
.req_ies
,
1821 data
->assoc_info
.req_ies_len
,
1822 data
->assoc_info
.reassoc
);
1825 #endif /* CONFIG_AP */
1827 ft_completed
= wpa_ft_is_completed(wpa_s
->wpa
);
1828 if (data
&& wpa_supplicant_event_associnfo(wpa_s
, data
) < 0)
1831 if (wpa_drv_get_bssid(wpa_s
, bssid
) < 0) {
1832 wpa_dbg(wpa_s
, MSG_ERROR
, "Failed to get BSSID");
1833 wpa_supplicant_deauthenticate(
1834 wpa_s
, WLAN_REASON_DEAUTH_LEAVING
);
1838 wpa_supplicant_set_state(wpa_s
, WPA_ASSOCIATED
);
1839 if (os_memcmp(bssid
, wpa_s
->bssid
, ETH_ALEN
) != 0) {
1840 wpa_dbg(wpa_s
, MSG_DEBUG
, "Associated to a new BSS: BSSID="
1841 MACSTR
, MAC2STR(bssid
));
1842 random_add_randomness(bssid
, ETH_ALEN
);
1843 os_memcpy(wpa_s
->bssid
, bssid
, ETH_ALEN
);
1844 os_memset(wpa_s
->pending_bssid
, 0, ETH_ALEN
);
1845 wpas_notify_bssid_changed(wpa_s
);
1847 if (wpa_supplicant_dynamic_keys(wpa_s
) && !ft_completed
) {
1848 wpa_clear_keys(wpa_s
, bssid
);
1850 if (wpa_supplicant_select_config(wpa_s
) < 0) {
1851 wpa_supplicant_deauthenticate(
1852 wpa_s
, WLAN_REASON_DEAUTH_LEAVING
);
1855 if (wpa_s
->current_ssid
) {
1856 struct wpa_bss
*bss
= NULL
;
1858 bss
= wpa_supplicant_get_new_bss(wpa_s
, bssid
);
1860 wpa_supplicant_update_scan_results(wpa_s
);
1862 /* Get the BSS from the new scan results */
1863 bss
= wpa_supplicant_get_new_bss(wpa_s
, bssid
);
1867 wpa_s
->current_bss
= bss
;
1870 if (wpa_s
->conf
->ap_scan
== 1 &&
1871 wpa_s
->drv_flags
& WPA_DRIVER_FLAGS_BSS_SELECTION
) {
1872 if (wpa_supplicant_assoc_update_ie(wpa_s
) < 0)
1873 wpa_msg(wpa_s
, MSG_WARNING
,
1874 "WPA/RSN IEs not updated");
1879 os_memcpy(wpa_s
->sme
.prev_bssid
, bssid
, ETH_ALEN
);
1880 wpa_s
->sme
.prev_bssid_set
= 1;
1881 #endif /* CONFIG_SME */
1883 wpa_msg(wpa_s
, MSG_INFO
, "Associated with " MACSTR
, MAC2STR(bssid
));
1884 if (wpa_s
->current_ssid
) {
1885 /* When using scanning (ap_scan=1), SIM PC/SC interface can be
1886 * initialized before association, but for other modes,
1887 * initialize PC/SC here, if the current configuration needs
1888 * smartcard or SIM/USIM. */
1889 wpa_supplicant_scard_init(wpa_s
, wpa_s
->current_ssid
);
1891 wpa_sm_notify_assoc(wpa_s
->wpa
, bssid
);
1893 l2_packet_notify_auth_start(wpa_s
->l2
);
1896 * Set portEnabled first to FALSE in order to get EAP state machine out
1897 * of the SUCCESS state and eapSuccess cleared. Without this, EAPOL PAE
1898 * state machine may transit to AUTHENTICATING state based on obsolete
1899 * eapSuccess and then trigger BE_AUTH to SUCCESS and PAE to
1900 * AUTHENTICATED without ever giving chance to EAP state machine to
1903 if (!ft_completed
) {
1904 eapol_sm_notify_portEnabled(wpa_s
->eapol
, FALSE
);
1905 eapol_sm_notify_portValid(wpa_s
->eapol
, FALSE
);
1907 if (wpa_key_mgmt_wpa_psk(wpa_s
->key_mgmt
) || ft_completed
)
1908 eapol_sm_notify_eap_success(wpa_s
->eapol
, FALSE
);
1909 /* 802.1X::portControl = Auto */
1910 eapol_sm_notify_portEnabled(wpa_s
->eapol
, TRUE
);
1911 wpa_s
->eapol_received
= 0;
1912 if (wpa_s
->key_mgmt
== WPA_KEY_MGMT_NONE
||
1913 wpa_s
->key_mgmt
== WPA_KEY_MGMT_WPA_NONE
||
1914 (wpa_s
->current_ssid
&&
1915 wpa_s
->current_ssid
->mode
== IEEE80211_MODE_IBSS
)) {
1916 if (wpa_s
->key_mgmt
== WPA_KEY_MGMT_WPA_NONE
&&
1918 WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC_DONE
)) {
1920 * Set the key after having received joined-IBSS event
1923 wpa_supplicant_set_wpa_none_key(wpa_s
,
1924 wpa_s
->current_ssid
);
1926 wpa_supplicant_cancel_auth_timeout(wpa_s
);
1927 wpa_supplicant_set_state(wpa_s
, WPA_COMPLETED
);
1928 } else if (!ft_completed
) {
1929 /* Timeout for receiving the first EAPOL packet */
1930 wpa_supplicant_req_auth_timeout(wpa_s
, 10, 0);
1932 wpa_supplicant_cancel_scan(wpa_s
);
1934 if ((wpa_s
->drv_flags
& WPA_DRIVER_FLAGS_4WAY_HANDSHAKE
) &&
1935 wpa_key_mgmt_wpa_psk(wpa_s
->key_mgmt
)) {
1937 * We are done; the driver will take care of RSN 4-way
1940 wpa_supplicant_cancel_auth_timeout(wpa_s
);
1941 wpa_supplicant_set_state(wpa_s
, WPA_COMPLETED
);
1942 eapol_sm_notify_portValid(wpa_s
->eapol
, TRUE
);
1943 eapol_sm_notify_eap_success(wpa_s
->eapol
, TRUE
);
1944 } else if ((wpa_s
->drv_flags
& WPA_DRIVER_FLAGS_4WAY_HANDSHAKE
) &&
1945 wpa_key_mgmt_wpa_ieee8021x(wpa_s
->key_mgmt
)) {
1947 * The driver will take care of RSN 4-way handshake, so we need
1948 * to allow EAPOL supplicant to complete its work without
1949 * waiting for WPA supplicant.
1951 eapol_sm_notify_portValid(wpa_s
->eapol
, TRUE
);
1952 } else if (ft_completed
) {
1954 * FT protocol completed - make sure EAPOL state machine ends
1955 * up in authenticated.
1957 wpa_supplicant_cancel_auth_timeout(wpa_s
);
1958 wpa_supplicant_set_state(wpa_s
, WPA_COMPLETED
);
1959 eapol_sm_notify_portValid(wpa_s
->eapol
, TRUE
);
1960 eapol_sm_notify_eap_success(wpa_s
->eapol
, TRUE
);
1963 wpa_s
->last_eapol_matches_bssid
= 0;
1965 if (wpa_s
->pending_eapol_rx
) {
1966 struct os_time now
, age
;
1968 os_time_sub(&now
, &wpa_s
->pending_eapol_rx_time
, &age
);
1969 if (age
.sec
== 0 && age
.usec
< 100000 &&
1970 os_memcmp(wpa_s
->pending_eapol_rx_src
, bssid
, ETH_ALEN
) ==
1972 wpa_dbg(wpa_s
, MSG_DEBUG
, "Process pending EAPOL "
1973 "frame that was received just before "
1974 "association notification");
1975 wpa_supplicant_rx_eapol(
1976 wpa_s
, wpa_s
->pending_eapol_rx_src
,
1977 wpabuf_head(wpa_s
->pending_eapol_rx
),
1978 wpabuf_len(wpa_s
->pending_eapol_rx
));
1980 wpabuf_free(wpa_s
->pending_eapol_rx
);
1981 wpa_s
->pending_eapol_rx
= NULL
;
1984 if ((wpa_s
->key_mgmt
== WPA_KEY_MGMT_NONE
||
1985 wpa_s
->key_mgmt
== WPA_KEY_MGMT_IEEE8021X_NO_WPA
) &&
1986 wpa_s
->current_ssid
&&
1987 (wpa_s
->drv_flags
& WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC_DONE
)) {
1988 /* Set static WEP keys again */
1989 wpa_set_wep_keys(wpa_s
, wpa_s
->current_ssid
);
1992 #ifdef CONFIG_IBSS_RSN
1993 if (wpa_s
->current_ssid
&&
1994 wpa_s
->current_ssid
->mode
== WPAS_MODE_IBSS
&&
1995 wpa_s
->key_mgmt
!= WPA_KEY_MGMT_NONE
&&
1996 wpa_s
->key_mgmt
!= WPA_KEY_MGMT_WPA_NONE
&&
1997 wpa_s
->ibss_rsn
== NULL
) {
1998 wpa_s
->ibss_rsn
= ibss_rsn_init(wpa_s
);
1999 if (!wpa_s
->ibss_rsn
) {
2000 wpa_msg(wpa_s
, MSG_INFO
, "Failed to init IBSS RSN");
2001 wpa_supplicant_deauthenticate(
2002 wpa_s
, WLAN_REASON_DEAUTH_LEAVING
);
2006 ibss_rsn_set_psk(wpa_s
->ibss_rsn
, wpa_s
->current_ssid
->psk
);
2008 #endif /* CONFIG_IBSS_RSN */
2010 wpas_wps_notify_assoc(wpa_s
, bssid
);
2014 static int disconnect_reason_recoverable(u16 reason_code
)
2016 return reason_code
== WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY
||
2017 reason_code
== WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA
||
2018 reason_code
== WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA
;
2022 static void wpa_supplicant_event_disassoc(struct wpa_supplicant
*wpa_s
,
2024 int locally_generated
)
2028 if (wpa_s
->key_mgmt
== WPA_KEY_MGMT_WPA_NONE
) {
2030 * At least Host AP driver and a Prism3 card seemed to be
2031 * generating streams of disconnected events when configuring
2032 * IBSS for WPA-None. Ignore them for now.
2037 bssid
= wpa_s
->bssid
;
2038 if (is_zero_ether_addr(bssid
))
2039 bssid
= wpa_s
->pending_bssid
;
2041 if (!is_zero_ether_addr(bssid
) ||
2042 wpa_s
->wpa_state
>= WPA_AUTHENTICATING
) {
2043 wpa_msg(wpa_s
, MSG_INFO
, WPA_EVENT_DISCONNECTED
"bssid=" MACSTR
2045 MAC2STR(bssid
), reason_code
,
2046 locally_generated
? " locally_generated=1" : "");
2051 static int could_be_psk_mismatch(struct wpa_supplicant
*wpa_s
, u16 reason_code
,
2052 int locally_generated
)
2054 if (wpa_s
->wpa_state
!= WPA_4WAY_HANDSHAKE
||
2055 !wpa_key_mgmt_wpa_psk(wpa_s
->key_mgmt
))
2056 return 0; /* Not in 4-way handshake with PSK */
2059 * It looks like connection was lost while trying to go through PSK
2060 * 4-way handshake. Filter out known disconnection cases that are caused
2061 * by something else than PSK mismatch to avoid confusing reports.
2064 if (locally_generated
) {
2065 if (reason_code
== WLAN_REASON_IE_IN_4WAY_DIFFERS
)
2073 static void wpa_supplicant_event_disassoc_finish(struct wpa_supplicant
*wpa_s
,
2075 int locally_generated
)
2079 u8 prev_pending_bssid
[ETH_ALEN
];
2080 struct wpa_bss
*fast_reconnect
= NULL
;
2081 #ifndef CONFIG_NO_SCAN_PROCESSING
2082 struct wpa_ssid
*fast_reconnect_ssid
= NULL
;
2083 #endif /* CONFIG_NO_SCAN_PROCESSING */
2084 struct wpa_ssid
*last_ssid
;
2086 authenticating
= wpa_s
->wpa_state
== WPA_AUTHENTICATING
;
2087 os_memcpy(prev_pending_bssid
, wpa_s
->pending_bssid
, ETH_ALEN
);
2089 if (wpa_s
->key_mgmt
== WPA_KEY_MGMT_WPA_NONE
) {
2091 * At least Host AP driver and a Prism3 card seemed to be
2092 * generating streams of disconnected events when configuring
2093 * IBSS for WPA-None. Ignore them for now.
2095 wpa_dbg(wpa_s
, MSG_DEBUG
, "Disconnect event - ignore in "
2096 "IBSS/WPA-None mode");
2100 if (could_be_psk_mismatch(wpa_s
, reason_code
, locally_generated
)) {
2101 wpa_msg(wpa_s
, MSG_INFO
, "WPA: 4-Way Handshake failed - "
2102 "pre-shared key may be incorrect");
2103 if (wpas_p2p_4way_hs_failed(wpa_s
) > 0)
2104 return; /* P2P group removed */
2105 wpas_auth_failed(wpa_s
);
2107 if (!wpa_s
->disconnected
&&
2108 (!wpa_s
->auto_reconnect_disabled
||
2109 wpa_s
->key_mgmt
== WPA_KEY_MGMT_WPS
)) {
2110 wpa_dbg(wpa_s
, MSG_DEBUG
, "Auto connect enabled: try to "
2111 "reconnect (wps=%d wpa_state=%d)",
2112 wpa_s
->key_mgmt
== WPA_KEY_MGMT_WPS
,
2114 if (wpa_s
->wpa_state
== WPA_COMPLETED
&&
2115 wpa_s
->current_ssid
&&
2116 wpa_s
->current_ssid
->mode
== WPAS_MODE_INFRA
&&
2117 !locally_generated
&&
2118 disconnect_reason_recoverable(reason_code
)) {
2120 * It looks like the AP has dropped association with
2121 * us, but could allow us to get back in. Try to
2122 * reconnect to the same BSS without full scan to save
2123 * time for some common cases.
2125 fast_reconnect
= wpa_s
->current_bss
;
2126 #ifndef CONFIG_NO_SCAN_PROCESSING
2127 fast_reconnect_ssid
= wpa_s
->current_ssid
;
2128 #endif /* CONFIG_NO_SCAN_PROCESSING */
2129 } else if (wpa_s
->wpa_state
>= WPA_ASSOCIATING
)
2130 wpa_supplicant_req_scan(wpa_s
, 0, 100000);
2132 wpa_dbg(wpa_s
, MSG_DEBUG
, "Do not request new "
2135 wpa_dbg(wpa_s
, MSG_DEBUG
, "Auto connect disabled: do not "
2136 "try to re-connect");
2137 wpa_s
->reassociate
= 0;
2138 wpa_s
->disconnected
= 1;
2139 wpa_supplicant_cancel_sched_scan(wpa_s
);
2141 bssid
= wpa_s
->bssid
;
2142 if (is_zero_ether_addr(bssid
))
2143 bssid
= wpa_s
->pending_bssid
;
2144 if (wpa_s
->wpa_state
>= WPA_AUTHENTICATING
)
2145 wpas_connection_failed(wpa_s
, bssid
);
2146 wpa_sm_notify_disassoc(wpa_s
->wpa
);
2147 if (locally_generated
)
2148 wpa_s
->disconnect_reason
= -reason_code
;
2150 wpa_s
->disconnect_reason
= reason_code
;
2151 wpas_notify_disconnect_reason(wpa_s
);
2152 if (wpa_supplicant_dynamic_keys(wpa_s
)) {
2153 wpa_dbg(wpa_s
, MSG_DEBUG
, "Disconnect event - remove keys");
2154 wpa_s
->keys_cleared
= 0;
2155 wpa_clear_keys(wpa_s
, wpa_s
->bssid
);
2157 last_ssid
= wpa_s
->current_ssid
;
2158 wpa_supplicant_mark_disassoc(wpa_s
);
2160 if (authenticating
&& (wpa_s
->drv_flags
& WPA_DRIVER_FLAGS_SME
)) {
2161 sme_disassoc_while_authenticating(wpa_s
, prev_pending_bssid
);
2162 wpa_s
->current_ssid
= last_ssid
;
2165 if (fast_reconnect
) {
2166 #ifndef CONFIG_NO_SCAN_PROCESSING
2167 wpa_dbg(wpa_s
, MSG_DEBUG
, "Try to reconnect to the same BSS");
2168 if (wpa_supplicant_connect(wpa_s
, fast_reconnect
,
2169 fast_reconnect_ssid
) < 0) {
2170 /* Recover through full scan */
2171 wpa_supplicant_req_scan(wpa_s
, 0, 100000);
2173 #endif /* CONFIG_NO_SCAN_PROCESSING */
2178 #ifdef CONFIG_DELAYED_MIC_ERROR_REPORT
2179 void wpa_supplicant_delayed_mic_error_report(void *eloop_ctx
, void *sock_ctx
)
2181 struct wpa_supplicant
*wpa_s
= eloop_ctx
;
2183 if (!wpa_s
->pending_mic_error_report
)
2186 wpa_dbg(wpa_s
, MSG_DEBUG
, "WPA: Sending pending MIC error report");
2187 wpa_sm_key_request(wpa_s
->wpa
, 1, wpa_s
->pending_mic_error_pairwise
);
2188 wpa_s
->pending_mic_error_report
= 0;
2190 #endif /* CONFIG_DELAYED_MIC_ERROR_REPORT */
2194 wpa_supplicant_event_michael_mic_failure(struct wpa_supplicant
*wpa_s
,
2195 union wpa_event_data
*data
)
2200 wpa_msg(wpa_s
, MSG_WARNING
, "Michael MIC failure detected");
2201 pairwise
= (data
&& data
->michael_mic_failure
.unicast
);
2203 if ((wpa_s
->last_michael_mic_error
&&
2204 t
.sec
- wpa_s
->last_michael_mic_error
<= 60) ||
2205 wpa_s
->pending_mic_error_report
) {
2206 if (wpa_s
->pending_mic_error_report
) {
2208 * Send the pending MIC error report immediately since
2209 * we are going to start countermeasures and AP better
2212 wpa_sm_key_request(wpa_s
->wpa
, 1,
2213 wpa_s
->pending_mic_error_pairwise
);
2216 /* Send the new MIC error report immediately since we are going
2217 * to start countermeasures and AP better do the same.
2219 wpa_sm_key_request(wpa_s
->wpa
, 1, pairwise
);
2221 /* initialize countermeasures */
2222 wpa_s
->countermeasures
= 1;
2224 wpa_blacklist_add(wpa_s
, wpa_s
->bssid
);
2226 wpa_msg(wpa_s
, MSG_WARNING
, "TKIP countermeasures started");
2229 * Need to wait for completion of request frame. We do not get
2230 * any callback for the message completion, so just wait a
2231 * short while and hope for the best. */
2234 wpa_drv_set_countermeasures(wpa_s
, 1);
2235 wpa_supplicant_deauthenticate(wpa_s
,
2236 WLAN_REASON_MICHAEL_MIC_FAILURE
);
2237 eloop_cancel_timeout(wpa_supplicant_stop_countermeasures
,
2239 eloop_register_timeout(60, 0,
2240 wpa_supplicant_stop_countermeasures
,
2242 /* TODO: mark the AP rejected for 60 second. STA is
2243 * allowed to associate with another AP.. */
2245 #ifdef CONFIG_DELAYED_MIC_ERROR_REPORT
2246 if (wpa_s
->mic_errors_seen
) {
2248 * Reduce the effectiveness of Michael MIC error
2249 * reports as a means for attacking against TKIP if
2250 * more than one MIC failure is noticed with the same
2251 * PTK. We delay the transmission of the reports by a
2252 * random time between 0 and 60 seconds in order to
2253 * force the attacker wait 60 seconds before getting
2254 * the information on whether a frame resulted in a MIC
2260 if (os_get_random(rval
, sizeof(rval
)) < 0)
2261 sec
= os_random() % 60;
2263 sec
= WPA_GET_BE32(rval
) % 60;
2264 wpa_dbg(wpa_s
, MSG_DEBUG
, "WPA: Delay MIC error "
2265 "report %d seconds", sec
);
2266 wpa_s
->pending_mic_error_report
= 1;
2267 wpa_s
->pending_mic_error_pairwise
= pairwise
;
2268 eloop_cancel_timeout(
2269 wpa_supplicant_delayed_mic_error_report
,
2271 eloop_register_timeout(
2272 sec
, os_random() % 1000000,
2273 wpa_supplicant_delayed_mic_error_report
,
2276 wpa_sm_key_request(wpa_s
->wpa
, 1, pairwise
);
2278 #else /* CONFIG_DELAYED_MIC_ERROR_REPORT */
2279 wpa_sm_key_request(wpa_s
->wpa
, 1, pairwise
);
2280 #endif /* CONFIG_DELAYED_MIC_ERROR_REPORT */
2282 wpa_s
->last_michael_mic_error
= t
.sec
;
2283 wpa_s
->mic_errors_seen
++;
2287 #ifdef CONFIG_TERMINATE_ONLASTIF
2288 static int any_interfaces(struct wpa_supplicant
*head
)
2290 struct wpa_supplicant
*wpa_s
;
2292 for (wpa_s
= head
; wpa_s
!= NULL
; wpa_s
= wpa_s
->next
)
2293 if (!wpa_s
->interface_removed
)
2297 #endif /* CONFIG_TERMINATE_ONLASTIF */
2301 wpa_supplicant_event_interface_status(struct wpa_supplicant
*wpa_s
,
2302 union wpa_event_data
*data
)
2304 if (os_strcmp(wpa_s
->ifname
, data
->interface_status
.ifname
) != 0)
2307 switch (data
->interface_status
.ievent
) {
2308 case EVENT_INTERFACE_ADDED
:
2309 if (!wpa_s
->interface_removed
)
2311 wpa_s
->interface_removed
= 0;
2312 wpa_dbg(wpa_s
, MSG_DEBUG
, "Configured interface was added");
2313 if (wpa_supplicant_driver_init(wpa_s
) < 0) {
2314 wpa_msg(wpa_s
, MSG_INFO
, "Failed to initialize the "
2315 "driver after interface was added");
2317 wpa_supplicant_set_state(wpa_s
, WPA_DISCONNECTED
);
2319 case EVENT_INTERFACE_REMOVED
:
2320 wpa_dbg(wpa_s
, MSG_DEBUG
, "Configured interface was removed");
2321 wpa_s
->interface_removed
= 1;
2322 wpa_supplicant_mark_disassoc(wpa_s
);
2323 wpa_supplicant_set_state(wpa_s
, WPA_INTERFACE_DISABLED
);
2324 l2_packet_deinit(wpa_s
->l2
);
2326 #ifdef CONFIG_IBSS_RSN
2327 ibss_rsn_deinit(wpa_s
->ibss_rsn
);
2328 wpa_s
->ibss_rsn
= NULL
;
2329 #endif /* CONFIG_IBSS_RSN */
2330 #ifdef CONFIG_TERMINATE_ONLASTIF
2331 /* check if last interface */
2332 if (!any_interfaces(wpa_s
->global
->ifaces
))
2334 #endif /* CONFIG_TERMINATE_ONLASTIF */
2340 #ifdef CONFIG_PEERKEY
2342 wpa_supplicant_event_stkstart(struct wpa_supplicant
*wpa_s
,
2343 union wpa_event_data
*data
)
2347 wpa_sm_stkstart(wpa_s
->wpa
, data
->stkstart
.peer
);
2349 #endif /* CONFIG_PEERKEY */
2353 static void wpa_supplicant_event_tdls(struct wpa_supplicant
*wpa_s
,
2354 union wpa_event_data
*data
)
2358 switch (data
->tdls
.oper
) {
2359 case TDLS_REQUEST_SETUP
:
2360 wpa_tdls_remove(wpa_s
->wpa
, data
->tdls
.peer
);
2361 if (wpa_tdls_is_external_setup(wpa_s
->wpa
))
2362 wpa_tdls_start(wpa_s
->wpa
, data
->tdls
.peer
);
2364 wpa_drv_tdls_oper(wpa_s
, TDLS_SETUP
, data
->tdls
.peer
);
2366 case TDLS_REQUEST_TEARDOWN
:
2367 if (wpa_tdls_is_external_setup(wpa_s
->wpa
))
2368 wpa_tdls_teardown_link(wpa_s
->wpa
, data
->tdls
.peer
,
2369 data
->tdls
.reason_code
);
2371 wpa_drv_tdls_oper(wpa_s
, TDLS_TEARDOWN
,
2376 #endif /* CONFIG_TDLS */
2380 static void wpa_supplicant_event_wnm(struct wpa_supplicant
*wpa_s
,
2381 union wpa_event_data
*data
)
2385 switch (data
->wnm
.oper
) {
2386 case WNM_OPER_SLEEP
:
2387 wpa_printf(MSG_DEBUG
, "Start sending WNM-Sleep Request "
2388 "(action=%d, intval=%d)",
2389 data
->wnm
.sleep_action
, data
->wnm
.sleep_intval
);
2390 ieee802_11_send_wnmsleep_req(wpa_s
, data
->wnm
.sleep_action
,
2391 data
->wnm
.sleep_intval
, NULL
);
2395 #endif /* CONFIG_WNM */
2398 #ifdef CONFIG_IEEE80211R
2400 wpa_supplicant_event_ft_response(struct wpa_supplicant
*wpa_s
,
2401 union wpa_event_data
*data
)
2406 if (wpa_ft_process_response(wpa_s
->wpa
, data
->ft_ies
.ies
,
2407 data
->ft_ies
.ies_len
,
2408 data
->ft_ies
.ft_action
,
2409 data
->ft_ies
.target_ap
,
2410 data
->ft_ies
.ric_ies
,
2411 data
->ft_ies
.ric_ies_len
) < 0) {
2412 /* TODO: prevent MLME/driver from trying to associate? */
2415 #endif /* CONFIG_IEEE80211R */
2418 #ifdef CONFIG_IBSS_RSN
2419 static void wpa_supplicant_event_ibss_rsn_start(struct wpa_supplicant
*wpa_s
,
2420 union wpa_event_data
*data
)
2422 struct wpa_ssid
*ssid
;
2423 if (wpa_s
->wpa_state
< WPA_ASSOCIATED
)
2427 ssid
= wpa_s
->current_ssid
;
2430 if (ssid
->mode
!= WPAS_MODE_IBSS
|| !wpa_key_mgmt_wpa(ssid
->key_mgmt
))
2433 ibss_rsn_start(wpa_s
->ibss_rsn
, data
->ibss_rsn_start
.peer
);
2437 static void wpa_supplicant_event_ibss_auth(struct wpa_supplicant
*wpa_s
,
2438 union wpa_event_data
*data
)
2440 struct wpa_ssid
*ssid
= wpa_s
->current_ssid
;
2445 /* check if the ssid is correctly configured as IBSS/RSN */
2446 if (ssid
->mode
!= WPAS_MODE_IBSS
|| !wpa_key_mgmt_wpa(ssid
->key_mgmt
))
2449 ibss_rsn_handle_auth(wpa_s
->ibss_rsn
, data
->rx_mgmt
.frame
,
2450 data
->rx_mgmt
.frame_len
);
2452 #endif /* CONFIG_IBSS_RSN */
2455 #ifdef CONFIG_IEEE80211R
2456 static void ft_rx_action(struct wpa_supplicant
*wpa_s
, const u8
*data
,
2459 const u8
*sta_addr
, *target_ap_addr
;
2462 wpa_hexdump(MSG_MSGDUMP
, "FT: RX Action", data
, len
);
2463 if (!(wpa_s
->drv_flags
& WPA_DRIVER_FLAGS_SME
))
2464 return; /* only SME case supported for now */
2465 if (len
< 1 + 2 * ETH_ALEN
+ 2)
2468 return; /* Only FT Action Response is supported for now */
2469 sta_addr
= data
+ 1;
2470 target_ap_addr
= data
+ 1 + ETH_ALEN
;
2471 status
= WPA_GET_LE16(data
+ 1 + 2 * ETH_ALEN
);
2472 wpa_dbg(wpa_s
, MSG_DEBUG
, "FT: Received FT Action Response: STA "
2473 MACSTR
" TargetAP " MACSTR
" status %u",
2474 MAC2STR(sta_addr
), MAC2STR(target_ap_addr
), status
);
2476 if (os_memcmp(sta_addr
, wpa_s
->own_addr
, ETH_ALEN
) != 0) {
2477 wpa_dbg(wpa_s
, MSG_DEBUG
, "FT: Foreign STA Address " MACSTR
2478 " in FT Action Response", MAC2STR(sta_addr
));
2483 wpa_dbg(wpa_s
, MSG_DEBUG
, "FT: FT Action Response indicates "
2484 "failure (status code %d)", status
);
2485 /* TODO: report error to FT code(?) */
2489 if (wpa_ft_process_response(wpa_s
->wpa
, data
+ 1 + 2 * ETH_ALEN
+ 2,
2490 len
- (1 + 2 * ETH_ALEN
+ 2), 1,
2491 target_ap_addr
, NULL
, 0) < 0)
2496 struct wpa_bss
*bss
;
2497 bss
= wpa_bss_get_bssid(wpa_s
, target_ap_addr
);
2499 wpa_s
->sme
.freq
= bss
->freq
;
2500 wpa_s
->sme
.auth_alg
= WPA_AUTH_ALG_FT
;
2501 sme_associate(wpa_s
, WPAS_MODE_INFRA
, target_ap_addr
,
2504 #endif /* CONFIG_SME */
2506 #endif /* CONFIG_IEEE80211R */
2509 static void wpa_supplicant_event_unprot_deauth(struct wpa_supplicant
*wpa_s
,
2510 struct unprot_deauth
*e
)
2512 #ifdef CONFIG_IEEE80211W
2513 wpa_printf(MSG_DEBUG
, "Unprotected Deauthentication frame "
2514 "dropped: " MACSTR
" -> " MACSTR
2515 " (reason code %u)",
2516 MAC2STR(e
->sa
), MAC2STR(e
->da
), e
->reason_code
);
2517 sme_event_unprot_disconnect(wpa_s
, e
->sa
, e
->da
, e
->reason_code
);
2518 #endif /* CONFIG_IEEE80211W */
2522 static void wpa_supplicant_event_unprot_disassoc(struct wpa_supplicant
*wpa_s
,
2523 struct unprot_disassoc
*e
)
2525 #ifdef CONFIG_IEEE80211W
2526 wpa_printf(MSG_DEBUG
, "Unprotected Disassociation frame "
2527 "dropped: " MACSTR
" -> " MACSTR
2528 " (reason code %u)",
2529 MAC2STR(e
->sa
), MAC2STR(e
->da
), e
->reason_code
);
2530 sme_event_unprot_disconnect(wpa_s
, e
->sa
, e
->da
, e
->reason_code
);
2531 #endif /* CONFIG_IEEE80211W */
2535 static void wpas_event_disconnect(struct wpa_supplicant
*wpa_s
, const u8
*addr
,
2536 u16 reason_code
, int locally_generated
,
2537 const u8
*ie
, size_t ie_len
, int deauth
)
2540 if (wpa_s
->ap_iface
&& addr
) {
2541 hostapd_notif_disassoc(wpa_s
->ap_iface
->bss
[0], addr
);
2545 if (wpa_s
->ap_iface
) {
2546 wpa_dbg(wpa_s
, MSG_DEBUG
, "Ignore deauth event in AP mode");
2549 #endif /* CONFIG_AP */
2551 wpa_supplicant_event_disassoc(wpa_s
, reason_code
, locally_generated
);
2553 if (reason_code
== WLAN_REASON_IEEE_802_1X_AUTH_FAILED
||
2554 ((wpa_key_mgmt_wpa_ieee8021x(wpa_s
->key_mgmt
) ||
2555 (wpa_s
->key_mgmt
& WPA_KEY_MGMT_IEEE8021X_NO_WPA
)) &&
2556 eapol_sm_failed(wpa_s
->eapol
)))
2557 wpas_auth_failed(wpa_s
);
2560 if (deauth
&& reason_code
> 0) {
2561 if (wpas_p2p_deauth_notif(wpa_s
, addr
, reason_code
, ie
, ie_len
,
2562 locally_generated
) > 0) {
2564 * The interface was removed, so cannot continue
2565 * processing any additional operations after this.
2570 #endif /* CONFIG_P2P */
2572 wpa_supplicant_event_disassoc_finish(wpa_s
, reason_code
,
2577 static void wpas_event_disassoc(struct wpa_supplicant
*wpa_s
,
2578 struct disassoc_info
*info
)
2580 u16 reason_code
= 0;
2581 int locally_generated
= 0;
2582 const u8
*addr
= NULL
;
2583 const u8
*ie
= NULL
;
2586 wpa_dbg(wpa_s
, MSG_DEBUG
, "Disassociation notification");
2591 ie_len
= info
->ie_len
;
2592 reason_code
= info
->reason_code
;
2593 locally_generated
= info
->locally_generated
;
2594 wpa_dbg(wpa_s
, MSG_DEBUG
, " * reason %u%s", reason_code
,
2595 locally_generated
? " (locally generated)" : "");
2597 wpa_dbg(wpa_s
, MSG_DEBUG
, " * address " MACSTR
,
2599 wpa_hexdump(MSG_DEBUG
, "Disassociation frame IE(s)",
2604 if (wpa_s
->ap_iface
&& info
&& info
->addr
) {
2605 hostapd_notif_disassoc(wpa_s
->ap_iface
->bss
[0], info
->addr
);
2609 if (wpa_s
->ap_iface
) {
2610 wpa_dbg(wpa_s
, MSG_DEBUG
, "Ignore disassoc event in AP mode");
2613 #endif /* CONFIG_AP */
2617 wpas_p2p_disassoc_notif(
2618 wpa_s
, info
->addr
, reason_code
, info
->ie
, info
->ie_len
,
2621 #endif /* CONFIG_P2P */
2623 if (wpa_s
->drv_flags
& WPA_DRIVER_FLAGS_SME
)
2624 sme_event_disassoc(wpa_s
, info
);
2626 wpas_event_disconnect(wpa_s
, addr
, reason_code
, locally_generated
,
2631 static void wpas_event_deauth(struct wpa_supplicant
*wpa_s
,
2632 struct deauth_info
*info
)
2634 u16 reason_code
= 0;
2635 int locally_generated
= 0;
2636 const u8
*addr
= NULL
;
2637 const u8
*ie
= NULL
;
2640 wpa_dbg(wpa_s
, MSG_DEBUG
, "Deauthentication notification");
2645 ie_len
= info
->ie_len
;
2646 reason_code
= info
->reason_code
;
2647 locally_generated
= info
->locally_generated
;
2648 wpa_dbg(wpa_s
, MSG_DEBUG
, " * reason %u%s",
2650 locally_generated
? " (locally generated)" : "");
2652 wpa_dbg(wpa_s
, MSG_DEBUG
, " * address " MACSTR
,
2655 wpa_hexdump(MSG_DEBUG
, "Deauthentication frame IE(s)",
2659 wpa_reset_ft_completed(wpa_s
->wpa
);
2661 wpas_event_disconnect(wpa_s
, addr
, reason_code
,
2662 locally_generated
, ie
, ie_len
, 1);
2666 static void wpa_supplicant_update_channel_list(struct wpa_supplicant
*wpa_s
)
2668 const char *rn
, *rn2
;
2669 struct wpa_supplicant
*ifs
;
2671 if (wpa_s
->drv_priv
== NULL
)
2672 return; /* Ignore event during drv initialization */
2674 free_hw_features(wpa_s
);
2675 wpa_s
->hw
.modes
= wpa_drv_get_hw_feature_data(
2676 wpa_s
, &wpa_s
->hw
.num_modes
, &wpa_s
->hw
.flags
);
2679 wpas_p2p_update_channel_list(wpa_s
);
2680 #endif /* CONFIG_P2P */
2683 * Check other interfaces to see if they have the same radio-name. If
2684 * so, they get updated with this same hw mode info.
2686 if (!wpa_s
->driver
->get_radio_name
)
2689 rn
= wpa_s
->driver
->get_radio_name(wpa_s
->drv_priv
);
2690 if (rn
== NULL
|| rn
[0] == '\0')
2693 wpa_dbg(wpa_s
, MSG_DEBUG
, "Checking for other virtual interfaces "
2694 "sharing same radio (%s) in event_channel_list_change", rn
);
2696 for (ifs
= wpa_s
->global
->ifaces
; ifs
; ifs
= ifs
->next
) {
2697 if (ifs
== wpa_s
|| !ifs
->driver
->get_radio_name
)
2700 rn2
= ifs
->driver
->get_radio_name(ifs
->drv_priv
);
2701 if (rn2
&& os_strcmp(rn
, rn2
) == 0) {
2702 wpa_printf(MSG_DEBUG
, "%s: Updating hw mode",
2704 free_hw_features(ifs
);
2705 ifs
->hw
.modes
= wpa_drv_get_hw_feature_data(
2706 ifs
, &ifs
->hw
.num_modes
, &ifs
->hw
.flags
);
2712 void wpa_supplicant_event(void *ctx
, enum wpa_event_type event
,
2713 union wpa_event_data
*data
)
2715 struct wpa_supplicant
*wpa_s
= ctx
;
2717 if (wpa_s
->wpa_state
== WPA_INTERFACE_DISABLED
&&
2718 event
!= EVENT_INTERFACE_ENABLED
&&
2719 event
!= EVENT_INTERFACE_STATUS
&&
2720 event
!= EVENT_SCHED_SCAN_STOPPED
) {
2721 wpa_dbg(wpa_s
, MSG_DEBUG
,
2722 "Ignore event %s (%d) while interface is disabled",
2723 event_to_string(event
), event
);
2727 #ifndef CONFIG_NO_STDOUT_DEBUG
2729 int level
= MSG_DEBUG
;
2731 if (event
== EVENT_RX_MGMT
&& data
->rx_mgmt
.frame_len
>= 24) {
2732 const struct ieee80211_hdr
*hdr
;
2734 hdr
= (const struct ieee80211_hdr
*) data
->rx_mgmt
.frame
;
2735 fc
= le_to_host16(hdr
->frame_control
);
2736 if (WLAN_FC_GET_TYPE(fc
) == WLAN_FC_TYPE_MGMT
&&
2737 WLAN_FC_GET_STYPE(fc
) == WLAN_FC_STYPE_BEACON
)
2738 level
= MSG_EXCESSIVE
;
2741 wpa_dbg(wpa_s
, level
, "Event %s (%d) received",
2742 event_to_string(event
), event
);
2744 #endif /* CONFIG_NO_STDOUT_DEBUG */
2748 sme_event_auth(wpa_s
, data
);
2751 wpa_supplicant_event_assoc(wpa_s
, data
);
2753 case EVENT_DISASSOC
:
2754 wpas_event_disassoc(wpa_s
,
2755 data
? &data
->disassoc_info
: NULL
);
2758 wpas_event_deauth(wpa_s
,
2759 data
? &data
->deauth_info
: NULL
);
2761 case EVENT_MICHAEL_MIC_FAILURE
:
2762 wpa_supplicant_event_michael_mic_failure(wpa_s
, data
);
2764 #ifndef CONFIG_NO_SCAN_PROCESSING
2765 case EVENT_SCAN_RESULTS
:
2766 wpa_supplicant_event_scan_results(wpa_s
, data
);
2767 if (wpa_s
->wpa_state
!= WPA_AUTHENTICATING
&&
2768 wpa_s
->wpa_state
!= WPA_ASSOCIATING
)
2769 wpas_p2p_continue_after_scan(wpa_s
);
2771 #endif /* CONFIG_NO_SCAN_PROCESSING */
2772 case EVENT_ASSOCINFO
:
2773 wpa_supplicant_event_associnfo(wpa_s
, data
);
2775 case EVENT_INTERFACE_STATUS
:
2776 wpa_supplicant_event_interface_status(wpa_s
, data
);
2778 case EVENT_PMKID_CANDIDATE
:
2779 wpa_supplicant_event_pmkid_candidate(wpa_s
, data
);
2781 #ifdef CONFIG_PEERKEY
2782 case EVENT_STKSTART
:
2783 wpa_supplicant_event_stkstart(wpa_s
, data
);
2785 #endif /* CONFIG_PEERKEY */
2788 wpa_supplicant_event_tdls(wpa_s
, data
);
2790 #endif /* CONFIG_TDLS */
2793 wpa_supplicant_event_wnm(wpa_s
, data
);
2795 #endif /* CONFIG_WNM */
2796 #ifdef CONFIG_IEEE80211R
2797 case EVENT_FT_RESPONSE
:
2798 wpa_supplicant_event_ft_response(wpa_s
, data
);
2800 #endif /* CONFIG_IEEE80211R */
2801 #ifdef CONFIG_IBSS_RSN
2802 case EVENT_IBSS_RSN_START
:
2803 wpa_supplicant_event_ibss_rsn_start(wpa_s
, data
);
2805 #endif /* CONFIG_IBSS_RSN */
2806 case EVENT_ASSOC_REJECT
:
2807 if (data
->assoc_reject
.bssid
)
2808 wpa_msg(wpa_s
, MSG_INFO
, WPA_EVENT_ASSOC_REJECT
2809 "bssid=" MACSTR
" status_code=%u",
2810 MAC2STR(data
->assoc_reject
.bssid
),
2811 data
->assoc_reject
.status_code
);
2813 wpa_msg(wpa_s
, MSG_INFO
, WPA_EVENT_ASSOC_REJECT
2815 data
->assoc_reject
.status_code
);
2816 if (wpa_s
->drv_flags
& WPA_DRIVER_FLAGS_SME
)
2817 sme_event_assoc_reject(wpa_s
, data
);
2819 const u8
*bssid
= data
->assoc_reject
.bssid
;
2820 if (bssid
== NULL
|| is_zero_ether_addr(bssid
))
2821 bssid
= wpa_s
->pending_bssid
;
2822 wpas_connection_failed(wpa_s
, bssid
);
2823 wpa_supplicant_mark_disassoc(wpa_s
);
2826 case EVENT_AUTH_TIMED_OUT
:
2827 if (wpa_s
->drv_flags
& WPA_DRIVER_FLAGS_SME
)
2828 sme_event_auth_timed_out(wpa_s
, data
);
2830 case EVENT_ASSOC_TIMED_OUT
:
2831 if (wpa_s
->drv_flags
& WPA_DRIVER_FLAGS_SME
)
2832 sme_event_assoc_timed_out(wpa_s
, data
);
2834 case EVENT_TX_STATUS
:
2835 wpa_dbg(wpa_s
, MSG_DEBUG
, "EVENT_TX_STATUS dst=" MACSTR
2836 " type=%d stype=%d",
2837 MAC2STR(data
->tx_status
.dst
),
2838 data
->tx_status
.type
, data
->tx_status
.stype
);
2840 if (wpa_s
->ap_iface
== NULL
) {
2841 #ifdef CONFIG_OFFCHANNEL
2842 if (data
->tx_status
.type
== WLAN_FC_TYPE_MGMT
&&
2843 data
->tx_status
.stype
== WLAN_FC_STYPE_ACTION
)
2844 offchannel_send_action_tx_status(
2845 wpa_s
, data
->tx_status
.dst
,
2846 data
->tx_status
.data
,
2847 data
->tx_status
.data_len
,
2848 data
->tx_status
.ack
?
2849 OFFCHANNEL_SEND_ACTION_SUCCESS
:
2850 OFFCHANNEL_SEND_ACTION_NO_ACK
);
2851 #endif /* CONFIG_OFFCHANNEL */
2854 #endif /* CONFIG_AP */
2855 #ifdef CONFIG_OFFCHANNEL
2856 wpa_dbg(wpa_s
, MSG_DEBUG
, "EVENT_TX_STATUS pending_dst="
2857 MACSTR
, MAC2STR(wpa_s
->parent
->pending_action_dst
));
2859 * Catch TX status events for Action frames we sent via group
2860 * interface in GO mode.
2862 if (data
->tx_status
.type
== WLAN_FC_TYPE_MGMT
&&
2863 data
->tx_status
.stype
== WLAN_FC_STYPE_ACTION
&&
2864 os_memcmp(wpa_s
->parent
->pending_action_dst
,
2865 data
->tx_status
.dst
, ETH_ALEN
) == 0) {
2866 offchannel_send_action_tx_status(
2867 wpa_s
->parent
, data
->tx_status
.dst
,
2868 data
->tx_status
.data
,
2869 data
->tx_status
.data_len
,
2870 data
->tx_status
.ack
?
2871 OFFCHANNEL_SEND_ACTION_SUCCESS
:
2872 OFFCHANNEL_SEND_ACTION_NO_ACK
);
2875 #endif /* CONFIG_OFFCHANNEL */
2877 switch (data
->tx_status
.type
) {
2878 case WLAN_FC_TYPE_MGMT
:
2879 ap_mgmt_tx_cb(wpa_s
, data
->tx_status
.data
,
2880 data
->tx_status
.data_len
,
2881 data
->tx_status
.stype
,
2882 data
->tx_status
.ack
);
2884 case WLAN_FC_TYPE_DATA
:
2885 ap_tx_status(wpa_s
, data
->tx_status
.dst
,
2886 data
->tx_status
.data
,
2887 data
->tx_status
.data_len
,
2888 data
->tx_status
.ack
);
2891 #endif /* CONFIG_AP */
2894 case EVENT_EAPOL_TX_STATUS
:
2895 ap_eapol_tx_status(wpa_s
, data
->eapol_tx_status
.dst
,
2896 data
->eapol_tx_status
.data
,
2897 data
->eapol_tx_status
.data_len
,
2898 data
->eapol_tx_status
.ack
);
2900 case EVENT_DRIVER_CLIENT_POLL_OK
:
2901 ap_client_poll_ok(wpa_s
, data
->client_poll
.addr
);
2903 case EVENT_RX_FROM_UNKNOWN
:
2904 if (wpa_s
->ap_iface
== NULL
)
2906 ap_rx_from_unknown_sta(wpa_s
, data
->rx_from_unknown
.addr
,
2907 data
->rx_from_unknown
.wds
);
2909 case EVENT_CH_SWITCH
:
2912 if (!wpa_s
->ap_iface
) {
2913 wpa_dbg(wpa_s
, MSG_DEBUG
, "AP: Ignore channel switch "
2914 "event in non-AP mode");
2918 wpas_ap_ch_switch(wpa_s
, data
->ch_switch
.freq
,
2919 data
->ch_switch
.ht_enabled
,
2920 data
->ch_switch
.ch_offset
);
2922 #endif /* CONFIG_AP */
2923 #if defined(CONFIG_AP) || defined(CONFIG_IBSS_RSN)
2924 case EVENT_RX_MGMT
: {
2926 const struct ieee80211_mgmt
*mgmt
;
2928 mgmt
= (const struct ieee80211_mgmt
*)
2929 data
->rx_mgmt
.frame
;
2930 fc
= le_to_host16(mgmt
->frame_control
);
2931 stype
= WLAN_FC_GET_STYPE(fc
);
2934 if (wpa_s
->ap_iface
== NULL
) {
2935 #endif /* CONFIG_AP */
2937 if (stype
== WLAN_FC_STYPE_PROBE_REQ
&&
2938 data
->rx_mgmt
.frame_len
> 24) {
2939 const u8
*src
= mgmt
->sa
;
2940 const u8
*ie
= mgmt
->u
.probe_req
.variable
;
2941 size_t ie_len
= data
->rx_mgmt
.frame_len
-
2942 (mgmt
->u
.probe_req
.variable
-
2943 data
->rx_mgmt
.frame
);
2944 wpas_p2p_probe_req_rx(
2945 wpa_s
, src
, mgmt
->da
,
2946 mgmt
->bssid
, ie
, ie_len
,
2947 data
->rx_mgmt
.ssi_signal
);
2950 #endif /* CONFIG_P2P */
2951 #ifdef CONFIG_IBSS_RSN
2952 if (stype
== WLAN_FC_STYPE_AUTH
&&
2953 data
->rx_mgmt
.frame_len
>= 30) {
2954 wpa_supplicant_event_ibss_auth(wpa_s
, data
);
2957 #endif /* CONFIG_IBSS_RSN */
2958 wpa_dbg(wpa_s
, MSG_DEBUG
, "AP: ignore received "
2959 "management frame in non-AP mode");
2964 if (stype
== WLAN_FC_STYPE_PROBE_REQ
&&
2965 data
->rx_mgmt
.frame_len
> 24) {
2966 const u8
*ie
= mgmt
->u
.probe_req
.variable
;
2967 size_t ie_len
= data
->rx_mgmt
.frame_len
-
2968 (mgmt
->u
.probe_req
.variable
-
2969 data
->rx_mgmt
.frame
);
2971 wpas_notify_preq(wpa_s
, mgmt
->sa
, mgmt
->da
,
2972 mgmt
->bssid
, ie
, ie_len
,
2973 data
->rx_mgmt
.ssi_signal
);
2976 ap_mgmt_rx(wpa_s
, &data
->rx_mgmt
);
2977 #endif /* CONFIG_AP */
2980 #endif /* CONFIG_AP || CONFIG_IBSS_RSN */
2981 case EVENT_RX_ACTION
:
2982 wpa_dbg(wpa_s
, MSG_DEBUG
, "Received Action frame: SA=" MACSTR
2983 " Category=%u DataLen=%d freq=%d MHz",
2984 MAC2STR(data
->rx_action
.sa
),
2985 data
->rx_action
.category
, (int) data
->rx_action
.len
,
2986 data
->rx_action
.freq
);
2987 #ifdef CONFIG_IEEE80211R
2988 if (data
->rx_action
.category
== WLAN_ACTION_FT
) {
2989 ft_rx_action(wpa_s
, data
->rx_action
.data
,
2990 data
->rx_action
.len
);
2993 #endif /* CONFIG_IEEE80211R */
2994 #ifdef CONFIG_IEEE80211W
2996 if (data
->rx_action
.category
== WLAN_ACTION_SA_QUERY
) {
2997 sme_sa_query_rx(wpa_s
, data
->rx_action
.sa
,
2998 data
->rx_action
.data
,
2999 data
->rx_action
.len
);
3002 #endif /* CONFIG_SME */
3003 #endif /* CONFIG_IEEE80211W */
3005 if (data
->rx_action
.category
== WLAN_ACTION_WNM
) {
3006 ieee802_11_rx_wnm_action(wpa_s
, &data
->rx_action
);
3009 #endif /* CONFIG_WNM */
3011 if (data
->rx_action
.category
== WLAN_ACTION_PUBLIC
&&
3012 gas_query_rx(wpa_s
->gas
, data
->rx_action
.da
,
3013 data
->rx_action
.sa
, data
->rx_action
.bssid
,
3014 data
->rx_action
.data
, data
->rx_action
.len
,
3015 data
->rx_action
.freq
) == 0)
3017 #endif /* CONFIG_GAS */
3019 if (data
->rx_action
.category
== WLAN_ACTION_PUBLIC
&&
3020 data
->rx_action
.len
>= 4 &&
3021 data
->rx_action
.data
[0] == WLAN_TDLS_DISCOVERY_RESPONSE
) {
3022 wpa_dbg(wpa_s
, MSG_DEBUG
, "TDLS: Received Discovery "
3023 "Response from " MACSTR
,
3024 MAC2STR(data
->rx_action
.sa
));
3027 #endif /* CONFIG_TDLS */
3028 #ifdef CONFIG_INTERWORKING
3029 if (data
->rx_action
.category
== WLAN_ACTION_QOS
&&
3030 data
->rx_action
.len
>= 1 &&
3031 data
->rx_action
.data
[0] == QOS_QOS_MAP_CONFIG
) {
3032 wpa_dbg(wpa_s
, MSG_DEBUG
, "Interworking: Received QoS Map Configure frame from "
3033 MACSTR
, MAC2STR(data
->rx_action
.sa
));
3034 if (os_memcmp(data
->rx_action
.sa
, wpa_s
->bssid
, ETH_ALEN
)
3036 wpas_qos_map_set(wpa_s
, data
->rx_action
.data
+ 1,
3037 data
->rx_action
.len
- 1);
3040 #endif /* CONFIG_INTERWORKING */
3042 wpas_p2p_rx_action(wpa_s
, data
->rx_action
.da
,
3044 data
->rx_action
.bssid
,
3045 data
->rx_action
.category
,
3046 data
->rx_action
.data
,
3047 data
->rx_action
.len
, data
->rx_action
.freq
);
3048 #endif /* CONFIG_P2P */
3050 case EVENT_RX_PROBE_REQ
:
3051 if (data
->rx_probe_req
.sa
== NULL
||
3052 data
->rx_probe_req
.ie
== NULL
)
3055 if (wpa_s
->ap_iface
) {
3056 hostapd_probe_req_rx(wpa_s
->ap_iface
->bss
[0],
3057 data
->rx_probe_req
.sa
,
3058 data
->rx_probe_req
.da
,
3059 data
->rx_probe_req
.bssid
,
3060 data
->rx_probe_req
.ie
,
3061 data
->rx_probe_req
.ie_len
,
3062 data
->rx_probe_req
.ssi_signal
);
3065 #endif /* CONFIG_AP */
3067 wpas_p2p_probe_req_rx(wpa_s
, data
->rx_probe_req
.sa
,
3068 data
->rx_probe_req
.da
,
3069 data
->rx_probe_req
.bssid
,
3070 data
->rx_probe_req
.ie
,
3071 data
->rx_probe_req
.ie_len
,
3072 data
->rx_probe_req
.ssi_signal
);
3073 #endif /* CONFIG_P2P */
3075 case EVENT_REMAIN_ON_CHANNEL
:
3076 #ifdef CONFIG_OFFCHANNEL
3077 offchannel_remain_on_channel_cb(
3078 wpa_s
, data
->remain_on_channel
.freq
,
3079 data
->remain_on_channel
.duration
);
3080 #endif /* CONFIG_OFFCHANNEL */
3082 wpas_p2p_remain_on_channel_cb(
3083 wpa_s
, data
->remain_on_channel
.freq
,
3084 data
->remain_on_channel
.duration
);
3085 #endif /* CONFIG_P2P */
3087 case EVENT_CANCEL_REMAIN_ON_CHANNEL
:
3088 #ifdef CONFIG_OFFCHANNEL
3089 offchannel_cancel_remain_on_channel_cb(
3090 wpa_s
, data
->remain_on_channel
.freq
);
3091 #endif /* CONFIG_OFFCHANNEL */
3093 wpas_p2p_cancel_remain_on_channel_cb(
3094 wpa_s
, data
->remain_on_channel
.freq
);
3095 #endif /* CONFIG_P2P */
3098 case EVENT_P2P_DEV_FOUND
: {
3099 struct p2p_peer_info peer_info
;
3101 os_memset(&peer_info
, 0, sizeof(peer_info
));
3102 if (data
->p2p_dev_found
.dev_addr
)
3103 os_memcpy(peer_info
.p2p_device_addr
,
3104 data
->p2p_dev_found
.dev_addr
, ETH_ALEN
);
3105 if (data
->p2p_dev_found
.pri_dev_type
)
3106 os_memcpy(peer_info
.pri_dev_type
,
3107 data
->p2p_dev_found
.pri_dev_type
,
3108 sizeof(peer_info
.pri_dev_type
));
3109 if (data
->p2p_dev_found
.dev_name
)
3110 os_strlcpy(peer_info
.device_name
,
3111 data
->p2p_dev_found
.dev_name
,
3112 sizeof(peer_info
.device_name
));
3113 peer_info
.config_methods
= data
->p2p_dev_found
.config_methods
;
3114 peer_info
.dev_capab
= data
->p2p_dev_found
.dev_capab
;
3115 peer_info
.group_capab
= data
->p2p_dev_found
.group_capab
;
3118 * FIX: new_device=1 is not necessarily correct. We should
3119 * maintain a P2P peer database in wpa_supplicant and update
3120 * this information based on whether the peer is truly new.
3122 wpas_dev_found(wpa_s
, data
->p2p_dev_found
.addr
, &peer_info
, 1);
3125 case EVENT_P2P_GO_NEG_REQ_RX
:
3126 wpas_go_neg_req_rx(wpa_s
, data
->p2p_go_neg_req_rx
.src
,
3127 data
->p2p_go_neg_req_rx
.dev_passwd_id
);
3129 case EVENT_P2P_GO_NEG_COMPLETED
:
3130 wpas_go_neg_completed(wpa_s
, data
->p2p_go_neg_completed
.res
);
3132 case EVENT_P2P_PROV_DISC_REQUEST
:
3133 wpas_prov_disc_req(wpa_s
, data
->p2p_prov_disc_req
.peer
,
3134 data
->p2p_prov_disc_req
.config_methods
,
3135 data
->p2p_prov_disc_req
.dev_addr
,
3136 data
->p2p_prov_disc_req
.pri_dev_type
,
3137 data
->p2p_prov_disc_req
.dev_name
,
3138 data
->p2p_prov_disc_req
.supp_config_methods
,
3139 data
->p2p_prov_disc_req
.dev_capab
,
3140 data
->p2p_prov_disc_req
.group_capab
,
3143 case EVENT_P2P_PROV_DISC_RESPONSE
:
3144 wpas_prov_disc_resp(wpa_s
, data
->p2p_prov_disc_resp
.peer
,
3145 data
->p2p_prov_disc_resp
.config_methods
);
3147 case EVENT_P2P_SD_REQUEST
:
3148 wpas_sd_request(wpa_s
, data
->p2p_sd_req
.freq
,
3149 data
->p2p_sd_req
.sa
,
3150 data
->p2p_sd_req
.dialog_token
,
3151 data
->p2p_sd_req
.update_indic
,
3152 data
->p2p_sd_req
.tlvs
,
3153 data
->p2p_sd_req
.tlvs_len
);
3155 case EVENT_P2P_SD_RESPONSE
:
3156 wpas_sd_response(wpa_s
, data
->p2p_sd_resp
.sa
,
3157 data
->p2p_sd_resp
.update_indic
,
3158 data
->p2p_sd_resp
.tlvs
,
3159 data
->p2p_sd_resp
.tlvs_len
);
3161 #endif /* CONFIG_P2P */
3162 case EVENT_EAPOL_RX
:
3163 wpa_supplicant_rx_eapol(wpa_s
, data
->eapol_rx
.src
,
3164 data
->eapol_rx
.data
,
3165 data
->eapol_rx
.data_len
);
3167 case EVENT_SIGNAL_CHANGE
:
3168 bgscan_notify_signal_change(
3169 wpa_s
, data
->signal_change
.above_threshold
,
3170 data
->signal_change
.current_signal
,
3171 data
->signal_change
.current_noise
,
3172 data
->signal_change
.current_txrate
);
3174 case EVENT_INTERFACE_ENABLED
:
3175 wpa_dbg(wpa_s
, MSG_DEBUG
, "Interface was enabled");
3176 if (wpa_s
->wpa_state
== WPA_INTERFACE_DISABLED
) {
3177 wpa_supplicant_update_mac_addr(wpa_s
);
3179 if (!wpa_s
->ap_iface
) {
3180 wpa_supplicant_set_state(wpa_s
,
3182 wpa_supplicant_req_scan(wpa_s
, 0, 0);
3184 wpa_supplicant_set_state(wpa_s
,
3186 #else /* CONFIG_AP */
3187 wpa_supplicant_set_state(wpa_s
, WPA_DISCONNECTED
);
3188 wpa_supplicant_req_scan(wpa_s
, 0, 0);
3189 #endif /* CONFIG_AP */
3192 case EVENT_INTERFACE_DISABLED
:
3193 wpa_dbg(wpa_s
, MSG_DEBUG
, "Interface was disabled");
3194 wpa_supplicant_mark_disassoc(wpa_s
);
3195 wpa_supplicant_set_state(wpa_s
, WPA_INTERFACE_DISABLED
);
3197 case EVENT_CHANNEL_LIST_CHANGED
:
3198 wpa_supplicant_update_channel_list(wpa_s
);
3200 case EVENT_INTERFACE_UNAVAILABLE
:
3202 wpas_p2p_interface_unavailable(wpa_s
);
3203 #endif /* CONFIG_P2P */
3205 case EVENT_BEST_CHANNEL
:
3206 wpa_dbg(wpa_s
, MSG_DEBUG
, "Best channel event received "
3208 data
->best_chan
.freq_24
, data
->best_chan
.freq_5
,
3209 data
->best_chan
.freq_overall
);
3210 wpa_s
->best_24_freq
= data
->best_chan
.freq_24
;
3211 wpa_s
->best_5_freq
= data
->best_chan
.freq_5
;
3212 wpa_s
->best_overall_freq
= data
->best_chan
.freq_overall
;
3214 wpas_p2p_update_best_channels(wpa_s
, data
->best_chan
.freq_24
,
3215 data
->best_chan
.freq_5
,
3216 data
->best_chan
.freq_overall
);
3217 #endif /* CONFIG_P2P */
3219 case EVENT_UNPROT_DEAUTH
:
3220 wpa_supplicant_event_unprot_deauth(wpa_s
,
3221 &data
->unprot_deauth
);
3223 case EVENT_UNPROT_DISASSOC
:
3224 wpa_supplicant_event_unprot_disassoc(wpa_s
,
3225 &data
->unprot_disassoc
);
3227 case EVENT_STATION_LOW_ACK
:
3229 if (wpa_s
->ap_iface
&& data
)
3230 hostapd_event_sta_low_ack(wpa_s
->ap_iface
->bss
[0],
3231 data
->low_ack
.addr
);
3232 #endif /* CONFIG_AP */
3235 wpa_tdls_disable_link(wpa_s
->wpa
, data
->low_ack
.addr
);
3236 #endif /* CONFIG_TDLS */
3238 case EVENT_IBSS_PEER_LOST
:
3239 #ifdef CONFIG_IBSS_RSN
3240 ibss_rsn_stop(wpa_s
->ibss_rsn
, data
->ibss_peer_lost
.peer
);
3241 #endif /* CONFIG_IBSS_RSN */
3243 case EVENT_DRIVER_GTK_REKEY
:
3244 if (os_memcmp(data
->driver_gtk_rekey
.bssid
,
3245 wpa_s
->bssid
, ETH_ALEN
))
3249 wpa_sm_update_replay_ctr(wpa_s
->wpa
,
3250 data
->driver_gtk_rekey
.replay_ctr
);
3252 case EVENT_SCHED_SCAN_STOPPED
:
3253 wpa_s
->sched_scanning
= 0;
3254 wpa_supplicant_notify_scanning(wpa_s
, 0);
3256 if (wpa_s
->wpa_state
== WPA_INTERFACE_DISABLED
)
3260 * If we timed out, start a new sched scan to continue
3261 * searching for more SSIDs.
3263 if (wpa_s
->sched_scan_timed_out
)
3264 wpa_supplicant_req_sched_scan(wpa_s
);
3266 case EVENT_WPS_BUTTON_PUSHED
:
3268 wpas_wps_start_pbc(wpa_s
, NULL
, 0);
3269 #endif /* CONFIG_WPS */
3271 case EVENT_CONNECT_FAILED_REASON
:
3273 if (!wpa_s
->ap_iface
|| !data
)
3275 hostapd_event_connect_failed_reason(
3276 wpa_s
->ap_iface
->bss
[0],
3277 data
->connect_failed_reason
.addr
,
3278 data
->connect_failed_reason
.code
);
3279 #endif /* CONFIG_AP */
3282 wpa_msg(wpa_s
, MSG_INFO
, "Unknown event %d", event
);