/src/hostap/wpa_supplicant/events.c
Line | Count | Source |
1 | | /* |
2 | | * WPA Supplicant - Driver event processing |
3 | | * Copyright (c) 2003-2019, Jouni Malinen <j@w1.fi> |
4 | | * |
5 | | * This software may be distributed under the terms of the BSD license. |
6 | | * See README for more details. |
7 | | */ |
8 | | |
9 | | #include "includes.h" |
10 | | |
11 | | #include "common.h" |
12 | | #include "utils/crc32.h" |
13 | | #include "eapol_supp/eapol_supp_sm.h" |
14 | | #include "rsn_supp/wpa.h" |
15 | | #include "eloop.h" |
16 | | #include "config.h" |
17 | | #include "l2_packet/l2_packet.h" |
18 | | #include "wpa_supplicant_i.h" |
19 | | #include "driver_i.h" |
20 | | #include "pcsc_funcs.h" |
21 | | #include "rsn_supp/preauth.h" |
22 | | #include "rsn_supp/pmksa_cache.h" |
23 | | #include "common/wpa_ctrl.h" |
24 | | #include "eap_peer/eap.h" |
25 | | #include "ap/hostapd.h" |
26 | | #include "ap/sta_info.h" |
27 | | #include "p2p/p2p.h" |
28 | | #include "fst/fst.h" |
29 | | #include "wnm_sta.h" |
30 | | #include "notify.h" |
31 | | #include "common/ieee802_11_defs.h" |
32 | | #include "common/ieee802_11_common.h" |
33 | | #include "common/gas_server.h" |
34 | | #include "common/dpp.h" |
35 | | #include "common/ptksa_cache.h" |
36 | | #include "crypto/random.h" |
37 | | #include "bssid_ignore.h" |
38 | | #include "wpas_glue.h" |
39 | | #include "wps_supplicant.h" |
40 | | #include "ibss_rsn.h" |
41 | | #include "sme.h" |
42 | | #include "gas_query.h" |
43 | | #include "p2p_supplicant.h" |
44 | | #include "bgscan.h" |
45 | | #include "autoscan.h" |
46 | | #include "ap.h" |
47 | | #include "bss.h" |
48 | | #include "scan.h" |
49 | | #include "offchannel.h" |
50 | | #include "interworking.h" |
51 | | #include "mesh.h" |
52 | | #include "mesh_mpm.h" |
53 | | #include "wmm_ac.h" |
54 | | #include "dpp_supplicant.h" |
55 | | #include "pr_supplicant.h" |
56 | | #include "nan_supplicant.h" |
57 | | |
58 | | |
59 | | #define MAX_OWE_TRANSITION_BSS_SELECT_COUNT 5 |
60 | | |
61 | | |
62 | | #ifndef CONFIG_NO_SCAN_PROCESSING |
63 | | static int wpas_select_network_from_last_scan(struct wpa_supplicant *wpa_s, |
64 | | int new_scan, int own_request, |
65 | | bool trigger_6ghz_scan, |
66 | | union wpa_event_data *data); |
67 | | #endif /* CONFIG_NO_SCAN_PROCESSING */ |
68 | | |
69 | | |
70 | | int wpas_temp_disabled(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid) |
71 | 0 | { |
72 | 0 | struct os_reltime now; |
73 | |
|
74 | 0 | if (ssid == NULL || ssid->disabled_until.sec == 0) |
75 | 0 | return 0; |
76 | | |
77 | 0 | os_get_reltime(&now); |
78 | 0 | if (ssid->disabled_until.sec > now.sec) |
79 | 0 | return ssid->disabled_until.sec - now.sec; |
80 | | |
81 | 0 | wpas_clear_temp_disabled(wpa_s, ssid, 0); |
82 | |
|
83 | 0 | return 0; |
84 | 0 | } |
85 | | |
86 | | |
87 | | #ifndef CONFIG_NO_SCAN_PROCESSING |
88 | | /** |
89 | | * wpas_reenabled_network_time - Time until first network is re-enabled |
90 | | * @wpa_s: Pointer to wpa_supplicant data |
91 | | * Returns: If all enabled networks are temporarily disabled, returns the time |
92 | | * (in sec) until the first network is re-enabled. Otherwise returns 0. |
93 | | * |
94 | | * This function is used in case all enabled networks are temporarily disabled, |
95 | | * in which case it returns the time (in sec) that the first network will be |
96 | | * re-enabled. The function assumes that at least one network is enabled. |
97 | | */ |
98 | | static int wpas_reenabled_network_time(struct wpa_supplicant *wpa_s) |
99 | 0 | { |
100 | 0 | struct wpa_ssid *ssid; |
101 | 0 | int disabled_for, res = 0; |
102 | |
|
103 | 0 | #ifdef CONFIG_INTERWORKING |
104 | 0 | if (wpa_s->conf->auto_interworking && wpa_s->conf->interworking && |
105 | 0 | wpa_s->conf->cred) |
106 | 0 | return 0; |
107 | 0 | #endif /* CONFIG_INTERWORKING */ |
108 | | |
109 | 0 | for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next) { |
110 | 0 | if (ssid->disabled) |
111 | 0 | continue; |
112 | | |
113 | 0 | disabled_for = wpas_temp_disabled(wpa_s, ssid); |
114 | 0 | if (!disabled_for) |
115 | 0 | return 0; |
116 | | |
117 | 0 | if (!res || disabled_for < res) |
118 | 0 | res = disabled_for; |
119 | 0 | } |
120 | | |
121 | 0 | return res; |
122 | 0 | } |
123 | | #endif /* CONFIG_NO_SCAN_PROCESSING */ |
124 | | |
125 | | |
126 | | void wpas_network_reenabled(void *eloop_ctx, void *timeout_ctx) |
127 | 0 | { |
128 | 0 | struct wpa_supplicant *wpa_s = eloop_ctx; |
129 | |
|
130 | 0 | if (wpa_s->disconnected || wpa_s->wpa_state != WPA_SCANNING) |
131 | 0 | return; |
132 | | |
133 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
134 | 0 | "Try to associate due to network getting re-enabled"); |
135 | 0 | if (wpa_supplicant_fast_associate(wpa_s) != 1) { |
136 | 0 | wpa_supplicant_cancel_sched_scan(wpa_s); |
137 | 0 | wpa_supplicant_req_scan(wpa_s, 0, 0); |
138 | 0 | } |
139 | 0 | } |
140 | | |
141 | | |
142 | | static struct wpa_bss * __wpa_supplicant_get_new_bss( |
143 | | struct wpa_supplicant *wpa_s, const u8 *bssid, const u8 *ssid, |
144 | | size_t ssid_len) |
145 | 0 | { |
146 | 0 | if (ssid && ssid_len > 0) |
147 | 0 | return wpa_bss_get(wpa_s, bssid, ssid, ssid_len); |
148 | 0 | else |
149 | 0 | return wpa_bss_get_bssid(wpa_s, bssid); |
150 | 0 | } |
151 | | |
152 | | |
153 | | static struct wpa_bss * _wpa_supplicant_get_new_bss( |
154 | | struct wpa_supplicant *wpa_s, const u8 *bssid, const u8 *ssid, |
155 | | size_t ssid_len, bool try_update_scan_results) |
156 | 0 | { |
157 | 0 | struct wpa_bss *bss = __wpa_supplicant_get_new_bss(wpa_s, bssid, ssid, |
158 | 0 | ssid_len); |
159 | |
|
160 | 0 | if (bss || !try_update_scan_results) |
161 | 0 | return bss; |
162 | | |
163 | 0 | wpa_supplicant_update_scan_results(wpa_s, bssid); |
164 | |
|
165 | 0 | return __wpa_supplicant_get_new_bss(wpa_s, bssid, ssid, ssid_len); |
166 | 0 | } |
167 | | |
168 | | |
169 | | static struct wpa_bss * wpa_supplicant_get_new_bss( |
170 | | struct wpa_supplicant *wpa_s, const u8 *bssid) |
171 | 0 | { |
172 | 0 | struct wpa_bss *bss = NULL; |
173 | 0 | struct wpa_ssid *ssid = wpa_s->current_ssid; |
174 | 0 | u8 drv_ssid[SSID_MAX_LEN]; |
175 | 0 | int res; |
176 | 0 | bool try_update_scan_results = true; |
177 | |
|
178 | 0 | res = wpa_drv_get_ssid(wpa_s, drv_ssid); |
179 | 0 | if (res > 0) { |
180 | 0 | bss = _wpa_supplicant_get_new_bss(wpa_s, bssid, drv_ssid, res, |
181 | 0 | try_update_scan_results); |
182 | 0 | try_update_scan_results = false; |
183 | 0 | } |
184 | 0 | if (!bss && ssid && ssid->ssid_len > 0) { |
185 | 0 | bss = _wpa_supplicant_get_new_bss(wpa_s, bssid, ssid->ssid, |
186 | 0 | ssid->ssid_len, |
187 | 0 | try_update_scan_results); |
188 | 0 | try_update_scan_results = false; |
189 | 0 | } |
190 | 0 | if (!bss) |
191 | 0 | bss = _wpa_supplicant_get_new_bss(wpa_s, bssid, NULL, 0, |
192 | 0 | try_update_scan_results); |
193 | |
|
194 | 0 | return bss; |
195 | 0 | } |
196 | | |
197 | | |
198 | | static struct wpa_bss * |
199 | | wpa_supplicant_update_current_bss(struct wpa_supplicant *wpa_s, const u8 *bssid) |
200 | 0 | { |
201 | 0 | struct wpa_bss *bss = wpa_supplicant_get_new_bss(wpa_s, bssid); |
202 | |
|
203 | 0 | if (bss) |
204 | 0 | wpa_s->current_bss = bss; |
205 | |
|
206 | 0 | return bss; |
207 | 0 | } |
208 | | |
209 | | |
210 | | static void wpa_supplicant_update_link_bss(struct wpa_supplicant *wpa_s, |
211 | | u8 link_id, const u8 *bssid) |
212 | 0 | { |
213 | 0 | struct wpa_bss *bss = wpa_supplicant_get_new_bss(wpa_s, bssid); |
214 | |
|
215 | 0 | if (bss) |
216 | 0 | wpa_s->links[link_id].bss = bss; |
217 | 0 | } |
218 | | |
219 | | |
220 | | static int wpa_supplicant_select_config(struct wpa_supplicant *wpa_s, |
221 | | union wpa_event_data *data) |
222 | 0 | { |
223 | 0 | struct wpa_ssid *ssid, *old_ssid; |
224 | 0 | struct wpa_bss *bss; |
225 | 0 | u8 drv_ssid[SSID_MAX_LEN]; |
226 | 0 | size_t drv_ssid_len; |
227 | 0 | int res; |
228 | |
|
229 | 0 | if (wpa_s->conf->ap_scan == 1 && wpa_s->current_ssid) { |
230 | 0 | wpa_supplicant_update_current_bss(wpa_s, wpa_s->bssid); |
231 | |
|
232 | 0 | if (wpa_s->current_ssid->ssid_len == 0) |
233 | 0 | return 0; /* current profile still in use */ |
234 | 0 | res = wpa_drv_get_ssid(wpa_s, drv_ssid); |
235 | 0 | if (res < 0) { |
236 | 0 | wpa_msg(wpa_s, MSG_INFO, |
237 | 0 | "Failed to read SSID from driver"); |
238 | 0 | return 0; /* try to use current profile */ |
239 | 0 | } |
240 | 0 | drv_ssid_len = res; |
241 | |
|
242 | 0 | if (drv_ssid_len == wpa_s->current_ssid->ssid_len && |
243 | 0 | os_memcmp(drv_ssid, wpa_s->current_ssid->ssid, |
244 | 0 | drv_ssid_len) == 0) |
245 | 0 | return 0; /* current profile still in use */ |
246 | | |
247 | | #ifdef CONFIG_OWE |
248 | | if ((wpa_s->current_ssid->key_mgmt & WPA_KEY_MGMT_OWE) && |
249 | | wpa_s->current_bss && |
250 | | (wpa_s->current_bss->flags & WPA_BSS_OWE_TRANSITION) && |
251 | | drv_ssid_len == wpa_s->current_bss->ssid_len && |
252 | | os_memcmp(drv_ssid, wpa_s->current_bss->ssid, |
253 | | drv_ssid_len) == 0) |
254 | | return 0; /* current profile still in use */ |
255 | | #endif /* CONFIG_OWE */ |
256 | | |
257 | 0 | wpa_msg(wpa_s, MSG_DEBUG, |
258 | 0 | "Driver-initiated BSS selection changed the SSID to %s", |
259 | 0 | wpa_ssid_txt(drv_ssid, drv_ssid_len)); |
260 | | /* continue selecting a new network profile */ |
261 | 0 | } |
262 | | |
263 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "Select network based on association " |
264 | 0 | "information"); |
265 | 0 | ssid = wpa_supplicant_get_ssid(wpa_s); |
266 | 0 | if (ssid == NULL) { |
267 | 0 | wpa_msg(wpa_s, MSG_INFO, |
268 | 0 | "No network configuration found for the current AP"); |
269 | 0 | return -1; |
270 | 0 | } |
271 | | |
272 | 0 | if (wpas_network_disabled(wpa_s, ssid)) { |
273 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "Selected network is disabled"); |
274 | 0 | return -1; |
275 | 0 | } |
276 | | |
277 | 0 | if (disallowed_bssid(wpa_s, wpa_s->bssid) || |
278 | 0 | disallowed_ssid(wpa_s, ssid->ssid, ssid->ssid_len)) { |
279 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "Selected BSS is disallowed"); |
280 | 0 | return -1; |
281 | 0 | } |
282 | | |
283 | 0 | res = wpas_temp_disabled(wpa_s, ssid); |
284 | 0 | if (res > 0) { |
285 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "Selected network is temporarily " |
286 | 0 | "disabled for %d second(s)", res); |
287 | 0 | return -1; |
288 | 0 | } |
289 | | |
290 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "Network configuration found for the " |
291 | 0 | "current AP"); |
292 | 0 | bss = wpa_supplicant_update_current_bss(wpa_s, wpa_s->bssid); |
293 | 0 | if (wpa_key_mgmt_wpa_any(ssid->key_mgmt)) { |
294 | 0 | u8 wpa_ie[80]; |
295 | 0 | size_t wpa_ie_len = sizeof(wpa_ie); |
296 | 0 | bool skip_default_rsne; |
297 | | |
298 | | /* Do not override RSNE/RSNXE with the default values if the |
299 | | * driver indicated the actual values used in the |
300 | | * (Re)Association Request frame. */ |
301 | 0 | skip_default_rsne = data && data->assoc_info.req_ies; |
302 | 0 | if (wpa_supplicant_set_suites(wpa_s, bss, ssid, |
303 | 0 | wpa_ie, &wpa_ie_len, |
304 | 0 | skip_default_rsne) < 0) |
305 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "Could not set WPA suites"); |
306 | 0 | } else { |
307 | 0 | wpa_supplicant_set_non_wpa_policy(wpa_s, ssid); |
308 | 0 | } |
309 | |
|
310 | 0 | if (wpa_s->current_ssid && wpa_s->current_ssid != ssid) |
311 | 0 | eapol_sm_invalidate_cached_session(wpa_s->eapol); |
312 | 0 | old_ssid = wpa_s->current_ssid; |
313 | 0 | wpa_s->current_ssid = ssid; |
314 | |
|
315 | 0 | wpa_supplicant_rsn_supp_set_config(wpa_s, wpa_s->current_ssid); |
316 | 0 | wpa_supplicant_initiate_eapol(wpa_s); |
317 | 0 | if (old_ssid != wpa_s->current_ssid) |
318 | 0 | wpas_notify_network_changed(wpa_s); |
319 | |
|
320 | 0 | return 0; |
321 | 0 | } |
322 | | |
323 | | |
324 | | void wpa_supplicant_stop_countermeasures(void *eloop_ctx, void *sock_ctx) |
325 | 0 | { |
326 | 0 | struct wpa_supplicant *wpa_s = eloop_ctx; |
327 | |
|
328 | 0 | if (wpa_s->countermeasures) { |
329 | 0 | wpa_s->countermeasures = 0; |
330 | 0 | wpa_drv_set_countermeasures(wpa_s, 0); |
331 | 0 | wpa_msg(wpa_s, MSG_INFO, "WPA: TKIP countermeasures stopped"); |
332 | | |
333 | | /* |
334 | | * It is possible that the device is sched scanning, which means |
335 | | * that a connection attempt will be done only when we receive |
336 | | * scan results. However, in this case, it would be preferable |
337 | | * to scan and connect immediately, so cancel the sched_scan and |
338 | | * issue a regular scan flow. |
339 | | */ |
340 | 0 | wpa_supplicant_cancel_sched_scan(wpa_s); |
341 | 0 | wpa_supplicant_req_scan(wpa_s, 0, 0); |
342 | 0 | } |
343 | 0 | } |
344 | | |
345 | | |
346 | | void wpas_reset_mlo_info(struct wpa_supplicant *wpa_s) |
347 | 0 | { |
348 | 0 | int i; |
349 | |
|
350 | 0 | if (!wpa_s->valid_links) |
351 | 0 | return; |
352 | | |
353 | 0 | wpa_s->valid_links = 0; |
354 | 0 | wpa_s->mlo_assoc_link_id = 0; |
355 | 0 | os_memset(wpa_s->ap_mld_addr, 0, ETH_ALEN); |
356 | 0 | for (i = 0; i < MAX_NUM_MLD_LINKS; i++) |
357 | 0 | wpabuf_free(wpa_s->links[i].ies); |
358 | 0 | os_memset(wpa_s->links, 0, sizeof(wpa_s->links)); |
359 | 0 | } |
360 | | |
361 | | |
362 | | void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s) |
363 | 0 | { |
364 | 0 | int bssid_changed; |
365 | |
|
366 | 0 | wnm_bss_keep_alive_deinit(wpa_s); |
367 | |
|
368 | | #ifdef CONFIG_IBSS_RSN |
369 | | ibss_rsn_deinit(wpa_s->ibss_rsn); |
370 | | wpa_s->ibss_rsn = NULL; |
371 | | #endif /* CONFIG_IBSS_RSN */ |
372 | |
|
373 | | #ifdef CONFIG_AP |
374 | | wpa_supplicant_ap_deinit(wpa_s); |
375 | | #endif /* CONFIG_AP */ |
376 | |
|
377 | 0 | #ifdef CONFIG_HS20 |
378 | | /* Clear possibly configured frame filters */ |
379 | 0 | wpa_drv_configure_frame_filters(wpa_s, 0); |
380 | 0 | #endif /* CONFIG_HS20 */ |
381 | |
|
382 | 0 | if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) |
383 | 0 | return; |
384 | | |
385 | 0 | if (os_reltime_initialized(&wpa_s->session_start)) { |
386 | 0 | os_reltime_age(&wpa_s->session_start, &wpa_s->session_length); |
387 | 0 | wpa_s->session_start.sec = 0; |
388 | 0 | wpa_s->session_start.usec = 0; |
389 | 0 | wpas_notify_session_length(wpa_s); |
390 | 0 | } |
391 | |
|
392 | 0 | wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED); |
393 | |
|
394 | | #ifdef CONFIG_ENC_ASSOC |
395 | | /* Clear configured keys and PTKSA */ |
396 | | if (wpa_s->ptksa && |
397 | | ptksa_cache_get(wpa_s->ptksa, wpa_s->bssid, WPA_CIPHER_NONE)) { |
398 | | wpa_clear_keys(wpa_s, wpa_s->bssid); |
399 | | ptksa_cache_flush(wpa_s->ptksa, wpa_s->bssid, WPA_CIPHER_NONE); |
400 | | } |
401 | | #endif /* CONFIG_ENC_ASSOC */ |
402 | |
|
403 | 0 | bssid_changed = !is_zero_ether_addr(wpa_s->bssid); |
404 | 0 | os_memset(wpa_s->bssid, 0, ETH_ALEN); |
405 | 0 | os_memset(wpa_s->pending_bssid, 0, ETH_ALEN); |
406 | 0 | sme_clear_on_disassoc(wpa_s); |
407 | 0 | wpa_s->current_bss = NULL; |
408 | 0 | wpa_s->assoc_freq = 0; |
409 | 0 | wpa_s->assisted_dfs = false; |
410 | |
|
411 | 0 | if (bssid_changed) |
412 | 0 | wpas_notify_bssid_changed(wpa_s); |
413 | |
|
414 | 0 | eapol_sm_notify_portEnabled(wpa_s->eapol, false); |
415 | 0 | eapol_sm_notify_portValid(wpa_s->eapol, false); |
416 | 0 | if (wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt) || |
417 | 0 | wpa_s->key_mgmt == WPA_KEY_MGMT_OWE || |
418 | 0 | wpa_s->key_mgmt == WPA_KEY_MGMT_DPP || wpa_s->drv_authorized_port) |
419 | 0 | eapol_sm_notify_eap_success(wpa_s->eapol, false); |
420 | 0 | wpa_s->drv_authorized_port = 0; |
421 | 0 | wpa_s->ap_ies_from_associnfo = 0; |
422 | 0 | wpa_s->current_ssid = NULL; |
423 | 0 | eapol_sm_notify_config(wpa_s->eapol, NULL, NULL); |
424 | 0 | wpa_s->key_mgmt = 0; |
425 | 0 | wpa_s->allowed_key_mgmts = 0; |
426 | |
|
427 | 0 | #ifndef CONFIG_NO_RRM |
428 | 0 | wpas_rrm_reset(wpa_s); |
429 | 0 | #endif /* CONFIG_NO_RRM */ |
430 | 0 | wpa_s->wnmsleep_used = 0; |
431 | 0 | #ifdef CONFIG_WNM |
432 | 0 | wpa_s->wnm_mode = 0; |
433 | 0 | #endif /* CONFIG_WNM */ |
434 | 0 | wnm_clear_coloc_intf_reporting(wpa_s); |
435 | 0 | wpa_s->disable_mbo_oce = 0; |
436 | |
|
437 | | #ifdef CONFIG_TESTING_OPTIONS |
438 | | wpa_s->last_tk_alg = WPA_ALG_NONE; |
439 | | os_memset(wpa_s->last_tk, 0, sizeof(wpa_s->last_tk)); |
440 | | #endif /* CONFIG_TESTING_OPTIONS */ |
441 | 0 | wpa_s->ieee80211ac = 0; |
442 | |
|
443 | 0 | if (wpa_s->enabled_4addr_mode && wpa_drv_set_4addr_mode(wpa_s, 0) == 0) |
444 | 0 | wpa_s->enabled_4addr_mode = 0; |
445 | |
|
446 | 0 | wpa_s->wps_scan_done = false; |
447 | 0 | wpas_reset_mlo_info(wpa_s); |
448 | 0 | #ifndef CONFIG_NO_ROBUST_AV |
449 | 0 | wpas_scs_deinit(wpa_s); |
450 | 0 | #endif /* CONFIG_NO_ROBUST_AV */ |
451 | |
|
452 | | #ifdef CONFIG_SME |
453 | | wpa_s->sme.bss_max_idle_period = 0; |
454 | | #endif /* CONFIG_SME */ |
455 | |
|
456 | 0 | wpa_s->ssid_verified = false; |
457 | 0 | wpa_s->bigtk_set = false; |
458 | |
|
459 | 0 | wpabuf_free(wpa_s->pending_eapol_rx); |
460 | 0 | wpa_s->pending_eapol_rx = NULL; |
461 | 0 | wpa_s->ext_auth_to_same_bss = false; |
462 | 0 | } |
463 | | |
464 | | |
465 | | static void wpa_find_assoc_pmkid(struct wpa_supplicant *wpa_s) |
466 | 0 | { |
467 | 0 | struct wpa_ie_data ie; |
468 | 0 | int pmksa_set = -1; |
469 | 0 | size_t i; |
470 | 0 | struct rsn_pmksa_cache_entry *cur_pmksa; |
471 | | |
472 | | /* Start with assumption of no PMKSA cache entry match for cases other |
473 | | * than SAE. In particular, this is needed to generate the PMKSA cache |
474 | | * entries for Suite B cases with driver-based roaming indication. */ |
475 | 0 | cur_pmksa = pmksa_cache_get_current(wpa_s->wpa); |
476 | 0 | if (cur_pmksa && !wpa_key_mgmt_sae(cur_pmksa->akmp)) |
477 | 0 | pmksa_cache_clear_current(wpa_s->wpa); |
478 | |
|
479 | 0 | if (wpa_sm_parse_own_wpa_ie(wpa_s->wpa, &ie) < 0 || |
480 | 0 | ie.pmkid == NULL) |
481 | 0 | return; |
482 | | |
483 | 0 | for (i = 0; i < ie.num_pmkid; i++) { |
484 | 0 | pmksa_set = pmksa_cache_set_current(wpa_s->wpa, |
485 | 0 | ie.pmkid + i * PMKID_LEN, |
486 | 0 | NULL, NULL, 0, NULL, 0, |
487 | 0 | true); |
488 | 0 | if (pmksa_set == 0) { |
489 | 0 | eapol_sm_notify_pmkid_attempt(wpa_s->eapol); |
490 | 0 | wpa_sm_set_pmk_from_pmksa(wpa_s->wpa); |
491 | 0 | break; |
492 | 0 | } |
493 | 0 | } |
494 | |
|
495 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "RSN: PMKID from assoc IE %sfound from " |
496 | 0 | "PMKSA cache", pmksa_set == 0 ? "" : "not "); |
497 | 0 | } |
498 | | |
499 | | |
500 | | static void wpa_supplicant_event_pmkid_candidate(struct wpa_supplicant *wpa_s, |
501 | | union wpa_event_data *data) |
502 | 0 | { |
503 | 0 | if (data == NULL) { |
504 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "RSN: No data in PMKID candidate " |
505 | 0 | "event"); |
506 | 0 | return; |
507 | 0 | } |
508 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "RSN: PMKID candidate event - bssid=" MACSTR |
509 | 0 | " index=%d preauth=%d", |
510 | 0 | MAC2STR(data->pmkid_candidate.bssid), |
511 | 0 | data->pmkid_candidate.index, |
512 | 0 | data->pmkid_candidate.preauth); |
513 | |
|
514 | 0 | pmksa_candidate_add(wpa_s->wpa, data->pmkid_candidate.bssid, |
515 | 0 | data->pmkid_candidate.index, |
516 | 0 | data->pmkid_candidate.preauth); |
517 | 0 | } |
518 | | |
519 | | |
520 | | static int wpa_supplicant_dynamic_keys(struct wpa_supplicant *wpa_s) |
521 | 0 | { |
522 | 0 | if (wpa_s->key_mgmt == WPA_KEY_MGMT_NONE || |
523 | 0 | wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE) |
524 | 0 | return 0; |
525 | | |
526 | 0 | #ifdef IEEE8021X_EAPOL |
527 | 0 | if (wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA && |
528 | 0 | wpa_s->current_ssid && |
529 | 0 | !(wpa_s->current_ssid->eapol_flags & |
530 | 0 | (EAPOL_FLAG_REQUIRE_KEY_UNICAST | |
531 | 0 | EAPOL_FLAG_REQUIRE_KEY_BROADCAST))) { |
532 | | /* IEEE 802.1X, but not using dynamic WEP keys (i.e., either |
533 | | * plaintext or static WEP keys). */ |
534 | 0 | return 0; |
535 | 0 | } |
536 | 0 | #endif /* IEEE8021X_EAPOL */ |
537 | | |
538 | 0 | return 1; |
539 | 0 | } |
540 | | |
541 | | |
542 | | /** |
543 | | * wpa_supplicant_scard_init - Initialize SIM/USIM access with PC/SC |
544 | | * @wpa_s: pointer to wpa_supplicant data |
545 | | * @ssid: Configuration data for the network |
546 | | * Returns: 0 on success, -1 on failure |
547 | | * |
548 | | * This function is called when starting authentication with a network that is |
549 | | * configured to use PC/SC for SIM/USIM access (EAP-SIM or EAP-AKA). |
550 | | */ |
551 | | int wpa_supplicant_scard_init(struct wpa_supplicant *wpa_s, |
552 | | struct wpa_ssid *ssid) |
553 | 0 | { |
554 | 0 | #ifdef IEEE8021X_EAPOL |
555 | | #ifdef PCSC_FUNCS |
556 | | int aka = 0, sim = 0; |
557 | | |
558 | | if ((ssid != NULL && ssid->eap.pcsc == NULL) || |
559 | | wpa_s->scard != NULL || wpa_s->conf->external_sim) |
560 | | return 0; |
561 | | |
562 | | if (ssid == NULL || ssid->eap.eap_methods == NULL) { |
563 | | sim = 1; |
564 | | aka = 1; |
565 | | } else { |
566 | | struct eap_method_type *eap = ssid->eap.eap_methods; |
567 | | while (eap->vendor != EAP_VENDOR_IETF || |
568 | | eap->method != EAP_TYPE_NONE) { |
569 | | if (eap->vendor == EAP_VENDOR_IETF) { |
570 | | if (eap->method == EAP_TYPE_SIM) |
571 | | sim = 1; |
572 | | else if (eap->method == EAP_TYPE_AKA || |
573 | | eap->method == EAP_TYPE_AKA_PRIME) |
574 | | aka = 1; |
575 | | } |
576 | | eap++; |
577 | | } |
578 | | } |
579 | | |
580 | | if (eap_peer_get_eap_method(EAP_VENDOR_IETF, EAP_TYPE_SIM) == NULL) |
581 | | sim = 0; |
582 | | if (eap_peer_get_eap_method(EAP_VENDOR_IETF, EAP_TYPE_AKA) == NULL && |
583 | | eap_peer_get_eap_method(EAP_VENDOR_IETF, EAP_TYPE_AKA_PRIME) == |
584 | | NULL) |
585 | | aka = 0; |
586 | | |
587 | | if (!sim && !aka) { |
588 | | wpa_dbg(wpa_s, MSG_DEBUG, "Selected network is configured to " |
589 | | "use SIM, but neither EAP-SIM nor EAP-AKA are " |
590 | | "enabled"); |
591 | | return 0; |
592 | | } |
593 | | |
594 | | wpa_dbg(wpa_s, MSG_DEBUG, "Selected network is configured to use SIM " |
595 | | "(sim=%d aka=%d) - initialize PCSC", sim, aka); |
596 | | |
597 | | wpa_s->scard = scard_init(wpa_s->conf->pcsc_reader); |
598 | | if (wpa_s->scard == NULL) { |
599 | | wpa_msg(wpa_s, MSG_WARNING, "Failed to initialize SIM " |
600 | | "(pcsc-lite)"); |
601 | | return -1; |
602 | | } |
603 | | wpa_sm_set_scard_ctx(wpa_s->wpa, wpa_s->scard); |
604 | | eapol_sm_register_scard_ctx(wpa_s->eapol, wpa_s->scard); |
605 | | #endif /* PCSC_FUNCS */ |
606 | 0 | #endif /* IEEE8021X_EAPOL */ |
607 | |
|
608 | 0 | return 0; |
609 | 0 | } |
610 | | |
611 | | |
612 | | #ifndef CONFIG_NO_SCAN_PROCESSING |
613 | | |
614 | | #ifdef CONFIG_WEP |
615 | | static int has_wep_key(struct wpa_ssid *ssid) |
616 | | { |
617 | | int i; |
618 | | |
619 | | for (i = 0; i < NUM_WEP_KEYS; i++) { |
620 | | if (ssid->wep_key_len[i]) |
621 | | return 1; |
622 | | } |
623 | | |
624 | | return 0; |
625 | | } |
626 | | #endif /* CONFIG_WEP */ |
627 | | |
628 | | |
629 | | static int wpa_supplicant_match_privacy(struct wpa_bss *bss, |
630 | | struct wpa_ssid *ssid) |
631 | 0 | { |
632 | 0 | int privacy = 0; |
633 | |
|
634 | 0 | if (ssid->mixed_cell) |
635 | 0 | return 1; |
636 | | |
637 | | #ifdef CONFIG_WPS |
638 | | if (ssid->key_mgmt & WPA_KEY_MGMT_WPS) |
639 | | return 1; |
640 | | #endif /* CONFIG_WPS */ |
641 | | |
642 | | #ifdef CONFIG_OWE |
643 | | if ((ssid->key_mgmt & WPA_KEY_MGMT_OWE) && !ssid->owe_only) |
644 | | return 1; |
645 | | #endif /* CONFIG_OWE */ |
646 | | |
647 | | #ifdef CONFIG_WEP |
648 | | if (has_wep_key(ssid)) |
649 | | privacy = 1; |
650 | | #endif /* CONFIG_WEP */ |
651 | | |
652 | 0 | #ifdef IEEE8021X_EAPOL |
653 | 0 | if ((ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X_NO_WPA) && |
654 | 0 | ssid->eapol_flags & (EAPOL_FLAG_REQUIRE_KEY_UNICAST | |
655 | 0 | EAPOL_FLAG_REQUIRE_KEY_BROADCAST)) |
656 | 0 | privacy = 1; |
657 | 0 | #endif /* IEEE8021X_EAPOL */ |
658 | |
|
659 | 0 | if (wpa_key_mgmt_wpa(ssid->key_mgmt)) |
660 | 0 | privacy = 1; |
661 | |
|
662 | 0 | if (bss->caps & IEEE80211_CAP_PRIVACY) |
663 | 0 | return privacy; |
664 | 0 | return !privacy; |
665 | 0 | } |
666 | | |
667 | | |
668 | | static int wpa_supplicant_ssid_bss_match(struct wpa_supplicant *wpa_s, |
669 | | struct wpa_ssid *ssid, |
670 | | struct wpa_bss *bss, int debug_print) |
671 | 0 | { |
672 | 0 | struct wpa_ie_data ie; |
673 | 0 | int proto_match = 0; |
674 | 0 | const u8 *rsn_ie, *wpa_ie; |
675 | 0 | int ret; |
676 | | #ifdef CONFIG_WEP |
677 | | int wep_ok; |
678 | | #endif /* CONFIG_WEP */ |
679 | 0 | bool is_6ghz_bss = is_6ghz_freq(bss->freq); |
680 | |
|
681 | 0 | ret = wpas_wps_ssid_bss_match(wpa_s, ssid, bss); |
682 | 0 | if (ret >= 0) |
683 | 0 | return ret; |
684 | | |
685 | | #ifdef CONFIG_WEP |
686 | | /* Allow TSN if local configuration accepts WEP use without WPA/WPA2 */ |
687 | | wep_ok = !wpa_key_mgmt_wpa(ssid->key_mgmt) && |
688 | | (((ssid->key_mgmt & WPA_KEY_MGMT_NONE) && |
689 | | ssid->wep_key_len[ssid->wep_tx_keyidx] > 0) || |
690 | | (ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X_NO_WPA)); |
691 | | #endif /* CONFIG_WEP */ |
692 | | |
693 | 0 | rsn_ie = wpa_bss_get_rsne(wpa_s, bss, ssid, false); |
694 | 0 | if (is_6ghz_bss && !rsn_ie) { |
695 | 0 | if (debug_print) |
696 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
697 | 0 | " skip - 6 GHz BSS without RSNE"); |
698 | 0 | return 0; |
699 | 0 | } |
700 | | |
701 | 0 | while ((ssid->proto & WPA_PROTO_RSN) && rsn_ie) { |
702 | 0 | proto_match++; |
703 | |
|
704 | 0 | if (wpa_parse_wpa_ie(rsn_ie, 2 + rsn_ie[1], &ie)) { |
705 | 0 | if (debug_print) |
706 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
707 | 0 | " skip RSN IE - parse failed"); |
708 | 0 | break; |
709 | 0 | } |
710 | 0 | if (!ie.has_pairwise) |
711 | 0 | ie.pairwise_cipher = wpa_default_rsn_cipher(bss->freq); |
712 | 0 | if (!ie.has_group) |
713 | 0 | ie.group_cipher = wpa_default_rsn_cipher(bss->freq); |
714 | |
|
715 | 0 | if (is_6ghz_bss || !is_zero_ether_addr(bss->mld_addr)) { |
716 | | /* WEP and TKIP are not allowed on 6 GHz/MLD */ |
717 | 0 | ie.pairwise_cipher &= ~(WPA_CIPHER_WEP40 | |
718 | 0 | WPA_CIPHER_WEP104 | |
719 | 0 | WPA_CIPHER_TKIP); |
720 | 0 | ie.group_cipher &= ~(WPA_CIPHER_WEP40 | |
721 | 0 | WPA_CIPHER_WEP104 | |
722 | 0 | WPA_CIPHER_TKIP); |
723 | 0 | } |
724 | |
|
725 | | #ifdef CONFIG_WEP |
726 | | if (wep_ok && |
727 | | (ie.group_cipher & (WPA_CIPHER_WEP40 | WPA_CIPHER_WEP104))) |
728 | | { |
729 | | if (debug_print) |
730 | | wpa_dbg(wpa_s, MSG_DEBUG, |
731 | | " selected based on TSN in RSN IE"); |
732 | | return 1; |
733 | | } |
734 | | #endif /* CONFIG_WEP */ |
735 | |
|
736 | 0 | if (!(ie.proto & ssid->proto)) { |
737 | 0 | if (debug_print) |
738 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
739 | 0 | " skip RSN IE - proto mismatch"); |
740 | 0 | break; |
741 | 0 | } |
742 | | |
743 | 0 | if (!(ie.pairwise_cipher & ssid->pairwise_cipher)) { |
744 | 0 | if (debug_print) |
745 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
746 | 0 | " skip RSN IE - PTK cipher mismatch"); |
747 | 0 | break; |
748 | 0 | } |
749 | | |
750 | 0 | if (!(ie.group_cipher & ssid->group_cipher)) { |
751 | 0 | if (debug_print) |
752 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
753 | 0 | " skip RSN IE - GTK cipher mismatch"); |
754 | 0 | break; |
755 | 0 | } |
756 | | |
757 | 0 | if (ssid->group_mgmt_cipher && |
758 | 0 | !(ie.mgmt_group_cipher & ssid->group_mgmt_cipher)) { |
759 | 0 | if (debug_print) |
760 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
761 | 0 | " skip RSN IE - group mgmt cipher mismatch"); |
762 | 0 | break; |
763 | 0 | } |
764 | | |
765 | 0 | if (is_6ghz_bss) { |
766 | | /* MFPC must be supported on 6 GHz */ |
767 | 0 | if (!(ie.capabilities & WPA_CAPABILITY_MFPC)) { |
768 | 0 | if (debug_print) |
769 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
770 | 0 | " skip RSNE - 6 GHz without MFPC"); |
771 | 0 | break; |
772 | 0 | } |
773 | | |
774 | | /* WPA PSK is not allowed on the 6 GHz band */ |
775 | 0 | ie.key_mgmt &= ~(WPA_KEY_MGMT_PSK | |
776 | 0 | WPA_KEY_MGMT_FT_PSK | |
777 | 0 | WPA_KEY_MGMT_PSK_SHA256); |
778 | 0 | } |
779 | | |
780 | 0 | if (!(ie.key_mgmt & ssid->key_mgmt)) { |
781 | 0 | if (debug_print) |
782 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
783 | 0 | " skip RSN IE - key mgmt mismatch"); |
784 | 0 | break; |
785 | 0 | } |
786 | | |
787 | 0 | if (!(ie.capabilities & WPA_CAPABILITY_MFPC) && |
788 | 0 | wpas_get_ssid_pmf(wpa_s, ssid) == |
789 | 0 | MGMT_FRAME_PROTECTION_REQUIRED) { |
790 | 0 | if (debug_print) |
791 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
792 | 0 | " skip RSN IE - no mgmt frame protection"); |
793 | 0 | break; |
794 | 0 | } |
795 | 0 | if ((ie.capabilities & WPA_CAPABILITY_MFPR) && |
796 | 0 | wpas_get_ssid_pmf(wpa_s, ssid) == |
797 | 0 | NO_MGMT_FRAME_PROTECTION) { |
798 | 0 | if (debug_print) |
799 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
800 | 0 | " skip RSN IE - no mgmt frame protection enabled but AP requires it"); |
801 | 0 | break; |
802 | 0 | } |
803 | | |
804 | 0 | if (debug_print) |
805 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
806 | 0 | " selected based on RSN IE"); |
807 | 0 | return 1; |
808 | 0 | } |
809 | | |
810 | 0 | if (is_6ghz_bss) { |
811 | 0 | if (debug_print) |
812 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
813 | 0 | " skip - 6 GHz BSS without matching RSNE"); |
814 | 0 | return 0; |
815 | 0 | } |
816 | | |
817 | 0 | wpa_ie = wpa_bss_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE); |
818 | |
|
819 | 0 | if (wpas_get_ssid_pmf(wpa_s, ssid) == MGMT_FRAME_PROTECTION_REQUIRED && |
820 | 0 | (!(ssid->key_mgmt & WPA_KEY_MGMT_OWE) || ssid->owe_only)) { |
821 | | #ifdef CONFIG_OWE |
822 | | if ((ssid->key_mgmt & WPA_KEY_MGMT_OWE) && ssid->owe_only && |
823 | | !wpa_ie && !rsn_ie && |
824 | | wpa_s->owe_transition_select && |
825 | | wpa_bss_get_vendor_ie(bss, OWE_IE_VENDOR_TYPE) && |
826 | | ssid->owe_transition_bss_select_count + 1 <= |
827 | | MAX_OWE_TRANSITION_BSS_SELECT_COUNT) { |
828 | | ssid->owe_transition_bss_select_count++; |
829 | | if (debug_print) |
830 | | wpa_dbg(wpa_s, MSG_DEBUG, |
831 | | " skip OWE open BSS (selection count %d does not exceed %d)", |
832 | | ssid->owe_transition_bss_select_count, |
833 | | MAX_OWE_TRANSITION_BSS_SELECT_COUNT); |
834 | | wpa_s->owe_transition_search = 1; |
835 | | return 0; |
836 | | } |
837 | | #endif /* CONFIG_OWE */ |
838 | 0 | if (debug_print) |
839 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
840 | 0 | " skip - MFP Required but network not MFP Capable"); |
841 | 0 | return 0; |
842 | 0 | } |
843 | | |
844 | 0 | while ((ssid->proto & WPA_PROTO_WPA) && wpa_ie) { |
845 | 0 | proto_match++; |
846 | |
|
847 | 0 | if (wpa_parse_wpa_ie(wpa_ie, 2 + wpa_ie[1], &ie)) { |
848 | 0 | if (debug_print) |
849 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
850 | 0 | " skip WPA IE - parse failed"); |
851 | 0 | break; |
852 | 0 | } |
853 | | |
854 | | #ifdef CONFIG_WEP |
855 | | if (wep_ok && |
856 | | (ie.group_cipher & (WPA_CIPHER_WEP40 | WPA_CIPHER_WEP104))) |
857 | | { |
858 | | if (debug_print) |
859 | | wpa_dbg(wpa_s, MSG_DEBUG, |
860 | | " selected based on TSN in WPA IE"); |
861 | | return 1; |
862 | | } |
863 | | #endif /* CONFIG_WEP */ |
864 | | |
865 | 0 | if (!(ie.proto & ssid->proto)) { |
866 | 0 | if (debug_print) |
867 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
868 | 0 | " skip WPA IE - proto mismatch"); |
869 | 0 | break; |
870 | 0 | } |
871 | | |
872 | 0 | if (!(ie.pairwise_cipher & ssid->pairwise_cipher)) { |
873 | 0 | if (debug_print) |
874 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
875 | 0 | " skip WPA IE - PTK cipher mismatch"); |
876 | 0 | break; |
877 | 0 | } |
878 | | |
879 | 0 | if (!(ie.group_cipher & ssid->group_cipher)) { |
880 | 0 | if (debug_print) |
881 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
882 | 0 | " skip WPA IE - GTK cipher mismatch"); |
883 | 0 | break; |
884 | 0 | } |
885 | | |
886 | 0 | if (!(ie.key_mgmt & ssid->key_mgmt)) { |
887 | 0 | if (debug_print) |
888 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
889 | 0 | " skip WPA IE - key mgmt mismatch"); |
890 | 0 | break; |
891 | 0 | } |
892 | | |
893 | 0 | if (debug_print) |
894 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
895 | 0 | " selected based on WPA IE"); |
896 | 0 | return 1; |
897 | 0 | } |
898 | | |
899 | 0 | if ((ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X_NO_WPA) && !wpa_ie && |
900 | 0 | !rsn_ie) { |
901 | 0 | if (debug_print) |
902 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
903 | 0 | " allow for non-WPA IEEE 802.1X"); |
904 | 0 | return 1; |
905 | 0 | } |
906 | | |
907 | | #ifdef CONFIG_OWE |
908 | | if ((ssid->key_mgmt & WPA_KEY_MGMT_OWE) && !ssid->owe_only && |
909 | | !wpa_ie && !rsn_ie) { |
910 | | if (wpa_s->owe_transition_select && |
911 | | wpa_bss_get_vendor_ie(bss, OWE_IE_VENDOR_TYPE) && |
912 | | ssid->owe_transition_bss_select_count + 1 <= |
913 | | MAX_OWE_TRANSITION_BSS_SELECT_COUNT) { |
914 | | ssid->owe_transition_bss_select_count++; |
915 | | if (debug_print) |
916 | | wpa_dbg(wpa_s, MSG_DEBUG, |
917 | | " skip OWE transition BSS (selection count %d does not exceed %d)", |
918 | | ssid->owe_transition_bss_select_count, |
919 | | MAX_OWE_TRANSITION_BSS_SELECT_COUNT); |
920 | | wpa_s->owe_transition_search = 1; |
921 | | return 0; |
922 | | } |
923 | | if (debug_print) |
924 | | wpa_dbg(wpa_s, MSG_DEBUG, |
925 | | " allow in OWE transition mode"); |
926 | | return 1; |
927 | | } |
928 | | #endif /* CONFIG_OWE */ |
929 | | |
930 | 0 | if ((ssid->proto & (WPA_PROTO_WPA | WPA_PROTO_RSN)) && |
931 | 0 | wpa_key_mgmt_wpa(ssid->key_mgmt) && proto_match == 0) { |
932 | 0 | if (debug_print) |
933 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
934 | 0 | " skip - no WPA/RSN proto match"); |
935 | 0 | return 0; |
936 | 0 | } |
937 | | |
938 | 0 | if (!wpa_key_mgmt_wpa(ssid->key_mgmt)) { |
939 | 0 | if (debug_print) |
940 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, " allow in non-WPA/WPA2"); |
941 | 0 | return 1; |
942 | 0 | } |
943 | | |
944 | 0 | if (debug_print) |
945 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
946 | 0 | " reject due to mismatch with WPA/WPA2"); |
947 | |
|
948 | 0 | return 0; |
949 | 0 | } |
950 | | |
951 | | |
952 | | static int freq_allowed(int *freqs, int freq) |
953 | 0 | { |
954 | 0 | int i; |
955 | |
|
956 | 0 | if (freqs == NULL) |
957 | 0 | return 1; |
958 | | |
959 | 0 | for (i = 0; freqs[i]; i++) |
960 | 0 | if (freqs[i] == freq) |
961 | 0 | return 1; |
962 | 0 | return 0; |
963 | 0 | } |
964 | | |
965 | | |
966 | | static int rate_match(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid, |
967 | | struct wpa_bss *bss, int debug_print) |
968 | 0 | { |
969 | 0 | const struct hostapd_hw_modes *mode = NULL, *modes; |
970 | 0 | const u8 scan_ie[2] = { WLAN_EID_SUPP_RATES, WLAN_EID_EXT_SUPP_RATES }; |
971 | 0 | const u8 *rate_ie; |
972 | 0 | int i, j, k; |
973 | |
|
974 | 0 | if (bss->freq == 0) |
975 | 0 | return 1; /* Cannot do matching without knowing band */ |
976 | | |
977 | 0 | modes = wpa_s->hw.modes; |
978 | 0 | if (modes == NULL) { |
979 | | /* |
980 | | * The driver does not provide any additional information |
981 | | * about the utilized hardware, so allow the connection attempt |
982 | | * to continue. |
983 | | */ |
984 | 0 | return 1; |
985 | 0 | } |
986 | | |
987 | 0 | for (i = 0; i < wpa_s->hw.num_modes; i++) { |
988 | 0 | for (j = 0; j < modes[i].num_channels; j++) { |
989 | 0 | int freq = modes[i].channels[j].freq; |
990 | 0 | if (freq == bss->freq) { |
991 | 0 | if (mode && |
992 | 0 | mode->mode == HOSTAPD_MODE_IEEE80211G) |
993 | 0 | break; /* do not allow 802.11b replace |
994 | | * 802.11g */ |
995 | 0 | mode = &modes[i]; |
996 | 0 | break; |
997 | 0 | } |
998 | 0 | } |
999 | 0 | } |
1000 | |
|
1001 | 0 | if (mode == NULL) |
1002 | 0 | return 0; |
1003 | | |
1004 | 0 | for (i = 0; i < (int) sizeof(scan_ie); i++) { |
1005 | 0 | rate_ie = wpa_bss_get_ie(bss, scan_ie[i]); |
1006 | 0 | if (rate_ie == NULL) |
1007 | 0 | continue; |
1008 | | |
1009 | 0 | for (j = 2; j < rate_ie[1] + 2; j++) { |
1010 | 0 | int flagged = !!(rate_ie[j] & 0x80); |
1011 | 0 | int r = (rate_ie[j] & 0x7f) * 5; |
1012 | | |
1013 | | /* |
1014 | | * IEEE Std 802.11n-2009 7.3.2.2: |
1015 | | * The new BSS Membership selector value is encoded |
1016 | | * like a legacy basic rate, but it is not a rate and |
1017 | | * only indicates if the BSS members are required to |
1018 | | * support the mandatory features of Clause 20 [HT PHY] |
1019 | | * in order to join the BSS. |
1020 | | */ |
1021 | 0 | if (flagged && ((rate_ie[j] & 0x7f) == |
1022 | 0 | BSS_MEMBERSHIP_SELECTOR_HT_PHY)) { |
1023 | 0 | if (!ht_supported(mode)) { |
1024 | 0 | if (debug_print) |
1025 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
1026 | 0 | " hardware does not support HT PHY"); |
1027 | 0 | return 0; |
1028 | 0 | } |
1029 | 0 | continue; |
1030 | 0 | } |
1031 | | |
1032 | | /* There's also a VHT selector for 802.11ac */ |
1033 | 0 | if (flagged && ((rate_ie[j] & 0x7f) == |
1034 | 0 | BSS_MEMBERSHIP_SELECTOR_VHT_PHY)) { |
1035 | 0 | if (!vht_supported(mode)) { |
1036 | 0 | if (debug_print) |
1037 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
1038 | 0 | " hardware does not support VHT PHY"); |
1039 | 0 | return 0; |
1040 | 0 | } |
1041 | 0 | continue; |
1042 | 0 | } |
1043 | | |
1044 | 0 | if (flagged && ((rate_ie[j] & 0x7f) == |
1045 | 0 | BSS_MEMBERSHIP_SELECTOR_HE_PHY)) { |
1046 | 0 | if (!he_supported(mode, IEEE80211_MODE_INFRA)) { |
1047 | 0 | if (debug_print) |
1048 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
1049 | 0 | " hardware does not support HE PHY"); |
1050 | 0 | return 0; |
1051 | 0 | } |
1052 | 0 | continue; |
1053 | 0 | } |
1054 | | |
1055 | 0 | if (flagged && ((rate_ie[j] & 0x7f) == |
1056 | 0 | BSS_MEMBERSHIP_SELECTOR_EHT_PHY)) { |
1057 | 0 | if (!eht_supported(mode, IEEE80211_MODE_INFRA)) |
1058 | 0 | { |
1059 | 0 | if (debug_print) |
1060 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
1061 | 0 | " hardware does not support EHT PHY"); |
1062 | 0 | return 0; |
1063 | 0 | } |
1064 | 0 | continue; |
1065 | 0 | } |
1066 | | |
1067 | | #ifdef CONFIG_SAE |
1068 | | if (flagged && ((rate_ie[j] & 0x7f) == |
1069 | | BSS_MEMBERSHIP_SELECTOR_SAE_H2E_ONLY)) { |
1070 | | if (wpas_get_ssid_sae_pwe(wpa_s, ssid) == |
1071 | | SAE_PWE_HUNT_AND_PECK && |
1072 | | !ssid->sae_password_id && |
1073 | | !is_6ghz_freq(bss->freq) && |
1074 | | wpa_key_mgmt_sae(ssid->key_mgmt)) { |
1075 | | if (debug_print) |
1076 | | wpa_dbg(wpa_s, MSG_DEBUG, |
1077 | | " SAE H2E disabled"); |
1078 | | #ifdef CONFIG_TESTING_OPTIONS |
1079 | | if (wpa_s->ignore_sae_h2e_only) { |
1080 | | wpa_dbg(wpa_s, MSG_DEBUG, |
1081 | | "TESTING: Ignore SAE H2E requirement mismatch"); |
1082 | | continue; |
1083 | | } |
1084 | | #endif /* CONFIG_TESTING_OPTIONS */ |
1085 | | return 0; |
1086 | | } |
1087 | | continue; |
1088 | | } |
1089 | | #endif /* CONFIG_SAE */ |
1090 | | |
1091 | 0 | if (!flagged) |
1092 | 0 | continue; |
1093 | | |
1094 | | /* check for legacy basic rates */ |
1095 | 0 | for (k = 0; k < mode->num_rates; k++) { |
1096 | 0 | if (mode->rates[k] == r) |
1097 | 0 | break; |
1098 | 0 | } |
1099 | 0 | if (k == mode->num_rates) { |
1100 | | /* |
1101 | | * IEEE Std 802.11-2007 7.3.2.2 demands that in |
1102 | | * order to join a BSS all required rates |
1103 | | * have to be supported by the hardware. |
1104 | | */ |
1105 | 0 | if (debug_print) |
1106 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
1107 | 0 | " hardware does not support required rate %d.%d Mbps (freq=%d mode==%d num_rates=%d)", |
1108 | 0 | r / 10, r % 10, |
1109 | 0 | bss->freq, mode->mode, mode->num_rates); |
1110 | 0 | return 0; |
1111 | 0 | } |
1112 | 0 | } |
1113 | 0 | } |
1114 | | |
1115 | 0 | return 1; |
1116 | 0 | } |
1117 | | |
1118 | | |
1119 | | /* |
1120 | | * Test whether BSS is in an ESS. |
1121 | | * This is done differently in DMG (60 GHz) and non-DMG bands |
1122 | | */ |
1123 | | static int bss_is_ess(struct wpa_bss *bss) |
1124 | 0 | { |
1125 | 0 | if (bss_is_dmg(bss)) { |
1126 | 0 | return (bss->caps & IEEE80211_CAP_DMG_MASK) == |
1127 | 0 | IEEE80211_CAP_DMG_AP; |
1128 | 0 | } |
1129 | | |
1130 | 0 | return ((bss->caps & (IEEE80211_CAP_ESS | IEEE80211_CAP_IBSS)) == |
1131 | 0 | IEEE80211_CAP_ESS); |
1132 | 0 | } |
1133 | | |
1134 | | |
1135 | | static int match_mac_mask(const u8 *addr_a, const u8 *addr_b, const u8 *mask) |
1136 | 0 | { |
1137 | 0 | size_t i; |
1138 | |
|
1139 | 0 | for (i = 0; i < ETH_ALEN; i++) { |
1140 | 0 | if ((addr_a[i] & mask[i]) != (addr_b[i] & mask[i])) |
1141 | 0 | return 0; |
1142 | 0 | } |
1143 | 0 | return 1; |
1144 | 0 | } |
1145 | | |
1146 | | |
1147 | | static int addr_in_list(const u8 *addr, const u8 *list, size_t num) |
1148 | 0 | { |
1149 | 0 | size_t i; |
1150 | |
|
1151 | 0 | for (i = 0; i < num; i++) { |
1152 | 0 | const u8 *a = list + i * ETH_ALEN * 2; |
1153 | 0 | const u8 *m = a + ETH_ALEN; |
1154 | |
|
1155 | 0 | if (match_mac_mask(a, addr, m)) |
1156 | 0 | return 1; |
1157 | 0 | } |
1158 | 0 | return 0; |
1159 | 0 | } |
1160 | | |
1161 | | |
1162 | | static void owe_trans_ssid(struct wpa_supplicant *wpa_s, struct wpa_bss *bss, |
1163 | | const u8 **ret_ssid, size_t *ret_ssid_len) |
1164 | 0 | { |
1165 | | #ifdef CONFIG_OWE |
1166 | | const u8 *owe, *bssid; |
1167 | | |
1168 | | owe = wpa_bss_get_vendor_ie(bss, OWE_IE_VENDOR_TYPE); |
1169 | | if (!owe || !wpa_bss_get_rsne(wpa_s, bss, NULL, false)) |
1170 | | return; |
1171 | | |
1172 | | if (wpas_get_owe_trans_network(owe, &bssid, ret_ssid, ret_ssid_len)) |
1173 | | return; |
1174 | | |
1175 | | /* Match the profile SSID against the OWE transition mode SSID on the |
1176 | | * open network. */ |
1177 | | wpa_dbg(wpa_s, MSG_DEBUG, "OWE: transition mode BSSID: " MACSTR |
1178 | | " SSID: %s", MAC2STR(bssid), |
1179 | | wpa_ssid_txt(*ret_ssid, *ret_ssid_len)); |
1180 | | |
1181 | | if (!(bss->flags & WPA_BSS_OWE_TRANSITION)) { |
1182 | | struct wpa_ssid *ssid; |
1183 | | |
1184 | | for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next) { |
1185 | | if (wpas_network_disabled(wpa_s, ssid)) |
1186 | | continue; |
1187 | | if (ssid->ssid_len == *ret_ssid_len && |
1188 | | os_memcmp(ssid->ssid, *ret_ssid, *ret_ssid_len) == |
1189 | | 0) { |
1190 | | /* OWE BSS in transition mode for a currently |
1191 | | * enabled OWE network. */ |
1192 | | wpa_dbg(wpa_s, MSG_DEBUG, |
1193 | | "OWE: transition mode OWE SSID for active OWE profile"); |
1194 | | bss->flags |= WPA_BSS_OWE_TRANSITION; |
1195 | | break; |
1196 | | } |
1197 | | } |
1198 | | } |
1199 | | #endif /* CONFIG_OWE */ |
1200 | 0 | } |
1201 | | |
1202 | | |
1203 | | static bool wpas_valid_ml_bss(struct wpa_supplicant *wpa_s, struct wpa_bss *bss) |
1204 | 0 | { |
1205 | 0 | u16 removed_links; |
1206 | |
|
1207 | 0 | if (!bss->valid_links) |
1208 | 0 | return true; |
1209 | | |
1210 | | /* Check if the current BSS is going to be removed */ |
1211 | 0 | removed_links = wpa_bss_parse_reconf_ml_element(wpa_s, bss); |
1212 | 0 | if (BIT(bss->mld_link_id) & removed_links) |
1213 | 0 | return false; |
1214 | | |
1215 | 0 | return true; |
1216 | 0 | } |
1217 | | |
1218 | | |
1219 | | int disabled_freq(struct wpa_supplicant *wpa_s, int freq) |
1220 | 0 | { |
1221 | 0 | int i, j; |
1222 | |
|
1223 | 0 | if (!wpa_s->hw.modes || !wpa_s->hw.num_modes) |
1224 | 0 | return 0; |
1225 | | |
1226 | 0 | for (j = 0; j < wpa_s->hw.num_modes; j++) { |
1227 | 0 | struct hostapd_hw_modes *mode = &wpa_s->hw.modes[j]; |
1228 | |
|
1229 | 0 | for (i = 0; i < mode->num_channels; i++) { |
1230 | 0 | struct hostapd_channel_data *chan = &mode->channels[i]; |
1231 | |
|
1232 | 0 | if (chan->freq == freq) |
1233 | 0 | return !!(chan->flag & HOSTAPD_CHAN_DISABLED); |
1234 | 0 | } |
1235 | 0 | } |
1236 | | |
1237 | 0 | return 1; |
1238 | 0 | } |
1239 | | |
1240 | | |
1241 | | static bool wpa_scan_res_ok(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid, |
1242 | | const u8 *match_ssid, size_t match_ssid_len, |
1243 | | struct wpa_bss *bss, int bssid_ignore_count, |
1244 | | bool debug_print, bool link); |
1245 | | |
1246 | | |
1247 | | #ifdef CONFIG_SAE_PK |
1248 | | static bool sae_pk_acceptable_bss_with_pk(struct wpa_supplicant *wpa_s, |
1249 | | struct wpa_bss *orig_bss, |
1250 | | struct wpa_ssid *ssid, |
1251 | | const u8 *match_ssid, |
1252 | | size_t match_ssid_len) |
1253 | | { |
1254 | | struct wpa_bss *bss; |
1255 | | |
1256 | | dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) { |
1257 | | int count; |
1258 | | const u8 *ie; |
1259 | | |
1260 | | if (bss == orig_bss) |
1261 | | continue; |
1262 | | ie = wpa_bss_get_rsnxe(wpa_s, bss, ssid, false); |
1263 | | if (!(ieee802_11_rsnx_capab(ie, WLAN_RSNX_CAPAB_SAE_PK))) |
1264 | | continue; |
1265 | | |
1266 | | /* TODO: Could be more thorough in checking what kind of |
1267 | | * signal strength or throughput estimate would be acceptable |
1268 | | * compared to the originally selected BSS. */ |
1269 | | if (bss->est_throughput < 2000) |
1270 | | return false; |
1271 | | |
1272 | | count = wpa_bssid_ignore_is_listed(wpa_s, bss->bssid); |
1273 | | if (wpa_scan_res_ok(wpa_s, ssid, match_ssid, match_ssid_len, |
1274 | | bss, count, false, false)) |
1275 | | return true; |
1276 | | } |
1277 | | |
1278 | | return false; |
1279 | | } |
1280 | | #endif /* CONFIG_SAE_PK */ |
1281 | | |
1282 | | |
1283 | | static bool wpa_scan_res_ok(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid, |
1284 | | const u8 *match_ssid, size_t match_ssid_len, |
1285 | | struct wpa_bss *bss, int bssid_ignore_count, |
1286 | | bool debug_print, bool link) |
1287 | 0 | { |
1288 | 0 | int res; |
1289 | 0 | bool wpa, check_ssid = false; |
1290 | | #ifdef CONFIG_MBO |
1291 | | const u8 *assoc_disallow; |
1292 | | #endif /* CONFIG_MBO */ |
1293 | | #ifdef CONFIG_SAE |
1294 | | u8 rsnxe_capa = 0; |
1295 | | enum sae_pwe sae_pwe; |
1296 | | #endif /* CONFIG_SAE */ |
1297 | 0 | const u8 *ie; |
1298 | |
|
1299 | 0 | ie = wpa_bss_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE); |
1300 | 0 | wpa = ie && ie[1]; |
1301 | 0 | ie = wpa_bss_get_rsne(wpa_s, bss, ssid, false); |
1302 | 0 | wpa |= ie && ie[1]; |
1303 | |
|
1304 | | #ifdef CONFIG_SAE |
1305 | | ie = wpa_bss_get_rsnxe(wpa_s, bss, ssid, false); |
1306 | | if (ie && ie[0] == WLAN_EID_VENDOR_SPECIFIC && ie[1] >= 4 + 1) |
1307 | | rsnxe_capa = ie[4 + 2]; |
1308 | | else if (ie && ie[1] >= 1) |
1309 | | rsnxe_capa = ie[2]; |
1310 | | #endif /* CONFIG_SAE */ |
1311 | |
|
1312 | 0 | check_ssid = wpa || ssid->ssid_len > 0; |
1313 | |
|
1314 | 0 | if (wpas_network_disabled(wpa_s, ssid)) { |
1315 | 0 | if (debug_print) |
1316 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, " skip - disabled"); |
1317 | 0 | return false; |
1318 | 0 | } |
1319 | | |
1320 | 0 | res = wpas_temp_disabled(wpa_s, ssid); |
1321 | 0 | if (res > 0) { |
1322 | 0 | if (debug_print) |
1323 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
1324 | 0 | " skip - disabled temporarily for %d second(s)", |
1325 | 0 | res); |
1326 | 0 | return false; |
1327 | 0 | } |
1328 | | |
1329 | | #ifdef CONFIG_WPS |
1330 | | if ((ssid->key_mgmt & WPA_KEY_MGMT_WPS) && bssid_ignore_count) { |
1331 | | if (debug_print) |
1332 | | wpa_dbg(wpa_s, MSG_DEBUG, |
1333 | | " skip - BSSID ignored (WPS)"); |
1334 | | return false; |
1335 | | } |
1336 | | |
1337 | | if (wpa && ssid->ssid_len == 0 && |
1338 | | wpas_wps_ssid_wildcard_ok(wpa_s, ssid, bss)) |
1339 | | check_ssid = false; |
1340 | | |
1341 | | if (!wpa && (ssid->key_mgmt & WPA_KEY_MGMT_WPS)) { |
1342 | | /* Only allow wildcard SSID match if an AP advertises active |
1343 | | * WPS operation that matches our mode. */ |
1344 | | check_ssid = ssid->ssid_len > 0 || |
1345 | | !wpas_wps_ssid_wildcard_ok(wpa_s, ssid, bss); |
1346 | | } |
1347 | | #endif /* CONFIG_WPS */ |
1348 | | |
1349 | 0 | if (ssid->bssid_set && ssid->ssid_len == 0 && |
1350 | 0 | ether_addr_equal(bss->bssid, ssid->bssid)) |
1351 | 0 | check_ssid = false; |
1352 | |
|
1353 | 0 | if (check_ssid && |
1354 | 0 | (match_ssid_len != ssid->ssid_len || |
1355 | 0 | os_memcmp(match_ssid, ssid->ssid, match_ssid_len) != 0)) { |
1356 | 0 | if (debug_print) |
1357 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, " skip - SSID mismatch"); |
1358 | 0 | return false; |
1359 | 0 | } |
1360 | | |
1361 | 0 | if (!link && ssid->bssid_set && |
1362 | 0 | !ether_addr_equal(bss->bssid, ssid->bssid)) { |
1363 | 0 | if (debug_print) |
1364 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, " skip - BSSID mismatch"); |
1365 | 0 | return false; |
1366 | 0 | } |
1367 | | |
1368 | | /* check the list of BSSIDs to ignore */ |
1369 | 0 | if (ssid->num_bssid_ignore && |
1370 | 0 | addr_in_list(bss->bssid, ssid->bssid_ignore, |
1371 | 0 | ssid->num_bssid_ignore)) { |
1372 | 0 | if (debug_print) |
1373 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
1374 | 0 | " skip - BSSID configured to be ignored"); |
1375 | 0 | return false; |
1376 | 0 | } |
1377 | | |
1378 | | /* if there is a list of accepted BSSIDs, only accept those APs */ |
1379 | 0 | if (ssid->num_bssid_accept && |
1380 | 0 | !addr_in_list(bss->bssid, ssid->bssid_accept, |
1381 | 0 | ssid->num_bssid_accept)) { |
1382 | 0 | if (debug_print) |
1383 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
1384 | 0 | " skip - BSSID not in list of accepted values"); |
1385 | 0 | return false; |
1386 | 0 | } |
1387 | | |
1388 | 0 | if (!wpa_supplicant_ssid_bss_match(wpa_s, ssid, bss, debug_print)) |
1389 | 0 | return false; |
1390 | | |
1391 | 0 | if (!wpa && |
1392 | 0 | !(ssid->key_mgmt & WPA_KEY_MGMT_NONE) && |
1393 | 0 | !(ssid->key_mgmt & WPA_KEY_MGMT_WPS) && |
1394 | 0 | !(ssid->key_mgmt & WPA_KEY_MGMT_OWE) && |
1395 | 0 | !(ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X_NO_WPA)) { |
1396 | 0 | if (debug_print) |
1397 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
1398 | 0 | " skip - non-WPA network not allowed"); |
1399 | 0 | return false; |
1400 | 0 | } |
1401 | | |
1402 | | #ifdef CONFIG_WEP |
1403 | | if (wpa && !wpa_key_mgmt_wpa(ssid->key_mgmt) && has_wep_key(ssid)) { |
1404 | | if (debug_print) |
1405 | | wpa_dbg(wpa_s, MSG_DEBUG, |
1406 | | " skip - ignore WPA/WPA2 AP for WEP network block"); |
1407 | | return false; |
1408 | | } |
1409 | | #endif /* CONFIG_WEP */ |
1410 | | |
1411 | 0 | if (!wpa_supplicant_match_privacy(bss, ssid)) { |
1412 | 0 | if (debug_print) |
1413 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, " skip - privacy mismatch"); |
1414 | 0 | return false; |
1415 | 0 | } |
1416 | | |
1417 | 0 | if (ssid->mode != WPAS_MODE_MESH && !bss_is_ess(bss) && |
1418 | 0 | !bss_is_pbss(bss)) { |
1419 | 0 | if (debug_print) |
1420 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
1421 | 0 | " skip - not ESS, PBSS, or MBSS"); |
1422 | 0 | return false; |
1423 | 0 | } |
1424 | | |
1425 | 0 | if (ssid->pbss != 2 && ssid->pbss != bss_is_pbss(bss)) { |
1426 | 0 | if (debug_print) |
1427 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
1428 | 0 | " skip - PBSS mismatch (ssid %d bss %d)", |
1429 | 0 | ssid->pbss, bss_is_pbss(bss)); |
1430 | 0 | return false; |
1431 | 0 | } |
1432 | | |
1433 | 0 | if (!freq_allowed(ssid->freq_list, bss->freq)) { |
1434 | 0 | if (debug_print) |
1435 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
1436 | 0 | " skip - frequency not allowed"); |
1437 | 0 | return false; |
1438 | 0 | } |
1439 | | |
1440 | | #ifdef CONFIG_MESH |
1441 | | if (ssid->mode == WPAS_MODE_MESH && ssid->frequency > 0 && |
1442 | | ssid->frequency != bss->freq) { |
1443 | | if (debug_print) |
1444 | | wpa_dbg(wpa_s, MSG_DEBUG, |
1445 | | " skip - frequency not allowed (mesh)"); |
1446 | | return false; |
1447 | | } |
1448 | | #endif /* CONFIG_MESH */ |
1449 | | |
1450 | 0 | if (!rate_match(wpa_s, ssid, bss, debug_print)) { |
1451 | 0 | if (debug_print) |
1452 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
1453 | 0 | " skip - rate sets do not match"); |
1454 | 0 | return false; |
1455 | 0 | } |
1456 | | |
1457 | | #ifdef CONFIG_SAE |
1458 | | /* When using SAE Password Identifier and when operationg on the 6 GHz |
1459 | | * band, only H2E is allowed. */ |
1460 | | sae_pwe = wpas_get_ssid_sae_pwe(wpa_s, ssid); |
1461 | | if ((sae_pwe == SAE_PWE_HASH_TO_ELEMENT || |
1462 | | wpa_key_mgmt_only_sae_ext_key(ssid->key_mgmt) || |
1463 | | is_6ghz_freq(bss->freq) || ssid->sae_password_id) && |
1464 | | sae_pwe != SAE_PWE_FORCE_HUNT_AND_PECK && |
1465 | | wpa_key_mgmt_only_sae(ssid->key_mgmt) && |
1466 | | !(rsnxe_capa & BIT(WLAN_RSNX_CAPAB_SAE_H2E))) { |
1467 | | if (debug_print) |
1468 | | wpa_dbg(wpa_s, MSG_DEBUG, |
1469 | | " skip - SAE H2E required, but not supported by the AP"); |
1470 | | return false; |
1471 | | } |
1472 | | #endif /* CONFIG_SAE */ |
1473 | | |
1474 | | #ifdef CONFIG_SAE_PK |
1475 | | if (ssid->sae_pk == SAE_PK_MODE_ONLY && |
1476 | | !(rsnxe_capa & BIT(WLAN_RSNX_CAPAB_SAE_PK))) { |
1477 | | if (debug_print) |
1478 | | wpa_dbg(wpa_s, MSG_DEBUG, |
1479 | | " skip - SAE-PK required, but not supported by the AP"); |
1480 | | return false; |
1481 | | } |
1482 | | #endif /* CONFIG_SAE_PK */ |
1483 | | |
1484 | 0 | #ifndef CONFIG_IBSS_RSN |
1485 | 0 | if (ssid->mode == WPAS_MODE_IBSS && |
1486 | 0 | !(ssid->key_mgmt & (WPA_KEY_MGMT_NONE | WPA_KEY_MGMT_WPA_NONE))) { |
1487 | 0 | if (debug_print) |
1488 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
1489 | 0 | " skip - IBSS RSN not supported in the build"); |
1490 | 0 | return false; |
1491 | 0 | } |
1492 | 0 | #endif /* !CONFIG_IBSS_RSN */ |
1493 | | |
1494 | | #ifdef CONFIG_P2P |
1495 | | if (ssid->p2p_group && |
1496 | | !wpa_bss_get_vendor_ie(bss, P2P_IE_VENDOR_TYPE) && |
1497 | | !wpa_bss_get_vendor_ie_beacon(bss, P2P_IE_VENDOR_TYPE)) { |
1498 | | if (debug_print) |
1499 | | wpa_dbg(wpa_s, MSG_DEBUG, " skip - no P2P IE seen"); |
1500 | | return false; |
1501 | | } |
1502 | | |
1503 | | if (!is_zero_ether_addr(ssid->go_p2p_dev_addr)) { |
1504 | | struct wpabuf *p2p_ie; |
1505 | | u8 dev_addr[ETH_ALEN]; |
1506 | | |
1507 | | ie = wpa_bss_get_vendor_ie(bss, P2P_IE_VENDOR_TYPE); |
1508 | | if (!ie) { |
1509 | | if (debug_print) |
1510 | | wpa_dbg(wpa_s, MSG_DEBUG, |
1511 | | " skip - no P2P element"); |
1512 | | return false; |
1513 | | } |
1514 | | p2p_ie = wpa_bss_get_vendor_ie_multi(bss, P2P_IE_VENDOR_TYPE); |
1515 | | if (!p2p_ie) { |
1516 | | if (debug_print) |
1517 | | wpa_dbg(wpa_s, MSG_DEBUG, |
1518 | | " skip - could not fetch P2P element"); |
1519 | | return false; |
1520 | | } |
1521 | | |
1522 | | if (p2p_parse_dev_addr_in_p2p_ie(p2p_ie, dev_addr) < 0 || |
1523 | | !ether_addr_equal(dev_addr, ssid->go_p2p_dev_addr)) { |
1524 | | if (debug_print) |
1525 | | wpa_dbg(wpa_s, MSG_DEBUG, |
1526 | | " skip - no matching GO P2P Device Address in P2P element"); |
1527 | | wpabuf_free(p2p_ie); |
1528 | | return false; |
1529 | | } |
1530 | | wpabuf_free(p2p_ie); |
1531 | | } |
1532 | | |
1533 | | /* |
1534 | | * TODO: skip the AP if its P2P IE has Group Formation bit set in the |
1535 | | * P2P Group Capability Bitmap and we are not in Group Formation with |
1536 | | * that device. |
1537 | | */ |
1538 | | #endif /* CONFIG_P2P */ |
1539 | | |
1540 | 0 | if (os_reltime_before(&bss->last_update, &wpa_s->scan_min_time)) { |
1541 | 0 | struct os_reltime diff; |
1542 | |
|
1543 | 0 | os_reltime_sub(&wpa_s->scan_min_time, &bss->last_update, &diff); |
1544 | 0 | if (debug_print) |
1545 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
1546 | 0 | " skip - scan result not recent enough (%u.%06u seconds too old)", |
1547 | 0 | (unsigned int) diff.sec, |
1548 | 0 | (unsigned int) diff.usec); |
1549 | 0 | return false; |
1550 | 0 | } |
1551 | | #ifdef CONFIG_MBO |
1552 | | #ifdef CONFIG_TESTING_OPTIONS |
1553 | | if (wpa_s->ignore_assoc_disallow) |
1554 | | goto skip_assoc_disallow; |
1555 | | #endif /* CONFIG_TESTING_OPTIONS */ |
1556 | | assoc_disallow = wpas_mbo_check_assoc_disallow(bss); |
1557 | | if (assoc_disallow && assoc_disallow[1] >= 1) { |
1558 | | if (debug_print) |
1559 | | wpa_dbg(wpa_s, MSG_DEBUG, |
1560 | | " skip - MBO association disallowed (reason %u)", |
1561 | | assoc_disallow[2]); |
1562 | | return false; |
1563 | | } |
1564 | | |
1565 | | if (wpa_is_bss_tmp_disallowed(wpa_s, bss)) { |
1566 | | if (debug_print) |
1567 | | wpa_dbg(wpa_s, MSG_DEBUG, |
1568 | | " skip - AP temporarily disallowed"); |
1569 | | return false; |
1570 | | } |
1571 | | #ifdef CONFIG_TESTING_OPTIONS |
1572 | | skip_assoc_disallow: |
1573 | | #endif /* CONFIG_TESTING_OPTIONS */ |
1574 | | #endif /* CONFIG_MBO */ |
1575 | | |
1576 | | #ifdef CONFIG_DPP |
1577 | | if ((ssid->key_mgmt & WPA_KEY_MGMT_DPP) && |
1578 | | !wpa_sm_pmksa_exists(wpa_s->wpa, bss->bssid, wpa_s->own_addr, |
1579 | | ssid) && |
1580 | | (!ssid->dpp_connector || !ssid->dpp_netaccesskey || |
1581 | | !ssid->dpp_csign)) { |
1582 | | if (debug_print) |
1583 | | wpa_dbg(wpa_s, MSG_DEBUG, |
1584 | | " skip - no PMKSA entry for DPP"); |
1585 | | return false; |
1586 | | } |
1587 | | #endif /* CONFIG_DPP */ |
1588 | | |
1589 | | #ifdef CONFIG_SAE_PK |
1590 | | if (ssid->sae_pk == SAE_PK_MODE_AUTOMATIC && |
1591 | | wpa_key_mgmt_sae(ssid->key_mgmt) && |
1592 | | ((ssid->sae_password && |
1593 | | sae_pk_valid_password(ssid->sae_password)) || |
1594 | | (!ssid->sae_password && ssid->passphrase && |
1595 | | sae_pk_valid_password(ssid->passphrase))) && |
1596 | | !(rsnxe_capa & BIT(WLAN_RSNX_CAPAB_SAE_PK)) && |
1597 | | sae_pk_acceptable_bss_with_pk(wpa_s, bss, ssid, match_ssid, |
1598 | | match_ssid_len)) { |
1599 | | if (debug_print) |
1600 | | wpa_dbg(wpa_s, MSG_DEBUG, |
1601 | | " skip - another acceptable BSS with SAE-PK in the same ESS"); |
1602 | | return false; |
1603 | | } |
1604 | | #endif /* CONFIG_SAE_PK */ |
1605 | | |
1606 | 0 | if (bss->ssid_len == 0) { |
1607 | | #ifdef CONFIG_OWE |
1608 | | const u8 *owe_ssid = NULL; |
1609 | | size_t owe_ssid_len = 0; |
1610 | | |
1611 | | owe_trans_ssid(wpa_s, bss, &owe_ssid, &owe_ssid_len); |
1612 | | if (owe_ssid && owe_ssid_len && |
1613 | | owe_ssid_len == ssid->ssid_len && |
1614 | | os_memcmp(owe_ssid, ssid->ssid, owe_ssid_len) == 0) { |
1615 | | if (debug_print) |
1616 | | wpa_dbg(wpa_s, MSG_DEBUG, |
1617 | | " skip - no SSID in BSS entry for a possible OWE transition mode BSS"); |
1618 | | int_array_add_unique(&wpa_s->owe_trans_scan_freq, |
1619 | | bss->freq); |
1620 | | return false; |
1621 | | } |
1622 | | #endif /* CONFIG_OWE */ |
1623 | 0 | if (debug_print) |
1624 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
1625 | 0 | " skip - no SSID known for the BSS"); |
1626 | 0 | return false; |
1627 | 0 | } |
1628 | | |
1629 | 0 | if (!link && !wpas_valid_ml_bss(wpa_s, bss)) { |
1630 | 0 | if (debug_print) |
1631 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
1632 | 0 | " skip - ML BSS going to be removed"); |
1633 | 0 | return false; |
1634 | 0 | } |
1635 | | |
1636 | | /* Matching configuration found */ |
1637 | 0 | return true; |
1638 | 0 | } |
1639 | | |
1640 | | |
1641 | | struct wpa_ssid * wpa_scan_res_match(struct wpa_supplicant *wpa_s, |
1642 | | int i, struct wpa_bss *bss, |
1643 | | struct wpa_ssid *group, |
1644 | | int only_first_ssid, int debug_print, |
1645 | | bool link) |
1646 | 0 | { |
1647 | 0 | u8 wpa_ie_len, rsn_ie_len; |
1648 | 0 | const u8 *ie; |
1649 | 0 | struct wpa_ssid *ssid; |
1650 | 0 | const u8 *match_ssid; |
1651 | 0 | size_t match_ssid_len; |
1652 | 0 | int bssid_ignore_count; |
1653 | |
|
1654 | 0 | ie = wpa_bss_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE); |
1655 | 0 | wpa_ie_len = ie ? ie[1] : 0; |
1656 | |
|
1657 | 0 | ie = wpa_bss_get_rsne(wpa_s, bss, NULL, false); |
1658 | 0 | rsn_ie_len = ie ? ie[1] : 0; |
1659 | |
|
1660 | 0 | if (debug_print) { |
1661 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "%d: " MACSTR |
1662 | 0 | " ssid='%s' wpa_ie_len=%u rsn_ie_len=%u caps=0x%x level=%d freq=%d %s%s", |
1663 | 0 | i, MAC2STR(bss->bssid), |
1664 | 0 | wpa_ssid_txt(bss->ssid, bss->ssid_len), |
1665 | 0 | wpa_ie_len, rsn_ie_len, bss->caps, bss->level, |
1666 | 0 | bss->freq, |
1667 | 0 | wpa_bss_get_vendor_ie(bss, WPS_IE_VENDOR_TYPE) ? |
1668 | 0 | " wps" : "", |
1669 | 0 | (wpa_bss_get_vendor_ie(bss, P2P_IE_VENDOR_TYPE) || |
1670 | 0 | wpa_bss_get_vendor_ie_beacon(bss, P2P_IE_VENDOR_TYPE)) |
1671 | 0 | ? " p2p" : ""); |
1672 | 0 | } |
1673 | |
|
1674 | 0 | bssid_ignore_count = wpa_bssid_ignore_is_listed(wpa_s, bss->bssid); |
1675 | 0 | if (bssid_ignore_count) { |
1676 | 0 | int limit = 1; |
1677 | 0 | if (wpa_supplicant_enabled_networks(wpa_s) == 1) { |
1678 | | /* |
1679 | | * When only a single network is enabled, we can |
1680 | | * trigger BSSID ignoring on the first failure. This |
1681 | | * should not be done with multiple enabled networks to |
1682 | | * avoid getting forced to move into a worse ESS on |
1683 | | * single error if there are no other BSSes of the |
1684 | | * current ESS. |
1685 | | */ |
1686 | 0 | limit = 0; |
1687 | 0 | } |
1688 | 0 | if (bssid_ignore_count > limit) { |
1689 | 0 | if (debug_print) { |
1690 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
1691 | 0 | " skip - BSSID ignored (count=%d limit=%d)", |
1692 | 0 | bssid_ignore_count, limit); |
1693 | 0 | } |
1694 | 0 | return NULL; |
1695 | 0 | } |
1696 | 0 | } |
1697 | | |
1698 | 0 | match_ssid = bss->ssid; |
1699 | 0 | match_ssid_len = bss->ssid_len; |
1700 | 0 | owe_trans_ssid(wpa_s, bss, &match_ssid, &match_ssid_len); |
1701 | |
|
1702 | 0 | if (match_ssid_len == 0) { |
1703 | 0 | if (debug_print) |
1704 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, " skip - SSID not known"); |
1705 | 0 | return NULL; |
1706 | 0 | } |
1707 | | |
1708 | 0 | if (disallowed_bssid(wpa_s, bss->bssid)) { |
1709 | 0 | if (debug_print) |
1710 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, " skip - BSSID disallowed"); |
1711 | 0 | return NULL; |
1712 | 0 | } |
1713 | | |
1714 | 0 | if (disallowed_ssid(wpa_s, match_ssid, match_ssid_len)) { |
1715 | 0 | if (debug_print) |
1716 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, " skip - SSID disallowed"); |
1717 | 0 | return NULL; |
1718 | 0 | } |
1719 | | |
1720 | 0 | if (disabled_freq(wpa_s, bss->freq)) { |
1721 | 0 | if (debug_print) |
1722 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, " skip - channel disabled"); |
1723 | 0 | return NULL; |
1724 | 0 | } |
1725 | | |
1726 | 0 | if (wnm_is_bss_excluded(wpa_s, bss)) { |
1727 | 0 | if (debug_print) |
1728 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, " skip - BSSID excluded"); |
1729 | 0 | return NULL; |
1730 | 0 | } |
1731 | | |
1732 | 0 | for (ssid = group; ssid; ssid = only_first_ssid ? NULL : ssid->pnext) { |
1733 | 0 | if (wpa_scan_res_ok(wpa_s, ssid, match_ssid, match_ssid_len, |
1734 | 0 | bss, bssid_ignore_count, debug_print, link)) |
1735 | 0 | return ssid; |
1736 | 0 | } |
1737 | | |
1738 | | /* No matching configuration found */ |
1739 | 0 | return NULL; |
1740 | 0 | } |
1741 | | |
1742 | | |
1743 | | struct wpa_bss * |
1744 | | wpa_supplicant_select_bss(struct wpa_supplicant *wpa_s, |
1745 | | struct wpa_ssid *group, |
1746 | | struct wpa_ssid **selected_ssid, |
1747 | | int only_first_ssid) |
1748 | 1.12k | { |
1749 | 1.12k | unsigned int i; |
1750 | | |
1751 | 1.12k | if (wpa_s->current_ssid) { |
1752 | 1.12k | struct wpa_ssid *ssid; |
1753 | | |
1754 | 1.12k | wpa_dbg(wpa_s, MSG_DEBUG, |
1755 | 1.12k | "Scan results matching the currently selected network"); |
1756 | 1.12k | for (i = 0; i < wpa_s->last_scan_res_used; i++) { |
1757 | 0 | struct wpa_bss *bss = wpa_s->last_scan_res[i]; |
1758 | |
|
1759 | 0 | ssid = wpa_scan_res_match(wpa_s, i, bss, group, |
1760 | 0 | only_first_ssid, 0, false); |
1761 | 0 | if (ssid != wpa_s->current_ssid) |
1762 | 0 | continue; |
1763 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "%u: " MACSTR |
1764 | 0 | " freq=%d level=%d snr=%d est_throughput=%u", |
1765 | 0 | i, MAC2STR(bss->bssid), bss->freq, bss->level, |
1766 | 0 | bss->snr, bss->est_throughput); |
1767 | 0 | } |
1768 | 1.12k | } |
1769 | | |
1770 | 1.12k | if (only_first_ssid) |
1771 | 1.12k | wpa_dbg(wpa_s, MSG_DEBUG, "Try to find BSS matching pre-selected network id=%d", |
1772 | 1.12k | group->id); |
1773 | 0 | else |
1774 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "Selecting BSS from priority group %d", |
1775 | 1.12k | group->priority); |
1776 | | |
1777 | 1.12k | for (i = 0; i < wpa_s->last_scan_res_used; i++) { |
1778 | 0 | struct wpa_bss *bss = wpa_s->last_scan_res[i]; |
1779 | |
|
1780 | 0 | wpa_s->owe_transition_select = 1; |
1781 | 0 | *selected_ssid = wpa_scan_res_match(wpa_s, i, bss, group, |
1782 | 0 | only_first_ssid, 1, false); |
1783 | 0 | wpa_s->owe_transition_select = 0; |
1784 | 0 | if (!*selected_ssid) |
1785 | 0 | continue; |
1786 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, " selected %sBSS " MACSTR |
1787 | 0 | " ssid='%s'", |
1788 | 0 | bss == wpa_s->current_bss ? "current ": "", |
1789 | 0 | MAC2STR(bss->bssid), |
1790 | 0 | wpa_ssid_txt(bss->ssid, bss->ssid_len)); |
1791 | 0 | return bss; |
1792 | 0 | } |
1793 | | |
1794 | 1.12k | return NULL; |
1795 | 1.12k | } |
1796 | | |
1797 | | |
1798 | | struct wpa_bss * wpa_supplicant_pick_network(struct wpa_supplicant *wpa_s, |
1799 | | struct wpa_ssid **selected_ssid, |
1800 | | bool clear_ignorelist) |
1801 | 0 | { |
1802 | 0 | struct wpa_bss *selected = NULL; |
1803 | 0 | size_t prio; |
1804 | 0 | struct wpa_ssid *next_ssid = NULL; |
1805 | 0 | struct wpa_ssid *ssid; |
1806 | |
|
1807 | 0 | if (wpa_s->last_scan_res == NULL || |
1808 | 0 | wpa_s->last_scan_res_used == 0) |
1809 | 0 | return NULL; /* no scan results from last update */ |
1810 | | |
1811 | 0 | if (wpa_s->next_ssid) { |
1812 | | /* check that next_ssid is still valid */ |
1813 | 0 | for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next) { |
1814 | 0 | if (ssid == wpa_s->next_ssid) |
1815 | 0 | break; |
1816 | 0 | } |
1817 | 0 | next_ssid = ssid; |
1818 | 0 | wpa_s->next_ssid = NULL; |
1819 | 0 | } |
1820 | |
|
1821 | 0 | while (selected == NULL) { |
1822 | 0 | for (prio = 0; prio < wpa_s->conf->num_prio; prio++) { |
1823 | 0 | if (next_ssid && next_ssid->priority == |
1824 | 0 | wpa_s->conf->pssid[prio]->priority) { |
1825 | 0 | selected = wpa_supplicant_select_bss( |
1826 | 0 | wpa_s, next_ssid, selected_ssid, 1); |
1827 | 0 | if (selected) |
1828 | 0 | break; |
1829 | 0 | } |
1830 | 0 | selected = wpa_supplicant_select_bss( |
1831 | 0 | wpa_s, wpa_s->conf->pssid[prio], |
1832 | 0 | selected_ssid, 0); |
1833 | 0 | if (selected) |
1834 | 0 | break; |
1835 | 0 | } |
1836 | |
|
1837 | 0 | if (!selected && |
1838 | 0 | (wpa_s->bssid_ignore || wnm_active_bss_trans_mgmt(wpa_s)) && |
1839 | 0 | !wpa_s->countermeasures && clear_ignorelist) { |
1840 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
1841 | 0 | "No APs found - clear BSSID ignore list and try again"); |
1842 | 0 | wnm_btm_reset(wpa_s); |
1843 | 0 | wpa_bssid_ignore_clear(wpa_s); |
1844 | 0 | wpa_s->bssid_ignore_cleared = true; |
1845 | 0 | } else if (selected == NULL) |
1846 | 0 | break; |
1847 | 0 | } |
1848 | |
|
1849 | 0 | ssid = *selected_ssid; |
1850 | 0 | if (selected && ssid && ssid->mem_only_psk && !ssid->psk_set && |
1851 | 0 | !ssid->passphrase && !ssid->ext_psk) { |
1852 | 0 | const char *field_name, *txt = NULL; |
1853 | |
|
1854 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
1855 | 0 | "PSK/passphrase not yet available for the selected network"); |
1856 | |
|
1857 | 0 | wpas_notify_network_request(wpa_s, ssid, |
1858 | 0 | WPA_CTRL_REQ_PSK_PASSPHRASE, NULL); |
1859 | |
|
1860 | 0 | field_name = wpa_supplicant_ctrl_req_to_string( |
1861 | 0 | WPA_CTRL_REQ_PSK_PASSPHRASE, NULL, &txt); |
1862 | 0 | if (field_name == NULL) |
1863 | 0 | return NULL; |
1864 | | |
1865 | 0 | wpas_send_ctrl_req(wpa_s, ssid, field_name, txt); |
1866 | |
|
1867 | 0 | selected = NULL; |
1868 | 0 | } |
1869 | | |
1870 | 0 | return selected; |
1871 | 0 | } |
1872 | | |
1873 | | |
1874 | | static void wpa_supplicant_req_new_scan(struct wpa_supplicant *wpa_s, |
1875 | | int timeout_sec, int timeout_usec) |
1876 | 0 | { |
1877 | 0 | if (!wpa_supplicant_enabled_networks(wpa_s)) { |
1878 | | /* |
1879 | | * No networks are enabled; short-circuit request so |
1880 | | * we don't wait timeout seconds before transitioning |
1881 | | * to INACTIVE state. |
1882 | | */ |
1883 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "Short-circuit new scan request " |
1884 | 0 | "since there are no enabled networks"); |
1885 | 0 | wpa_supplicant_set_state(wpa_s, WPA_INACTIVE); |
1886 | 0 | return; |
1887 | 0 | } |
1888 | | |
1889 | 0 | wpa_s->scan_for_connection = 1; |
1890 | 0 | wpa_supplicant_req_scan(wpa_s, timeout_sec, timeout_usec); |
1891 | 0 | } |
1892 | | |
1893 | | |
1894 | | static bool ml_link_probe_scan(struct wpa_supplicant *wpa_s) |
1895 | 0 | { |
1896 | 0 | if (!wpa_s->ml_connect_probe_ssid || !wpa_s->ml_connect_probe_bss) |
1897 | 0 | return false; |
1898 | | |
1899 | 0 | wpa_msg(wpa_s, MSG_DEBUG, |
1900 | 0 | "Request association with " MACSTR " after ML probe", |
1901 | 0 | MAC2STR(wpa_s->ml_connect_probe_bss->bssid)); |
1902 | |
|
1903 | 0 | wpa_supplicant_associate(wpa_s, wpa_s->ml_connect_probe_bss, |
1904 | 0 | wpa_s->ml_connect_probe_ssid); |
1905 | |
|
1906 | 0 | wpa_s->ml_connect_probe_ssid = NULL; |
1907 | 0 | wpa_s->ml_connect_probe_bss = NULL; |
1908 | |
|
1909 | 0 | return true; |
1910 | 0 | } |
1911 | | |
1912 | | |
1913 | | static int wpa_supplicant_connect_ml_missing(struct wpa_supplicant *wpa_s, |
1914 | | struct wpa_bss *selected, |
1915 | | struct wpa_ssid *ssid) |
1916 | 0 | { |
1917 | 0 | int *freqs; |
1918 | 0 | u16 missing_links = 0, removed_links, usable_links; |
1919 | |
|
1920 | 0 | if (!((wpa_s->drv_flags2 & WPA_DRIVER_FLAGS2_MLO) && |
1921 | 0 | (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME))) |
1922 | 0 | return 0; |
1923 | | |
1924 | 0 | usable_links = wpa_bss_get_usable_links(wpa_s, selected, ssid, |
1925 | 0 | &missing_links); |
1926 | 0 | if (!usable_links || !missing_links) |
1927 | 0 | return 0; |
1928 | | |
1929 | 0 | removed_links = wpa_bss_parse_reconf_ml_element(wpa_s, selected); |
1930 | 0 | missing_links &= ~removed_links; |
1931 | |
|
1932 | 0 | if (!missing_links) |
1933 | 0 | return 0; |
1934 | | |
1935 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
1936 | 0 | "MLD: Doing an ML probe for missing links 0x%04x", |
1937 | 0 | missing_links); |
1938 | |
|
1939 | 0 | freqs = os_malloc(sizeof(int) * 2); |
1940 | 0 | if (!freqs) |
1941 | 0 | return 0; |
1942 | | |
1943 | 0 | wpa_s->ml_connect_probe_ssid = ssid; |
1944 | 0 | wpa_s->ml_connect_probe_bss = selected; |
1945 | |
|
1946 | 0 | freqs[0] = selected->freq; |
1947 | 0 | freqs[1] = 0; |
1948 | |
|
1949 | 0 | wpa_s->manual_scan_passive = 0; |
1950 | 0 | wpa_s->manual_scan_use_id = 0; |
1951 | 0 | wpa_s->manual_scan_only_new = 0; |
1952 | 0 | wpa_s->scan_id_count = 0; |
1953 | 0 | os_free(wpa_s->manual_scan_freqs); |
1954 | 0 | wpa_s->manual_scan_freqs = freqs; |
1955 | |
|
1956 | 0 | os_memcpy(wpa_s->ml_probe_bssid, selected->bssid, ETH_ALEN); |
1957 | | |
1958 | | /* |
1959 | | * In case the ML probe request is intended to retrieve information from |
1960 | | * the transmitted BSS, the AP MLD ID should be included and should be |
1961 | | * set to zero. |
1962 | | * In case the ML probe requested is intended to retrieve information |
1963 | | * from a non-transmitted BSS, the AP MLD ID should not be included. |
1964 | | */ |
1965 | 0 | if (selected->mld_bss_non_transmitted) |
1966 | 0 | wpa_s->ml_probe_mld_id = -1; |
1967 | 0 | else |
1968 | 0 | wpa_s->ml_probe_mld_id = 0; |
1969 | |
|
1970 | 0 | if (ssid && ssid->ssid_len) { |
1971 | 0 | os_free(wpa_s->ssids_from_scan_req); |
1972 | 0 | wpa_s->num_ssids_from_scan_req = 0; |
1973 | |
|
1974 | 0 | wpa_s->ssids_from_scan_req = |
1975 | 0 | os_zalloc(sizeof(struct wpa_ssid_value)); |
1976 | 0 | if (wpa_s->ssids_from_scan_req) { |
1977 | 0 | wpa_printf(MSG_DEBUG, |
1978 | 0 | "MLD: ML probe: With direct SSID"); |
1979 | |
|
1980 | 0 | wpa_s->num_ssids_from_scan_req = 1; |
1981 | 0 | wpa_s->ssids_from_scan_req[0].ssid_len = ssid->ssid_len; |
1982 | 0 | os_memcpy(wpa_s->ssids_from_scan_req[0].ssid, |
1983 | 0 | ssid->ssid, ssid->ssid_len); |
1984 | 0 | } |
1985 | 0 | } |
1986 | |
|
1987 | 0 | wpa_s->ml_probe_links = missing_links; |
1988 | |
|
1989 | 0 | wpa_s->normal_scans = 0; |
1990 | 0 | wpa_s->scan_req = MANUAL_SCAN_REQ; |
1991 | 0 | wpa_s->after_wps = 0; |
1992 | 0 | wpa_s->known_wps_freq = 0; |
1993 | 0 | wpa_supplicant_req_scan(wpa_s, 0, 0); |
1994 | |
|
1995 | 0 | return 1; |
1996 | 0 | } |
1997 | | |
1998 | | |
1999 | | int wpa_supplicant_connect(struct wpa_supplicant *wpa_s, |
2000 | | struct wpa_bss *selected, |
2001 | | struct wpa_ssid *ssid) |
2002 | 0 | { |
2003 | 0 | #ifdef IEEE8021X_EAPOL |
2004 | 0 | if ((eap_is_wps_pbc_enrollee(&ssid->eap) && |
2005 | 0 | wpas_wps_partner_link_overlap_detect(wpa_s)) || |
2006 | 0 | wpas_wps_scan_pbc_overlap(wpa_s, selected, ssid)) { |
2007 | 0 | wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_OVERLAP |
2008 | 0 | "PBC session overlap"); |
2009 | 0 | wpas_notify_wps_event_pbc_overlap(wpa_s); |
2010 | 0 | wpa_s->wps_overlap = true; |
2011 | | #ifdef CONFIG_P2P |
2012 | | if (wpa_s->p2p_group_interface == P2P_GROUP_INTERFACE_CLIENT || |
2013 | | wpa_s->p2p_in_provisioning) { |
2014 | | eloop_register_timeout(0, 0, wpas_p2p_pbc_overlap_cb, |
2015 | | wpa_s, NULL); |
2016 | | return -1; |
2017 | | } |
2018 | | #endif /* CONFIG_P2P */ |
2019 | |
|
2020 | | #ifdef CONFIG_WPS |
2021 | | wpas_wps_pbc_overlap(wpa_s); |
2022 | | wpas_wps_cancel(wpa_s); |
2023 | | #endif /* CONFIG_WPS */ |
2024 | 0 | return -1; |
2025 | 0 | } |
2026 | 0 | #endif /* IEEE8021X_EAPOL */ |
2027 | | |
2028 | 0 | wpa_msg(wpa_s, MSG_DEBUG, |
2029 | 0 | "Considering connect request: reassociate: %d selected: " |
2030 | 0 | MACSTR " bssid: " MACSTR " pending: " MACSTR |
2031 | 0 | " wpa_state: %s ssid=%p current_ssid=%p", |
2032 | 0 | wpa_s->reassociate, MAC2STR(selected->bssid), |
2033 | 0 | MAC2STR(wpa_s->bssid), MAC2STR(wpa_s->pending_bssid), |
2034 | 0 | wpa_supplicant_state_txt(wpa_s->wpa_state), |
2035 | 0 | ssid, wpa_s->current_ssid); |
2036 | | |
2037 | | /* |
2038 | | * Do not trigger new association unless the BSSID has changed or if |
2039 | | * reassociation is requested. If we are in process of associating with |
2040 | | * the selected BSSID, do not trigger new attempt. |
2041 | | */ |
2042 | 0 | if (wpa_s->reassociate || |
2043 | 0 | (!ether_addr_equal(selected->bssid, wpa_s->bssid) && |
2044 | 0 | ((wpa_s->wpa_state != WPA_ASSOCIATING && |
2045 | 0 | wpa_s->wpa_state != WPA_AUTHENTICATING) || |
2046 | 0 | (!is_zero_ether_addr(wpa_s->pending_bssid) && |
2047 | 0 | !ether_addr_equal(selected->bssid, wpa_s->pending_bssid)) || |
2048 | 0 | (is_zero_ether_addr(wpa_s->pending_bssid) && |
2049 | 0 | ssid != wpa_s->current_ssid)))) { |
2050 | 0 | if (wpa_supplicant_scard_init(wpa_s, ssid)) { |
2051 | 0 | wpa_supplicant_req_new_scan(wpa_s, 10, 0); |
2052 | 0 | return 0; |
2053 | 0 | } |
2054 | | |
2055 | 0 | if (wpa_supplicant_connect_ml_missing(wpa_s, selected, ssid)) |
2056 | 0 | return 0; |
2057 | | |
2058 | 0 | wpa_msg(wpa_s, MSG_DEBUG, "Request association with " MACSTR, |
2059 | 0 | MAC2STR(selected->bssid)); |
2060 | 0 | wpa_supplicant_associate(wpa_s, selected, ssid); |
2061 | 0 | } else { |
2062 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "Already associated or trying to " |
2063 | 0 | "connect with the selected AP"); |
2064 | 0 | } |
2065 | | |
2066 | 0 | return 0; |
2067 | 0 | } |
2068 | | |
2069 | | |
2070 | | static struct wpa_ssid * |
2071 | | wpa_supplicant_pick_new_network(struct wpa_supplicant *wpa_s) |
2072 | 0 | { |
2073 | 0 | size_t prio; |
2074 | 0 | struct wpa_ssid *ssid; |
2075 | |
|
2076 | 0 | for (prio = 0; prio < wpa_s->conf->num_prio; prio++) { |
2077 | 0 | for (ssid = wpa_s->conf->pssid[prio]; ssid; ssid = ssid->pnext) |
2078 | 0 | { |
2079 | 0 | if (wpas_network_disabled(wpa_s, ssid)) |
2080 | 0 | continue; |
2081 | 0 | #ifndef CONFIG_IBSS_RSN |
2082 | 0 | if (ssid->mode == WPAS_MODE_IBSS && |
2083 | 0 | !(ssid->key_mgmt & (WPA_KEY_MGMT_NONE | |
2084 | 0 | WPA_KEY_MGMT_WPA_NONE))) { |
2085 | 0 | wpa_msg(wpa_s, MSG_INFO, |
2086 | 0 | "IBSS RSN not supported in the build - cannot use the profile for SSID '%s'", |
2087 | 0 | wpa_ssid_txt(ssid->ssid, |
2088 | 0 | ssid->ssid_len)); |
2089 | 0 | continue; |
2090 | 0 | } |
2091 | 0 | #endif /* !CONFIG_IBSS_RSN */ |
2092 | 0 | if (ssid->mode == WPAS_MODE_IBSS || |
2093 | 0 | ssid->mode == WPAS_MODE_AP || |
2094 | 0 | ssid->mode == WPAS_MODE_MESH) |
2095 | 0 | return ssid; |
2096 | 0 | } |
2097 | 0 | } |
2098 | 0 | return NULL; |
2099 | 0 | } |
2100 | | |
2101 | | |
2102 | | /* TODO: move the rsn_preauth_scan_result*() to be called from notify.c based |
2103 | | * on BSS added and BSS changed events */ |
2104 | | static void wpa_supplicant_rsn_preauth_scan_results( |
2105 | | struct wpa_supplicant *wpa_s) |
2106 | 0 | { |
2107 | 0 | struct wpa_bss *bss; |
2108 | |
|
2109 | 0 | if (rsn_preauth_scan_results(wpa_s->wpa) < 0) |
2110 | 0 | return; |
2111 | | |
2112 | 0 | dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) { |
2113 | 0 | const u8 *ssid, *rsn; |
2114 | |
|
2115 | 0 | ssid = wpa_bss_get_ie(bss, WLAN_EID_SSID); |
2116 | 0 | if (ssid == NULL) |
2117 | 0 | continue; |
2118 | | |
2119 | 0 | rsn = wpa_bss_get_rsne(wpa_s, bss, NULL, false); |
2120 | 0 | if (rsn == NULL) |
2121 | 0 | continue; |
2122 | | |
2123 | 0 | rsn_preauth_scan_result(wpa_s->wpa, bss->bssid, ssid, rsn); |
2124 | 0 | } |
2125 | |
|
2126 | 0 | } |
2127 | | |
2128 | | |
2129 | | #ifndef CONFIG_NO_ROAMING |
2130 | | |
2131 | | static int wpas_get_snr_signal_info(u32 frequency, int avg_signal, int noise) |
2132 | 0 | { |
2133 | 0 | if (noise == WPA_INVALID_NOISE) { |
2134 | 0 | if (IS_5GHZ(frequency)) { |
2135 | 0 | noise = DEFAULT_NOISE_FLOOR_5GHZ; |
2136 | 0 | } else if (is_6ghz_freq(frequency)) { |
2137 | 0 | noise = DEFAULT_NOISE_FLOOR_6GHZ; |
2138 | 0 | } else { |
2139 | 0 | noise = DEFAULT_NOISE_FLOOR_2GHZ; |
2140 | 0 | } |
2141 | 0 | } |
2142 | 0 | return avg_signal - noise; |
2143 | 0 | } |
2144 | | |
2145 | | |
2146 | | static unsigned int |
2147 | | wpas_get_est_throughput_from_bss_snr(const struct wpa_supplicant *wpa_s, |
2148 | | const struct wpa_bss *bss, int snr) |
2149 | 0 | { |
2150 | 0 | int rate = wpa_bss_get_max_rate(bss); |
2151 | 0 | const u8 *ies = wpa_bss_ie_ptr(bss); |
2152 | 0 | size_t ie_len = bss->ie_len ? bss->ie_len : bss->beacon_ie_len; |
2153 | 0 | enum chan_width max_cw = CHAN_WIDTH_UNKNOWN; |
2154 | |
|
2155 | 0 | return wpas_get_est_tpt(wpa_s, ies, ie_len, rate, snr, bss->freq, |
2156 | 0 | &max_cw); |
2157 | 0 | } |
2158 | | |
2159 | | |
2160 | | static int wpas_evaluate_band_score(int frequency) |
2161 | 0 | { |
2162 | 0 | if (is_6ghz_freq(frequency)) |
2163 | 0 | return 2; |
2164 | 0 | if (IS_5GHZ(frequency)) |
2165 | 0 | return 1; |
2166 | 0 | return 0; |
2167 | 0 | } |
2168 | | |
2169 | | |
2170 | | int wpa_supplicant_need_to_roam_within_ess(struct wpa_supplicant *wpa_s, |
2171 | | struct wpa_bss *current_bss, |
2172 | | struct wpa_bss *selected, |
2173 | | bool poll_current) |
2174 | 0 | { |
2175 | 0 | int min_diff, diff; |
2176 | 0 | int cur_band_score, sel_band_score; |
2177 | 0 | int to_5ghz, to_6ghz; |
2178 | 0 | int cur_level, sel_level; |
2179 | 0 | unsigned int cur_est, sel_est; |
2180 | 0 | struct wpa_signal_info si; |
2181 | 0 | int cur_snr = 0; |
2182 | 0 | int ret = 0; |
2183 | 0 | const u8 *cur_ies = wpa_bss_ie_ptr(current_bss); |
2184 | 0 | const u8 *sel_ies = wpa_bss_ie_ptr(selected); |
2185 | 0 | size_t cur_ie_len = current_bss->ie_len ? current_bss->ie_len : |
2186 | 0 | current_bss->beacon_ie_len; |
2187 | 0 | size_t sel_ie_len = selected->ie_len ? selected->ie_len : |
2188 | 0 | selected->beacon_ie_len; |
2189 | |
|
2190 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "Considering within-ESS reassociation"); |
2191 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "Current BSS: " MACSTR |
2192 | 0 | " freq=%d level=%d snr=%d est_throughput=%u", |
2193 | 0 | MAC2STR(current_bss->bssid), |
2194 | 0 | current_bss->freq, current_bss->level, |
2195 | 0 | current_bss->snr, current_bss->est_throughput); |
2196 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "Selected BSS: " MACSTR |
2197 | 0 | " freq=%d level=%d snr=%d est_throughput=%u", |
2198 | 0 | MAC2STR(selected->bssid), selected->freq, selected->level, |
2199 | 0 | selected->snr, selected->est_throughput); |
2200 | |
|
2201 | 0 | if (wpas_ap_link_address(wpa_s, selected->bssid)) { |
2202 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "MLD: associated to selected BSS"); |
2203 | 0 | return 0; |
2204 | 0 | } |
2205 | | |
2206 | 0 | if (wpa_s->current_ssid->bssid_set && |
2207 | 0 | ether_addr_equal(selected->bssid, wpa_s->current_ssid->bssid)) { |
2208 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "Allow reassociation - selected BSS " |
2209 | 0 | "has preferred BSSID"); |
2210 | 0 | return 1; |
2211 | 0 | } |
2212 | | |
2213 | | /* |
2214 | | * Try to poll the signal from the driver since this will allow to get |
2215 | | * more accurate values. In some cases, there can be big differences |
2216 | | * between the RSSI of the Probe Response frames of the AP we are |
2217 | | * associated with and the Beacon frames we hear from the same AP after |
2218 | | * association. This can happen, e.g., when there are two antennas that |
2219 | | * hear the AP very differently. If the driver chooses to hear the |
2220 | | * Probe Response frames during the scan on the "bad" antenna because |
2221 | | * it wants to save power, but knows to choose the other antenna after |
2222 | | * association, we will hear our AP with a low RSSI as part of the |
2223 | | * scan even when we can hear it decently on the other antenna. To cope |
2224 | | * with this, ask the driver to teach us how it hears the AP. Also, the |
2225 | | * scan results may be a bit old, since we can very quickly get fresh |
2226 | | * information about our currently associated AP. |
2227 | | */ |
2228 | 0 | if (poll_current && wpa_drv_signal_poll(wpa_s, &si) == 0 && |
2229 | 0 | (si.data.avg_beacon_signal || si.data.avg_signal)) { |
2230 | | /* |
2231 | | * Normalize avg_signal to the RSSI over 20 MHz, as the |
2232 | | * throughput is estimated based on the RSSI over 20 MHz |
2233 | | */ |
2234 | 0 | cur_level = si.data.avg_beacon_signal ? |
2235 | 0 | si.data.avg_beacon_signal : |
2236 | 0 | (si.data.avg_signal - |
2237 | 0 | wpas_channel_width_rssi_bump(cur_ies, cur_ie_len, |
2238 | 0 | si.chanwidth)); |
2239 | 0 | cur_snr = wpas_get_snr_signal_info(si.frequency, cur_level, |
2240 | 0 | si.current_noise); |
2241 | |
|
2242 | 0 | cur_est = wpas_get_est_throughput_from_bss_snr(wpa_s, |
2243 | 0 | current_bss, |
2244 | 0 | cur_snr); |
2245 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
2246 | 0 | "Using signal poll values for the current BSS: level=%d snr=%d est_throughput=%u", |
2247 | 0 | cur_level, cur_snr, cur_est); |
2248 | 0 | } else { |
2249 | | /* Level and SNR are measured over 20 MHz channel */ |
2250 | 0 | cur_level = current_bss->level; |
2251 | 0 | cur_snr = current_bss->snr; |
2252 | 0 | cur_est = current_bss->est_throughput; |
2253 | 0 | } |
2254 | | |
2255 | | /* Adjust the SNR of BSSes based on the channel width. */ |
2256 | 0 | cur_level += wpas_channel_width_rssi_bump(cur_ies, cur_ie_len, |
2257 | 0 | current_bss->max_cw); |
2258 | 0 | cur_snr = wpas_adjust_snr_by_chanwidth(cur_ies, cur_ie_len, |
2259 | 0 | current_bss->max_cw, cur_snr); |
2260 | |
|
2261 | 0 | sel_est = selected->est_throughput; |
2262 | 0 | sel_level = selected->level + |
2263 | 0 | wpas_channel_width_rssi_bump(sel_ies, sel_ie_len, |
2264 | 0 | selected->max_cw); |
2265 | |
|
2266 | 0 | if (sel_est > cur_est + 5000) { |
2267 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
2268 | 0 | "Allow reassociation - selected BSS has better estimated throughput"); |
2269 | 0 | return 1; |
2270 | 0 | } |
2271 | | |
2272 | 0 | to_5ghz = selected->freq > 4000 && current_bss->freq < 4000; |
2273 | 0 | to_6ghz = is_6ghz_freq(selected->freq) && |
2274 | 0 | !is_6ghz_freq(current_bss->freq); |
2275 | |
|
2276 | 0 | if (cur_level < 0 && |
2277 | 0 | cur_level > sel_level + to_5ghz * 2 + to_6ghz * 2 && |
2278 | 0 | sel_est < cur_est * 1.2) { |
2279 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "Skip roam - Current BSS has better " |
2280 | 0 | "signal level"); |
2281 | 0 | return 0; |
2282 | 0 | } |
2283 | | |
2284 | 0 | if (cur_est > sel_est + 5000) { |
2285 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
2286 | 0 | "Skip roam - Current BSS has better estimated throughput"); |
2287 | 0 | return 0; |
2288 | 0 | } |
2289 | | |
2290 | 0 | if (cur_snr > GREAT_SNR) { |
2291 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
2292 | 0 | "Skip roam - Current BSS has good SNR (%u > %u)", |
2293 | 0 | cur_snr, GREAT_SNR); |
2294 | 0 | return 0; |
2295 | 0 | } |
2296 | | |
2297 | 0 | if (cur_level < -85) /* ..-86 dBm */ |
2298 | 0 | min_diff = 1; |
2299 | 0 | else if (cur_level < -80) /* -85..-81 dBm */ |
2300 | 0 | min_diff = 2; |
2301 | 0 | else if (cur_level < -75) /* -80..-76 dBm */ |
2302 | 0 | min_diff = 3; |
2303 | 0 | else if (cur_level < -70) /* -75..-71 dBm */ |
2304 | 0 | min_diff = 4; |
2305 | 0 | else if (cur_level < 0) /* -70..-1 dBm */ |
2306 | 0 | min_diff = 5; |
2307 | 0 | else /* unspecified units (not in dBm) */ |
2308 | 0 | min_diff = 2; |
2309 | |
|
2310 | 0 | if (cur_est > sel_est * 1.5) |
2311 | 0 | min_diff += 10; |
2312 | 0 | else if (cur_est > sel_est * 1.2) |
2313 | 0 | min_diff += 5; |
2314 | 0 | else if (cur_est > sel_est * 1.1) |
2315 | 0 | min_diff += 2; |
2316 | 0 | else if (cur_est > sel_est) |
2317 | 0 | min_diff++; |
2318 | 0 | else if (sel_est > cur_est * 1.5) |
2319 | 0 | min_diff -= 10; |
2320 | 0 | else if (sel_est > cur_est * 1.2) |
2321 | 0 | min_diff -= 5; |
2322 | 0 | else if (sel_est > cur_est * 1.1) |
2323 | 0 | min_diff -= 2; |
2324 | 0 | else if (sel_est > cur_est) |
2325 | 0 | min_diff--; |
2326 | |
|
2327 | 0 | cur_band_score = wpas_evaluate_band_score(current_bss->freq); |
2328 | 0 | sel_band_score = wpas_evaluate_band_score(selected->freq); |
2329 | 0 | min_diff += (cur_band_score - sel_band_score) * 2; |
2330 | 0 | if (wpa_s->signal_threshold && cur_level <= wpa_s->signal_threshold && |
2331 | 0 | sel_level > wpa_s->signal_threshold) |
2332 | 0 | min_diff -= 2; |
2333 | 0 | diff = sel_level - cur_level; |
2334 | 0 | if (diff < min_diff) { |
2335 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
2336 | 0 | "Skip roam - too small difference in signal level (%d < %d)", |
2337 | 0 | diff, min_diff); |
2338 | 0 | ret = 0; |
2339 | 0 | } else { |
2340 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
2341 | 0 | "Allow reassociation due to difference in signal level (%d >= %d)", |
2342 | 0 | diff, min_diff); |
2343 | 0 | ret = 1; |
2344 | 0 | } |
2345 | 0 | wpa_msg_ctrl(wpa_s, MSG_INFO, "%scur_bssid=" MACSTR |
2346 | 0 | " cur_freq=%d cur_level=%d cur_est=%d sel_bssid=" MACSTR |
2347 | 0 | " sel_freq=%d sel_level=%d sel_est=%d", |
2348 | 0 | ret ? WPA_EVENT_DO_ROAM : WPA_EVENT_SKIP_ROAM, |
2349 | 0 | MAC2STR(current_bss->bssid), |
2350 | 0 | current_bss->freq, cur_level, cur_est, |
2351 | 0 | MAC2STR(selected->bssid), |
2352 | 0 | selected->freq, sel_level, sel_est); |
2353 | 0 | return ret; |
2354 | 0 | } |
2355 | | |
2356 | | #endif /* CONFIG_NO_ROAMING */ |
2357 | | |
2358 | | |
2359 | | static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s, |
2360 | | struct wpa_bss *selected, |
2361 | | struct wpa_ssid *ssid) |
2362 | 0 | { |
2363 | 0 | struct wpa_bss *current_bss = NULL; |
2364 | 0 | const u8 *bssid; |
2365 | |
|
2366 | 0 | if (wpa_s->reassociate) |
2367 | 0 | return 1; /* explicit request to reassociate */ |
2368 | 0 | if (wpa_s->wpa_state < WPA_ASSOCIATED) |
2369 | 0 | return 1; /* we are not associated; continue */ |
2370 | 0 | if (wpa_s->current_ssid == NULL) |
2371 | 0 | return 1; /* unknown current SSID */ |
2372 | 0 | if (wpa_s->current_ssid != ssid) |
2373 | 0 | return 1; /* different network block */ |
2374 | | |
2375 | 0 | if (wpas_driver_bss_selection(wpa_s)) |
2376 | 0 | return 0; /* Driver-based roaming */ |
2377 | | |
2378 | 0 | if (wpa_s->valid_links) |
2379 | 0 | bssid = wpa_s->links[wpa_s->mlo_assoc_link_id].bssid; |
2380 | 0 | else |
2381 | 0 | bssid = wpa_s->bssid; |
2382 | |
|
2383 | 0 | if (wpa_s->current_ssid->ssid) |
2384 | 0 | current_bss = wpa_bss_get(wpa_s, bssid, |
2385 | 0 | wpa_s->current_ssid->ssid, |
2386 | 0 | wpa_s->current_ssid->ssid_len); |
2387 | 0 | if (!current_bss) |
2388 | 0 | current_bss = wpa_bss_get_bssid(wpa_s, bssid); |
2389 | |
|
2390 | 0 | if (!current_bss) |
2391 | 0 | return 1; /* current BSS not seen in scan results */ |
2392 | | |
2393 | 0 | if (current_bss == selected) |
2394 | 0 | return 0; |
2395 | | |
2396 | 0 | if (selected->last_update_idx > current_bss->last_update_idx) |
2397 | 0 | return 1; /* current BSS not seen in the last scan */ |
2398 | | |
2399 | 0 | #ifndef CONFIG_NO_ROAMING |
2400 | 0 | return wpa_supplicant_need_to_roam_within_ess(wpa_s, current_bss, |
2401 | 0 | selected, true); |
2402 | | #else /* CONFIG_NO_ROAMING */ |
2403 | | return 0; |
2404 | | #endif /* CONFIG_NO_ROAMING */ |
2405 | 0 | } |
2406 | | |
2407 | | |
2408 | | static int wpas_trigger_6ghz_scan(struct wpa_supplicant *wpa_s, |
2409 | | union wpa_event_data *data) |
2410 | 0 | { |
2411 | 0 | struct wpa_driver_scan_params params; |
2412 | 0 | unsigned int j; |
2413 | |
|
2414 | 0 | wpa_dbg(wpa_s, MSG_INFO, "Triggering 6GHz-only scan"); |
2415 | 0 | os_memset(¶ms, 0, sizeof(params)); |
2416 | 0 | params.non_coloc_6ghz = wpa_s->last_scan_non_coloc_6ghz; |
2417 | 0 | for (j = 0; j < data->scan_info.num_ssids; j++) |
2418 | 0 | params.ssids[j] = data->scan_info.ssids[j]; |
2419 | 0 | params.num_ssids = data->scan_info.num_ssids; |
2420 | 0 | wpa_add_scan_freqs_list(wpa_s, HOSTAPD_MODE_IEEE80211A, ¶ms, |
2421 | 0 | true, false, false); |
2422 | 0 | if (!wpa_supplicant_trigger_scan(wpa_s, ¶ms, true, true)) { |
2423 | 0 | wpa_s->scan_in_progress_6ghz = true; |
2424 | 0 | wpas_notify_scan_in_progress_6ghz(wpa_s); |
2425 | 0 | os_free(params.freqs); |
2426 | 0 | return 1; |
2427 | 0 | } |
2428 | 0 | wpa_dbg(wpa_s, MSG_INFO, "Failed to trigger 6GHz-only scan"); |
2429 | 0 | os_free(params.freqs); |
2430 | 0 | return 0; |
2431 | 0 | } |
2432 | | |
2433 | | |
2434 | | static bool wpas_short_ssid_match(struct wpa_supplicant *wpa_s, |
2435 | | struct wpa_scan_results *scan_res) |
2436 | 0 | { |
2437 | 0 | size_t i; |
2438 | 0 | struct wpa_ssid *ssid = wpa_s->current_ssid; |
2439 | 0 | u32 current_ssid_short = ieee80211_crc32(ssid->ssid, ssid->ssid_len); |
2440 | |
|
2441 | 0 | for (i = 0; i < scan_res->num; i++) { |
2442 | 0 | struct wpa_scan_res *res = scan_res->res[i]; |
2443 | 0 | const u8 *rnr_ie, *ie_end; |
2444 | 0 | const struct ieee80211_neighbor_ap_info *info; |
2445 | 0 | size_t left; |
2446 | |
|
2447 | 0 | rnr_ie = wpa_scan_get_ie(res, WLAN_EID_REDUCED_NEIGHBOR_REPORT); |
2448 | 0 | if (!rnr_ie) |
2449 | 0 | continue; |
2450 | | |
2451 | 0 | ie_end = rnr_ie + 2 + rnr_ie[1]; |
2452 | 0 | rnr_ie += 2; |
2453 | |
|
2454 | 0 | left = ie_end - rnr_ie; |
2455 | 0 | if (left < sizeof(struct ieee80211_neighbor_ap_info)) |
2456 | 0 | continue; |
2457 | | |
2458 | 0 | info = (const struct ieee80211_neighbor_ap_info *) rnr_ie; |
2459 | 0 | if (info->tbtt_info_len < 11) |
2460 | 0 | continue; /* short SSID not included */ |
2461 | 0 | left -= sizeof(struct ieee80211_neighbor_ap_info); |
2462 | 0 | rnr_ie += sizeof(struct ieee80211_neighbor_ap_info); |
2463 | |
|
2464 | 0 | while (left >= info->tbtt_info_len && rnr_ie + 11 <= ie_end) { |
2465 | | /* Skip TBTT offset and BSSID */ |
2466 | 0 | u32 short_ssid = WPA_GET_LE32(rnr_ie + 1 + ETH_ALEN); |
2467 | |
|
2468 | 0 | if (short_ssid == current_ssid_short) |
2469 | 0 | return true; |
2470 | | |
2471 | 0 | left -= info->tbtt_info_len; |
2472 | 0 | rnr_ie += info->tbtt_info_len; |
2473 | 0 | } |
2474 | 0 | } |
2475 | | |
2476 | 0 | return false; |
2477 | 0 | } |
2478 | | |
2479 | | |
2480 | | /* |
2481 | | * Return a negative value if no scan results could be fetched or if scan |
2482 | | * results should not be shared with other virtual interfaces. |
2483 | | * Return 0 if scan results were fetched and may be shared with other |
2484 | | * interfaces. |
2485 | | * Return 1 if scan results may be shared with other virtual interfaces but may |
2486 | | * not trigger any operations. |
2487 | | * Return 2 if the interface was removed and cannot be used. |
2488 | | */ |
2489 | | static int _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s, |
2490 | | union wpa_event_data *data, |
2491 | | int own_request, int update_only) |
2492 | 0 | { |
2493 | 0 | struct wpa_scan_results *scan_res = NULL; |
2494 | 0 | int ret = 0; |
2495 | 0 | int ap = 0; |
2496 | 0 | bool trigger_6ghz_scan; |
2497 | 0 | bool short_ssid_match_found = false; |
2498 | | #ifndef CONFIG_NO_RANDOM_POOL |
2499 | | size_t i, num; |
2500 | | #endif /* CONFIG_NO_RANDOM_POOL */ |
2501 | |
|
2502 | | #ifdef CONFIG_AP |
2503 | | if (wpa_s->ap_iface) |
2504 | | ap = 1; |
2505 | | #endif /* CONFIG_AP */ |
2506 | |
|
2507 | 0 | trigger_6ghz_scan = wpa_s->crossed_6ghz_dom && |
2508 | 0 | wpa_s->last_scan_all_chan; |
2509 | 0 | wpa_s->crossed_6ghz_dom = false; |
2510 | 0 | wpa_s->last_scan_all_chan = false; |
2511 | |
|
2512 | 0 | wpa_supplicant_notify_scanning(wpa_s, 0); |
2513 | |
|
2514 | 0 | scan_res = wpa_supplicant_get_scan_results(wpa_s, |
2515 | 0 | data ? &data->scan_info : |
2516 | 0 | NULL, 1, NULL); |
2517 | |
|
2518 | 0 | if (wpa_s->scan_in_progress_6ghz) { |
2519 | 0 | wpa_s->scan_in_progress_6ghz = false; |
2520 | 0 | wpas_notify_scan_in_progress_6ghz(wpa_s); |
2521 | 0 | } |
2522 | |
|
2523 | 0 | if (scan_res == NULL) { |
2524 | 0 | if (wpa_s->conf->ap_scan == 2 || ap || |
2525 | 0 | wpa_s->scan_res_handler == scan_only_handler) |
2526 | 0 | return -1; |
2527 | 0 | if (!own_request) |
2528 | 0 | return -1; |
2529 | 0 | if (data && data->scan_info.external_scan) |
2530 | 0 | return -1; |
2531 | 0 | if (wpa_s->scan_res_fail_handler) { |
2532 | 0 | void (*handler)(struct wpa_supplicant *wpa_s); |
2533 | |
|
2534 | 0 | handler = wpa_s->scan_res_fail_handler; |
2535 | 0 | wpa_s->scan_res_fail_handler = NULL; |
2536 | 0 | handler(wpa_s); |
2537 | 0 | } else { |
2538 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
2539 | 0 | "Failed to get scan results - try scanning again"); |
2540 | 0 | wpa_supplicant_req_new_scan(wpa_s, 1, 0); |
2541 | 0 | } |
2542 | |
|
2543 | 0 | ret = -1; |
2544 | 0 | goto scan_work_done; |
2545 | 0 | } |
2546 | | |
2547 | | #ifndef CONFIG_NO_RANDOM_POOL |
2548 | | num = scan_res->num; |
2549 | | if (num > 10) |
2550 | | num = 10; |
2551 | | for (i = 0; i < num; i++) { |
2552 | | u8 buf[5]; |
2553 | | struct wpa_scan_res *res = scan_res->res[i]; |
2554 | | buf[0] = res->bssid[5]; |
2555 | | buf[1] = res->qual & 0xff; |
2556 | | buf[2] = res->noise & 0xff; |
2557 | | buf[3] = res->level & 0xff; |
2558 | | buf[4] = res->tsf & 0xff; |
2559 | | random_add_randomness(buf, sizeof(buf)); |
2560 | | } |
2561 | | #endif /* CONFIG_NO_RANDOM_POOL */ |
2562 | | |
2563 | 0 | if (data) { |
2564 | 0 | size_t idx; |
2565 | |
|
2566 | 0 | wpa_s->last_scan_external = data->scan_info.external_scan; |
2567 | 0 | wpa_s->last_scan_num_ssids = data->scan_info.num_ssids; |
2568 | 0 | for (idx = 0; idx < wpa_s->last_scan_num_ssids; idx++) { |
2569 | | /* Copy the SSID and its length */ |
2570 | 0 | if (idx >= WPAS_MAX_SCAN_SSIDS || |
2571 | 0 | data->scan_info.ssids[idx].ssid_len > SSID_MAX_LEN) |
2572 | 0 | continue; |
2573 | | |
2574 | 0 | os_memcpy(wpa_s->last_scan_ssids[idx].ssid, |
2575 | 0 | data->scan_info.ssids[idx].ssid, |
2576 | 0 | data->scan_info.ssids[idx].ssid_len); |
2577 | 0 | wpa_s->last_scan_ssids[idx].ssid_len = |
2578 | 0 | data->scan_info.ssids[idx].ssid_len; |
2579 | 0 | } |
2580 | 0 | } else { |
2581 | 0 | wpa_s->last_scan_external = false; |
2582 | 0 | wpa_s->last_scan_num_ssids = 0; |
2583 | 0 | } |
2584 | |
|
2585 | 0 | if (update_only) { |
2586 | 0 | ret = 1; |
2587 | 0 | goto scan_work_done; |
2588 | 0 | } |
2589 | | |
2590 | 0 | if (own_request && wpa_s->scan_res_handler && |
2591 | 0 | !(data && data->scan_info.external_scan)) { |
2592 | 0 | void (*scan_res_handler)(struct wpa_supplicant *wpa_s, |
2593 | 0 | struct wpa_scan_results *scan_res); |
2594 | |
|
2595 | 0 | scan_res_handler = wpa_s->scan_res_handler; |
2596 | 0 | wpa_s->scan_res_handler = NULL; |
2597 | 0 | scan_res_handler(wpa_s, scan_res); |
2598 | 0 | ret = 1; |
2599 | 0 | goto scan_work_done; |
2600 | 0 | } |
2601 | | |
2602 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "New scan results available (own=%u ext=%u)", |
2603 | 0 | wpa_s->own_scan_running, |
2604 | 0 | data ? data->scan_info.external_scan : 0); |
2605 | 0 | if (wpa_s->last_scan_req == MANUAL_SCAN_REQ && |
2606 | 0 | wpa_s->manual_scan_use_id && wpa_s->own_scan_running && |
2607 | 0 | own_request && !(data && data->scan_info.external_scan)) { |
2608 | 0 | wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_SCAN_RESULTS "id=%u", |
2609 | 0 | wpa_s->manual_scan_id); |
2610 | 0 | wpa_s->manual_scan_use_id = 0; |
2611 | 0 | } else { |
2612 | 0 | wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_SCAN_RESULTS); |
2613 | 0 | } |
2614 | 0 | wpas_notify_scan_results(wpa_s); |
2615 | |
|
2616 | 0 | wpas_notify_scan_done(wpa_s, 1); |
2617 | |
|
2618 | 0 | if (ap) { |
2619 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "Ignore scan results in AP mode"); |
2620 | | #ifdef CONFIG_AP |
2621 | | if (wpa_s->ap_iface->scan_cb) |
2622 | | wpa_s->ap_iface->scan_cb(wpa_s->ap_iface); |
2623 | | #endif /* CONFIG_AP */ |
2624 | 0 | goto scan_work_done; |
2625 | 0 | } |
2626 | | |
2627 | 0 | if (data && data->scan_info.external_scan) { |
2628 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "Do not use results from externally requested scan operation for network selection"); |
2629 | 0 | wpa_scan_results_free(scan_res); |
2630 | 0 | return 0; |
2631 | 0 | } |
2632 | | |
2633 | 0 | if (sme_proc_obss_scan(wpa_s) > 0) |
2634 | 0 | goto scan_work_done; |
2635 | | |
2636 | 0 | #ifndef CONFIG_NO_RRM |
2637 | 0 | if (own_request && data && |
2638 | 0 | wpas_beacon_rep_scan_process(wpa_s, scan_res, &data->scan_info) > 0) |
2639 | 0 | goto scan_work_done; |
2640 | 0 | #endif /* CONFIG_NO_RRM */ |
2641 | | |
2642 | 0 | if (ml_link_probe_scan(wpa_s)) |
2643 | 0 | goto scan_work_done; |
2644 | | |
2645 | 0 | if ((wpa_s->conf->ap_scan == 2 && !wpas_wps_searching(wpa_s))) |
2646 | 0 | goto scan_work_done; |
2647 | | |
2648 | 0 | if (autoscan_notify_scan(wpa_s, scan_res)) |
2649 | 0 | goto scan_work_done; |
2650 | | |
2651 | 0 | if (wpa_s->disconnected) { |
2652 | 0 | wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED); |
2653 | 0 | goto scan_work_done; |
2654 | 0 | } |
2655 | | |
2656 | 0 | if (!wpas_driver_bss_selection(wpa_s) && |
2657 | 0 | bgscan_notify_scan(wpa_s, scan_res) == 1) |
2658 | 0 | goto scan_work_done; |
2659 | | |
2660 | 0 | wpas_wps_update_ap_info(wpa_s, scan_res); |
2661 | |
|
2662 | 0 | if (wnm_scan_process(wpa_s, false) > 0) |
2663 | 0 | goto scan_work_done; |
2664 | | |
2665 | 0 | if (wpa_s->wpa_state >= WPA_AUTHENTICATING && |
2666 | 0 | wpa_s->wpa_state < WPA_COMPLETED) |
2667 | 0 | goto scan_work_done; |
2668 | | |
2669 | 0 | if (wpa_s->current_ssid && trigger_6ghz_scan && own_request && data && |
2670 | 0 | wpas_short_ssid_match(wpa_s, scan_res)) { |
2671 | 0 | wpa_dbg(wpa_s, MSG_INFO, "Short SSID match in scan results"); |
2672 | 0 | short_ssid_match_found = true; |
2673 | 0 | } |
2674 | |
|
2675 | 0 | wpa_scan_results_free(scan_res); |
2676 | |
|
2677 | 0 | if (own_request && wpa_s->scan_work) { |
2678 | 0 | struct wpa_radio_work *work = wpa_s->scan_work; |
2679 | 0 | wpa_s->scan_work = NULL; |
2680 | 0 | radio_work_done(work); |
2681 | 0 | } |
2682 | |
|
2683 | 0 | os_free(wpa_s->last_scan_freqs); |
2684 | 0 | wpa_s->last_scan_freqs = NULL; |
2685 | 0 | if (own_request && data && |
2686 | 0 | data->scan_info.freqs && data->scan_info.num_freqs) { |
2687 | 0 | wpa_s->last_scan_freqs = |
2688 | 0 | os_malloc(sizeof(int) * |
2689 | 0 | (data->scan_info.num_freqs + 1)); |
2690 | 0 | if (wpa_s->last_scan_freqs) { |
2691 | 0 | os_memcpy(wpa_s->last_scan_freqs, |
2692 | 0 | data->scan_info.freqs, |
2693 | 0 | sizeof(int) * data->scan_info.num_freqs); |
2694 | 0 | wpa_s->last_scan_freqs[data->scan_info.num_freqs] = 0; |
2695 | 0 | } |
2696 | 0 | } |
2697 | |
|
2698 | 0 | if (wpa_s->supp_pbc_active && !wpas_wps_partner_link_scan_done(wpa_s)) |
2699 | 0 | return ret; |
2700 | | |
2701 | 0 | if (short_ssid_match_found && wpas_trigger_6ghz_scan(wpa_s, data) > 0) |
2702 | 0 | return 1; |
2703 | | |
2704 | 0 | return wpas_select_network_from_last_scan(wpa_s, 1, own_request, |
2705 | 0 | trigger_6ghz_scan, data); |
2706 | | |
2707 | 0 | scan_work_done: |
2708 | 0 | wpa_scan_results_free(scan_res); |
2709 | 0 | if (own_request && wpa_s->scan_work) { |
2710 | 0 | struct wpa_radio_work *work = wpa_s->scan_work; |
2711 | 0 | wpa_s->scan_work = NULL; |
2712 | 0 | radio_work_done(work); |
2713 | 0 | } |
2714 | 0 | return ret; |
2715 | 0 | } |
2716 | | |
2717 | | |
2718 | | /** |
2719 | | * Select a network from the last scan |
2720 | | * @wpa_s: Pointer to wpa_supplicant data |
2721 | | * @new_scan: Whether this function was called right after a scan has finished |
2722 | | * @own_request: Whether the scan was requested by this interface |
2723 | | * @trigger_6ghz_scan: Whether to trigger a 6ghz-only scan when applicable |
2724 | | * @data: Scan data from scan that finished if applicable |
2725 | | * |
2726 | | * See _wpa_supplicant_event_scan_results() for return values. |
2727 | | */ |
2728 | | static int wpas_select_network_from_last_scan(struct wpa_supplicant *wpa_s, |
2729 | | int new_scan, int own_request, |
2730 | | bool trigger_6ghz_scan, |
2731 | | union wpa_event_data *data) |
2732 | 0 | { |
2733 | 0 | struct wpa_bss *selected; |
2734 | 0 | struct wpa_ssid *ssid = NULL; |
2735 | 0 | int time_to_reenable = wpas_reenabled_network_time(wpa_s); |
2736 | |
|
2737 | 0 | if (time_to_reenable > 0) { |
2738 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
2739 | 0 | "Postpone network selection by %d seconds since all networks are disabled", |
2740 | 0 | time_to_reenable); |
2741 | 0 | eloop_cancel_timeout(wpas_network_reenabled, wpa_s, NULL); |
2742 | 0 | eloop_register_timeout(time_to_reenable, 0, |
2743 | 0 | wpas_network_reenabled, wpa_s, NULL); |
2744 | 0 | return 0; |
2745 | 0 | } |
2746 | | |
2747 | 0 | if (wpa_s->p2p_mgmt) |
2748 | 0 | return 0; /* no normal connection on p2p_mgmt interface */ |
2749 | | |
2750 | 0 | wpa_s->owe_transition_search = 0; |
2751 | | #ifdef CONFIG_OWE |
2752 | | os_free(wpa_s->owe_trans_scan_freq); |
2753 | | wpa_s->owe_trans_scan_freq = NULL; |
2754 | | #endif /* CONFIG_OWE */ |
2755 | 0 | selected = wpa_supplicant_pick_network(wpa_s, &ssid, new_scan); |
2756 | |
|
2757 | | #ifdef CONFIG_MESH |
2758 | | if (wpa_s->ifmsh) { |
2759 | | wpa_msg(wpa_s, MSG_INFO, |
2760 | | "Avoiding join because we already joined a mesh group"); |
2761 | | return 0; |
2762 | | } |
2763 | | #endif /* CONFIG_MESH */ |
2764 | |
|
2765 | 0 | if (selected) { |
2766 | 0 | int skip; |
2767 | 0 | skip = !wpa_supplicant_need_to_roam(wpa_s, selected, ssid); |
2768 | 0 | if (skip) { |
2769 | 0 | if (new_scan) |
2770 | 0 | wpa_supplicant_rsn_preauth_scan_results(wpa_s); |
2771 | 0 | return 0; |
2772 | 0 | } |
2773 | | |
2774 | 0 | wpa_s->suitable_network++; |
2775 | |
|
2776 | 0 | if (ssid != wpa_s->current_ssid && |
2777 | 0 | wpa_s->wpa_state >= WPA_AUTHENTICATING) { |
2778 | 0 | wpa_s->own_disconnect_req = 1; |
2779 | 0 | wpa_supplicant_deauthenticate( |
2780 | 0 | wpa_s, WLAN_REASON_DEAUTH_LEAVING); |
2781 | 0 | } |
2782 | |
|
2783 | 0 | if (wpa_supplicant_connect(wpa_s, selected, ssid) < 0) { |
2784 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "Connect failed"); |
2785 | 0 | return -1; |
2786 | 0 | } |
2787 | 0 | wpa_s->supp_pbc_active = false; |
2788 | |
|
2789 | 0 | if (new_scan) |
2790 | 0 | wpa_supplicant_rsn_preauth_scan_results(wpa_s); |
2791 | | /* |
2792 | | * Do not allow other virtual radios to trigger operations based |
2793 | | * on these scan results since we do not want them to start |
2794 | | * other associations at the same time. |
2795 | | */ |
2796 | 0 | return 1; |
2797 | 0 | } else { |
2798 | 0 | wpa_s->no_suitable_network++; |
2799 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "No suitable network found"); |
2800 | 0 | ssid = wpa_supplicant_pick_new_network(wpa_s); |
2801 | 0 | if (ssid) { |
2802 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "Setup a new network"); |
2803 | 0 | wpa_supplicant_associate(wpa_s, NULL, ssid); |
2804 | 0 | if (new_scan) |
2805 | 0 | wpa_supplicant_rsn_preauth_scan_results(wpa_s); |
2806 | 0 | } else if (own_request) { |
2807 | 0 | if (wpa_s->support_6ghz && trigger_6ghz_scan && data && |
2808 | 0 | wpas_trigger_6ghz_scan(wpa_s, data) > 0) |
2809 | 0 | return 1; |
2810 | | |
2811 | | /* |
2812 | | * No SSID found. If SCAN results are as a result of |
2813 | | * own scan request and not due to a scan request on |
2814 | | * another shared interface, try another scan. |
2815 | | */ |
2816 | 0 | int timeout_sec = wpa_s->scan_interval; |
2817 | 0 | int timeout_usec = 0; |
2818 | | #ifdef CONFIG_P2P |
2819 | | int res; |
2820 | | |
2821 | | res = wpas_p2p_scan_no_go_seen(wpa_s); |
2822 | | if (res == 2) |
2823 | | return 2; |
2824 | | if (res == 1) |
2825 | | return 0; |
2826 | | |
2827 | | if (wpas_p2p_retry_limit_exceeded(wpa_s)) |
2828 | | return 0; |
2829 | | |
2830 | | if (wpa_s->p2p_in_provisioning || |
2831 | | wpa_s->show_group_started || |
2832 | | wpa_s->p2p_in_invitation) { |
2833 | | /* |
2834 | | * Use shorter wait during P2P Provisioning |
2835 | | * state and during P2P join-a-group operation |
2836 | | * to speed up group formation. |
2837 | | */ |
2838 | | timeout_sec = 0; |
2839 | | timeout_usec = 250000; |
2840 | | wpa_supplicant_req_new_scan(wpa_s, timeout_sec, |
2841 | | timeout_usec); |
2842 | | return 0; |
2843 | | } |
2844 | | #endif /* CONFIG_P2P */ |
2845 | 0 | #ifdef CONFIG_INTERWORKING |
2846 | 0 | if (wpa_s->conf->auto_interworking && |
2847 | 0 | wpa_s->conf->interworking && |
2848 | 0 | wpa_s->conf->cred) { |
2849 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "Interworking: " |
2850 | 0 | "start ANQP fetch since no matching " |
2851 | 0 | "networks found"); |
2852 | 0 | wpa_s->network_select = 1; |
2853 | 0 | wpa_s->auto_network_select = 1; |
2854 | 0 | interworking_start_fetch_anqp(wpa_s); |
2855 | 0 | return 1; |
2856 | 0 | } |
2857 | 0 | #endif /* CONFIG_INTERWORKING */ |
2858 | | #ifdef CONFIG_WPS |
2859 | | if (wpa_s->after_wps > 0 || wpas_wps_searching(wpa_s)) { |
2860 | | wpa_dbg(wpa_s, MSG_DEBUG, "Use shorter wait during WPS processing"); |
2861 | | timeout_sec = 0; |
2862 | | timeout_usec = 500000; |
2863 | | wpa_supplicant_req_new_scan(wpa_s, timeout_sec, |
2864 | | timeout_usec); |
2865 | | return 0; |
2866 | | } |
2867 | | #endif /* CONFIG_WPS */ |
2868 | | #ifdef CONFIG_OWE |
2869 | | if (wpa_s->owe_transition_search) { |
2870 | | wpa_dbg(wpa_s, MSG_DEBUG, |
2871 | | "OWE: Use shorter wait during transition mode search"); |
2872 | | timeout_sec = 0; |
2873 | | timeout_usec = 500000; |
2874 | | if (wpa_s->owe_trans_scan_freq) { |
2875 | | os_free(wpa_s->next_scan_freqs); |
2876 | | wpa_s->next_scan_freqs = |
2877 | | wpa_s->owe_trans_scan_freq; |
2878 | | wpa_s->owe_trans_scan_freq = NULL; |
2879 | | timeout_usec = 100000; |
2880 | | } |
2881 | | wpa_supplicant_req_new_scan(wpa_s, timeout_sec, |
2882 | | timeout_usec); |
2883 | | return 0; |
2884 | | } |
2885 | | #endif /* CONFIG_OWE */ |
2886 | 0 | if (wpa_supplicant_req_sched_scan(wpa_s)) |
2887 | 0 | wpa_supplicant_req_new_scan(wpa_s, timeout_sec, |
2888 | 0 | timeout_usec); |
2889 | |
|
2890 | 0 | wpa_msg_ctrl(wpa_s, MSG_INFO, |
2891 | 0 | WPA_EVENT_NETWORK_NOT_FOUND); |
2892 | 0 | } |
2893 | 0 | } |
2894 | 0 | return 0; |
2895 | 0 | } |
2896 | | |
2897 | | |
2898 | | static bool equal_scan_freq_list(struct wpa_supplicant *self, |
2899 | | struct wpa_supplicant *other) |
2900 | 0 | { |
2901 | 0 | const int *list1, *list2; |
2902 | |
|
2903 | 0 | list1 = self->conf->freq_list ? self->conf->freq_list : |
2904 | 0 | self->last_scan_freqs; |
2905 | 0 | list2 = other->conf->freq_list ? other->conf->freq_list : |
2906 | 0 | other->last_scan_freqs; |
2907 | |
|
2908 | 0 | return int_array_equal(list1, list2); |
2909 | 0 | } |
2910 | | |
2911 | | |
2912 | | static int wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s, |
2913 | | union wpa_event_data *data) |
2914 | 0 | { |
2915 | 0 | struct wpa_supplicant *ifs; |
2916 | 0 | int res; |
2917 | |
|
2918 | 0 | res = _wpa_supplicant_event_scan_results(wpa_s, data, 1, 0); |
2919 | 0 | if (res == 2) { |
2920 | | /* |
2921 | | * Interface may have been removed, so must not dereference |
2922 | | * wpa_s after this. |
2923 | | */ |
2924 | 0 | return 1; |
2925 | 0 | } |
2926 | | |
2927 | 0 | if (res < 0) { |
2928 | | /* |
2929 | | * If no scan results could be fetched, then no need to |
2930 | | * notify those interfaces that did not actually request |
2931 | | * this scan. Similarly, if scan results started a new operation on this |
2932 | | * interface, do not notify other interfaces to avoid concurrent |
2933 | | * operations during a connection attempt. |
2934 | | */ |
2935 | 0 | return 0; |
2936 | 0 | } |
2937 | | |
2938 | | /* |
2939 | | * Manual scan requests are more specific to a use case than the |
2940 | | * normal scan requests; hence, skip updating sibling radios. |
2941 | | */ |
2942 | 0 | if (wpa_s->last_scan_req == MANUAL_SCAN_REQ) |
2943 | 0 | return 0; |
2944 | | |
2945 | | /* |
2946 | | * Check other interfaces to see if they share the same radio and |
2947 | | * frequency list. If so, they get updated with this same scan info. |
2948 | | */ |
2949 | 0 | dl_list_for_each(ifs, &wpa_s->radio->ifaces, struct wpa_supplicant, |
2950 | 0 | radio_list) { |
2951 | 0 | if (ifs != wpa_s && equal_scan_freq_list(wpa_s, ifs)) { |
2952 | 0 | wpa_printf(MSG_DEBUG, "%s: Updating scan results from " |
2953 | 0 | "sibling", ifs->ifname); |
2954 | 0 | res = _wpa_supplicant_event_scan_results(ifs, data, 0, |
2955 | 0 | res > 0); |
2956 | 0 | if (res < 0) |
2957 | 0 | return 0; |
2958 | 0 | } |
2959 | 0 | } |
2960 | | |
2961 | 0 | return 0; |
2962 | 0 | } |
2963 | | |
2964 | | #endif /* CONFIG_NO_SCAN_PROCESSING */ |
2965 | | |
2966 | | |
2967 | | int wpa_supplicant_fast_associate(struct wpa_supplicant *wpa_s) |
2968 | 0 | { |
2969 | | #ifdef CONFIG_NO_SCAN_PROCESSING |
2970 | | return -1; |
2971 | | #else /* CONFIG_NO_SCAN_PROCESSING */ |
2972 | 0 | struct os_reltime now; |
2973 | |
|
2974 | 0 | wpa_s->ignore_post_flush_scan_res = 0; |
2975 | |
|
2976 | 0 | if (wpa_s->last_scan_res_used == 0) |
2977 | 0 | return -1; |
2978 | | |
2979 | 0 | os_get_reltime(&now); |
2980 | 0 | if (os_reltime_expired(&now, &wpa_s->last_scan, |
2981 | 0 | wpa_s->conf->scan_res_valid_for_connect)) { |
2982 | 0 | wpa_printf(MSG_DEBUG, "Fast associate: Old scan results"); |
2983 | 0 | return -1; |
2984 | 0 | } else if (wpa_s->crossed_6ghz_dom) { |
2985 | 0 | wpa_printf(MSG_DEBUG, "Fast associate: Crossed 6 GHz domain"); |
2986 | 0 | return -1; |
2987 | 0 | } |
2988 | | |
2989 | 0 | return wpas_select_network_from_last_scan(wpa_s, 0, 1, false, NULL); |
2990 | 0 | #endif /* CONFIG_NO_SCAN_PROCESSING */ |
2991 | 0 | } |
2992 | | |
2993 | | |
2994 | | int wpa_wps_supplicant_fast_associate(struct wpa_supplicant *wpa_s) |
2995 | 0 | { |
2996 | | #ifdef CONFIG_NO_SCAN_PROCESSING |
2997 | | return -1; |
2998 | | #else /* CONFIG_NO_SCAN_PROCESSING */ |
2999 | 0 | return wpas_select_network_from_last_scan(wpa_s, 1, 1, false, NULL); |
3000 | 0 | #endif /* CONFIG_NO_SCAN_PROCESSING */ |
3001 | 0 | } |
3002 | | |
3003 | | |
3004 | | #ifdef CONFIG_WNM |
3005 | | |
3006 | | static void wnm_bss_keep_alive(void *eloop_ctx, void *sock_ctx) |
3007 | 0 | { |
3008 | 0 | struct wpa_supplicant *wpa_s = eloop_ctx; |
3009 | |
|
3010 | 0 | if (wpa_s->wpa_state < WPA_ASSOCIATED) |
3011 | 0 | return; |
3012 | | |
3013 | 0 | if (!wpa_s->no_keep_alive) { |
3014 | 0 | wpa_printf(MSG_DEBUG, "WNM: Send keep-alive to AP " MACSTR, |
3015 | 0 | MAC2STR(wpa_s->bssid)); |
3016 | | /* TODO: could skip this if normal data traffic has been sent */ |
3017 | | /* TODO: Consider using some more appropriate data frame for |
3018 | | * this */ |
3019 | 0 | if (wpa_s->l2) |
3020 | 0 | l2_packet_send(wpa_s->l2, wpa_s->bssid, 0x0800, |
3021 | 0 | (u8 *) "", 0); |
3022 | 0 | } |
3023 | |
|
3024 | | #ifdef CONFIG_SME |
3025 | | if (wpa_s->sme.bss_max_idle_period) { |
3026 | | unsigned int msec; |
3027 | | msec = wpa_s->sme.bss_max_idle_period * 1024; /* times 1000 */ |
3028 | | if (msec > 100) |
3029 | | msec -= 100; |
3030 | | eloop_register_timeout(msec / 1000, msec % 1000 * 1000, |
3031 | | wnm_bss_keep_alive, wpa_s, NULL); |
3032 | | } |
3033 | | #endif /* CONFIG_SME */ |
3034 | 0 | } |
3035 | | |
3036 | | |
3037 | | static void wnm_process_assoc_resp(struct wpa_supplicant *wpa_s, |
3038 | | const u8 *ies, size_t ies_len) |
3039 | 0 | { |
3040 | 0 | struct ieee802_11_elems elems; |
3041 | |
|
3042 | 0 | if (ies == NULL) |
3043 | 0 | return; |
3044 | | |
3045 | 0 | if (ieee802_11_parse_elems(ies, ies_len, &elems, 1) == ParseFailed) |
3046 | 0 | return; |
3047 | |
|
3048 | | #ifdef CONFIG_SME |
3049 | | if (elems.bss_max_idle_period) { |
3050 | | unsigned int msec; |
3051 | | wpa_s->sme.bss_max_idle_period = |
3052 | | WPA_GET_LE16(elems.bss_max_idle_period); |
3053 | | wpa_printf(MSG_DEBUG, "WNM: BSS Max Idle Period: %u (* 1000 " |
3054 | | "TU)%s", wpa_s->sme.bss_max_idle_period, |
3055 | | (elems.bss_max_idle_period[2] & 0x01) ? |
3056 | | " (protected keep-live required)" : ""); |
3057 | | if (wpa_s->sme.bss_max_idle_period == 0) |
3058 | | wpa_s->sme.bss_max_idle_period = 1; |
3059 | | if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME) { |
3060 | | eloop_cancel_timeout(wnm_bss_keep_alive, wpa_s, NULL); |
3061 | | /* msec times 1000 */ |
3062 | | msec = wpa_s->sme.bss_max_idle_period * 1024; |
3063 | | if (msec > 100) |
3064 | | msec -= 100; |
3065 | | eloop_register_timeout(msec / 1000, msec % 1000 * 1000, |
3066 | | wnm_bss_keep_alive, wpa_s, |
3067 | | NULL); |
3068 | | } |
3069 | | } else { |
3070 | | wpa_s->sme.bss_max_idle_period = 0; |
3071 | | } |
3072 | | #endif /* CONFIG_SME */ |
3073 | 0 | } |
3074 | | |
3075 | | #endif /* CONFIG_WNM */ |
3076 | | |
3077 | | |
3078 | | void wnm_bss_keep_alive_deinit(struct wpa_supplicant *wpa_s) |
3079 | 0 | { |
3080 | 0 | #ifdef CONFIG_WNM |
3081 | 0 | eloop_cancel_timeout(wnm_bss_keep_alive, wpa_s, NULL); |
3082 | 0 | #endif /* CONFIG_WNM */ |
3083 | 0 | } |
3084 | | |
3085 | | |
3086 | | static int wpas_qos_map_set(struct wpa_supplicant *wpa_s, const u8 *qos_map, |
3087 | | size_t len) |
3088 | 0 | { |
3089 | 0 | int res; |
3090 | |
|
3091 | 0 | wpa_hexdump(MSG_DEBUG, "Interworking: QoS Map Set", qos_map, len); |
3092 | 0 | res = wpa_drv_set_qos_map(wpa_s, qos_map, len); |
3093 | 0 | if (res) { |
3094 | 0 | wpa_printf(MSG_DEBUG, "Interworking: Failed to configure QoS Map Set to the driver"); |
3095 | 0 | } |
3096 | |
|
3097 | 0 | return res; |
3098 | 0 | } |
3099 | | |
3100 | | |
3101 | | static void interworking_process_assoc_resp(struct wpa_supplicant *wpa_s, |
3102 | | const u8 *ies, size_t ies_len) |
3103 | 0 | { |
3104 | 0 | struct ieee802_11_elems elems; |
3105 | |
|
3106 | 0 | if (ies == NULL) |
3107 | 0 | return; |
3108 | | |
3109 | 0 | if (ieee802_11_parse_elems(ies, ies_len, &elems, 1) == ParseFailed) |
3110 | 0 | return; |
3111 | | |
3112 | 0 | if (elems.qos_map_set) { |
3113 | 0 | wpas_qos_map_set(wpa_s, elems.qos_map_set, |
3114 | 0 | elems.qos_map_set_len); |
3115 | 0 | } |
3116 | 0 | } |
3117 | | |
3118 | | |
3119 | | static void wpa_supplicant_set_4addr_mode(struct wpa_supplicant *wpa_s) |
3120 | 0 | { |
3121 | 0 | if (wpa_s->enabled_4addr_mode) { |
3122 | 0 | wpa_printf(MSG_DEBUG, "4addr mode already set"); |
3123 | 0 | return; |
3124 | 0 | } |
3125 | | |
3126 | 0 | if (wpa_drv_set_4addr_mode(wpa_s, 1) < 0) { |
3127 | 0 | wpa_msg(wpa_s, MSG_ERROR, "Failed to set 4addr mode"); |
3128 | 0 | goto fail; |
3129 | 0 | } |
3130 | 0 | wpa_s->enabled_4addr_mode = 1; |
3131 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "Successfully set 4addr mode"); |
3132 | 0 | return; |
3133 | | |
3134 | 0 | fail: |
3135 | 0 | wpa_supplicant_deauthenticate(wpa_s, WLAN_REASON_DEAUTH_LEAVING); |
3136 | 0 | } |
3137 | | |
3138 | | |
3139 | | static void multi_ap_process_assoc_resp(struct wpa_supplicant *wpa_s, |
3140 | | const u8 *ies, size_t ies_len) |
3141 | 0 | { |
3142 | 0 | struct ieee802_11_elems elems; |
3143 | 0 | struct multi_ap_params multi_ap; |
3144 | 0 | u16 status; |
3145 | |
|
3146 | 0 | wpa_s->multi_ap_ie = 0; |
3147 | |
|
3148 | 0 | if (!ies || |
3149 | 0 | ieee802_11_parse_elems(ies, ies_len, &elems, 1) == ParseFailed || |
3150 | 0 | !elems.multi_ap) |
3151 | 0 | return; |
3152 | | |
3153 | 0 | status = check_multi_ap_ie(elems.multi_ap + 4, elems.multi_ap_len - 4, |
3154 | 0 | &multi_ap); |
3155 | 0 | if (status != WLAN_STATUS_SUCCESS) |
3156 | 0 | return; |
3157 | | |
3158 | 0 | wpa_s->multi_ap_backhaul = !!(multi_ap.capability & |
3159 | 0 | MULTI_AP_BACKHAUL_BSS); |
3160 | 0 | wpa_s->multi_ap_fronthaul = !!(multi_ap.capability & |
3161 | 0 | MULTI_AP_FRONTHAUL_BSS); |
3162 | 0 | wpa_s->multi_ap_ie = 1; |
3163 | 0 | } |
3164 | | |
3165 | | |
3166 | | static void multi_ap_set_4addr_mode(struct wpa_supplicant *wpa_s) |
3167 | 0 | { |
3168 | 0 | if (!wpa_s->current_ssid || |
3169 | 0 | !wpa_s->current_ssid->multi_ap_backhaul_sta) |
3170 | 0 | return; |
3171 | | |
3172 | 0 | if (!wpa_s->multi_ap_ie) { |
3173 | 0 | wpa_printf(MSG_INFO, |
3174 | 0 | "AP does not include valid Multi-AP element"); |
3175 | 0 | goto fail; |
3176 | 0 | } |
3177 | | |
3178 | 0 | if (!wpa_s->multi_ap_backhaul) { |
3179 | 0 | if (wpa_s->multi_ap_fronthaul && |
3180 | 0 | wpa_s->current_ssid->key_mgmt & WPA_KEY_MGMT_WPS) { |
3181 | 0 | wpa_printf(MSG_INFO, |
3182 | 0 | "WPS active, accepting fronthaul-only BSS"); |
3183 | | /* Don't set 4addr mode in this case, so just return */ |
3184 | 0 | return; |
3185 | 0 | } |
3186 | 0 | wpa_printf(MSG_INFO, "AP doesn't support backhaul BSS"); |
3187 | 0 | goto fail; |
3188 | 0 | } |
3189 | | |
3190 | 0 | wpa_supplicant_set_4addr_mode(wpa_s); |
3191 | 0 | return; |
3192 | | |
3193 | 0 | fail: |
3194 | 0 | wpa_supplicant_deauthenticate(wpa_s, WLAN_REASON_DEAUTH_LEAVING); |
3195 | 0 | } |
3196 | | |
3197 | | |
3198 | | #ifdef CONFIG_FST |
3199 | | static int wpas_fst_update_mbie(struct wpa_supplicant *wpa_s, |
3200 | | const u8 *ie, size_t ie_len) |
3201 | | { |
3202 | | struct mb_ies_info mb_ies; |
3203 | | |
3204 | | if (!ie || !ie_len || !wpa_s->fst) |
3205 | | return -ENOENT; |
3206 | | |
3207 | | os_memset(&mb_ies, 0, sizeof(mb_ies)); |
3208 | | |
3209 | | while (ie_len >= 2 && mb_ies.nof_ies < MAX_NOF_MB_IES_SUPPORTED) { |
3210 | | size_t len; |
3211 | | |
3212 | | len = 2 + ie[1]; |
3213 | | if (len > ie_len) { |
3214 | | wpa_hexdump(MSG_DEBUG, "FST: Truncated IE found", |
3215 | | ie, ie_len); |
3216 | | break; |
3217 | | } |
3218 | | |
3219 | | if (ie[0] == WLAN_EID_MULTI_BAND) { |
3220 | | wpa_printf(MSG_DEBUG, "MB IE of %u bytes found", |
3221 | | (unsigned int) len); |
3222 | | mb_ies.ies[mb_ies.nof_ies].ie = ie + 2; |
3223 | | mb_ies.ies[mb_ies.nof_ies].ie_len = len - 2; |
3224 | | mb_ies.nof_ies++; |
3225 | | } |
3226 | | |
3227 | | ie_len -= len; |
3228 | | ie += len; |
3229 | | } |
3230 | | |
3231 | | if (mb_ies.nof_ies > 0) { |
3232 | | wpabuf_free(wpa_s->received_mb_ies); |
3233 | | wpa_s->received_mb_ies = mb_ies_by_info(&mb_ies); |
3234 | | return 0; |
3235 | | } |
3236 | | |
3237 | | return -ENOENT; |
3238 | | } |
3239 | | #endif /* CONFIG_FST */ |
3240 | | |
3241 | | |
3242 | | static int wpa_supplicant_use_own_rsne_params(struct wpa_supplicant *wpa_s, |
3243 | | union wpa_event_data *data) |
3244 | 0 | { |
3245 | 0 | int sel; |
3246 | 0 | const u8 *p; |
3247 | 0 | int l, len; |
3248 | 0 | bool found = false; |
3249 | 0 | struct wpa_ie_data ie; |
3250 | 0 | struct wpa_ssid *ssid = wpa_s->current_ssid; |
3251 | 0 | struct wpa_bss *bss = wpa_s->current_bss; |
3252 | 0 | int pmf; |
3253 | |
|
3254 | 0 | if (!ssid) |
3255 | 0 | return 0; |
3256 | | |
3257 | 0 | p = data->assoc_info.req_ies; |
3258 | 0 | l = data->assoc_info.req_ies_len; |
3259 | |
|
3260 | 0 | while (p && l >= 2) { |
3261 | 0 | len = p[1] + 2; |
3262 | 0 | if (len > l) { |
3263 | 0 | wpa_hexdump(MSG_DEBUG, "Truncated IE in assoc_info", |
3264 | 0 | p, l); |
3265 | 0 | break; |
3266 | 0 | } |
3267 | 0 | if (((p[0] == WLAN_EID_VENDOR_SPECIFIC && p[1] >= 6 && |
3268 | 0 | (os_memcmp(&p[2], "\x00\x50\xF2\x01\x01\x00", 6) == 0)) || |
3269 | 0 | (p[0] == WLAN_EID_VENDOR_SPECIFIC && p[1] >= 4 && |
3270 | 0 | (os_memcmp(&p[2], "\x50\x6F\x9A\x12", 4) == 0)) || |
3271 | 0 | (p[0] == WLAN_EID_RSN && p[1] >= 2))) { |
3272 | 0 | found = true; |
3273 | 0 | break; |
3274 | 0 | } |
3275 | 0 | l -= len; |
3276 | 0 | p += len; |
3277 | 0 | } |
3278 | |
|
3279 | 0 | if (!found || wpa_parse_wpa_ie(p, len, &ie) < 0) { |
3280 | 0 | wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_OCV, 0); |
3281 | 0 | return 0; |
3282 | 0 | } |
3283 | | |
3284 | 0 | wpa_hexdump(MSG_DEBUG, |
3285 | 0 | "WPA: Update cipher suite selection based on IEs in driver-generated WPA/RSNE in AssocReq", |
3286 | 0 | p, l); |
3287 | | |
3288 | | /* Update proto from (Re)Association Request frame info */ |
3289 | 0 | wpa_s->wpa_proto = ie.proto; |
3290 | 0 | wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_PROTO, wpa_s->wpa_proto); |
3291 | 0 | wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_RSN_ENABLED, |
3292 | 0 | !!(wpa_s->wpa_proto & WPA_PROTO_RSN)); |
3293 | | |
3294 | | /* Update AKMP suite from (Re)Association Request frame info */ |
3295 | 0 | sel = ie.key_mgmt; |
3296 | 0 | if (ssid->key_mgmt) |
3297 | 0 | sel &= ssid->key_mgmt; |
3298 | |
|
3299 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
3300 | 0 | "WPA: AP key_mgmt 0x%x network key_mgmt 0x%x; available key_mgmt 0x%x", |
3301 | 0 | ie.key_mgmt, ssid->key_mgmt, sel); |
3302 | 0 | if (ie.key_mgmt && !sel) { |
3303 | 0 | wpa_supplicant_deauthenticate( |
3304 | 0 | wpa_s, WLAN_REASON_AKMP_NOT_VALID); |
3305 | 0 | return -1; |
3306 | 0 | } |
3307 | | |
3308 | | #ifdef CONFIG_OCV |
3309 | | if (((wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME) || |
3310 | | (wpa_s->drv_flags2 & WPA_DRIVER_FLAGS2_OCV)) && ssid->ocv) |
3311 | | wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_OCV, |
3312 | | !!(ie.capabilities & WPA_CAPABILITY_OCVC)); |
3313 | | #endif /* CONFIG_OCV */ |
3314 | | |
3315 | | /* |
3316 | | * Update PMK in wpa_sm and the driver if roamed to WPA/WPA2 PSK from a |
3317 | | * different AKM. |
3318 | | */ |
3319 | 0 | if (wpa_s->key_mgmt != ie.key_mgmt && |
3320 | 0 | wpa_key_mgmt_wpa_psk_no_sae(ie.key_mgmt)) { |
3321 | 0 | if (!ssid->psk_set) { |
3322 | 0 | wpa_dbg(wpa_s, MSG_INFO, |
3323 | 0 | "No PSK available for association"); |
3324 | 0 | wpas_auth_failed(wpa_s, "NO_PSK_AVAILABLE", NULL); |
3325 | 0 | return -1; |
3326 | 0 | } |
3327 | | |
3328 | 0 | wpa_sm_set_pmk(wpa_s->wpa, ssid->psk, PMK_LEN, NULL, NULL); |
3329 | 0 | if (wpa_s->conf->key_mgmt_offload && |
3330 | 0 | (wpa_s->drv_flags & WPA_DRIVER_FLAGS_KEY_MGMT_OFFLOAD) && |
3331 | 0 | wpa_drv_set_key(wpa_s, -1, 0, NULL, 0, 0, NULL, 0, |
3332 | 0 | ssid->psk, PMK_LEN, KEY_FLAG_PMK)) |
3333 | 0 | wpa_dbg(wpa_s, MSG_ERROR, |
3334 | 0 | "WPA: Cannot set PMK for key management offload"); |
3335 | 0 | } |
3336 | | |
3337 | 0 | wpa_s->key_mgmt = ie.key_mgmt; |
3338 | 0 | wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_KEY_MGMT, wpa_s->key_mgmt); |
3339 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using KEY_MGMT %s and proto %d", |
3340 | 0 | wpa_key_mgmt_txt(wpa_s->key_mgmt, wpa_s->wpa_proto), |
3341 | 0 | wpa_s->wpa_proto); |
3342 | | |
3343 | | /* Update pairwise cipher from (Re)Association Request frame info */ |
3344 | 0 | sel = ie.pairwise_cipher; |
3345 | 0 | if (ssid->pairwise_cipher) |
3346 | 0 | sel &= ssid->pairwise_cipher; |
3347 | |
|
3348 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
3349 | 0 | "WPA: AP pairwise cipher 0x%x network pairwise cipher 0x%x; available pairwise cipher 0x%x", |
3350 | 0 | ie.pairwise_cipher, ssid->pairwise_cipher, sel); |
3351 | 0 | if (ie.pairwise_cipher && !sel) { |
3352 | 0 | wpa_supplicant_deauthenticate( |
3353 | 0 | wpa_s, WLAN_REASON_PAIRWISE_CIPHER_NOT_VALID); |
3354 | 0 | return -1; |
3355 | 0 | } |
3356 | | |
3357 | 0 | wpa_s->pairwise_cipher = ie.pairwise_cipher; |
3358 | 0 | wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_PAIRWISE, |
3359 | 0 | wpa_s->pairwise_cipher); |
3360 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using PTK %s", |
3361 | 0 | wpa_cipher_txt(wpa_s->pairwise_cipher)); |
3362 | | |
3363 | | /* Update other parameters based on AP's WPA IE/RSNE, if available */ |
3364 | 0 | if (!bss) { |
3365 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
3366 | 0 | "WPA: current_bss == NULL - skip AP IE check"); |
3367 | 0 | return 0; |
3368 | 0 | } |
3369 | | |
3370 | | /* Update GTK and IGTK from AP's RSNE */ |
3371 | 0 | found = false; |
3372 | |
|
3373 | 0 | if (wpa_s->wpa_proto & WPA_PROTO_RSN) { |
3374 | 0 | const u8 *bss_rsn; |
3375 | |
|
3376 | 0 | bss_rsn = wpa_bss_get_rsne(wpa_s, bss, ssid, |
3377 | 0 | wpa_s->valid_links); |
3378 | 0 | if (bss_rsn) { |
3379 | 0 | p = bss_rsn; |
3380 | 0 | len = 2 + bss_rsn[1]; |
3381 | 0 | found = true; |
3382 | 0 | } |
3383 | 0 | } else if (wpa_s->wpa_proto & WPA_PROTO_WPA) { |
3384 | 0 | const u8 *bss_wpa; |
3385 | |
|
3386 | 0 | bss_wpa = wpa_bss_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE); |
3387 | 0 | if (bss_wpa) { |
3388 | 0 | p = bss_wpa; |
3389 | 0 | len = 2 + bss_wpa[1]; |
3390 | 0 | found = true; |
3391 | 0 | } |
3392 | 0 | } |
3393 | |
|
3394 | 0 | if (!found || wpa_parse_wpa_ie(p, len, &ie) < 0) |
3395 | 0 | return 0; |
3396 | | |
3397 | 0 | pmf = wpas_get_ssid_pmf(wpa_s, ssid); |
3398 | 0 | if (!(ie.capabilities & WPA_CAPABILITY_MFPC) && |
3399 | 0 | pmf == MGMT_FRAME_PROTECTION_REQUIRED) { |
3400 | | /* AP does not support MFP, local configuration requires it */ |
3401 | 0 | wpa_supplicant_deauthenticate( |
3402 | 0 | wpa_s, WLAN_REASON_INVALID_RSN_IE_CAPAB); |
3403 | 0 | return -1; |
3404 | 0 | } |
3405 | 0 | if ((ie.capabilities & WPA_CAPABILITY_MFPR) && |
3406 | 0 | pmf == NO_MGMT_FRAME_PROTECTION) { |
3407 | | /* AP requires MFP, local configuration disables it */ |
3408 | 0 | wpa_supplicant_deauthenticate( |
3409 | 0 | wpa_s, WLAN_REASON_INVALID_RSN_IE_CAPAB); |
3410 | 0 | return -1; |
3411 | 0 | } |
3412 | | |
3413 | | /* Update PMF from local configuration now that MFP validation was done |
3414 | | * above */ |
3415 | 0 | wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_MFP, pmf); |
3416 | | |
3417 | | /* Update GTK from AP's RSNE */ |
3418 | 0 | sel = ie.group_cipher; |
3419 | 0 | if (ssid->group_cipher) |
3420 | 0 | sel &= ssid->group_cipher; |
3421 | |
|
3422 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
3423 | 0 | "WPA: AP group cipher 0x%x network group cipher 0x%x; available group cipher 0x%x", |
3424 | 0 | ie.group_cipher, ssid->group_cipher, sel); |
3425 | 0 | if (ie.group_cipher && !sel) { |
3426 | 0 | wpa_supplicant_deauthenticate( |
3427 | 0 | wpa_s, WLAN_REASON_GROUP_CIPHER_NOT_VALID); |
3428 | 0 | return -1; |
3429 | 0 | } |
3430 | | |
3431 | 0 | wpa_s->group_cipher = ie.group_cipher; |
3432 | 0 | wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_GROUP, wpa_s->group_cipher); |
3433 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using GTK %s", |
3434 | 0 | wpa_cipher_txt(wpa_s->group_cipher)); |
3435 | | |
3436 | | /* Update IGTK from AP RSN IE */ |
3437 | 0 | sel = ie.mgmt_group_cipher; |
3438 | 0 | if (ssid->group_mgmt_cipher) |
3439 | 0 | sel &= ssid->group_mgmt_cipher; |
3440 | |
|
3441 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
3442 | 0 | "WPA: AP mgmt_group_cipher 0x%x network mgmt_group_cipher 0x%x; available mgmt_group_cipher 0x%x", |
3443 | 0 | ie.mgmt_group_cipher, ssid->group_mgmt_cipher, sel); |
3444 | |
|
3445 | 0 | if (pmf == NO_MGMT_FRAME_PROTECTION || |
3446 | 0 | !(ie.capabilities & WPA_CAPABILITY_MFPC)) { |
3447 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
3448 | 0 | "WPA: STA/AP is not MFP capable; AP RSNE caps 0x%x", |
3449 | 0 | ie.capabilities); |
3450 | 0 | ie.mgmt_group_cipher = 0; |
3451 | 0 | } |
3452 | |
|
3453 | 0 | if (ie.mgmt_group_cipher && !sel) { |
3454 | 0 | wpa_supplicant_deauthenticate( |
3455 | 0 | wpa_s, WLAN_REASON_CIPHER_SUITE_REJECTED); |
3456 | 0 | return -1; |
3457 | 0 | } |
3458 | | |
3459 | 0 | wpa_s->mgmt_group_cipher = ie.mgmt_group_cipher; |
3460 | 0 | wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_MGMT_GROUP, |
3461 | 0 | wpa_s->mgmt_group_cipher); |
3462 | 0 | if (wpa_s->mgmt_group_cipher) |
3463 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using MGMT group cipher %s", |
3464 | 0 | wpa_cipher_txt(wpa_s->mgmt_group_cipher)); |
3465 | 0 | else |
3466 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "WPA: not using MGMT group cipher"); |
3467 | |
|
3468 | 0 | return 0; |
3469 | 0 | } |
3470 | | |
3471 | | |
3472 | | static void wpas_parse_connection_info_link(struct wpa_supplicant *wpa_s, |
3473 | | int i, |
3474 | | struct ieee802_11_elems *req_elems, |
3475 | | struct ieee802_11_elems *resp_elems, |
3476 | | struct wpabuf *req_mlbuf, |
3477 | | struct wpabuf *resp_mlbuf) |
3478 | 0 | { |
3479 | 0 | struct ieee802_11_elems req_persta_elems = *req_elems; |
3480 | 0 | struct ieee802_11_elems resp_persta_elems = *resp_elems; |
3481 | 0 | struct supported_chan_width sta_cw; |
3482 | 0 | enum chan_width ap_cw; |
3483 | |
|
3484 | 0 | if (ieee802_11_parse_link_assoc_req(&req_persta_elems, req_mlbuf, i, |
3485 | 0 | true) == ParseFailed || |
3486 | 0 | ieee802_11_parse_link_assoc_resp(&resp_persta_elems, resp_mlbuf, i, |
3487 | 0 | true) == ParseFailed) { |
3488 | 0 | wpa_s->links[i].max_nss_rx = wpa_s->connection_max_nss_rx; |
3489 | 0 | wpa_s->links[i].max_nss_tx = wpa_s->connection_max_nss_tx; |
3490 | 0 | wpa_s->links[i].channel_bandwidth = |
3491 | 0 | wpa_s->connection_channel_bandwidth; |
3492 | 0 | return; |
3493 | 0 | } |
3494 | | |
3495 | 0 | sta_cw = get_supported_channel_width(&req_persta_elems); |
3496 | 0 | ap_cw = get_operation_channel_width(&resp_persta_elems); |
3497 | |
|
3498 | 0 | if (wpa_s->connection_vht || wpa_s->connection_he || |
3499 | 0 | wpa_s->connection_eht) { |
3500 | 0 | wpa_s->links[i].channel_bandwidth = |
3501 | 0 | get_sta_operation_chan_width(ap_cw, sta_cw); |
3502 | 0 | } else if (wpa_s->connection_ht) { |
3503 | 0 | wpa_s->links[i].channel_bandwidth = (ap_cw == CHAN_WIDTH_40) ? |
3504 | 0 | CHAN_WIDTH_40 : CHAN_WIDTH_20; |
3505 | 0 | } else { |
3506 | 0 | wpa_s->links[i].channel_bandwidth = CHAN_WIDTH_20; |
3507 | 0 | } |
3508 | |
|
3509 | 0 | wpa_s->links[i].max_nss_rx = |
3510 | 0 | MIN(get_max_nss_capability(&req_persta_elems, true, |
3511 | 0 | wpa_s->links[i].channel_bandwidth), |
3512 | 0 | get_max_nss_capability(&resp_persta_elems, false, |
3513 | 0 | wpa_s->links[i].channel_bandwidth)); |
3514 | |
|
3515 | 0 | wpa_s->links[i].max_nss_tx = |
3516 | 0 | MIN(get_max_nss_capability(&req_persta_elems, false, |
3517 | 0 | wpa_s->links[i].channel_bandwidth), |
3518 | 0 | get_max_nss_capability(&resp_persta_elems, true, |
3519 | 0 | wpa_s->links[i].channel_bandwidth)); |
3520 | |
|
3521 | 0 | } |
3522 | | |
3523 | | |
3524 | | static void wpas_parse_connection_info(struct wpa_supplicant *wpa_s, |
3525 | | unsigned int freq, |
3526 | | const u8 *req_ies, size_t req_ies_len, |
3527 | | const u8 *resp_ies, size_t resp_ies_len) |
3528 | 0 | { |
3529 | 0 | struct ieee802_11_elems req_elems, resp_elems; |
3530 | 0 | int max_nss_rx_req, max_nss_rx_resp, max_nss_tx_req, max_nss_tx_resp; |
3531 | 0 | struct supported_chan_width sta_supported_chan_width; |
3532 | 0 | enum chan_width ap_operation_chan_width; |
3533 | 0 | struct wpabuf *req_mlbuf, *resp_mlbuf; |
3534 | |
|
3535 | 0 | wpa_s->connection_set = 0; |
3536 | |
|
3537 | 0 | if (!req_ies || !resp_ies || |
3538 | 0 | ieee802_11_parse_elems(req_ies, req_ies_len, &req_elems, 0) == |
3539 | 0 | ParseFailed || |
3540 | 0 | ieee802_11_parse_elems(resp_ies, resp_ies_len, &resp_elems, 0) == |
3541 | 0 | ParseFailed) |
3542 | 0 | return; |
3543 | | |
3544 | 0 | wpa_s->connection_set = 1; |
3545 | 0 | wpa_s->connection_ht = req_elems.ht_capabilities && |
3546 | 0 | resp_elems.ht_capabilities; |
3547 | | |
3548 | | /* Do not include subset of VHT on 2.4 GHz vendor extension in |
3549 | | * consideration for reporting VHT association. */ |
3550 | 0 | wpa_s->connection_vht = req_elems.vht_capabilities && |
3551 | 0 | resp_elems.vht_capabilities && |
3552 | 0 | (!freq || wpas_freq_to_band(freq) != BAND_2_4_GHZ); |
3553 | 0 | wpa_s->connection_he = req_elems.he_capabilities && |
3554 | 0 | resp_elems.he_capabilities; |
3555 | 0 | wpa_s->connection_eht = req_elems.eht_capabilities && |
3556 | 0 | resp_elems.eht_capabilities; |
3557 | 0 | if (req_elems.rrm_enabled) |
3558 | 0 | wpa_s->rrm.rrm_used = 1; |
3559 | |
|
3560 | | #ifdef CONFIG_PMKSA_PRIVACY |
3561 | | if (wpa_s->assoc_resp_encrypted && resp_elems.nonce) { |
3562 | | os_memcpy(wpa_s->pmkid_anonce, resp_elems.nonce, NONCE_LEN); |
3563 | | wpa_s->pmkid_anonce_set = true; |
3564 | | wpa_hexdump(MSG_DEBUG, |
3565 | | "PMKID privacy: ANonce in Assoc Response", |
3566 | | wpa_s->pmkid_anonce, NONCE_LEN); |
3567 | | } |
3568 | | #endif /* CONFIG_PMKSA_PRIVACY */ |
3569 | |
|
3570 | 0 | sta_supported_chan_width = get_supported_channel_width(&req_elems); |
3571 | 0 | ap_operation_chan_width = get_operation_channel_width(&resp_elems); |
3572 | 0 | if (wpa_s->connection_vht || wpa_s->connection_he || |
3573 | 0 | wpa_s->connection_eht) { |
3574 | 0 | wpa_s->connection_channel_bandwidth = |
3575 | 0 | get_sta_operation_chan_width(ap_operation_chan_width, |
3576 | 0 | sta_supported_chan_width); |
3577 | 0 | } else if (wpa_s->connection_ht) { |
3578 | 0 | wpa_s->connection_channel_bandwidth = |
3579 | 0 | ap_operation_chan_width == CHAN_WIDTH_40 ? |
3580 | 0 | CHAN_WIDTH_40 : CHAN_WIDTH_20; |
3581 | 0 | } else { |
3582 | 0 | wpa_s->connection_channel_bandwidth = CHAN_WIDTH_20; |
3583 | 0 | } |
3584 | |
|
3585 | 0 | max_nss_rx_req = get_max_nss_capability( |
3586 | 0 | &req_elems, 1, wpa_s->connection_channel_bandwidth); |
3587 | 0 | max_nss_rx_resp = get_max_nss_capability( |
3588 | 0 | &resp_elems, 1, wpa_s->connection_channel_bandwidth); |
3589 | 0 | max_nss_tx_req = get_max_nss_capability( |
3590 | 0 | &req_elems, 0, wpa_s->connection_channel_bandwidth); |
3591 | 0 | max_nss_tx_resp = get_max_nss_capability( |
3592 | 0 | &resp_elems, 0, wpa_s->connection_channel_bandwidth); |
3593 | |
|
3594 | 0 | wpa_s->connection_max_nss_rx = MIN(max_nss_tx_resp, max_nss_rx_req); |
3595 | 0 | wpa_s->connection_max_nss_tx = MIN(max_nss_rx_resp, max_nss_tx_req); |
3596 | |
|
3597 | 0 | req_mlbuf = ieee802_11_defrag(req_elems.basic_mle, |
3598 | 0 | req_elems.basic_mle_len, true); |
3599 | 0 | resp_mlbuf = ieee802_11_defrag(resp_elems.basic_mle, |
3600 | 0 | resp_elems.basic_mle_len, true); |
3601 | 0 | if (req_mlbuf && resp_mlbuf) { |
3602 | 0 | int i; |
3603 | |
|
3604 | 0 | for_each_link(wpa_s->valid_links, i) |
3605 | 0 | wpas_parse_connection_info_link(wpa_s, i, |
3606 | 0 | &req_elems, &resp_elems, |
3607 | 0 | req_mlbuf, resp_mlbuf); |
3608 | 0 | } |
3609 | 0 | wpabuf_free(req_mlbuf); |
3610 | 0 | wpabuf_free(resp_mlbuf); |
3611 | 0 | } |
3612 | | |
3613 | | |
3614 | | #ifdef CONFIG_P2P |
3615 | | |
3616 | | static bool is_assisted_dfs_p2p_allowed_cc(const char *country) |
3617 | | { |
3618 | | return country[0] == 'U' && country[1] == 'S'; |
3619 | | } |
3620 | | |
3621 | | |
3622 | | static bool is_assisted_p2p_dfs_allowed(struct wpa_supplicant *wpa_s, |
3623 | | struct wpa_bss *bss) |
3624 | | { |
3625 | | const u8 *elem; |
3626 | | const char *country; |
3627 | | |
3628 | | if (wpa_s->hw_dfs_domain != HOSTAPD_DFS_REGION_FCC || |
3629 | | !wpa_s->device_country_set) |
3630 | | return false; |
3631 | | |
3632 | | /* Country IE (alpha2 at first two bytes of the payload) */ |
3633 | | elem = wpa_bss_get_ie(bss, WLAN_EID_COUNTRY); |
3634 | | if (!elem || elem[1] < 2) |
3635 | | return false; |
3636 | | |
3637 | | country = (const char *) (elem + 2); |
3638 | | |
3639 | | /* Require the BSS country to match the device country */ |
3640 | | if (country[0] != wpa_s->device_country[0] || |
3641 | | country[1] != wpa_s->device_country[1]) |
3642 | | return false; |
3643 | | |
3644 | | return is_assisted_dfs_p2p_allowed_cc(country); |
3645 | | } |
3646 | | |
3647 | | |
3648 | | static bool is_dfs_owner_ap(struct wpa_supplicant *wpa_s, struct wpa_bss *bss) |
3649 | | { |
3650 | | if (!bss) |
3651 | | return false; |
3652 | | |
3653 | | /* Must NOT have P2P IE (not a P2P GO) */ |
3654 | | if (wpa_bss_get_vendor_ie(bss, P2P_IE_VENDOR_TYPE) || |
3655 | | wpa_bss_get_vendor_ie_beacon(bss, P2P_IE_VENDOR_TYPE)) |
3656 | | return false; |
3657 | | |
3658 | | /* Must be an infrastructure mode connection, not P2P group */ |
3659 | | if (wpa_s->current_ssid && wpa_s->current_ssid->p2p_group) |
3660 | | return false; |
3661 | | |
3662 | | /* Beacon interval of the connected DFS AP needs to be short enough to |
3663 | | * have time to inform P2P clients about the need to vacate the |
3664 | | * operating channel within regulatory requirements. */ |
3665 | | if (bss->beacon_int == 0 || bss->beacon_int > 100) |
3666 | | return false; |
3667 | | |
3668 | | return true; |
3669 | | } |
3670 | | |
3671 | | #endif /* CONFIG_P2P */ |
3672 | | |
3673 | | |
3674 | | #ifdef CONFIG_ENC_ASSOC |
3675 | | static int wpas_rx_enc_assoc_resp(struct wpa_supplicant *wpa_s, const u8 *aa, |
3676 | | const u8 *resp_ies, size_t resp_ies_len) |
3677 | | { |
3678 | | struct ptksa_cache_entry *entry; |
3679 | | |
3680 | | entry = ptksa_cache_get(wpa_s->ptksa, aa, wpa_s->pairwise_cipher); |
3681 | | if (!entry || (entry->auth_alg != WLAN_AUTH_EPPKE && |
3682 | | entry->auth_alg != WLAN_AUTH_802_1X)) |
3683 | | return 0; |
3684 | | |
3685 | | wpa_sm_set_ptk_kck_kek(wpa_s->wpa, entry->ptk.hash_alg, |
3686 | | entry->ptk.kck, entry->ptk.kck_len, |
3687 | | entry->ptk.kek, entry->ptk.kek_len); |
3688 | | |
3689 | | #ifdef CONFIG_TESTING_OPTIONS |
3690 | | wpa_sm_set_ptk_tk(wpa_s->wpa, entry->ptk.tk, entry->ptk.tk_len); |
3691 | | #endif /* CONFIG_TESTING_OPTIONS */ |
3692 | | |
3693 | | return process_encrypted_assoc_resp(wpa_s->wpa, |
3694 | | ((wpa_s->drv_flags2 & |
3695 | | WPA_DRIVER_FLAGS2_MLO) && |
3696 | | wpa_s->valid_links) ? |
3697 | | wpa_s->valid_links : -1, |
3698 | | resp_ies, resp_ies_len); |
3699 | | } |
3700 | | #endif /* CONFIG_ENC_ASSOC */ |
3701 | | |
3702 | | |
3703 | | static int wpa_supplicant_event_associnfo(struct wpa_supplicant *wpa_s, |
3704 | | union wpa_event_data *data) |
3705 | 0 | { |
3706 | 0 | int l, len, found = 0, wpa_found, rsn_found; |
3707 | 0 | #ifndef CONFIG_NO_WPA |
3708 | 0 | int found_x = 0; |
3709 | 0 | #endif /* CONFIG_NO_WPA */ |
3710 | 0 | const u8 *p, *ie; |
3711 | 0 | u8 bssid[ETH_ALEN]; |
3712 | 0 | bool bssid_known; |
3713 | 0 | enum wpa_rsn_override rsn_override; |
3714 | |
|
3715 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "Association info event"); |
3716 | 0 | wpa_s->ssid_verified = false; |
3717 | 0 | wpa_s->bigtk_set = false; |
3718 | | #ifdef CONFIG_ENC_ASSOC |
3719 | | if (data->assoc_info.resp_frame && |
3720 | | data->assoc_info.resp_frame_len >= 2 && |
3721 | | (WPA_GET_LE16(data->assoc_info.resp_frame) & WLAN_FC_PROTECTED)) { |
3722 | | wpa_printf(MSG_INFO, "Association Response frame is encrypted"); |
3723 | | wpa_s->assoc_resp_encrypted = true; |
3724 | | } else { |
3725 | | wpa_s->assoc_resp_encrypted = false; |
3726 | | } |
3727 | | #endif /* CONFIG_ENC_ASSOC */ |
3728 | | #ifdef CONFIG_SAE |
3729 | | #ifdef CONFIG_SME |
3730 | | /* SAE H2E binds the SSID into PT and that verifies the SSID |
3731 | | * implicitly. */ |
3732 | | if (wpa_s->sme.sae.state == SAE_ACCEPTED && wpa_s->sme.sae.h2e) |
3733 | | wpa_s->ssid_verified = true; |
3734 | | #endif /* CONFIG_SME */ |
3735 | | #endif /* CONFIG_SAE */ |
3736 | 0 | bssid_known = wpa_drv_get_bssid(wpa_s, bssid) == 0; |
3737 | 0 | if (data->assoc_info.req_ies) |
3738 | 0 | wpa_hexdump(MSG_DEBUG, "req_ies", data->assoc_info.req_ies, |
3739 | 0 | data->assoc_info.req_ies_len); |
3740 | 0 | if (data->assoc_info.resp_ies) { |
3741 | 0 | wpa_hexdump(MSG_DEBUG, "resp_ies", data->assoc_info.resp_ies, |
3742 | 0 | data->assoc_info.resp_ies_len); |
3743 | | #ifdef CONFIG_TDLS |
3744 | | wpa_tdls_assoc_resp_ies(wpa_s->wpa, data->assoc_info.resp_ies, |
3745 | | data->assoc_info.resp_ies_len); |
3746 | | #endif /* CONFIG_TDLS */ |
3747 | 0 | #ifdef CONFIG_WNM |
3748 | 0 | wnm_process_assoc_resp(wpa_s, data->assoc_info.resp_ies, |
3749 | 0 | data->assoc_info.resp_ies_len); |
3750 | 0 | #endif /* CONFIG_WNM */ |
3751 | 0 | interworking_process_assoc_resp(wpa_s, data->assoc_info.resp_ies, |
3752 | 0 | data->assoc_info.resp_ies_len); |
3753 | 0 | if ((wpa_s->hw_capab & BIT(CAPAB_VHT)) && |
3754 | 0 | get_ie(data->assoc_info.resp_ies, |
3755 | 0 | data->assoc_info.resp_ies_len, WLAN_EID_VHT_CAP)) |
3756 | 0 | wpa_s->ieee80211ac = 1; |
3757 | |
|
3758 | 0 | multi_ap_process_assoc_resp(wpa_s, data->assoc_info.resp_ies, |
3759 | 0 | data->assoc_info.resp_ies_len); |
3760 | 0 | } |
3761 | 0 | if (data->assoc_info.beacon_ies) |
3762 | 0 | wpa_hexdump(MSG_DEBUG, "beacon_ies", |
3763 | 0 | data->assoc_info.beacon_ies, |
3764 | 0 | data->assoc_info.beacon_ies_len); |
3765 | 0 | if (data->assoc_info.freq) |
3766 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "freq=%u MHz", |
3767 | 0 | data->assoc_info.freq); |
3768 | |
|
3769 | 0 | wpas_parse_connection_info(wpa_s, data->assoc_info.freq, |
3770 | 0 | data->assoc_info.req_ies, |
3771 | 0 | data->assoc_info.req_ies_len, |
3772 | 0 | data->assoc_info.resp_ies, |
3773 | 0 | data->assoc_info.resp_ies_len); |
3774 | |
|
3775 | 0 | p = data->assoc_info.req_ies; |
3776 | 0 | l = data->assoc_info.req_ies_len; |
3777 | | |
3778 | | /* Go through the IEs and make a copy of the WPA/RSN IE, if present. */ |
3779 | 0 | while (p && l >= 2) { |
3780 | 0 | len = p[1] + 2; |
3781 | 0 | if (len > l) { |
3782 | 0 | wpa_hexdump(MSG_DEBUG, "Truncated IE in assoc_info", |
3783 | 0 | p, l); |
3784 | 0 | break; |
3785 | 0 | } |
3786 | 0 | if (!found && |
3787 | 0 | ((p[0] == WLAN_EID_VENDOR_SPECIFIC && p[1] >= 6 && |
3788 | 0 | (os_memcmp(&p[2], "\x00\x50\xF2\x01\x01\x00", 6) == 0)) || |
3789 | 0 | (p[0] == WLAN_EID_VENDOR_SPECIFIC && p[1] >= 4 && |
3790 | 0 | (os_memcmp(&p[2], "\x50\x6F\x9A\x12", 4) == 0)) || |
3791 | 0 | (p[0] == WLAN_EID_RSN && p[1] >= 2))) { |
3792 | 0 | if (wpa_sm_set_assoc_wpa_ie(wpa_s->wpa, p, len)) |
3793 | 0 | break; |
3794 | 0 | found = 1; |
3795 | 0 | wpa_find_assoc_pmkid(wpa_s); |
3796 | 0 | } |
3797 | 0 | #ifndef CONFIG_NO_WPA |
3798 | 0 | if (!found_x && p[0] == WLAN_EID_RSNX) { |
3799 | 0 | if (wpa_sm_set_assoc_rsnxe(wpa_s->wpa, p, len)) |
3800 | 0 | break; |
3801 | 0 | found_x = 1; |
3802 | 0 | } |
3803 | 0 | #endif /* CONFIG_NO_WPA */ |
3804 | 0 | l -= len; |
3805 | 0 | p += len; |
3806 | 0 | } |
3807 | 0 | if (!found && data->assoc_info.req_ies) |
3808 | 0 | wpa_sm_set_assoc_wpa_ie(wpa_s->wpa, NULL, 0); |
3809 | 0 | #ifndef CONFIG_NO_WPA |
3810 | 0 | if (!found_x && data->assoc_info.req_ies) |
3811 | 0 | wpa_sm_set_assoc_rsnxe(wpa_s->wpa, NULL, 0); |
3812 | 0 | #endif /* CONFIG_NO_WPA */ |
3813 | |
|
3814 | 0 | rsn_override = RSN_OVERRIDE_NOT_USED; |
3815 | 0 | ie = get_vendor_ie(data->assoc_info.req_ies, |
3816 | 0 | data->assoc_info.req_ies_len, |
3817 | 0 | RSN_SELECTION_IE_VENDOR_TYPE); |
3818 | 0 | if (ie && ie[1] >= 4 + 1) { |
3819 | 0 | switch (ie[2 + 4]) { |
3820 | 0 | case RSN_SELECTION_RSNE: |
3821 | 0 | rsn_override = RSN_OVERRIDE_RSNE; |
3822 | 0 | break; |
3823 | 0 | case RSN_SELECTION_RSNE_OVERRIDE: |
3824 | 0 | rsn_override = RSN_OVERRIDE_RSNE_OVERRIDE; |
3825 | 0 | break; |
3826 | 0 | case RSN_SELECTION_RSNE_OVERRIDE_2: |
3827 | 0 | rsn_override = RSN_OVERRIDE_RSNE_OVERRIDE_2; |
3828 | 0 | break; |
3829 | 0 | } |
3830 | 0 | } |
3831 | 0 | wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_RSN_OVERRIDE, rsn_override); |
3832 | |
|
3833 | | #ifdef CONFIG_FILS |
3834 | | #ifdef CONFIG_SME |
3835 | | if (wpa_s->sme.auth_alg == WPA_AUTH_ALG_FILS || |
3836 | | wpa_s->sme.auth_alg == WPA_AUTH_ALG_FILS_SK_PFS) { |
3837 | | if (!data->assoc_info.resp_frame || |
3838 | | fils_process_assoc_resp(wpa_s->wpa, |
3839 | | data->assoc_info.resp_frame, |
3840 | | data->assoc_info.resp_frame_len) < |
3841 | | 0) { |
3842 | | wpa_supplicant_deauthenticate(wpa_s, |
3843 | | WLAN_REASON_UNSPECIFIED); |
3844 | | return -1; |
3845 | | } |
3846 | | |
3847 | | /* FILS use of an AEAD cipher include the SSID element in |
3848 | | * (Re)Association Request frame in the AAD and since the AP |
3849 | | * accepted that, the SSID was verified. */ |
3850 | | wpa_s->ssid_verified = true; |
3851 | | } |
3852 | | #endif /* CONFIG_SME */ |
3853 | | |
3854 | | /* Additional processing for FILS when SME is in driver */ |
3855 | | if (wpa_s->auth_alg == WPA_AUTH_ALG_FILS && |
3856 | | !(wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)) |
3857 | | wpa_sm_set_reset_fils_completed(wpa_s->wpa, 1); |
3858 | | #endif /* CONFIG_FILS */ |
3859 | |
|
3860 | | #ifdef CONFIG_ENC_ASSOC |
3861 | | if (wpa_s->assoc_resp_encrypted && |
3862 | | (wpa_s->drv_flags2 & |
3863 | | WPA_DRIVER_FLAGS2_ASSOCIATION_FRAME_ENCRYPTION) && |
3864 | | wpas_rx_enc_assoc_resp(wpa_s, wpa_s->valid_links ? |
3865 | | wpa_s->ap_mld_addr : bssid, |
3866 | | data->assoc_info.resp_ies, |
3867 | | data->assoc_info.resp_ies_len) < 0) { |
3868 | | wpa_supplicant_deauthenticate(wpa_s, WLAN_REASON_UNSPECIFIED); |
3869 | | return -1; |
3870 | | } |
3871 | | #endif /* CONFIG_ENC_ASSOC */ |
3872 | |
|
3873 | | #ifdef CONFIG_OWE |
3874 | | if (wpa_s->key_mgmt == WPA_KEY_MGMT_OWE && |
3875 | | !(wpa_s->drv_flags2 & WPA_DRIVER_FLAGS2_OWE_OFFLOAD_STA) && |
3876 | | (!bssid_known || |
3877 | | owe_process_assoc_resp(wpa_s->wpa, |
3878 | | wpa_s->valid_links ? |
3879 | | wpa_s->ap_mld_addr : bssid, |
3880 | | data->assoc_info.resp_ies, |
3881 | | data->assoc_info.resp_ies_len) < 0)) { |
3882 | | wpa_supplicant_deauthenticate(wpa_s, WLAN_REASON_UNSPECIFIED); |
3883 | | return -1; |
3884 | | } |
3885 | | #endif /* CONFIG_OWE */ |
3886 | |
|
3887 | | #ifdef CONFIG_DPP2 |
3888 | | wpa_sm_set_dpp_z(wpa_s->wpa, NULL); |
3889 | | if (DPP_VERSION > 1 && wpa_s->key_mgmt == WPA_KEY_MGMT_DPP && |
3890 | | wpa_s->dpp_pfs) { |
3891 | | struct ieee802_11_elems elems; |
3892 | | |
3893 | | if (ieee802_11_parse_elems(data->assoc_info.resp_ies, |
3894 | | data->assoc_info.resp_ies_len, |
3895 | | &elems, 0) == ParseFailed || |
3896 | | !elems.owe_dh) |
3897 | | goto no_pfs; |
3898 | | if (dpp_pfs_process(wpa_s->dpp_pfs, elems.owe_dh, |
3899 | | elems.owe_dh_len) < 0) { |
3900 | | wpa_supplicant_deauthenticate(wpa_s, |
3901 | | WLAN_REASON_UNSPECIFIED); |
3902 | | return -1; |
3903 | | } |
3904 | | |
3905 | | wpa_sm_set_dpp_z(wpa_s->wpa, wpa_s->dpp_pfs->secret); |
3906 | | } |
3907 | | no_pfs: |
3908 | | #endif /* CONFIG_DPP2 */ |
3909 | |
|
3910 | | #ifdef CONFIG_IEEE80211R |
3911 | | #ifdef CONFIG_SME |
3912 | | if (wpa_s->sme.auth_alg == WPA_AUTH_ALG_FT) { |
3913 | | if (!bssid_known || |
3914 | | wpa_ft_validate_reassoc_resp(wpa_s->wpa, |
3915 | | data->assoc_info.resp_ies, |
3916 | | data->assoc_info.resp_ies_len, |
3917 | | bssid) < 0) { |
3918 | | wpa_dbg(wpa_s, MSG_DEBUG, "FT: Validation of " |
3919 | | "Reassociation Response failed"); |
3920 | | wpa_supplicant_deauthenticate( |
3921 | | wpa_s, WLAN_REASON_INVALID_IE); |
3922 | | return -1; |
3923 | | } |
3924 | | /* SSID is included in PMK-R0 derivation, so it is verified |
3925 | | * implicitly. */ |
3926 | | wpa_s->ssid_verified = true; |
3927 | | } |
3928 | | |
3929 | | p = data->assoc_info.resp_ies; |
3930 | | l = data->assoc_info.resp_ies_len; |
3931 | | |
3932 | | #ifdef CONFIG_WPS_STRICT |
3933 | | if (p && wpa_s->current_ssid && |
3934 | | wpa_s->current_ssid->key_mgmt == WPA_KEY_MGMT_WPS) { |
3935 | | struct wpabuf *wps; |
3936 | | wps = ieee802_11_vendor_ie_concat(p, l, WPS_IE_VENDOR_TYPE); |
3937 | | if (wps == NULL) { |
3938 | | wpa_msg(wpa_s, MSG_INFO, "WPS-STRICT: AP did not " |
3939 | | "include WPS IE in (Re)Association Response"); |
3940 | | return -1; |
3941 | | } |
3942 | | |
3943 | | if (wps_validate_assoc_resp(wps) < 0) { |
3944 | | wpabuf_free(wps); |
3945 | | wpa_supplicant_deauthenticate( |
3946 | | wpa_s, WLAN_REASON_INVALID_IE); |
3947 | | return -1; |
3948 | | } |
3949 | | wpabuf_free(wps); |
3950 | | } |
3951 | | #endif /* CONFIG_WPS_STRICT */ |
3952 | | |
3953 | | /* Go through the IEs and make a copy of the MDIE, if present. */ |
3954 | | while (p && l >= 2) { |
3955 | | len = p[1] + 2; |
3956 | | if (len > l) { |
3957 | | wpa_hexdump(MSG_DEBUG, "Truncated IE in assoc_info", |
3958 | | p, l); |
3959 | | break; |
3960 | | } |
3961 | | if (p[0] == WLAN_EID_MOBILITY_DOMAIN && |
3962 | | p[1] >= MOBILITY_DOMAIN_ID_LEN) { |
3963 | | wpa_s->sme.ft_used = 1; |
3964 | | os_memcpy(wpa_s->sme.mobility_domain, p + 2, |
3965 | | MOBILITY_DOMAIN_ID_LEN); |
3966 | | break; |
3967 | | } |
3968 | | l -= len; |
3969 | | p += len; |
3970 | | } |
3971 | | #endif /* CONFIG_SME */ |
3972 | | |
3973 | | /* Process FT when SME is in the driver */ |
3974 | | if (!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME) && |
3975 | | wpa_ft_is_completed(wpa_s->wpa)) { |
3976 | | if (!bssid_known || |
3977 | | wpa_ft_validate_reassoc_resp(wpa_s->wpa, |
3978 | | data->assoc_info.resp_ies, |
3979 | | data->assoc_info.resp_ies_len, |
3980 | | bssid) < 0) { |
3981 | | wpa_dbg(wpa_s, MSG_DEBUG, "FT: Validation of " |
3982 | | "Reassociation Response failed"); |
3983 | | wpa_supplicant_deauthenticate( |
3984 | | wpa_s, WLAN_REASON_INVALID_IE); |
3985 | | return -1; |
3986 | | } |
3987 | | wpa_dbg(wpa_s, MSG_DEBUG, "FT: Reassociation Response done"); |
3988 | | /* SSID is included in PMK-R0 derivation, so it is verified |
3989 | | * implicitly. */ |
3990 | | wpa_s->ssid_verified = true; |
3991 | | } |
3992 | | |
3993 | | wpa_sm_set_ft_params(wpa_s->wpa, data->assoc_info.resp_ies, |
3994 | | data->assoc_info.resp_ies_len); |
3995 | | #endif /* CONFIG_IEEE80211R */ |
3996 | |
|
3997 | 0 | #ifndef CONFIG_NO_ROBUST_AV |
3998 | 0 | if (bssid_known) |
3999 | 0 | wpas_handle_assoc_resp_mscs(wpa_s, bssid, |
4000 | 0 | data->assoc_info.resp_ies, |
4001 | 0 | data->assoc_info.resp_ies_len); |
4002 | 0 | #endif /* CONFIG_NO_ROBUST_AV */ |
4003 | | |
4004 | | /* WPA/RSN IE from Beacon/ProbeResp */ |
4005 | 0 | p = data->assoc_info.beacon_ies; |
4006 | 0 | l = data->assoc_info.beacon_ies_len; |
4007 | | |
4008 | | /* Go through the IEs and make a copy of the WPA/RSN IEs, if present. |
4009 | | */ |
4010 | 0 | wpa_found = rsn_found = 0; |
4011 | 0 | while (p && l >= 2) { |
4012 | 0 | len = p[1] + 2; |
4013 | 0 | if (len > l) { |
4014 | 0 | wpa_hexdump(MSG_DEBUG, "Truncated IE in beacon_ies", |
4015 | 0 | p, l); |
4016 | 0 | break; |
4017 | 0 | } |
4018 | 0 | if (!wpa_found && |
4019 | 0 | p[0] == WLAN_EID_VENDOR_SPECIFIC && p[1] >= 6 && |
4020 | 0 | os_memcmp(&p[2], "\x00\x50\xF2\x01\x01\x00", 6) == 0) { |
4021 | 0 | wpa_found = 1; |
4022 | 0 | wpa_sm_set_ap_wpa_ie(wpa_s->wpa, p, len); |
4023 | 0 | } |
4024 | |
|
4025 | 0 | if (!rsn_found && |
4026 | 0 | p[0] == WLAN_EID_RSN && p[1] >= 2) { |
4027 | 0 | rsn_found = 1; |
4028 | 0 | wpa_sm_set_ap_rsn_ie(wpa_s->wpa, p, len); |
4029 | 0 | } |
4030 | |
|
4031 | 0 | if (p[0] == WLAN_EID_VENDOR_SPECIFIC && p[1] >= 6 && |
4032 | 0 | WPA_GET_BE32(&p[2]) == RSNE_OVERRIDE_2_IE_VENDOR_TYPE) |
4033 | 0 | wpa_sm_set_ap_rsne_override_2(wpa_s->wpa, p, len); |
4034 | |
|
4035 | 0 | if (p[0] == WLAN_EID_VENDOR_SPECIFIC && p[1] >= 6 && |
4036 | 0 | WPA_GET_BE32(&p[2]) == RSNE_OVERRIDE_IE_VENDOR_TYPE) |
4037 | 0 | wpa_sm_set_ap_rsne_override(wpa_s->wpa, p, len); |
4038 | |
|
4039 | 0 | if (p[0] == WLAN_EID_RSNX && p[1] >= 1) |
4040 | 0 | wpa_sm_set_ap_rsnxe(wpa_s->wpa, p, len); |
4041 | |
|
4042 | 0 | if (p[0] == WLAN_EID_VENDOR_SPECIFIC && p[1] >= 5 && |
4043 | 0 | WPA_GET_BE32(&p[2]) == RSNXE_OVERRIDE_IE_VENDOR_TYPE) |
4044 | 0 | wpa_sm_set_ap_rsnxe_override(wpa_s->wpa, p, len); |
4045 | |
|
4046 | 0 | l -= len; |
4047 | 0 | p += len; |
4048 | 0 | } |
4049 | |
|
4050 | 0 | if (!wpa_found && data->assoc_info.beacon_ies) |
4051 | 0 | wpa_sm_set_ap_wpa_ie(wpa_s->wpa, NULL, 0); |
4052 | 0 | if (!rsn_found && data->assoc_info.beacon_ies) { |
4053 | 0 | wpa_sm_set_ap_rsn_ie(wpa_s->wpa, NULL, 0); |
4054 | 0 | wpa_sm_set_ap_rsnxe(wpa_s->wpa, NULL, 0); |
4055 | 0 | wpa_sm_set_ap_rsne_override(wpa_s->wpa, NULL, 0); |
4056 | 0 | wpa_sm_set_ap_rsne_override_2(wpa_s->wpa, NULL, 0); |
4057 | 0 | wpa_sm_set_ap_rsnxe_override(wpa_s->wpa, NULL, 0); |
4058 | 0 | } |
4059 | 0 | if (wpa_found || rsn_found) |
4060 | 0 | wpa_s->ap_ies_from_associnfo = 1; |
4061 | |
|
4062 | 0 | if (wpa_s->assoc_freq && data->assoc_info.freq) { |
4063 | 0 | struct wpa_bss *bss; |
4064 | 0 | unsigned int freq = 0; |
4065 | |
|
4066 | 0 | if (bssid_known) { |
4067 | 0 | bss = wpa_bss_get_bssid_latest(wpa_s, bssid); |
4068 | 0 | if (bss) |
4069 | 0 | freq = bss->freq; |
4070 | 0 | } |
4071 | 0 | if (freq != data->assoc_info.freq) { |
4072 | 0 | wpa_printf(MSG_DEBUG, |
4073 | 0 | "Operating frequency changed from %u to %u MHz", |
4074 | 0 | wpa_s->assoc_freq, data->assoc_info.freq); |
4075 | 0 | wpa_supplicant_update_scan_results(wpa_s, bssid); |
4076 | 0 | } |
4077 | 0 | } |
4078 | |
|
4079 | 0 | wpa_s->assoc_freq = data->assoc_info.freq; |
4080 | |
|
4081 | | #ifdef CONFIG_P2P |
4082 | | if (wpa_s->allow_p2p_assisted_dfs && |
4083 | | ieee80211_is_dfs(wpa_s->assoc_freq, wpa_s->hw.modes, |
4084 | | wpa_s->hw.num_modes)) { |
4085 | | struct wpa_bss *bss = NULL; |
4086 | | |
4087 | | if (bssid_known) |
4088 | | bss = wpa_bss_get_bssid_latest(wpa_s, bssid); |
4089 | | |
4090 | | if (bss && is_assisted_p2p_dfs_allowed(wpa_s, bss) && |
4091 | | is_dfs_owner_ap(wpa_s, bss)) { |
4092 | | enum chan_width ap_operation_chan_width = |
4093 | | CHAN_WIDTH_UNKNOWN; |
4094 | | struct ieee802_11_elems resp_elems_local; |
4095 | | |
4096 | | /* Parse resp_ies locally to extract AP operation |
4097 | | * channel width */ |
4098 | | if (data->assoc_info.resp_ies && |
4099 | | ieee802_11_parse_elems( |
4100 | | data->assoc_info.resp_ies, |
4101 | | data->assoc_info.resp_ies_len, |
4102 | | &resp_elems_local, 0) != ParseFailed) |
4103 | | ap_operation_chan_width = |
4104 | | get_operation_channel_width( |
4105 | | &resp_elems_local); |
4106 | | |
4107 | | wpa_s->assisted_dfs = true; |
4108 | | wpas_update_dfs_ap_info(wpa_s, wpa_s->assoc_freq, |
4109 | | ap_operation_chan_width, false); |
4110 | | } |
4111 | | } else if (wpa_s->allow_p2p_assisted_dfs && wpa_s->valid_links) { |
4112 | | /* For MLO, check other links as well for DFS */ |
4113 | | int i; |
4114 | | |
4115 | | for_each_link(wpa_s->valid_links, i) { |
4116 | | struct wpa_bss *link_bss; |
4117 | | |
4118 | | if (wpa_s->links[i].freq == wpa_s->assoc_freq) |
4119 | | continue; |
4120 | | |
4121 | | if (ieee80211_is_dfs(wpa_s->links[i].freq, |
4122 | | wpa_s->hw.modes, |
4123 | | wpa_s->hw.num_modes)) { |
4124 | | link_bss = wpa_s->links[i].bss; |
4125 | | if (!link_bss) |
4126 | | link_bss = wpa_bss_get_bssid( |
4127 | | wpa_s, wpa_s->links[i].bssid); |
4128 | | |
4129 | | if (link_bss && |
4130 | | is_assisted_p2p_dfs_allowed(wpa_s, |
4131 | | link_bss) && |
4132 | | is_dfs_owner_ap(wpa_s, link_bss)) { |
4133 | | wpa_s->assisted_dfs = true; |
4134 | | wpas_update_dfs_ap_info( |
4135 | | wpa_s, wpa_s->links[i].freq, |
4136 | | wpa_s->links[i].channel_bandwidth, |
4137 | | false); |
4138 | | break; |
4139 | | } |
4140 | | } |
4141 | | } |
4142 | | } |
4143 | | #endif /* CONFIG_P2P */ |
4144 | |
|
4145 | 0 | #ifndef CONFIG_NO_ROBUST_AV |
4146 | 0 | wpas_handle_assoc_resp_qos_mgmt(wpa_s, data->assoc_info.resp_ies, |
4147 | 0 | data->assoc_info.resp_ies_len); |
4148 | 0 | #endif /* CONFIG_NO_ROBUST_AV */ |
4149 | |
|
4150 | 0 | return 0; |
4151 | 0 | } |
4152 | | |
4153 | | |
4154 | | static int wpa_supplicant_assoc_update_ie(struct wpa_supplicant *wpa_s) |
4155 | 0 | { |
4156 | 0 | const u8 *bss_wpa = NULL, *bss_rsn = NULL, *bss_rsnx = NULL; |
4157 | 0 | const u8 *rsnoe, *rsno2e, *rsnxoe; |
4158 | |
|
4159 | 0 | if (!wpa_s->current_bss || !wpa_s->current_ssid) |
4160 | 0 | return -1; |
4161 | | |
4162 | 0 | if (!wpa_key_mgmt_wpa_any(wpa_s->current_ssid->key_mgmt)) |
4163 | 0 | return 0; |
4164 | | |
4165 | 0 | bss_wpa = wpa_bss_get_vendor_ie(wpa_s->current_bss, |
4166 | 0 | WPA_IE_VENDOR_TYPE); |
4167 | 0 | bss_rsn = wpa_bss_get_ie(wpa_s->current_bss, WLAN_EID_RSN); |
4168 | 0 | bss_rsnx = wpa_bss_get_ie(wpa_s->current_bss, WLAN_EID_RSNX); |
4169 | 0 | rsnoe = wpa_bss_get_vendor_ie(wpa_s->current_bss, |
4170 | 0 | RSNE_OVERRIDE_IE_VENDOR_TYPE); |
4171 | 0 | rsno2e = wpa_bss_get_vendor_ie(wpa_s->current_bss, |
4172 | 0 | RSNE_OVERRIDE_2_IE_VENDOR_TYPE); |
4173 | 0 | rsnxoe = wpa_bss_get_vendor_ie(wpa_s->current_bss, |
4174 | 0 | RSNXE_OVERRIDE_IE_VENDOR_TYPE); |
4175 | |
|
4176 | 0 | if (wpa_sm_set_ap_wpa_ie(wpa_s->wpa, bss_wpa, |
4177 | 0 | bss_wpa ? 2 + bss_wpa[1] : 0) || |
4178 | 0 | wpa_sm_set_ap_rsn_ie(wpa_s->wpa, bss_rsn, |
4179 | 0 | bss_rsn ? 2 + bss_rsn[1] : 0) || |
4180 | 0 | wpa_sm_set_ap_rsnxe(wpa_s->wpa, bss_rsnx, |
4181 | 0 | bss_rsnx ? 2 + bss_rsnx[1] : 0) || |
4182 | 0 | wpa_sm_set_ap_rsne_override(wpa_s->wpa, rsnoe, |
4183 | 0 | rsnoe ? 2 + rsnoe[1] : 0) || |
4184 | 0 | wpa_sm_set_ap_rsne_override_2(wpa_s->wpa, rsno2e, |
4185 | 0 | rsno2e ? 2 + rsno2e[1] : 0) || |
4186 | 0 | wpa_sm_set_ap_rsnxe_override(wpa_s->wpa, rsnxoe, |
4187 | 0 | rsnxoe ? 2 + rsnxoe[1] : 0)) |
4188 | 0 | return -1; |
4189 | | |
4190 | 0 | return 0; |
4191 | 0 | } |
4192 | | |
4193 | | |
4194 | | static void wpas_fst_update_mb_assoc(struct wpa_supplicant *wpa_s, |
4195 | | union wpa_event_data *data) |
4196 | 0 | { |
4197 | | #ifdef CONFIG_FST |
4198 | | struct assoc_info *ai = data ? &data->assoc_info : NULL; |
4199 | | struct wpa_bss *bss = wpa_s->current_bss; |
4200 | | const u8 *ieprb, *iebcn; |
4201 | | |
4202 | | wpabuf_free(wpa_s->received_mb_ies); |
4203 | | wpa_s->received_mb_ies = NULL; |
4204 | | |
4205 | | if (ai && |
4206 | | !wpas_fst_update_mbie(wpa_s, ai->resp_ies, ai->resp_ies_len)) { |
4207 | | wpa_printf(MSG_DEBUG, |
4208 | | "FST: MB IEs updated from Association Response frame"); |
4209 | | return; |
4210 | | } |
4211 | | |
4212 | | if (ai && |
4213 | | !wpas_fst_update_mbie(wpa_s, ai->beacon_ies, ai->beacon_ies_len)) { |
4214 | | wpa_printf(MSG_DEBUG, |
4215 | | "FST: MB IEs updated from association event Beacon IEs"); |
4216 | | return; |
4217 | | } |
4218 | | |
4219 | | if (!bss) |
4220 | | return; |
4221 | | |
4222 | | ieprb = wpa_bss_ie_ptr(bss); |
4223 | | iebcn = ieprb + bss->ie_len; |
4224 | | |
4225 | | if (!wpas_fst_update_mbie(wpa_s, ieprb, bss->ie_len)) |
4226 | | wpa_printf(MSG_DEBUG, "FST: MB IEs updated from bss IE"); |
4227 | | else if (!wpas_fst_update_mbie(wpa_s, iebcn, bss->beacon_ie_len)) |
4228 | | wpa_printf(MSG_DEBUG, "FST: MB IEs updated from bss beacon IE"); |
4229 | | #endif /* CONFIG_FST */ |
4230 | 0 | } |
4231 | | |
4232 | | |
4233 | | static unsigned int wpas_ml_parse_assoc(struct wpa_supplicant *wpa_s, |
4234 | | struct ieee802_11_elems *elems, |
4235 | | struct ml_sta_link_info *ml_info) |
4236 | 0 | { |
4237 | 0 | struct wpabuf *mlbuf; |
4238 | 0 | struct ieee80211_eht_ml *ml; |
4239 | 0 | size_t ml_len; |
4240 | 0 | struct eht_ml_basic_common_info *common_info; |
4241 | 0 | const u8 *pos; |
4242 | 0 | u16 eml_capa = 0, mld_capa = 0; |
4243 | 0 | const u16 control = MULTI_LINK_CONTROL_TYPE_BASIC | |
4244 | 0 | BASIC_MULTI_LINK_CTRL_PRES_LINK_ID | |
4245 | 0 | BASIC_MULTI_LINK_CTRL_PRES_BSS_PARAM_CH_COUNT; |
4246 | 0 | u8 expected_common_info_len = 9; |
4247 | 0 | unsigned int i = 0; |
4248 | 0 | u16 ml_control; |
4249 | |
|
4250 | 0 | if (!wpa_s->valid_links || !elems->basic_mle || !elems->basic_mle_len) |
4251 | 0 | return 0; |
4252 | | |
4253 | 0 | mlbuf = ieee802_11_defrag(elems->basic_mle, elems->basic_mle_len, true); |
4254 | 0 | if (!mlbuf) |
4255 | 0 | return 0; |
4256 | | |
4257 | 0 | ml = (struct ieee80211_eht_ml *) wpabuf_head(mlbuf); |
4258 | 0 | ml_len = wpabuf_len(mlbuf); |
4259 | 0 | if (ml_len < sizeof(*ml)) |
4260 | 0 | goto out; |
4261 | | |
4262 | 0 | os_memset(ml_info, 0, sizeof(*ml_info) * MAX_NUM_MLD_LINKS); |
4263 | |
|
4264 | 0 | ml_control = le_to_host16(ml->ml_control); |
4265 | |
|
4266 | 0 | if ((ml_control & control) != control) { |
4267 | 0 | wpa_printf(MSG_DEBUG, "MLD: Invalid presence BM=0x%x", |
4268 | 0 | ml_control); |
4269 | 0 | goto out; |
4270 | 0 | } |
4271 | | |
4272 | 0 | if (ml_control & BASIC_MULTI_LINK_CTRL_PRES_EML_CAPA) { |
4273 | 0 | wpa_printf(MSG_DEBUG, "MLD: EML capabilities included"); |
4274 | 0 | expected_common_info_len += 2; |
4275 | 0 | } |
4276 | |
|
4277 | 0 | if (ml_control & BASIC_MULTI_LINK_CTRL_PRES_MLD_CAPA) { |
4278 | 0 | wpa_printf(MSG_DEBUG, "MLD: MLD capabilities included"); |
4279 | 0 | expected_common_info_len += 2; |
4280 | 0 | } |
4281 | |
|
4282 | 0 | if (ml_control & BASIC_MULTI_LINK_CTRL_PRES_MSD_INFO) { |
4283 | 0 | wpa_printf(MSG_DEBUG, |
4284 | 0 | "MLD: Unexpected: medium sync delay info present"); |
4285 | 0 | expected_common_info_len += 2; |
4286 | 0 | } |
4287 | |
|
4288 | 0 | if (ml_control & BASIC_MULTI_LINK_CTRL_PRES_AP_MLD_ID) { |
4289 | 0 | wpa_printf(MSG_DEBUG, |
4290 | 0 | "MLD: Unexpected: MLD ID present"); |
4291 | 0 | expected_common_info_len++; |
4292 | 0 | } |
4293 | |
|
4294 | 0 | if (sizeof(*ml) + expected_common_info_len > ml_len) { |
4295 | 0 | wpa_printf(MSG_DEBUG, |
4296 | 0 | "MLD: Not enough bytes for common info. ml_len=%zu", |
4297 | 0 | ml_len); |
4298 | 0 | goto out; |
4299 | 0 | } |
4300 | | |
4301 | 0 | common_info = (struct eht_ml_basic_common_info *) ml->variable; |
4302 | 0 | if (common_info->len < expected_common_info_len) { |
4303 | 0 | wpa_printf(MSG_DEBUG, |
4304 | 0 | "MLD: Invalid common info len=%u. expected=%u", |
4305 | 0 | common_info->len, expected_common_info_len); |
4306 | 0 | goto out; |
4307 | 0 | } |
4308 | | |
4309 | 0 | wpa_printf(MSG_DEBUG, "MLD: address: " MACSTR, |
4310 | 0 | MAC2STR(common_info->mld_addr)); |
4311 | |
|
4312 | 0 | if (!ether_addr_equal(wpa_s->ap_mld_addr, common_info->mld_addr)) { |
4313 | 0 | wpa_printf(MSG_DEBUG, "MLD: Mismatching MLD address (expected " |
4314 | 0 | MACSTR ")", MAC2STR(wpa_s->ap_mld_addr)); |
4315 | 0 | goto out; |
4316 | 0 | } |
4317 | | |
4318 | 0 | pos = common_info->variable; |
4319 | | |
4320 | | /* Store the information for the association link */ |
4321 | 0 | ml_info[i].link_id = *pos; |
4322 | 0 | pos++; |
4323 | | |
4324 | | /* Skip the BSS Parameters Change Count */ |
4325 | 0 | pos++; |
4326 | | |
4327 | | /* Skip the Medium Synchronization Delay Information if present */ |
4328 | 0 | if (ml_control & BASIC_MULTI_LINK_CTRL_PRES_MSD_INFO) |
4329 | 0 | pos += 2; |
4330 | |
|
4331 | 0 | if (ml_control & BASIC_MULTI_LINK_CTRL_PRES_EML_CAPA) { |
4332 | 0 | eml_capa = WPA_GET_LE16(pos); |
4333 | 0 | pos += 2; |
4334 | 0 | } |
4335 | |
|
4336 | 0 | if (ml_control & BASIC_MULTI_LINK_CTRL_PRES_MLD_CAPA) { |
4337 | 0 | mld_capa = WPA_GET_LE16(pos); |
4338 | 0 | pos += 2; |
4339 | 0 | } |
4340 | |
|
4341 | 0 | wpa_printf(MSG_DEBUG, |
4342 | 0 | "MLD: link_id=%u, eml=0x%x, mld=0x%x", |
4343 | 0 | ml_info[i].link_id, eml_capa, mld_capa); |
4344 | |
|
4345 | 0 | i++; |
4346 | |
|
4347 | 0 | pos = ((u8 *) common_info) + common_info->len; |
4348 | 0 | ml_len -= sizeof(*ml) + common_info->len; |
4349 | 0 | while (ml_len > 2 && i < MAX_NUM_MLD_LINKS) { |
4350 | 0 | size_t sub_elem_len, sta_info_len, sta_info_len_min; |
4351 | 0 | u8 nstr_bitmap_len = 0; |
4352 | 0 | u16 ctrl; |
4353 | 0 | const u8 *end; |
4354 | 0 | int num_frag_subelems; |
4355 | |
|
4356 | 0 | num_frag_subelems = |
4357 | 0 | ieee802_11_defrag_mle_subelem(mlbuf, pos, |
4358 | 0 | &sub_elem_len); |
4359 | 0 | if (num_frag_subelems < 0) { |
4360 | 0 | wpa_printf(MSG_DEBUG, |
4361 | 0 | "MLD: Failed to parse MLE subelem"); |
4362 | 0 | goto out; |
4363 | 0 | } |
4364 | | |
4365 | 0 | ml_len -= num_frag_subelems * 2; |
4366 | |
|
4367 | 0 | wpa_printf(MSG_DEBUG, "MLD: Subelement len=%zu", sub_elem_len); |
4368 | |
|
4369 | 0 | if (sub_elem_len > ml_len - 2) { |
4370 | 0 | wpa_printf(MSG_DEBUG, |
4371 | 0 | "MLD: Invalid link info len: %zu > %zu", |
4372 | 0 | 2 + sub_elem_len, ml_len); |
4373 | 0 | goto out; |
4374 | 0 | } |
4375 | | |
4376 | 0 | switch (*pos) { |
4377 | 0 | case MULTI_LINK_SUB_ELEM_ID_PER_STA_PROFILE: |
4378 | 0 | break; |
4379 | 0 | case MULTI_LINK_SUB_ELEM_ID_FRAGMENT: |
4380 | 0 | case MULTI_LINK_SUB_ELEM_ID_VENDOR: |
4381 | 0 | wpa_printf(MSG_DEBUG, |
4382 | 0 | "MLD: Skip subelement id=%u, len=%zu", |
4383 | 0 | *pos, sub_elem_len); |
4384 | 0 | pos += 2 + sub_elem_len; |
4385 | 0 | ml_len -= 2 + sub_elem_len; |
4386 | 0 | continue; |
4387 | 0 | default: |
4388 | 0 | wpa_printf(MSG_DEBUG, "MLD: Unknown subelement ID=%u", |
4389 | 0 | *pos); |
4390 | 0 | goto out; |
4391 | 0 | } |
4392 | | |
4393 | 0 | end = pos + 2 + sub_elem_len; |
4394 | | |
4395 | | /* Skip the subelement ID and the length */ |
4396 | 0 | pos += 2; |
4397 | 0 | ml_len -= 2; |
4398 | |
|
4399 | 0 | if (end - pos < 2) |
4400 | 0 | goto out; |
4401 | | |
4402 | | /* Get the station control field */ |
4403 | 0 | ctrl = WPA_GET_LE16(pos); |
4404 | |
|
4405 | 0 | pos += 2; |
4406 | 0 | ml_len -= 2; |
4407 | |
|
4408 | 0 | if (!(ctrl & BASIC_MLE_STA_CTRL_COMPLETE_PROFILE)) { |
4409 | 0 | wpa_printf(MSG_DEBUG, |
4410 | 0 | "MLD: Per STA complete profile expected"); |
4411 | 0 | goto out; |
4412 | 0 | } |
4413 | | |
4414 | 0 | if (!(ctrl & BASIC_MLE_STA_CTRL_PRES_STA_MAC)) { |
4415 | 0 | wpa_printf(MSG_DEBUG, |
4416 | 0 | "MLD: Per STA MAC address not present"); |
4417 | 0 | goto out; |
4418 | 0 | } |
4419 | | |
4420 | 0 | if (!(ctrl & BASIC_MLE_STA_CTRL_PRES_TSF_OFFSET)) { |
4421 | 0 | wpa_printf(MSG_DEBUG, |
4422 | 0 | "MLD: Per STA TSF offset not present"); |
4423 | 0 | goto out; |
4424 | 0 | } |
4425 | | |
4426 | 0 | if (!(ctrl & BASIC_MLE_STA_CTRL_PRES_BEACON_INT)) { |
4427 | 0 | wpa_printf(MSG_DEBUG, |
4428 | 0 | "MLD: Beacon interval not present"); |
4429 | 0 | goto out; |
4430 | 0 | } |
4431 | | |
4432 | 0 | if (!(ctrl & BASIC_MLE_STA_CTRL_PRES_DTIM_INFO)) { |
4433 | 0 | wpa_printf(MSG_DEBUG, |
4434 | 0 | "MLD: DTIM information not present"); |
4435 | 0 | goto out; |
4436 | 0 | } |
4437 | | |
4438 | 0 | if (ctrl & BASIC_MLE_STA_CTRL_PRES_NSTR_LINK_PAIR) { |
4439 | 0 | if (ctrl & BASIC_MLE_STA_CTRL_NSTR_BITMAP) |
4440 | 0 | nstr_bitmap_len = 2; |
4441 | 0 | else |
4442 | 0 | nstr_bitmap_len = 1; |
4443 | 0 | } |
4444 | |
|
4445 | 0 | if (!(ctrl & BASIC_MLE_STA_CTRL_PRES_BSS_PARAM_COUNT)) { |
4446 | 0 | wpa_printf(MSG_DEBUG, |
4447 | 0 | "MLD: BSS params change count not present"); |
4448 | 0 | goto out; |
4449 | 0 | } |
4450 | | |
4451 | 0 | sta_info_len_min = 1 + ETH_ALEN + 8 + 2 + 2 + 1 + |
4452 | 0 | nstr_bitmap_len; |
4453 | 0 | if (sta_info_len_min > ml_len || |
4454 | 0 | sta_info_len_min > (size_t) (end - pos) || |
4455 | 0 | sta_info_len_min + 2 > sub_elem_len) { |
4456 | 0 | wpa_printf(MSG_DEBUG, |
4457 | 0 | "MLD: Invalid STA info min len=%zu, len=%u", |
4458 | 0 | sta_info_len_min, *pos); |
4459 | 0 | goto out; |
4460 | 0 | } |
4461 | 0 | sta_info_len = *pos; |
4462 | 0 | if (sta_info_len > ml_len || |
4463 | 0 | sta_info_len > sub_elem_len - 2 || |
4464 | 0 | sta_info_len < sta_info_len_min) { |
4465 | 0 | wpa_printf(MSG_DEBUG, |
4466 | 0 | "MLD: Invalid STA info min len=%zu, len=%zu", |
4467 | 0 | sta_info_len_min, sta_info_len); |
4468 | 0 | goto out; |
4469 | 0 | } |
4470 | | |
4471 | | /* Get the link address */ |
4472 | 0 | wpa_printf(MSG_DEBUG, |
4473 | 0 | "MLD: link addr: " MACSTR " nstr BM len=%u", |
4474 | 0 | MAC2STR(pos + 1), nstr_bitmap_len); |
4475 | |
|
4476 | 0 | ml_info[i].link_id = ctrl & BASIC_MLE_STA_CTRL_LINK_ID_MASK; |
4477 | 0 | os_memcpy(ml_info[i].bssid, pos + 1, ETH_ALEN); |
4478 | |
|
4479 | 0 | pos += sta_info_len; |
4480 | 0 | ml_len -= sta_info_len; |
4481 | |
|
4482 | 0 | wpa_printf(MSG_DEBUG, "MLD: sub_elem_len=%zu, sta_info_len=%zu", |
4483 | 0 | sub_elem_len, sta_info_len); |
4484 | |
|
4485 | 0 | sub_elem_len -= sta_info_len + 2; |
4486 | 0 | if (sub_elem_len < 4) { |
4487 | 0 | wpa_printf(MSG_DEBUG, "MLD: Per STA profile too short"); |
4488 | 0 | goto out; |
4489 | 0 | } |
4490 | | |
4491 | 0 | wpa_hexdump(MSG_MSGDUMP, "MLD: STA profile", pos, sub_elem_len); |
4492 | 0 | ml_info[i].status = WPA_GET_LE16(pos + 2); |
4493 | |
|
4494 | 0 | if (sub_elem_len > ml_len) |
4495 | 0 | goto out; |
4496 | 0 | pos += sub_elem_len; |
4497 | 0 | ml_len -= sub_elem_len; |
4498 | |
|
4499 | 0 | i++; |
4500 | 0 | } |
4501 | | |
4502 | 0 | wpabuf_free(mlbuf); |
4503 | 0 | return i; |
4504 | 0 | out: |
4505 | 0 | wpabuf_free(mlbuf); |
4506 | 0 | return 0; |
4507 | 0 | } |
4508 | | |
4509 | | |
4510 | | static int wpa_drv_get_mlo_info(struct wpa_supplicant *wpa_s) |
4511 | 0 | { |
4512 | 0 | struct driver_sta_mlo_info mlo; |
4513 | 0 | int i; |
4514 | |
|
4515 | 0 | os_memset(&mlo, 0, sizeof(mlo)); |
4516 | 0 | if (wpas_drv_get_sta_mlo_info(wpa_s, &mlo)) { |
4517 | 0 | wpa_dbg(wpa_s, MSG_ERROR, "Failed to get MLO link info"); |
4518 | 0 | wpa_supplicant_deauthenticate(wpa_s, |
4519 | 0 | WLAN_REASON_DEAUTH_LEAVING); |
4520 | 0 | return -1; |
4521 | 0 | } |
4522 | | |
4523 | 0 | if (wpa_s->valid_links == mlo.valid_links) { |
4524 | 0 | bool match = true; |
4525 | |
|
4526 | 0 | if (!mlo.valid_links) |
4527 | 0 | return 0; |
4528 | | |
4529 | 0 | for_each_link(mlo.valid_links, i) { |
4530 | 0 | if (!ether_addr_equal(wpa_s->links[i].addr, |
4531 | 0 | mlo.links[i].addr) || |
4532 | 0 | !ether_addr_equal(wpa_s->links[i].bssid, |
4533 | 0 | mlo.links[i].bssid)) { |
4534 | 0 | match = false; |
4535 | 0 | break; |
4536 | 0 | } |
4537 | 0 | } |
4538 | |
|
4539 | 0 | if (match && wpa_s->mlo_assoc_link_id == mlo.assoc_link_id && |
4540 | 0 | ether_addr_equal(wpa_s->ap_mld_addr, mlo.ap_mld_addr)) |
4541 | 0 | return 0; |
4542 | 0 | } |
4543 | | |
4544 | 0 | wpa_s->valid_links = mlo.valid_links; |
4545 | 0 | wpa_s->mlo_assoc_link_id = mlo.assoc_link_id; |
4546 | 0 | os_memcpy(wpa_s->ap_mld_addr, mlo.ap_mld_addr, ETH_ALEN); |
4547 | 0 | for_each_link(wpa_s->valid_links, i) { |
4548 | 0 | os_memcpy(wpa_s->links[i].addr, mlo.links[i].addr, ETH_ALEN); |
4549 | 0 | os_memcpy(wpa_s->links[i].bssid, mlo.links[i].bssid, ETH_ALEN); |
4550 | 0 | wpa_s->links[i].freq = mlo.links[i].freq; |
4551 | 0 | wpa_supplicant_update_link_bss(wpa_s, i, mlo.links[i].bssid); |
4552 | 0 | } |
4553 | |
|
4554 | 0 | return 0; |
4555 | 0 | } |
4556 | | |
4557 | | |
4558 | | static int wpa_sm_set_ml_info(struct wpa_supplicant *wpa_s) |
4559 | 0 | { |
4560 | 0 | struct driver_sta_mlo_info drv_mlo; |
4561 | 0 | struct wpa_sm_mlo wpa_mlo; |
4562 | 0 | int i; |
4563 | |
|
4564 | 0 | os_memset(&drv_mlo, 0, sizeof(drv_mlo)); |
4565 | 0 | if (wpas_drv_get_sta_mlo_info(wpa_s, &drv_mlo)) { |
4566 | 0 | wpa_dbg(wpa_s, MSG_INFO, "Failed to get MLO link info"); |
4567 | 0 | return -1; |
4568 | 0 | } |
4569 | | |
4570 | 0 | os_memset(&wpa_mlo, 0, sizeof(wpa_mlo)); |
4571 | 0 | if (!drv_mlo.valid_links) |
4572 | 0 | goto out; |
4573 | | |
4574 | 0 | os_memcpy(wpa_mlo.ap_mld_addr, drv_mlo.ap_mld_addr, ETH_ALEN); |
4575 | 0 | wpa_mlo.assoc_link_id = drv_mlo.assoc_link_id; |
4576 | 0 | wpa_mlo.valid_links = drv_mlo.valid_links; |
4577 | 0 | wpa_mlo.req_links = drv_mlo.req_links; |
4578 | |
|
4579 | 0 | for_each_link(drv_mlo.req_links, i) { |
4580 | 0 | struct wpa_bss *bss; |
4581 | 0 | const u8 *rsne, *rsnxe, *rsnoe, *rsno2e, *rsnxoe; |
4582 | |
|
4583 | 0 | bss = wpa_supplicant_get_new_bss(wpa_s, drv_mlo.links[i].bssid); |
4584 | 0 | if (!bss) { |
4585 | 0 | wpa_dbg(wpa_s, MSG_INFO, |
4586 | 0 | "Failed to get MLO link %d BSS", i); |
4587 | 0 | return -1; |
4588 | 0 | } |
4589 | | |
4590 | 0 | rsne = wpa_bss_get_ie(bss, WLAN_EID_RSN); |
4591 | 0 | rsnxe = wpa_bss_get_ie(bss, WLAN_EID_RSNX); |
4592 | 0 | rsnoe = wpa_bss_get_vendor_ie(bss, |
4593 | 0 | RSNE_OVERRIDE_IE_VENDOR_TYPE); |
4594 | 0 | rsno2e = wpa_bss_get_vendor_ie(bss, |
4595 | 0 | RSNE_OVERRIDE_2_IE_VENDOR_TYPE); |
4596 | 0 | rsnxoe = wpa_bss_get_vendor_ie(bss, |
4597 | 0 | RSNXE_OVERRIDE_IE_VENDOR_TYPE); |
4598 | |
|
4599 | 0 | wpa_mlo.links[i].ap_rsne = rsne ? (u8 *) rsne : NULL; |
4600 | 0 | wpa_mlo.links[i].ap_rsne_len = rsne ? 2 + rsne[1] : 0; |
4601 | 0 | wpa_mlo.links[i].ap_rsnxe = rsnxe ? (u8 *) rsnxe : NULL; |
4602 | 0 | wpa_mlo.links[i].ap_rsnxe_len = rsnxe ? 2 + rsnxe[1] : 0; |
4603 | 0 | wpa_mlo.links[i].ap_rsnoe = rsnoe ? (u8 *) rsnoe : NULL; |
4604 | 0 | wpa_mlo.links[i].ap_rsnoe_len = rsnoe ? 2 + rsnoe[1] : 0; |
4605 | 0 | wpa_mlo.links[i].ap_rsno2e = rsno2e ? (u8 *) rsno2e : NULL; |
4606 | 0 | wpa_mlo.links[i].ap_rsno2e_len = rsno2e ? 2 + rsno2e[1] : 0; |
4607 | 0 | wpa_mlo.links[i].ap_rsnxoe = rsnxoe ? (u8 *) rsnxoe : NULL; |
4608 | 0 | wpa_mlo.links[i].ap_rsnxoe_len = rsnxoe ? 2 + rsnxoe[1] : 0; |
4609 | |
|
4610 | 0 | os_memcpy(wpa_mlo.links[i].bssid, drv_mlo.links[i].bssid, |
4611 | 0 | ETH_ALEN); |
4612 | 0 | os_memcpy(wpa_mlo.links[i].addr, drv_mlo.links[i].addr, |
4613 | 0 | ETH_ALEN); |
4614 | 0 | } |
4615 | | |
4616 | 0 | out: |
4617 | 0 | return wpa_sm_set_mlo_params(wpa_s->wpa, &wpa_mlo); |
4618 | 0 | } |
4619 | | |
4620 | | |
4621 | | static void wpa_supplicant_event_assoc(struct wpa_supplicant *wpa_s, |
4622 | | union wpa_event_data *data) |
4623 | 0 | { |
4624 | 0 | u8 bssid[ETH_ALEN]; |
4625 | 0 | int ft_completed, already_authorized; |
4626 | 0 | int new_bss = 0; |
4627 | | #if defined(CONFIG_FILS) || defined(CONFIG_MBO) |
4628 | | struct wpa_bss *bss; |
4629 | | #endif /* CONFIG_FILS || CONFIG_MBO */ |
4630 | |
|
4631 | | #ifdef CONFIG_AP |
4632 | | if (wpa_s->ap_iface) { |
4633 | | if (!data) |
4634 | | return; |
4635 | | hostapd_notif_assoc(wpa_s->ap_iface->bss[0], |
4636 | | data->assoc_info.addr, |
4637 | | data->assoc_info.req_ies, |
4638 | | data->assoc_info.req_ies_len, NULL, 0, |
4639 | | NULL, data->assoc_info.reassoc); |
4640 | | return; |
4641 | | } |
4642 | | #endif /* CONFIG_AP */ |
4643 | |
|
4644 | 0 | eloop_cancel_timeout(wpas_network_reenabled, wpa_s, NULL); |
4645 | 0 | wpa_s->own_reconnect_req = 0; |
4646 | |
|
4647 | 0 | ft_completed = wpa_ft_is_completed(wpa_s->wpa); |
4648 | |
|
4649 | 0 | if (wpa_drv_get_bssid(wpa_s, bssid) < 0) { |
4650 | 0 | wpa_dbg(wpa_s, MSG_ERROR, "Failed to get BSSID"); |
4651 | 0 | wpa_supplicant_deauthenticate( |
4652 | 0 | wpa_s, WLAN_REASON_DEAUTH_LEAVING); |
4653 | 0 | return; |
4654 | 0 | } |
4655 | | |
4656 | 0 | if (wpa_drv_get_mlo_info(wpa_s) < 0) { |
4657 | 0 | wpa_dbg(wpa_s, MSG_ERROR, "Failed to get MLO connection info"); |
4658 | 0 | wpa_supplicant_deauthenticate(wpa_s, |
4659 | 0 | WLAN_REASON_DEAUTH_LEAVING); |
4660 | 0 | return; |
4661 | 0 | } |
4662 | | |
4663 | 0 | if (ft_completed && |
4664 | 0 | (wpa_s->drv_flags & WPA_DRIVER_FLAGS_BSS_SELECTION)) { |
4665 | 0 | wpa_msg(wpa_s, MSG_INFO, "Attempt to roam to " MACSTR, |
4666 | 0 | MAC2STR(bssid)); |
4667 | 0 | if (!wpa_supplicant_update_current_bss(wpa_s, bssid)) { |
4668 | 0 | wpa_printf(MSG_ERROR, |
4669 | 0 | "Can't find target AP's information!"); |
4670 | 0 | return; |
4671 | 0 | } |
4672 | 0 | wpa_supplicant_assoc_update_ie(wpa_s); |
4673 | 0 | } |
4674 | | |
4675 | 0 | if (data && wpa_supplicant_event_associnfo(wpa_s, data) < 0) |
4676 | 0 | return; |
4677 | | /* |
4678 | | * FILS authentication can share the same mechanism to mark the |
4679 | | * connection fully authenticated, so set ft_completed also based on |
4680 | | * FILS result. |
4681 | | */ |
4682 | 0 | if (!ft_completed) |
4683 | 0 | ft_completed = wpa_fils_is_completed(wpa_s->wpa); |
4684 | |
|
4685 | 0 | if (!ft_completed) |
4686 | 0 | ft_completed = wpa_eppke_is_completed(wpa_s->wpa); |
4687 | |
|
4688 | 0 | if (!ft_completed) |
4689 | 0 | ft_completed = wpa_eap_over_auth_frame_is_completed(wpa_s->wpa); |
4690 | |
|
4691 | 0 | wpa_supplicant_set_state(wpa_s, WPA_ASSOCIATED); |
4692 | 0 | if (!ether_addr_equal(bssid, wpa_s->bssid)) { |
4693 | 0 | if (os_reltime_initialized(&wpa_s->session_start)) { |
4694 | 0 | os_reltime_age(&wpa_s->session_start, |
4695 | 0 | &wpa_s->session_length); |
4696 | 0 | wpa_s->session_start.sec = 0; |
4697 | 0 | wpa_s->session_start.usec = 0; |
4698 | 0 | wpas_notify_session_length(wpa_s); |
4699 | 0 | } else { |
4700 | 0 | wpas_notify_auth_changed(wpa_s); |
4701 | 0 | os_get_reltime(&wpa_s->session_start); |
4702 | 0 | } |
4703 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "Associated to a new BSS: BSSID=" |
4704 | 0 | MACSTR, MAC2STR(bssid)); |
4705 | 0 | new_bss = 1; |
4706 | 0 | random_add_randomness(bssid, ETH_ALEN); |
4707 | 0 | os_memcpy(wpa_s->bssid, bssid, ETH_ALEN); |
4708 | 0 | os_memset(wpa_s->pending_bssid, 0, ETH_ALEN); |
4709 | 0 | wpas_notify_bssid_changed(wpa_s); |
4710 | |
|
4711 | 0 | if (wpa_supplicant_dynamic_keys(wpa_s) && !ft_completed) { |
4712 | 0 | wpa_clear_keys(wpa_s, bssid); |
4713 | 0 | } |
4714 | 0 | if (wpa_supplicant_select_config(wpa_s, data) < 0) { |
4715 | 0 | wpa_supplicant_deauthenticate( |
4716 | 0 | wpa_s, WLAN_REASON_DEAUTH_LEAVING); |
4717 | 0 | return; |
4718 | 0 | } |
4719 | 0 | } |
4720 | | |
4721 | 0 | if (!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME) && |
4722 | 0 | data && wpa_supplicant_use_own_rsne_params(wpa_s, data) < 0) |
4723 | 0 | return; |
4724 | | |
4725 | 0 | multi_ap_set_4addr_mode(wpa_s); |
4726 | |
|
4727 | 0 | if (wpa_s->conf->ap_scan == 1 && |
4728 | 0 | wpa_s->drv_flags & WPA_DRIVER_FLAGS_BSS_SELECTION) { |
4729 | 0 | if (wpa_supplicant_assoc_update_ie(wpa_s) < 0 && new_bss) |
4730 | 0 | wpa_msg(wpa_s, MSG_WARNING, |
4731 | 0 | "WPA/RSN IEs not updated"); |
4732 | 0 | } |
4733 | |
|
4734 | 0 | wpas_fst_update_mb_assoc(wpa_s, data); |
4735 | |
|
4736 | | #ifdef CONFIG_SME |
4737 | | /* |
4738 | | * Cache the current AP's BSSID (for non-MLO connection) or MLD address |
4739 | | * (for MLO connection) as the previous BSSID for subsequent |
4740 | | * reassociation requests handled by SME-in-wpa_supplicant. |
4741 | | */ |
4742 | | os_memcpy(wpa_s->sme.prev_bssid, |
4743 | | wpa_s->valid_links ? wpa_s->ap_mld_addr : bssid, ETH_ALEN); |
4744 | | wpa_s->sme.prev_bssid_set = 1; |
4745 | | wpa_s->sme.last_unprot_disconnect.sec = 0; |
4746 | | #endif /* CONFIG_SME */ |
4747 | |
|
4748 | 0 | wpa_msg(wpa_s, MSG_INFO, "Associated with " MACSTR, MAC2STR(bssid)); |
4749 | 0 | if (wpa_s->current_ssid) { |
4750 | | /* When using scanning (ap_scan=1), SIM PC/SC interface can be |
4751 | | * initialized before association, but for other modes, |
4752 | | * initialize PC/SC here, if the current configuration needs |
4753 | | * smartcard or SIM/USIM. */ |
4754 | 0 | wpa_supplicant_scard_init(wpa_s, wpa_s->current_ssid); |
4755 | 0 | } |
4756 | 0 | wpa_sm_notify_assoc(wpa_s->wpa, bssid); |
4757 | |
|
4758 | | #ifdef CONFIG_PMKSA_PRIVACY |
4759 | | if (wpa_s->pmkid_anonce_set && wpa_s->pmkid_snonce_set && |
4760 | | wpa_s->assoc_resp_encrypted && |
4761 | | wpa_sm_pmksa_privacy_supported(wpa_s->wpa) && |
4762 | | (wpa_s->drv_flags2 & |
4763 | | WPA_DRIVER_FLAGS2_ASSOCIATION_FRAME_ENCRYPTION)) { |
4764 | | struct rsn_pmksa_cache *t = wpa_sm_get_pmksa_cache(wpa_s->wpa); |
4765 | | const u8 *addr = wpa_s->valid_links ? |
4766 | | wpa_s->ap_mld_addr : wpa_s->bssid; |
4767 | | struct rsn_pmksa_cache_entry *e; |
4768 | | |
4769 | | e = pmksa_cache_get(t, addr, NULL, NULL, 0, wpa_s->key_mgmt); |
4770 | | if (e && (e->auth_alg == WLAN_AUTH_EPPKE || |
4771 | | e->auth_alg == WLAN_AUTH_802_1X)) { |
4772 | | rsn_pmkid_privacy(wpa_s->pmkid_anonce, |
4773 | | wpa_s->pmkid_snonce, |
4774 | | wpa_s->key_mgmt, e->pmk_len, |
4775 | | e->pmkid); |
4776 | | } else { |
4777 | | wpa_printf(MSG_DEBUG, |
4778 | | "PMKID privacy: PMKSA cache entry not found for " |
4779 | | MACSTR, MAC2STR(addr)); |
4780 | | } |
4781 | | wpa_s->pmkid_anonce_set = false; |
4782 | | wpa_s->pmkid_snonce_set = false; |
4783 | | } |
4784 | | #endif /* CONFIG_PMKSA_PRIVACY */ |
4785 | |
|
4786 | 0 | if (wpa_sm_set_ml_info(wpa_s)) { |
4787 | 0 | wpa_dbg(wpa_s, MSG_INFO, |
4788 | 0 | "Failed to set MLO connection info to wpa_sm"); |
4789 | 0 | wpa_supplicant_deauthenticate(wpa_s, |
4790 | 0 | WLAN_REASON_DEAUTH_LEAVING); |
4791 | 0 | return; |
4792 | 0 | } |
4793 | | |
4794 | 0 | if (wpa_s->l2) |
4795 | 0 | l2_packet_notify_auth_start(wpa_s->l2); |
4796 | |
|
4797 | 0 | already_authorized = data && data->assoc_info.authorized; |
4798 | | |
4799 | | /* |
4800 | | * Set portEnabled first to false in order to get EAP state machine out |
4801 | | * of the SUCCESS state and eapSuccess cleared. Without this, EAPOL PAE |
4802 | | * state machine may transit to AUTHENTICATING state based on obsolete |
4803 | | * eapSuccess and then trigger BE_AUTH to SUCCESS and PAE to |
4804 | | * AUTHENTICATED without ever giving chance to EAP state machine to |
4805 | | * reset the state. |
4806 | | */ |
4807 | 0 | if (!ft_completed && !already_authorized) { |
4808 | 0 | eapol_sm_notify_portEnabled(wpa_s->eapol, false); |
4809 | 0 | eapol_sm_notify_portValid(wpa_s->eapol, false); |
4810 | 0 | } |
4811 | 0 | if (wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt) || |
4812 | 0 | wpa_s->key_mgmt == WPA_KEY_MGMT_DPP || |
4813 | 0 | wpa_s->key_mgmt == WPA_KEY_MGMT_OWE || ft_completed || |
4814 | 0 | already_authorized || wpa_s->drv_authorized_port) |
4815 | 0 | eapol_sm_notify_eap_success(wpa_s->eapol, false); |
4816 | | /* 802.1X::portControl = Auto */ |
4817 | 0 | eapol_sm_notify_portEnabled(wpa_s->eapol, true); |
4818 | 0 | wpa_s->eapol_received = 0; |
4819 | 0 | if (wpa_s->key_mgmt == WPA_KEY_MGMT_NONE || |
4820 | 0 | wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE || |
4821 | 0 | (wpa_s->current_ssid && |
4822 | 0 | wpa_s->current_ssid->mode == WPAS_MODE_IBSS)) { |
4823 | 0 | if (wpa_s->current_ssid && |
4824 | 0 | wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE && |
4825 | 0 | (wpa_s->drv_flags & |
4826 | 0 | WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC_DONE)) { |
4827 | | /* |
4828 | | * Set the key after having received joined-IBSS event |
4829 | | * from the driver. |
4830 | | */ |
4831 | 0 | wpa_supplicant_set_wpa_none_key(wpa_s, |
4832 | 0 | wpa_s->current_ssid); |
4833 | 0 | } |
4834 | 0 | wpa_supplicant_cancel_auth_timeout(wpa_s); |
4835 | 0 | wpa_supplicant_set_state(wpa_s, WPA_COMPLETED); |
4836 | 0 | } else if (!ft_completed) { |
4837 | | /* Timeout for receiving the first EAPOL packet */ |
4838 | 0 | wpa_supplicant_req_auth_timeout(wpa_s, 10, 0); |
4839 | 0 | } |
4840 | 0 | wpa_supplicant_cancel_scan(wpa_s); |
4841 | |
|
4842 | 0 | if (ft_completed) { |
4843 | | /* |
4844 | | * FT protocol completed - make sure EAPOL state machine ends |
4845 | | * up in authenticated. |
4846 | | */ |
4847 | 0 | wpa_supplicant_cancel_auth_timeout(wpa_s); |
4848 | 0 | wpa_supplicant_set_state(wpa_s, WPA_COMPLETED); |
4849 | 0 | eapol_sm_notify_portValid(wpa_s->eapol, true); |
4850 | 0 | eapol_sm_notify_eap_success(wpa_s->eapol, true); |
4851 | 0 | } else if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE_PSK) && |
4852 | 0 | wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt)) { |
4853 | 0 | if (already_authorized) { |
4854 | | /* |
4855 | | * We are done; the driver will take care of RSN 4-way |
4856 | | * handshake. |
4857 | | */ |
4858 | 0 | wpa_supplicant_cancel_auth_timeout(wpa_s); |
4859 | 0 | wpa_supplicant_set_state(wpa_s, WPA_COMPLETED); |
4860 | 0 | eapol_sm_notify_portValid(wpa_s->eapol, true); |
4861 | 0 | eapol_sm_notify_eap_success(wpa_s->eapol, true); |
4862 | 0 | } else { |
4863 | | /* Update port, WPA_COMPLETED state from the |
4864 | | * EVENT_PORT_AUTHORIZED handler when the driver is done |
4865 | | * with the 4-way handshake. |
4866 | | */ |
4867 | 0 | wpa_msg(wpa_s, MSG_DEBUG, |
4868 | 0 | "ASSOC INFO: wait for driver port authorized indication"); |
4869 | 0 | } |
4870 | 0 | } else if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE_8021X) && |
4871 | 0 | wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt)) { |
4872 | | /* |
4873 | | * The driver will take care of RSN 4-way handshake, so we need |
4874 | | * to allow EAPOL supplicant to complete its work without |
4875 | | * waiting for WPA supplicant. |
4876 | | */ |
4877 | 0 | eapol_sm_notify_portValid(wpa_s->eapol, true); |
4878 | 0 | } |
4879 | |
|
4880 | 0 | wpa_s->last_eapol_matches_bssid = 0; |
4881 | 0 | wpa_s->ext_auth_to_same_bss = false; |
4882 | |
|
4883 | | #ifdef CONFIG_TESTING_OPTIONS |
4884 | | if (wpa_s->rsne_override_eapol) { |
4885 | | wpa_printf(MSG_DEBUG, |
4886 | | "TESTING: RSNE EAPOL-Key msg 2/4 override"); |
4887 | | wpa_sm_set_assoc_wpa_ie(wpa_s->wpa, |
4888 | | wpabuf_head(wpa_s->rsne_override_eapol), |
4889 | | wpabuf_len(wpa_s->rsne_override_eapol)); |
4890 | | } |
4891 | | if (wpa_s->rsnxe_override_eapol) { |
4892 | | wpa_printf(MSG_DEBUG, |
4893 | | "TESTING: RSNXE EAPOL-Key msg 2/4 override"); |
4894 | | wpa_sm_set_assoc_rsnxe(wpa_s->wpa, |
4895 | | wpabuf_head(wpa_s->rsnxe_override_eapol), |
4896 | | wpabuf_len(wpa_s->rsnxe_override_eapol)); |
4897 | | } |
4898 | | #endif /* CONFIG_TESTING_OPTIONS */ |
4899 | |
|
4900 | 0 | if (wpa_s->pending_eapol_rx) { |
4901 | 0 | struct os_reltime now, age; |
4902 | 0 | os_get_reltime(&now); |
4903 | 0 | os_reltime_sub(&now, &wpa_s->pending_eapol_rx_time, &age); |
4904 | 0 | if (age.sec == 0 && age.usec < 200000 && |
4905 | 0 | ether_addr_equal(wpa_s->pending_eapol_rx_src, |
4906 | 0 | wpa_s->valid_links ? wpa_s->ap_mld_addr : |
4907 | 0 | bssid)) { |
4908 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "Process pending EAPOL " |
4909 | 0 | "frame that was received just before " |
4910 | 0 | "association notification"); |
4911 | 0 | wpa_supplicant_rx_eapol( |
4912 | 0 | wpa_s, wpa_s->pending_eapol_rx_src, |
4913 | 0 | wpabuf_head(wpa_s->pending_eapol_rx), |
4914 | 0 | wpabuf_len(wpa_s->pending_eapol_rx), |
4915 | 0 | wpa_s->pending_eapol_encrypted); |
4916 | 0 | } |
4917 | 0 | wpabuf_free(wpa_s->pending_eapol_rx); |
4918 | 0 | wpa_s->pending_eapol_rx = NULL; |
4919 | 0 | } |
4920 | |
|
4921 | | #ifdef CONFIG_WEP |
4922 | | if ((wpa_s->key_mgmt == WPA_KEY_MGMT_NONE || |
4923 | | wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA) && |
4924 | | wpa_s->current_ssid && |
4925 | | (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC_DONE)) { |
4926 | | /* Set static WEP keys again */ |
4927 | | wpa_set_wep_keys(wpa_s, wpa_s->current_ssid); |
4928 | | } |
4929 | | #endif /* CONFIG_WEP */ |
4930 | |
|
4931 | | #ifdef CONFIG_IBSS_RSN |
4932 | | if (wpa_s->current_ssid && |
4933 | | wpa_s->current_ssid->mode == WPAS_MODE_IBSS && |
4934 | | wpa_s->key_mgmt != WPA_KEY_MGMT_NONE && |
4935 | | wpa_s->key_mgmt != WPA_KEY_MGMT_WPA_NONE && |
4936 | | wpa_s->ibss_rsn == NULL) { |
4937 | | wpa_s->ibss_rsn = ibss_rsn_init(wpa_s, wpa_s->current_ssid); |
4938 | | if (!wpa_s->ibss_rsn) { |
4939 | | wpa_msg(wpa_s, MSG_INFO, "Failed to init IBSS RSN"); |
4940 | | wpa_supplicant_deauthenticate( |
4941 | | wpa_s, WLAN_REASON_DEAUTH_LEAVING); |
4942 | | return; |
4943 | | } |
4944 | | |
4945 | | ibss_rsn_set_psk(wpa_s->ibss_rsn, wpa_s->current_ssid->psk); |
4946 | | } |
4947 | | #endif /* CONFIG_IBSS_RSN */ |
4948 | |
|
4949 | 0 | wpas_wps_notify_assoc(wpa_s, bssid); |
4950 | |
|
4951 | 0 | #ifndef CONFIG_NO_WMM_AC |
4952 | 0 | if (data) { |
4953 | 0 | wmm_ac_notify_assoc(wpa_s, data->assoc_info.resp_ies, |
4954 | 0 | data->assoc_info.resp_ies_len, |
4955 | 0 | &data->assoc_info.wmm_params); |
4956 | |
|
4957 | 0 | if (wpa_s->reassoc_same_bss) |
4958 | 0 | wmm_ac_restore_tspecs(wpa_s); |
4959 | 0 | } |
4960 | 0 | #endif /* CONFIG_NO_WMM_AC */ |
4961 | |
|
4962 | | #if defined(CONFIG_FILS) || defined(CONFIG_MBO) |
4963 | | bss = wpa_bss_get_bssid(wpa_s, bssid); |
4964 | | #endif /* CONFIG_FILS || CONFIG_MBO */ |
4965 | | #ifdef CONFIG_FILS |
4966 | | if (wpa_key_mgmt_fils(wpa_s->key_mgmt)) { |
4967 | | const u8 *fils_cache_id = wpa_bss_get_fils_cache_id(bss); |
4968 | | |
4969 | | if (fils_cache_id) |
4970 | | wpa_sm_set_fils_cache_id(wpa_s->wpa, fils_cache_id); |
4971 | | } |
4972 | | #endif /* CONFIG_FILS */ |
4973 | |
|
4974 | | #ifdef CONFIG_MBO |
4975 | | wpas_mbo_check_pmf(wpa_s, bss, wpa_s->current_ssid); |
4976 | | #endif /* CONFIG_MBO */ |
4977 | |
|
4978 | | #ifdef CONFIG_DPP2 |
4979 | | wpa_s->dpp_pfs_fallback = 0; |
4980 | | #endif /* CONFIG_DPP2 */ |
4981 | |
|
4982 | 0 | if (wpa_s->current_ssid && wpa_s->current_ssid->enable_4addr_mode) |
4983 | 0 | wpa_supplicant_set_4addr_mode(wpa_s); |
4984 | 0 | } |
4985 | | |
4986 | | |
4987 | | static int disconnect_reason_recoverable(u16 reason_code) |
4988 | 0 | { |
4989 | 0 | return reason_code == WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY || |
4990 | 0 | reason_code == WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA || |
4991 | 0 | reason_code == WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA; |
4992 | 0 | } |
4993 | | |
4994 | | |
4995 | | static void wpa_supplicant_event_disassoc(struct wpa_supplicant *wpa_s, |
4996 | | u16 reason_code, |
4997 | | int locally_generated) |
4998 | 0 | { |
4999 | 0 | const u8 *bssid; |
5000 | |
|
5001 | 0 | bssid = wpa_s->bssid; |
5002 | 0 | if (is_zero_ether_addr(bssid)) |
5003 | 0 | bssid = wpa_s->pending_bssid; |
5004 | |
|
5005 | 0 | if (!is_zero_ether_addr(bssid) || |
5006 | 0 | wpa_s->wpa_state >= WPA_AUTHENTICATING) { |
5007 | 0 | wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_DISCONNECTED "bssid=" MACSTR |
5008 | 0 | " reason=%d%s", |
5009 | 0 | MAC2STR(bssid), reason_code, |
5010 | 0 | locally_generated ? " locally_generated=1" : ""); |
5011 | 0 | } |
5012 | 0 | } |
5013 | | |
5014 | | |
5015 | | static int could_be_psk_mismatch(struct wpa_supplicant *wpa_s, u16 reason_code, |
5016 | | int locally_generated) |
5017 | 0 | { |
5018 | 0 | if (wpa_s->wpa_state != WPA_4WAY_HANDSHAKE || |
5019 | 0 | !wpa_s->new_connection || |
5020 | 0 | !wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt) || |
5021 | 0 | wpa_key_mgmt_sae(wpa_s->key_mgmt)) |
5022 | 0 | return 0; /* Not in initial 4-way handshake with PSK */ |
5023 | | |
5024 | | /* |
5025 | | * It looks like connection was lost while trying to go through PSK |
5026 | | * 4-way handshake. Filter out known disconnection cases that are caused |
5027 | | * by something else than PSK mismatch to avoid confusing reports. |
5028 | | */ |
5029 | | |
5030 | 0 | if (locally_generated) { |
5031 | 0 | if (reason_code == WLAN_REASON_IE_IN_4WAY_DIFFERS) |
5032 | 0 | return 0; |
5033 | 0 | if (reason_code == WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY) |
5034 | 0 | return 0; |
5035 | 0 | } |
5036 | | |
5037 | 0 | return 1; |
5038 | 0 | } |
5039 | | |
5040 | | |
5041 | | static void wpa_supplicant_event_disassoc_finish(struct wpa_supplicant *wpa_s, |
5042 | | u16 reason_code, |
5043 | | int locally_generated) |
5044 | 0 | { |
5045 | 0 | const u8 *bssid; |
5046 | 0 | struct wpa_bss *fast_reconnect = NULL; |
5047 | 0 | struct wpa_ssid *fast_reconnect_ssid = NULL; |
5048 | 0 | struct wpa_bss *curr = NULL; |
5049 | |
|
5050 | 0 | if (!wpa_s->disconnected && wpa_s->wpa_state >= WPA_AUTHENTICATING && |
5051 | 0 | reason_code == WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY && |
5052 | 0 | locally_generated) |
5053 | | /* |
5054 | | * Remove the inactive AP (which is probably out of range) from |
5055 | | * the BSS list after marking disassociation. In particular |
5056 | | * mac80211-based drivers use the |
5057 | | * WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY reason code in |
5058 | | * locally generated disconnection events for cases where the |
5059 | | * AP does not reply anymore. |
5060 | | */ |
5061 | 0 | curr = wpa_s->current_bss; |
5062 | |
|
5063 | 0 | if (could_be_psk_mismatch(wpa_s, reason_code, locally_generated)) { |
5064 | 0 | wpa_msg(wpa_s, MSG_INFO, "WPA: 4-Way Handshake failed - " |
5065 | 0 | "pre-shared key may be incorrect"); |
5066 | 0 | if (wpas_p2p_4way_hs_failed(wpa_s) > 0) |
5067 | 0 | return; /* P2P group removed */ |
5068 | 0 | bssid = wpa_s->bssid; |
5069 | 0 | if (is_zero_ether_addr(bssid)) |
5070 | 0 | bssid = wpa_s->pending_bssid; |
5071 | 0 | wpa_bssid_ignore_add(wpa_s, bssid); |
5072 | 0 | wpas_auth_failed(wpa_s, "WRONG_KEY", wpa_s->pending_bssid); |
5073 | 0 | wpas_notify_psk_mismatch(wpa_s); |
5074 | 0 | } |
5075 | 0 | if (!wpa_s->disconnected && |
5076 | 0 | (!wpa_s->auto_reconnect_disabled || |
5077 | 0 | wpa_s->key_mgmt == WPA_KEY_MGMT_WPS || |
5078 | 0 | wpas_wps_searching(wpa_s) || |
5079 | 0 | wpas_wps_reenable_networks_pending(wpa_s))) { |
5080 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "Auto connect enabled: try to " |
5081 | 0 | "reconnect (wps=%d/%d wpa_state=%d)", |
5082 | 0 | wpa_s->key_mgmt == WPA_KEY_MGMT_WPS, |
5083 | 0 | wpas_wps_searching(wpa_s), |
5084 | 0 | wpa_s->wpa_state); |
5085 | 0 | if (wpa_s->wpa_state == WPA_COMPLETED && |
5086 | 0 | wpa_s->current_ssid && |
5087 | 0 | wpa_s->current_ssid->mode == WPAS_MODE_INFRA && |
5088 | 0 | (wpa_s->own_reconnect_req || |
5089 | 0 | (!locally_generated && |
5090 | 0 | disconnect_reason_recoverable(reason_code)))) { |
5091 | | /* |
5092 | | * It looks like the AP has dropped association with |
5093 | | * us, but could allow us to get back in. This is also |
5094 | | * triggered for cases where local reconnection request |
5095 | | * is used to force reassociation with the same BSS. |
5096 | | * Try to reconnect to the same BSS without a full scan |
5097 | | * to save time for some common cases. |
5098 | | */ |
5099 | 0 | fast_reconnect = wpa_s->current_bss; |
5100 | 0 | fast_reconnect_ssid = wpa_s->current_ssid; |
5101 | 0 | } else if (wpa_s->wpa_state >= WPA_ASSOCIATING) { |
5102 | 0 | wpa_supplicant_req_scan(wpa_s, 0, 100000); |
5103 | 0 | } else { |
5104 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "Do not request new " |
5105 | 0 | "immediate scan"); |
5106 | 0 | } |
5107 | 0 | } else { |
5108 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "Auto connect disabled: do not " |
5109 | 0 | "try to re-connect"); |
5110 | 0 | wpa_s->reassociate = 0; |
5111 | 0 | wpa_s->disconnected = 1; |
5112 | 0 | if (!wpa_s->pno) |
5113 | 0 | wpa_supplicant_cancel_sched_scan(wpa_s); |
5114 | 0 | } |
5115 | 0 | bssid = wpa_s->bssid; |
5116 | 0 | if (is_zero_ether_addr(bssid)) |
5117 | 0 | bssid = wpa_s->pending_bssid; |
5118 | 0 | if (wpa_s->wpa_state >= WPA_AUTHENTICATING) |
5119 | 0 | wpas_connection_failed(wpa_s, bssid, NULL); |
5120 | 0 | wpa_sm_notify_disassoc(wpa_s->wpa); |
5121 | 0 | ptksa_cache_flush(wpa_s->ptksa, wpa_s->bssid, WPA_CIPHER_NONE); |
5122 | |
|
5123 | 0 | wpas_update_dfs_ap_info(wpa_s, 0, 0, true); |
5124 | |
|
5125 | 0 | if (locally_generated) |
5126 | 0 | wpa_s->disconnect_reason = -reason_code; |
5127 | 0 | else |
5128 | 0 | wpa_s->disconnect_reason = reason_code; |
5129 | 0 | wpas_notify_disconnect_reason(wpa_s); |
5130 | | #ifdef CONFIG_DPP2 |
5131 | | wpas_dpp_send_conn_status_result(wpa_s, DPP_STATUS_AUTH_FAILURE); |
5132 | | #endif /* CONFIG_DPP2 */ |
5133 | 0 | if (wpa_supplicant_dynamic_keys(wpa_s)) { |
5134 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "Disconnect event - remove keys"); |
5135 | 0 | wpa_clear_keys(wpa_s, wpa_s->bssid); |
5136 | 0 | } |
5137 | 0 | wpa_supplicant_mark_disassoc(wpa_s); |
5138 | |
|
5139 | 0 | if (curr) |
5140 | 0 | wpa_bss_remove(wpa_s, curr, "Connection to AP lost"); |
5141 | |
|
5142 | 0 | if (fast_reconnect && |
5143 | 0 | !wpas_network_disabled(wpa_s, fast_reconnect_ssid) && |
5144 | 0 | !disallowed_bssid(wpa_s, fast_reconnect->bssid) && |
5145 | 0 | !disallowed_ssid(wpa_s, fast_reconnect->ssid, |
5146 | 0 | fast_reconnect->ssid_len) && |
5147 | 0 | !wpas_temp_disabled(wpa_s, fast_reconnect_ssid) && |
5148 | 0 | !wpa_is_bss_tmp_disallowed(wpa_s, fast_reconnect)) { |
5149 | 0 | #ifndef CONFIG_NO_SCAN_PROCESSING |
5150 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "Try to reconnect to the same BSS"); |
5151 | 0 | if (wpa_supplicant_connect(wpa_s, fast_reconnect, |
5152 | 0 | fast_reconnect_ssid) < 0) { |
5153 | | /* Recover through full scan */ |
5154 | 0 | wpa_supplicant_req_scan(wpa_s, 0, 100000); |
5155 | 0 | } |
5156 | 0 | #endif /* CONFIG_NO_SCAN_PROCESSING */ |
5157 | 0 | } else if (fast_reconnect) { |
5158 | | /* |
5159 | | * Could not reconnect to the same BSS due to network being |
5160 | | * disabled. Use a new scan to match the alternative behavior |
5161 | | * above, i.e., to continue automatic reconnection attempt in a |
5162 | | * way that enforces disabled network rules. |
5163 | | */ |
5164 | 0 | wpa_supplicant_req_scan(wpa_s, 0, 100000); |
5165 | 0 | } |
5166 | 0 | } |
5167 | | |
5168 | | |
5169 | | #ifdef CONFIG_DELAYED_MIC_ERROR_REPORT |
5170 | | void wpa_supplicant_delayed_mic_error_report(void *eloop_ctx, void *sock_ctx) |
5171 | | { |
5172 | | struct wpa_supplicant *wpa_s = eloop_ctx; |
5173 | | |
5174 | | if (!wpa_s->pending_mic_error_report) |
5175 | | return; |
5176 | | |
5177 | | wpa_dbg(wpa_s, MSG_DEBUG, "WPA: Sending pending MIC error report"); |
5178 | | wpa_sm_key_request(wpa_s->wpa, 1, wpa_s->pending_mic_error_pairwise); |
5179 | | wpa_s->pending_mic_error_report = 0; |
5180 | | } |
5181 | | #endif /* CONFIG_DELAYED_MIC_ERROR_REPORT */ |
5182 | | |
5183 | | |
5184 | | static void |
5185 | | wpa_supplicant_event_michael_mic_failure(struct wpa_supplicant *wpa_s, |
5186 | | union wpa_event_data *data) |
5187 | 0 | { |
5188 | 0 | int pairwise; |
5189 | 0 | struct os_reltime t; |
5190 | |
|
5191 | 0 | wpa_msg(wpa_s, MSG_WARNING, "Michael MIC failure detected"); |
5192 | 0 | pairwise = (data && data->michael_mic_failure.unicast); |
5193 | 0 | os_get_reltime(&t); |
5194 | 0 | if ((os_reltime_initialized(&wpa_s->last_michael_mic_error) && |
5195 | 0 | !os_reltime_expired(&t, &wpa_s->last_michael_mic_error, 60)) || |
5196 | 0 | wpa_s->pending_mic_error_report) { |
5197 | 0 | if (wpa_s->pending_mic_error_report) { |
5198 | | /* |
5199 | | * Send the pending MIC error report immediately since |
5200 | | * we are going to start countermeasures and AP better |
5201 | | * do the same. |
5202 | | */ |
5203 | 0 | wpa_sm_key_request(wpa_s->wpa, 1, |
5204 | 0 | wpa_s->pending_mic_error_pairwise); |
5205 | 0 | } |
5206 | | |
5207 | | /* Send the new MIC error report immediately since we are going |
5208 | | * to start countermeasures and AP better do the same. |
5209 | | */ |
5210 | 0 | wpa_sm_key_request(wpa_s->wpa, 1, pairwise); |
5211 | | |
5212 | | /* initialize countermeasures */ |
5213 | 0 | wpa_s->countermeasures = 1; |
5214 | |
|
5215 | 0 | wpa_bssid_ignore_add(wpa_s, wpa_s->bssid); |
5216 | |
|
5217 | 0 | wpa_msg(wpa_s, MSG_WARNING, "TKIP countermeasures started"); |
5218 | | |
5219 | | /* |
5220 | | * Need to wait for completion of request frame. We do not get |
5221 | | * any callback for the message completion, so just wait a |
5222 | | * short while and hope for the best. */ |
5223 | 0 | os_sleep(0, 10000); |
5224 | |
|
5225 | 0 | wpa_drv_set_countermeasures(wpa_s, 1); |
5226 | 0 | wpa_supplicant_deauthenticate(wpa_s, |
5227 | 0 | WLAN_REASON_MICHAEL_MIC_FAILURE); |
5228 | 0 | eloop_cancel_timeout(wpa_supplicant_stop_countermeasures, |
5229 | 0 | wpa_s, NULL); |
5230 | 0 | eloop_register_timeout(60, 0, |
5231 | 0 | wpa_supplicant_stop_countermeasures, |
5232 | 0 | wpa_s, NULL); |
5233 | | /* TODO: mark the AP rejected for 60 second. STA is |
5234 | | * allowed to associate with another AP.. */ |
5235 | 0 | } else { |
5236 | | #ifdef CONFIG_DELAYED_MIC_ERROR_REPORT |
5237 | | if (wpa_s->mic_errors_seen) { |
5238 | | /* |
5239 | | * Reduce the effectiveness of Michael MIC error |
5240 | | * reports as a means for attacking against TKIP if |
5241 | | * more than one MIC failure is noticed with the same |
5242 | | * PTK. We delay the transmission of the reports by a |
5243 | | * random time between 0 and 60 seconds in order to |
5244 | | * force the attacker wait 60 seconds before getting |
5245 | | * the information on whether a frame resulted in a MIC |
5246 | | * failure. |
5247 | | */ |
5248 | | u8 rval[4]; |
5249 | | int sec; |
5250 | | |
5251 | | if (os_get_random(rval, sizeof(rval)) < 0) |
5252 | | sec = os_random() % 60; |
5253 | | else |
5254 | | sec = WPA_GET_BE32(rval) % 60; |
5255 | | wpa_dbg(wpa_s, MSG_DEBUG, "WPA: Delay MIC error " |
5256 | | "report %d seconds", sec); |
5257 | | wpa_s->pending_mic_error_report = 1; |
5258 | | wpa_s->pending_mic_error_pairwise = pairwise; |
5259 | | eloop_cancel_timeout( |
5260 | | wpa_supplicant_delayed_mic_error_report, |
5261 | | wpa_s, NULL); |
5262 | | eloop_register_timeout( |
5263 | | sec, os_random() % 1000000, |
5264 | | wpa_supplicant_delayed_mic_error_report, |
5265 | | wpa_s, NULL); |
5266 | | } else { |
5267 | | wpa_sm_key_request(wpa_s->wpa, 1, pairwise); |
5268 | | } |
5269 | | #else /* CONFIG_DELAYED_MIC_ERROR_REPORT */ |
5270 | 0 | wpa_sm_key_request(wpa_s->wpa, 1, pairwise); |
5271 | 0 | #endif /* CONFIG_DELAYED_MIC_ERROR_REPORT */ |
5272 | 0 | } |
5273 | 0 | wpa_s->last_michael_mic_error = t; |
5274 | 0 | wpa_s->mic_errors_seen++; |
5275 | 0 | } |
5276 | | |
5277 | | |
5278 | | #ifdef CONFIG_TERMINATE_ONLASTIF |
5279 | | static int any_interfaces(struct wpa_supplicant *head) |
5280 | | { |
5281 | | struct wpa_supplicant *wpa_s; |
5282 | | |
5283 | | for (wpa_s = head; wpa_s != NULL; wpa_s = wpa_s->next) |
5284 | | if (!wpa_s->interface_removed) |
5285 | | return 1; |
5286 | | return 0; |
5287 | | } |
5288 | | #endif /* CONFIG_TERMINATE_ONLASTIF */ |
5289 | | |
5290 | | |
5291 | | static void |
5292 | | wpa_supplicant_event_interface_status(struct wpa_supplicant *wpa_s, |
5293 | | union wpa_event_data *data) |
5294 | 0 | { |
5295 | 0 | if (os_strcmp(wpa_s->ifname, data->interface_status.ifname) != 0) |
5296 | 0 | return; |
5297 | | |
5298 | 0 | switch (data->interface_status.ievent) { |
5299 | 0 | case EVENT_INTERFACE_ADDED: |
5300 | 0 | if (!wpa_s->interface_removed) |
5301 | 0 | break; |
5302 | 0 | wpa_s->interface_removed = 0; |
5303 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "Configured interface was added"); |
5304 | 0 | if (wpa_supplicant_driver_init(wpa_s) < 0) { |
5305 | 0 | wpa_msg(wpa_s, MSG_INFO, "Failed to initialize the " |
5306 | 0 | "driver after interface was added"); |
5307 | 0 | } |
5308 | |
|
5309 | | #ifdef CONFIG_P2P |
5310 | | if (!wpa_s->global->p2p && |
5311 | | !wpa_s->global->p2p_disabled && |
5312 | | !wpa_s->conf->p2p_disabled && |
5313 | | (wpa_s->drv_flags & |
5314 | | WPA_DRIVER_FLAGS_DEDICATED_P2P_DEVICE) && |
5315 | | wpas_p2p_add_p2pdev_interface( |
5316 | | wpa_s, wpa_s->global->params.conf_p2p_dev) < 0) { |
5317 | | wpa_printf(MSG_INFO, |
5318 | | "P2P: Failed to enable P2P Device interface"); |
5319 | | /* Try to continue without. P2P will be disabled. */ |
5320 | | } |
5321 | | #endif /* CONFIG_P2P */ |
5322 | |
|
5323 | 0 | break; |
5324 | 0 | case EVENT_INTERFACE_REMOVED: |
5325 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "Configured interface was removed"); |
5326 | 0 | wpa_s->interface_removed = 1; |
5327 | 0 | wpa_supplicant_mark_disassoc(wpa_s); |
5328 | 0 | wpa_supplicant_set_state(wpa_s, WPA_INTERFACE_DISABLED); |
5329 | 0 | l2_packet_deinit(wpa_s->l2); |
5330 | 0 | wpa_s->l2 = NULL; |
5331 | |
|
5332 | | #ifdef CONFIG_P2P |
5333 | | if (wpa_s->global->p2p && |
5334 | | wpa_s->global->p2p_init_wpa_s->parent == wpa_s && |
5335 | | (wpa_s->drv_flags & |
5336 | | WPA_DRIVER_FLAGS_DEDICATED_P2P_DEVICE)) { |
5337 | | wpa_dbg(wpa_s, MSG_DEBUG, |
5338 | | "Removing P2P Device interface"); |
5339 | | wpa_supplicant_remove_iface( |
5340 | | wpa_s->global, wpa_s->global->p2p_init_wpa_s, |
5341 | | 0); |
5342 | | wpa_s->global->p2p_init_wpa_s = NULL; |
5343 | | } |
5344 | | #endif /* CONFIG_P2P */ |
5345 | |
|
5346 | | #ifdef CONFIG_MATCH_IFACE |
5347 | | if (wpa_s->matched) { |
5348 | | wpa_supplicant_remove_iface(wpa_s->global, wpa_s, 0); |
5349 | | break; |
5350 | | } |
5351 | | #endif /* CONFIG_MATCH_IFACE */ |
5352 | |
|
5353 | | #ifdef CONFIG_TERMINATE_ONLASTIF |
5354 | | /* check if last interface */ |
5355 | | if (!any_interfaces(wpa_s->global->ifaces)) |
5356 | | eloop_terminate(); |
5357 | | #endif /* CONFIG_TERMINATE_ONLASTIF */ |
5358 | 0 | break; |
5359 | 0 | } |
5360 | 0 | } |
5361 | | |
5362 | | |
5363 | | #ifdef CONFIG_TDLS |
5364 | | static void wpa_supplicant_event_tdls(struct wpa_supplicant *wpa_s, |
5365 | | union wpa_event_data *data) |
5366 | | { |
5367 | | if (data == NULL) |
5368 | | return; |
5369 | | switch (data->tdls.oper) { |
5370 | | case TDLS_REQUEST_SETUP: |
5371 | | wpa_tdls_remove(wpa_s->wpa, data->tdls.peer); |
5372 | | if (wpa_tdls_is_external_setup(wpa_s->wpa)) |
5373 | | wpa_tdls_start(wpa_s->wpa, data->tdls.peer); |
5374 | | else |
5375 | | wpa_drv_tdls_oper(wpa_s, TDLS_SETUP, data->tdls.peer); |
5376 | | break; |
5377 | | case TDLS_REQUEST_TEARDOWN: |
5378 | | if (wpa_tdls_is_external_setup(wpa_s->wpa)) |
5379 | | wpa_tdls_teardown_link(wpa_s->wpa, data->tdls.peer, |
5380 | | data->tdls.reason_code); |
5381 | | else |
5382 | | wpa_drv_tdls_oper(wpa_s, TDLS_TEARDOWN, |
5383 | | data->tdls.peer); |
5384 | | break; |
5385 | | case TDLS_REQUEST_DISCOVER: |
5386 | | wpa_tdls_send_discovery_request(wpa_s->wpa, |
5387 | | data->tdls.peer); |
5388 | | break; |
5389 | | } |
5390 | | } |
5391 | | #endif /* CONFIG_TDLS */ |
5392 | | |
5393 | | |
5394 | | #ifdef CONFIG_WNM |
5395 | | static void wpa_supplicant_event_wnm(struct wpa_supplicant *wpa_s, |
5396 | | union wpa_event_data *data) |
5397 | 0 | { |
5398 | 0 | if (data == NULL) |
5399 | 0 | return; |
5400 | 0 | switch (data->wnm.oper) { |
5401 | 0 | case WNM_OPER_SLEEP: |
5402 | 0 | wpa_printf(MSG_DEBUG, "Start sending WNM-Sleep Request " |
5403 | 0 | "(action=%d, intval=%d)", |
5404 | 0 | data->wnm.sleep_action, data->wnm.sleep_intval); |
5405 | 0 | ieee802_11_send_wnmsleep_req(wpa_s, data->wnm.sleep_action, |
5406 | 0 | data->wnm.sleep_intval, NULL); |
5407 | 0 | break; |
5408 | 0 | } |
5409 | 0 | } |
5410 | | #endif /* CONFIG_WNM */ |
5411 | | |
5412 | | |
5413 | | #ifdef CONFIG_IEEE80211R |
5414 | | static void |
5415 | | wpa_supplicant_event_ft_response(struct wpa_supplicant *wpa_s, |
5416 | | union wpa_event_data *data) |
5417 | | { |
5418 | | if (data == NULL) |
5419 | | return; |
5420 | | |
5421 | | if (wpa_ft_process_response(wpa_s->wpa, data->ft_ies.ies, |
5422 | | data->ft_ies.ies_len, |
5423 | | data->ft_ies.ft_action, |
5424 | | data->ft_ies.target_ap, |
5425 | | data->ft_ies.ric_ies, |
5426 | | data->ft_ies.ric_ies_len) < 0) { |
5427 | | /* TODO: prevent MLME/driver from trying to associate? */ |
5428 | | } |
5429 | | } |
5430 | | #endif /* CONFIG_IEEE80211R */ |
5431 | | |
5432 | | |
5433 | | #ifdef CONFIG_IBSS_RSN |
5434 | | static void wpa_supplicant_event_ibss_rsn_start(struct wpa_supplicant *wpa_s, |
5435 | | union wpa_event_data *data) |
5436 | | { |
5437 | | struct wpa_ssid *ssid; |
5438 | | if (wpa_s->wpa_state < WPA_ASSOCIATED) |
5439 | | return; |
5440 | | if (data == NULL) |
5441 | | return; |
5442 | | ssid = wpa_s->current_ssid; |
5443 | | if (ssid == NULL) |
5444 | | return; |
5445 | | if (ssid->mode != WPAS_MODE_IBSS || !wpa_key_mgmt_wpa(ssid->key_mgmt)) |
5446 | | return; |
5447 | | |
5448 | | ibss_rsn_start(wpa_s->ibss_rsn, data->ibss_rsn_start.peer); |
5449 | | } |
5450 | | |
5451 | | |
5452 | | static void wpa_supplicant_event_ibss_auth(struct wpa_supplicant *wpa_s, |
5453 | | union wpa_event_data *data) |
5454 | | { |
5455 | | struct wpa_ssid *ssid = wpa_s->current_ssid; |
5456 | | |
5457 | | if (ssid == NULL) |
5458 | | return; |
5459 | | |
5460 | | /* check if the ssid is correctly configured as IBSS/RSN */ |
5461 | | if (ssid->mode != WPAS_MODE_IBSS || !wpa_key_mgmt_wpa(ssid->key_mgmt)) |
5462 | | return; |
5463 | | |
5464 | | ibss_rsn_handle_auth(wpa_s->ibss_rsn, data->rx_mgmt.frame, |
5465 | | data->rx_mgmt.frame_len); |
5466 | | } |
5467 | | #endif /* CONFIG_IBSS_RSN */ |
5468 | | |
5469 | | |
5470 | | #ifdef CONFIG_IEEE80211R |
5471 | | static void ft_rx_action(struct wpa_supplicant *wpa_s, const u8 *da, |
5472 | | const u8 *sa, const u8 *data, size_t len) |
5473 | | { |
5474 | | const u8 *sta_addr, *target_ap_addr; |
5475 | | u16 status; |
5476 | | |
5477 | | wpa_hexdump(MSG_MSGDUMP, "FT: RX Action", data, len); |
5478 | | if (is_multicast_ether_addr(da)) { |
5479 | | wpa_printf(MSG_DEBUG, |
5480 | | "FT: Ignore group-addressed FT Action frame (A1=" MACSTR " A2=" MACSTR ")", |
5481 | | MAC2STR(da), MAC2STR(sa)); |
5482 | | return; |
5483 | | } |
5484 | | if (!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)) |
5485 | | return; /* only SME case supported for now */ |
5486 | | if (len < 1 + 2 * ETH_ALEN + 2) |
5487 | | return; |
5488 | | if (data[0] != 2) |
5489 | | return; /* Only FT Action Response is supported for now */ |
5490 | | sta_addr = data + 1; |
5491 | | target_ap_addr = data + 1 + ETH_ALEN; |
5492 | | status = WPA_GET_LE16(data + 1 + 2 * ETH_ALEN); |
5493 | | wpa_dbg(wpa_s, MSG_DEBUG, "FT: Received FT Action Response: STA " |
5494 | | MACSTR " TargetAP " MACSTR " status %u", |
5495 | | MAC2STR(sta_addr), MAC2STR(target_ap_addr), status); |
5496 | | |
5497 | | if (!ether_addr_equal(sta_addr, wpa_s->own_addr)) { |
5498 | | wpa_dbg(wpa_s, MSG_DEBUG, "FT: Foreign STA Address " MACSTR |
5499 | | " in FT Action Response", MAC2STR(sta_addr)); |
5500 | | return; |
5501 | | } |
5502 | | |
5503 | | if (status) { |
5504 | | wpa_dbg(wpa_s, MSG_DEBUG, "FT: FT Action Response indicates " |
5505 | | "failure (status code %d)", status); |
5506 | | /* TODO: report error to FT code(?) */ |
5507 | | return; |
5508 | | } |
5509 | | |
5510 | | if (wpa_ft_process_response(wpa_s->wpa, data + 1 + 2 * ETH_ALEN + 2, |
5511 | | len - (1 + 2 * ETH_ALEN + 2), 1, |
5512 | | target_ap_addr, NULL, 0) < 0) |
5513 | | return; |
5514 | | |
5515 | | #ifdef CONFIG_SME |
5516 | | { |
5517 | | struct wpa_bss *bss; |
5518 | | bss = wpa_bss_get_bssid(wpa_s, target_ap_addr); |
5519 | | if (bss) |
5520 | | wpa_s->sme.freq = bss->freq; |
5521 | | wpa_s->sme.auth_alg = WPA_AUTH_ALG_FT; |
5522 | | sme_associate(wpa_s, WPAS_MODE_INFRA, target_ap_addr, |
5523 | | WLAN_AUTH_FT); |
5524 | | } |
5525 | | #endif /* CONFIG_SME */ |
5526 | | } |
5527 | | #endif /* CONFIG_IEEE80211R */ |
5528 | | |
5529 | | |
5530 | | static void wpa_supplicant_event_unprot_deauth(struct wpa_supplicant *wpa_s, |
5531 | | struct unprot_deauth *e) |
5532 | 0 | { |
5533 | 0 | wpa_printf(MSG_DEBUG, "Unprotected Deauthentication frame " |
5534 | 0 | "dropped: " MACSTR " -> " MACSTR |
5535 | 0 | " (reason code %u)", |
5536 | 0 | MAC2STR(e->sa), MAC2STR(e->da), e->reason_code); |
5537 | 0 | sme_event_unprot_disconnect(wpa_s, e->sa, e->da, e->reason_code); |
5538 | 0 | } |
5539 | | |
5540 | | |
5541 | | static void wpa_supplicant_event_unprot_disassoc(struct wpa_supplicant *wpa_s, |
5542 | | struct unprot_disassoc *e) |
5543 | 0 | { |
5544 | 0 | wpa_printf(MSG_DEBUG, "Unprotected Disassociation frame " |
5545 | 0 | "dropped: " MACSTR " -> " MACSTR |
5546 | 0 | " (reason code %u)", |
5547 | 0 | MAC2STR(e->sa), MAC2STR(e->da), e->reason_code); |
5548 | 0 | sme_event_unprot_disconnect(wpa_s, e->sa, e->da, e->reason_code); |
5549 | 0 | } |
5550 | | |
5551 | | |
5552 | | static void wpas_event_disconnect(struct wpa_supplicant *wpa_s, const u8 *addr, |
5553 | | u16 reason_code, int locally_generated, |
5554 | | const u8 *ie, size_t ie_len, int deauth) |
5555 | 0 | { |
5556 | | #ifdef CONFIG_AP |
5557 | | if (wpa_s->ap_iface && addr) { |
5558 | | hostapd_notif_disassoc(wpa_s->ap_iface->bss[0], addr); |
5559 | | return; |
5560 | | } |
5561 | | |
5562 | | if (wpa_s->ap_iface) { |
5563 | | wpa_dbg(wpa_s, MSG_DEBUG, "Ignore deauth event in AP mode"); |
5564 | | return; |
5565 | | } |
5566 | | #endif /* CONFIG_AP */ |
5567 | |
|
5568 | 0 | if (!locally_generated) |
5569 | 0 | wpa_s->own_disconnect_req = 0; |
5570 | |
|
5571 | 0 | wpa_supplicant_event_disassoc(wpa_s, reason_code, locally_generated); |
5572 | |
|
5573 | 0 | if (((reason_code == WLAN_REASON_IEEE_802_1X_AUTH_FAILED || |
5574 | 0 | ((wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt) || |
5575 | 0 | (wpa_s->key_mgmt & WPA_KEY_MGMT_IEEE8021X_NO_WPA)) && |
5576 | 0 | eapol_sm_failed(wpa_s->eapol))) && |
5577 | 0 | !wpa_s->eap_expected_failure)) |
5578 | 0 | wpas_auth_failed(wpa_s, "AUTH_FAILED", addr); |
5579 | |
|
5580 | | #ifdef CONFIG_P2P |
5581 | | if (deauth && reason_code > 0) { |
5582 | | if (wpas_p2p_deauth_notif(wpa_s, addr, reason_code, ie, ie_len, |
5583 | | locally_generated) > 0) { |
5584 | | /* |
5585 | | * The interface was removed, so cannot continue |
5586 | | * processing any additional operations after this. |
5587 | | */ |
5588 | | return; |
5589 | | } |
5590 | | } |
5591 | | #endif /* CONFIG_P2P */ |
5592 | |
|
5593 | 0 | wpa_supplicant_event_disassoc_finish(wpa_s, reason_code, |
5594 | 0 | locally_generated); |
5595 | 0 | } |
5596 | | |
5597 | | |
5598 | | static void wpas_event_disassoc(struct wpa_supplicant *wpa_s, |
5599 | | struct disassoc_info *info) |
5600 | 0 | { |
5601 | 0 | u16 reason_code = 0; |
5602 | 0 | int locally_generated = 0; |
5603 | 0 | const u8 *addr = NULL; |
5604 | 0 | const u8 *ie = NULL; |
5605 | 0 | size_t ie_len = 0; |
5606 | |
|
5607 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "Disassociation notification"); |
5608 | |
|
5609 | 0 | if (info) { |
5610 | 0 | addr = info->addr; |
5611 | 0 | ie = info->ie; |
5612 | 0 | ie_len = info->ie_len; |
5613 | 0 | reason_code = info->reason_code; |
5614 | 0 | locally_generated = info->locally_generated; |
5615 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, " * reason %u (%s)%s", reason_code, |
5616 | 0 | reason2str(reason_code), |
5617 | 0 | locally_generated ? " locally_generated=1" : ""); |
5618 | 0 | if (addr) |
5619 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, " * address " MACSTR, |
5620 | 0 | MAC2STR(addr)); |
5621 | 0 | wpa_hexdump(MSG_DEBUG, "Disassociation frame IE(s)", |
5622 | 0 | ie, ie_len); |
5623 | 0 | } |
5624 | |
|
5625 | | #ifdef CONFIG_AP |
5626 | | if (wpa_s->ap_iface && info && info->addr) { |
5627 | | hostapd_notif_disassoc(wpa_s->ap_iface->bss[0], info->addr); |
5628 | | return; |
5629 | | } |
5630 | | |
5631 | | if (wpa_s->ap_iface) { |
5632 | | wpa_dbg(wpa_s, MSG_DEBUG, "Ignore disassoc event in AP mode"); |
5633 | | return; |
5634 | | } |
5635 | | #endif /* CONFIG_AP */ |
5636 | |
|
5637 | | #ifdef CONFIG_P2P |
5638 | | if (info) { |
5639 | | wpas_p2p_disassoc_notif( |
5640 | | wpa_s, info->addr, reason_code, info->ie, info->ie_len, |
5641 | | locally_generated); |
5642 | | } |
5643 | | #endif /* CONFIG_P2P */ |
5644 | |
|
5645 | 0 | if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME) |
5646 | 0 | sme_event_disassoc(wpa_s, info); |
5647 | |
|
5648 | 0 | wpas_event_disconnect(wpa_s, addr, reason_code, locally_generated, |
5649 | 0 | ie, ie_len, 0); |
5650 | 0 | } |
5651 | | |
5652 | | |
5653 | | static void wpas_event_deauth(struct wpa_supplicant *wpa_s, |
5654 | | struct deauth_info *info) |
5655 | 0 | { |
5656 | 0 | u16 reason_code = 0; |
5657 | 0 | int locally_generated = 0; |
5658 | 0 | const u8 *addr = NULL; |
5659 | 0 | const u8 *ie = NULL; |
5660 | 0 | size_t ie_len = 0; |
5661 | |
|
5662 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "Deauthentication notification"); |
5663 | |
|
5664 | 0 | if (info) { |
5665 | 0 | addr = info->addr; |
5666 | 0 | ie = info->ie; |
5667 | 0 | ie_len = info->ie_len; |
5668 | 0 | reason_code = info->reason_code; |
5669 | 0 | locally_generated = info->locally_generated; |
5670 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, " * reason %u (%s)%s", |
5671 | 0 | reason_code, reason2str(reason_code), |
5672 | 0 | locally_generated ? " locally_generated=1" : ""); |
5673 | 0 | if (addr) { |
5674 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, " * address " MACSTR, |
5675 | 0 | MAC2STR(addr)); |
5676 | 0 | } |
5677 | 0 | wpa_hexdump(MSG_DEBUG, "Deauthentication frame IE(s)", |
5678 | 0 | ie, ie_len); |
5679 | 0 | } |
5680 | |
|
5681 | 0 | wpa_reset_ft_completed(wpa_s->wpa); |
5682 | |
|
5683 | 0 | wpas_event_disconnect(wpa_s, addr, reason_code, |
5684 | 0 | locally_generated, ie, ie_len, 1); |
5685 | 0 | } |
5686 | | |
5687 | | |
5688 | | static const char * reg_init_str(enum reg_change_initiator init) |
5689 | 0 | { |
5690 | 0 | switch (init) { |
5691 | 0 | case REGDOM_SET_BY_CORE: |
5692 | 0 | return "CORE"; |
5693 | 0 | case REGDOM_SET_BY_USER: |
5694 | 0 | return "USER"; |
5695 | 0 | case REGDOM_SET_BY_DRIVER: |
5696 | 0 | return "DRIVER"; |
5697 | 0 | case REGDOM_SET_BY_COUNTRY_IE: |
5698 | 0 | return "COUNTRY_IE"; |
5699 | 0 | case REGDOM_BEACON_HINT: |
5700 | 0 | return "BEACON_HINT"; |
5701 | 0 | } |
5702 | 0 | return "?"; |
5703 | 0 | } |
5704 | | |
5705 | | |
5706 | | static const char * reg_type_str(enum reg_type type) |
5707 | 0 | { |
5708 | 0 | switch (type) { |
5709 | 0 | case REGDOM_TYPE_UNKNOWN: |
5710 | 0 | return "UNKNOWN"; |
5711 | 0 | case REGDOM_TYPE_COUNTRY: |
5712 | 0 | return "COUNTRY"; |
5713 | 0 | case REGDOM_TYPE_WORLD: |
5714 | 0 | return "WORLD"; |
5715 | 0 | case REGDOM_TYPE_CUSTOM_WORLD: |
5716 | 0 | return "CUSTOM_WORLD"; |
5717 | 0 | case REGDOM_TYPE_INTERSECTION: |
5718 | 0 | return "INTERSECTION"; |
5719 | 0 | } |
5720 | 0 | return "?"; |
5721 | 0 | } |
5722 | | |
5723 | | |
5724 | | static void wpas_beacon_hint(struct wpa_supplicant *wpa_s, const char *title, |
5725 | | struct frequency_attrs *attrs) |
5726 | 0 | { |
5727 | 0 | if (!attrs->freq) |
5728 | 0 | return; |
5729 | 0 | wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_REGDOM_BEACON_HINT |
5730 | 0 | "%s freq=%u max_tx_power=%u%s%s%s", |
5731 | 0 | title, attrs->freq, attrs->max_tx_power, |
5732 | 0 | attrs->disabled ? " disabled=1" : "", |
5733 | 0 | attrs->no_ir ? " no_ir=1" : "", |
5734 | 0 | attrs->radar ? " radar=1" : ""); |
5735 | 0 | } |
5736 | | |
5737 | | |
5738 | | void wpa_supplicant_update_channel_list(struct wpa_supplicant *wpa_s, |
5739 | | struct channel_list_changed *info) |
5740 | 0 | { |
5741 | 0 | struct wpa_supplicant *ifs; |
5742 | 0 | u8 dfs_domain; |
5743 | | |
5744 | | /* |
5745 | | * To allow backwards compatibility with higher level layers that |
5746 | | * assumed the REGDOM_CHANGE event is sent over the initially added |
5747 | | * interface. Find the highest parent of this interface and use it to |
5748 | | * send the event. |
5749 | | */ |
5750 | 0 | for (ifs = wpa_s; ifs->parent && ifs != ifs->parent; ifs = ifs->parent) |
5751 | 0 | ; |
5752 | |
|
5753 | 0 | if (info) { |
5754 | 0 | wpa_msg(ifs, MSG_INFO, |
5755 | 0 | WPA_EVENT_REGDOM_CHANGE "init=%s type=%s%s%s", |
5756 | 0 | reg_init_str(info->initiator), reg_type_str(info->type), |
5757 | 0 | info->alpha2[0] ? " alpha2=" : "", |
5758 | 0 | info->alpha2[0] ? info->alpha2 : ""); |
5759 | |
|
5760 | 0 | if (info->initiator == REGDOM_BEACON_HINT) { |
5761 | 0 | wpas_beacon_hint(ifs, "before", |
5762 | 0 | &info->beacon_hint_before); |
5763 | 0 | wpas_beacon_hint(ifs, "after", |
5764 | 0 | &info->beacon_hint_after); |
5765 | 0 | } |
5766 | 0 | } |
5767 | |
|
5768 | 0 | if (wpa_s->drv_priv == NULL) |
5769 | 0 | return; /* Ignore event during drv initialization */ |
5770 | | |
5771 | 0 | dl_list_for_each(ifs, &wpa_s->radio->ifaces, struct wpa_supplicant, |
5772 | 0 | radio_list) { |
5773 | 0 | bool was_6ghz_enabled; |
5774 | |
|
5775 | 0 | wpa_printf(MSG_DEBUG, "%s: Updating hw mode", |
5776 | 0 | ifs->ifname); |
5777 | 0 | if (info && info->alpha2[0] && |
5778 | 0 | info->type == REGDOM_TYPE_COUNTRY) { |
5779 | 0 | ifs->device_country[0] = info->alpha2[0]; |
5780 | 0 | ifs->device_country[1] = info->alpha2[1]; |
5781 | 0 | ifs->device_country[2] = '\0'; |
5782 | 0 | ifs->device_country_set = true; |
5783 | 0 | } |
5784 | 0 | free_hw_features(ifs); |
5785 | 0 | ifs->hw.modes = wpa_drv_get_hw_feature_data( |
5786 | 0 | ifs, &ifs->hw.num_modes, &ifs->hw.flags, &dfs_domain); |
5787 | |
|
5788 | 0 | was_6ghz_enabled = ifs->is_6ghz_enabled; |
5789 | 0 | ifs->is_6ghz_enabled = wpas_is_6ghz_supported(ifs, true); |
5790 | | |
5791 | | /* Restart PNO/sched_scan with updated channel list */ |
5792 | 0 | if (ifs->pno) { |
5793 | 0 | wpas_stop_pno(ifs); |
5794 | 0 | wpas_start_pno(ifs); |
5795 | 0 | } else if (ifs->sched_scanning && !ifs->pno_sched_pending) { |
5796 | 0 | wpa_dbg(ifs, MSG_DEBUG, |
5797 | 0 | "Channel list changed - restart sched_scan"); |
5798 | 0 | wpas_scan_restart_sched_scan(ifs); |
5799 | 0 | } else if (!was_6ghz_enabled && ifs->is_6ghz_enabled) { |
5800 | 0 | wpa_dbg(ifs, MSG_INFO, |
5801 | 0 | "Channel list changed: 6 GHz was enabled"); |
5802 | |
|
5803 | 0 | ifs->crossed_6ghz_dom = true; |
5804 | 0 | } |
5805 | 0 | } |
5806 | |
|
5807 | 0 | wpas_p2p_update_channel_list(wpa_s, WPAS_P2P_CHANNEL_UPDATE_DRIVER); |
5808 | 0 | } |
5809 | | |
5810 | | |
5811 | | static void wpas_event_rx_mgmt_action(struct wpa_supplicant *wpa_s, |
5812 | | const u8 *frame, size_t len, int freq, |
5813 | | int rssi) |
5814 | 0 | { |
5815 | 0 | const struct ieee80211_mgmt *mgmt; |
5816 | 0 | const u8 *payload; |
5817 | 0 | size_t plen; |
5818 | 0 | u8 category; |
5819 | |
|
5820 | 0 | if (len < IEEE80211_HDRLEN + 2) |
5821 | 0 | return; |
5822 | | |
5823 | 0 | mgmt = (const struct ieee80211_mgmt *) frame; |
5824 | 0 | payload = frame + IEEE80211_HDRLEN; |
5825 | 0 | category = *payload++; |
5826 | 0 | plen = len - IEEE80211_HDRLEN - 1; |
5827 | |
|
5828 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "Received Action frame: SA=" MACSTR |
5829 | 0 | " Category=%u DataLen=%d freq=%d MHz", |
5830 | 0 | MAC2STR(mgmt->sa), category, (int) plen, freq); |
5831 | |
|
5832 | 0 | #ifndef CONFIG_NO_WMM_AC |
5833 | 0 | if (category == WLAN_ACTION_WMM) { |
5834 | 0 | wmm_ac_rx_action(wpa_s, mgmt->da, mgmt->sa, payload, plen); |
5835 | 0 | return; |
5836 | 0 | } |
5837 | 0 | #endif /* CONFIG_NO_WMM_AC */ |
5838 | | |
5839 | | #ifdef CONFIG_IEEE80211R |
5840 | | if (category == WLAN_ACTION_FT) { |
5841 | | ft_rx_action(wpa_s, mgmt->da, mgmt->sa, payload, plen); |
5842 | | return; |
5843 | | } |
5844 | | #endif /* CONFIG_IEEE80211R */ |
5845 | | |
5846 | | #ifdef CONFIG_SME |
5847 | | if (category == WLAN_ACTION_SA_QUERY) { |
5848 | | sme_sa_query_rx(wpa_s, mgmt->da, mgmt->sa, payload, plen); |
5849 | | return; |
5850 | | } |
5851 | | #endif /* CONFIG_SME */ |
5852 | | |
5853 | 0 | #ifdef CONFIG_WNM |
5854 | 0 | if (mgmt->u.action.category == WLAN_ACTION_WNM) { |
5855 | 0 | ieee802_11_rx_wnm_action(wpa_s, mgmt, len); |
5856 | 0 | return; |
5857 | 0 | } |
5858 | 0 | #endif /* CONFIG_WNM */ |
5859 | | |
5860 | 0 | #ifdef CONFIG_GAS |
5861 | 0 | if ((mgmt->u.action.category == WLAN_ACTION_PUBLIC || |
5862 | 0 | mgmt->u.action.category == WLAN_ACTION_PROTECTED_DUAL) && |
5863 | 0 | gas_query_rx(wpa_s->gas, mgmt->da, mgmt->sa, mgmt->bssid, |
5864 | 0 | mgmt->u.action.category, |
5865 | 0 | payload, plen, freq) == 0) |
5866 | 0 | return; |
5867 | 0 | #endif /* CONFIG_GAS */ |
5868 | | |
5869 | | #ifdef CONFIG_GAS_SERVER |
5870 | | if ((mgmt->u.action.category == WLAN_ACTION_PUBLIC || |
5871 | | mgmt->u.action.category == WLAN_ACTION_PROTECTED_DUAL) && |
5872 | | gas_server_rx(wpa_s->gas_server, mgmt->da, mgmt->sa, mgmt->bssid, |
5873 | | mgmt->u.action.category, |
5874 | | payload, plen, freq) == 0) |
5875 | | return; |
5876 | | #endif /* CONFIG_GAS_SERVER */ |
5877 | | |
5878 | | #ifdef CONFIG_TDLS |
5879 | | if (category == WLAN_ACTION_PUBLIC && plen >= 4 && |
5880 | | payload[0] == WLAN_TDLS_DISCOVERY_RESPONSE) { |
5881 | | wpa_dbg(wpa_s, MSG_DEBUG, |
5882 | | "TDLS: Received Discovery Response from " MACSTR, |
5883 | | MAC2STR(mgmt->sa)); |
5884 | | if (wpa_s->valid_links && |
5885 | | wpa_tdls_process_discovery_response(wpa_s->wpa, mgmt->sa, |
5886 | | &payload[1], plen - 1)) |
5887 | | wpa_dbg(wpa_s, MSG_ERROR, |
5888 | | "TDLS: Discovery Response process failed for " |
5889 | | MACSTR, MAC2STR(mgmt->sa)); |
5890 | | return; |
5891 | | } |
5892 | | #endif /* CONFIG_TDLS */ |
5893 | | |
5894 | 0 | #ifdef CONFIG_INTERWORKING |
5895 | 0 | if (category == WLAN_ACTION_QOS && plen >= 1 && |
5896 | 0 | payload[0] == QOS_QOS_MAP_CONFIG) { |
5897 | 0 | const u8 *pos = payload + 1; |
5898 | 0 | size_t qlen = plen - 1; |
5899 | |
|
5900 | 0 | if (is_multicast_ether_addr(mgmt->da)) { |
5901 | 0 | wpa_printf(MSG_DEBUG, |
5902 | 0 | "Interworking: Ignore group-addressed Qos Map Configure frame (A1=" |
5903 | 0 | MACSTR " A2=" MACSTR ")", |
5904 | 0 | MAC2STR(mgmt->da), MAC2STR(mgmt->sa)); |
5905 | 0 | return; |
5906 | 0 | } |
5907 | | |
5908 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "Interworking: Received QoS Map Configure frame from " |
5909 | 0 | MACSTR, MAC2STR(mgmt->sa)); |
5910 | 0 | if (ether_addr_equal(mgmt->sa, wpa_s->bssid) && |
5911 | 0 | qlen > 2 && pos[0] == WLAN_EID_QOS_MAP_SET && |
5912 | 0 | pos[1] <= qlen - 2 && pos[1] >= 16) |
5913 | 0 | wpas_qos_map_set(wpa_s, pos + 2, pos[1]); |
5914 | 0 | return; |
5915 | 0 | } |
5916 | 0 | #endif /* CONFIG_INTERWORKING */ |
5917 | | |
5918 | 0 | #ifndef CONFIG_NO_RRM |
5919 | 0 | if (category == WLAN_ACTION_RADIO_MEASUREMENT && |
5920 | 0 | payload[0] == WLAN_RRM_RADIO_MEASUREMENT_REQUEST) { |
5921 | 0 | wpas_rrm_handle_radio_measurement_request(wpa_s, mgmt->sa, |
5922 | 0 | mgmt->da, |
5923 | 0 | payload + 1, |
5924 | 0 | plen - 1); |
5925 | 0 | return; |
5926 | 0 | } |
5927 | | |
5928 | 0 | if (category == WLAN_ACTION_RADIO_MEASUREMENT && |
5929 | 0 | payload[0] == WLAN_RRM_NEIGHBOR_REPORT_RESPONSE) { |
5930 | 0 | wpas_rrm_process_neighbor_rep(wpa_s, mgmt->da, mgmt->sa, |
5931 | 0 | payload + 1, plen - 1); |
5932 | 0 | return; |
5933 | 0 | } |
5934 | | |
5935 | 0 | if (category == WLAN_ACTION_RADIO_MEASUREMENT && |
5936 | 0 | payload[0] == WLAN_RRM_LINK_MEASUREMENT_REQUEST) { |
5937 | 0 | wpas_rrm_handle_link_measurement_request(wpa_s, mgmt->sa, |
5938 | 0 | payload + 1, plen - 1, |
5939 | 0 | rssi); |
5940 | 0 | return; |
5941 | 0 | } |
5942 | 0 | #endif /* CONFIG_NO_RRM */ |
5943 | | |
5944 | | #ifdef CONFIG_FST |
5945 | | if (mgmt->u.action.category == WLAN_ACTION_FST && wpa_s->fst) { |
5946 | | fst_rx_action(wpa_s->fst, mgmt, len); |
5947 | | return; |
5948 | | } |
5949 | | #endif /* CONFIG_FST */ |
5950 | | |
5951 | 0 | if (category == WLAN_ACTION_PUBLIC && plen >= 5 && |
5952 | 0 | payload[0] == WLAN_PA_VENDOR_SPECIFIC && |
5953 | 0 | WPA_GET_BE32(&payload[1]) == NAN_SDF_VENDOR_TYPE) { |
5954 | 0 | payload += 5; |
5955 | 0 | plen -= 5; |
5956 | 0 | wpas_nan_de_rx_sdf(wpa_s, mgmt->sa, mgmt->bssid, freq, |
5957 | 0 | payload, plen, rssi); |
5958 | 0 | return; |
5959 | 0 | } |
5960 | | |
5961 | | #ifdef CONFIG_DPP |
5962 | | if (category == WLAN_ACTION_PUBLIC && plen >= 5 && |
5963 | | payload[0] == WLAN_PA_VENDOR_SPECIFIC && |
5964 | | WPA_GET_BE24(&payload[1]) == OUI_WFA && |
5965 | | payload[4] == DPP_OUI_TYPE) { |
5966 | | payload++; |
5967 | | plen--; |
5968 | | wpas_dpp_rx_action(wpa_s, mgmt->sa, payload, plen, freq); |
5969 | | return; |
5970 | | } |
5971 | | #endif /* CONFIG_DPP */ |
5972 | | |
5973 | 0 | #ifndef CONFIG_NO_ROBUST_AV |
5974 | 0 | if (category == WLAN_ACTION_ROBUST_AV_STREAMING && |
5975 | 0 | payload[0] == ROBUST_AV_SCS_RESP) { |
5976 | 0 | wpas_handle_robust_av_scs_recv_action(wpa_s, mgmt->da, mgmt->sa, |
5977 | 0 | payload + 1, plen - 1); |
5978 | 0 | return; |
5979 | 0 | } |
5980 | | |
5981 | 0 | if (category == WLAN_ACTION_ROBUST_AV_STREAMING && |
5982 | 0 | payload[0] == ROBUST_AV_MSCS_RESP) { |
5983 | 0 | wpas_handle_robust_av_recv_action(wpa_s, mgmt->da, mgmt->sa, |
5984 | 0 | payload + 1, plen - 1); |
5985 | 0 | return; |
5986 | 0 | } |
5987 | | |
5988 | 0 | if (category == WLAN_ACTION_VENDOR_SPECIFIC_PROTECTED && plen > 4 && |
5989 | 0 | WPA_GET_BE32(payload) == QM_ACTION_VENDOR_TYPE) { |
5990 | 0 | wpas_handle_qos_mgmt_recv_action(wpa_s, mgmt->da, mgmt->sa, |
5991 | 0 | payload + 4, plen - 4); |
5992 | 0 | return; |
5993 | 0 | } |
5994 | 0 | #endif /* CONFIG_NO_ROBUST_AV */ |
5995 | | |
5996 | 0 | wpas_p2p_rx_action(wpa_s, mgmt->da, mgmt->sa, mgmt->bssid, |
5997 | 0 | category, payload, plen, freq); |
5998 | 0 | if (wpa_s->ifmsh) |
5999 | 0 | mesh_mpm_action_rx(wpa_s, mgmt, len); |
6000 | 0 | } |
6001 | | |
6002 | | |
6003 | | static void wpa_supplicant_notify_avoid_freq(struct wpa_supplicant *wpa_s, |
6004 | | union wpa_event_data *event) |
6005 | 0 | { |
6006 | 0 | struct wpa_freq_range_list *list; |
6007 | 0 | char *str = NULL; |
6008 | |
|
6009 | 0 | list = &event->freq_range; |
6010 | |
|
6011 | 0 | if (list->num) |
6012 | 0 | str = freq_range_list_str(list); |
6013 | 0 | wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_AVOID_FREQ "ranges=%s", |
6014 | 0 | str ? str : ""); |
6015 | |
|
6016 | | #ifdef CONFIG_P2P |
6017 | | if (freq_range_list_parse(&wpa_s->global->p2p_go_avoid_freq, str)) { |
6018 | | wpa_dbg(wpa_s, MSG_ERROR, "%s: Failed to parse freq range", |
6019 | | __func__); |
6020 | | } else { |
6021 | | wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Update channel list based on frequency avoid event"); |
6022 | | |
6023 | | /* |
6024 | | * The update channel flow will also take care of moving a GO |
6025 | | * from the unsafe frequency if needed. |
6026 | | */ |
6027 | | wpas_p2p_update_channel_list(wpa_s, |
6028 | | WPAS_P2P_CHANNEL_UPDATE_AVOID); |
6029 | | } |
6030 | | #endif /* CONFIG_P2P */ |
6031 | |
|
6032 | 0 | os_free(str); |
6033 | 0 | } |
6034 | | |
6035 | | |
6036 | | static void wpa_supplicant_event_port_authorized(struct wpa_supplicant *wpa_s) |
6037 | 0 | { |
6038 | 0 | if (wpa_s->wpa_state == WPA_ASSOCIATED) { |
6039 | 0 | wpa_supplicant_cancel_auth_timeout(wpa_s); |
6040 | 0 | wpa_supplicant_set_state(wpa_s, WPA_COMPLETED); |
6041 | 0 | eapol_sm_notify_portValid(wpa_s->eapol, true); |
6042 | 0 | eapol_sm_notify_eap_success(wpa_s->eapol, true); |
6043 | 0 | wpa_s->drv_authorized_port = 1; |
6044 | 0 | } |
6045 | 0 | } |
6046 | | |
6047 | | |
6048 | | static unsigned int wpas_event_cac_ms(const struct wpa_supplicant *wpa_s, |
6049 | | int freq) |
6050 | 0 | { |
6051 | 0 | size_t i; |
6052 | 0 | int j; |
6053 | |
|
6054 | 0 | for (i = 0; i < wpa_s->hw.num_modes; i++) { |
6055 | 0 | const struct hostapd_hw_modes *mode = &wpa_s->hw.modes[i]; |
6056 | |
|
6057 | 0 | for (j = 0; j < mode->num_channels; j++) { |
6058 | 0 | const struct hostapd_channel_data *chan; |
6059 | |
|
6060 | 0 | chan = &mode->channels[j]; |
6061 | 0 | if (chan->freq == freq) |
6062 | 0 | return chan->dfs_cac_ms; |
6063 | 0 | } |
6064 | 0 | } |
6065 | | |
6066 | 0 | return 0; |
6067 | 0 | } |
6068 | | |
6069 | | |
6070 | | static void wpas_event_dfs_cac_started(struct wpa_supplicant *wpa_s, |
6071 | | struct dfs_event *radar) |
6072 | 0 | { |
6073 | | #if defined(NEED_AP_MLME) && defined(CONFIG_AP) |
6074 | | if (wpa_s->ap_iface || wpa_s->ifmsh) { |
6075 | | wpas_ap_event_dfs_cac_started(wpa_s, radar); |
6076 | | } else |
6077 | | #endif /* NEED_AP_MLME && CONFIG_AP */ |
6078 | 0 | { |
6079 | 0 | unsigned int cac_time = wpas_event_cac_ms(wpa_s, radar->freq); |
6080 | |
|
6081 | 0 | cac_time /= 1000; /* convert from ms to sec */ |
6082 | 0 | if (!cac_time) |
6083 | 0 | cac_time = 10 * 60; /* max timeout: 10 minutes */ |
6084 | | |
6085 | | /* Restart auth timeout: CAC time added to initial timeout */ |
6086 | 0 | wpas_auth_timeout_restart(wpa_s, cac_time); |
6087 | 0 | } |
6088 | 0 | } |
6089 | | |
6090 | | |
6091 | | static void wpas_event_dfs_cac_finished(struct wpa_supplicant *wpa_s, |
6092 | | struct dfs_event *radar) |
6093 | 0 | { |
6094 | | #if defined(NEED_AP_MLME) && defined(CONFIG_AP) |
6095 | | if (wpa_s->ap_iface || wpa_s->ifmsh) { |
6096 | | wpas_ap_event_dfs_cac_finished(wpa_s, radar); |
6097 | | } else |
6098 | | #endif /* NEED_AP_MLME && CONFIG_AP */ |
6099 | 0 | { |
6100 | | /* Restart auth timeout with original value after CAC is |
6101 | | * finished */ |
6102 | 0 | wpas_auth_timeout_restart(wpa_s, 0); |
6103 | 0 | } |
6104 | 0 | } |
6105 | | |
6106 | | |
6107 | | static void wpas_event_dfs_cac_aborted(struct wpa_supplicant *wpa_s, |
6108 | | struct dfs_event *radar) |
6109 | 0 | { |
6110 | | #if defined(NEED_AP_MLME) && defined(CONFIG_AP) |
6111 | | if (wpa_s->ap_iface || wpa_s->ifmsh) { |
6112 | | wpas_ap_event_dfs_cac_aborted(wpa_s, radar); |
6113 | | } else |
6114 | | #endif /* NEED_AP_MLME && CONFIG_AP */ |
6115 | 0 | { |
6116 | | /* Restart auth timeout with original value after CAC is |
6117 | | * aborted */ |
6118 | 0 | wpas_auth_timeout_restart(wpa_s, 0); |
6119 | 0 | } |
6120 | 0 | } |
6121 | | |
6122 | | |
6123 | | static void wpa_supplicant_event_assoc_auth(struct wpa_supplicant *wpa_s, |
6124 | | union wpa_event_data *data) |
6125 | 0 | { |
6126 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
6127 | 0 | "Connection authorized by device, previous state %d", |
6128 | 0 | wpa_s->wpa_state); |
6129 | |
|
6130 | 0 | wpa_supplicant_event_port_authorized(wpa_s); |
6131 | |
|
6132 | 0 | wpa_s->last_eapol_matches_bssid = 1; |
6133 | |
|
6134 | 0 | wpa_sm_set_rx_replay_ctr(wpa_s->wpa, data->assoc_info.key_replay_ctr); |
6135 | 0 | wpa_sm_set_ptk_kck_kek(wpa_s->wpa, RSN_HASH_NOT_SPECIFIED, |
6136 | 0 | data->assoc_info.ptk_kck, |
6137 | 0 | data->assoc_info.ptk_kck_len, |
6138 | 0 | data->assoc_info.ptk_kek, |
6139 | 0 | data->assoc_info.ptk_kek_len); |
6140 | | #ifdef CONFIG_FILS |
6141 | | if (wpa_s->auth_alg == WPA_AUTH_ALG_FILS) { |
6142 | | struct wpa_bss *bss = wpa_bss_get_bssid(wpa_s, wpa_s->bssid); |
6143 | | const u8 *fils_cache_id = wpa_bss_get_fils_cache_id(bss); |
6144 | | |
6145 | | /* Update ERP next sequence number */ |
6146 | | eapol_sm_update_erp_next_seq_num( |
6147 | | wpa_s->eapol, data->assoc_info.fils_erp_next_seq_num); |
6148 | | |
6149 | | if (data->assoc_info.fils_pmk && data->assoc_info.fils_pmkid) { |
6150 | | /* Add the new PMK and PMKID to the PMKSA cache */ |
6151 | | wpa_sm_pmksa_cache_add(wpa_s->wpa, |
6152 | | data->assoc_info.fils_pmk, |
6153 | | data->assoc_info.fils_pmk_len, |
6154 | | data->assoc_info.fils_pmkid, |
6155 | | wpa_s->valid_links ? |
6156 | | wpa_s->ap_mld_addr : |
6157 | | wpa_s->bssid, |
6158 | | fils_cache_id); |
6159 | | } else if (data->assoc_info.fils_pmkid) { |
6160 | | /* Update the current PMKSA used for this connection */ |
6161 | | pmksa_cache_set_current(wpa_s->wpa, |
6162 | | data->assoc_info.fils_pmkid, |
6163 | | NULL, NULL, 0, NULL, 0, true); |
6164 | | } |
6165 | | } |
6166 | | #endif /* CONFIG_FILS */ |
6167 | 0 | } |
6168 | | |
6169 | | |
6170 | | static const char * connect_fail_reason(enum sta_connect_fail_reason_codes code) |
6171 | 0 | { |
6172 | 0 | switch (code) { |
6173 | 0 | case STA_CONNECT_FAIL_REASON_UNSPECIFIED: |
6174 | 0 | return ""; |
6175 | 0 | case STA_CONNECT_FAIL_REASON_NO_BSS_FOUND: |
6176 | 0 | return "no_bss_found"; |
6177 | 0 | case STA_CONNECT_FAIL_REASON_AUTH_TX_FAIL: |
6178 | 0 | return "auth_tx_fail"; |
6179 | 0 | case STA_CONNECT_FAIL_REASON_AUTH_NO_ACK_RECEIVED: |
6180 | 0 | return "auth_no_ack_received"; |
6181 | 0 | case STA_CONNECT_FAIL_REASON_AUTH_NO_RESP_RECEIVED: |
6182 | 0 | return "auth_no_resp_received"; |
6183 | 0 | case STA_CONNECT_FAIL_REASON_ASSOC_REQ_TX_FAIL: |
6184 | 0 | return "assoc_req_tx_fail"; |
6185 | 0 | case STA_CONNECT_FAIL_REASON_ASSOC_NO_ACK_RECEIVED: |
6186 | 0 | return "assoc_no_ack_received"; |
6187 | 0 | case STA_CONNECT_FAIL_REASON_ASSOC_NO_RESP_RECEIVED: |
6188 | 0 | return "assoc_no_resp_received"; |
6189 | 0 | default: |
6190 | 0 | return "unknown_reason"; |
6191 | 0 | } |
6192 | 0 | } |
6193 | | |
6194 | | |
6195 | | static void wpas_event_assoc_reject(struct wpa_supplicant *wpa_s, |
6196 | | union wpa_event_data *data) |
6197 | 0 | { |
6198 | 0 | const u8 *bssid = data->assoc_reject.bssid; |
6199 | 0 | struct ieee802_11_elems elems; |
6200 | 0 | struct ml_sta_link_info ml_info[MAX_NUM_MLD_LINKS]; |
6201 | 0 | const u8 *link_bssids[MAX_NUM_MLD_LINKS + 1]; |
6202 | | #ifdef CONFIG_MBO |
6203 | | struct wpa_bss *reject_bss; |
6204 | | #endif /* CONFIG_MBO */ |
6205 | |
|
6206 | 0 | if (!bssid || is_zero_ether_addr(bssid)) |
6207 | 0 | bssid = wpa_s->pending_bssid; |
6208 | | #ifdef CONFIG_MBO |
6209 | | if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME) |
6210 | | reject_bss = wpa_s->current_bss; |
6211 | | else |
6212 | | reject_bss = wpa_bss_get_bssid(wpa_s, bssid); |
6213 | | #endif /* CONFIG_MBO */ |
6214 | |
|
6215 | 0 | if (data->assoc_reject.bssid) |
6216 | 0 | wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_ASSOC_REJECT |
6217 | 0 | "bssid=" MACSTR " status_code=%u%s%s%s%s%s", |
6218 | 0 | MAC2STR(data->assoc_reject.bssid), |
6219 | 0 | data->assoc_reject.status_code, |
6220 | 0 | data->assoc_reject.timed_out ? " timeout" : "", |
6221 | 0 | data->assoc_reject.timeout_reason ? "=" : "", |
6222 | 0 | data->assoc_reject.timeout_reason ? |
6223 | 0 | data->assoc_reject.timeout_reason : "", |
6224 | 0 | data->assoc_reject.reason_code != |
6225 | 0 | STA_CONNECT_FAIL_REASON_UNSPECIFIED ? |
6226 | 0 | " qca_driver_reason=" : "", |
6227 | 0 | connect_fail_reason(data->assoc_reject.reason_code)); |
6228 | 0 | else |
6229 | 0 | wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_ASSOC_REJECT |
6230 | 0 | "status_code=%u%s%s%s%s%s", |
6231 | 0 | data->assoc_reject.status_code, |
6232 | 0 | data->assoc_reject.timed_out ? " timeout" : "", |
6233 | 0 | data->assoc_reject.timeout_reason ? "=" : "", |
6234 | 0 | data->assoc_reject.timeout_reason ? |
6235 | 0 | data->assoc_reject.timeout_reason : "", |
6236 | 0 | data->assoc_reject.reason_code != |
6237 | 0 | STA_CONNECT_FAIL_REASON_UNSPECIFIED ? |
6238 | 0 | " qca_driver_reason=" : "", |
6239 | 0 | connect_fail_reason(data->assoc_reject.reason_code)); |
6240 | 0 | wpa_s->assoc_status_code = data->assoc_reject.status_code; |
6241 | 0 | wpas_notify_assoc_status_code(wpa_s); |
6242 | |
|
6243 | | #ifdef CONFIG_OWE |
6244 | | if (data->assoc_reject.status_code == |
6245 | | WLAN_STATUS_FINITE_CYCLIC_GROUP_NOT_SUPPORTED && |
6246 | | wpa_s->key_mgmt == WPA_KEY_MGMT_OWE && |
6247 | | wpa_s->current_ssid && |
6248 | | wpa_s->current_ssid->owe_group == 0 && |
6249 | | wpa_s->last_owe_group != 21) { |
6250 | | struct wpa_ssid *ssid = wpa_s->current_ssid; |
6251 | | struct wpa_bss *bss = wpa_s->current_bss; |
6252 | | |
6253 | | if (!bss) { |
6254 | | bss = wpa_supplicant_get_new_bss(wpa_s, bssid); |
6255 | | if (!bss) { |
6256 | | wpas_connection_failed(wpa_s, bssid, NULL); |
6257 | | wpa_supplicant_mark_disassoc(wpa_s); |
6258 | | return; |
6259 | | } |
6260 | | } |
6261 | | wpa_printf(MSG_DEBUG, "OWE: Try next supported DH group"); |
6262 | | wpas_connect_work_done(wpa_s); |
6263 | | wpa_supplicant_mark_disassoc(wpa_s); |
6264 | | wpa_supplicant_connect(wpa_s, bss, ssid); |
6265 | | return; |
6266 | | } |
6267 | | #endif /* CONFIG_OWE */ |
6268 | |
|
6269 | | #ifdef CONFIG_DPP2 |
6270 | | /* Try to follow AP's PFS policy. WLAN_STATUS_ASSOC_DENIED_UNSPEC is |
6271 | | * the status code defined in the DPP R2 tech spec. |
6272 | | * WLAN_STATUS_AKMP_NOT_VALID is addressed in the same manner as an |
6273 | | * interoperability workaround with older hostapd implementation. */ |
6274 | | if (DPP_VERSION > 1 && wpa_s->current_ssid && |
6275 | | (wpa_s->current_ssid->key_mgmt == WPA_KEY_MGMT_DPP || |
6276 | | ((wpa_s->current_ssid->key_mgmt & WPA_KEY_MGMT_DPP) && |
6277 | | wpa_s->key_mgmt == WPA_KEY_MGMT_DPP)) && |
6278 | | wpa_s->current_ssid->dpp_pfs == 0 && |
6279 | | (data->assoc_reject.status_code == |
6280 | | WLAN_STATUS_ASSOC_DENIED_UNSPEC || |
6281 | | data->assoc_reject.status_code == WLAN_STATUS_AKMP_NOT_VALID)) { |
6282 | | struct wpa_ssid *ssid = wpa_s->current_ssid; |
6283 | | struct wpa_bss *bss = wpa_s->current_bss; |
6284 | | |
6285 | | wpa_s->current_ssid->dpp_pfs_fallback ^= 1; |
6286 | | if (!bss) |
6287 | | bss = wpa_supplicant_get_new_bss(wpa_s, bssid); |
6288 | | if (!bss || wpa_s->dpp_pfs_fallback) { |
6289 | | wpa_printf(MSG_DEBUG, |
6290 | | "DPP: Updated PFS policy for next try"); |
6291 | | wpas_connection_failed(wpa_s, bssid, NULL); |
6292 | | wpa_supplicant_mark_disassoc(wpa_s); |
6293 | | return; |
6294 | | } |
6295 | | wpa_printf(MSG_DEBUG, "DPP: Try again with updated PFS policy"); |
6296 | | wpa_s->dpp_pfs_fallback = 1; |
6297 | | wpas_connect_work_done(wpa_s); |
6298 | | wpa_supplicant_mark_disassoc(wpa_s); |
6299 | | wpa_supplicant_connect(wpa_s, bss, ssid); |
6300 | | return; |
6301 | | } |
6302 | | #endif /* CONFIG_DPP2 */ |
6303 | |
|
6304 | | #ifdef CONFIG_MBO |
6305 | | if (data->assoc_reject.status_code == |
6306 | | WLAN_STATUS_DENIED_POOR_CHANNEL_CONDITIONS && |
6307 | | reject_bss && data->assoc_reject.resp_ies) { |
6308 | | const u8 *rssi_rej; |
6309 | | |
6310 | | rssi_rej = mbo_get_attr_from_ies( |
6311 | | data->assoc_reject.resp_ies, |
6312 | | data->assoc_reject.resp_ies_len, |
6313 | | OCE_ATTR_ID_RSSI_BASED_ASSOC_REJECT); |
6314 | | if (rssi_rej && rssi_rej[1] == 2) { |
6315 | | wpa_printf(MSG_DEBUG, |
6316 | | "OCE: RSSI-based association rejection from " |
6317 | | MACSTR " (Delta RSSI: %u, Retry Delay: %u)", |
6318 | | MAC2STR(reject_bss->bssid), |
6319 | | rssi_rej[2], rssi_rej[3]); |
6320 | | wpa_bss_tmp_disallow(wpa_s, |
6321 | | reject_bss->bssid, |
6322 | | rssi_rej[3], |
6323 | | rssi_rej[2] + reject_bss->level); |
6324 | | } |
6325 | | } |
6326 | | #endif /* CONFIG_MBO */ |
6327 | | |
6328 | | /* Check for other failed links in the response */ |
6329 | 0 | os_memset(link_bssids, 0, sizeof(link_bssids)); |
6330 | 0 | if (ieee802_11_parse_elems(data->assoc_reject.resp_ies, |
6331 | 0 | data->assoc_reject.resp_ies_len, |
6332 | 0 | &elems, 1) != ParseFailed) { |
6333 | 0 | unsigned int n_links, i, idx; |
6334 | |
|
6335 | 0 | idx = 0; |
6336 | 0 | n_links = wpas_ml_parse_assoc(wpa_s, &elems, ml_info); |
6337 | |
|
6338 | 0 | for (i = 1; i < n_links; i++) { |
6339 | | /* The status cannot be success here. |
6340 | | * Add the link to the failed list if it is reporting |
6341 | | * an error. The only valid "non-error" status is |
6342 | | * TX_LINK_NOT_ACCEPTED as that means this link may |
6343 | | * still accept an association from us. |
6344 | | */ |
6345 | 0 | if (ml_info[i].status != |
6346 | 0 | WLAN_STATUS_DENIED_TX_LINK_NOT_ACCEPTED) { |
6347 | 0 | link_bssids[idx] = ml_info[i].bssid; |
6348 | 0 | idx++; |
6349 | 0 | } |
6350 | 0 | } |
6351 | 0 | } |
6352 | |
|
6353 | 0 | if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME) { |
6354 | 0 | sme_event_assoc_reject(wpa_s, data, link_bssids); |
6355 | 0 | return; |
6356 | 0 | } |
6357 | | |
6358 | | /* Driver-based SME cases */ |
6359 | | |
6360 | | #ifdef CONFIG_SAE |
6361 | | if (wpa_s->current_ssid && |
6362 | | wpa_key_mgmt_sae(wpa_s->current_ssid->key_mgmt) && |
6363 | | !data->assoc_reject.timed_out) { |
6364 | | wpa_dbg(wpa_s, MSG_DEBUG, "SAE: Drop PMKSA cache entry"); |
6365 | | wpa_sm_aborted_cached(wpa_s->wpa); |
6366 | | wpa_sm_pmksa_cache_flush(wpa_s->wpa, wpa_s->current_ssid); |
6367 | | } |
6368 | | #endif /* CONFIG_SAE */ |
6369 | | |
6370 | | #ifdef CONFIG_DPP |
6371 | | if (wpa_s->current_ssid && |
6372 | | wpa_s->current_ssid->key_mgmt == WPA_KEY_MGMT_DPP && |
6373 | | !data->assoc_reject.timed_out) { |
6374 | | wpa_dbg(wpa_s, MSG_DEBUG, "DPP: Drop PMKSA cache entry"); |
6375 | | wpa_sm_aborted_cached(wpa_s->wpa); |
6376 | | wpa_sm_pmksa_cache_flush(wpa_s->wpa, wpa_s->current_ssid); |
6377 | | } |
6378 | | #endif /* CONFIG_DPP */ |
6379 | | |
6380 | | #ifdef CONFIG_FILS |
6381 | | /* Update ERP next sequence number */ |
6382 | | if (wpa_s->auth_alg == WPA_AUTH_ALG_FILS) { |
6383 | | fils_pmksa_cache_flush(wpa_s); |
6384 | | eapol_sm_update_erp_next_seq_num( |
6385 | | wpa_s->eapol, |
6386 | | data->assoc_reject.fils_erp_next_seq_num); |
6387 | | fils_connection_failure(wpa_s); |
6388 | | } |
6389 | | #endif /* CONFIG_FILS */ |
6390 | | |
6391 | 0 | wpas_connection_failed(wpa_s, bssid, link_bssids); |
6392 | 0 | wpa_supplicant_mark_disassoc(wpa_s); |
6393 | 0 | } |
6394 | | |
6395 | | |
6396 | | static void wpas_event_unprot_beacon(struct wpa_supplicant *wpa_s, |
6397 | | struct unprot_beacon *data) |
6398 | 0 | { |
6399 | 0 | struct wpabuf *buf; |
6400 | 0 | int res; |
6401 | |
|
6402 | 0 | if (!data || wpa_s->wpa_state != WPA_COMPLETED || |
6403 | 0 | !ether_addr_equal(data->sa, wpa_s->bssid)) |
6404 | 0 | return; |
6405 | 0 | wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_UNPROT_BEACON MACSTR, |
6406 | 0 | MAC2STR(data->sa)); |
6407 | |
|
6408 | 0 | buf = wpabuf_alloc(4); |
6409 | 0 | if (!buf) |
6410 | 0 | return; |
6411 | | |
6412 | 0 | wpabuf_put_u8(buf, WLAN_ACTION_WNM); |
6413 | 0 | wpabuf_put_u8(buf, WNM_NOTIFICATION_REQ); |
6414 | 0 | wpabuf_put_u8(buf, 1); /* Dialog Token */ |
6415 | 0 | wpabuf_put_u8(buf, WNM_NOTIF_TYPE_BEACON_PROTECTION_FAILURE); |
6416 | |
|
6417 | 0 | res = wpa_drv_send_action(wpa_s, wpa_s->assoc_freq, 0, wpa_s->bssid, |
6418 | 0 | wpa_s->own_addr, wpa_s->bssid, |
6419 | 0 | wpabuf_head(buf), wpabuf_len(buf), 0); |
6420 | 0 | if (res < 0) |
6421 | 0 | wpa_printf(MSG_DEBUG, |
6422 | 0 | "Failed to send WNM-Notification Request frame"); |
6423 | |
|
6424 | 0 | wpabuf_free(buf); |
6425 | 0 | } |
6426 | | |
6427 | | |
6428 | | static const char * bitmap_to_str(u8 value, char *buf) |
6429 | 0 | { |
6430 | 0 | char *pos = buf; |
6431 | 0 | int i, k = 0; |
6432 | |
|
6433 | 0 | for (i = 7; i >= 0; i--) |
6434 | 0 | pos[k++] = (value & BIT(i)) ? '1' : '0'; |
6435 | |
|
6436 | 0 | pos[8] = '\0'; |
6437 | 0 | return pos; |
6438 | 0 | } |
6439 | | |
6440 | | |
6441 | | static void wpas_tid_link_map(struct wpa_supplicant *wpa_s, |
6442 | | struct tid_link_map_info *info) |
6443 | 0 | { |
6444 | 0 | char map_info[1000], *pos, *end; |
6445 | 0 | int res, i; |
6446 | |
|
6447 | 0 | pos = map_info; |
6448 | 0 | end = pos + sizeof(map_info); |
6449 | 0 | res = os_snprintf(map_info, sizeof(map_info), "default=%d", |
6450 | 0 | info->default_map); |
6451 | 0 | if (os_snprintf_error(end - pos, res)) |
6452 | 0 | return; |
6453 | 0 | pos += res; |
6454 | |
|
6455 | 0 | if (!info->default_map) { |
6456 | 0 | for_each_link(info->valid_links, i) { |
6457 | 0 | char uplink_map_str[9]; |
6458 | 0 | char downlink_map_str[9]; |
6459 | |
|
6460 | 0 | bitmap_to_str(info->t2lmap[i].uplink, uplink_map_str); |
6461 | 0 | bitmap_to_str(info->t2lmap[i].downlink, |
6462 | 0 | downlink_map_str); |
6463 | |
|
6464 | 0 | res = os_snprintf(pos, end - pos, |
6465 | 0 | " link_id=%d up_link=%s down_link=%s", |
6466 | 0 | i, uplink_map_str, |
6467 | 0 | downlink_map_str); |
6468 | 0 | if (os_snprintf_error(end - pos, res)) |
6469 | 0 | return; |
6470 | 0 | pos += res; |
6471 | 0 | } |
6472 | 0 | } |
6473 | | |
6474 | 0 | wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_T2LM_UPDATE "%s", map_info); |
6475 | 0 | } |
6476 | | |
6477 | | |
6478 | | static void wpas_setup_link_reconfig(struct wpa_supplicant *wpa_s, |
6479 | | struct reconfig_info *info) |
6480 | 0 | { |
6481 | 0 | const u8 *key_data = info->resp_ie; |
6482 | 0 | size_t key_data_len = 0; |
6483 | 0 | const u8 *ies, *end; |
6484 | 0 | bool success = false; |
6485 | 0 | int i; |
6486 | |
|
6487 | 0 | if (!info->added_links) { |
6488 | 0 | wpa_printf(MSG_INFO, "No links to be added"); |
6489 | 0 | return; |
6490 | 0 | } |
6491 | | |
6492 | 0 | if (wpa_drv_get_mlo_info(wpa_s) < 0) { |
6493 | 0 | wpa_printf(MSG_INFO, |
6494 | 0 | "SETUP_LINK_RECONFIG: Failed to set reconfig info to wpa_s"); |
6495 | 0 | return; |
6496 | 0 | } |
6497 | | |
6498 | 0 | if (wpa_sm_set_ml_info(wpa_s)) { |
6499 | 0 | wpa_printf(MSG_ERROR, |
6500 | 0 | "SETUP_LINK_RECONFIG: Failed to set reconfig info to wpa_sm"); |
6501 | 0 | return; |
6502 | 0 | } |
6503 | | |
6504 | 0 | wpa_hexdump(MSG_DEBUG, "MLD: Reconfiguration Status List", |
6505 | 0 | info->status_list, info->count * 3); |
6506 | 0 | for (i = 0; i < info->count; i++) { |
6507 | 0 | if (WPA_GET_LE16(info->status_list + i * 3 + 1) == |
6508 | 0 | WLAN_STATUS_SUCCESS) |
6509 | 0 | success = true; |
6510 | 0 | } |
6511 | |
|
6512 | 0 | if (!key_data || info->resp_ie_len == 0) |
6513 | 0 | return; |
6514 | | |
6515 | 0 | if (success) { |
6516 | | /* Starting with Group Key Data subfield, Key Data Length |
6517 | | * field */ |
6518 | 0 | if (info->resp_ie_len < 1U + key_data[0]) { |
6519 | 0 | wpa_printf(MSG_INFO, |
6520 | 0 | "MLD: Invalid keys in the link setup response"); |
6521 | 0 | return; |
6522 | 0 | } |
6523 | | |
6524 | 0 | key_data_len = key_data[0]; |
6525 | 0 | key_data++; |
6526 | 0 | wpa_hexdump_key(MSG_DEBUG, |
6527 | 0 | "MLD: Link reconfig resp - Group Key Data", |
6528 | 0 | key_data, key_data_len); |
6529 | |
|
6530 | 0 | if (wpa_sm_install_mlo_group_keys(wpa_s->wpa, key_data, |
6531 | 0 | key_data_len, |
6532 | 0 | info->added_links)) { |
6533 | 0 | wpa_printf(MSG_ERROR, |
6534 | 0 | "SETUP_LINK_RECONFIG: Failed to install group keys for added links"); |
6535 | 0 | return; |
6536 | 0 | } |
6537 | 0 | } |
6538 | | |
6539 | 0 | ies = key_data + key_data_len; |
6540 | 0 | end = info->resp_ie + info->resp_ie_len; |
6541 | 0 | wpa_hexdump(MSG_DEBUG, "MLD: Link reconfig resp - IEs", ies, end - ies); |
6542 | |
|
6543 | 0 | wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_LINK_RECONFIG "valid_links=0x%x", |
6544 | 0 | wpa_s->valid_links); |
6545 | 0 | } |
6546 | | |
6547 | | |
6548 | | static void wpas_link_reconfig(struct wpa_supplicant *wpa_s) |
6549 | 0 | { |
6550 | 0 | u8 bssid[ETH_ALEN]; |
6551 | |
|
6552 | 0 | if (wpa_drv_get_bssid(wpa_s, bssid) < 0) { |
6553 | 0 | wpa_printf(MSG_ERROR, "LINK_RECONFIG: Failed to get BSSID"); |
6554 | 0 | wpa_supplicant_deauthenticate(wpa_s, |
6555 | 0 | WLAN_REASON_DEAUTH_LEAVING); |
6556 | 0 | return; |
6557 | 0 | } |
6558 | | |
6559 | 0 | if (!ether_addr_equal(bssid, wpa_s->bssid)) { |
6560 | 0 | os_memcpy(wpa_s->bssid, bssid, ETH_ALEN); |
6561 | 0 | wpa_supplicant_update_current_bss(wpa_s, wpa_s->bssid); |
6562 | 0 | wpas_notify_bssid_changed(wpa_s); |
6563 | 0 | } |
6564 | |
|
6565 | 0 | if (wpa_drv_get_mlo_info(wpa_s) < 0) { |
6566 | 0 | wpa_printf(MSG_ERROR, |
6567 | 0 | "LINK_RECONFIG: Failed to get MLO connection info"); |
6568 | 0 | wpa_supplicant_deauthenticate(wpa_s, |
6569 | 0 | WLAN_REASON_DEAUTH_LEAVING); |
6570 | 0 | return; |
6571 | 0 | } |
6572 | | |
6573 | 0 | if (wpa_sm_set_ml_info(wpa_s)) { |
6574 | 0 | wpa_printf(MSG_ERROR, |
6575 | 0 | "LINK_RECONFIG: Failed to set MLO connection info to wpa_sm"); |
6576 | 0 | wpa_supplicant_deauthenticate(wpa_s, |
6577 | 0 | WLAN_REASON_DEAUTH_LEAVING); |
6578 | 0 | return; |
6579 | 0 | } |
6580 | | |
6581 | 0 | wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_LINK_RECONFIG "valid_links=0x%x", |
6582 | 0 | wpa_s->valid_links); |
6583 | 0 | } |
6584 | | |
6585 | | |
6586 | | #ifdef CONFIG_PASN |
6587 | | static int wpas_pasn_auth(struct wpa_supplicant *wpa_s, |
6588 | | const struct ieee80211_mgmt *mgmt, size_t len, |
6589 | | int freq) |
6590 | | { |
6591 | | struct ieee802_11_elems elems; |
6592 | | size_t auth_length; |
6593 | | |
6594 | | auth_length = IEEE80211_HDRLEN + sizeof(mgmt->u.auth); |
6595 | | |
6596 | | if (len < auth_length) { |
6597 | | wpa_printf(MSG_DEBUG, "PASN: Too short Authentication frame"); |
6598 | | return -2; |
6599 | | } |
6600 | | |
6601 | | if (le_to_host16(mgmt->u.auth.auth_alg) != WLAN_AUTH_PASN) { |
6602 | | wpa_printf(MSG_DEBUG, |
6603 | | "PASN: Not a PASN Authentication frame, skip frame parsing"); |
6604 | | return -2; |
6605 | | } |
6606 | | |
6607 | | if (ieee802_11_parse_elems(mgmt->u.auth.variable, |
6608 | | len - offsetof(struct ieee80211_mgmt, |
6609 | | u.auth.variable), |
6610 | | &elems, 1) == ParseFailed) { |
6611 | | wpa_printf(MSG_DEBUG, |
6612 | | "PASN: Failed parsing Authentication frame"); |
6613 | | return -2; |
6614 | | } |
6615 | | |
6616 | | #ifdef CONFIG_P2P |
6617 | | if (elems.p2p2_ie && elems.p2p2_ie_len) |
6618 | | return wpas_p2p_pasn_auth_rx(wpa_s, mgmt, len, freq); |
6619 | | #endif /* CONFIG_P2P */ |
6620 | | #ifdef CONFIG_PR |
6621 | | if (elems.proximity_ranging && elems.proximity_ranging_len) |
6622 | | return wpas_pr_pasn_auth_rx(wpa_s, mgmt, len, freq); |
6623 | | #endif /* CONFIG_PR */ |
6624 | | |
6625 | | return wpas_pasn_auth_rx(wpa_s, mgmt, len); |
6626 | | } |
6627 | | #endif /* CONFIG_PASN */ |
6628 | | |
6629 | | |
6630 | | void wpa_supplicant_event(void *ctx, enum wpa_event_type event, |
6631 | | union wpa_event_data *data) |
6632 | 0 | { |
6633 | 0 | struct wpa_supplicant *wpa_s = ctx; |
6634 | 0 | int resched; |
6635 | 0 | struct os_reltime age, clear_at; |
6636 | 0 | #ifndef CONFIG_NO_STDOUT_DEBUG |
6637 | 0 | int level = MSG_DEBUG; |
6638 | 0 | #endif /* CONFIG_NO_STDOUT_DEBUG */ |
6639 | |
|
6640 | 0 | if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED && |
6641 | 0 | event != EVENT_INTERFACE_ENABLED && |
6642 | 0 | event != EVENT_INTERFACE_STATUS && |
6643 | 0 | event != EVENT_SCAN_RESULTS && |
6644 | 0 | event != EVENT_SCHED_SCAN_STOPPED) { |
6645 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
6646 | 0 | "Ignore event %s (%d) while interface is disabled", |
6647 | 0 | event_to_string(event), event); |
6648 | 0 | return; |
6649 | 0 | } |
6650 | | |
6651 | 0 | #ifndef CONFIG_NO_STDOUT_DEBUG |
6652 | 0 | if (event == EVENT_RX_MGMT && data->rx_mgmt.frame_len >= 24) { |
6653 | 0 | const struct ieee80211_hdr *hdr; |
6654 | 0 | u16 fc; |
6655 | 0 | hdr = (const struct ieee80211_hdr *) data->rx_mgmt.frame; |
6656 | 0 | fc = le_to_host16(hdr->frame_control); |
6657 | 0 | if (WLAN_FC_GET_TYPE(fc) == WLAN_FC_TYPE_MGMT && |
6658 | 0 | WLAN_FC_GET_STYPE(fc) == WLAN_FC_STYPE_BEACON) |
6659 | 0 | level = MSG_EXCESSIVE; |
6660 | 0 | } |
6661 | |
|
6662 | 0 | wpa_dbg(wpa_s, level, "Event %s (%d) received", |
6663 | 0 | event_to_string(event), event); |
6664 | 0 | #endif /* CONFIG_NO_STDOUT_DEBUG */ |
6665 | |
|
6666 | 0 | switch (event) { |
6667 | 0 | case EVENT_AUTH: |
6668 | | #ifdef CONFIG_FST |
6669 | | if (!wpas_fst_update_mbie(wpa_s, data->auth.ies, |
6670 | | data->auth.ies_len)) |
6671 | | wpa_printf(MSG_DEBUG, |
6672 | | "FST: MB IEs updated from auth IE"); |
6673 | | #endif /* CONFIG_FST */ |
6674 | 0 | sme_event_auth(wpa_s, data); |
6675 | 0 | wpa_s->auth_status_code = data->auth.status_code; |
6676 | 0 | wpas_notify_auth_status_code(wpa_s); |
6677 | 0 | break; |
6678 | 0 | case EVENT_ASSOC: |
6679 | | #ifdef CONFIG_TESTING_OPTIONS |
6680 | | if (wpa_s->ignore_auth_resp) { |
6681 | | wpa_printf(MSG_INFO, |
6682 | | "EVENT_ASSOC - ignore_auth_resp active!"); |
6683 | | break; |
6684 | | } |
6685 | | if (wpa_s->testing_resend_assoc) { |
6686 | | wpa_printf(MSG_INFO, |
6687 | | "EVENT_DEAUTH - testing_resend_assoc"); |
6688 | | break; |
6689 | | } |
6690 | | #endif /* CONFIG_TESTING_OPTIONS */ |
6691 | 0 | if (wpa_s->disconnected) { |
6692 | 0 | wpa_printf(MSG_INFO, |
6693 | 0 | "Ignore unexpected EVENT_ASSOC in disconnected state"); |
6694 | 0 | break; |
6695 | 0 | } |
6696 | 0 | #ifndef CONFIG_NO_ROBUST_AV |
6697 | 0 | if (dl_list_len(&wpa_s->active_scs_ids) > 0) { |
6698 | 0 | wpa_printf(MSG_DEBUG, |
6699 | 0 | "SCS rules renegotiation required after roaming"); |
6700 | 0 | wpa_s->scs_reconfigure = true; |
6701 | 0 | } |
6702 | 0 | #endif /* CONFIG_NO_ROBUST_AV */ |
6703 | 0 | wpa_supplicant_event_assoc(wpa_s, data); |
6704 | 0 | wpa_s->assoc_status_code = WLAN_STATUS_SUCCESS; |
6705 | 0 | if (data && |
6706 | 0 | (data->assoc_info.authorized || |
6707 | 0 | (!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME) && |
6708 | 0 | wpa_fils_is_completed(wpa_s->wpa)))) |
6709 | 0 | wpa_supplicant_event_assoc_auth(wpa_s, data); |
6710 | 0 | if (data) { |
6711 | 0 | wpa_msg(wpa_s, MSG_INFO, |
6712 | 0 | WPA_EVENT_SUBNET_STATUS_UPDATE "status=%u", |
6713 | 0 | data->assoc_info.subnet_status); |
6714 | 0 | } |
6715 | 0 | break; |
6716 | 0 | case EVENT_DISASSOC: |
6717 | 0 | wpas_event_disassoc(wpa_s, |
6718 | 0 | data ? &data->disassoc_info : NULL); |
6719 | 0 | break; |
6720 | 0 | case EVENT_DEAUTH: |
6721 | | #ifdef CONFIG_TESTING_OPTIONS |
6722 | | if (wpa_s->ignore_auth_resp) { |
6723 | | wpa_printf(MSG_INFO, |
6724 | | "EVENT_DEAUTH - ignore_auth_resp active!"); |
6725 | | break; |
6726 | | } |
6727 | | if (wpa_s->testing_resend_assoc) { |
6728 | | wpa_printf(MSG_INFO, |
6729 | | "EVENT_DEAUTH - testing_resend_assoc"); |
6730 | | break; |
6731 | | } |
6732 | | #endif /* CONFIG_TESTING_OPTIONS */ |
6733 | 0 | wpas_event_deauth(wpa_s, |
6734 | 0 | data ? &data->deauth_info : NULL); |
6735 | 0 | break; |
6736 | 0 | case EVENT_LINK_RECONFIG: |
6737 | 0 | wpas_link_reconfig(wpa_s); |
6738 | 0 | break; |
6739 | 0 | case EVENT_MICHAEL_MIC_FAILURE: |
6740 | 0 | wpa_supplicant_event_michael_mic_failure(wpa_s, data); |
6741 | 0 | break; |
6742 | 0 | #ifndef CONFIG_NO_SCAN_PROCESSING |
6743 | 0 | case EVENT_SCAN_STARTED: |
6744 | 0 | if (wpa_s->own_scan_requested || |
6745 | 0 | (data && !data->scan_info.external_scan)) { |
6746 | 0 | struct os_reltime diff; |
6747 | |
|
6748 | 0 | os_get_reltime(&wpa_s->scan_start_time); |
6749 | 0 | os_reltime_sub(&wpa_s->scan_start_time, |
6750 | 0 | &wpa_s->scan_trigger_time, &diff); |
6751 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "Own scan request started a scan in %ld.%06ld seconds", |
6752 | 0 | diff.sec, diff.usec); |
6753 | 0 | wpa_s->own_scan_requested = 0; |
6754 | 0 | wpa_s->own_scan_running = 1; |
6755 | 0 | if (wpa_s->last_scan_req == MANUAL_SCAN_REQ && |
6756 | 0 | wpa_s->manual_scan_use_id) { |
6757 | 0 | wpa_msg_ctrl(wpa_s, MSG_INFO, |
6758 | 0 | WPA_EVENT_SCAN_STARTED "id=%u", |
6759 | 0 | wpa_s->manual_scan_id); |
6760 | 0 | } else { |
6761 | 0 | wpa_msg_ctrl(wpa_s, MSG_INFO, |
6762 | 0 | WPA_EVENT_SCAN_STARTED); |
6763 | 0 | } |
6764 | 0 | } else { |
6765 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "External program started a scan"); |
6766 | 0 | wpa_s->radio->external_scan_req_interface = wpa_s; |
6767 | 0 | wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_SCAN_STARTED); |
6768 | 0 | } |
6769 | 0 | break; |
6770 | 0 | case EVENT_SCAN_RESULTS: |
6771 | 0 | if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) { |
6772 | 0 | wpa_s->scan_res_handler = NULL; |
6773 | 0 | wpa_s->own_scan_running = 0; |
6774 | 0 | wpa_s->radio->external_scan_req_interface = NULL; |
6775 | 0 | wpa_s->last_scan_req = NORMAL_SCAN_REQ; |
6776 | 0 | break; |
6777 | 0 | } |
6778 | | |
6779 | 0 | if (!(data && data->scan_info.external_scan) && |
6780 | 0 | os_reltime_initialized(&wpa_s->scan_start_time)) { |
6781 | 0 | struct os_reltime now, diff; |
6782 | 0 | os_get_reltime(&now); |
6783 | 0 | os_reltime_sub(&now, &wpa_s->scan_start_time, &diff); |
6784 | 0 | wpa_s->scan_start_time.sec = 0; |
6785 | 0 | wpa_s->scan_start_time.usec = 0; |
6786 | 0 | wpa_s->wps_scan_done = true; |
6787 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "Scan completed in %ld.%06ld seconds", |
6788 | 0 | diff.sec, diff.usec); |
6789 | 0 | } |
6790 | 0 | if (wpa_supplicant_event_scan_results(wpa_s, data)) |
6791 | 0 | break; /* interface may have been removed */ |
6792 | 0 | if (!(data && data->scan_info.external_scan)) |
6793 | 0 | wpa_s->own_scan_running = 0; |
6794 | 0 | if (data && data->scan_info.nl_scan_event) |
6795 | 0 | wpa_s->radio->external_scan_req_interface = NULL; |
6796 | 0 | radio_work_check_next(wpa_s); |
6797 | 0 | break; |
6798 | 0 | #endif /* CONFIG_NO_SCAN_PROCESSING */ |
6799 | 0 | case EVENT_ASSOCINFO: |
6800 | 0 | wpa_supplicant_event_associnfo(wpa_s, data); |
6801 | 0 | break; |
6802 | 0 | case EVENT_INTERFACE_STATUS: |
6803 | 0 | wpa_supplicant_event_interface_status(wpa_s, data); |
6804 | 0 | break; |
6805 | 0 | case EVENT_PMKID_CANDIDATE: |
6806 | 0 | wpa_supplicant_event_pmkid_candidate(wpa_s, data); |
6807 | 0 | break; |
6808 | | #ifdef CONFIG_TDLS |
6809 | | case EVENT_TDLS: |
6810 | | wpa_supplicant_event_tdls(wpa_s, data); |
6811 | | break; |
6812 | | #endif /* CONFIG_TDLS */ |
6813 | 0 | #ifdef CONFIG_WNM |
6814 | 0 | case EVENT_WNM: |
6815 | 0 | wpa_supplicant_event_wnm(wpa_s, data); |
6816 | 0 | break; |
6817 | 0 | #endif /* CONFIG_WNM */ |
6818 | | #ifdef CONFIG_IEEE80211R |
6819 | | case EVENT_FT_RESPONSE: |
6820 | | wpa_supplicant_event_ft_response(wpa_s, data); |
6821 | | break; |
6822 | | #endif /* CONFIG_IEEE80211R */ |
6823 | | #ifdef CONFIG_IBSS_RSN |
6824 | | case EVENT_IBSS_RSN_START: |
6825 | | wpa_supplicant_event_ibss_rsn_start(wpa_s, data); |
6826 | | break; |
6827 | | #endif /* CONFIG_IBSS_RSN */ |
6828 | 0 | case EVENT_ASSOC_REJECT: |
6829 | 0 | wpas_event_assoc_reject(wpa_s, data); |
6830 | 0 | break; |
6831 | 0 | case EVENT_AUTH_TIMED_OUT: |
6832 | | /* It is possible to get this event from earlier connection */ |
6833 | 0 | if (wpa_s->current_ssid && |
6834 | 0 | wpa_s->current_ssid->mode == WPAS_MODE_MESH) { |
6835 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
6836 | 0 | "Ignore AUTH_TIMED_OUT in mesh configuration"); |
6837 | 0 | break; |
6838 | 0 | } |
6839 | 0 | if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME) |
6840 | 0 | sme_event_auth_timed_out(wpa_s, data); |
6841 | 0 | break; |
6842 | 0 | case EVENT_ASSOC_TIMED_OUT: |
6843 | | /* It is possible to get this event from earlier connection */ |
6844 | 0 | if (wpa_s->current_ssid && |
6845 | 0 | wpa_s->current_ssid->mode == WPAS_MODE_MESH) { |
6846 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
6847 | 0 | "Ignore ASSOC_TIMED_OUT in mesh configuration"); |
6848 | 0 | break; |
6849 | 0 | } |
6850 | 0 | if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME) |
6851 | 0 | sme_event_assoc_timed_out(wpa_s, data); |
6852 | 0 | break; |
6853 | 0 | case EVENT_TX_STATUS: |
6854 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "EVENT_TX_STATUS dst=" MACSTR |
6855 | 0 | " type=%d stype=%d", |
6856 | 0 | MAC2STR(data->tx_status.dst), |
6857 | 0 | data->tx_status.type, data->tx_status.stype); |
6858 | 0 | #ifdef CONFIG_WNM |
6859 | 0 | if (data->tx_status.type == WLAN_FC_TYPE_MGMT && |
6860 | 0 | data->tx_status.stype == WLAN_FC_STYPE_ACTION && |
6861 | 0 | wnm_btm_resp_tx_status(wpa_s, data->tx_status.data, |
6862 | 0 | data->tx_status.data_len) == 0) |
6863 | 0 | break; |
6864 | 0 | #endif /* CONFIG_WNM */ |
6865 | | #ifdef CONFIG_PASN |
6866 | | #ifdef CONFIG_P2P |
6867 | | if (data->tx_status.type == WLAN_FC_TYPE_MGMT && |
6868 | | data->tx_status.stype == WLAN_FC_STYPE_AUTH && |
6869 | | !wpa_s->pasn_auth_work && |
6870 | | wpa_s->p2p_pasn_auth_work && |
6871 | | wpas_p2p_pasn_auth_tx_status(wpa_s, |
6872 | | data->tx_status.data, |
6873 | | data->tx_status.data_len, |
6874 | | data->tx_status.ack) == 0) |
6875 | | break; |
6876 | | #endif /* CONFIG_P2P */ |
6877 | | #ifdef CONFIG_PR |
6878 | | if (data->tx_status.type == WLAN_FC_TYPE_MGMT && |
6879 | | data->tx_status.stype == WLAN_FC_STYPE_AUTH && |
6880 | | !wpa_s->pasn_auth_work && |
6881 | | wpa_s->pr_pasn_auth_work && |
6882 | | wpas_pr_pasn_auth_tx_status(wpa_s, |
6883 | | data->tx_status.data, |
6884 | | data->tx_status.data_len, |
6885 | | data->tx_status.ack) == 0) |
6886 | | break; |
6887 | | #endif /* CONFIG_PR */ |
6888 | | if (data->tx_status.type == WLAN_FC_TYPE_MGMT && |
6889 | | data->tx_status.stype == WLAN_FC_STYPE_AUTH && |
6890 | | wpas_pasn_auth_tx_status(wpa_s, data->tx_status.data, |
6891 | | data->tx_status.data_len, |
6892 | | data->tx_status.ack) == 0) |
6893 | | break; |
6894 | | #endif /* CONFIG_PASN */ |
6895 | | #ifdef CONFIG_AP |
6896 | | if (wpa_s->ap_iface == NULL) { |
6897 | | #ifdef CONFIG_OFFCHANNEL |
6898 | | if (data->tx_status.type == WLAN_FC_TYPE_MGMT && |
6899 | | data->tx_status.stype == WLAN_FC_STYPE_ACTION) |
6900 | | offchannel_send_action_tx_status( |
6901 | | wpa_s, data->tx_status.dst, |
6902 | | data->tx_status.data, |
6903 | | data->tx_status.data_len, |
6904 | | data->tx_status.ack ? |
6905 | | OFFCHANNEL_SEND_ACTION_SUCCESS : |
6906 | | OFFCHANNEL_SEND_ACTION_NO_ACK); |
6907 | | #endif /* CONFIG_OFFCHANNEL */ |
6908 | | break; |
6909 | | } |
6910 | | #endif /* CONFIG_AP */ |
6911 | | #ifdef CONFIG_OFFCHANNEL |
6912 | | wpa_dbg(wpa_s, MSG_DEBUG, "EVENT_TX_STATUS pending_dst=" |
6913 | | MACSTR, MAC2STR(wpa_s->p2pdev->pending_action_dst)); |
6914 | | /* |
6915 | | * Catch TX status events for Action frames we sent via group |
6916 | | * interface in GO mode, or via standalone AP interface. |
6917 | | * Note, wpa_s->p2pdev will be the same as wpa_s->parent, |
6918 | | * except when the primary interface is used as a GO interface |
6919 | | * (for drivers which do not have group interface concurrency) |
6920 | | */ |
6921 | | if (data->tx_status.type == WLAN_FC_TYPE_MGMT && |
6922 | | data->tx_status.stype == WLAN_FC_STYPE_ACTION && |
6923 | | ether_addr_equal(wpa_s->p2pdev->pending_action_dst, |
6924 | | data->tx_status.dst)) { |
6925 | | offchannel_send_action_tx_status( |
6926 | | wpa_s->p2pdev, data->tx_status.dst, |
6927 | | data->tx_status.data, |
6928 | | data->tx_status.data_len, |
6929 | | data->tx_status.ack ? |
6930 | | OFFCHANNEL_SEND_ACTION_SUCCESS : |
6931 | | OFFCHANNEL_SEND_ACTION_NO_ACK); |
6932 | | break; |
6933 | | } |
6934 | | #endif /* CONFIG_OFFCHANNEL */ |
6935 | | #ifdef CONFIG_AP |
6936 | | switch (data->tx_status.type) { |
6937 | | case WLAN_FC_TYPE_MGMT: |
6938 | | ap_mgmt_tx_cb(wpa_s, data->tx_status.data, |
6939 | | data->tx_status.data_len, |
6940 | | data->tx_status.stype, |
6941 | | data->tx_status.ack); |
6942 | | break; |
6943 | | case WLAN_FC_TYPE_DATA: |
6944 | | ap_tx_status(wpa_s, data->tx_status.dst, |
6945 | | data->tx_status.data, |
6946 | | data->tx_status.data_len, |
6947 | | data->tx_status.ack); |
6948 | | break; |
6949 | | } |
6950 | | #endif /* CONFIG_AP */ |
6951 | 0 | break; |
6952 | | #ifdef CONFIG_AP |
6953 | | case EVENT_EAPOL_TX_STATUS: |
6954 | | ap_eapol_tx_status(wpa_s, data->eapol_tx_status.dst, |
6955 | | data->eapol_tx_status.data, |
6956 | | data->eapol_tx_status.data_len, |
6957 | | data->eapol_tx_status.ack); |
6958 | | break; |
6959 | | case EVENT_DRIVER_CLIENT_POLL_OK: |
6960 | | ap_client_poll_ok(wpa_s, data->client_poll.addr); |
6961 | | break; |
6962 | | case EVENT_RX_FROM_UNKNOWN: |
6963 | | if (wpa_s->ap_iface == NULL) |
6964 | | break; |
6965 | | ap_rx_from_unknown_sta(wpa_s, data->rx_from_unknown.addr, |
6966 | | data->rx_from_unknown.wds); |
6967 | | break; |
6968 | | #endif /* CONFIG_AP */ |
6969 | | |
6970 | 0 | case EVENT_LINK_CH_SWITCH_STARTED: |
6971 | 0 | case EVENT_LINK_CH_SWITCH: |
6972 | 0 | if (!data || !wpa_s->current_ssid || |
6973 | 0 | !(wpa_s->valid_links & BIT(data->ch_switch.link_id))) |
6974 | 0 | break; |
6975 | | |
6976 | 0 | wpa_msg(wpa_s, MSG_INFO, |
6977 | 0 | "%sfreq=%d link_id=%d ht_enabled=%d ch_offset=%d ch_width=%s cf1=%d cf2=%d", |
6978 | 0 | event == EVENT_LINK_CH_SWITCH ? |
6979 | 0 | WPA_EVENT_LINK_CHANNEL_SWITCH : |
6980 | 0 | WPA_EVENT_LINK_CHANNEL_SWITCH_STARTED, |
6981 | 0 | data->ch_switch.freq, |
6982 | 0 | data->ch_switch.link_id, |
6983 | 0 | data->ch_switch.ht_enabled, |
6984 | 0 | data->ch_switch.ch_offset, |
6985 | 0 | channel_width_to_string(data->ch_switch.ch_width), |
6986 | 0 | data->ch_switch.cf1, |
6987 | 0 | data->ch_switch.cf2); |
6988 | 0 | if (event == EVENT_LINK_CH_SWITCH_STARTED) |
6989 | 0 | break; |
6990 | | |
6991 | 0 | wpa_s->links[data->ch_switch.link_id].freq = |
6992 | 0 | data->ch_switch.freq; |
6993 | 0 | if (wpa_s->links[data->ch_switch.link_id].bss && |
6994 | 0 | wpa_s->links[data->ch_switch.link_id].bss->freq != |
6995 | 0 | data->ch_switch.freq) { |
6996 | 0 | wpa_s->links[data->ch_switch.link_id].bss->freq = |
6997 | 0 | data->ch_switch.freq; |
6998 | 0 | notify_bss_changes( |
6999 | 0 | wpa_s, WPA_BSS_FREQ_CHANGED_FLAG, |
7000 | 0 | wpa_s->links[data->ch_switch.link_id].bss); |
7001 | 0 | } |
7002 | 0 | break; |
7003 | 0 | case EVENT_CH_SWITCH_STARTED: |
7004 | 0 | case EVENT_CH_SWITCH: |
7005 | 0 | if (!data || !wpa_s->current_ssid) |
7006 | 0 | break; |
7007 | | |
7008 | 0 | wpa_msg(wpa_s, MSG_INFO, |
7009 | 0 | "%sfreq=%d ht_enabled=%d ch_offset=%d ch_width=%s cf1=%d cf2=%d", |
7010 | 0 | event == EVENT_CH_SWITCH ? WPA_EVENT_CHANNEL_SWITCH : |
7011 | 0 | WPA_EVENT_CHANNEL_SWITCH_STARTED, |
7012 | 0 | data->ch_switch.freq, |
7013 | 0 | data->ch_switch.ht_enabled, |
7014 | 0 | data->ch_switch.ch_offset, |
7015 | 0 | channel_width_to_string(data->ch_switch.ch_width), |
7016 | 0 | data->ch_switch.cf1, |
7017 | 0 | data->ch_switch.cf2); |
7018 | 0 | if (event == EVENT_CH_SWITCH_STARTED) |
7019 | 0 | break; |
7020 | | |
7021 | 0 | wpa_s->assoc_freq = data->ch_switch.freq; |
7022 | 0 | wpa_s->current_ssid->frequency = data->ch_switch.freq; |
7023 | 0 | if (wpa_s->current_bss && |
7024 | 0 | wpa_s->current_bss->freq != data->ch_switch.freq) { |
7025 | 0 | wpa_s->current_bss->freq = data->ch_switch.freq; |
7026 | 0 | notify_bss_changes(wpa_s, WPA_BSS_FREQ_CHANGED_FLAG, |
7027 | 0 | wpa_s->current_bss); |
7028 | 0 | } |
7029 | |
|
7030 | | #ifdef CONFIG_SME |
7031 | | switch (data->ch_switch.ch_offset) { |
7032 | | case 1: |
7033 | | wpa_s->sme.ht_sec_chan = HT_SEC_CHAN_ABOVE; |
7034 | | break; |
7035 | | case -1: |
7036 | | wpa_s->sme.ht_sec_chan = HT_SEC_CHAN_BELOW; |
7037 | | break; |
7038 | | default: |
7039 | | wpa_s->sme.ht_sec_chan = HT_SEC_CHAN_UNKNOWN; |
7040 | | break; |
7041 | | } |
7042 | | #endif /* CONFIG_SME */ |
7043 | |
|
7044 | | #ifdef CONFIG_AP |
7045 | | if (wpa_s->current_ssid->mode == WPAS_MODE_AP || |
7046 | | wpa_s->current_ssid->mode == WPAS_MODE_P2P_GO || |
7047 | | wpa_s->current_ssid->mode == WPAS_MODE_MESH || |
7048 | | wpa_s->current_ssid->mode == |
7049 | | WPAS_MODE_P2P_GROUP_FORMATION) { |
7050 | | wpas_ap_ch_switch(wpa_s, data->ch_switch.freq, |
7051 | | data->ch_switch.ht_enabled, |
7052 | | data->ch_switch.ch_offset, |
7053 | | data->ch_switch.ch_width, |
7054 | | data->ch_switch.cf1, |
7055 | | data->ch_switch.cf2, |
7056 | | data->ch_switch.punct_bitmap, |
7057 | | 1); |
7058 | | } |
7059 | | #endif /* CONFIG_AP */ |
7060 | |
|
7061 | 0 | if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME) |
7062 | 0 | sme_event_ch_switch(wpa_s); |
7063 | |
|
7064 | 0 | wpas_p2p_update_channel_list(wpa_s, WPAS_P2P_CHANNEL_UPDATE_CS); |
7065 | 0 | wnm_clear_coloc_intf_reporting(wpa_s); |
7066 | 0 | break; |
7067 | | #ifdef CONFIG_AP |
7068 | | #ifdef NEED_AP_MLME |
7069 | | case EVENT_DFS_RADAR_DETECTED: |
7070 | | if (data) |
7071 | | wpas_ap_event_dfs_radar_detected(wpa_s, |
7072 | | &data->dfs_event); |
7073 | | break; |
7074 | | case EVENT_DFS_NOP_FINISHED: |
7075 | | if (data) |
7076 | | wpas_ap_event_dfs_cac_nop_finished(wpa_s, |
7077 | | &data->dfs_event); |
7078 | | break; |
7079 | | #endif /* NEED_AP_MLME */ |
7080 | | #endif /* CONFIG_AP */ |
7081 | 0 | case EVENT_DFS_CAC_STARTED: |
7082 | 0 | if (data) |
7083 | 0 | wpas_event_dfs_cac_started(wpa_s, &data->dfs_event); |
7084 | 0 | break; |
7085 | 0 | case EVENT_DFS_CAC_FINISHED: |
7086 | 0 | if (data) |
7087 | 0 | wpas_event_dfs_cac_finished(wpa_s, &data->dfs_event); |
7088 | 0 | break; |
7089 | 0 | case EVENT_DFS_CAC_ABORTED: |
7090 | 0 | if (data) |
7091 | 0 | wpas_event_dfs_cac_aborted(wpa_s, &data->dfs_event); |
7092 | 0 | break; |
7093 | 0 | case EVENT_RX_MGMT: { |
7094 | 0 | u16 fc, stype; |
7095 | 0 | const struct ieee80211_mgmt *mgmt; |
7096 | |
|
7097 | | #ifdef CONFIG_TESTING_OPTIONS |
7098 | | if (wpa_s->ext_mgmt_frame_handling) { |
7099 | | struct rx_mgmt *rx = &data->rx_mgmt; |
7100 | | size_t hex_len = 2 * rx->frame_len + 1; |
7101 | | char *hex = os_malloc(hex_len); |
7102 | | if (hex) { |
7103 | | wpa_snprintf_hex(hex, hex_len, |
7104 | | rx->frame, rx->frame_len); |
7105 | | wpa_msg(wpa_s, MSG_INFO, "MGMT-RX freq=%d datarate=%u ssi_signal=%d %s", |
7106 | | rx->freq, rx->datarate, rx->ssi_signal, |
7107 | | hex); |
7108 | | os_free(hex); |
7109 | | } |
7110 | | break; |
7111 | | } |
7112 | | #endif /* CONFIG_TESTING_OPTIONS */ |
7113 | |
|
7114 | 0 | mgmt = (const struct ieee80211_mgmt *) |
7115 | 0 | data->rx_mgmt.frame; |
7116 | 0 | fc = le_to_host16(mgmt->frame_control); |
7117 | 0 | stype = WLAN_FC_GET_STYPE(fc); |
7118 | |
|
7119 | | #ifdef CONFIG_AP |
7120 | | if (wpa_s->ap_iface == NULL) { |
7121 | | #endif /* CONFIG_AP */ |
7122 | | #ifdef CONFIG_P2P |
7123 | | if (stype == WLAN_FC_STYPE_PROBE_REQ && |
7124 | | data->rx_mgmt.frame_len > IEEE80211_HDRLEN) { |
7125 | | const u8 *src = mgmt->sa; |
7126 | | const u8 *ie; |
7127 | | size_t ie_len; |
7128 | | |
7129 | | ie = data->rx_mgmt.frame + IEEE80211_HDRLEN; |
7130 | | ie_len = data->rx_mgmt.frame_len - |
7131 | | IEEE80211_HDRLEN; |
7132 | | wpas_p2p_probe_req_rx( |
7133 | | wpa_s, src, mgmt->da, |
7134 | | mgmt->bssid, ie, ie_len, |
7135 | | data->rx_mgmt.freq, |
7136 | | data->rx_mgmt.ssi_signal); |
7137 | | break; |
7138 | | } |
7139 | | #endif /* CONFIG_P2P */ |
7140 | | #ifdef CONFIG_IBSS_RSN |
7141 | | if (wpa_s->current_ssid && |
7142 | | wpa_s->current_ssid->mode == WPAS_MODE_IBSS && |
7143 | | stype == WLAN_FC_STYPE_AUTH && |
7144 | | data->rx_mgmt.frame_len >= 30) { |
7145 | | wpa_supplicant_event_ibss_auth(wpa_s, data); |
7146 | | break; |
7147 | | } |
7148 | | #endif /* CONFIG_IBSS_RSN */ |
7149 | |
|
7150 | 0 | if (stype == WLAN_FC_STYPE_ACTION) { |
7151 | 0 | wpas_event_rx_mgmt_action( |
7152 | 0 | wpa_s, data->rx_mgmt.frame, |
7153 | 0 | data->rx_mgmt.frame_len, |
7154 | 0 | data->rx_mgmt.freq, |
7155 | 0 | data->rx_mgmt.ssi_signal); |
7156 | 0 | break; |
7157 | 0 | } |
7158 | | |
7159 | 0 | if (wpa_s->ifmsh) { |
7160 | 0 | mesh_mpm_mgmt_rx(wpa_s, &data->rx_mgmt); |
7161 | 0 | break; |
7162 | 0 | } |
7163 | | #ifdef CONFIG_PASN |
7164 | | if (stype == WLAN_FC_STYPE_AUTH && |
7165 | | wpas_pasn_auth(wpa_s, mgmt, data->rx_mgmt.frame_len, |
7166 | | data->rx_mgmt.freq) != -2) |
7167 | | break; |
7168 | | #endif /* CONFIG_PASN */ |
7169 | | |
7170 | | #ifdef CONFIG_SAE |
7171 | | if (stype == WLAN_FC_STYPE_AUTH && |
7172 | | !(wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME) && |
7173 | | ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_SAE) || |
7174 | | (wpa_s->drv_flags2 & WPA_DRIVER_FLAGS2_EPPKE))) { |
7175 | | sme_external_auth_mgmt_rx( |
7176 | | wpa_s, data->rx_mgmt.frame, |
7177 | | data->rx_mgmt.frame_len); |
7178 | | break; |
7179 | | } |
7180 | | #endif /* CONFIG_SAE */ |
7181 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "AP: ignore received " |
7182 | 0 | "management frame in non-AP mode"); |
7183 | 0 | break; |
7184 | | #ifdef CONFIG_AP |
7185 | | } |
7186 | | |
7187 | | if (stype == WLAN_FC_STYPE_PROBE_REQ && |
7188 | | data->rx_mgmt.frame_len > IEEE80211_HDRLEN) { |
7189 | | const u8 *ie; |
7190 | | size_t ie_len; |
7191 | | |
7192 | | ie = data->rx_mgmt.frame + IEEE80211_HDRLEN; |
7193 | | ie_len = data->rx_mgmt.frame_len - IEEE80211_HDRLEN; |
7194 | | |
7195 | | wpas_notify_preq(wpa_s, mgmt->sa, mgmt->da, |
7196 | | mgmt->bssid, ie, ie_len, |
7197 | | data->rx_mgmt.ssi_signal); |
7198 | | } |
7199 | | |
7200 | | ap_mgmt_rx(wpa_s, &data->rx_mgmt); |
7201 | | #endif /* CONFIG_AP */ |
7202 | 0 | break; |
7203 | 0 | } |
7204 | 0 | case EVENT_RX_PROBE_REQ: |
7205 | 0 | if (data->rx_probe_req.sa == NULL || |
7206 | 0 | data->rx_probe_req.ie == NULL) |
7207 | 0 | break; |
7208 | | #ifdef CONFIG_AP |
7209 | | if (wpa_s->ap_iface) { |
7210 | | hostapd_probe_req_rx(wpa_s->ap_iface->bss[0], |
7211 | | data->rx_probe_req.sa, |
7212 | | data->rx_probe_req.da, |
7213 | | data->rx_probe_req.bssid, |
7214 | | data->rx_probe_req.ie, |
7215 | | data->rx_probe_req.ie_len, |
7216 | | data->rx_probe_req.ssi_signal); |
7217 | | break; |
7218 | | } |
7219 | | #endif /* CONFIG_AP */ |
7220 | 0 | wpas_p2p_probe_req_rx(wpa_s, data->rx_probe_req.sa, |
7221 | 0 | data->rx_probe_req.da, |
7222 | 0 | data->rx_probe_req.bssid, |
7223 | 0 | data->rx_probe_req.ie, |
7224 | 0 | data->rx_probe_req.ie_len, |
7225 | 0 | 0, |
7226 | 0 | data->rx_probe_req.ssi_signal); |
7227 | 0 | break; |
7228 | 0 | case EVENT_REMAIN_ON_CHANNEL: |
7229 | | #ifdef CONFIG_OFFCHANNEL |
7230 | | offchannel_remain_on_channel_cb( |
7231 | | wpa_s, data->remain_on_channel.freq, |
7232 | | data->remain_on_channel.duration); |
7233 | | #endif /* CONFIG_OFFCHANNEL */ |
7234 | 0 | wpas_p2p_remain_on_channel_cb( |
7235 | 0 | wpa_s, data->remain_on_channel.freq, |
7236 | 0 | data->remain_on_channel.duration); |
7237 | | #ifdef CONFIG_DPP |
7238 | | wpas_dpp_remain_on_channel_cb( |
7239 | | wpa_s, data->remain_on_channel.freq, |
7240 | | data->remain_on_channel.duration); |
7241 | | #endif /* CONFIG_DPP */ |
7242 | 0 | wpas_nan_usd_remain_on_channel_cb( |
7243 | 0 | wpa_s, data->remain_on_channel.freq, |
7244 | 0 | data->remain_on_channel.duration); |
7245 | 0 | break; |
7246 | 0 | case EVENT_CANCEL_REMAIN_ON_CHANNEL: |
7247 | | #ifdef CONFIG_OFFCHANNEL |
7248 | | offchannel_cancel_remain_on_channel_cb( |
7249 | | wpa_s, data->remain_on_channel.freq); |
7250 | | #endif /* CONFIG_OFFCHANNEL */ |
7251 | 0 | wpas_p2p_cancel_remain_on_channel_cb( |
7252 | 0 | wpa_s, data->remain_on_channel.freq); |
7253 | | #ifdef CONFIG_DPP |
7254 | | wpas_dpp_cancel_remain_on_channel_cb( |
7255 | | wpa_s, data->remain_on_channel.freq); |
7256 | | #endif /* CONFIG_DPP */ |
7257 | 0 | wpas_nan_usd_cancel_remain_on_channel_cb( |
7258 | 0 | wpa_s, data->remain_on_channel.freq); |
7259 | 0 | break; |
7260 | 0 | case EVENT_EAPOL_RX: |
7261 | 0 | wpa_supplicant_rx_eapol(wpa_s, data->eapol_rx.src, |
7262 | 0 | data->eapol_rx.data, |
7263 | 0 | data->eapol_rx.data_len, |
7264 | 0 | data->eapol_rx.encrypted); |
7265 | 0 | break; |
7266 | 0 | case EVENT_SIGNAL_CHANGE: |
7267 | 0 | wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_SIGNAL_CHANGE |
7268 | 0 | "above=%d signal=%d noise=%d txrate=%lu", |
7269 | 0 | data->signal_change.above_threshold, |
7270 | 0 | data->signal_change.data.signal, |
7271 | 0 | data->signal_change.current_noise, |
7272 | 0 | data->signal_change.data.current_tx_rate); |
7273 | 0 | wpa_bss_update_level(wpa_s->current_bss, |
7274 | 0 | data->signal_change.data.signal); |
7275 | 0 | bgscan_notify_signal_change( |
7276 | 0 | wpa_s, data->signal_change.above_threshold, |
7277 | 0 | data->signal_change.data.signal, |
7278 | 0 | data->signal_change.current_noise, |
7279 | 0 | data->signal_change.data.current_tx_rate); |
7280 | 0 | os_memcpy(&wpa_s->last_signal_info, data, |
7281 | 0 | sizeof(struct wpa_signal_info)); |
7282 | 0 | wpas_notify_signal_change(wpa_s); |
7283 | 0 | break; |
7284 | 0 | case EVENT_INTERFACE_MAC_CHANGED: |
7285 | 0 | wpa_supplicant_update_mac_addr(wpa_s); |
7286 | 0 | wpa_sm_pmksa_cache_flush(wpa_s->wpa, NULL); |
7287 | 0 | break; |
7288 | 0 | case EVENT_INTERFACE_ENABLED: |
7289 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "Interface was enabled"); |
7290 | 0 | if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) { |
7291 | 0 | u8 addr[ETH_ALEN]; |
7292 | |
|
7293 | 0 | eloop_cancel_timeout(wpas_clear_disabled_interface, |
7294 | 0 | wpa_s, NULL); |
7295 | 0 | os_memcpy(addr, wpa_s->own_addr, ETH_ALEN); |
7296 | 0 | wpa_supplicant_update_mac_addr(wpa_s); |
7297 | 0 | if (!ether_addr_equal(addr, wpa_s->own_addr)) |
7298 | 0 | wpa_sm_pmksa_cache_flush(wpa_s->wpa, NULL); |
7299 | 0 | else |
7300 | 0 | wpa_sm_pmksa_cache_reconfig(wpa_s->wpa); |
7301 | 0 | wpa_supplicant_set_default_scan_ies(wpa_s); |
7302 | 0 | if (wpa_s->p2p_mgmt || wpa_s->nan_mgmt) { |
7303 | 0 | wpa_supplicant_set_state(wpa_s, |
7304 | 0 | WPA_DISCONNECTED); |
7305 | 0 | break; |
7306 | 0 | } |
7307 | | |
7308 | | #ifdef CONFIG_AP |
7309 | | if (!wpa_s->ap_iface) { |
7310 | | wpa_supplicant_set_state(wpa_s, |
7311 | | WPA_DISCONNECTED); |
7312 | | wpa_s->scan_req = NORMAL_SCAN_REQ; |
7313 | | wpa_supplicant_req_scan(wpa_s, 0, 0); |
7314 | | } else |
7315 | | wpa_supplicant_set_state(wpa_s, |
7316 | | WPA_COMPLETED); |
7317 | | #else /* CONFIG_AP */ |
7318 | 0 | wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED); |
7319 | 0 | wpa_supplicant_req_scan(wpa_s, 0, 0); |
7320 | 0 | #endif /* CONFIG_AP */ |
7321 | 0 | } |
7322 | 0 | break; |
7323 | 0 | case EVENT_INTERFACE_DISABLED: |
7324 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "Interface was disabled"); |
7325 | 0 | if (wpa_s->nan_mgmt) { |
7326 | 0 | wpas_nan_flush(wpa_s); |
7327 | 0 | wpa_supplicant_set_state(wpa_s, |
7328 | 0 | WPA_INTERFACE_DISABLED); |
7329 | 0 | break; |
7330 | 0 | } |
7331 | | #ifdef CONFIG_P2P |
7332 | | if (wpa_s->p2p_group_interface == P2P_GROUP_INTERFACE_GO || |
7333 | | (wpa_s->current_ssid && wpa_s->current_ssid->p2p_group && |
7334 | | wpa_s->current_ssid->mode == WPAS_MODE_P2P_GO)) { |
7335 | | /* |
7336 | | * Mark interface disabled if this happens to end up not |
7337 | | * being removed as a separate P2P group interface. |
7338 | | */ |
7339 | | wpa_supplicant_set_state(wpa_s, WPA_INTERFACE_DISABLED); |
7340 | | /* |
7341 | | * The interface was externally disabled. Remove |
7342 | | * it assuming an external entity will start a |
7343 | | * new session if needed. |
7344 | | */ |
7345 | | if (wpa_s->current_ssid && |
7346 | | wpa_s->current_ssid->p2p_group) |
7347 | | wpas_p2p_interface_unavailable(wpa_s); |
7348 | | else |
7349 | | wpas_p2p_disconnect(wpa_s); |
7350 | | /* |
7351 | | * wpa_s instance may have been freed, so must not use |
7352 | | * it here anymore. |
7353 | | */ |
7354 | | break; |
7355 | | } |
7356 | | if (wpa_s->p2p_scan_work && wpa_s->global->p2p && |
7357 | | p2p_in_progress(wpa_s->global->p2p) > 1) { |
7358 | | /* This radio work will be cancelled, so clear P2P |
7359 | | * state as well. |
7360 | | */ |
7361 | | p2p_stop_find(wpa_s->global->p2p); |
7362 | | } |
7363 | | #endif /* CONFIG_P2P */ |
7364 | | |
7365 | 0 | if (wpa_s->wpa_state >= WPA_AUTHENTICATING) { |
7366 | | /* |
7367 | | * Indicate disconnection to keep ctrl_iface events |
7368 | | * consistent. |
7369 | | */ |
7370 | 0 | wpa_supplicant_event_disassoc( |
7371 | 0 | wpa_s, WLAN_REASON_DEAUTH_LEAVING, 1); |
7372 | 0 | } |
7373 | 0 | wpa_supplicant_mark_disassoc(wpa_s); |
7374 | 0 | os_reltime_age(&wpa_s->last_scan, &age); |
7375 | 0 | if (age.sec >= wpa_s->conf->scan_res_valid_for_connect) { |
7376 | 0 | clear_at.sec = wpa_s->conf->scan_res_valid_for_connect; |
7377 | 0 | clear_at.usec = 0; |
7378 | 0 | } else { |
7379 | 0 | struct os_reltime tmp; |
7380 | |
|
7381 | 0 | tmp.sec = wpa_s->conf->scan_res_valid_for_connect; |
7382 | 0 | tmp.usec = 0; |
7383 | 0 | os_reltime_sub(&tmp, &age, &clear_at); |
7384 | 0 | } |
7385 | 0 | eloop_register_timeout(clear_at.sec, clear_at.usec, |
7386 | 0 | wpas_clear_disabled_interface, |
7387 | 0 | wpa_s, NULL); |
7388 | 0 | radio_remove_works(wpa_s, NULL, 0); |
7389 | |
|
7390 | 0 | wpa_supplicant_set_state(wpa_s, WPA_INTERFACE_DISABLED); |
7391 | 0 | break; |
7392 | 0 | case EVENT_CHANNEL_LIST_CHANGED: |
7393 | 0 | wpa_supplicant_update_channel_list( |
7394 | 0 | wpa_s, &data->channel_list_changed); |
7395 | 0 | break; |
7396 | 0 | case EVENT_INTERFACE_UNAVAILABLE: |
7397 | 0 | wpas_p2p_interface_unavailable(wpa_s); |
7398 | 0 | break; |
7399 | 0 | case EVENT_BEST_CHANNEL: |
7400 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, "Best channel event received " |
7401 | 0 | "(%d %d %d)", |
7402 | 0 | data->best_chan.freq_24, data->best_chan.freq_5, |
7403 | 0 | data->best_chan.freq_overall); |
7404 | 0 | wpa_s->best_24_freq = data->best_chan.freq_24; |
7405 | 0 | wpa_s->best_5_freq = data->best_chan.freq_5; |
7406 | 0 | wpa_s->best_overall_freq = data->best_chan.freq_overall; |
7407 | 0 | wpas_p2p_update_best_channels(wpa_s, data->best_chan.freq_24, |
7408 | 0 | data->best_chan.freq_5, |
7409 | 0 | data->best_chan.freq_overall); |
7410 | 0 | break; |
7411 | 0 | case EVENT_UNPROT_DEAUTH: |
7412 | 0 | wpa_supplicant_event_unprot_deauth(wpa_s, |
7413 | 0 | &data->unprot_deauth); |
7414 | 0 | break; |
7415 | 0 | case EVENT_UNPROT_DISASSOC: |
7416 | 0 | wpa_supplicant_event_unprot_disassoc(wpa_s, |
7417 | 0 | &data->unprot_disassoc); |
7418 | 0 | break; |
7419 | 0 | case EVENT_STATION_LOW_ACK: |
7420 | | #ifdef CONFIG_AP |
7421 | | if (wpa_s->ap_iface && data) |
7422 | | hostapd_event_sta_low_ack(wpa_s->ap_iface->bss[0], |
7423 | | data->low_ack.addr); |
7424 | | #endif /* CONFIG_AP */ |
7425 | | #ifdef CONFIG_TDLS |
7426 | | if (data) |
7427 | | wpa_tdls_disable_unreachable_link(wpa_s->wpa, |
7428 | | data->low_ack.addr); |
7429 | | #endif /* CONFIG_TDLS */ |
7430 | 0 | break; |
7431 | 0 | case EVENT_IBSS_PEER_LOST: |
7432 | | #ifdef CONFIG_IBSS_RSN |
7433 | | ibss_rsn_stop(wpa_s->ibss_rsn, data->ibss_peer_lost.peer); |
7434 | | #endif /* CONFIG_IBSS_RSN */ |
7435 | 0 | break; |
7436 | 0 | case EVENT_DRIVER_GTK_REKEY: |
7437 | 0 | if (!ether_addr_equal(data->driver_gtk_rekey.bssid, |
7438 | 0 | wpa_s->bssid)) |
7439 | 0 | break; |
7440 | 0 | if (!wpa_s->wpa) |
7441 | 0 | break; |
7442 | 0 | wpa_sm_update_replay_ctr(wpa_s->wpa, |
7443 | 0 | data->driver_gtk_rekey.replay_ctr); |
7444 | 0 | break; |
7445 | 0 | case EVENT_SCHED_SCAN_STOPPED: |
7446 | 0 | wpa_s->sched_scanning = 0; |
7447 | 0 | resched = wpa_s->scanning && wpas_scan_scheduled(wpa_s); |
7448 | 0 | wpa_supplicant_notify_scanning(wpa_s, 0); |
7449 | |
|
7450 | 0 | if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) |
7451 | 0 | break; |
7452 | | |
7453 | | /* |
7454 | | * If the driver stopped scanning without being requested to, |
7455 | | * request a new scan to continue scanning for networks. |
7456 | | */ |
7457 | 0 | if (!wpa_s->sched_scan_stop_req && |
7458 | 0 | wpa_s->wpa_state == WPA_SCANNING) { |
7459 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
7460 | 0 | "Restart scanning after unexpected sched_scan stop event"); |
7461 | 0 | wpa_supplicant_req_scan(wpa_s, 1, 0); |
7462 | 0 | break; |
7463 | 0 | } |
7464 | | |
7465 | 0 | wpa_s->sched_scan_stop_req = 0; |
7466 | | |
7467 | | /* |
7468 | | * Start a new sched scan to continue searching for more SSIDs |
7469 | | * either if timed out or PNO schedule scan is pending. |
7470 | | */ |
7471 | 0 | if (wpa_s->sched_scan_timed_out) { |
7472 | 0 | wpa_supplicant_req_sched_scan(wpa_s); |
7473 | 0 | } else if (wpa_s->pno_sched_pending) { |
7474 | 0 | wpa_s->pno_sched_pending = 0; |
7475 | 0 | wpas_start_pno(wpa_s); |
7476 | 0 | } else if (resched) { |
7477 | 0 | wpa_supplicant_req_scan(wpa_s, 0, 0); |
7478 | 0 | } |
7479 | |
|
7480 | 0 | break; |
7481 | 0 | case EVENT_WPS_BUTTON_PUSHED: |
7482 | | #ifdef CONFIG_WPS |
7483 | | wpas_wps_start_pbc(wpa_s, NULL, 0, 0); |
7484 | | #endif /* CONFIG_WPS */ |
7485 | 0 | break; |
7486 | 0 | case EVENT_AVOID_FREQUENCIES: |
7487 | 0 | wpa_supplicant_notify_avoid_freq(wpa_s, data); |
7488 | 0 | break; |
7489 | 0 | case EVENT_CONNECT_FAILED_REASON: |
7490 | | #ifdef CONFIG_AP |
7491 | | if (!wpa_s->ap_iface || !data) |
7492 | | break; |
7493 | | hostapd_event_connect_failed_reason( |
7494 | | wpa_s->ap_iface->bss[0], |
7495 | | data->connect_failed_reason.addr, |
7496 | | data->connect_failed_reason.code); |
7497 | | #endif /* CONFIG_AP */ |
7498 | 0 | break; |
7499 | 0 | case EVENT_NEW_PEER_CANDIDATE: |
7500 | | #ifdef CONFIG_MESH |
7501 | | if (!wpa_s->ifmsh || !data) |
7502 | | break; |
7503 | | wpa_mesh_notify_peer(wpa_s, data->mesh_peer.peer, |
7504 | | data->mesh_peer.ies, |
7505 | | data->mesh_peer.ie_len); |
7506 | | #endif /* CONFIG_MESH */ |
7507 | 0 | break; |
7508 | 0 | case EVENT_SURVEY: |
7509 | | #ifdef CONFIG_AP |
7510 | | if (!wpa_s->ap_iface) |
7511 | | break; |
7512 | | hostapd_event_get_survey(wpa_s->ap_iface, |
7513 | | &data->survey_results); |
7514 | | #endif /* CONFIG_AP */ |
7515 | 0 | break; |
7516 | 0 | case EVENT_ACS_CHANNEL_SELECTED: |
7517 | | #ifdef CONFIG_AP |
7518 | | #ifdef CONFIG_ACS |
7519 | | if (!wpa_s->ap_iface) |
7520 | | break; |
7521 | | hostapd_acs_channel_selected(wpa_s->ap_iface->bss[0], |
7522 | | &data->acs_selected_channels); |
7523 | | #endif /* CONFIG_ACS */ |
7524 | | #endif /* CONFIG_AP */ |
7525 | 0 | break; |
7526 | 0 | case EVENT_P2P_LO_STOP: |
7527 | | #ifdef CONFIG_P2P |
7528 | | wpa_s->p2p_lo_started = 0; |
7529 | | wpa_msg(wpa_s, MSG_INFO, P2P_EVENT_LISTEN_OFFLOAD_STOP |
7530 | | P2P_LISTEN_OFFLOAD_STOP_REASON "reason=%d", |
7531 | | data->p2p_lo_stop.reason_code); |
7532 | | #endif /* CONFIG_P2P */ |
7533 | 0 | break; |
7534 | 0 | case EVENT_BEACON_LOSS: |
7535 | 0 | if (!wpa_s->current_bss || !wpa_s->current_ssid) |
7536 | 0 | break; |
7537 | 0 | wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_BEACON_LOSS); |
7538 | 0 | bgscan_notify_beacon_loss(wpa_s); |
7539 | 0 | break; |
7540 | 0 | case EVENT_EXTERNAL_AUTH: |
7541 | | #ifdef CONFIG_SAE |
7542 | | if (!wpa_s->current_ssid) { |
7543 | | wpa_printf(MSG_DEBUG, "SAE: current_ssid is NULL"); |
7544 | | break; |
7545 | | } |
7546 | | sme_external_auth_trigger(wpa_s, data); |
7547 | | #endif /* CONFIG_SAE */ |
7548 | 0 | break; |
7549 | | #ifdef CONFIG_PASN |
7550 | | case EVENT_PASN_AUTH: |
7551 | | wpas_pasn_auth_trigger(wpa_s, &data->pasn_auth); |
7552 | | break; |
7553 | | #endif /* CONFIG_PASN */ |
7554 | 0 | case EVENT_PORT_AUTHORIZED: |
7555 | | #ifdef CONFIG_AP |
7556 | | if (wpa_s->ap_iface && wpa_s->ap_iface->bss[0]) { |
7557 | | struct sta_info *sta; |
7558 | | |
7559 | | sta = ap_get_sta(wpa_s->ap_iface->bss[0], |
7560 | | data->port_authorized.sta_addr); |
7561 | | if (sta) |
7562 | | ap_sta_set_authorized(wpa_s->ap_iface->bss[0], |
7563 | | sta, 1); |
7564 | | else |
7565 | | wpa_printf(MSG_DEBUG, |
7566 | | "No STA info matching port authorized event found"); |
7567 | | break; |
7568 | | } |
7569 | | #endif /* CONFIG_AP */ |
7570 | 0 | #ifndef CONFIG_NO_WPA |
7571 | 0 | if (data->port_authorized.td_bitmap_len) { |
7572 | 0 | wpa_printf(MSG_DEBUG, |
7573 | 0 | "WPA3: Transition Disable bitmap from the driver event: 0x%x", |
7574 | 0 | data->port_authorized.td_bitmap[0]); |
7575 | 0 | wpas_transition_disable( |
7576 | 0 | wpa_s, data->port_authorized.td_bitmap[0]); |
7577 | 0 | } |
7578 | 0 | #endif /* CONFIG_NO_WPA */ |
7579 | 0 | wpa_supplicant_event_port_authorized(wpa_s); |
7580 | 0 | break; |
7581 | 0 | case EVENT_STATION_OPMODE_CHANGED: |
7582 | | #ifdef CONFIG_AP |
7583 | | if (!wpa_s->ap_iface || !data) |
7584 | | break; |
7585 | | |
7586 | | hostapd_event_sta_opmode_changed(wpa_s->ap_iface->bss[0], |
7587 | | data->sta_opmode.addr, |
7588 | | data->sta_opmode.smps_mode, |
7589 | | data->sta_opmode.chan_width, |
7590 | | data->sta_opmode.rx_nss); |
7591 | | #endif /* CONFIG_AP */ |
7592 | 0 | break; |
7593 | 0 | case EVENT_UNPROT_BEACON: |
7594 | 0 | wpas_event_unprot_beacon(wpa_s, &data->unprot_beacon); |
7595 | 0 | break; |
7596 | 0 | case EVENT_TX_WAIT_EXPIRE: |
7597 | | #ifdef CONFIG_DPP |
7598 | | wpas_dpp_tx_wait_expire(wpa_s); |
7599 | | #endif /* CONFIG_DPP */ |
7600 | 0 | wpas_nan_usd_tx_wait_expire(wpa_s); |
7601 | 0 | break; |
7602 | 0 | case EVENT_TID_LINK_MAP: |
7603 | 0 | if (data) |
7604 | 0 | wpas_tid_link_map(wpa_s, &data->t2l_map_info); |
7605 | 0 | break; |
7606 | 0 | case EVENT_SETUP_LINK_RECONFIG: |
7607 | 0 | if (data) |
7608 | 0 | wpas_setup_link_reconfig(wpa_s, &data->reconfig_info); |
7609 | 0 | break; |
7610 | | #ifdef CONFIG_NAN |
7611 | | case EVENT_NAN_CLUSTER_JOIN: |
7612 | | wpas_nan_cluster_join(wpa_s, data->nan_cluster_join_info.bssid, |
7613 | | data->nan_cluster_join_info.new_cluster); |
7614 | | break; |
7615 | | case EVENT_NAN_NEXT_DW: |
7616 | | wpas_nan_next_dw(wpa_s, data->nan_next_dw_info.freq); |
7617 | | break; |
7618 | | #endif /* CONFIG_NAN */ |
7619 | 0 | default: |
7620 | 0 | wpa_msg(wpa_s, MSG_INFO, "Unknown event %d", event); |
7621 | 0 | break; |
7622 | 0 | } |
7623 | 0 | } |
7624 | | |
7625 | | |
7626 | | void wpa_supplicant_event_global(void *ctx, enum wpa_event_type event, |
7627 | | union wpa_event_data *data) |
7628 | 0 | { |
7629 | 0 | struct wpa_supplicant *wpa_s; |
7630 | |
|
7631 | 0 | if (event != EVENT_INTERFACE_STATUS) |
7632 | 0 | return; |
7633 | | |
7634 | 0 | wpa_s = wpa_supplicant_get_iface(ctx, data->interface_status.ifname); |
7635 | 0 | if (wpa_s && wpa_s->driver->get_ifindex) { |
7636 | 0 | unsigned int ifindex; |
7637 | |
|
7638 | 0 | ifindex = wpa_s->driver->get_ifindex(wpa_s->drv_priv); |
7639 | 0 | if (ifindex != data->interface_status.ifindex) { |
7640 | 0 | wpa_dbg(wpa_s, MSG_DEBUG, |
7641 | 0 | "interface status ifindex %d mismatch (%d)", |
7642 | 0 | ifindex, data->interface_status.ifindex); |
7643 | 0 | return; |
7644 | 0 | } |
7645 | 0 | } |
7646 | | #ifdef CONFIG_MATCH_IFACE |
7647 | | else if (data->interface_status.ievent == EVENT_INTERFACE_ADDED) { |
7648 | | struct wpa_interface *wpa_i; |
7649 | | |
7650 | | wpa_i = wpa_supplicant_match_iface( |
7651 | | ctx, data->interface_status.ifname); |
7652 | | if (!wpa_i) |
7653 | | return; |
7654 | | wpa_s = wpa_supplicant_add_iface(ctx, wpa_i, NULL); |
7655 | | os_free(wpa_i); |
7656 | | } |
7657 | | #endif /* CONFIG_MATCH_IFACE */ |
7658 | | |
7659 | 0 | if (wpa_s) |
7660 | 0 | wpa_supplicant_event(wpa_s, event, data); |
7661 | 0 | } |