2 * WPA Supplicant - Driver event processing
3 * Copyright (c) 2003-2017, 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"
29 #include "common/ieee802_11_defs.h"
30 #include "common/ieee802_11_common.h"
31 #include "common/gas_server.h"
32 #include "crypto/random.h"
33 #include "blacklist.h"
34 #include "wpas_glue.h"
35 #include "wps_supplicant.h"
38 #include "gas_query.h"
39 #include "p2p_supplicant.h"
45 #include "offchannel.h"
46 #include "interworking.h"
50 #include "dpp_supplicant.h"
53 #ifndef CONFIG_NO_SCAN_PROCESSING
54 static int wpas_select_network_from_last_scan(struct wpa_supplicant
*wpa_s
,
55 int new_scan
, int own_request
);
56 #endif /* CONFIG_NO_SCAN_PROCESSING */
59 int wpas_temp_disabled(struct wpa_supplicant
*wpa_s
, struct wpa_ssid
*ssid
)
61 struct os_reltime now
;
63 if (ssid
== NULL
|| ssid
->disabled_until
.sec
== 0)
67 if (ssid
->disabled_until
.sec
> now
.sec
)
68 return ssid
->disabled_until
.sec
- now
.sec
;
70 wpas_clear_temp_disabled(wpa_s
, ssid
, 0);
76 #ifndef CONFIG_NO_SCAN_PROCESSING
78 * wpas_reenabled_network_time - Time until first network is re-enabled
79 * @wpa_s: Pointer to wpa_supplicant data
80 * Returns: If all enabled networks are temporarily disabled, returns the time
81 * (in sec) until the first network is re-enabled. Otherwise returns 0.
83 * This function is used in case all enabled networks are temporarily disabled,
84 * in which case it returns the time (in sec) that the first network will be
85 * re-enabled. The function assumes that at least one network is enabled.
87 static int wpas_reenabled_network_time(struct wpa_supplicant
*wpa_s
)
89 struct wpa_ssid
*ssid
;
90 int disabled_for
, res
= 0;
92 #ifdef CONFIG_INTERWORKING
93 if (wpa_s
->conf
->auto_interworking
&& wpa_s
->conf
->interworking
&&
96 #endif /* CONFIG_INTERWORKING */
98 for (ssid
= wpa_s
->conf
->ssid
; ssid
; ssid
= ssid
->next
) {
102 disabled_for
= wpas_temp_disabled(wpa_s
, ssid
);
106 if (!res
|| disabled_for
< res
)
112 #endif /* CONFIG_NO_SCAN_PROCESSING */
115 void wpas_network_reenabled(void *eloop_ctx
, void *timeout_ctx
)
117 struct wpa_supplicant
*wpa_s
= eloop_ctx
;
119 if (wpa_s
->disconnected
|| wpa_s
->wpa_state
!= WPA_SCANNING
)
122 wpa_dbg(wpa_s
, MSG_DEBUG
,
123 "Try to associate due to network getting re-enabled");
124 if (wpa_supplicant_fast_associate(wpa_s
) != 1) {
125 wpa_supplicant_cancel_sched_scan(wpa_s
);
126 wpa_supplicant_req_scan(wpa_s
, 0, 0);
131 static struct wpa_bss
* wpa_supplicant_get_new_bss(
132 struct wpa_supplicant
*wpa_s
, const u8
*bssid
)
134 struct wpa_bss
*bss
= NULL
;
135 struct wpa_ssid
*ssid
= wpa_s
->current_ssid
;
137 if (ssid
->ssid_len
> 0)
138 bss
= wpa_bss_get(wpa_s
, bssid
, ssid
->ssid
, ssid
->ssid_len
);
140 bss
= wpa_bss_get_bssid(wpa_s
, bssid
);
146 static void wpa_supplicant_update_current_bss(struct wpa_supplicant
*wpa_s
)
148 struct wpa_bss
*bss
= wpa_supplicant_get_new_bss(wpa_s
, wpa_s
->bssid
);
151 wpa_supplicant_update_scan_results(wpa_s
);
153 /* Get the BSS from the new scan results */
154 bss
= wpa_supplicant_get_new_bss(wpa_s
, wpa_s
->bssid
);
158 wpa_s
->current_bss
= bss
;
162 static int wpa_supplicant_select_config(struct wpa_supplicant
*wpa_s
)
164 struct wpa_ssid
*ssid
, *old_ssid
;
165 u8 drv_ssid
[SSID_MAX_LEN
];
169 if (wpa_s
->conf
->ap_scan
== 1 && wpa_s
->current_ssid
) {
170 wpa_supplicant_update_current_bss(wpa_s
);
172 if (wpa_s
->current_ssid
->ssid_len
== 0)
173 return 0; /* current profile still in use */
174 res
= wpa_drv_get_ssid(wpa_s
, drv_ssid
);
176 wpa_msg(wpa_s
, MSG_INFO
,
177 "Failed to read SSID from driver");
178 return 0; /* try to use current profile */
182 if (drv_ssid_len
== wpa_s
->current_ssid
->ssid_len
&&
183 os_memcmp(drv_ssid
, wpa_s
->current_ssid
->ssid
,
185 return 0; /* current profile still in use */
187 wpa_msg(wpa_s
, MSG_DEBUG
,
188 "Driver-initiated BSS selection changed the SSID to %s",
189 wpa_ssid_txt(drv_ssid
, drv_ssid_len
));
190 /* continue selecting a new network profile */
193 wpa_dbg(wpa_s
, MSG_DEBUG
, "Select network based on association "
195 ssid
= wpa_supplicant_get_ssid(wpa_s
);
197 wpa_msg(wpa_s
, MSG_INFO
,
198 "No network configuration found for the current AP");
202 if (wpas_network_disabled(wpa_s
, ssid
)) {
203 wpa_dbg(wpa_s
, MSG_DEBUG
, "Selected network is disabled");
207 if (disallowed_bssid(wpa_s
, wpa_s
->bssid
) ||
208 disallowed_ssid(wpa_s
, ssid
->ssid
, ssid
->ssid_len
)) {
209 wpa_dbg(wpa_s
, MSG_DEBUG
, "Selected BSS is disallowed");
213 res
= wpas_temp_disabled(wpa_s
, ssid
);
215 wpa_dbg(wpa_s
, MSG_DEBUG
, "Selected network is temporarily "
216 "disabled for %d second(s)", res
);
220 wpa_dbg(wpa_s
, MSG_DEBUG
, "Network configuration found for the "
222 if (wpa_key_mgmt_wpa_any(ssid
->key_mgmt
)) {
224 size_t wpa_ie_len
= sizeof(wpa_ie
);
225 if (wpa_supplicant_set_suites(wpa_s
, NULL
, ssid
,
226 wpa_ie
, &wpa_ie_len
) < 0)
227 wpa_dbg(wpa_s
, MSG_DEBUG
, "Could not set WPA suites");
229 wpa_supplicant_set_non_wpa_policy(wpa_s
, ssid
);
232 if (wpa_s
->current_ssid
&& wpa_s
->current_ssid
!= ssid
)
233 eapol_sm_invalidate_cached_session(wpa_s
->eapol
);
234 old_ssid
= wpa_s
->current_ssid
;
235 wpa_s
->current_ssid
= ssid
;
237 wpa_supplicant_update_current_bss(wpa_s
);
239 wpa_supplicant_rsn_supp_set_config(wpa_s
, wpa_s
->current_ssid
);
240 wpa_supplicant_initiate_eapol(wpa_s
);
241 if (old_ssid
!= wpa_s
->current_ssid
)
242 wpas_notify_network_changed(wpa_s
);
248 void wpa_supplicant_stop_countermeasures(void *eloop_ctx
, void *sock_ctx
)
250 struct wpa_supplicant
*wpa_s
= eloop_ctx
;
252 if (wpa_s
->countermeasures
) {
253 wpa_s
->countermeasures
= 0;
254 wpa_drv_set_countermeasures(wpa_s
, 0);
255 wpa_msg(wpa_s
, MSG_INFO
, "WPA: TKIP countermeasures stopped");
258 * It is possible that the device is sched scanning, which means
259 * that a connection attempt will be done only when we receive
260 * scan results. However, in this case, it would be preferable
261 * to scan and connect immediately, so cancel the sched_scan and
262 * issue a regular scan flow.
264 wpa_supplicant_cancel_sched_scan(wpa_s
);
265 wpa_supplicant_req_scan(wpa_s
, 0, 0);
270 void wpa_supplicant_mark_disassoc(struct wpa_supplicant
*wpa_s
)
274 wnm_bss_keep_alive_deinit(wpa_s
);
276 #ifdef CONFIG_IBSS_RSN
277 ibss_rsn_deinit(wpa_s
->ibss_rsn
);
278 wpa_s
->ibss_rsn
= NULL
;
279 #endif /* CONFIG_IBSS_RSN */
282 wpa_supplicant_ap_deinit(wpa_s
);
283 #endif /* CONFIG_AP */
286 /* Clear possibly configured frame filters */
287 wpa_drv_configure_frame_filters(wpa_s
, 0);
288 #endif /* CONFIG_HS20 */
290 if (wpa_s
->wpa_state
== WPA_INTERFACE_DISABLED
)
293 wpa_supplicant_set_state(wpa_s
, WPA_DISCONNECTED
);
294 bssid_changed
= !is_zero_ether_addr(wpa_s
->bssid
);
295 os_memset(wpa_s
->bssid
, 0, ETH_ALEN
);
296 os_memset(wpa_s
->pending_bssid
, 0, ETH_ALEN
);
297 sme_clear_on_disassoc(wpa_s
);
298 wpa_s
->current_bss
= NULL
;
299 wpa_s
->assoc_freq
= 0;
302 wpas_notify_bssid_changed(wpa_s
);
304 eapol_sm_notify_portEnabled(wpa_s
->eapol
, FALSE
);
305 eapol_sm_notify_portValid(wpa_s
->eapol
, FALSE
);
306 if (wpa_key_mgmt_wpa_psk(wpa_s
->key_mgmt
) ||
307 wpa_s
->key_mgmt
== WPA_KEY_MGMT_OWE
||
308 wpa_s
->key_mgmt
== WPA_KEY_MGMT_DPP
)
309 eapol_sm_notify_eap_success(wpa_s
->eapol
, FALSE
);
310 wpa_s
->ap_ies_from_associnfo
= 0;
311 wpa_s
->current_ssid
= NULL
;
312 eapol_sm_notify_config(wpa_s
->eapol
, NULL
, NULL
);
315 wpas_rrm_reset(wpa_s
);
316 wpa_s
->wnmsleep_used
= 0;
320 static void wpa_find_assoc_pmkid(struct wpa_supplicant
*wpa_s
)
322 struct wpa_ie_data ie
;
326 if (wpa_sm_parse_own_wpa_ie(wpa_s
->wpa
, &ie
) < 0 ||
330 for (i
= 0; i
< ie
.num_pmkid
; i
++) {
331 pmksa_set
= pmksa_cache_set_current(wpa_s
->wpa
,
332 ie
.pmkid
+ i
* PMKID_LEN
,
333 NULL
, NULL
, 0, NULL
);
334 if (pmksa_set
== 0) {
335 eapol_sm_notify_pmkid_attempt(wpa_s
->eapol
);
340 wpa_dbg(wpa_s
, MSG_DEBUG
, "RSN: PMKID from assoc IE %sfound from "
341 "PMKSA cache", pmksa_set
== 0 ? "" : "not ");
345 static void wpa_supplicant_event_pmkid_candidate(struct wpa_supplicant
*wpa_s
,
346 union wpa_event_data
*data
)
349 wpa_dbg(wpa_s
, MSG_DEBUG
, "RSN: No data in PMKID candidate "
353 wpa_dbg(wpa_s
, MSG_DEBUG
, "RSN: PMKID candidate event - bssid=" MACSTR
354 " index=%d preauth=%d",
355 MAC2STR(data
->pmkid_candidate
.bssid
),
356 data
->pmkid_candidate
.index
,
357 data
->pmkid_candidate
.preauth
);
359 pmksa_candidate_add(wpa_s
->wpa
, data
->pmkid_candidate
.bssid
,
360 data
->pmkid_candidate
.index
,
361 data
->pmkid_candidate
.preauth
);
365 static int wpa_supplicant_dynamic_keys(struct wpa_supplicant
*wpa_s
)
367 if (wpa_s
->key_mgmt
== WPA_KEY_MGMT_NONE
||
368 wpa_s
->key_mgmt
== WPA_KEY_MGMT_WPA_NONE
)
371 #ifdef IEEE8021X_EAPOL
372 if (wpa_s
->key_mgmt
== WPA_KEY_MGMT_IEEE8021X_NO_WPA
&&
373 wpa_s
->current_ssid
&&
374 !(wpa_s
->current_ssid
->eapol_flags
&
375 (EAPOL_FLAG_REQUIRE_KEY_UNICAST
|
376 EAPOL_FLAG_REQUIRE_KEY_BROADCAST
))) {
377 /* IEEE 802.1X, but not using dynamic WEP keys (i.e., either
378 * plaintext or static WEP keys). */
381 #endif /* IEEE8021X_EAPOL */
388 * wpa_supplicant_scard_init - Initialize SIM/USIM access with PC/SC
389 * @wpa_s: pointer to wpa_supplicant data
390 * @ssid: Configuration data for the network
391 * Returns: 0 on success, -1 on failure
393 * This function is called when starting authentication with a network that is
394 * configured to use PC/SC for SIM/USIM access (EAP-SIM or EAP-AKA).
396 int wpa_supplicant_scard_init(struct wpa_supplicant
*wpa_s
,
397 struct wpa_ssid
*ssid
)
399 #ifdef IEEE8021X_EAPOL
401 int aka
= 0, sim
= 0;
403 if ((ssid
!= NULL
&& ssid
->eap
.pcsc
== NULL
) ||
404 wpa_s
->scard
!= NULL
|| wpa_s
->conf
->external_sim
)
407 if (ssid
== NULL
|| ssid
->eap
.eap_methods
== NULL
) {
411 struct eap_method_type
*eap
= ssid
->eap
.eap_methods
;
412 while (eap
->vendor
!= EAP_VENDOR_IETF
||
413 eap
->method
!= EAP_TYPE_NONE
) {
414 if (eap
->vendor
== EAP_VENDOR_IETF
) {
415 if (eap
->method
== EAP_TYPE_SIM
)
417 else if (eap
->method
== EAP_TYPE_AKA
||
418 eap
->method
== EAP_TYPE_AKA_PRIME
)
425 if (eap_peer_get_eap_method(EAP_VENDOR_IETF
, EAP_TYPE_SIM
) == NULL
)
427 if (eap_peer_get_eap_method(EAP_VENDOR_IETF
, EAP_TYPE_AKA
) == NULL
&&
428 eap_peer_get_eap_method(EAP_VENDOR_IETF
, EAP_TYPE_AKA_PRIME
) ==
433 wpa_dbg(wpa_s
, MSG_DEBUG
, "Selected network is configured to "
434 "use SIM, but neither EAP-SIM nor EAP-AKA are "
439 wpa_dbg(wpa_s
, MSG_DEBUG
, "Selected network is configured to use SIM "
440 "(sim=%d aka=%d) - initialize PCSC", sim
, aka
);
442 wpa_s
->scard
= scard_init(wpa_s
->conf
->pcsc_reader
);
443 if (wpa_s
->scard
== NULL
) {
444 wpa_msg(wpa_s
, MSG_WARNING
, "Failed to initialize SIM "
448 wpa_sm_set_scard_ctx(wpa_s
->wpa
, wpa_s
->scard
);
449 eapol_sm_register_scard_ctx(wpa_s
->eapol
, wpa_s
->scard
);
450 #endif /* PCSC_FUNCS */
451 #endif /* IEEE8021X_EAPOL */
457 #ifndef CONFIG_NO_SCAN_PROCESSING
459 static int has_wep_key(struct wpa_ssid
*ssid
)
463 for (i
= 0; i
< NUM_WEP_KEYS
; i
++) {
464 if (ssid
->wep_key_len
[i
])
472 static int wpa_supplicant_match_privacy(struct wpa_bss
*bss
,
473 struct wpa_ssid
*ssid
)
477 if (ssid
->mixed_cell
)
481 if (ssid
->key_mgmt
& WPA_KEY_MGMT_WPS
)
483 #endif /* CONFIG_WPS */
485 if (has_wep_key(ssid
))
488 #ifdef IEEE8021X_EAPOL
489 if ((ssid
->key_mgmt
& WPA_KEY_MGMT_IEEE8021X_NO_WPA
) &&
490 ssid
->eapol_flags
& (EAPOL_FLAG_REQUIRE_KEY_UNICAST
|
491 EAPOL_FLAG_REQUIRE_KEY_BROADCAST
))
493 #endif /* IEEE8021X_EAPOL */
495 if (wpa_key_mgmt_wpa(ssid
->key_mgmt
))
498 if (ssid
->key_mgmt
& WPA_KEY_MGMT_OSEN
)
501 if (bss
->caps
& IEEE80211_CAP_PRIVACY
)
507 static int wpa_supplicant_ssid_bss_match(struct wpa_supplicant
*wpa_s
,
508 struct wpa_ssid
*ssid
,
509 struct wpa_bss
*bss
, int debug_print
)
511 struct wpa_ie_data ie
;
513 const u8
*rsn_ie
, *wpa_ie
;
517 ret
= wpas_wps_ssid_bss_match(wpa_s
, ssid
, bss
);
521 /* Allow TSN if local configuration accepts WEP use without WPA/WPA2 */
522 wep_ok
= !wpa_key_mgmt_wpa(ssid
->key_mgmt
) &&
523 (((ssid
->key_mgmt
& WPA_KEY_MGMT_NONE
) &&
524 ssid
->wep_key_len
[ssid
->wep_tx_keyidx
] > 0) ||
525 (ssid
->key_mgmt
& WPA_KEY_MGMT_IEEE8021X_NO_WPA
));
527 rsn_ie
= wpa_bss_get_ie(bss
, WLAN_EID_RSN
);
528 while ((ssid
->proto
& WPA_PROTO_RSN
) && rsn_ie
) {
531 if (wpa_parse_wpa_ie(rsn_ie
, 2 + rsn_ie
[1], &ie
)) {
533 wpa_dbg(wpa_s
, MSG_DEBUG
,
534 " skip RSN IE - parse failed");
539 (ie
.group_cipher
& (WPA_CIPHER_WEP40
| WPA_CIPHER_WEP104
)))
542 wpa_dbg(wpa_s
, MSG_DEBUG
,
543 " selected based on TSN in RSN IE");
547 if (!(ie
.proto
& ssid
->proto
)) {
549 wpa_dbg(wpa_s
, MSG_DEBUG
,
550 " skip RSN IE - proto mismatch");
554 if (!(ie
.pairwise_cipher
& ssid
->pairwise_cipher
)) {
556 wpa_dbg(wpa_s
, MSG_DEBUG
,
557 " skip RSN IE - PTK cipher mismatch");
561 if (!(ie
.group_cipher
& ssid
->group_cipher
)) {
563 wpa_dbg(wpa_s
, MSG_DEBUG
,
564 " skip RSN IE - GTK cipher mismatch");
568 if (!(ie
.key_mgmt
& ssid
->key_mgmt
)) {
570 wpa_dbg(wpa_s
, MSG_DEBUG
,
571 " skip RSN IE - key mgmt mismatch");
575 #ifdef CONFIG_IEEE80211W
576 if (!(ie
.capabilities
& WPA_CAPABILITY_MFPC
) &&
577 wpas_get_ssid_pmf(wpa_s
, ssid
) ==
578 MGMT_FRAME_PROTECTION_REQUIRED
) {
580 wpa_dbg(wpa_s
, MSG_DEBUG
,
581 " skip RSN IE - no mgmt frame protection");
584 #endif /* CONFIG_IEEE80211W */
585 if ((ie
.capabilities
& WPA_CAPABILITY_MFPR
) &&
586 wpas_get_ssid_pmf(wpa_s
, ssid
) ==
587 NO_MGMT_FRAME_PROTECTION
) {
589 wpa_dbg(wpa_s
, MSG_DEBUG
,
590 " skip RSN IE - no mgmt frame protection enabled but AP requires it");
594 if (!(ie
.capabilities
& WPA_CAPABILITY_MFPC
) &&
595 wpas_mbo_get_bss_attr(bss
, MBO_ATTR_ID_AP_CAPA_IND
) &&
596 wpas_get_ssid_pmf(wpa_s
, ssid
) !=
597 NO_MGMT_FRAME_PROTECTION
) {
599 wpa_dbg(wpa_s
, MSG_DEBUG
,
600 " skip RSN IE - no mgmt frame protection enabled on MBO AP");
603 #endif /* CONFIG_MBO */
606 wpa_dbg(wpa_s
, MSG_DEBUG
,
607 " selected based on RSN IE");
611 #ifdef CONFIG_IEEE80211W
612 if (wpas_get_ssid_pmf(wpa_s
, ssid
) == MGMT_FRAME_PROTECTION_REQUIRED
) {
614 wpa_dbg(wpa_s
, MSG_DEBUG
,
615 " skip - MFP Required but network not MFP Capable");
618 #endif /* CONFIG_IEEE80211W */
620 wpa_ie
= wpa_bss_get_vendor_ie(bss
, WPA_IE_VENDOR_TYPE
);
621 while ((ssid
->proto
& WPA_PROTO_WPA
) && wpa_ie
) {
624 if (wpa_parse_wpa_ie(wpa_ie
, 2 + wpa_ie
[1], &ie
)) {
626 wpa_dbg(wpa_s
, MSG_DEBUG
,
627 " skip WPA IE - parse failed");
632 (ie
.group_cipher
& (WPA_CIPHER_WEP40
| WPA_CIPHER_WEP104
)))
635 wpa_dbg(wpa_s
, MSG_DEBUG
,
636 " selected based on TSN in WPA IE");
640 if (!(ie
.proto
& ssid
->proto
)) {
642 wpa_dbg(wpa_s
, MSG_DEBUG
,
643 " skip WPA IE - proto mismatch");
647 if (!(ie
.pairwise_cipher
& ssid
->pairwise_cipher
)) {
649 wpa_dbg(wpa_s
, MSG_DEBUG
,
650 " skip WPA IE - PTK cipher mismatch");
654 if (!(ie
.group_cipher
& ssid
->group_cipher
)) {
656 wpa_dbg(wpa_s
, MSG_DEBUG
,
657 " skip WPA IE - GTK cipher mismatch");
661 if (!(ie
.key_mgmt
& ssid
->key_mgmt
)) {
663 wpa_dbg(wpa_s
, MSG_DEBUG
,
664 " skip WPA IE - key mgmt mismatch");
669 wpa_dbg(wpa_s
, MSG_DEBUG
,
670 " selected based on WPA IE");
674 if ((ssid
->key_mgmt
& WPA_KEY_MGMT_IEEE8021X_NO_WPA
) && !wpa_ie
&&
677 wpa_dbg(wpa_s
, MSG_DEBUG
,
678 " allow for non-WPA IEEE 802.1X");
682 if ((ssid
->proto
& (WPA_PROTO_WPA
| WPA_PROTO_RSN
)) &&
683 wpa_key_mgmt_wpa(ssid
->key_mgmt
) && proto_match
== 0) {
685 wpa_dbg(wpa_s
, MSG_DEBUG
,
686 " skip - no WPA/RSN proto match");
690 if ((ssid
->key_mgmt
& WPA_KEY_MGMT_OSEN
) &&
691 wpa_bss_get_vendor_ie(bss
, OSEN_IE_VENDOR_TYPE
)) {
693 wpa_dbg(wpa_s
, MSG_DEBUG
, " allow in OSEN");
697 if (!wpa_key_mgmt_wpa(ssid
->key_mgmt
)) {
699 wpa_dbg(wpa_s
, MSG_DEBUG
, " allow in non-WPA/WPA2");
704 wpa_dbg(wpa_s
, MSG_DEBUG
,
705 " reject due to mismatch with WPA/WPA2");
711 static int freq_allowed(int *freqs
, int freq
)
718 for (i
= 0; freqs
[i
]; i
++)
719 if (freqs
[i
] == freq
)
725 static int rate_match(struct wpa_supplicant
*wpa_s
, struct wpa_bss
*bss
,
728 const struct hostapd_hw_modes
*mode
= NULL
, *modes
;
729 const u8 scan_ie
[2] = { WLAN_EID_SUPP_RATES
, WLAN_EID_EXT_SUPP_RATES
};
734 return 1; /* Cannot do matching without knowing band */
736 modes
= wpa_s
->hw
.modes
;
739 * The driver does not provide any additional information
740 * about the utilized hardware, so allow the connection attempt
746 for (i
= 0; i
< wpa_s
->hw
.num_modes
; i
++) {
747 for (j
= 0; j
< modes
[i
].num_channels
; j
++) {
748 int freq
= modes
[i
].channels
[j
].freq
;
749 if (freq
== bss
->freq
) {
751 mode
->mode
== HOSTAPD_MODE_IEEE80211G
)
752 break; /* do not allow 802.11b replace
763 for (i
= 0; i
< (int) sizeof(scan_ie
); i
++) {
764 rate_ie
= wpa_bss_get_ie(bss
, scan_ie
[i
]);
768 for (j
= 2; j
< rate_ie
[1] + 2; j
++) {
769 int flagged
= !!(rate_ie
[j
] & 0x80);
770 int r
= (rate_ie
[j
] & 0x7f) * 5;
773 * IEEE Std 802.11n-2009 7.3.2.2:
774 * The new BSS Membership selector value is encoded
775 * like a legacy basic rate, but it is not a rate and
776 * only indicates if the BSS members are required to
777 * support the mandatory features of Clause 20 [HT PHY]
778 * in order to join the BSS.
780 if (flagged
&& ((rate_ie
[j
] & 0x7f) ==
781 BSS_MEMBERSHIP_SELECTOR_HT_PHY
)) {
782 if (!ht_supported(mode
)) {
784 wpa_dbg(wpa_s
, MSG_DEBUG
,
785 " hardware does not support HT PHY");
791 /* There's also a VHT selector for 802.11ac */
792 if (flagged
&& ((rate_ie
[j
] & 0x7f) ==
793 BSS_MEMBERSHIP_SELECTOR_VHT_PHY
)) {
794 if (!vht_supported(mode
)) {
796 wpa_dbg(wpa_s
, MSG_DEBUG
,
797 " hardware does not support VHT PHY");
806 /* check for legacy basic rates */
807 for (k
= 0; k
< mode
->num_rates
; k
++) {
808 if (mode
->rates
[k
] == r
)
811 if (k
== mode
->num_rates
) {
813 * IEEE Std 802.11-2007 7.3.2.2 demands that in
814 * order to join a BSS all required rates
815 * have to be supported by the hardware.
818 wpa_dbg(wpa_s
, MSG_DEBUG
,
819 " hardware does not support required rate %d.%d Mbps (freq=%d mode==%d num_rates=%d)",
821 bss
->freq
, mode
->mode
, mode
->num_rates
);
832 * Test whether BSS is in an ESS.
833 * This is done differently in DMG (60 GHz) and non-DMG bands
835 static int bss_is_ess(struct wpa_bss
*bss
)
837 if (bss_is_dmg(bss
)) {
838 return (bss
->caps
& IEEE80211_CAP_DMG_MASK
) ==
839 IEEE80211_CAP_DMG_AP
;
842 return ((bss
->caps
& (IEEE80211_CAP_ESS
| IEEE80211_CAP_IBSS
)) ==
847 static int match_mac_mask(const u8
*addr_a
, const u8
*addr_b
, const u8
*mask
)
851 for (i
= 0; i
< ETH_ALEN
; i
++) {
852 if ((addr_a
[i
] & mask
[i
]) != (addr_b
[i
] & mask
[i
]))
859 static int addr_in_list(const u8
*addr
, const u8
*list
, size_t num
)
863 for (i
= 0; i
< num
; i
++) {
864 const u8
*a
= list
+ i
* ETH_ALEN
* 2;
865 const u8
*m
= a
+ ETH_ALEN
;
867 if (match_mac_mask(a
, addr
, m
))
874 struct wpa_ssid
* wpa_scan_res_match(struct wpa_supplicant
*wpa_s
,
875 int i
, struct wpa_bss
*bss
,
876 struct wpa_ssid
*group
,
877 int only_first_ssid
, int debug_print
)
879 u8 wpa_ie_len
, rsn_ie_len
;
881 struct wpa_blacklist
*e
;
883 struct wpa_ssid
*ssid
;
886 const u8
*assoc_disallow
;
887 #endif /* CONFIG_MBO */
889 ie
= wpa_bss_get_vendor_ie(bss
, WPA_IE_VENDOR_TYPE
);
890 wpa_ie_len
= ie
? ie
[1] : 0;
892 ie
= wpa_bss_get_ie(bss
, WLAN_EID_RSN
);
893 rsn_ie_len
= ie
? ie
[1] : 0;
895 ie
= wpa_bss_get_vendor_ie(bss
, OSEN_IE_VENDOR_TYPE
);
899 wpa_dbg(wpa_s
, MSG_DEBUG
, "%d: " MACSTR
900 " ssid='%s' wpa_ie_len=%u rsn_ie_len=%u caps=0x%x level=%d freq=%d %s%s%s",
901 i
, MAC2STR(bss
->bssid
),
902 wpa_ssid_txt(bss
->ssid
, bss
->ssid_len
),
903 wpa_ie_len
, rsn_ie_len
, bss
->caps
, bss
->level
,
905 wpa_bss_get_vendor_ie(bss
, WPS_IE_VENDOR_TYPE
) ?
907 (wpa_bss_get_vendor_ie(bss
, P2P_IE_VENDOR_TYPE
) ||
908 wpa_bss_get_vendor_ie_beacon(bss
, P2P_IE_VENDOR_TYPE
))
910 osen
? " osen=1" : "");
913 e
= wpa_blacklist_get(wpa_s
, bss
->bssid
);
916 if (wpa_supplicant_enabled_networks(wpa_s
) == 1) {
918 * When only a single network is enabled, we can
919 * trigger blacklisting on the first failure. This
920 * should not be done with multiple enabled networks to
921 * avoid getting forced to move into a worse ESS on
922 * single error if there are no other BSSes of the
927 if (e
->count
> limit
) {
929 wpa_dbg(wpa_s
, MSG_DEBUG
,
930 " skip - blacklisted (count=%d limit=%d)",
937 if (bss
->ssid_len
== 0) {
939 wpa_dbg(wpa_s
, MSG_DEBUG
, " skip - SSID not known");
943 if (disallowed_bssid(wpa_s
, bss
->bssid
)) {
945 wpa_dbg(wpa_s
, MSG_DEBUG
, " skip - BSSID disallowed");
949 if (disallowed_ssid(wpa_s
, bss
->ssid
, bss
->ssid_len
)) {
951 wpa_dbg(wpa_s
, MSG_DEBUG
, " skip - SSID disallowed");
955 wpa
= wpa_ie_len
> 0 || rsn_ie_len
> 0;
957 for (ssid
= group
; ssid
; ssid
= only_first_ssid
? NULL
: ssid
->pnext
) {
958 int check_ssid
= wpa
? 1 : (ssid
->ssid_len
!= 0);
961 if (wpas_network_disabled(wpa_s
, ssid
)) {
963 wpa_dbg(wpa_s
, MSG_DEBUG
, " skip - disabled");
967 res
= wpas_temp_disabled(wpa_s
, ssid
);
970 wpa_dbg(wpa_s
, MSG_DEBUG
,
971 " skip - disabled temporarily for %d second(s)",
977 if ((ssid
->key_mgmt
& WPA_KEY_MGMT_WPS
) && e
&& e
->count
> 0) {
979 wpa_dbg(wpa_s
, MSG_DEBUG
,
980 " skip - blacklisted (WPS)");
984 if (wpa
&& ssid
->ssid_len
== 0 &&
985 wpas_wps_ssid_wildcard_ok(wpa_s
, ssid
, bss
))
988 if (!wpa
&& (ssid
->key_mgmt
& WPA_KEY_MGMT_WPS
)) {
989 /* Only allow wildcard SSID match if an AP
990 * advertises active WPS operation that matches
993 if (ssid
->ssid_len
== 0 &&
994 wpas_wps_ssid_wildcard_ok(wpa_s
, ssid
, bss
))
997 #endif /* CONFIG_WPS */
999 if (ssid
->bssid_set
&& ssid
->ssid_len
== 0 &&
1000 os_memcmp(bss
->bssid
, ssid
->bssid
, ETH_ALEN
) == 0)
1004 (bss
->ssid_len
!= ssid
->ssid_len
||
1005 os_memcmp(bss
->ssid
, ssid
->ssid
, bss
->ssid_len
) != 0)) {
1007 wpa_dbg(wpa_s
, MSG_DEBUG
,
1008 " skip - SSID mismatch");
1012 if (ssid
->bssid_set
&&
1013 os_memcmp(bss
->bssid
, ssid
->bssid
, ETH_ALEN
) != 0) {
1015 wpa_dbg(wpa_s
, MSG_DEBUG
,
1016 " skip - BSSID mismatch");
1020 /* check blacklist */
1021 if (ssid
->num_bssid_blacklist
&&
1022 addr_in_list(bss
->bssid
, ssid
->bssid_blacklist
,
1023 ssid
->num_bssid_blacklist
)) {
1025 wpa_dbg(wpa_s
, MSG_DEBUG
,
1026 " skip - BSSID blacklisted");
1030 /* if there is a whitelist, only accept those APs */
1031 if (ssid
->num_bssid_whitelist
&&
1032 !addr_in_list(bss
->bssid
, ssid
->bssid_whitelist
,
1033 ssid
->num_bssid_whitelist
)) {
1035 wpa_dbg(wpa_s
, MSG_DEBUG
,
1036 " skip - BSSID not in whitelist");
1040 if (!wpa_supplicant_ssid_bss_match(wpa_s
, ssid
, bss
,
1044 if (!osen
&& !wpa
&&
1045 !(ssid
->key_mgmt
& WPA_KEY_MGMT_NONE
) &&
1046 !(ssid
->key_mgmt
& WPA_KEY_MGMT_WPS
) &&
1047 !(ssid
->key_mgmt
& WPA_KEY_MGMT_IEEE8021X_NO_WPA
)) {
1049 wpa_dbg(wpa_s
, MSG_DEBUG
,
1050 " skip - non-WPA network not allowed");
1054 if (wpa
&& !wpa_key_mgmt_wpa(ssid
->key_mgmt
) &&
1055 has_wep_key(ssid
)) {
1057 wpa_dbg(wpa_s
, MSG_DEBUG
,
1058 " skip - ignore WPA/WPA2 AP for WEP network block");
1062 if ((ssid
->key_mgmt
& WPA_KEY_MGMT_OSEN
) && !osen
) {
1064 wpa_dbg(wpa_s
, MSG_DEBUG
,
1065 " skip - non-OSEN network not allowed");
1069 if (!wpa_supplicant_match_privacy(bss
, ssid
)) {
1071 wpa_dbg(wpa_s
, MSG_DEBUG
,
1072 " skip - privacy mismatch");
1076 if (ssid
->mode
!= IEEE80211_MODE_MESH
&& !bss_is_ess(bss
) &&
1077 !bss_is_pbss(bss
)) {
1079 wpa_dbg(wpa_s
, MSG_DEBUG
,
1080 " skip - not ESS, PBSS, or MBSS");
1084 if (ssid
->pbss
!= 2 && ssid
->pbss
!= bss_is_pbss(bss
)) {
1086 wpa_dbg(wpa_s
, MSG_DEBUG
,
1087 " skip - PBSS mismatch (ssid %d bss %d)",
1088 ssid
->pbss
, bss_is_pbss(bss
));
1092 if (!freq_allowed(ssid
->freq_list
, bss
->freq
)) {
1094 wpa_dbg(wpa_s
, MSG_DEBUG
,
1095 " skip - frequency not allowed");
1100 if (ssid
->mode
== IEEE80211_MODE_MESH
&& ssid
->frequency
> 0 &&
1101 ssid
->frequency
!= bss
->freq
) {
1103 wpa_dbg(wpa_s
, MSG_DEBUG
,
1104 " skip - frequency not allowed (mesh)");
1107 #endif /* CONFIG_MESH */
1109 if (!rate_match(wpa_s
, bss
, debug_print
)) {
1111 wpa_dbg(wpa_s
, MSG_DEBUG
,
1112 " skip - rate sets do not match");
1116 #ifndef CONFIG_IBSS_RSN
1117 if (ssid
->mode
== WPAS_MODE_IBSS
&&
1118 !(ssid
->key_mgmt
& (WPA_KEY_MGMT_NONE
|
1119 WPA_KEY_MGMT_WPA_NONE
))) {
1121 wpa_dbg(wpa_s
, MSG_DEBUG
,
1122 " skip - IBSS RSN not supported in the build");
1125 #endif /* !CONFIG_IBSS_RSN */
1128 if (ssid
->p2p_group
&&
1129 !wpa_bss_get_vendor_ie(bss
, P2P_IE_VENDOR_TYPE
) &&
1130 !wpa_bss_get_vendor_ie_beacon(bss
, P2P_IE_VENDOR_TYPE
)) {
1132 wpa_dbg(wpa_s
, MSG_DEBUG
,
1133 " skip - no P2P IE seen");
1137 if (!is_zero_ether_addr(ssid
->go_p2p_dev_addr
)) {
1138 struct wpabuf
*p2p_ie
;
1139 u8 dev_addr
[ETH_ALEN
];
1141 ie
= wpa_bss_get_vendor_ie(bss
, P2P_IE_VENDOR_TYPE
);
1144 wpa_dbg(wpa_s
, MSG_DEBUG
,
1145 " skip - no P2P element");
1148 p2p_ie
= wpa_bss_get_vendor_ie_multi(
1149 bss
, P2P_IE_VENDOR_TYPE
);
1150 if (p2p_ie
== NULL
) {
1152 wpa_dbg(wpa_s
, MSG_DEBUG
,
1153 " skip - could not fetch P2P element");
1157 if (p2p_parse_dev_addr_in_p2p_ie(p2p_ie
, dev_addr
) < 0
1158 || os_memcmp(dev_addr
, ssid
->go_p2p_dev_addr
,
1161 wpa_dbg(wpa_s
, MSG_DEBUG
,
1162 " skip - no matching GO P2P Device Address in P2P element");
1163 wpabuf_free(p2p_ie
);
1166 wpabuf_free(p2p_ie
);
1170 * TODO: skip the AP if its P2P IE has Group Formation
1171 * bit set in the P2P Group Capability Bitmap and we
1172 * are not in Group Formation with that device.
1174 #endif /* CONFIG_P2P */
1176 if (os_reltime_before(&bss
->last_update
, &wpa_s
->scan_min_time
))
1178 struct os_reltime diff
;
1180 os_reltime_sub(&wpa_s
->scan_min_time
,
1181 &bss
->last_update
, &diff
);
1183 wpa_dbg(wpa_s
, MSG_DEBUG
,
1184 " skip - scan result not recent enough (%u.%06u seconds too old)",
1185 (unsigned int) diff
.sec
,
1186 (unsigned int) diff
.usec
);
1190 #ifdef CONFIG_TESTING_OPTIONS
1191 if (wpa_s
->ignore_assoc_disallow
)
1192 goto skip_assoc_disallow
;
1193 #endif /* CONFIG_TESTING_OPTIONS */
1194 assoc_disallow
= wpas_mbo_get_bss_attr(
1195 bss
, MBO_ATTR_ID_ASSOC_DISALLOW
);
1196 if (assoc_disallow
&& assoc_disallow
[1] >= 1) {
1198 wpa_dbg(wpa_s
, MSG_DEBUG
,
1199 " skip - MBO association disallowed (reason %u)",
1204 if (wpa_is_bss_tmp_disallowed(wpa_s
, bss
->bssid
)) {
1206 wpa_dbg(wpa_s
, MSG_DEBUG
,
1207 " skip - MBO retry delay has not passed yet");
1210 #ifdef CONFIG_TESTING_OPTIONS
1211 skip_assoc_disallow
:
1212 #endif /* CONFIG_TESTING_OPTIONS */
1213 #endif /* CONFIG_MBO */
1216 if ((ssid
->key_mgmt
& WPA_KEY_MGMT_DPP
) &&
1217 !wpa_sm_pmksa_exists(wpa_s
->wpa
, bss
->bssid
, ssid
) &&
1218 (!ssid
->dpp_connector
||
1219 !ssid
->dpp_netaccesskey
||
1220 !ssid
->dpp_csign
)) {
1222 wpa_dbg(wpa_s
, MSG_DEBUG
,
1223 " skip - no PMKSA entry for DPP");
1226 #endif /* CONFIG_DPP */
1228 /* Matching configuration found */
1232 /* No matching configuration found */
1237 static struct wpa_bss
*
1238 wpa_supplicant_select_bss(struct wpa_supplicant
*wpa_s
,
1239 struct wpa_ssid
*group
,
1240 struct wpa_ssid
**selected_ssid
,
1241 int only_first_ssid
)
1245 if (wpa_s
->current_ssid
) {
1246 struct wpa_ssid
*ssid
;
1248 wpa_dbg(wpa_s
, MSG_DEBUG
,
1249 "Scan results matching the currently selected network");
1250 for (i
= 0; i
< wpa_s
->last_scan_res_used
; i
++) {
1251 struct wpa_bss
*bss
= wpa_s
->last_scan_res
[i
];
1253 ssid
= wpa_scan_res_match(wpa_s
, i
, bss
, group
,
1254 only_first_ssid
, 0);
1255 if (ssid
!= wpa_s
->current_ssid
)
1257 wpa_dbg(wpa_s
, MSG_DEBUG
, "%u: " MACSTR
1258 " freq=%d level=%d snr=%d est_throughput=%u",
1259 i
, MAC2STR(bss
->bssid
), bss
->freq
, bss
->level
,
1260 bss
->snr
, bss
->est_throughput
);
1264 if (only_first_ssid
)
1265 wpa_dbg(wpa_s
, MSG_DEBUG
, "Try to find BSS matching pre-selected network id=%d",
1268 wpa_dbg(wpa_s
, MSG_DEBUG
, "Selecting BSS from priority group %d",
1271 for (i
= 0; i
< wpa_s
->last_scan_res_used
; i
++) {
1272 struct wpa_bss
*bss
= wpa_s
->last_scan_res
[i
];
1273 *selected_ssid
= wpa_scan_res_match(wpa_s
, i
, bss
, group
,
1274 only_first_ssid
, 1);
1275 if (!*selected_ssid
)
1277 wpa_dbg(wpa_s
, MSG_DEBUG
, " selected BSS " MACSTR
1279 MAC2STR(bss
->bssid
),
1280 wpa_ssid_txt(bss
->ssid
, bss
->ssid_len
));
1288 struct wpa_bss
* wpa_supplicant_pick_network(struct wpa_supplicant
*wpa_s
,
1289 struct wpa_ssid
**selected_ssid
)
1291 struct wpa_bss
*selected
= NULL
;
1293 struct wpa_ssid
*next_ssid
= NULL
;
1294 struct wpa_ssid
*ssid
;
1296 if (wpa_s
->last_scan_res
== NULL
||
1297 wpa_s
->last_scan_res_used
== 0)
1298 return NULL
; /* no scan results from last update */
1300 if (wpa_s
->next_ssid
) {
1301 /* check that next_ssid is still valid */
1302 for (ssid
= wpa_s
->conf
->ssid
; ssid
; ssid
= ssid
->next
) {
1303 if (ssid
== wpa_s
->next_ssid
)
1307 wpa_s
->next_ssid
= NULL
;
1310 while (selected
== NULL
) {
1311 for (prio
= 0; prio
< wpa_s
->conf
->num_prio
; prio
++) {
1312 if (next_ssid
&& next_ssid
->priority
==
1313 wpa_s
->conf
->pssid
[prio
]->priority
) {
1314 selected
= wpa_supplicant_select_bss(
1315 wpa_s
, next_ssid
, selected_ssid
, 1);
1319 selected
= wpa_supplicant_select_bss(
1320 wpa_s
, wpa_s
->conf
->pssid
[prio
],
1326 if (selected
== NULL
&& wpa_s
->blacklist
&&
1327 !wpa_s
->countermeasures
) {
1328 wpa_dbg(wpa_s
, MSG_DEBUG
, "No APs found - clear "
1329 "blacklist and try again");
1330 wpa_blacklist_clear(wpa_s
);
1331 wpa_s
->blacklist_cleared
++;
1332 } else if (selected
== NULL
)
1336 ssid
= *selected_ssid
;
1337 if (selected
&& ssid
&& ssid
->mem_only_psk
&& !ssid
->psk_set
&&
1338 !ssid
->passphrase
&& !ssid
->ext_psk
) {
1339 const char *field_name
, *txt
= NULL
;
1341 wpa_dbg(wpa_s
, MSG_DEBUG
,
1342 "PSK/passphrase not yet available for the selected network");
1344 wpas_notify_network_request(wpa_s
, ssid
,
1345 WPA_CTRL_REQ_PSK_PASSPHRASE
, NULL
);
1347 field_name
= wpa_supplicant_ctrl_req_to_string(
1348 WPA_CTRL_REQ_PSK_PASSPHRASE
, NULL
, &txt
);
1349 if (field_name
== NULL
)
1352 wpas_send_ctrl_req(wpa_s
, ssid
, field_name
, txt
);
1361 static void wpa_supplicant_req_new_scan(struct wpa_supplicant
*wpa_s
,
1362 int timeout_sec
, int timeout_usec
)
1364 if (!wpa_supplicant_enabled_networks(wpa_s
)) {
1366 * No networks are enabled; short-circuit request so
1367 * we don't wait timeout seconds before transitioning
1368 * to INACTIVE state.
1370 wpa_dbg(wpa_s
, MSG_DEBUG
, "Short-circuit new scan request "
1371 "since there are no enabled networks");
1372 wpa_supplicant_set_state(wpa_s
, WPA_INACTIVE
);
1376 wpa_s
->scan_for_connection
= 1;
1377 wpa_supplicant_req_scan(wpa_s
, timeout_sec
, timeout_usec
);
1381 int wpa_supplicant_connect(struct wpa_supplicant
*wpa_s
,
1382 struct wpa_bss
*selected
,
1383 struct wpa_ssid
*ssid
)
1385 if (wpas_wps_scan_pbc_overlap(wpa_s
, selected
, ssid
)) {
1386 wpa_msg(wpa_s
, MSG_INFO
, WPS_EVENT_OVERLAP
1387 "PBC session overlap");
1388 wpas_notify_wps_event_pbc_overlap(wpa_s
);
1390 if (wpa_s
->p2p_group_interface
== P2P_GROUP_INTERFACE_CLIENT
||
1391 wpa_s
->p2p_in_provisioning
) {
1392 eloop_register_timeout(0, 0, wpas_p2p_pbc_overlap_cb
,
1396 #endif /* CONFIG_P2P */
1399 wpas_wps_pbc_overlap(wpa_s
);
1400 wpas_wps_cancel(wpa_s
);
1401 #endif /* CONFIG_WPS */
1405 wpa_msg(wpa_s
, MSG_DEBUG
,
1406 "Considering connect request: reassociate: %d selected: "
1407 MACSTR
" bssid: " MACSTR
" pending: " MACSTR
1408 " wpa_state: %s ssid=%p current_ssid=%p",
1409 wpa_s
->reassociate
, MAC2STR(selected
->bssid
),
1410 MAC2STR(wpa_s
->bssid
), MAC2STR(wpa_s
->pending_bssid
),
1411 wpa_supplicant_state_txt(wpa_s
->wpa_state
),
1412 ssid
, wpa_s
->current_ssid
);
1415 * Do not trigger new association unless the BSSID has changed or if
1416 * reassociation is requested. If we are in process of associating with
1417 * the selected BSSID, do not trigger new attempt.
1419 if (wpa_s
->reassociate
||
1420 (os_memcmp(selected
->bssid
, wpa_s
->bssid
, ETH_ALEN
) != 0 &&
1421 ((wpa_s
->wpa_state
!= WPA_ASSOCIATING
&&
1422 wpa_s
->wpa_state
!= WPA_AUTHENTICATING
) ||
1423 (!is_zero_ether_addr(wpa_s
->pending_bssid
) &&
1424 os_memcmp(selected
->bssid
, wpa_s
->pending_bssid
, ETH_ALEN
) !=
1426 (is_zero_ether_addr(wpa_s
->pending_bssid
) &&
1427 ssid
!= wpa_s
->current_ssid
)))) {
1428 if (wpa_supplicant_scard_init(wpa_s
, ssid
)) {
1429 wpa_supplicant_req_new_scan(wpa_s
, 10, 0);
1432 wpa_msg(wpa_s
, MSG_DEBUG
, "Request association with " MACSTR
,
1433 MAC2STR(selected
->bssid
));
1434 wpa_supplicant_associate(wpa_s
, selected
, ssid
);
1436 wpa_dbg(wpa_s
, MSG_DEBUG
, "Already associated or trying to "
1437 "connect with the selected AP");
1444 static struct wpa_ssid
*
1445 wpa_supplicant_pick_new_network(struct wpa_supplicant
*wpa_s
)
1448 struct wpa_ssid
*ssid
;
1450 for (prio
= 0; prio
< wpa_s
->conf
->num_prio
; prio
++) {
1451 for (ssid
= wpa_s
->conf
->pssid
[prio
]; ssid
; ssid
= ssid
->pnext
)
1453 if (wpas_network_disabled(wpa_s
, ssid
))
1455 #ifndef CONFIG_IBSS_RSN
1456 if (ssid
->mode
== WPAS_MODE_IBSS
&&
1457 !(ssid
->key_mgmt
& (WPA_KEY_MGMT_NONE
|
1458 WPA_KEY_MGMT_WPA_NONE
))) {
1459 wpa_msg(wpa_s
, MSG_INFO
,
1460 "IBSS RSN not supported in the build - cannot use the profile for SSID '%s'",
1461 wpa_ssid_txt(ssid
->ssid
,
1465 #endif /* !CONFIG_IBSS_RSN */
1466 if (ssid
->mode
== IEEE80211_MODE_IBSS
||
1467 ssid
->mode
== IEEE80211_MODE_AP
||
1468 ssid
->mode
== IEEE80211_MODE_MESH
)
1476 /* TODO: move the rsn_preauth_scan_result*() to be called from notify.c based
1477 * on BSS added and BSS changed events */
1478 static void wpa_supplicant_rsn_preauth_scan_results(
1479 struct wpa_supplicant
*wpa_s
)
1481 struct wpa_bss
*bss
;
1483 if (rsn_preauth_scan_results(wpa_s
->wpa
) < 0)
1486 dl_list_for_each(bss
, &wpa_s
->bss
, struct wpa_bss
, list
) {
1487 const u8
*ssid
, *rsn
;
1489 ssid
= wpa_bss_get_ie(bss
, WLAN_EID_SSID
);
1493 rsn
= wpa_bss_get_ie(bss
, WLAN_EID_RSN
);
1497 rsn_preauth_scan_result(wpa_s
->wpa
, bss
->bssid
, ssid
, rsn
);
1503 static int wpa_supplicant_need_to_roam(struct wpa_supplicant
*wpa_s
,
1504 struct wpa_bss
*selected
,
1505 struct wpa_ssid
*ssid
)
1507 struct wpa_bss
*current_bss
= NULL
;
1508 #ifndef CONFIG_NO_ROAMING
1511 int cur_est
, sel_est
;
1512 #endif /* CONFIG_NO_ROAMING */
1514 if (wpa_s
->reassociate
)
1515 return 1; /* explicit request to reassociate */
1516 if (wpa_s
->wpa_state
< WPA_ASSOCIATED
)
1517 return 1; /* we are not associated; continue */
1518 if (wpa_s
->current_ssid
== NULL
)
1519 return 1; /* unknown current SSID */
1520 if (wpa_s
->current_ssid
!= ssid
)
1521 return 1; /* different network block */
1523 if (wpas_driver_bss_selection(wpa_s
))
1524 return 0; /* Driver-based roaming */
1526 if (wpa_s
->current_ssid
->ssid
)
1527 current_bss
= wpa_bss_get(wpa_s
, wpa_s
->bssid
,
1528 wpa_s
->current_ssid
->ssid
,
1529 wpa_s
->current_ssid
->ssid_len
);
1531 current_bss
= wpa_bss_get_bssid(wpa_s
, wpa_s
->bssid
);
1534 return 1; /* current BSS not seen in scan results */
1536 if (current_bss
== selected
)
1539 if (selected
->last_update_idx
> current_bss
->last_update_idx
)
1540 return 1; /* current BSS not seen in the last scan */
1542 #ifndef CONFIG_NO_ROAMING
1543 wpa_dbg(wpa_s
, MSG_DEBUG
, "Considering within-ESS reassociation");
1544 wpa_dbg(wpa_s
, MSG_DEBUG
, "Current BSS: " MACSTR
1545 " freq=%d level=%d snr=%d est_throughput=%u",
1546 MAC2STR(current_bss
->bssid
),
1547 current_bss
->freq
, current_bss
->level
,
1548 current_bss
->snr
, current_bss
->est_throughput
);
1549 wpa_dbg(wpa_s
, MSG_DEBUG
, "Selected BSS: " MACSTR
1550 " freq=%d level=%d snr=%d est_throughput=%u",
1551 MAC2STR(selected
->bssid
), selected
->freq
, selected
->level
,
1552 selected
->snr
, selected
->est_throughput
);
1554 if (wpa_s
->current_ssid
->bssid_set
&&
1555 os_memcmp(selected
->bssid
, wpa_s
->current_ssid
->bssid
, ETH_ALEN
) ==
1557 wpa_dbg(wpa_s
, MSG_DEBUG
, "Allow reassociation - selected BSS "
1558 "has preferred BSSID");
1562 if (selected
->est_throughput
> current_bss
->est_throughput
+ 5000) {
1563 wpa_dbg(wpa_s
, MSG_DEBUG
,
1564 "Allow reassociation - selected BSS has better estimated throughput");
1568 to_5ghz
= selected
->freq
> 4000 && current_bss
->freq
< 4000;
1570 if (current_bss
->level
< 0 &&
1571 current_bss
->level
> selected
->level
+ to_5ghz
* 2) {
1572 wpa_dbg(wpa_s
, MSG_DEBUG
, "Skip roam - Current BSS has better "
1577 if (current_bss
->est_throughput
> selected
->est_throughput
+ 5000) {
1578 wpa_dbg(wpa_s
, MSG_DEBUG
,
1579 "Skip roam - Current BSS has better estimated throughput");
1583 cur_est
= current_bss
->est_throughput
;
1584 sel_est
= selected
->est_throughput
;
1586 if (current_bss
->level
< 0) {
1587 if (current_bss
->level
< -85)
1589 else if (current_bss
->level
< -80)
1591 else if (current_bss
->level
< -75)
1593 else if (current_bss
->level
< -70)
1597 if (cur_est
> sel_est
* 1.5)
1599 else if (cur_est
> sel_est
* 1.2)
1601 else if (cur_est
> sel_est
* 1.1)
1603 else if (cur_est
> sel_est
)
1609 /* Make it easier to move to 5 GHz band */
1610 if (sel_est
> cur_est
* 1.5)
1612 else if (sel_est
> cur_est
* 1.2)
1614 else if (sel_est
> cur_est
* 1.1)
1617 if (min_diff
> reduce
)
1622 diff
= abs(current_bss
->level
- selected
->level
);
1623 if (diff
< min_diff
) {
1624 wpa_dbg(wpa_s
, MSG_DEBUG
,
1625 "Skip roam - too small difference in signal level (%d < %d)",
1630 wpa_dbg(wpa_s
, MSG_DEBUG
,
1631 "Allow reassociation due to difference in signal level (%d >= %d)",
1634 #else /* CONFIG_NO_ROAMING */
1636 #endif /* CONFIG_NO_ROAMING */
1641 * Return a negative value if no scan results could be fetched or if scan
1642 * results should not be shared with other virtual interfaces.
1643 * Return 0 if scan results were fetched and may be shared with other
1645 * Return 1 if scan results may be shared with other virtual interfaces but may
1646 * not trigger any operations.
1647 * Return 2 if the interface was removed and cannot be used.
1649 static int _wpa_supplicant_event_scan_results(struct wpa_supplicant
*wpa_s
,
1650 union wpa_event_data
*data
,
1651 int own_request
, int update_only
)
1653 struct wpa_scan_results
*scan_res
= NULL
;
1656 #ifndef CONFIG_NO_RANDOM_POOL
1658 #endif /* CONFIG_NO_RANDOM_POOL */
1661 if (wpa_s
->ap_iface
)
1663 #endif /* CONFIG_AP */
1665 wpa_supplicant_notify_scanning(wpa_s
, 0);
1667 scan_res
= wpa_supplicant_get_scan_results(wpa_s
,
1668 data
? &data
->scan_info
:
1670 if (scan_res
== NULL
) {
1671 if (wpa_s
->conf
->ap_scan
== 2 || ap
||
1672 wpa_s
->scan_res_handler
== scan_only_handler
)
1676 if (data
&& data
->scan_info
.external_scan
)
1678 wpa_dbg(wpa_s
, MSG_DEBUG
, "Failed to get scan results - try "
1680 wpa_supplicant_req_new_scan(wpa_s
, 1, 0);
1682 goto scan_work_done
;
1685 #ifndef CONFIG_NO_RANDOM_POOL
1686 num
= scan_res
->num
;
1689 for (i
= 0; i
< num
; i
++) {
1691 struct wpa_scan_res
*res
= scan_res
->res
[i
];
1692 buf
[0] = res
->bssid
[5];
1693 buf
[1] = res
->qual
& 0xff;
1694 buf
[2] = res
->noise
& 0xff;
1695 buf
[3] = res
->level
& 0xff;
1696 buf
[4] = res
->tsf
& 0xff;
1697 random_add_randomness(buf
, sizeof(buf
));
1699 #endif /* CONFIG_NO_RANDOM_POOL */
1703 goto scan_work_done
;
1706 if (own_request
&& wpa_s
->scan_res_handler
&&
1707 !(data
&& data
->scan_info
.external_scan
)) {
1708 void (*scan_res_handler
)(struct wpa_supplicant
*wpa_s
,
1709 struct wpa_scan_results
*scan_res
);
1711 scan_res_handler
= wpa_s
->scan_res_handler
;
1712 wpa_s
->scan_res_handler
= NULL
;
1713 scan_res_handler(wpa_s
, scan_res
);
1715 goto scan_work_done
;
1719 wpa_dbg(wpa_s
, MSG_DEBUG
, "Ignore scan results in AP mode");
1721 if (wpa_s
->ap_iface
->scan_cb
)
1722 wpa_s
->ap_iface
->scan_cb(wpa_s
->ap_iface
);
1723 #endif /* CONFIG_AP */
1724 goto scan_work_done
;
1727 wpa_dbg(wpa_s
, MSG_DEBUG
, "New scan results available (own=%u ext=%u)",
1728 wpa_s
->own_scan_running
,
1729 data
? data
->scan_info
.external_scan
: 0);
1730 if (wpa_s
->last_scan_req
== MANUAL_SCAN_REQ
&&
1731 wpa_s
->manual_scan_use_id
&& wpa_s
->own_scan_running
&&
1732 own_request
&& !(data
&& data
->scan_info
.external_scan
)) {
1733 wpa_msg_ctrl(wpa_s
, MSG_INFO
, WPA_EVENT_SCAN_RESULTS
"id=%u",
1734 wpa_s
->manual_scan_id
);
1735 wpa_s
->manual_scan_use_id
= 0;
1737 wpa_msg_ctrl(wpa_s
, MSG_INFO
, WPA_EVENT_SCAN_RESULTS
);
1739 wpas_notify_scan_results(wpa_s
);
1741 wpas_notify_scan_done(wpa_s
, 1);
1743 if (data
&& data
->scan_info
.external_scan
) {
1744 wpa_dbg(wpa_s
, MSG_DEBUG
, "Do not use results from externally requested scan operation for network selection");
1745 wpa_scan_results_free(scan_res
);
1749 if (wnm_scan_process(wpa_s
, 1) > 0)
1750 goto scan_work_done
;
1752 if (sme_proc_obss_scan(wpa_s
) > 0)
1753 goto scan_work_done
;
1756 wpas_beacon_rep_scan_process(wpa_s
, scan_res
, &data
->scan_info
) > 0)
1757 goto scan_work_done
;
1759 if ((wpa_s
->conf
->ap_scan
== 2 && !wpas_wps_searching(wpa_s
)))
1760 goto scan_work_done
;
1762 if (autoscan_notify_scan(wpa_s
, scan_res
))
1763 goto scan_work_done
;
1765 if (wpa_s
->disconnected
) {
1766 wpa_supplicant_set_state(wpa_s
, WPA_DISCONNECTED
);
1767 goto scan_work_done
;
1770 if (!wpas_driver_bss_selection(wpa_s
) &&
1771 bgscan_notify_scan(wpa_s
, scan_res
) == 1)
1772 goto scan_work_done
;
1774 wpas_wps_update_ap_info(wpa_s
, scan_res
);
1776 if (wpa_s
->wpa_state
>= WPA_AUTHENTICATING
&&
1777 wpa_s
->wpa_state
< WPA_COMPLETED
)
1778 goto scan_work_done
;
1780 wpa_scan_results_free(scan_res
);
1782 if (own_request
&& wpa_s
->scan_work
) {
1783 struct wpa_radio_work
*work
= wpa_s
->scan_work
;
1784 wpa_s
->scan_work
= NULL
;
1785 radio_work_done(work
);
1788 return wpas_select_network_from_last_scan(wpa_s
, 1, own_request
);
1791 wpa_scan_results_free(scan_res
);
1792 if (own_request
&& wpa_s
->scan_work
) {
1793 struct wpa_radio_work
*work
= wpa_s
->scan_work
;
1794 wpa_s
->scan_work
= NULL
;
1795 radio_work_done(work
);
1801 static int wpas_select_network_from_last_scan(struct wpa_supplicant
*wpa_s
,
1802 int new_scan
, int own_request
)
1804 struct wpa_bss
*selected
;
1805 struct wpa_ssid
*ssid
= NULL
;
1806 int time_to_reenable
= wpas_reenabled_network_time(wpa_s
);
1808 if (time_to_reenable
> 0) {
1809 wpa_dbg(wpa_s
, MSG_DEBUG
,
1810 "Postpone network selection by %d seconds since all networks are disabled",
1812 eloop_cancel_timeout(wpas_network_reenabled
, wpa_s
, NULL
);
1813 eloop_register_timeout(time_to_reenable
, 0,
1814 wpas_network_reenabled
, wpa_s
, NULL
);
1818 if (wpa_s
->p2p_mgmt
)
1819 return 0; /* no normal connection on p2p_mgmt interface */
1821 selected
= wpa_supplicant_pick_network(wpa_s
, &ssid
);
1825 wpa_msg(wpa_s
, MSG_INFO
,
1826 "Avoiding join because we already joined a mesh group");
1829 #endif /* CONFIG_MESH */
1833 skip
= !wpa_supplicant_need_to_roam(wpa_s
, selected
, ssid
);
1836 wpa_supplicant_rsn_preauth_scan_results(wpa_s
);
1840 if (ssid
!= wpa_s
->current_ssid
&&
1841 wpa_s
->wpa_state
>= WPA_AUTHENTICATING
) {
1842 wpa_s
->own_disconnect_req
= 1;
1843 wpa_supplicant_deauthenticate(
1844 wpa_s
, WLAN_REASON_DEAUTH_LEAVING
);
1847 if (wpa_supplicant_connect(wpa_s
, selected
, ssid
) < 0) {
1848 wpa_dbg(wpa_s
, MSG_DEBUG
, "Connect failed");
1852 wpa_supplicant_rsn_preauth_scan_results(wpa_s
);
1854 * Do not allow other virtual radios to trigger operations based
1855 * on these scan results since we do not want them to start
1856 * other associations at the same time.
1860 wpa_dbg(wpa_s
, MSG_DEBUG
, "No suitable network found");
1861 ssid
= wpa_supplicant_pick_new_network(wpa_s
);
1863 wpa_dbg(wpa_s
, MSG_DEBUG
, "Setup a new network");
1864 wpa_supplicant_associate(wpa_s
, NULL
, ssid
);
1866 wpa_supplicant_rsn_preauth_scan_results(wpa_s
);
1867 } else if (own_request
) {
1869 * No SSID found. If SCAN results are as a result of
1870 * own scan request and not due to a scan request on
1871 * another shared interface, try another scan.
1873 int timeout_sec
= wpa_s
->scan_interval
;
1874 int timeout_usec
= 0;
1878 res
= wpas_p2p_scan_no_go_seen(wpa_s
);
1884 if (wpa_s
->p2p_in_provisioning
||
1885 wpa_s
->show_group_started
||
1886 wpa_s
->p2p_in_invitation
) {
1888 * Use shorter wait during P2P Provisioning
1889 * state and during P2P join-a-group operation
1890 * to speed up group formation.
1893 timeout_usec
= 250000;
1894 wpa_supplicant_req_new_scan(wpa_s
, timeout_sec
,
1898 #endif /* CONFIG_P2P */
1899 #ifdef CONFIG_INTERWORKING
1900 if (wpa_s
->conf
->auto_interworking
&&
1901 wpa_s
->conf
->interworking
&&
1902 wpa_s
->conf
->cred
) {
1903 wpa_dbg(wpa_s
, MSG_DEBUG
, "Interworking: "
1904 "start ANQP fetch since no matching "
1906 wpa_s
->network_select
= 1;
1907 wpa_s
->auto_network_select
= 1;
1908 interworking_start_fetch_anqp(wpa_s
);
1911 #endif /* CONFIG_INTERWORKING */
1913 if (wpa_s
->after_wps
> 0 || wpas_wps_searching(wpa_s
)) {
1914 wpa_dbg(wpa_s
, MSG_DEBUG
, "Use shorter wait during WPS processing");
1916 timeout_usec
= 500000;
1917 wpa_supplicant_req_new_scan(wpa_s
, timeout_sec
,
1921 #endif /* CONFIG_WPS */
1922 if (wpa_supplicant_req_sched_scan(wpa_s
))
1923 wpa_supplicant_req_new_scan(wpa_s
, timeout_sec
,
1926 wpa_msg_ctrl(wpa_s
, MSG_INFO
,
1927 WPA_EVENT_NETWORK_NOT_FOUND
);
1934 static int wpa_supplicant_event_scan_results(struct wpa_supplicant
*wpa_s
,
1935 union wpa_event_data
*data
)
1937 struct wpa_supplicant
*ifs
;
1940 res
= _wpa_supplicant_event_scan_results(wpa_s
, data
, 1, 0);
1943 * Interface may have been removed, so must not dereference
1951 * If no scan results could be fetched, then no need to
1952 * notify those interfaces that did not actually request
1953 * this scan. Similarly, if scan results started a new operation on this
1954 * interface, do not notify other interfaces to avoid concurrent
1955 * operations during a connection attempt.
1961 * Check other interfaces to see if they share the same radio. If
1962 * so, they get updated with this same scan info.
1964 dl_list_for_each(ifs
, &wpa_s
->radio
->ifaces
, struct wpa_supplicant
,
1967 wpa_printf(MSG_DEBUG
, "%s: Updating scan results from "
1968 "sibling", ifs
->ifname
);
1969 res
= _wpa_supplicant_event_scan_results(ifs
, data
, 0,
1979 #endif /* CONFIG_NO_SCAN_PROCESSING */
1982 int wpa_supplicant_fast_associate(struct wpa_supplicant
*wpa_s
)
1984 #ifdef CONFIG_NO_SCAN_PROCESSING
1986 #else /* CONFIG_NO_SCAN_PROCESSING */
1987 struct os_reltime now
;
1989 wpa_s
->ignore_post_flush_scan_res
= 0;
1991 if (wpa_s
->last_scan_res_used
== 0)
1994 os_get_reltime(&now
);
1995 if (os_reltime_expired(&now
, &wpa_s
->last_scan
, 5)) {
1996 wpa_printf(MSG_DEBUG
, "Fast associate: Old scan results");
2000 return wpas_select_network_from_last_scan(wpa_s
, 0, 1);
2001 #endif /* CONFIG_NO_SCAN_PROCESSING */
2006 static void wnm_bss_keep_alive(void *eloop_ctx
, void *sock_ctx
)
2008 struct wpa_supplicant
*wpa_s
= eloop_ctx
;
2010 if (wpa_s
->wpa_state
< WPA_ASSOCIATED
)
2013 if (!wpa_s
->no_keep_alive
) {
2014 wpa_printf(MSG_DEBUG
, "WNM: Send keep-alive to AP " MACSTR
,
2015 MAC2STR(wpa_s
->bssid
));
2016 /* TODO: could skip this if normal data traffic has been sent */
2017 /* TODO: Consider using some more appropriate data frame for
2020 l2_packet_send(wpa_s
->l2
, wpa_s
->bssid
, 0x0800,
2025 if (wpa_s
->sme
.bss_max_idle_period
) {
2027 msec
= wpa_s
->sme
.bss_max_idle_period
* 1024; /* times 1000 */
2030 eloop_register_timeout(msec
/ 1000, msec
% 1000 * 1000,
2031 wnm_bss_keep_alive
, wpa_s
, NULL
);
2033 #endif /* CONFIG_SME */
2037 static void wnm_process_assoc_resp(struct wpa_supplicant
*wpa_s
,
2038 const u8
*ies
, size_t ies_len
)
2040 struct ieee802_11_elems elems
;
2045 if (ieee802_11_parse_elems(ies
, ies_len
, &elems
, 1) == ParseFailed
)
2049 if (elems
.bss_max_idle_period
) {
2051 wpa_s
->sme
.bss_max_idle_period
=
2052 WPA_GET_LE16(elems
.bss_max_idle_period
);
2053 wpa_printf(MSG_DEBUG
, "WNM: BSS Max Idle Period: %u (* 1000 "
2054 "TU)%s", wpa_s
->sme
.bss_max_idle_period
,
2055 (elems
.bss_max_idle_period
[2] & 0x01) ?
2056 " (protected keep-live required)" : "");
2057 if (wpa_s
->sme
.bss_max_idle_period
== 0)
2058 wpa_s
->sme
.bss_max_idle_period
= 1;
2059 if (wpa_s
->drv_flags
& WPA_DRIVER_FLAGS_SME
) {
2060 eloop_cancel_timeout(wnm_bss_keep_alive
, wpa_s
, NULL
);
2061 /* msec times 1000 */
2062 msec
= wpa_s
->sme
.bss_max_idle_period
* 1024;
2065 eloop_register_timeout(msec
/ 1000, msec
% 1000 * 1000,
2066 wnm_bss_keep_alive
, wpa_s
,
2070 #endif /* CONFIG_SME */
2073 #endif /* CONFIG_WNM */
2076 void wnm_bss_keep_alive_deinit(struct wpa_supplicant
*wpa_s
)
2079 eloop_cancel_timeout(wnm_bss_keep_alive
, wpa_s
, NULL
);
2080 #endif /* CONFIG_WNM */
2084 #ifdef CONFIG_INTERWORKING
2086 static int wpas_qos_map_set(struct wpa_supplicant
*wpa_s
, const u8
*qos_map
,
2091 wpa_hexdump(MSG_DEBUG
, "Interworking: QoS Map Set", qos_map
, len
);
2092 res
= wpa_drv_set_qos_map(wpa_s
, qos_map
, len
);
2094 wpa_printf(MSG_DEBUG
, "Interworking: Failed to configure QoS Map Set to the driver");
2101 static void interworking_process_assoc_resp(struct wpa_supplicant
*wpa_s
,
2102 const u8
*ies
, size_t ies_len
)
2104 struct ieee802_11_elems elems
;
2109 if (ieee802_11_parse_elems(ies
, ies_len
, &elems
, 1) == ParseFailed
)
2112 if (elems
.qos_map_set
) {
2113 wpas_qos_map_set(wpa_s
, elems
.qos_map_set
,
2114 elems
.qos_map_set_len
);
2118 #endif /* CONFIG_INTERWORKING */
2122 static int wpas_fst_update_mbie(struct wpa_supplicant
*wpa_s
,
2123 const u8
*ie
, size_t ie_len
)
2125 struct mb_ies_info mb_ies
;
2127 if (!ie
|| !ie_len
|| !wpa_s
->fst
)
2130 os_memset(&mb_ies
, 0, sizeof(mb_ies
));
2132 while (ie_len
>= 2 && mb_ies
.nof_ies
< MAX_NOF_MB_IES_SUPPORTED
) {
2137 wpa_hexdump(MSG_DEBUG
, "FST: Truncated IE found",
2142 if (ie
[0] == WLAN_EID_MULTI_BAND
) {
2143 wpa_printf(MSG_DEBUG
, "MB IE of %u bytes found",
2144 (unsigned int) len
);
2145 mb_ies
.ies
[mb_ies
.nof_ies
].ie
= ie
+ 2;
2146 mb_ies
.ies
[mb_ies
.nof_ies
].ie_len
= len
- 2;
2154 if (mb_ies
.nof_ies
> 0) {
2155 wpabuf_free(wpa_s
->received_mb_ies
);
2156 wpa_s
->received_mb_ies
= mb_ies_by_info(&mb_ies
);
2162 #endif /* CONFIG_FST */
2165 static int wpa_supplicant_event_associnfo(struct wpa_supplicant
*wpa_s
,
2166 union wpa_event_data
*data
)
2168 int l
, len
, found
= 0, wpa_found
, rsn_found
;
2170 #ifdef CONFIG_IEEE80211R
2172 #endif /* CONFIG_IEEE80211R */
2174 wpa_dbg(wpa_s
, MSG_DEBUG
, "Association info event");
2175 if (data
->assoc_info
.req_ies
)
2176 wpa_hexdump(MSG_DEBUG
, "req_ies", data
->assoc_info
.req_ies
,
2177 data
->assoc_info
.req_ies_len
);
2178 if (data
->assoc_info
.resp_ies
) {
2179 wpa_hexdump(MSG_DEBUG
, "resp_ies", data
->assoc_info
.resp_ies
,
2180 data
->assoc_info
.resp_ies_len
);
2182 wpa_tdls_assoc_resp_ies(wpa_s
->wpa
, data
->assoc_info
.resp_ies
,
2183 data
->assoc_info
.resp_ies_len
);
2184 #endif /* CONFIG_TDLS */
2186 wnm_process_assoc_resp(wpa_s
, data
->assoc_info
.resp_ies
,
2187 data
->assoc_info
.resp_ies_len
);
2188 #endif /* CONFIG_WNM */
2189 #ifdef CONFIG_INTERWORKING
2190 interworking_process_assoc_resp(wpa_s
, data
->assoc_info
.resp_ies
,
2191 data
->assoc_info
.resp_ies_len
);
2192 #endif /* CONFIG_INTERWORKING */
2194 if (data
->assoc_info
.beacon_ies
)
2195 wpa_hexdump(MSG_DEBUG
, "beacon_ies",
2196 data
->assoc_info
.beacon_ies
,
2197 data
->assoc_info
.beacon_ies_len
);
2198 if (data
->assoc_info
.freq
)
2199 wpa_dbg(wpa_s
, MSG_DEBUG
, "freq=%u MHz",
2200 data
->assoc_info
.freq
);
2202 p
= data
->assoc_info
.req_ies
;
2203 l
= data
->assoc_info
.req_ies_len
;
2205 /* Go through the IEs and make a copy of the WPA/RSN IE, if present. */
2206 while (p
&& l
>= 2) {
2209 wpa_hexdump(MSG_DEBUG
, "Truncated IE in assoc_info",
2213 if ((p
[0] == WLAN_EID_VENDOR_SPECIFIC
&& p
[1] >= 6 &&
2214 (os_memcmp(&p
[2], "\x00\x50\xF2\x01\x01\x00", 6) == 0)) ||
2215 (p
[0] == WLAN_EID_VENDOR_SPECIFIC
&& p
[1] >= 4 &&
2216 (os_memcmp(&p
[2], "\x50\x6F\x9A\x12", 4) == 0)) ||
2217 (p
[0] == WLAN_EID_RSN
&& p
[1] >= 2)) {
2218 if (wpa_sm_set_assoc_wpa_ie(wpa_s
->wpa
, p
, len
))
2221 wpa_find_assoc_pmkid(wpa_s
);
2227 if (!found
&& data
->assoc_info
.req_ies
)
2228 wpa_sm_set_assoc_wpa_ie(wpa_s
->wpa
, NULL
, 0);
2232 if ((wpa_s
->sme
.auth_alg
== WPA_AUTH_ALG_FILS
||
2233 wpa_s
->sme
.auth_alg
== WPA_AUTH_ALG_FILS_SK_PFS
) &&
2234 (!data
->assoc_info
.resp_frame
||
2235 fils_process_assoc_resp(wpa_s
->wpa
,
2236 data
->assoc_info
.resp_frame
,
2237 data
->assoc_info
.resp_frame_len
) < 0)) {
2238 wpa_supplicant_deauthenticate(wpa_s
, WLAN_REASON_UNSPECIFIED
);
2241 #endif /* CONFIG_SME */
2243 /* Additional processing for FILS when SME is in driver */
2244 if (wpa_s
->auth_alg
== WPA_AUTH_ALG_FILS
&&
2245 !(wpa_s
->drv_flags
& WPA_DRIVER_FLAGS_SME
))
2246 wpa_sm_set_reset_fils_completed(wpa_s
->wpa
, 1);
2247 #endif /* CONFIG_FILS */
2250 if (wpa_s
->key_mgmt
== WPA_KEY_MGMT_OWE
&&
2251 owe_process_assoc_resp(wpa_s
->wpa
,
2252 data
->assoc_info
.resp_ies
,
2253 data
->assoc_info
.resp_ies_len
) < 0) {
2254 wpa_supplicant_deauthenticate(wpa_s
, WLAN_REASON_UNSPECIFIED
);
2257 #endif /* CONFIG_OWE */
2259 #ifdef CONFIG_IEEE80211R
2261 if (wpa_s
->sme
.auth_alg
== WPA_AUTH_ALG_FT
) {
2262 if (wpa_drv_get_bssid(wpa_s
, bssid
) < 0 ||
2263 wpa_ft_validate_reassoc_resp(wpa_s
->wpa
,
2264 data
->assoc_info
.resp_ies
,
2265 data
->assoc_info
.resp_ies_len
,
2267 wpa_dbg(wpa_s
, MSG_DEBUG
, "FT: Validation of "
2268 "Reassociation Response failed");
2269 wpa_supplicant_deauthenticate(
2270 wpa_s
, WLAN_REASON_INVALID_IE
);
2275 p
= data
->assoc_info
.resp_ies
;
2276 l
= data
->assoc_info
.resp_ies_len
;
2278 #ifdef CONFIG_WPS_STRICT
2279 if (p
&& wpa_s
->current_ssid
&&
2280 wpa_s
->current_ssid
->key_mgmt
== WPA_KEY_MGMT_WPS
) {
2282 wps
= ieee802_11_vendor_ie_concat(p
, l
, WPS_IE_VENDOR_TYPE
);
2284 wpa_msg(wpa_s
, MSG_INFO
, "WPS-STRICT: AP did not "
2285 "include WPS IE in (Re)Association Response");
2289 if (wps_validate_assoc_resp(wps
) < 0) {
2291 wpa_supplicant_deauthenticate(
2292 wpa_s
, WLAN_REASON_INVALID_IE
);
2297 #endif /* CONFIG_WPS_STRICT */
2299 /* Go through the IEs and make a copy of the MDIE, if present. */
2300 while (p
&& l
>= 2) {
2303 wpa_hexdump(MSG_DEBUG
, "Truncated IE in assoc_info",
2307 if (p
[0] == WLAN_EID_MOBILITY_DOMAIN
&&
2308 p
[1] >= MOBILITY_DOMAIN_ID_LEN
) {
2309 wpa_s
->sme
.ft_used
= 1;
2310 os_memcpy(wpa_s
->sme
.mobility_domain
, p
+ 2,
2311 MOBILITY_DOMAIN_ID_LEN
);
2317 #endif /* CONFIG_SME */
2319 /* Process FT when SME is in the driver */
2320 if (!(wpa_s
->drv_flags
& WPA_DRIVER_FLAGS_SME
) &&
2321 wpa_ft_is_completed(wpa_s
->wpa
)) {
2322 if (wpa_drv_get_bssid(wpa_s
, bssid
) < 0 ||
2323 wpa_ft_validate_reassoc_resp(wpa_s
->wpa
,
2324 data
->assoc_info
.resp_ies
,
2325 data
->assoc_info
.resp_ies_len
,
2327 wpa_dbg(wpa_s
, MSG_DEBUG
, "FT: Validation of "
2328 "Reassociation Response failed");
2329 wpa_supplicant_deauthenticate(
2330 wpa_s
, WLAN_REASON_INVALID_IE
);
2333 wpa_dbg(wpa_s
, MSG_DEBUG
, "FT: Reassociation Response done");
2336 wpa_sm_set_ft_params(wpa_s
->wpa
, data
->assoc_info
.resp_ies
,
2337 data
->assoc_info
.resp_ies_len
);
2338 #endif /* CONFIG_IEEE80211R */
2340 /* WPA/RSN IE from Beacon/ProbeResp */
2341 p
= data
->assoc_info
.beacon_ies
;
2342 l
= data
->assoc_info
.beacon_ies_len
;
2344 /* Go through the IEs and make a copy of the WPA/RSN IEs, if present.
2346 wpa_found
= rsn_found
= 0;
2347 while (p
&& l
>= 2) {
2350 wpa_hexdump(MSG_DEBUG
, "Truncated IE in beacon_ies",
2355 p
[0] == WLAN_EID_VENDOR_SPECIFIC
&& p
[1] >= 6 &&
2356 os_memcmp(&p
[2], "\x00\x50\xF2\x01\x01\x00", 6) == 0) {
2358 wpa_sm_set_ap_wpa_ie(wpa_s
->wpa
, p
, len
);
2362 p
[0] == WLAN_EID_RSN
&& p
[1] >= 2) {
2364 wpa_sm_set_ap_rsn_ie(wpa_s
->wpa
, p
, len
);
2371 if (!wpa_found
&& data
->assoc_info
.beacon_ies
)
2372 wpa_sm_set_ap_wpa_ie(wpa_s
->wpa
, NULL
, 0);
2373 if (!rsn_found
&& data
->assoc_info
.beacon_ies
)
2374 wpa_sm_set_ap_rsn_ie(wpa_s
->wpa
, NULL
, 0);
2375 if (wpa_found
|| rsn_found
)
2376 wpa_s
->ap_ies_from_associnfo
= 1;
2378 if (wpa_s
->assoc_freq
&& data
->assoc_info
.freq
&&
2379 wpa_s
->assoc_freq
!= data
->assoc_info
.freq
) {
2380 wpa_printf(MSG_DEBUG
, "Operating frequency changed from "
2382 wpa_s
->assoc_freq
, data
->assoc_info
.freq
);
2383 wpa_supplicant_update_scan_results(wpa_s
);
2386 wpa_s
->assoc_freq
= data
->assoc_info
.freq
;
2392 static int wpa_supplicant_assoc_update_ie(struct wpa_supplicant
*wpa_s
)
2394 const u8
*bss_wpa
= NULL
, *bss_rsn
= NULL
;
2396 if (!wpa_s
->current_bss
|| !wpa_s
->current_ssid
)
2399 if (!wpa_key_mgmt_wpa_any(wpa_s
->current_ssid
->key_mgmt
))
2402 bss_wpa
= wpa_bss_get_vendor_ie(wpa_s
->current_bss
,
2403 WPA_IE_VENDOR_TYPE
);
2404 bss_rsn
= wpa_bss_get_ie(wpa_s
->current_bss
, WLAN_EID_RSN
);
2406 if (wpa_sm_set_ap_wpa_ie(wpa_s
->wpa
, bss_wpa
,
2407 bss_wpa
? 2 + bss_wpa
[1] : 0) ||
2408 wpa_sm_set_ap_rsn_ie(wpa_s
->wpa
, bss_rsn
,
2409 bss_rsn
? 2 + bss_rsn
[1] : 0))
2416 static void wpas_fst_update_mb_assoc(struct wpa_supplicant
*wpa_s
,
2417 union wpa_event_data
*data
)
2420 struct assoc_info
*ai
= data
? &data
->assoc_info
: NULL
;
2421 struct wpa_bss
*bss
= wpa_s
->current_bss
;
2422 const u8
*ieprb
, *iebcn
;
2424 wpabuf_free(wpa_s
->received_mb_ies
);
2425 wpa_s
->received_mb_ies
= NULL
;
2428 !wpas_fst_update_mbie(wpa_s
, ai
->resp_ies
, ai
->resp_ies_len
)) {
2429 wpa_printf(MSG_DEBUG
,
2430 "FST: MB IEs updated from Association Response frame");
2435 !wpas_fst_update_mbie(wpa_s
, ai
->beacon_ies
, ai
->beacon_ies_len
)) {
2436 wpa_printf(MSG_DEBUG
,
2437 "FST: MB IEs updated from association event Beacon IEs");
2444 ieprb
= (const u8
*) (bss
+ 1);
2445 iebcn
= ieprb
+ bss
->ie_len
;
2447 if (!wpas_fst_update_mbie(wpa_s
, ieprb
, bss
->ie_len
))
2448 wpa_printf(MSG_DEBUG
, "FST: MB IEs updated from bss IE");
2449 else if (!wpas_fst_update_mbie(wpa_s
, iebcn
, bss
->beacon_ie_len
))
2450 wpa_printf(MSG_DEBUG
, "FST: MB IEs updated from bss beacon IE");
2451 #endif /* CONFIG_FST */
2455 static void wpa_supplicant_event_assoc(struct wpa_supplicant
*wpa_s
,
2456 union wpa_event_data
*data
)
2459 int ft_completed
, already_authorized
;
2463 if (wpa_s
->ap_iface
) {
2466 hostapd_notif_assoc(wpa_s
->ap_iface
->bss
[0],
2467 data
->assoc_info
.addr
,
2468 data
->assoc_info
.req_ies
,
2469 data
->assoc_info
.req_ies_len
,
2470 data
->assoc_info
.reassoc
);
2473 #endif /* CONFIG_AP */
2475 eloop_cancel_timeout(wpas_network_reenabled
, wpa_s
, NULL
);
2477 ft_completed
= wpa_ft_is_completed(wpa_s
->wpa
);
2478 if (data
&& wpa_supplicant_event_associnfo(wpa_s
, data
) < 0)
2481 * FILS authentication can share the same mechanism to mark the
2482 * connection fully authenticated, so set ft_completed also based on
2486 ft_completed
= wpa_fils_is_completed(wpa_s
->wpa
);
2488 if (wpa_drv_get_bssid(wpa_s
, bssid
) < 0) {
2489 wpa_dbg(wpa_s
, MSG_ERROR
, "Failed to get BSSID");
2490 wpa_supplicant_deauthenticate(
2491 wpa_s
, WLAN_REASON_DEAUTH_LEAVING
);
2495 wpa_supplicant_set_state(wpa_s
, WPA_ASSOCIATED
);
2496 if (os_memcmp(bssid
, wpa_s
->bssid
, ETH_ALEN
) != 0) {
2497 wpa_dbg(wpa_s
, MSG_DEBUG
, "Associated to a new BSS: BSSID="
2498 MACSTR
, MAC2STR(bssid
));
2500 random_add_randomness(bssid
, ETH_ALEN
);
2501 os_memcpy(wpa_s
->bssid
, bssid
, ETH_ALEN
);
2502 os_memset(wpa_s
->pending_bssid
, 0, ETH_ALEN
);
2503 wpas_notify_bssid_changed(wpa_s
);
2505 if (wpa_supplicant_dynamic_keys(wpa_s
) && !ft_completed
) {
2506 wpa_clear_keys(wpa_s
, bssid
);
2508 if (wpa_supplicant_select_config(wpa_s
) < 0) {
2509 wpa_supplicant_deauthenticate(
2510 wpa_s
, WLAN_REASON_DEAUTH_LEAVING
);
2515 if (wpa_s
->conf
->ap_scan
== 1 &&
2516 wpa_s
->drv_flags
& WPA_DRIVER_FLAGS_BSS_SELECTION
) {
2517 if (wpa_supplicant_assoc_update_ie(wpa_s
) < 0 && new_bss
)
2518 wpa_msg(wpa_s
, MSG_WARNING
,
2519 "WPA/RSN IEs not updated");
2522 wpas_fst_update_mb_assoc(wpa_s
, data
);
2525 os_memcpy(wpa_s
->sme
.prev_bssid
, bssid
, ETH_ALEN
);
2526 wpa_s
->sme
.prev_bssid_set
= 1;
2527 wpa_s
->sme
.last_unprot_disconnect
.sec
= 0;
2528 #endif /* CONFIG_SME */
2530 wpa_msg(wpa_s
, MSG_INFO
, "Associated with " MACSTR
, MAC2STR(bssid
));
2531 if (wpa_s
->current_ssid
) {
2532 /* When using scanning (ap_scan=1), SIM PC/SC interface can be
2533 * initialized before association, but for other modes,
2534 * initialize PC/SC here, if the current configuration needs
2535 * smartcard or SIM/USIM. */
2536 wpa_supplicant_scard_init(wpa_s
, wpa_s
->current_ssid
);
2538 wpa_sm_notify_assoc(wpa_s
->wpa
, bssid
);
2540 l2_packet_notify_auth_start(wpa_s
->l2
);
2542 already_authorized
= data
&& data
->assoc_info
.authorized
;
2545 * Set portEnabled first to FALSE in order to get EAP state machine out
2546 * of the SUCCESS state and eapSuccess cleared. Without this, EAPOL PAE
2547 * state machine may transit to AUTHENTICATING state based on obsolete
2548 * eapSuccess and then trigger BE_AUTH to SUCCESS and PAE to
2549 * AUTHENTICATED without ever giving chance to EAP state machine to
2552 if (!ft_completed
&& !already_authorized
) {
2553 eapol_sm_notify_portEnabled(wpa_s
->eapol
, FALSE
);
2554 eapol_sm_notify_portValid(wpa_s
->eapol
, FALSE
);
2556 if (wpa_key_mgmt_wpa_psk(wpa_s
->key_mgmt
) ||
2557 wpa_s
->key_mgmt
== WPA_KEY_MGMT_DPP
||
2558 wpa_s
->key_mgmt
== WPA_KEY_MGMT_OWE
|| ft_completed
||
2560 eapol_sm_notify_eap_success(wpa_s
->eapol
, FALSE
);
2561 /* 802.1X::portControl = Auto */
2562 eapol_sm_notify_portEnabled(wpa_s
->eapol
, TRUE
);
2563 wpa_s
->eapol_received
= 0;
2564 if (wpa_s
->key_mgmt
== WPA_KEY_MGMT_NONE
||
2565 wpa_s
->key_mgmt
== WPA_KEY_MGMT_WPA_NONE
||
2566 (wpa_s
->current_ssid
&&
2567 wpa_s
->current_ssid
->mode
== IEEE80211_MODE_IBSS
)) {
2568 if (wpa_s
->current_ssid
&&
2569 wpa_s
->key_mgmt
== WPA_KEY_MGMT_WPA_NONE
&&
2571 WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC_DONE
)) {
2573 * Set the key after having received joined-IBSS event
2576 wpa_supplicant_set_wpa_none_key(wpa_s
,
2577 wpa_s
->current_ssid
);
2579 wpa_supplicant_cancel_auth_timeout(wpa_s
);
2580 wpa_supplicant_set_state(wpa_s
, WPA_COMPLETED
);
2581 } else if (!ft_completed
) {
2582 /* Timeout for receiving the first EAPOL packet */
2583 wpa_supplicant_req_auth_timeout(wpa_s
, 10, 0);
2585 wpa_supplicant_cancel_scan(wpa_s
);
2587 if ((wpa_s
->drv_flags
& WPA_DRIVER_FLAGS_4WAY_HANDSHAKE
) &&
2588 wpa_key_mgmt_wpa_psk(wpa_s
->key_mgmt
)) {
2590 * We are done; the driver will take care of RSN 4-way
2593 wpa_supplicant_cancel_auth_timeout(wpa_s
);
2594 wpa_supplicant_set_state(wpa_s
, WPA_COMPLETED
);
2595 eapol_sm_notify_portValid(wpa_s
->eapol
, TRUE
);
2596 eapol_sm_notify_eap_success(wpa_s
->eapol
, TRUE
);
2597 } else if ((wpa_s
->drv_flags
& WPA_DRIVER_FLAGS_4WAY_HANDSHAKE
) &&
2598 wpa_key_mgmt_wpa_ieee8021x(wpa_s
->key_mgmt
)) {
2600 * The driver will take care of RSN 4-way handshake, so we need
2601 * to allow EAPOL supplicant to complete its work without
2602 * waiting for WPA supplicant.
2604 eapol_sm_notify_portValid(wpa_s
->eapol
, TRUE
);
2605 } else if (ft_completed
) {
2607 * FT protocol completed - make sure EAPOL state machine ends
2608 * up in authenticated.
2610 wpa_supplicant_cancel_auth_timeout(wpa_s
);
2611 wpa_supplicant_set_state(wpa_s
, WPA_COMPLETED
);
2612 eapol_sm_notify_portValid(wpa_s
->eapol
, TRUE
);
2613 eapol_sm_notify_eap_success(wpa_s
->eapol
, TRUE
);
2616 wpa_s
->last_eapol_matches_bssid
= 0;
2618 if (wpa_s
->pending_eapol_rx
) {
2619 struct os_reltime now
, age
;
2620 os_get_reltime(&now
);
2621 os_reltime_sub(&now
, &wpa_s
->pending_eapol_rx_time
, &age
);
2622 if (age
.sec
== 0 && age
.usec
< 200000 &&
2623 os_memcmp(wpa_s
->pending_eapol_rx_src
, bssid
, ETH_ALEN
) ==
2625 wpa_dbg(wpa_s
, MSG_DEBUG
, "Process pending EAPOL "
2626 "frame that was received just before "
2627 "association notification");
2628 wpa_supplicant_rx_eapol(
2629 wpa_s
, wpa_s
->pending_eapol_rx_src
,
2630 wpabuf_head(wpa_s
->pending_eapol_rx
),
2631 wpabuf_len(wpa_s
->pending_eapol_rx
));
2633 wpabuf_free(wpa_s
->pending_eapol_rx
);
2634 wpa_s
->pending_eapol_rx
= NULL
;
2637 if ((wpa_s
->key_mgmt
== WPA_KEY_MGMT_NONE
||
2638 wpa_s
->key_mgmt
== WPA_KEY_MGMT_IEEE8021X_NO_WPA
) &&
2639 wpa_s
->current_ssid
&&
2640 (wpa_s
->drv_flags
& WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC_DONE
)) {
2641 /* Set static WEP keys again */
2642 wpa_set_wep_keys(wpa_s
, wpa_s
->current_ssid
);
2645 #ifdef CONFIG_IBSS_RSN
2646 if (wpa_s
->current_ssid
&&
2647 wpa_s
->current_ssid
->mode
== WPAS_MODE_IBSS
&&
2648 wpa_s
->key_mgmt
!= WPA_KEY_MGMT_NONE
&&
2649 wpa_s
->key_mgmt
!= WPA_KEY_MGMT_WPA_NONE
&&
2650 wpa_s
->ibss_rsn
== NULL
) {
2651 wpa_s
->ibss_rsn
= ibss_rsn_init(wpa_s
, wpa_s
->current_ssid
);
2652 if (!wpa_s
->ibss_rsn
) {
2653 wpa_msg(wpa_s
, MSG_INFO
, "Failed to init IBSS RSN");
2654 wpa_supplicant_deauthenticate(
2655 wpa_s
, WLAN_REASON_DEAUTH_LEAVING
);
2659 ibss_rsn_set_psk(wpa_s
->ibss_rsn
, wpa_s
->current_ssid
->psk
);
2661 #endif /* CONFIG_IBSS_RSN */
2663 wpas_wps_notify_assoc(wpa_s
, bssid
);
2666 wmm_ac_notify_assoc(wpa_s
, data
->assoc_info
.resp_ies
,
2667 data
->assoc_info
.resp_ies_len
,
2668 &data
->assoc_info
.wmm_params
);
2670 if (wpa_s
->reassoc_same_bss
)
2671 wmm_ac_restore_tspecs(wpa_s
);
2675 if (wpa_key_mgmt_fils(wpa_s
->key_mgmt
)) {
2676 struct wpa_bss
*bss
= wpa_bss_get_bssid(wpa_s
, bssid
);
2677 const u8
*fils_cache_id
= wpa_bss_get_fils_cache_id(bss
);
2680 wpa_sm_set_fils_cache_id(wpa_s
->wpa
, fils_cache_id
);
2682 #endif /* CONFIG_FILS */
2686 static int disconnect_reason_recoverable(u16 reason_code
)
2688 return reason_code
== WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY
||
2689 reason_code
== WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA
||
2690 reason_code
== WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA
;
2694 static void wpa_supplicant_event_disassoc(struct wpa_supplicant
*wpa_s
,
2696 int locally_generated
)
2700 if (wpa_s
->key_mgmt
== WPA_KEY_MGMT_WPA_NONE
) {
2702 * At least Host AP driver and a Prism3 card seemed to be
2703 * generating streams of disconnected events when configuring
2704 * IBSS for WPA-None. Ignore them for now.
2709 bssid
= wpa_s
->bssid
;
2710 if (is_zero_ether_addr(bssid
))
2711 bssid
= wpa_s
->pending_bssid
;
2713 if (!is_zero_ether_addr(bssid
) ||
2714 wpa_s
->wpa_state
>= WPA_AUTHENTICATING
) {
2715 wpa_msg(wpa_s
, MSG_INFO
, WPA_EVENT_DISCONNECTED
"bssid=" MACSTR
2717 MAC2STR(bssid
), reason_code
,
2718 locally_generated
? " locally_generated=1" : "");
2723 static int could_be_psk_mismatch(struct wpa_supplicant
*wpa_s
, u16 reason_code
,
2724 int locally_generated
)
2726 if (wpa_s
->wpa_state
!= WPA_4WAY_HANDSHAKE
||
2727 !wpa_key_mgmt_wpa_psk(wpa_s
->key_mgmt
))
2728 return 0; /* Not in 4-way handshake with PSK */
2731 * It looks like connection was lost while trying to go through PSK
2732 * 4-way handshake. Filter out known disconnection cases that are caused
2733 * by something else than PSK mismatch to avoid confusing reports.
2736 if (locally_generated
) {
2737 if (reason_code
== WLAN_REASON_IE_IN_4WAY_DIFFERS
)
2745 static void wpa_supplicant_event_disassoc_finish(struct wpa_supplicant
*wpa_s
,
2747 int locally_generated
)
2751 u8 prev_pending_bssid
[ETH_ALEN
];
2752 struct wpa_bss
*fast_reconnect
= NULL
;
2753 struct wpa_ssid
*fast_reconnect_ssid
= NULL
;
2754 struct wpa_ssid
*last_ssid
;
2755 struct wpa_bss
*curr
= NULL
;
2757 authenticating
= wpa_s
->wpa_state
== WPA_AUTHENTICATING
;
2758 os_memcpy(prev_pending_bssid
, wpa_s
->pending_bssid
, ETH_ALEN
);
2760 if (wpa_s
->key_mgmt
== WPA_KEY_MGMT_WPA_NONE
) {
2762 * At least Host AP driver and a Prism3 card seemed to be
2763 * generating streams of disconnected events when configuring
2764 * IBSS for WPA-None. Ignore them for now.
2766 wpa_dbg(wpa_s
, MSG_DEBUG
, "Disconnect event - ignore in "
2767 "IBSS/WPA-None mode");
2771 if (!wpa_s
->disconnected
&& wpa_s
->wpa_state
>= WPA_AUTHENTICATING
&&
2772 reason_code
== WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY
&&
2775 * Remove the inactive AP (which is probably out of range) from
2776 * the BSS list after marking disassociation. In particular
2777 * mac80211-based drivers use the
2778 * WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY reason code in
2779 * locally generated disconnection events for cases where the
2780 * AP does not reply anymore.
2782 curr
= wpa_s
->current_bss
;
2784 if (could_be_psk_mismatch(wpa_s
, reason_code
, locally_generated
)) {
2785 wpa_msg(wpa_s
, MSG_INFO
, "WPA: 4-Way Handshake failed - "
2786 "pre-shared key may be incorrect");
2787 if (wpas_p2p_4way_hs_failed(wpa_s
) > 0)
2788 return; /* P2P group removed */
2789 wpas_auth_failed(wpa_s
, "WRONG_KEY");
2791 if (!wpa_s
->disconnected
&&
2792 (!wpa_s
->auto_reconnect_disabled
||
2793 wpa_s
->key_mgmt
== WPA_KEY_MGMT_WPS
||
2794 wpas_wps_searching(wpa_s
) ||
2795 wpas_wps_reenable_networks_pending(wpa_s
))) {
2796 wpa_dbg(wpa_s
, MSG_DEBUG
, "Auto connect enabled: try to "
2797 "reconnect (wps=%d/%d wpa_state=%d)",
2798 wpa_s
->key_mgmt
== WPA_KEY_MGMT_WPS
,
2799 wpas_wps_searching(wpa_s
),
2801 if (wpa_s
->wpa_state
== WPA_COMPLETED
&&
2802 wpa_s
->current_ssid
&&
2803 wpa_s
->current_ssid
->mode
== WPAS_MODE_INFRA
&&
2804 !locally_generated
&&
2805 disconnect_reason_recoverable(reason_code
)) {
2807 * It looks like the AP has dropped association with
2808 * us, but could allow us to get back in. Try to
2809 * reconnect to the same BSS without full scan to save
2810 * time for some common cases.
2812 fast_reconnect
= wpa_s
->current_bss
;
2813 fast_reconnect_ssid
= wpa_s
->current_ssid
;
2814 } else if (wpa_s
->wpa_state
>= WPA_ASSOCIATING
)
2815 wpa_supplicant_req_scan(wpa_s
, 0, 100000);
2817 wpa_dbg(wpa_s
, MSG_DEBUG
, "Do not request new "
2820 wpa_dbg(wpa_s
, MSG_DEBUG
, "Auto connect disabled: do not "
2821 "try to re-connect");
2822 wpa_s
->reassociate
= 0;
2823 wpa_s
->disconnected
= 1;
2825 wpa_supplicant_cancel_sched_scan(wpa_s
);
2827 bssid
= wpa_s
->bssid
;
2828 if (is_zero_ether_addr(bssid
))
2829 bssid
= wpa_s
->pending_bssid
;
2830 if (wpa_s
->wpa_state
>= WPA_AUTHENTICATING
)
2831 wpas_connection_failed(wpa_s
, bssid
);
2832 wpa_sm_notify_disassoc(wpa_s
->wpa
);
2833 if (locally_generated
)
2834 wpa_s
->disconnect_reason
= -reason_code
;
2836 wpa_s
->disconnect_reason
= reason_code
;
2837 wpas_notify_disconnect_reason(wpa_s
);
2838 if (wpa_supplicant_dynamic_keys(wpa_s
)) {
2839 wpa_dbg(wpa_s
, MSG_DEBUG
, "Disconnect event - remove keys");
2840 wpa_clear_keys(wpa_s
, wpa_s
->bssid
);
2842 last_ssid
= wpa_s
->current_ssid
;
2843 wpa_supplicant_mark_disassoc(wpa_s
);
2846 wpa_bss_remove(wpa_s
, curr
, "Connection to AP lost");
2848 if (authenticating
&& (wpa_s
->drv_flags
& WPA_DRIVER_FLAGS_SME
)) {
2849 sme_disassoc_while_authenticating(wpa_s
, prev_pending_bssid
);
2850 wpa_s
->current_ssid
= last_ssid
;
2853 if (fast_reconnect
&&
2854 !wpas_network_disabled(wpa_s
, fast_reconnect_ssid
) &&
2855 !disallowed_bssid(wpa_s
, fast_reconnect
->bssid
) &&
2856 !disallowed_ssid(wpa_s
, fast_reconnect
->ssid
,
2857 fast_reconnect
->ssid_len
) &&
2858 !wpas_temp_disabled(wpa_s
, fast_reconnect_ssid
) &&
2859 !wpa_is_bss_tmp_disallowed(wpa_s
, fast_reconnect
->bssid
)) {
2860 #ifndef CONFIG_NO_SCAN_PROCESSING
2861 wpa_dbg(wpa_s
, MSG_DEBUG
, "Try to reconnect to the same BSS");
2862 if (wpa_supplicant_connect(wpa_s
, fast_reconnect
,
2863 fast_reconnect_ssid
) < 0) {
2864 /* Recover through full scan */
2865 wpa_supplicant_req_scan(wpa_s
, 0, 100000);
2867 #endif /* CONFIG_NO_SCAN_PROCESSING */
2868 } else if (fast_reconnect
) {
2870 * Could not reconnect to the same BSS due to network being
2871 * disabled. Use a new scan to match the alternative behavior
2872 * above, i.e., to continue automatic reconnection attempt in a
2873 * way that enforces disabled network rules.
2875 wpa_supplicant_req_scan(wpa_s
, 0, 100000);
2880 #ifdef CONFIG_DELAYED_MIC_ERROR_REPORT
2881 void wpa_supplicant_delayed_mic_error_report(void *eloop_ctx
, void *sock_ctx
)
2883 struct wpa_supplicant
*wpa_s
= eloop_ctx
;
2885 if (!wpa_s
->pending_mic_error_report
)
2888 wpa_dbg(wpa_s
, MSG_DEBUG
, "WPA: Sending pending MIC error report");
2889 wpa_sm_key_request(wpa_s
->wpa
, 1, wpa_s
->pending_mic_error_pairwise
);
2890 wpa_s
->pending_mic_error_report
= 0;
2892 #endif /* CONFIG_DELAYED_MIC_ERROR_REPORT */
2896 wpa_supplicant_event_michael_mic_failure(struct wpa_supplicant
*wpa_s
,
2897 union wpa_event_data
*data
)
2900 struct os_reltime t
;
2902 wpa_msg(wpa_s
, MSG_WARNING
, "Michael MIC failure detected");
2903 pairwise
= (data
&& data
->michael_mic_failure
.unicast
);
2905 if ((wpa_s
->last_michael_mic_error
.sec
&&
2906 !os_reltime_expired(&t
, &wpa_s
->last_michael_mic_error
, 60)) ||
2907 wpa_s
->pending_mic_error_report
) {
2908 if (wpa_s
->pending_mic_error_report
) {
2910 * Send the pending MIC error report immediately since
2911 * we are going to start countermeasures and AP better
2914 wpa_sm_key_request(wpa_s
->wpa
, 1,
2915 wpa_s
->pending_mic_error_pairwise
);
2918 /* Send the new MIC error report immediately since we are going
2919 * to start countermeasures and AP better do the same.
2921 wpa_sm_key_request(wpa_s
->wpa
, 1, pairwise
);
2923 /* initialize countermeasures */
2924 wpa_s
->countermeasures
= 1;
2926 wpa_blacklist_add(wpa_s
, wpa_s
->bssid
);
2928 wpa_msg(wpa_s
, MSG_WARNING
, "TKIP countermeasures started");
2931 * Need to wait for completion of request frame. We do not get
2932 * any callback for the message completion, so just wait a
2933 * short while and hope for the best. */
2936 wpa_drv_set_countermeasures(wpa_s
, 1);
2937 wpa_supplicant_deauthenticate(wpa_s
,
2938 WLAN_REASON_MICHAEL_MIC_FAILURE
);
2939 eloop_cancel_timeout(wpa_supplicant_stop_countermeasures
,
2941 eloop_register_timeout(60, 0,
2942 wpa_supplicant_stop_countermeasures
,
2944 /* TODO: mark the AP rejected for 60 second. STA is
2945 * allowed to associate with another AP.. */
2947 #ifdef CONFIG_DELAYED_MIC_ERROR_REPORT
2948 if (wpa_s
->mic_errors_seen
) {
2950 * Reduce the effectiveness of Michael MIC error
2951 * reports as a means for attacking against TKIP if
2952 * more than one MIC failure is noticed with the same
2953 * PTK. We delay the transmission of the reports by a
2954 * random time between 0 and 60 seconds in order to
2955 * force the attacker wait 60 seconds before getting
2956 * the information on whether a frame resulted in a MIC
2962 if (os_get_random(rval
, sizeof(rval
)) < 0)
2963 sec
= os_random() % 60;
2965 sec
= WPA_GET_BE32(rval
) % 60;
2966 wpa_dbg(wpa_s
, MSG_DEBUG
, "WPA: Delay MIC error "
2967 "report %d seconds", sec
);
2968 wpa_s
->pending_mic_error_report
= 1;
2969 wpa_s
->pending_mic_error_pairwise
= pairwise
;
2970 eloop_cancel_timeout(
2971 wpa_supplicant_delayed_mic_error_report
,
2973 eloop_register_timeout(
2974 sec
, os_random() % 1000000,
2975 wpa_supplicant_delayed_mic_error_report
,
2978 wpa_sm_key_request(wpa_s
->wpa
, 1, pairwise
);
2980 #else /* CONFIG_DELAYED_MIC_ERROR_REPORT */
2981 wpa_sm_key_request(wpa_s
->wpa
, 1, pairwise
);
2982 #endif /* CONFIG_DELAYED_MIC_ERROR_REPORT */
2984 wpa_s
->last_michael_mic_error
= t
;
2985 wpa_s
->mic_errors_seen
++;
2989 #ifdef CONFIG_TERMINATE_ONLASTIF
2990 static int any_interfaces(struct wpa_supplicant
*head
)
2992 struct wpa_supplicant
*wpa_s
;
2994 for (wpa_s
= head
; wpa_s
!= NULL
; wpa_s
= wpa_s
->next
)
2995 if (!wpa_s
->interface_removed
)
2999 #endif /* CONFIG_TERMINATE_ONLASTIF */
3003 wpa_supplicant_event_interface_status(struct wpa_supplicant
*wpa_s
,
3004 union wpa_event_data
*data
)
3006 if (os_strcmp(wpa_s
->ifname
, data
->interface_status
.ifname
) != 0)
3009 switch (data
->interface_status
.ievent
) {
3010 case EVENT_INTERFACE_ADDED
:
3011 if (!wpa_s
->interface_removed
)
3013 wpa_s
->interface_removed
= 0;
3014 wpa_dbg(wpa_s
, MSG_DEBUG
, "Configured interface was added");
3015 if (wpa_supplicant_driver_init(wpa_s
) < 0) {
3016 wpa_msg(wpa_s
, MSG_INFO
, "Failed to initialize the "
3017 "driver after interface was added");
3021 if (!wpa_s
->global
->p2p
&&
3022 !wpa_s
->global
->p2p_disabled
&&
3023 !wpa_s
->conf
->p2p_disabled
&&
3025 WPA_DRIVER_FLAGS_DEDICATED_P2P_DEVICE
) &&
3026 wpas_p2p_add_p2pdev_interface(
3027 wpa_s
, wpa_s
->global
->params
.conf_p2p_dev
) < 0) {
3028 wpa_printf(MSG_INFO
,
3029 "P2P: Failed to enable P2P Device interface");
3030 /* Try to continue without. P2P will be disabled. */
3032 #endif /* CONFIG_P2P */
3035 case EVENT_INTERFACE_REMOVED
:
3036 wpa_dbg(wpa_s
, MSG_DEBUG
, "Configured interface was removed");
3037 wpa_s
->interface_removed
= 1;
3038 wpa_supplicant_mark_disassoc(wpa_s
);
3039 wpa_supplicant_set_state(wpa_s
, WPA_INTERFACE_DISABLED
);
3040 l2_packet_deinit(wpa_s
->l2
);
3044 if (wpa_s
->global
->p2p
&&
3045 wpa_s
->global
->p2p_init_wpa_s
->parent
== wpa_s
&&
3047 WPA_DRIVER_FLAGS_DEDICATED_P2P_DEVICE
)) {
3048 wpa_dbg(wpa_s
, MSG_DEBUG
,
3049 "Removing P2P Device interface");
3050 wpa_supplicant_remove_iface(
3051 wpa_s
->global
, wpa_s
->global
->p2p_init_wpa_s
,
3053 wpa_s
->global
->p2p_init_wpa_s
= NULL
;
3055 #endif /* CONFIG_P2P */
3057 #ifdef CONFIG_MATCH_IFACE
3058 if (wpa_s
->matched
) {
3059 wpa_supplicant_remove_iface(wpa_s
->global
, wpa_s
, 0);
3062 #endif /* CONFIG_MATCH_IFACE */
3064 #ifdef CONFIG_TERMINATE_ONLASTIF
3065 /* check if last interface */
3066 if (!any_interfaces(wpa_s
->global
->ifaces
))
3068 #endif /* CONFIG_TERMINATE_ONLASTIF */
3074 #ifdef CONFIG_PEERKEY
3076 wpa_supplicant_event_stkstart(struct wpa_supplicant
*wpa_s
,
3077 union wpa_event_data
*data
)
3081 wpa_sm_stkstart(wpa_s
->wpa
, data
->stkstart
.peer
);
3083 #endif /* CONFIG_PEERKEY */
3087 static void wpa_supplicant_event_tdls(struct wpa_supplicant
*wpa_s
,
3088 union wpa_event_data
*data
)
3092 switch (data
->tdls
.oper
) {
3093 case TDLS_REQUEST_SETUP
:
3094 wpa_tdls_remove(wpa_s
->wpa
, data
->tdls
.peer
);
3095 if (wpa_tdls_is_external_setup(wpa_s
->wpa
))
3096 wpa_tdls_start(wpa_s
->wpa
, data
->tdls
.peer
);
3098 wpa_drv_tdls_oper(wpa_s
, TDLS_SETUP
, data
->tdls
.peer
);
3100 case TDLS_REQUEST_TEARDOWN
:
3101 if (wpa_tdls_is_external_setup(wpa_s
->wpa
))
3102 wpa_tdls_teardown_link(wpa_s
->wpa
, data
->tdls
.peer
,
3103 data
->tdls
.reason_code
);
3105 wpa_drv_tdls_oper(wpa_s
, TDLS_TEARDOWN
,
3108 case TDLS_REQUEST_DISCOVER
:
3109 wpa_tdls_send_discovery_request(wpa_s
->wpa
,
3114 #endif /* CONFIG_TDLS */
3118 static void wpa_supplicant_event_wnm(struct wpa_supplicant
*wpa_s
,
3119 union wpa_event_data
*data
)
3123 switch (data
->wnm
.oper
) {
3124 case WNM_OPER_SLEEP
:
3125 wpa_printf(MSG_DEBUG
, "Start sending WNM-Sleep Request "
3126 "(action=%d, intval=%d)",
3127 data
->wnm
.sleep_action
, data
->wnm
.sleep_intval
);
3128 ieee802_11_send_wnmsleep_req(wpa_s
, data
->wnm
.sleep_action
,
3129 data
->wnm
.sleep_intval
, NULL
);
3133 #endif /* CONFIG_WNM */
3136 #ifdef CONFIG_IEEE80211R
3138 wpa_supplicant_event_ft_response(struct wpa_supplicant
*wpa_s
,
3139 union wpa_event_data
*data
)
3144 if (wpa_ft_process_response(wpa_s
->wpa
, data
->ft_ies
.ies
,
3145 data
->ft_ies
.ies_len
,
3146 data
->ft_ies
.ft_action
,
3147 data
->ft_ies
.target_ap
,
3148 data
->ft_ies
.ric_ies
,
3149 data
->ft_ies
.ric_ies_len
) < 0) {
3150 /* TODO: prevent MLME/driver from trying to associate? */
3153 #endif /* CONFIG_IEEE80211R */
3156 #ifdef CONFIG_IBSS_RSN
3157 static void wpa_supplicant_event_ibss_rsn_start(struct wpa_supplicant
*wpa_s
,
3158 union wpa_event_data
*data
)
3160 struct wpa_ssid
*ssid
;
3161 if (wpa_s
->wpa_state
< WPA_ASSOCIATED
)
3165 ssid
= wpa_s
->current_ssid
;
3168 if (ssid
->mode
!= WPAS_MODE_IBSS
|| !wpa_key_mgmt_wpa(ssid
->key_mgmt
))
3171 ibss_rsn_start(wpa_s
->ibss_rsn
, data
->ibss_rsn_start
.peer
);
3175 static void wpa_supplicant_event_ibss_auth(struct wpa_supplicant
*wpa_s
,
3176 union wpa_event_data
*data
)
3178 struct wpa_ssid
*ssid
= wpa_s
->current_ssid
;
3183 /* check if the ssid is correctly configured as IBSS/RSN */
3184 if (ssid
->mode
!= WPAS_MODE_IBSS
|| !wpa_key_mgmt_wpa(ssid
->key_mgmt
))
3187 ibss_rsn_handle_auth(wpa_s
->ibss_rsn
, data
->rx_mgmt
.frame
,
3188 data
->rx_mgmt
.frame_len
);
3190 #endif /* CONFIG_IBSS_RSN */
3193 #ifdef CONFIG_IEEE80211R
3194 static void ft_rx_action(struct wpa_supplicant
*wpa_s
, const u8
*data
,
3197 const u8
*sta_addr
, *target_ap_addr
;
3200 wpa_hexdump(MSG_MSGDUMP
, "FT: RX Action", data
, len
);
3201 if (!(wpa_s
->drv_flags
& WPA_DRIVER_FLAGS_SME
))
3202 return; /* only SME case supported for now */
3203 if (len
< 1 + 2 * ETH_ALEN
+ 2)
3206 return; /* Only FT Action Response is supported for now */
3207 sta_addr
= data
+ 1;
3208 target_ap_addr
= data
+ 1 + ETH_ALEN
;
3209 status
= WPA_GET_LE16(data
+ 1 + 2 * ETH_ALEN
);
3210 wpa_dbg(wpa_s
, MSG_DEBUG
, "FT: Received FT Action Response: STA "
3211 MACSTR
" TargetAP " MACSTR
" status %u",
3212 MAC2STR(sta_addr
), MAC2STR(target_ap_addr
), status
);
3214 if (os_memcmp(sta_addr
, wpa_s
->own_addr
, ETH_ALEN
) != 0) {
3215 wpa_dbg(wpa_s
, MSG_DEBUG
, "FT: Foreign STA Address " MACSTR
3216 " in FT Action Response", MAC2STR(sta_addr
));
3221 wpa_dbg(wpa_s
, MSG_DEBUG
, "FT: FT Action Response indicates "
3222 "failure (status code %d)", status
);
3223 /* TODO: report error to FT code(?) */
3227 if (wpa_ft_process_response(wpa_s
->wpa
, data
+ 1 + 2 * ETH_ALEN
+ 2,
3228 len
- (1 + 2 * ETH_ALEN
+ 2), 1,
3229 target_ap_addr
, NULL
, 0) < 0)
3234 struct wpa_bss
*bss
;
3235 bss
= wpa_bss_get_bssid(wpa_s
, target_ap_addr
);
3237 wpa_s
->sme
.freq
= bss
->freq
;
3238 wpa_s
->sme
.auth_alg
= WPA_AUTH_ALG_FT
;
3239 sme_associate(wpa_s
, WPAS_MODE_INFRA
, target_ap_addr
,
3242 #endif /* CONFIG_SME */
3244 #endif /* CONFIG_IEEE80211R */
3247 static void wpa_supplicant_event_unprot_deauth(struct wpa_supplicant
*wpa_s
,
3248 struct unprot_deauth
*e
)
3250 #ifdef CONFIG_IEEE80211W
3251 wpa_printf(MSG_DEBUG
, "Unprotected Deauthentication frame "
3252 "dropped: " MACSTR
" -> " MACSTR
3253 " (reason code %u)",
3254 MAC2STR(e
->sa
), MAC2STR(e
->da
), e
->reason_code
);
3255 sme_event_unprot_disconnect(wpa_s
, e
->sa
, e
->da
, e
->reason_code
);
3256 #endif /* CONFIG_IEEE80211W */
3260 static void wpa_supplicant_event_unprot_disassoc(struct wpa_supplicant
*wpa_s
,
3261 struct unprot_disassoc
*e
)
3263 #ifdef CONFIG_IEEE80211W
3264 wpa_printf(MSG_DEBUG
, "Unprotected Disassociation frame "
3265 "dropped: " MACSTR
" -> " MACSTR
3266 " (reason code %u)",
3267 MAC2STR(e
->sa
), MAC2STR(e
->da
), e
->reason_code
);
3268 sme_event_unprot_disconnect(wpa_s
, e
->sa
, e
->da
, e
->reason_code
);
3269 #endif /* CONFIG_IEEE80211W */
3273 static void wpas_event_disconnect(struct wpa_supplicant
*wpa_s
, const u8
*addr
,
3274 u16 reason_code
, int locally_generated
,
3275 const u8
*ie
, size_t ie_len
, int deauth
)
3278 if (wpa_s
->ap_iface
&& addr
) {
3279 hostapd_notif_disassoc(wpa_s
->ap_iface
->bss
[0], addr
);
3283 if (wpa_s
->ap_iface
) {
3284 wpa_dbg(wpa_s
, MSG_DEBUG
, "Ignore deauth event in AP mode");
3287 #endif /* CONFIG_AP */
3289 if (!locally_generated
)
3290 wpa_s
->own_disconnect_req
= 0;
3292 wpa_supplicant_event_disassoc(wpa_s
, reason_code
, locally_generated
);
3294 if (((reason_code
== WLAN_REASON_IEEE_802_1X_AUTH_FAILED
||
3295 ((wpa_key_mgmt_wpa_ieee8021x(wpa_s
->key_mgmt
) ||
3296 (wpa_s
->key_mgmt
& WPA_KEY_MGMT_IEEE8021X_NO_WPA
)) &&
3297 eapol_sm_failed(wpa_s
->eapol
))) &&
3298 !wpa_s
->eap_expected_failure
))
3299 wpas_auth_failed(wpa_s
, "AUTH_FAILED");
3302 if (deauth
&& reason_code
> 0) {
3303 if (wpas_p2p_deauth_notif(wpa_s
, addr
, reason_code
, ie
, ie_len
,
3304 locally_generated
) > 0) {
3306 * The interface was removed, so cannot continue
3307 * processing any additional operations after this.
3312 #endif /* CONFIG_P2P */
3314 wpa_supplicant_event_disassoc_finish(wpa_s
, reason_code
,
3319 static void wpas_event_disassoc(struct wpa_supplicant
*wpa_s
,
3320 struct disassoc_info
*info
)
3322 u16 reason_code
= 0;
3323 int locally_generated
= 0;
3324 const u8
*addr
= NULL
;
3325 const u8
*ie
= NULL
;
3328 wpa_dbg(wpa_s
, MSG_DEBUG
, "Disassociation notification");
3333 ie_len
= info
->ie_len
;
3334 reason_code
= info
->reason_code
;
3335 locally_generated
= info
->locally_generated
;
3336 wpa_dbg(wpa_s
, MSG_DEBUG
, " * reason %u%s", reason_code
,
3337 locally_generated
? " (locally generated)" : "");
3339 wpa_dbg(wpa_s
, MSG_DEBUG
, " * address " MACSTR
,
3341 wpa_hexdump(MSG_DEBUG
, "Disassociation frame IE(s)",
3346 if (wpa_s
->ap_iface
&& info
&& info
->addr
) {
3347 hostapd_notif_disassoc(wpa_s
->ap_iface
->bss
[0], info
->addr
);
3351 if (wpa_s
->ap_iface
) {
3352 wpa_dbg(wpa_s
, MSG_DEBUG
, "Ignore disassoc event in AP mode");
3355 #endif /* CONFIG_AP */
3359 wpas_p2p_disassoc_notif(
3360 wpa_s
, info
->addr
, reason_code
, info
->ie
, info
->ie_len
,
3363 #endif /* CONFIG_P2P */
3365 if (wpa_s
->drv_flags
& WPA_DRIVER_FLAGS_SME
)
3366 sme_event_disassoc(wpa_s
, info
);
3368 wpas_event_disconnect(wpa_s
, addr
, reason_code
, locally_generated
,
3373 static void wpas_event_deauth(struct wpa_supplicant
*wpa_s
,
3374 struct deauth_info
*info
)
3376 u16 reason_code
= 0;
3377 int locally_generated
= 0;
3378 const u8
*addr
= NULL
;
3379 const u8
*ie
= NULL
;
3382 wpa_dbg(wpa_s
, MSG_DEBUG
, "Deauthentication notification");
3387 ie_len
= info
->ie_len
;
3388 reason_code
= info
->reason_code
;
3389 locally_generated
= info
->locally_generated
;
3390 wpa_dbg(wpa_s
, MSG_DEBUG
, " * reason %u%s",
3392 locally_generated
? " (locally generated)" : "");
3394 wpa_dbg(wpa_s
, MSG_DEBUG
, " * address " MACSTR
,
3397 wpa_hexdump(MSG_DEBUG
, "Deauthentication frame IE(s)",
3401 wpa_reset_ft_completed(wpa_s
->wpa
);
3403 wpas_event_disconnect(wpa_s
, addr
, reason_code
,
3404 locally_generated
, ie
, ie_len
, 1);
3408 static const char * reg_init_str(enum reg_change_initiator init
)
3411 case REGDOM_SET_BY_CORE
:
3413 case REGDOM_SET_BY_USER
:
3415 case REGDOM_SET_BY_DRIVER
:
3417 case REGDOM_SET_BY_COUNTRY_IE
:
3418 return "COUNTRY_IE";
3419 case REGDOM_BEACON_HINT
:
3420 return "BEACON_HINT";
3426 static const char * reg_type_str(enum reg_type type
)
3429 case REGDOM_TYPE_UNKNOWN
:
3431 case REGDOM_TYPE_COUNTRY
:
3433 case REGDOM_TYPE_WORLD
:
3435 case REGDOM_TYPE_CUSTOM_WORLD
:
3436 return "CUSTOM_WORLD";
3437 case REGDOM_TYPE_INTERSECTION
:
3438 return "INTERSECTION";
3444 static void wpa_supplicant_update_channel_list(
3445 struct wpa_supplicant
*wpa_s
, struct channel_list_changed
*info
)
3447 struct wpa_supplicant
*ifs
;
3451 * To allow backwards compatibility with higher level layers that
3452 * assumed the REGDOM_CHANGE event is sent over the initially added
3453 * interface. Find the highest parent of this interface and use it to
3456 for (ifs
= wpa_s
; ifs
->parent
&& ifs
!= ifs
->parent
; ifs
= ifs
->parent
)
3459 wpa_msg(ifs
, MSG_INFO
, WPA_EVENT_REGDOM_CHANGE
"init=%s type=%s%s%s",
3460 reg_init_str(info
->initiator
), reg_type_str(info
->type
),
3461 info
->alpha2
[0] ? " alpha2=" : "",
3462 info
->alpha2
[0] ? info
->alpha2
: "");
3464 if (wpa_s
->drv_priv
== NULL
)
3465 return; /* Ignore event during drv initialization */
3467 dl_list_for_each(ifs
, &wpa_s
->radio
->ifaces
, struct wpa_supplicant
,
3469 wpa_printf(MSG_DEBUG
, "%s: Updating hw mode",
3471 free_hw_features(ifs
);
3472 ifs
->hw
.modes
= wpa_drv_get_hw_feature_data(
3473 ifs
, &ifs
->hw
.num_modes
, &ifs
->hw
.flags
, &dfs_domain
);
3475 /* Restart PNO/sched_scan with updated channel list */
3478 wpas_start_pno(ifs
);
3479 } else if (ifs
->sched_scanning
&& !ifs
->pno_sched_pending
) {
3480 wpa_dbg(ifs
, MSG_DEBUG
,
3481 "Channel list changed - restart sched_scan");
3482 wpas_scan_restart_sched_scan(ifs
);
3486 wpas_p2p_update_channel_list(wpa_s
, WPAS_P2P_CHANNEL_UPDATE_DRIVER
);
3490 static void wpas_event_rx_mgmt_action(struct wpa_supplicant
*wpa_s
,
3491 const u8
*frame
, size_t len
, int freq
,
3494 const struct ieee80211_mgmt
*mgmt
;
3499 if (len
< IEEE80211_HDRLEN
+ 2)
3502 mgmt
= (const struct ieee80211_mgmt
*) frame
;
3503 payload
= frame
+ IEEE80211_HDRLEN
;
3504 category
= *payload
++;
3505 plen
= len
- IEEE80211_HDRLEN
- 1;
3507 wpa_dbg(wpa_s
, MSG_DEBUG
, "Received Action frame: SA=" MACSTR
3508 " Category=%u DataLen=%d freq=%d MHz",
3509 MAC2STR(mgmt
->sa
), category
, (int) plen
, freq
);
3511 if (category
== WLAN_ACTION_WMM
) {
3512 wmm_ac_rx_action(wpa_s
, mgmt
->da
, mgmt
->sa
, payload
, plen
);
3516 #ifdef CONFIG_IEEE80211R
3517 if (category
== WLAN_ACTION_FT
) {
3518 ft_rx_action(wpa_s
, payload
, plen
);
3521 #endif /* CONFIG_IEEE80211R */
3523 #ifdef CONFIG_IEEE80211W
3525 if (category
== WLAN_ACTION_SA_QUERY
) {
3526 sme_sa_query_rx(wpa_s
, mgmt
->sa
, payload
, plen
);
3529 #endif /* CONFIG_SME */
3530 #endif /* CONFIG_IEEE80211W */
3533 if (mgmt
->u
.action
.category
== WLAN_ACTION_WNM
) {
3534 ieee802_11_rx_wnm_action(wpa_s
, mgmt
, len
);
3537 #endif /* CONFIG_WNM */
3540 if ((mgmt
->u
.action
.category
== WLAN_ACTION_PUBLIC
||
3541 mgmt
->u
.action
.category
== WLAN_ACTION_PROTECTED_DUAL
) &&
3542 gas_query_rx(wpa_s
->gas
, mgmt
->da
, mgmt
->sa
, mgmt
->bssid
,
3543 mgmt
->u
.action
.category
,
3544 payload
, plen
, freq
) == 0)
3546 #endif /* CONFIG_GAS */
3548 #ifdef CONFIG_GAS_SERVER
3549 if ((mgmt
->u
.action
.category
== WLAN_ACTION_PUBLIC
||
3550 mgmt
->u
.action
.category
== WLAN_ACTION_PROTECTED_DUAL
) &&
3551 gas_server_rx(wpa_s
->gas_server
, mgmt
->da
, mgmt
->sa
, mgmt
->bssid
,
3552 mgmt
->u
.action
.category
,
3553 payload
, plen
, freq
) == 0)
3555 #endif /* CONFIG_GAS_SERVER */
3558 if (category
== WLAN_ACTION_PUBLIC
&& plen
>= 4 &&
3559 payload
[0] == WLAN_TDLS_DISCOVERY_RESPONSE
) {
3560 wpa_dbg(wpa_s
, MSG_DEBUG
,
3561 "TDLS: Received Discovery Response from " MACSTR
,
3565 #endif /* CONFIG_TDLS */
3567 #ifdef CONFIG_INTERWORKING
3568 if (category
== WLAN_ACTION_QOS
&& plen
>= 1 &&
3569 payload
[0] == QOS_QOS_MAP_CONFIG
) {
3570 const u8
*pos
= payload
+ 1;
3571 size_t qlen
= plen
- 1;
3572 wpa_dbg(wpa_s
, MSG_DEBUG
, "Interworking: Received QoS Map Configure frame from "
3573 MACSTR
, MAC2STR(mgmt
->sa
));
3574 if (os_memcmp(mgmt
->sa
, wpa_s
->bssid
, ETH_ALEN
) == 0 &&
3575 qlen
> 2 && pos
[0] == WLAN_EID_QOS_MAP_SET
&&
3576 pos
[1] <= qlen
- 2 && pos
[1] >= 16)
3577 wpas_qos_map_set(wpa_s
, pos
+ 2, pos
[1]);
3580 #endif /* CONFIG_INTERWORKING */
3582 if (category
== WLAN_ACTION_RADIO_MEASUREMENT
&&
3583 payload
[0] == WLAN_RRM_RADIO_MEASUREMENT_REQUEST
) {
3584 wpas_rrm_handle_radio_measurement_request(wpa_s
, mgmt
->sa
,
3591 if (category
== WLAN_ACTION_RADIO_MEASUREMENT
&&
3592 payload
[0] == WLAN_RRM_NEIGHBOR_REPORT_RESPONSE
) {
3593 wpas_rrm_process_neighbor_rep(wpa_s
, payload
+ 1, plen
- 1);
3597 if (category
== WLAN_ACTION_RADIO_MEASUREMENT
&&
3598 payload
[0] == WLAN_RRM_LINK_MEASUREMENT_REQUEST
) {
3599 wpas_rrm_handle_link_measurement_request(wpa_s
, mgmt
->sa
,
3600 payload
+ 1, plen
- 1,
3606 if (mgmt
->u
.action
.category
== WLAN_ACTION_FST
&& wpa_s
->fst
) {
3607 fst_rx_action(wpa_s
->fst
, mgmt
, len
);
3610 #endif /* CONFIG_FST */
3613 if (category
== WLAN_ACTION_PUBLIC
&& plen
>= 5 &&
3614 payload
[0] == WLAN_PA_VENDOR_SPECIFIC
&&
3615 WPA_GET_BE24(&payload
[1]) == OUI_WFA
&&
3616 payload
[4] == DPP_OUI_TYPE
) {
3619 wpas_dpp_rx_action(wpa_s
, mgmt
->sa
, payload
, plen
, freq
);
3622 #endif /* CONFIG_DPP */
3624 wpas_p2p_rx_action(wpa_s
, mgmt
->da
, mgmt
->sa
, mgmt
->bssid
,
3625 category
, payload
, plen
, freq
);
3627 mesh_mpm_action_rx(wpa_s
, mgmt
, len
);
3631 static void wpa_supplicant_notify_avoid_freq(struct wpa_supplicant
*wpa_s
,
3632 union wpa_event_data
*event
)
3634 struct wpa_freq_range_list
*list
;
3637 list
= &event
->freq_range
;
3640 str
= freq_range_list_str(list
);
3641 wpa_msg(wpa_s
, MSG_INFO
, WPA_EVENT_AVOID_FREQ
"ranges=%s",
3645 if (freq_range_list_parse(&wpa_s
->global
->p2p_go_avoid_freq
, str
)) {
3646 wpa_dbg(wpa_s
, MSG_ERROR
, "%s: Failed to parse freq range",
3649 wpa_dbg(wpa_s
, MSG_DEBUG
, "P2P: Update channel list based on frequency avoid event");
3652 * The update channel flow will also take care of moving a GO
3653 * from the unsafe frequency if needed.
3655 wpas_p2p_update_channel_list(wpa_s
,
3656 WPAS_P2P_CHANNEL_UPDATE_AVOID
);
3658 #endif /* CONFIG_P2P */
3664 static void wpa_supplicant_event_assoc_auth(struct wpa_supplicant
*wpa_s
,
3665 union wpa_event_data
*data
)
3667 wpa_dbg(wpa_s
, MSG_DEBUG
,
3668 "Connection authorized by device, previous state %d",
3670 if (wpa_s
->wpa_state
== WPA_ASSOCIATED
) {
3671 wpa_supplicant_cancel_auth_timeout(wpa_s
);
3672 wpa_supplicant_set_state(wpa_s
, WPA_COMPLETED
);
3673 eapol_sm_notify_portValid(wpa_s
->eapol
, TRUE
);
3674 eapol_sm_notify_eap_success(wpa_s
->eapol
, TRUE
);
3676 wpa_sm_set_ptk_kck_kek(wpa_s
->wpa
, data
->assoc_info
.ptk_kck
,
3677 data
->assoc_info
.ptk_kck_len
,
3678 data
->assoc_info
.ptk_kek
,
3679 data
->assoc_info
.ptk_kek_len
);
3681 if (wpa_s
->auth_alg
== WPA_AUTH_ALG_FILS
) {
3682 struct wpa_bss
*bss
= wpa_bss_get_bssid(wpa_s
, wpa_s
->bssid
);
3683 const u8
*fils_cache_id
= wpa_bss_get_fils_cache_id(bss
);
3685 /* Update ERP next sequence number */
3686 eapol_sm_update_erp_next_seq_num(
3687 wpa_s
->eapol
, data
->assoc_info
.fils_erp_next_seq_num
);
3689 if (data
->assoc_info
.fils_pmk
&& data
->assoc_info
.fils_pmkid
) {
3690 /* Add the new PMK and PMKID to the PMKSA cache */
3691 wpa_sm_pmksa_cache_add(wpa_s
->wpa
,
3692 data
->assoc_info
.fils_pmk
,
3693 data
->assoc_info
.fils_pmk_len
,
3694 data
->assoc_info
.fils_pmkid
,
3695 wpa_s
->bssid
, fils_cache_id
);
3696 } else if (data
->assoc_info
.fils_pmkid
) {
3697 /* Update the current PMKSA used for this connection */
3698 pmksa_cache_set_current(wpa_s
->wpa
,
3699 data
->assoc_info
.fils_pmkid
,
3700 NULL
, NULL
, 0, NULL
);
3703 wpa_sm_set_rx_replay_ctr(wpa_s
->wpa
,
3704 data
->assoc_info
.key_replay_ctr
);
3706 #else /* CONFIG_FILS */
3707 wpa_sm_set_rx_replay_ctr(wpa_s
->wpa
, data
->assoc_info
.key_replay_ctr
);
3708 #endif /* CONFIG_FILS */
3712 void wpa_supplicant_event(void *ctx
, enum wpa_event_type event
,
3713 union wpa_event_data
*data
)
3715 struct wpa_supplicant
*wpa_s
= ctx
;
3718 if (wpa_s
->wpa_state
== WPA_INTERFACE_DISABLED
&&
3719 event
!= EVENT_INTERFACE_ENABLED
&&
3720 event
!= EVENT_INTERFACE_STATUS
&&
3721 event
!= EVENT_SCAN_RESULTS
&&
3722 event
!= EVENT_SCHED_SCAN_STOPPED
) {
3723 wpa_dbg(wpa_s
, MSG_DEBUG
,
3724 "Ignore event %s (%d) while interface is disabled",
3725 event_to_string(event
), event
);
3729 #ifndef CONFIG_NO_STDOUT_DEBUG
3731 int level
= MSG_DEBUG
;
3733 if (event
== EVENT_RX_MGMT
&& data
->rx_mgmt
.frame_len
>= 24) {
3734 const struct ieee80211_hdr
*hdr
;
3736 hdr
= (const struct ieee80211_hdr
*) data
->rx_mgmt
.frame
;
3737 fc
= le_to_host16(hdr
->frame_control
);
3738 if (WLAN_FC_GET_TYPE(fc
) == WLAN_FC_TYPE_MGMT
&&
3739 WLAN_FC_GET_STYPE(fc
) == WLAN_FC_STYPE_BEACON
)
3740 level
= MSG_EXCESSIVE
;
3743 wpa_dbg(wpa_s
, level
, "Event %s (%d) received",
3744 event_to_string(event
), event
);
3746 #endif /* CONFIG_NO_STDOUT_DEBUG */
3751 if (!wpas_fst_update_mbie(wpa_s
, data
->auth
.ies
,
3752 data
->auth
.ies_len
))
3753 wpa_printf(MSG_DEBUG
,
3754 "FST: MB IEs updated from auth IE");
3755 #endif /* CONFIG_FST */
3756 sme_event_auth(wpa_s
, data
);
3759 #ifdef CONFIG_TESTING_OPTIONS
3760 if (wpa_s
->ignore_auth_resp
) {
3761 wpa_printf(MSG_INFO
,
3762 "EVENT_ASSOC - ignore_auth_resp active!");
3765 #endif /* CONFIG_TESTING_OPTIONS */
3766 wpa_supplicant_event_assoc(wpa_s
, data
);
3768 (data
->assoc_info
.authorized
||
3769 (!(wpa_s
->drv_flags
& WPA_DRIVER_FLAGS_SME
) &&
3770 wpa_fils_is_completed(wpa_s
->wpa
))))
3771 wpa_supplicant_event_assoc_auth(wpa_s
, data
);
3773 wpa_msg(wpa_s
, MSG_INFO
,
3774 WPA_EVENT_SUBNET_STATUS_UPDATE
"status=%u",
3775 data
->assoc_info
.subnet_status
);
3778 case EVENT_DISASSOC
:
3779 wpas_event_disassoc(wpa_s
,
3780 data
? &data
->disassoc_info
: NULL
);
3783 #ifdef CONFIG_TESTING_OPTIONS
3784 if (wpa_s
->ignore_auth_resp
) {
3785 wpa_printf(MSG_INFO
,
3786 "EVENT_DEAUTH - ignore_auth_resp active!");
3789 #endif /* CONFIG_TESTING_OPTIONS */
3790 wpas_event_deauth(wpa_s
,
3791 data
? &data
->deauth_info
: NULL
);
3793 case EVENT_MICHAEL_MIC_FAILURE
:
3794 wpa_supplicant_event_michael_mic_failure(wpa_s
, data
);
3796 #ifndef CONFIG_NO_SCAN_PROCESSING
3797 case EVENT_SCAN_STARTED
:
3798 if (wpa_s
->own_scan_requested
||
3799 (data
&& !data
->scan_info
.external_scan
)) {
3800 struct os_reltime diff
;
3802 os_get_reltime(&wpa_s
->scan_start_time
);
3803 os_reltime_sub(&wpa_s
->scan_start_time
,
3804 &wpa_s
->scan_trigger_time
, &diff
);
3805 wpa_dbg(wpa_s
, MSG_DEBUG
, "Own scan request started a scan in %ld.%06ld seconds",
3806 diff
.sec
, diff
.usec
);
3807 wpa_s
->own_scan_requested
= 0;
3808 wpa_s
->own_scan_running
= 1;
3809 if (wpa_s
->last_scan_req
== MANUAL_SCAN_REQ
&&
3810 wpa_s
->manual_scan_use_id
) {
3811 wpa_msg_ctrl(wpa_s
, MSG_INFO
,
3812 WPA_EVENT_SCAN_STARTED
"id=%u",
3813 wpa_s
->manual_scan_id
);
3815 wpa_msg_ctrl(wpa_s
, MSG_INFO
,
3816 WPA_EVENT_SCAN_STARTED
);
3819 wpa_dbg(wpa_s
, MSG_DEBUG
, "External program started a scan");
3820 wpa_s
->radio
->external_scan_running
= 1;
3821 wpa_msg_ctrl(wpa_s
, MSG_INFO
, WPA_EVENT_SCAN_STARTED
);
3824 case EVENT_SCAN_RESULTS
:
3825 if (wpa_s
->wpa_state
== WPA_INTERFACE_DISABLED
) {
3826 wpa_s
->scan_res_handler
= NULL
;
3827 wpa_s
->own_scan_running
= 0;
3828 wpa_s
->radio
->external_scan_running
= 0;
3829 wpa_s
->last_scan_req
= NORMAL_SCAN_REQ
;
3833 if (!(data
&& data
->scan_info
.external_scan
) &&
3834 os_reltime_initialized(&wpa_s
->scan_start_time
)) {
3835 struct os_reltime now
, diff
;
3836 os_get_reltime(&now
);
3837 os_reltime_sub(&now
, &wpa_s
->scan_start_time
, &diff
);
3838 wpa_s
->scan_start_time
.sec
= 0;
3839 wpa_s
->scan_start_time
.usec
= 0;
3840 wpa_dbg(wpa_s
, MSG_DEBUG
, "Scan completed in %ld.%06ld seconds",
3841 diff
.sec
, diff
.usec
);
3843 if (wpa_supplicant_event_scan_results(wpa_s
, data
))
3844 break; /* interface may have been removed */
3845 if (!(data
&& data
->scan_info
.external_scan
))
3846 wpa_s
->own_scan_running
= 0;
3847 if (data
&& data
->scan_info
.nl_scan_event
)
3848 wpa_s
->radio
->external_scan_running
= 0;
3849 radio_work_check_next(wpa_s
);
3851 #endif /* CONFIG_NO_SCAN_PROCESSING */
3852 case EVENT_ASSOCINFO
:
3853 wpa_supplicant_event_associnfo(wpa_s
, data
);
3855 case EVENT_INTERFACE_STATUS
:
3856 wpa_supplicant_event_interface_status(wpa_s
, data
);
3858 case EVENT_PMKID_CANDIDATE
:
3859 wpa_supplicant_event_pmkid_candidate(wpa_s
, data
);
3861 #ifdef CONFIG_PEERKEY
3862 case EVENT_STKSTART
:
3863 wpa_supplicant_event_stkstart(wpa_s
, data
);
3865 #endif /* CONFIG_PEERKEY */
3868 wpa_supplicant_event_tdls(wpa_s
, data
);
3870 #endif /* CONFIG_TDLS */
3873 wpa_supplicant_event_wnm(wpa_s
, data
);
3875 #endif /* CONFIG_WNM */
3876 #ifdef CONFIG_IEEE80211R
3877 case EVENT_FT_RESPONSE
:
3878 wpa_supplicant_event_ft_response(wpa_s
, data
);
3880 #endif /* CONFIG_IEEE80211R */
3881 #ifdef CONFIG_IBSS_RSN
3882 case EVENT_IBSS_RSN_START
:
3883 wpa_supplicant_event_ibss_rsn_start(wpa_s
, data
);
3885 #endif /* CONFIG_IBSS_RSN */
3886 case EVENT_ASSOC_REJECT
:
3887 if (data
->assoc_reject
.bssid
)
3888 wpa_msg(wpa_s
, MSG_INFO
, WPA_EVENT_ASSOC_REJECT
3889 "bssid=" MACSTR
" status_code=%u%s%s%s",
3890 MAC2STR(data
->assoc_reject
.bssid
),
3891 data
->assoc_reject
.status_code
,
3892 data
->assoc_reject
.timed_out
? " timeout" : "",
3893 data
->assoc_reject
.timeout_reason
? "=" : "",
3894 data
->assoc_reject
.timeout_reason
?
3895 data
->assoc_reject
.timeout_reason
: "");
3897 wpa_msg(wpa_s
, MSG_INFO
, WPA_EVENT_ASSOC_REJECT
3898 "status_code=%u%s%s%s",
3899 data
->assoc_reject
.status_code
,
3900 data
->assoc_reject
.timed_out
? " timeout" : "",
3901 data
->assoc_reject
.timeout_reason
? "=" : "",
3902 data
->assoc_reject
.timeout_reason
?
3903 data
->assoc_reject
.timeout_reason
: "");
3904 wpa_s
->assoc_status_code
= data
->assoc_reject
.status_code
;
3905 wpas_notify_assoc_status_code(wpa_s
);
3906 if (wpa_s
->drv_flags
& WPA_DRIVER_FLAGS_SME
)
3907 sme_event_assoc_reject(wpa_s
, data
);
3909 const u8
*bssid
= data
->assoc_reject
.bssid
;
3912 /* Update ERP next sequence number */
3913 if (wpa_s
->auth_alg
== WPA_AUTH_ALG_FILS
)
3914 eapol_sm_update_erp_next_seq_num(
3916 data
->assoc_reject
.fils_erp_next_seq_num
);
3917 #endif /* CONFIG_FILS */
3919 if (bssid
== NULL
|| is_zero_ether_addr(bssid
))
3920 bssid
= wpa_s
->pending_bssid
;
3921 wpas_connection_failed(wpa_s
, bssid
);
3922 wpa_supplicant_mark_disassoc(wpa_s
);
3925 case EVENT_AUTH_TIMED_OUT
:
3926 /* It is possible to get this event from earlier connection */
3927 if (wpa_s
->current_ssid
&&
3928 wpa_s
->current_ssid
->mode
== WPAS_MODE_MESH
) {
3929 wpa_dbg(wpa_s
, MSG_DEBUG
,
3930 "Ignore AUTH_TIMED_OUT in mesh configuration");
3933 if (wpa_s
->drv_flags
& WPA_DRIVER_FLAGS_SME
)
3934 sme_event_auth_timed_out(wpa_s
, data
);
3936 case EVENT_ASSOC_TIMED_OUT
:
3937 /* It is possible to get this event from earlier connection */
3938 if (wpa_s
->current_ssid
&&
3939 wpa_s
->current_ssid
->mode
== WPAS_MODE_MESH
) {
3940 wpa_dbg(wpa_s
, MSG_DEBUG
,
3941 "Ignore ASSOC_TIMED_OUT in mesh configuration");
3944 if (wpa_s
->drv_flags
& WPA_DRIVER_FLAGS_SME
)
3945 sme_event_assoc_timed_out(wpa_s
, data
);
3947 case EVENT_TX_STATUS
:
3948 wpa_dbg(wpa_s
, MSG_DEBUG
, "EVENT_TX_STATUS dst=" MACSTR
3949 " type=%d stype=%d",
3950 MAC2STR(data
->tx_status
.dst
),
3951 data
->tx_status
.type
, data
->tx_status
.stype
);
3953 if (wpa_s
->ap_iface
== NULL
) {
3954 #ifdef CONFIG_OFFCHANNEL
3955 if (data
->tx_status
.type
== WLAN_FC_TYPE_MGMT
&&
3956 data
->tx_status
.stype
== WLAN_FC_STYPE_ACTION
)
3957 offchannel_send_action_tx_status(
3958 wpa_s
, data
->tx_status
.dst
,
3959 data
->tx_status
.data
,
3960 data
->tx_status
.data_len
,
3961 data
->tx_status
.ack
?
3962 OFFCHANNEL_SEND_ACTION_SUCCESS
:
3963 OFFCHANNEL_SEND_ACTION_NO_ACK
);
3964 #endif /* CONFIG_OFFCHANNEL */
3967 #endif /* CONFIG_AP */
3968 #ifdef CONFIG_OFFCHANNEL
3969 wpa_dbg(wpa_s
, MSG_DEBUG
, "EVENT_TX_STATUS pending_dst="
3970 MACSTR
, MAC2STR(wpa_s
->p2pdev
->pending_action_dst
));
3972 * Catch TX status events for Action frames we sent via group
3973 * interface in GO mode, or via standalone AP interface.
3974 * Note, wpa_s->p2pdev will be the same as wpa_s->parent,
3975 * except when the primary interface is used as a GO interface
3976 * (for drivers which do not have group interface concurrency)
3978 if (data
->tx_status
.type
== WLAN_FC_TYPE_MGMT
&&
3979 data
->tx_status
.stype
== WLAN_FC_STYPE_ACTION
&&
3980 os_memcmp(wpa_s
->p2pdev
->pending_action_dst
,
3981 data
->tx_status
.dst
, ETH_ALEN
) == 0) {
3982 offchannel_send_action_tx_status(
3983 wpa_s
->p2pdev
, data
->tx_status
.dst
,
3984 data
->tx_status
.data
,
3985 data
->tx_status
.data_len
,
3986 data
->tx_status
.ack
?
3987 OFFCHANNEL_SEND_ACTION_SUCCESS
:
3988 OFFCHANNEL_SEND_ACTION_NO_ACK
);
3991 #endif /* CONFIG_OFFCHANNEL */
3993 switch (data
->tx_status
.type
) {
3994 case WLAN_FC_TYPE_MGMT
:
3995 ap_mgmt_tx_cb(wpa_s
, data
->tx_status
.data
,
3996 data
->tx_status
.data_len
,
3997 data
->tx_status
.stype
,
3998 data
->tx_status
.ack
);
4000 case WLAN_FC_TYPE_DATA
:
4001 ap_tx_status(wpa_s
, data
->tx_status
.dst
,
4002 data
->tx_status
.data
,
4003 data
->tx_status
.data_len
,
4004 data
->tx_status
.ack
);
4007 #endif /* CONFIG_AP */
4010 case EVENT_EAPOL_TX_STATUS
:
4011 ap_eapol_tx_status(wpa_s
, data
->eapol_tx_status
.dst
,
4012 data
->eapol_tx_status
.data
,
4013 data
->eapol_tx_status
.data_len
,
4014 data
->eapol_tx_status
.ack
);
4016 case EVENT_DRIVER_CLIENT_POLL_OK
:
4017 ap_client_poll_ok(wpa_s
, data
->client_poll
.addr
);
4019 case EVENT_RX_FROM_UNKNOWN
:
4020 if (wpa_s
->ap_iface
== NULL
)
4022 ap_rx_from_unknown_sta(wpa_s
, data
->rx_from_unknown
.addr
,
4023 data
->rx_from_unknown
.wds
);
4025 case EVENT_CH_SWITCH
:
4026 if (!data
|| !wpa_s
->current_ssid
)
4029 wpa_msg(wpa_s
, MSG_INFO
, WPA_EVENT_CHANNEL_SWITCH
4030 "freq=%d ht_enabled=%d ch_offset=%d ch_width=%s cf1=%d cf2=%d",
4031 data
->ch_switch
.freq
,
4032 data
->ch_switch
.ht_enabled
,
4033 data
->ch_switch
.ch_offset
,
4034 channel_width_to_string(data
->ch_switch
.ch_width
),
4035 data
->ch_switch
.cf1
,
4036 data
->ch_switch
.cf2
);
4038 wpa_s
->assoc_freq
= data
->ch_switch
.freq
;
4039 wpa_s
->current_ssid
->frequency
= data
->ch_switch
.freq
;
4041 if (wpa_s
->current_ssid
->mode
== WPAS_MODE_AP
||
4042 wpa_s
->current_ssid
->mode
== WPAS_MODE_P2P_GO
||
4043 wpa_s
->current_ssid
->mode
==
4044 WPAS_MODE_P2P_GROUP_FORMATION
) {
4045 wpas_ap_ch_switch(wpa_s
, data
->ch_switch
.freq
,
4046 data
->ch_switch
.ht_enabled
,
4047 data
->ch_switch
.ch_offset
,
4048 data
->ch_switch
.ch_width
,
4049 data
->ch_switch
.cf1
,
4050 data
->ch_switch
.cf2
);
4053 wpas_p2p_update_channel_list(wpa_s
, WPAS_P2P_CHANNEL_UPDATE_CS
);
4056 case EVENT_DFS_RADAR_DETECTED
:
4058 wpas_event_dfs_radar_detected(wpa_s
, &data
->dfs_event
);
4060 case EVENT_DFS_CAC_STARTED
:
4062 wpas_event_dfs_cac_started(wpa_s
, &data
->dfs_event
);
4064 case EVENT_DFS_CAC_FINISHED
:
4066 wpas_event_dfs_cac_finished(wpa_s
, &data
->dfs_event
);
4068 case EVENT_DFS_CAC_ABORTED
:
4070 wpas_event_dfs_cac_aborted(wpa_s
, &data
->dfs_event
);
4072 case EVENT_DFS_NOP_FINISHED
:
4074 wpas_event_dfs_cac_nop_finished(wpa_s
,
4077 #endif /* NEED_AP_MLME */
4078 #endif /* CONFIG_AP */
4079 case EVENT_RX_MGMT
: {
4081 const struct ieee80211_mgmt
*mgmt
;
4083 #ifdef CONFIG_TESTING_OPTIONS
4084 if (wpa_s
->ext_mgmt_frame_handling
) {
4085 struct rx_mgmt
*rx
= &data
->rx_mgmt
;
4086 size_t hex_len
= 2 * rx
->frame_len
+ 1;
4087 char *hex
= os_malloc(hex_len
);
4089 wpa_snprintf_hex(hex
, hex_len
,
4090 rx
->frame
, rx
->frame_len
);
4091 wpa_msg(wpa_s
, MSG_INFO
, "MGMT-RX freq=%d datarate=%u ssi_signal=%d %s",
4092 rx
->freq
, rx
->datarate
, rx
->ssi_signal
,
4098 #endif /* CONFIG_TESTING_OPTIONS */
4100 mgmt
= (const struct ieee80211_mgmt
*)
4101 data
->rx_mgmt
.frame
;
4102 fc
= le_to_host16(mgmt
->frame_control
);
4103 stype
= WLAN_FC_GET_STYPE(fc
);
4106 if (wpa_s
->ap_iface
== NULL
) {
4107 #endif /* CONFIG_AP */
4109 if (stype
== WLAN_FC_STYPE_PROBE_REQ
&&
4110 data
->rx_mgmt
.frame_len
> IEEE80211_HDRLEN
) {
4111 const u8
*src
= mgmt
->sa
;
4115 ie
= data
->rx_mgmt
.frame
+ IEEE80211_HDRLEN
;
4116 ie_len
= data
->rx_mgmt
.frame_len
-
4118 wpas_p2p_probe_req_rx(
4119 wpa_s
, src
, mgmt
->da
,
4120 mgmt
->bssid
, ie
, ie_len
,
4122 data
->rx_mgmt
.ssi_signal
);
4125 #endif /* CONFIG_P2P */
4126 #ifdef CONFIG_IBSS_RSN
4127 if (wpa_s
->current_ssid
&&
4128 wpa_s
->current_ssid
->mode
== WPAS_MODE_IBSS
&&
4129 stype
== WLAN_FC_STYPE_AUTH
&&
4130 data
->rx_mgmt
.frame_len
>= 30) {
4131 wpa_supplicant_event_ibss_auth(wpa_s
, data
);
4134 #endif /* CONFIG_IBSS_RSN */
4136 if (stype
== WLAN_FC_STYPE_ACTION
) {
4137 wpas_event_rx_mgmt_action(
4138 wpa_s
, data
->rx_mgmt
.frame
,
4139 data
->rx_mgmt
.frame_len
,
4141 data
->rx_mgmt
.ssi_signal
);
4146 mesh_mpm_mgmt_rx(wpa_s
, &data
->rx_mgmt
);
4150 wpa_dbg(wpa_s
, MSG_DEBUG
, "AP: ignore received "
4151 "management frame in non-AP mode");
4156 if (stype
== WLAN_FC_STYPE_PROBE_REQ
&&
4157 data
->rx_mgmt
.frame_len
> IEEE80211_HDRLEN
) {
4161 ie
= data
->rx_mgmt
.frame
+ IEEE80211_HDRLEN
;
4162 ie_len
= data
->rx_mgmt
.frame_len
- IEEE80211_HDRLEN
;
4164 wpas_notify_preq(wpa_s
, mgmt
->sa
, mgmt
->da
,
4165 mgmt
->bssid
, ie
, ie_len
,
4166 data
->rx_mgmt
.ssi_signal
);
4169 ap_mgmt_rx(wpa_s
, &data
->rx_mgmt
);
4170 #endif /* CONFIG_AP */
4173 case EVENT_RX_PROBE_REQ
:
4174 if (data
->rx_probe_req
.sa
== NULL
||
4175 data
->rx_probe_req
.ie
== NULL
)
4178 if (wpa_s
->ap_iface
) {
4179 hostapd_probe_req_rx(wpa_s
->ap_iface
->bss
[0],
4180 data
->rx_probe_req
.sa
,
4181 data
->rx_probe_req
.da
,
4182 data
->rx_probe_req
.bssid
,
4183 data
->rx_probe_req
.ie
,
4184 data
->rx_probe_req
.ie_len
,
4185 data
->rx_probe_req
.ssi_signal
);
4188 #endif /* CONFIG_AP */
4189 wpas_p2p_probe_req_rx(wpa_s
, data
->rx_probe_req
.sa
,
4190 data
->rx_probe_req
.da
,
4191 data
->rx_probe_req
.bssid
,
4192 data
->rx_probe_req
.ie
,
4193 data
->rx_probe_req
.ie_len
,
4195 data
->rx_probe_req
.ssi_signal
);
4197 case EVENT_REMAIN_ON_CHANNEL
:
4198 #ifdef CONFIG_OFFCHANNEL
4199 offchannel_remain_on_channel_cb(
4200 wpa_s
, data
->remain_on_channel
.freq
,
4201 data
->remain_on_channel
.duration
);
4202 #endif /* CONFIG_OFFCHANNEL */
4203 wpas_p2p_remain_on_channel_cb(
4204 wpa_s
, data
->remain_on_channel
.freq
,
4205 data
->remain_on_channel
.duration
);
4207 case EVENT_CANCEL_REMAIN_ON_CHANNEL
:
4208 #ifdef CONFIG_OFFCHANNEL
4209 offchannel_cancel_remain_on_channel_cb(
4210 wpa_s
, data
->remain_on_channel
.freq
);
4211 #endif /* CONFIG_OFFCHANNEL */
4212 wpas_p2p_cancel_remain_on_channel_cb(
4213 wpa_s
, data
->remain_on_channel
.freq
);
4215 wpas_dpp_cancel_remain_on_channel_cb(
4216 wpa_s
, data
->remain_on_channel
.freq
);
4217 #endif /* CONFIG_DPP */
4219 case EVENT_EAPOL_RX
:
4220 wpa_supplicant_rx_eapol(wpa_s
, data
->eapol_rx
.src
,
4221 data
->eapol_rx
.data
,
4222 data
->eapol_rx
.data_len
);
4224 case EVENT_SIGNAL_CHANGE
:
4225 wpa_msg(wpa_s
, MSG_INFO
, WPA_EVENT_SIGNAL_CHANGE
4226 "above=%d signal=%d noise=%d txrate=%d",
4227 data
->signal_change
.above_threshold
,
4228 data
->signal_change
.current_signal
,
4229 data
->signal_change
.current_noise
,
4230 data
->signal_change
.current_txrate
);
4231 wpa_bss_update_level(wpa_s
->current_bss
,
4232 data
->signal_change
.current_signal
);
4233 bgscan_notify_signal_change(
4234 wpa_s
, data
->signal_change
.above_threshold
,
4235 data
->signal_change
.current_signal
,
4236 data
->signal_change
.current_noise
,
4237 data
->signal_change
.current_txrate
);
4239 case EVENT_INTERFACE_ENABLED
:
4240 wpa_dbg(wpa_s
, MSG_DEBUG
, "Interface was enabled");
4241 if (wpa_s
->wpa_state
== WPA_INTERFACE_DISABLED
) {
4242 wpa_supplicant_update_mac_addr(wpa_s
);
4243 if (wpa_s
->p2p_mgmt
) {
4244 wpa_supplicant_set_state(wpa_s
,
4250 if (!wpa_s
->ap_iface
) {
4251 wpa_supplicant_set_state(wpa_s
,
4253 wpa_s
->scan_req
= NORMAL_SCAN_REQ
;
4254 wpa_supplicant_req_scan(wpa_s
, 0, 0);
4256 wpa_supplicant_set_state(wpa_s
,
4258 #else /* CONFIG_AP */
4259 wpa_supplicant_set_state(wpa_s
, WPA_DISCONNECTED
);
4260 wpa_supplicant_req_scan(wpa_s
, 0, 0);
4261 #endif /* CONFIG_AP */
4264 case EVENT_INTERFACE_DISABLED
:
4265 wpa_dbg(wpa_s
, MSG_DEBUG
, "Interface was disabled");
4267 if (wpa_s
->p2p_group_interface
== P2P_GROUP_INTERFACE_GO
||
4268 (wpa_s
->current_ssid
&& wpa_s
->current_ssid
->p2p_group
&&
4269 wpa_s
->current_ssid
->mode
== WPAS_MODE_P2P_GO
)) {
4271 * Mark interface disabled if this happens to end up not
4272 * being removed as a separate P2P group interface.
4274 wpa_supplicant_set_state(wpa_s
, WPA_INTERFACE_DISABLED
);
4276 * The interface was externally disabled. Remove
4277 * it assuming an external entity will start a
4278 * new session if needed.
4280 if (wpa_s
->current_ssid
&&
4281 wpa_s
->current_ssid
->p2p_group
)
4282 wpas_p2p_interface_unavailable(wpa_s
);
4284 wpas_p2p_disconnect(wpa_s
);
4286 * wpa_s instance may have been freed, so must not use
4291 if (wpa_s
->p2p_scan_work
&& wpa_s
->global
->p2p
&&
4292 p2p_in_progress(wpa_s
->global
->p2p
) > 1) {
4293 /* This radio work will be cancelled, so clear P2P
4296 p2p_stop_find(wpa_s
->global
->p2p
);
4298 #endif /* CONFIG_P2P */
4300 if (wpa_s
->wpa_state
>= WPA_AUTHENTICATING
) {
4302 * Indicate disconnection to keep ctrl_iface events
4305 wpa_supplicant_event_disassoc(
4306 wpa_s
, WLAN_REASON_DEAUTH_LEAVING
, 1);
4308 wpa_supplicant_mark_disassoc(wpa_s
);
4309 wpa_bss_flush(wpa_s
);
4310 radio_remove_works(wpa_s
, NULL
, 0);
4312 wpa_supplicant_set_state(wpa_s
, WPA_INTERFACE_DISABLED
);
4314 case EVENT_CHANNEL_LIST_CHANGED
:
4315 wpa_supplicant_update_channel_list(
4316 wpa_s
, &data
->channel_list_changed
);
4318 case EVENT_INTERFACE_UNAVAILABLE
:
4319 wpas_p2p_interface_unavailable(wpa_s
);
4321 case EVENT_BEST_CHANNEL
:
4322 wpa_dbg(wpa_s
, MSG_DEBUG
, "Best channel event received "
4324 data
->best_chan
.freq_24
, data
->best_chan
.freq_5
,
4325 data
->best_chan
.freq_overall
);
4326 wpa_s
->best_24_freq
= data
->best_chan
.freq_24
;
4327 wpa_s
->best_5_freq
= data
->best_chan
.freq_5
;
4328 wpa_s
->best_overall_freq
= data
->best_chan
.freq_overall
;
4329 wpas_p2p_update_best_channels(wpa_s
, data
->best_chan
.freq_24
,
4330 data
->best_chan
.freq_5
,
4331 data
->best_chan
.freq_overall
);
4333 case EVENT_UNPROT_DEAUTH
:
4334 wpa_supplicant_event_unprot_deauth(wpa_s
,
4335 &data
->unprot_deauth
);
4337 case EVENT_UNPROT_DISASSOC
:
4338 wpa_supplicant_event_unprot_disassoc(wpa_s
,
4339 &data
->unprot_disassoc
);
4341 case EVENT_STATION_LOW_ACK
:
4343 if (wpa_s
->ap_iface
&& data
)
4344 hostapd_event_sta_low_ack(wpa_s
->ap_iface
->bss
[0],
4345 data
->low_ack
.addr
);
4346 #endif /* CONFIG_AP */
4349 wpa_tdls_disable_unreachable_link(wpa_s
->wpa
,
4350 data
->low_ack
.addr
);
4351 #endif /* CONFIG_TDLS */
4353 case EVENT_IBSS_PEER_LOST
:
4354 #ifdef CONFIG_IBSS_RSN
4355 ibss_rsn_stop(wpa_s
->ibss_rsn
, data
->ibss_peer_lost
.peer
);
4356 #endif /* CONFIG_IBSS_RSN */
4358 case EVENT_DRIVER_GTK_REKEY
:
4359 if (os_memcmp(data
->driver_gtk_rekey
.bssid
,
4360 wpa_s
->bssid
, ETH_ALEN
))
4364 wpa_sm_update_replay_ctr(wpa_s
->wpa
,
4365 data
->driver_gtk_rekey
.replay_ctr
);
4367 case EVENT_SCHED_SCAN_STOPPED
:
4368 wpa_s
->sched_scanning
= 0;
4369 resched
= wpa_s
->scanning
&& wpas_scan_scheduled(wpa_s
);
4370 wpa_supplicant_notify_scanning(wpa_s
, 0);
4372 if (wpa_s
->wpa_state
== WPA_INTERFACE_DISABLED
)
4376 * If the driver stopped scanning without being requested to,
4377 * request a new scan to continue scanning for networks.
4379 if (!wpa_s
->sched_scan_stop_req
&&
4380 wpa_s
->wpa_state
== WPA_SCANNING
) {
4381 wpa_dbg(wpa_s
, MSG_DEBUG
,
4382 "Restart scanning after unexpected sched_scan stop event");
4383 wpa_supplicant_req_scan(wpa_s
, 1, 0);
4387 wpa_s
->sched_scan_stop_req
= 0;
4390 * Start a new sched scan to continue searching for more SSIDs
4391 * either if timed out or PNO schedule scan is pending.
4393 if (wpa_s
->sched_scan_timed_out
) {
4394 wpa_supplicant_req_sched_scan(wpa_s
);
4395 } else if (wpa_s
->pno_sched_pending
) {
4396 wpa_s
->pno_sched_pending
= 0;
4397 wpas_start_pno(wpa_s
);
4398 } else if (resched
) {
4399 wpa_supplicant_req_scan(wpa_s
, 0, 0);
4403 case EVENT_WPS_BUTTON_PUSHED
:
4405 wpas_wps_start_pbc(wpa_s
, NULL
, 0);
4406 #endif /* CONFIG_WPS */
4408 case EVENT_AVOID_FREQUENCIES
:
4409 wpa_supplicant_notify_avoid_freq(wpa_s
, data
);
4411 case EVENT_CONNECT_FAILED_REASON
:
4413 if (!wpa_s
->ap_iface
|| !data
)
4415 hostapd_event_connect_failed_reason(
4416 wpa_s
->ap_iface
->bss
[0],
4417 data
->connect_failed_reason
.addr
,
4418 data
->connect_failed_reason
.code
);
4419 #endif /* CONFIG_AP */
4421 case EVENT_NEW_PEER_CANDIDATE
:
4423 if (!wpa_s
->ifmsh
|| !data
)
4425 wpa_mesh_notify_peer(wpa_s
, data
->mesh_peer
.peer
,
4426 data
->mesh_peer
.ies
,
4427 data
->mesh_peer
.ie_len
);
4428 #endif /* CONFIG_MESH */
4432 if (!wpa_s
->ap_iface
)
4434 hostapd_event_get_survey(wpa_s
->ap_iface
,
4435 &data
->survey_results
);
4436 #endif /* CONFIG_AP */
4438 case EVENT_ACS_CHANNEL_SELECTED
:
4441 if (!wpa_s
->ap_iface
)
4443 hostapd_acs_channel_selected(wpa_s
->ap_iface
->bss
[0],
4444 &data
->acs_selected_channels
);
4445 #endif /* CONFIG_ACS */
4446 #endif /* CONFIG_AP */
4448 case EVENT_P2P_LO_STOP
:
4450 wpa_s
->p2p_lo_started
= 0;
4451 wpa_msg(wpa_s
, MSG_INFO
, P2P_EVENT_LISTEN_OFFLOAD_STOP
4452 P2P_LISTEN_OFFLOAD_STOP_REASON
"reason=%d",
4453 data
->p2p_lo_stop
.reason_code
);
4454 #endif /* CONFIG_P2P */
4456 case EVENT_BEACON_LOSS
:
4457 if (!wpa_s
->current_bss
|| !wpa_s
->current_ssid
)
4459 wpa_msg(wpa_s
, MSG_INFO
, WPA_EVENT_BEACON_LOSS
);
4460 bgscan_notify_beacon_loss(wpa_s
);
4463 wpa_msg(wpa_s
, MSG_INFO
, "Unknown event %d", event
);
4469 void wpa_supplicant_event_global(void *ctx
, enum wpa_event_type event
,
4470 union wpa_event_data
*data
)
4472 struct wpa_supplicant
*wpa_s
;
4474 if (event
!= EVENT_INTERFACE_STATUS
)
4477 wpa_s
= wpa_supplicant_get_iface(ctx
, data
->interface_status
.ifname
);
4478 if (wpa_s
&& wpa_s
->driver
->get_ifindex
) {
4479 unsigned int ifindex
;
4481 ifindex
= wpa_s
->driver
->get_ifindex(wpa_s
->drv_priv
);
4482 if (ifindex
!= data
->interface_status
.ifindex
) {
4483 wpa_dbg(wpa_s
, MSG_DEBUG
,
4484 "interface status ifindex %d mismatch (%d)",
4485 ifindex
, data
->interface_status
.ifindex
);
4489 #ifdef CONFIG_MATCH_IFACE
4490 else if (data
->interface_status
.ievent
== EVENT_INTERFACE_ADDED
) {
4491 struct wpa_interface
*wpa_i
;
4493 wpa_i
= wpa_supplicant_match_iface(
4494 ctx
, data
->interface_status
.ifname
);
4497 wpa_s
= wpa_supplicant_add_iface(ctx
, wpa_i
, NULL
);
4502 #endif /* CONFIG_MATCH_IFACE */
4505 wpa_supplicant_event(wpa_s
, event
, data
);