Lines Matching refs:wpa_s
28 static void wpa_supplicant_gen_assoc_event(struct wpa_supplicant *wpa_s) in wpa_supplicant_gen_assoc_event() argument
33 ssid = wpa_supplicant_get_ssid(wpa_s); in wpa_supplicant_gen_assoc_event()
37 if (wpa_s->current_ssid == NULL) { in wpa_supplicant_gen_assoc_event()
38 wpa_s->current_ssid = ssid; in wpa_supplicant_gen_assoc_event()
39 wpas_notify_network_changed(wpa_s); in wpa_supplicant_gen_assoc_event()
41 wpa_supplicant_initiate_eapol(wpa_s); in wpa_supplicant_gen_assoc_event()
42 wpa_dbg(wpa_s, MSG_DEBUG, "Already associated with a configured " in wpa_supplicant_gen_assoc_event()
45 wpa_supplicant_event(wpa_s, EVENT_ASSOC, &data); in wpa_supplicant_gen_assoc_event()
50 static int wpas_wps_in_use(struct wpa_supplicant *wpa_s, in wpas_wps_in_use() argument
56 for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next) { in wpas_wps_in_use()
67 if (!wpa_s->global->p2p_disabled && wpa_s->global->p2p && in wpas_wps_in_use()
68 !wpa_s->conf->p2p_disabled) { in wpas_wps_in_use()
69 wpa_s->wps->dev.p2p = 1; in wpas_wps_in_use()
118 int wpa_supplicant_enabled_networks(struct wpa_supplicant *wpa_s) in wpa_supplicant_enabled_networks() argument
120 struct wpa_ssid *ssid = wpa_s->conf->ssid; in wpa_supplicant_enabled_networks()
123 if (wpa_s->p2p_mgmt) in wpa_supplicant_enabled_networks()
127 if (!wpas_network_disabled(wpa_s, ssid)) in wpa_supplicant_enabled_networks()
133 if (wpa_s->conf->cred && wpa_s->conf->interworking && in wpa_supplicant_enabled_networks()
134 wpa_s->conf->auto_interworking) in wpa_supplicant_enabled_networks()
137 wpa_dbg(wpa_s, MSG_DEBUG, "No enabled networks (%d disabled " in wpa_supplicant_enabled_networks()
144 static void wpa_supplicant_assoc_try(struct wpa_supplicant *wpa_s, in wpa_supplicant_assoc_try() argument
150 if (!wpas_network_disabled(wpa_s, ssid)) { in wpa_supplicant_assoc_try()
151 int temp_disabled = wpas_temp_disabled(wpa_s, ssid); in wpa_supplicant_assoc_try()
165 wpa_dbg(wpa_s, MSG_DEBUG, "wpa_supplicant_assoc_try: Reached " in wpa_supplicant_assoc_try()
167 wpa_s->prev_scan_ssid = WILDCARD_SSID_SCAN; in wpa_supplicant_assoc_try()
168 wpa_supplicant_req_scan(wpa_s, min_temp_disabled, 0); in wpa_supplicant_assoc_try()
173 wpa_s->prev_scan_ssid = ssid; in wpa_supplicant_assoc_try()
176 wpa_s->prev_scan_ssid = WILDCARD_SSID_SCAN; in wpa_supplicant_assoc_try()
178 wpa_supplicant_associate(wpa_s, NULL, ssid); in wpa_supplicant_assoc_try()
184 struct wpa_supplicant *wpa_s = work->wpa_s; in wpas_trigger_scan_cb() local
193 wpa_supplicant_notify_scanning(wpa_s, 0); in wpas_trigger_scan_cb()
194 wpas_notify_scan_done(wpa_s, 0); in wpas_trigger_scan_cb()
195 wpa_s->scan_work = NULL; in wpas_trigger_scan_cb()
199 if ((wpa_s->mac_addr_rand_enable & MAC_ADDR_RAND_SCAN) && in wpas_trigger_scan_cb()
200 wpa_s->wpa_state <= WPA_SCANNING) in wpas_trigger_scan_cb()
201 wpa_setup_mac_addr_rand_params(params, wpa_s->mac_addr_scan); in wpas_trigger_scan_cb()
203 if (wpas_update_random_addr_disassoc(wpa_s) < 0) { in wpas_trigger_scan_cb()
204 wpa_msg(wpa_s, MSG_INFO, in wpas_trigger_scan_cb()
207 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_SCAN_FAILED "ret=-1"); in wpas_trigger_scan_cb()
212 wpa_supplicant_notify_scanning(wpa_s, 1); in wpas_trigger_scan_cb()
214 if (wpa_s->clear_driver_scan_cache) { in wpas_trigger_scan_cb()
219 ret = wpa_drv_scan(wpa_s, params); in wpas_trigger_scan_cb()
230 wpa_s->curr_scan_cookie = params->scan_cookie; in wpas_trigger_scan_cb()
234 int retry = wpa_s->last_scan_req != MANUAL_SCAN_REQ && in wpas_trigger_scan_cb()
235 !wpa_s->beacon_rep_data.token; in wpas_trigger_scan_cb()
237 if (wpa_s->disconnected) in wpas_trigger_scan_cb()
244 wpa_supplicant_notify_scanning(wpa_s, 0); in wpas_trigger_scan_cb()
245 wpas_notify_scan_done(wpa_s, 0); in wpas_trigger_scan_cb()
246 if (wpa_s->wpa_state == WPA_SCANNING) in wpas_trigger_scan_cb()
247 wpa_supplicant_set_state(wpa_s, in wpas_trigger_scan_cb()
248 wpa_s->scan_prev_wpa_state); in wpas_trigger_scan_cb()
249 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_SCAN_FAILED "ret=%d%s", in wpas_trigger_scan_cb()
255 wpa_s->scan_req = wpa_s->last_scan_req; in wpas_trigger_scan_cb()
256 wpa_supplicant_req_scan(wpa_s, 1, 0); in wpas_trigger_scan_cb()
257 } else if (wpa_s->scan_res_handler) { in wpas_trigger_scan_cb()
259 wpa_s->scan_res_handler = NULL; in wpas_trigger_scan_cb()
262 if (wpa_s->beacon_rep_data.token) in wpas_trigger_scan_cb()
263 wpas_rrm_refuse_request(wpa_s); in wpas_trigger_scan_cb()
268 os_get_reltime(&wpa_s->scan_trigger_time); in wpas_trigger_scan_cb()
269 wpa_s->scan_runs++; in wpas_trigger_scan_cb()
270 wpa_s->normal_scans++; in wpas_trigger_scan_cb()
271 wpa_s->own_scan_requested = 1; in wpas_trigger_scan_cb()
272 wpa_s->clear_driver_scan_cache = 0; in wpas_trigger_scan_cb()
273 wpa_s->scan_work = work; in wpas_trigger_scan_cb()
283 int wpa_supplicant_trigger_scan(struct wpa_supplicant *wpa_s, in wpa_supplicant_trigger_scan() argument
288 if (wpa_s->scan_work) { in wpa_supplicant_trigger_scan()
289 wpa_dbg(wpa_s, MSG_INFO, "Reject scan trigger since one is already pending"); in wpa_supplicant_trigger_scan()
295 radio_add_work(wpa_s, 0, "scan", 0, wpas_trigger_scan_cb, ctx) < 0) in wpa_supplicant_trigger_scan()
298 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_SCAN_FAILED "ret=-1"); in wpa_supplicant_trigger_scan()
309 struct wpa_supplicant *wpa_s = eloop_ctx; in wpa_supplicant_delayed_sched_scan_timeout() local
311 wpa_dbg(wpa_s, MSG_DEBUG, "Starting delayed sched scan"); in wpa_supplicant_delayed_sched_scan_timeout()
313 if (wpa_supplicant_req_sched_scan(wpa_s)) in wpa_supplicant_delayed_sched_scan_timeout()
314 wpa_supplicant_req_scan(wpa_s, 0, 0); in wpa_supplicant_delayed_sched_scan_timeout()
321 struct wpa_supplicant *wpa_s = eloop_ctx; in wpa_supplicant_sched_scan_timeout() local
323 wpa_dbg(wpa_s, MSG_DEBUG, "Sched scan timeout - stopping it"); in wpa_supplicant_sched_scan_timeout()
325 wpa_s->sched_scan_timed_out = 1; in wpa_supplicant_sched_scan_timeout()
326 wpa_supplicant_cancel_sched_scan(wpa_s); in wpa_supplicant_sched_scan_timeout()
331 wpa_supplicant_start_sched_scan(struct wpa_supplicant *wpa_s, in wpa_supplicant_start_sched_scan() argument
336 wpa_supplicant_notify_scanning(wpa_s, 1); in wpa_supplicant_start_sched_scan()
337 ret = wpa_drv_sched_scan(wpa_s, params); in wpa_supplicant_start_sched_scan()
339 wpa_supplicant_notify_scanning(wpa_s, 0); in wpa_supplicant_start_sched_scan()
341 wpa_s->sched_scanning = 1; in wpa_supplicant_start_sched_scan()
347 static int wpa_supplicant_stop_sched_scan(struct wpa_supplicant *wpa_s) in wpa_supplicant_stop_sched_scan() argument
351 ret = wpa_drv_stop_sched_scan(wpa_s); in wpa_supplicant_stop_sched_scan()
353 wpa_dbg(wpa_s, MSG_DEBUG, "stopping sched_scan failed!"); in wpa_supplicant_stop_sched_scan()
396 struct wpa_supplicant *wpa_s, struct wpa_driver_scan_params *params) in wpa_supplicant_optimize_freqs() argument
399 if (params->freqs == NULL && wpa_s->p2p_in_provisioning && in wpa_supplicant_optimize_freqs()
400 wpa_s->go_params) { in wpa_supplicant_optimize_freqs()
402 if (wpa_s->p2p_in_provisioning < 5 && in wpa_supplicant_optimize_freqs()
403 wpa_s->go_params->freq > 0) { in wpa_supplicant_optimize_freqs()
404 wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Scan only GO " in wpa_supplicant_optimize_freqs()
406 wpa_s->go_params->freq); in wpa_supplicant_optimize_freqs()
409 params->freqs[0] = wpa_s->go_params->freq; in wpa_supplicant_optimize_freqs()
410 } else if (wpa_s->p2p_in_provisioning < 8 && in wpa_supplicant_optimize_freqs()
411 wpa_s->go_params->freq_list[0]) { in wpa_supplicant_optimize_freqs()
412 wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Scan only common " in wpa_supplicant_optimize_freqs()
415 wpa_s->go_params->freq_list); in wpa_supplicant_optimize_freqs()
419 wpa_s->p2p_in_provisioning++; in wpa_supplicant_optimize_freqs()
422 if (params->freqs == NULL && wpa_s->p2p_in_invitation) { in wpa_supplicant_optimize_freqs()
427 if (wpa_s->p2p_in_invitation < 5 && in wpa_supplicant_optimize_freqs()
428 wpa_s->p2p_invite_go_freq > 0) { in wpa_supplicant_optimize_freqs()
429 wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Scan only GO preferred frequency %d MHz during invitation", in wpa_supplicant_optimize_freqs()
430 wpa_s->p2p_invite_go_freq); in wpa_supplicant_optimize_freqs()
433 params->freqs[0] = wpa_s->p2p_invite_go_freq; in wpa_supplicant_optimize_freqs()
435 wpa_s->p2p_in_invitation++; in wpa_supplicant_optimize_freqs()
436 if (wpa_s->p2p_in_invitation > 20) { in wpa_supplicant_optimize_freqs()
443 wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Clear p2p_in_invitation"); in wpa_supplicant_optimize_freqs()
444 wpa_s->p2p_in_invitation = 0; in wpa_supplicant_optimize_freqs()
450 if (params->freqs == NULL && wpa_s->after_wps && wpa_s->wps_freq) { in wpa_supplicant_optimize_freqs()
455 wpa_dbg(wpa_s, MSG_DEBUG, "WPS: Scan only frequency %u MHz " in wpa_supplicant_optimize_freqs()
456 "that was used during provisioning", wpa_s->wps_freq); in wpa_supplicant_optimize_freqs()
459 params->freqs[0] = wpa_s->wps_freq; in wpa_supplicant_optimize_freqs()
460 wpa_s->after_wps--; in wpa_supplicant_optimize_freqs()
461 } else if (wpa_s->after_wps) in wpa_supplicant_optimize_freqs()
462 wpa_s->after_wps--; in wpa_supplicant_optimize_freqs()
464 if (params->freqs == NULL && wpa_s->known_wps_freq && wpa_s->wps_freq) in wpa_supplicant_optimize_freqs()
467 wpa_dbg(wpa_s, MSG_DEBUG, "WPS: Scan only frequency %u MHz", in wpa_supplicant_optimize_freqs()
468 wpa_s->wps_freq); in wpa_supplicant_optimize_freqs()
471 params->freqs[0] = wpa_s->wps_freq; in wpa_supplicant_optimize_freqs()
472 wpa_s->known_wps_freq = 0; /* only do this once */ in wpa_supplicant_optimize_freqs()
479 static void wpas_add_interworking_elements(struct wpa_supplicant *wpa_s, in wpas_add_interworking_elements() argument
483 wpabuf_put_u8(buf, is_zero_ether_addr(wpa_s->conf->hessid) ? 1 : in wpas_add_interworking_elements()
485 wpabuf_put_u8(buf, wpa_s->conf->access_network_type); in wpas_add_interworking_elements()
487 if (!is_zero_ether_addr(wpa_s->conf->hessid)) in wpas_add_interworking_elements()
488 wpabuf_put_data(buf, wpa_s->conf->hessid, ETH_ALEN); in wpas_add_interworking_elements()
494 static void wpas_fils_req_param_add_max_channel(struct wpa_supplicant *wpa_s, in wpas_fils_req_param_add_max_channel() argument
520 void wpa_supplicant_set_default_scan_ies(struct wpa_supplicant *wpa_s) in wpa_supplicant_set_default_scan_ies() argument
528 if (wpa_s->p2p_group_interface == P2P_GROUP_INTERFACE_CLIENT) in wpa_supplicant_set_default_scan_ies()
532 wpa_drv_get_ext_capa(wpa_s, type); in wpa_supplicant_set_default_scan_ies()
534 ext_capab_len = wpas_build_ext_capab(wpa_s, ext_capab, in wpa_supplicant_set_default_scan_ies()
541 if (wpa_s->enable_oce & OCE_STA) in wpa_supplicant_set_default_scan_ies()
542 wpas_fils_req_param_add_max_channel(wpa_s, &default_ies); in wpa_supplicant_set_default_scan_ies()
545 wpas_mbo_scan_ie(wpa_s, default_ies); in wpa_supplicant_set_default_scan_ies()
553 if (wpa_s->vendor_elem[frame_id]) { in wpa_supplicant_set_default_scan_ies()
556 len = wpabuf_len(wpa_s->vendor_elem[frame_id]); in wpa_supplicant_set_default_scan_ies()
559 wpa_s->vendor_elem[frame_id]); in wpa_supplicant_set_default_scan_ies()
563 wpa_drv_set_default_scan_ies(wpa_s, wpabuf_head(default_ies), in wpa_supplicant_set_default_scan_ies()
569 static struct wpabuf * wpa_supplicant_extra_ies(struct wpa_supplicant *wpa_s) in wpa_supplicant_extra_ies() argument
580 if (wpa_s->p2p_group_interface == P2P_GROUP_INTERFACE_CLIENT) in wpa_supplicant_extra_ies()
581 wpa_drv_get_ext_capa(wpa_s, WPA_IF_P2P_CLIENT); in wpa_supplicant_extra_ies()
584 wpa_drv_get_ext_capa(wpa_s, WPA_IF_STATION); in wpa_supplicant_extra_ies()
586 ext_capab_len = wpas_build_ext_capab(wpa_s, ext_capab, in wpa_supplicant_extra_ies()
593 if (wpa_s->conf->interworking && in wpa_supplicant_extra_ies()
595 wpas_add_interworking_elements(wpa_s, extra_ie); in wpa_supplicant_extra_ies()
599 if (wpa_s->enable_oce & OCE_STA) in wpa_supplicant_extra_ies()
600 wpas_fils_req_param_add_max_channel(wpa_s, &extra_ie); in wpa_supplicant_extra_ies()
604 wps = wpas_wps_in_use(wpa_s, &req_type); in wpa_supplicant_extra_ies()
610 &wpa_s->wps->dev, in wpa_supplicant_extra_ies()
611 wpa_s->wps->uuid, req_type, in wpa_supplicant_extra_ies()
622 size_t ielen = p2p_scan_ie_buf_len(wpa_s->global->p2p); in wpa_supplicant_extra_ies()
624 wpas_p2p_scan_ie(wpa_s, extra_ie); in wpa_supplicant_extra_ies()
628 wpa_supplicant_mesh_add_scan_ie(wpa_s, &extra_ie); in wpa_supplicant_extra_ies()
633 if (wpa_s->conf->hs20 && wpabuf_resize(&extra_ie, 9) == 0) in wpa_supplicant_extra_ies()
638 if (wpa_s->fst_ies && in wpa_supplicant_extra_ies()
639 wpabuf_resize(&extra_ie, wpabuf_len(wpa_s->fst_ies)) == 0) in wpa_supplicant_extra_ies()
640 wpabuf_put_buf(extra_ie, wpa_s->fst_ies); in wpa_supplicant_extra_ies()
646 wpas_mbo_scan_ie(wpa_s, extra_ie); in wpa_supplicant_extra_ies()
649 if (wpa_s->vendor_elem[VENDOR_ELEM_PROBE_REQ]) { in wpa_supplicant_extra_ies()
650 struct wpabuf *buf = wpa_s->vendor_elem[VENDOR_ELEM_PROBE_REQ]; in wpa_supplicant_extra_ies()
666 static int non_p2p_network_enabled(struct wpa_supplicant *wpa_s) in non_p2p_network_enabled() argument
670 for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next) { in non_p2p_network_enabled()
671 if (wpas_network_disabled(wpa_s, ssid)) in non_p2p_network_enabled()
677 if (wpa_s->conf->cred && wpa_s->conf->interworking && in non_p2p_network_enabled()
678 wpa_s->conf->auto_interworking) in non_p2p_network_enabled()
687 int wpa_add_scan_freqs_list(struct wpa_supplicant *wpa_s, in wpa_add_scan_freqs_list() argument
696 mode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes, band, is_6ghz); in wpa_add_scan_freqs_list()
722 static void wpa_setband_scan_freqs(struct wpa_supplicant *wpa_s, in wpa_setband_scan_freqs() argument
725 if (wpa_s->hw.modes == NULL) in wpa_setband_scan_freqs()
730 if (wpa_s->setband_mask & WPA_SETBAND_5G) in wpa_setband_scan_freqs()
731 wpa_add_scan_freqs_list(wpa_s, HOSTAPD_MODE_IEEE80211A, params, in wpa_setband_scan_freqs()
733 if (wpa_s->setband_mask & WPA_SETBAND_2G) in wpa_setband_scan_freqs()
734 wpa_add_scan_freqs_list(wpa_s, HOSTAPD_MODE_IEEE80211G, params, in wpa_setband_scan_freqs()
736 if (wpa_s->setband_mask & WPA_SETBAND_6G) in wpa_setband_scan_freqs()
737 wpa_add_scan_freqs_list(wpa_s, HOSTAPD_MODE_IEEE80211A, params, in wpa_setband_scan_freqs()
742 static void wpa_add_scan_ssid(struct wpa_supplicant *wpa_s, in wpa_add_scan_ssid() argument
769 static void wpa_add_owe_scan_ssid(struct wpa_supplicant *wpa_s, in wpa_add_owe_scan_ssid() argument
782 dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) { in wpa_add_owe_scan_ssid()
815 wpa_add_scan_ssid(wpa_s, params, max_ssids, in wpa_add_owe_scan_ssid()
823 static void wpa_set_scan_ssids(struct wpa_supplicant *wpa_s, in wpa_set_scan_ssids() argument
836 for (i = 0; i < wpa_s->scan_id_count; i++) { in wpa_set_scan_ssids()
837 ssid = wpa_config_get_network(wpa_s->conf, wpa_s->scan_id[i]); in wpa_set_scan_ssids()
841 wpa_add_scan_ssid(wpa_s, params, max_ssids, in wpa_set_scan_ssids()
847 wpa_add_owe_scan_ssid(wpa_s, params, ssid, max_ssids); in wpa_set_scan_ssids()
850 wpa_s->scan_id_count = 0; in wpa_set_scan_ssids()
854 static int wpa_set_ssids_from_scan_req(struct wpa_supplicant *wpa_s, in wpa_set_ssids_from_scan_req() argument
860 if (wpa_s->ssids_from_scan_req == NULL || in wpa_set_ssids_from_scan_req()
861 wpa_s->num_ssids_from_scan_req == 0) in wpa_set_ssids_from_scan_req()
864 if (wpa_s->num_ssids_from_scan_req > max_ssids) { in wpa_set_ssids_from_scan_req()
865 wpa_s->num_ssids_from_scan_req = max_ssids; in wpa_set_ssids_from_scan_req()
870 for (i = 0; i < wpa_s->num_ssids_from_scan_req; i++) { in wpa_set_ssids_from_scan_req()
871 params->ssids[i].ssid = wpa_s->ssids_from_scan_req[i].ssid; in wpa_set_ssids_from_scan_req()
873 wpa_s->ssids_from_scan_req[i].ssid_len; in wpa_set_ssids_from_scan_req()
879 params->num_ssids = wpa_s->num_ssids_from_scan_req; in wpa_set_ssids_from_scan_req()
880 wpa_s->num_ssids_from_scan_req = 0; in wpa_set_ssids_from_scan_req()
887 struct wpa_supplicant *wpa_s = eloop_ctx; in wpa_supplicant_scan() local
896 wpa_s->ignore_post_flush_scan_res = 0; in wpa_supplicant_scan()
898 if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) { in wpa_supplicant_scan()
899 wpa_dbg(wpa_s, MSG_DEBUG, "Skip scan - interface disabled"); in wpa_supplicant_scan()
903 if (wpa_s->disconnected && wpa_s->scan_req == NORMAL_SCAN_REQ) { in wpa_supplicant_scan()
904 wpa_dbg(wpa_s, MSG_DEBUG, "Disconnected - do not scan"); in wpa_supplicant_scan()
905 wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED); in wpa_supplicant_scan()
909 if (wpa_s->scanning) { in wpa_supplicant_scan()
914 wpa_dbg(wpa_s, MSG_DEBUG, "Already scanning - Reschedule the incoming scan req"); in wpa_supplicant_scan()
915 wpa_supplicant_req_scan(wpa_s, 1, 0); in wpa_supplicant_scan()
919 if (!wpa_supplicant_enabled_networks(wpa_s) && in wpa_supplicant_scan()
920 wpa_s->scan_req == NORMAL_SCAN_REQ) { in wpa_supplicant_scan()
921 wpa_dbg(wpa_s, MSG_DEBUG, "No enabled networks - do not scan"); in wpa_supplicant_scan()
922 wpa_supplicant_set_state(wpa_s, WPA_INACTIVE); in wpa_supplicant_scan()
926 if (wpa_s->conf->ap_scan != 0 && in wpa_supplicant_scan()
927 (wpa_s->drv_flags & WPA_DRIVER_FLAGS_WIRED)) { in wpa_supplicant_scan()
928 wpa_dbg(wpa_s, MSG_DEBUG, "Using wired authentication - " in wpa_supplicant_scan()
930 wpa_s->conf->ap_scan = 0; in wpa_supplicant_scan()
931 wpas_notify_ap_scan_changed(wpa_s); in wpa_supplicant_scan()
934 if (wpa_s->conf->ap_scan == 0) { in wpa_supplicant_scan()
935 wpa_supplicant_gen_assoc_event(wpa_s); in wpa_supplicant_scan()
940 if (wpa_s->scan_req != MANUAL_SCAN_REQ && in wpa_supplicant_scan()
941 wpa_s->connect_without_scan) { in wpa_supplicant_scan()
943 for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next) { in wpa_supplicant_scan()
944 if (ssid == wpa_s->connect_without_scan) in wpa_supplicant_scan()
949 p2p_in_prog = wpas_p2p_in_progress(wpa_s); in wpa_supplicant_scan()
953 wpa_dbg(wpa_s, MSG_DEBUG, "Delay station mode scan while P2P operation is in progress"); in wpa_supplicant_scan()
954 wpa_supplicant_req_scan(wpa_s, 5, 0); in wpa_supplicant_scan()
967 if (wpa_s->pno || wpa_s->pno_sched_pending) { in wpa_supplicant_scan()
968 wpa_dbg(wpa_s, MSG_DEBUG, "Defer scan - PNO is in progress"); in wpa_supplicant_scan()
969 wpa_supplicant_req_scan(wpa_s, 0, 100000); in wpa_supplicant_scan()
973 if (wpa_s->conf->ap_scan == 2) in wpa_supplicant_scan()
976 max_ssids = wpa_s->max_scan_ssids; in wpa_supplicant_scan()
981 wpa_s->last_scan_req = wpa_s->scan_req; in wpa_supplicant_scan()
982 wpa_s->scan_req = NORMAL_SCAN_REQ; in wpa_supplicant_scan()
985 wpa_s->connect_without_scan = NULL; in wpa_supplicant_scan()
989 wpa_supplicant_associate(wpa_s, NULL, ssid); in wpa_supplicant_scan()
996 wpa_s->scan_prev_wpa_state = wpa_s->wpa_state; in wpa_supplicant_scan()
997 if (wpa_s->wpa_state == WPA_DISCONNECTED || in wpa_supplicant_scan()
998 wpa_s->wpa_state == WPA_INACTIVE) in wpa_supplicant_scan()
999 wpa_supplicant_set_state(wpa_s, WPA_SCANNING); in wpa_supplicant_scan()
1004 if (wpa_s->autoscan_params != NULL) { in wpa_supplicant_scan()
1005 scan_params = wpa_s->autoscan_params; in wpa_supplicant_scan()
1009 if (wpa_s->last_scan_req == MANUAL_SCAN_REQ && in wpa_supplicant_scan()
1010 wpa_set_ssids_from_scan_req(wpa_s, ¶ms, max_ssids)) { in wpa_supplicant_scan()
1017 if (wpa_s->global->p2p_go_found_external_scan && in wpa_supplicant_scan()
1018 (wpa_s->p2p_group_interface == P2P_GROUP_INTERFACE_CLIENT) && in wpa_supplicant_scan()
1019 (wpa_s->global->p2p_group_formation == wpa_s)) { in wpa_supplicant_scan()
1020 wpa_dbg(wpa_s, MSG_DEBUG, in wpa_supplicant_scan()
1022 wpa_s->global->p2p_go_found_external_scan = 0; in wpa_supplicant_scan()
1023 if (wpa_supplicant_fast_associate(wpa_s) >= 0) { in wpa_supplicant_scan()
1029 if ((wpa_s->p2p_in_provisioning || wpa_s->show_group_started) && in wpa_supplicant_scan()
1030 wpa_s->go_params && !wpa_s->conf->passive_scan) { in wpa_supplicant_scan()
1032 wpa_s->p2p_in_provisioning, in wpa_supplicant_scan()
1033 wpa_s->show_group_started); in wpa_supplicant_scan()
1034 params.ssids[0].ssid = wpa_s->go_params->ssid; in wpa_supplicant_scan()
1035 params.ssids[0].ssid_len = wpa_s->go_params->ssid_len; in wpa_supplicant_scan()
1040 if (wpa_s->p2p_in_invitation) { in wpa_supplicant_scan()
1041 if (wpa_s->current_ssid) { in wpa_supplicant_scan()
1043 params.ssids[0].ssid = wpa_s->current_ssid->ssid; in wpa_supplicant_scan()
1045 wpa_s->current_ssid->ssid_len; in wpa_supplicant_scan()
1055 ssid = wpa_s->conf->ssid; in wpa_supplicant_scan()
1056 if (wpa_s->prev_scan_ssid != WILDCARD_SSID_SCAN) { in wpa_supplicant_scan()
1058 if (ssid == wpa_s->prev_scan_ssid) { in wpa_supplicant_scan()
1066 if (wpa_s->last_scan_req != MANUAL_SCAN_REQ && in wpa_supplicant_scan()
1068 !wpa_s->ap_iface && in wpa_supplicant_scan()
1070 wpa_s->conf->ap_scan == 2) { in wpa_supplicant_scan()
1071 wpa_s->connect_without_scan = NULL; in wpa_supplicant_scan()
1072 wpa_s->prev_scan_wildcard = 0; in wpa_supplicant_scan()
1073 wpa_supplicant_assoc_try(wpa_s, ssid); in wpa_supplicant_scan()
1075 } else if (wpa_s->conf->ap_scan == 2) { in wpa_supplicant_scan()
1081 } else if (wpa_s->reattach && wpa_s->current_ssid != NULL) { in wpa_supplicant_scan()
1087 ssid = wpa_s->current_ssid; in wpa_supplicant_scan()
1100 params.freqs[0] = wpa_s->assoc_freq; in wpa_supplicant_scan()
1108 wpa_s->reattach = 0; in wpa_supplicant_scan()
1113 ssid = wpa_s->conf->ssid; in wpa_supplicant_scan()
1115 if (!wpas_network_disabled(wpa_s, ssid) && in wpa_supplicant_scan()
1128 if (!wpas_network_disabled(wpa_s, ssid)) { in wpa_supplicant_scan()
1134 wpa_add_owe_scan_ssid(wpa_s, ¶ms, ssid, in wpa_supplicant_scan()
1142 start != wpa_s->conf->ssid) in wpa_supplicant_scan()
1143 ssid = wpa_s->conf->ssid; in wpa_supplicant_scan()
1146 if (wpa_s->scan_id_count && in wpa_supplicant_scan()
1147 wpa_s->last_scan_req == MANUAL_SCAN_REQ) in wpa_supplicant_scan()
1148 wpa_set_scan_ssids(wpa_s, ¶ms, max_ssids); in wpa_supplicant_scan()
1150 for (tssid = wpa_s->conf->ssid; in wpa_supplicant_scan()
1151 wpa_s->last_scan_req != MANUAL_SCAN_REQ && tssid; in wpa_supplicant_scan()
1153 if (wpas_network_disabled(wpa_s, tssid)) in wpa_supplicant_scan()
1175 if (!wpa_s->prev_scan_wildcard) { in wpa_supplicant_scan()
1178 wpa_s->prev_scan_wildcard = 1; in wpa_supplicant_scan()
1179 wpa_dbg(wpa_s, MSG_DEBUG, "Starting AP scan for " in wpa_supplicant_scan()
1182 wpa_s->prev_scan_ssid = ssid; in wpa_supplicant_scan()
1183 wpa_s->prev_scan_wildcard = 0; in wpa_supplicant_scan()
1184 wpa_dbg(wpa_s, MSG_DEBUG, in wpa_supplicant_scan()
1191 wpa_s->prev_scan_ssid = ssid; in wpa_supplicant_scan()
1192 wpa_dbg(wpa_s, MSG_DEBUG, "Include wildcard SSID in " in wpa_supplicant_scan()
1195 } else if (wpa_s->last_scan_req == MANUAL_SCAN_REQ && in wpa_supplicant_scan()
1196 wpa_s->manual_scan_passive && params.num_ssids == 0) { in wpa_supplicant_scan()
1197 wpa_dbg(wpa_s, MSG_DEBUG, "Use passive scan based on manual request"); in wpa_supplicant_scan()
1198 } else if (wpa_s->conf->passive_scan) { in wpa_supplicant_scan()
1199 wpa_dbg(wpa_s, MSG_DEBUG, in wpa_supplicant_scan()
1202 wpa_s->prev_scan_ssid = WILDCARD_SSID_SCAN; in wpa_supplicant_scan()
1204 wpa_dbg(wpa_s, MSG_DEBUG, "Starting AP scan for wildcard " in wpa_supplicant_scan()
1209 wpa_supplicant_optimize_freqs(wpa_s, ¶ms); in wpa_supplicant_scan()
1210 extra_ie = wpa_supplicant_extra_ies(wpa_s); in wpa_supplicant_scan()
1212 if (wpa_s->last_scan_req == MANUAL_SCAN_REQ && in wpa_supplicant_scan()
1213 wpa_s->manual_scan_only_new) { in wpa_supplicant_scan()
1219 if (wpa_s->last_scan_req == MANUAL_SCAN_REQ && params.freqs == NULL && in wpa_supplicant_scan()
1220 wpa_s->manual_scan_freqs) { in wpa_supplicant_scan()
1221 wpa_dbg(wpa_s, MSG_DEBUG, "Limit manual scan to specified channels"); in wpa_supplicant_scan()
1222 params.freqs = wpa_s->manual_scan_freqs; in wpa_supplicant_scan()
1223 wpa_s->manual_scan_freqs = NULL; in wpa_supplicant_scan()
1226 if (params.freqs == NULL && wpa_s->select_network_scan_freqs) { in wpa_supplicant_scan()
1227 wpa_dbg(wpa_s, MSG_DEBUG, in wpa_supplicant_scan()
1229 params.freqs = wpa_s->select_network_scan_freqs; in wpa_supplicant_scan()
1230 wpa_s->select_network_scan_freqs = NULL; in wpa_supplicant_scan()
1233 if (params.freqs == NULL && wpa_s->next_scan_freqs) { in wpa_supplicant_scan()
1234 wpa_dbg(wpa_s, MSG_DEBUG, "Optimize scan based on previously " in wpa_supplicant_scan()
1236 params.freqs = wpa_s->next_scan_freqs; in wpa_supplicant_scan()
1238 os_free(wpa_s->next_scan_freqs); in wpa_supplicant_scan()
1239 wpa_s->next_scan_freqs = NULL; in wpa_supplicant_scan()
1240 wpa_setband_scan_freqs(wpa_s, ¶ms); in wpa_supplicant_scan()
1243 if (wpa_s->last_scan_req == INITIAL_SCAN_REQ && in wpa_supplicant_scan()
1244 wpa_s->conf->initial_freq_list && !params.freqs) { in wpa_supplicant_scan()
1245 wpa_dbg(wpa_s, MSG_DEBUG, in wpa_supplicant_scan()
1247 int_array_concat(¶ms.freqs, wpa_s->conf->initial_freq_list); in wpa_supplicant_scan()
1248 } else if (wpa_s->conf->freq_list && !params.freqs) { in wpa_supplicant_scan()
1249 wpa_dbg(wpa_s, MSG_DEBUG, in wpa_supplicant_scan()
1251 int_array_concat(¶ms.freqs, wpa_s->conf->freq_list); in wpa_supplicant_scan()
1255 if (wpa_s->conf->scan_cur_freq && !params.freqs) { in wpa_supplicant_scan()
1256 unsigned int num = wpa_s->num_multichan_concurrent; in wpa_supplicant_scan()
1260 num = get_shared_radio_freqs(wpa_s, params.freqs, num); in wpa_supplicant_scan()
1262 wpa_dbg(wpa_s, MSG_DEBUG, "Scan only the " in wpa_supplicant_scan()
1273 if (wpa_s->enable_oce & OCE_STA) in wpa_supplicant_scan()
1278 wpa_s->conf, ¶ms.num_filter_ssids); in wpa_supplicant_scan()
1285 if (wpa_s->p2p_in_provisioning || wpa_s->p2p_in_invitation || in wpa_supplicant_scan()
1286 (wpa_s->show_group_started && wpa_s->go_params)) { in wpa_supplicant_scan()
1295 if ((wpa_s->mac_addr_rand_enable & MAC_ADDR_RAND_SCAN) && in wpa_supplicant_scan()
1296 wpa_s->wpa_state <= WPA_SCANNING) in wpa_supplicant_scan()
1297 wpa_setup_mac_addr_rand_params(¶ms, wpa_s->mac_addr_scan); in wpa_supplicant_scan()
1299 if (!is_zero_ether_addr(wpa_s->next_scan_bssid)) { in wpa_supplicant_scan()
1302 params.bssid = wpa_s->next_scan_bssid; in wpa_supplicant_scan()
1303 bss = wpa_bss_get_bssid_latest(wpa_s, params.bssid); in wpa_supplicant_scan()
1304 if (!wpa_s->next_scan_bssid_wildcard_ssid && in wpa_supplicant_scan()
1309 wpa_dbg(wpa_s, MSG_DEBUG, in wpa_supplicant_scan()
1315 wpa_dbg(wpa_s, MSG_DEBUG, in wpa_supplicant_scan()
1334 if (wpa_s->scan_for_connection && in wpa_supplicant_scan()
1335 wpa_s->last_scan_req == NORMAL_SCAN_REQ && in wpa_supplicant_scan()
1337 wpas_is_p2p_prioritized(wpa_s) && in wpa_supplicant_scan()
1338 wpa_s->p2p_group_interface == NOT_P2P_GROUP_INTERFACE && in wpa_supplicant_scan()
1339 non_p2p_network_enabled(wpa_s)) { in wpa_supplicant_scan()
1340 unsigned int num = wpa_s->num_multichan_concurrent; in wpa_supplicant_scan()
1344 num = get_shared_radio_freqs(wpa_s, params.freqs, num); in wpa_supplicant_scan()
1345 if (num > 0 && num == wpa_s->num_multichan_concurrent) { in wpa_supplicant_scan()
1346 …wpa_dbg(wpa_s, MSG_DEBUG, "Scan only the current operating channels since all channels are already… in wpa_supplicant_scan()
1355 ret = wpa_supplicant_trigger_scan(wpa_s, scan_params); in wpa_supplicant_scan()
1357 if (ret && wpa_s->last_scan_req == MANUAL_SCAN_REQ && params.freqs && in wpa_supplicant_scan()
1358 !wpa_s->manual_scan_freqs) { in wpa_supplicant_scan()
1360 wpa_s->manual_scan_freqs = params.freqs; in wpa_supplicant_scan()
1370 wpa_msg(wpa_s, MSG_WARNING, "Failed to initiate AP scan"); in wpa_supplicant_scan()
1371 if (wpa_s->scan_prev_wpa_state != wpa_s->wpa_state) in wpa_supplicant_scan()
1372 wpa_supplicant_set_state(wpa_s, in wpa_supplicant_scan()
1373 wpa_s->scan_prev_wpa_state); in wpa_supplicant_scan()
1375 wpa_s->scan_req = wpa_s->last_scan_req; in wpa_supplicant_scan()
1376 wpa_supplicant_req_scan(wpa_s, 1, 0); in wpa_supplicant_scan()
1378 wpa_s->scan_for_connection = 0; in wpa_supplicant_scan()
1380 wpa_s->interworking_fast_assoc_tried = 0; in wpa_supplicant_scan()
1382 wpa_s->next_scan_bssid_wildcard_ssid = 0; in wpa_supplicant_scan()
1384 os_memset(wpa_s->next_scan_bssid, 0, ETH_ALEN); in wpa_supplicant_scan()
1389 void wpa_supplicant_update_scan_int(struct wpa_supplicant *wpa_s, int sec) in wpa_supplicant_update_scan_int() argument
1394 cancelled = eloop_cancel_timeout_one(wpa_supplicant_scan, wpa_s, NULL, in wpa_supplicant_update_scan_int()
1406 wpa_supplicant_scan, wpa_s, NULL); in wpa_supplicant_update_scan_int()
1408 wpa_s->scan_interval = sec; in wpa_supplicant_update_scan_int()
1421 void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec) in wpa_supplicant_req_scan() argument
1425 if (wpa_s->p2p_mgmt) { in wpa_supplicant_req_scan()
1426 wpa_dbg(wpa_s, MSG_DEBUG, in wpa_supplicant_req_scan()
1432 res = eloop_deplete_timeout(sec, usec, wpa_supplicant_scan, wpa_s, in wpa_supplicant_req_scan()
1435 wpa_dbg(wpa_s, MSG_DEBUG, "Rescheduling scan request: %d.%06d sec", in wpa_supplicant_req_scan()
1438 …wpa_dbg(wpa_s, MSG_DEBUG, "Ignore new scan request for %d.%06d sec since an earlier request is sch… in wpa_supplicant_req_scan()
1441 wpa_dbg(wpa_s, MSG_DEBUG, "Setting scan request: %d.%06d sec", in wpa_supplicant_req_scan()
1443 eloop_register_timeout(sec, usec, wpa_supplicant_scan, wpa_s, NULL); in wpa_supplicant_req_scan()
1458 int wpa_supplicant_delayed_sched_scan(struct wpa_supplicant *wpa_s, in wpa_supplicant_delayed_sched_scan() argument
1461 if (!wpa_s->sched_scan_supported) in wpa_supplicant_delayed_sched_scan()
1466 wpa_s, NULL); in wpa_supplicant_delayed_sched_scan()
1473 wpa_scan_set_relative_rssi_params(struct wpa_supplicant *wpa_s, in wpa_scan_set_relative_rssi_params() argument
1476 if (wpa_s->wpa_state != WPA_COMPLETED || in wpa_scan_set_relative_rssi_params()
1477 !(wpa_s->drv_flags & WPA_DRIVER_FLAGS_SCHED_SCAN_RELATIVE_RSSI) || in wpa_scan_set_relative_rssi_params()
1478 wpa_s->srp.relative_rssi_set == 0) in wpa_scan_set_relative_rssi_params()
1482 params->relative_rssi = wpa_s->srp.relative_rssi; in wpa_scan_set_relative_rssi_params()
1484 if (wpa_s->srp.relative_adjust_rssi == 0) in wpa_scan_set_relative_rssi_params()
1487 params->relative_adjust_band = wpa_s->srp.relative_adjust_band; in wpa_scan_set_relative_rssi_params()
1488 params->relative_adjust_rssi = wpa_s->srp.relative_adjust_rssi; in wpa_scan_set_relative_rssi_params()
1500 int wpa_supplicant_req_sched_scan(struct wpa_supplicant *wpa_s) in wpa_supplicant_req_sched_scan() argument
1513 if (!wpa_s->sched_scan_supported) in wpa_supplicant_req_sched_scan()
1516 if (wpa_s->max_sched_scan_ssids > WPAS_MAX_SCAN_SSIDS) in wpa_supplicant_req_sched_scan()
1519 max_sched_scan_ssids = wpa_s->max_sched_scan_ssids; in wpa_supplicant_req_sched_scan()
1520 if (max_sched_scan_ssids < 1 || wpa_s->conf->disable_scan_offload) in wpa_supplicant_req_sched_scan()
1523 wpa_s->sched_scan_stop_req = 0; in wpa_supplicant_req_sched_scan()
1525 if (wpa_s->sched_scanning) { in wpa_supplicant_req_sched_scan()
1526 wpa_dbg(wpa_s, MSG_DEBUG, "Already sched scanning"); in wpa_supplicant_req_sched_scan()
1531 for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next) { in wpa_supplicant_req_sched_scan()
1532 if (!wpas_network_disabled(wpa_s, ssid) && !ssid->scan_ssid) { in wpa_supplicant_req_sched_scan()
1535 } else if (!wpas_network_disabled(wpa_s, ssid) && in wpa_supplicant_req_sched_scan()
1540 if (!wpas_network_disabled(wpa_s, ssid) && in wpa_supplicant_req_sched_scan()
1548 wpa_dbg(wpa_s, MSG_DEBUG, "Use normal scan instead of " in wpa_supplicant_req_sched_scan()
1557 if (wpa_s->normal_scans < 3 && in wpa_supplicant_req_sched_scan()
1558 (need_ssids <= wpa_s->max_scan_ssids || in wpa_supplicant_req_sched_scan()
1559 wpa_s->max_scan_ssids >= (int) max_sched_scan_ssids)) { in wpa_supplicant_req_sched_scan()
1567 wpa_dbg(wpa_s, MSG_DEBUG, "Use normal scan instead of " in wpa_supplicant_req_sched_scan()
1569 wpa_s->normal_scans); in wpa_supplicant_req_sched_scan()
1576 params.filter_ssids = os_calloc(wpa_s->max_match_sets, in wpa_supplicant_req_sched_scan()
1579 prev_state = wpa_s->wpa_state; in wpa_supplicant_req_sched_scan()
1580 if (wpa_s->wpa_state == WPA_DISCONNECTED || in wpa_supplicant_req_sched_scan()
1581 wpa_s->wpa_state == WPA_INACTIVE) in wpa_supplicant_req_sched_scan()
1582 wpa_supplicant_set_state(wpa_s, WPA_SCANNING); in wpa_supplicant_req_sched_scan()
1584 if (wpa_s->autoscan_params != NULL) { in wpa_supplicant_req_sched_scan()
1585 scan_params = wpa_s->autoscan_params; in wpa_supplicant_req_sched_scan()
1590 ssid = wpa_s->conf->ssid; in wpa_supplicant_req_sched_scan()
1591 if (wpa_s->prev_sched_ssid) { in wpa_supplicant_req_sched_scan()
1593 if (ssid == wpa_s->prev_sched_ssid) { in wpa_supplicant_req_sched_scan()
1601 if (!ssid || !wpa_s->prev_sched_ssid) { in wpa_supplicant_req_sched_scan()
1602 wpa_dbg(wpa_s, MSG_DEBUG, "Beginning of SSID list"); in wpa_supplicant_req_sched_scan()
1603 wpa_s->sched_scan_timeout = max_sched_scan_ssids * 2; in wpa_supplicant_req_sched_scan()
1604 wpa_s->first_sched_scan = 1; in wpa_supplicant_req_sched_scan()
1605 ssid = wpa_s->conf->ssid; in wpa_supplicant_req_sched_scan()
1606 wpa_s->prev_sched_ssid = ssid; in wpa_supplicant_req_sched_scan()
1610 wpa_dbg(wpa_s, MSG_DEBUG, "Add wildcard SSID to sched_scan"); in wpa_supplicant_req_sched_scan()
1615 if (wpas_network_disabled(wpa_s, ssid)) in wpa_supplicant_req_sched_scan()
1618 if (params.num_filter_ssids < wpa_s->max_match_sets && in wpa_supplicant_req_sched_scan()
1620 wpa_dbg(wpa_s, MSG_DEBUG, "add to filter ssid: %s", in wpa_supplicant_req_sched_scan()
1629 wpa_dbg(wpa_s, MSG_DEBUG, "Not enough room for SSID " in wpa_supplicant_req_sched_scan()
1639 wpa_dbg(wpa_s, MSG_DEBUG, in wpa_supplicant_req_sched_scan()
1648 wpa_s->prev_sched_ssid = ssid; in wpa_supplicant_req_sched_scan()
1652 (wpas_network_disabled(wpa_s, ssid) || in wpa_supplicant_req_sched_scan()
1659 wpa_s->prev_sched_ssid = ssid; in wpa_supplicant_req_sched_scan()
1668 extra_ie = wpa_supplicant_extra_ies(wpa_s); in wpa_supplicant_req_sched_scan()
1674 if (wpa_s->conf->filter_rssi) in wpa_supplicant_req_sched_scan()
1675 params.filter_rssi = wpa_s->conf->filter_rssi; in wpa_supplicant_req_sched_scan()
1678 if (wpa_s->conf->freq_list && !params.freqs) { in wpa_supplicant_req_sched_scan()
1679 wpa_dbg(wpa_s, MSG_DEBUG, in wpa_supplicant_req_sched_scan()
1681 int_array_concat(¶ms.freqs, wpa_s->conf->freq_list); in wpa_supplicant_req_sched_scan()
1685 if (wpa_s->enable_oce & OCE_STA) in wpa_supplicant_req_sched_scan()
1692 wpa_s->sched_scan_timed_out = 0; in wpa_supplicant_req_sched_scan()
1699 if (wpa_s->sched_scan_plans_num == 1 || in wpa_supplicant_req_sched_scan()
1700 (wpa_s->sched_scan_plans_num && !ssid && wpa_s->first_sched_scan)) { in wpa_supplicant_req_sched_scan()
1701 params.sched_scan_plans = wpa_s->sched_scan_plans; in wpa_supplicant_req_sched_scan()
1702 params.sched_scan_plans_num = wpa_s->sched_scan_plans_num; in wpa_supplicant_req_sched_scan()
1703 } else if (wpa_s->sched_scan_plans_num > 1) { in wpa_supplicant_req_sched_scan()
1704 wpa_dbg(wpa_s, MSG_DEBUG, in wpa_supplicant_req_sched_scan()
1707 &wpa_s->sched_scan_plans[wpa_s->sched_scan_plans_num - in wpa_supplicant_req_sched_scan()
1711 if (wpa_s->conf->sched_scan_interval) in wpa_supplicant_req_sched_scan()
1712 scan_plan.interval = wpa_s->conf->sched_scan_interval; in wpa_supplicant_req_sched_scan()
1716 if (scan_plan.interval > wpa_s->max_sched_scan_plan_interval) { in wpa_supplicant_req_sched_scan()
1720 wpa_s->max_sched_scan_plan_interval); in wpa_supplicant_req_sched_scan()
1722 wpa_s->max_sched_scan_plan_interval; in wpa_supplicant_req_sched_scan()
1730 params.sched_scan_start_delay = wpa_s->conf->sched_scan_start_delay; in wpa_supplicant_req_sched_scan()
1732 if (ssid || !wpa_s->first_sched_scan) { in wpa_supplicant_req_sched_scan()
1733 wpa_dbg(wpa_s, MSG_DEBUG, in wpa_supplicant_req_sched_scan()
1737 wpa_s->sched_scan_timeout); in wpa_supplicant_req_sched_scan()
1739 wpa_dbg(wpa_s, MSG_DEBUG, in wpa_supplicant_req_sched_scan()
1744 wpa_setband_scan_freqs(wpa_s, scan_params); in wpa_supplicant_req_sched_scan()
1746 if ((wpa_s->mac_addr_rand_enable & MAC_ADDR_RAND_SCHED_SCAN) && in wpa_supplicant_req_sched_scan()
1747 wpa_s->wpa_state <= WPA_SCANNING) in wpa_supplicant_req_sched_scan()
1749 wpa_s->mac_addr_sched_scan); in wpa_supplicant_req_sched_scan()
1751 wpa_scan_set_relative_rssi_params(wpa_s, scan_params); in wpa_supplicant_req_sched_scan()
1753 ret = wpa_supplicant_start_sched_scan(wpa_s, scan_params); in wpa_supplicant_req_sched_scan()
1758 wpa_msg(wpa_s, MSG_WARNING, "Failed to initiate sched scan"); in wpa_supplicant_req_sched_scan()
1759 if (prev_state != wpa_s->wpa_state) in wpa_supplicant_req_sched_scan()
1760 wpa_supplicant_set_state(wpa_s, prev_state); in wpa_supplicant_req_sched_scan()
1765 if (ssid || !wpa_s->first_sched_scan) { in wpa_supplicant_req_sched_scan()
1766 wpa_s->sched_scan_timed_out = 0; in wpa_supplicant_req_sched_scan()
1767 eloop_register_timeout(wpa_s->sched_scan_timeout, 0, in wpa_supplicant_req_sched_scan()
1769 wpa_s, NULL); in wpa_supplicant_req_sched_scan()
1770 wpa_s->first_sched_scan = 0; in wpa_supplicant_req_sched_scan()
1771 wpa_s->sched_scan_timeout /= 2; in wpa_supplicant_req_sched_scan()
1773 if ((unsigned int) wpa_s->sched_scan_timeout < in wpa_supplicant_req_sched_scan()
1776 wpa_s->max_sched_scan_plan_interval) { in wpa_supplicant_req_sched_scan()
1778 wpa_s->sched_scan_timeout = max_sched_scan_ssids * 2; in wpa_supplicant_req_sched_scan()
1784 wpa_s->prev_sched_ssid = NULL; in wpa_supplicant_req_sched_scan()
1797 void wpa_supplicant_cancel_scan(struct wpa_supplicant *wpa_s) in wpa_supplicant_cancel_scan() argument
1799 wpa_dbg(wpa_s, MSG_DEBUG, "Cancelling scan request"); in wpa_supplicant_cancel_scan()
1800 eloop_cancel_timeout(wpa_supplicant_scan, wpa_s, NULL); in wpa_supplicant_cancel_scan()
1810 void wpa_supplicant_cancel_delayed_sched_scan(struct wpa_supplicant *wpa_s) in wpa_supplicant_cancel_delayed_sched_scan() argument
1812 if (!wpa_s->sched_scan_supported) in wpa_supplicant_cancel_delayed_sched_scan()
1815 wpa_dbg(wpa_s, MSG_DEBUG, "Cancelling delayed sched scan"); in wpa_supplicant_cancel_delayed_sched_scan()
1817 wpa_s, NULL); in wpa_supplicant_cancel_delayed_sched_scan()
1827 void wpa_supplicant_cancel_sched_scan(struct wpa_supplicant *wpa_s) in wpa_supplicant_cancel_sched_scan() argument
1829 if (!wpa_s->sched_scanning) in wpa_supplicant_cancel_sched_scan()
1832 if (wpa_s->sched_scanning) in wpa_supplicant_cancel_sched_scan()
1833 wpa_s->sched_scan_stop_req = 1; in wpa_supplicant_cancel_sched_scan()
1835 wpa_dbg(wpa_s, MSG_DEBUG, "Cancelling sched scan"); in wpa_supplicant_cancel_sched_scan()
1836 eloop_cancel_timeout(wpa_supplicant_sched_scan_timeout, wpa_s, NULL); in wpa_supplicant_cancel_sched_scan()
1837 wpa_supplicant_stop_sched_scan(wpa_s); in wpa_supplicant_cancel_sched_scan()
1851 void wpa_supplicant_notify_scanning(struct wpa_supplicant *wpa_s, in wpa_supplicant_notify_scanning() argument
1854 if (wpa_s->scanning != scanning) { in wpa_supplicant_notify_scanning()
1855 wpa_s->scanning = scanning; in wpa_supplicant_notify_scanning()
1856 wpas_notify_scanning(wpa_s); in wpa_supplicant_notify_scanning()
2176 int wpa_supplicant_filter_bssid_match(struct wpa_supplicant *wpa_s, in wpa_supplicant_filter_bssid_match() argument
2181 if (wpa_s->bssid_filter == NULL) in wpa_supplicant_filter_bssid_match()
2184 for (i = 0; i < wpa_s->bssid_filter_count; i++) { in wpa_supplicant_filter_bssid_match()
2185 if (os_memcmp(wpa_s->bssid_filter + i * ETH_ALEN, bssid, in wpa_supplicant_filter_bssid_match()
2194 void filter_scan_res(struct wpa_supplicant *wpa_s, in filter_scan_res() argument
2199 if (wpa_s->bssid_filter == NULL) in filter_scan_res()
2203 if (wpa_supplicant_filter_bssid_match(wpa_s, in filter_scan_res()
2336 unsigned int wpas_get_est_tpt(const struct wpa_supplicant *wpa_s, in wpas_get_est_tpt() argument
2340 enum local_hw_capab capab = wpa_s->hw_capab; in wpas_get_est_tpt()
2435 void scan_est_throughput(struct wpa_supplicant *wpa_s, in scan_est_throughput() argument
2452 wpas_get_est_tpt(wpa_s, ies, ie_len, rate, snr); in scan_est_throughput()
2470 wpa_supplicant_get_scan_results(struct wpa_supplicant *wpa_s, in wpa_supplicant_get_scan_results() argument
2477 scan_res = wpa_drv_get_scan_results2(wpa_s); in wpa_supplicant_get_scan_results()
2479 wpa_dbg(wpa_s, MSG_DEBUG, "Failed to get scan results"); in wpa_supplicant_get_scan_results()
2489 filter_scan_res(wpa_s, scan_res); in wpa_supplicant_get_scan_results()
2495 scan_est_throughput(wpa_s, scan_res_item); in wpa_supplicant_get_scan_results()
2499 if (wpas_wps_searching(wpa_s)) { in wpa_supplicant_get_scan_results()
2500 wpa_dbg(wpa_s, MSG_DEBUG, "WPS: Order scan results with WPS " in wpa_supplicant_get_scan_results()
2512 if (wpa_s->ignore_post_flush_scan_res) { in wpa_supplicant_get_scan_results()
2516 wpa_dbg(wpa_s, MSG_DEBUG, in wpa_supplicant_get_scan_results()
2518 wpa_s->ignore_post_flush_scan_res = 0; in wpa_supplicant_get_scan_results()
2522 wpa_bss_update_start(wpa_s); in wpa_supplicant_get_scan_results()
2524 wpa_bss_update_scan_res(wpa_s, scan_res->res[i], in wpa_supplicant_get_scan_results()
2526 wpa_bss_update_end(wpa_s, info, new_scan); in wpa_supplicant_get_scan_results()
2544 int wpa_supplicant_update_scan_results(struct wpa_supplicant *wpa_s) in wpa_supplicant_update_scan_results() argument
2547 scan_res = wpa_supplicant_get_scan_results(wpa_s, NULL, 0); in wpa_supplicant_update_scan_results()
2559 void scan_only_handler(struct wpa_supplicant *wpa_s, in scan_only_handler() argument
2562 wpa_dbg(wpa_s, MSG_DEBUG, "Scan-only results received"); in scan_only_handler()
2563 if (wpa_s->last_scan_req == MANUAL_SCAN_REQ && in scan_only_handler()
2564 wpa_s->manual_scan_use_id && wpa_s->own_scan_running) { in scan_only_handler()
2565 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_SCAN_RESULTS "id=%u", in scan_only_handler()
2566 wpa_s->manual_scan_id); in scan_only_handler()
2567 wpa_s->manual_scan_use_id = 0; in scan_only_handler()
2569 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_SCAN_RESULTS); in scan_only_handler()
2571 wpas_notify_scan_results(wpa_s); in scan_only_handler()
2572 wpas_notify_scan_done(wpa_s, 1); in scan_only_handler()
2573 if (wpa_s->scan_work) { in scan_only_handler()
2574 struct wpa_radio_work *work = wpa_s->scan_work; in scan_only_handler()
2575 wpa_s->scan_work = NULL; in scan_only_handler()
2579 if (wpa_s->wpa_state == WPA_SCANNING) in scan_only_handler()
2580 wpa_supplicant_set_state(wpa_s, wpa_s->scan_prev_wpa_state); in scan_only_handler()
2584 int wpas_scan_scheduled(struct wpa_supplicant *wpa_s) in wpas_scan_scheduled() argument
2586 return eloop_is_timeout_registered(wpa_supplicant_scan, wpa_s, NULL); in wpas_scan_scheduled()
2707 int wpas_start_pno(struct wpa_supplicant *wpa_s) in wpas_start_pno() argument
2716 if (!wpa_s->sched_scan_supported) in wpas_start_pno()
2719 if (wpa_s->max_sched_scan_ssids > WPAS_MAX_SCAN_SSIDS) in wpas_start_pno()
2722 max_sched_scan_ssids = wpa_s->max_sched_scan_ssids; in wpas_start_pno()
2726 if (wpa_s->pno || wpa_s->pno_sched_pending) in wpas_start_pno()
2729 if ((wpa_s->wpa_state > WPA_SCANNING) && in wpas_start_pno()
2730 (wpa_s->wpa_state < WPA_COMPLETED)) { in wpas_start_pno()
2735 if (wpa_s->wpa_state == WPA_SCANNING) { in wpas_start_pno()
2736 wpa_supplicant_cancel_scan(wpa_s); in wpas_start_pno()
2737 if (wpa_s->sched_scanning) { in wpas_start_pno()
2740 wpa_supplicant_cancel_sched_scan(wpa_s); in wpas_start_pno()
2741 wpa_s->pno_sched_pending = 1; in wpas_start_pno()
2746 if (wpa_s->sched_scan_stop_req) { in wpas_start_pno()
2749 wpa_s->pno_sched_pending = 1; in wpas_start_pno()
2756 ssid = wpa_s->conf->ssid; in wpas_start_pno()
2758 if (!wpas_network_disabled(wpa_s, ssid)) { in wpas_start_pno()
2782 if (num_match_ssid > wpa_s->max_match_sets) { in wpas_start_pno()
2783 num_match_ssid = wpa_s->max_match_sets; in wpas_start_pno()
2784 wpa_dbg(wpa_s, MSG_DEBUG, "PNO: Too many SSIDs to match"); in wpas_start_pno()
2793 ssid = wpa_s->conf->pssid[prio]; in wpas_start_pno()
2795 if (!wpas_network_disabled(wpa_s, ssid)) { in wpas_start_pno()
2813 else if (prio + 1 == wpa_s->conf->num_prio) in wpas_start_pno()
2816 ssid = wpa_s->conf->pssid[++prio]; in wpas_start_pno()
2819 if (wpa_s->conf->filter_rssi) in wpas_start_pno()
2820 params.filter_rssi = wpa_s->conf->filter_rssi; in wpas_start_pno()
2822 if (wpa_s->sched_scan_plans_num) { in wpas_start_pno()
2823 params.sched_scan_plans = wpa_s->sched_scan_plans; in wpas_start_pno()
2824 params.sched_scan_plans_num = wpa_s->sched_scan_plans_num; in wpas_start_pno()
2827 if (wpa_s->conf->sched_scan_interval) in wpas_start_pno()
2828 scan_plan.interval = wpa_s->conf->sched_scan_interval; in wpas_start_pno()
2837 params.sched_scan_start_delay = wpa_s->conf->sched_scan_start_delay; in wpas_start_pno()
2839 if (params.freqs == NULL && wpa_s->manual_sched_scan_freqs) { in wpas_start_pno()
2840 wpa_dbg(wpa_s, MSG_DEBUG, "Limit sched scan to specified channels"); in wpas_start_pno()
2841 params.freqs = wpa_s->manual_sched_scan_freqs; in wpas_start_pno()
2844 if ((wpa_s->mac_addr_rand_enable & MAC_ADDR_RAND_PNO) && in wpas_start_pno()
2845 wpa_s->wpa_state <= WPA_SCANNING) in wpas_start_pno()
2846 wpa_setup_mac_addr_rand_params(¶ms, wpa_s->mac_addr_pno); in wpas_start_pno()
2848 wpa_scan_set_relative_rssi_params(wpa_s, ¶ms); in wpas_start_pno()
2850 ret = wpa_supplicant_start_sched_scan(wpa_s, ¶ms); in wpas_start_pno()
2854 wpa_s->pno = 1; in wpas_start_pno()
2856 wpa_msg(wpa_s, MSG_ERROR, "Failed to schedule PNO"); in wpas_start_pno()
2861 int wpas_stop_pno(struct wpa_supplicant *wpa_s) in wpas_stop_pno() argument
2865 if (!wpa_s->pno) in wpas_stop_pno()
2868 ret = wpa_supplicant_stop_sched_scan(wpa_s); in wpas_stop_pno()
2869 wpa_s->sched_scan_stop_req = 1; in wpas_stop_pno()
2871 wpa_s->pno = 0; in wpas_stop_pno()
2872 wpa_s->pno_sched_pending = 0; in wpas_stop_pno()
2874 if (wpa_s->wpa_state == WPA_SCANNING) in wpas_stop_pno()
2875 wpa_supplicant_req_scan(wpa_s, 0, 0); in wpas_stop_pno()
2881 void wpas_mac_addr_rand_scan_clear(struct wpa_supplicant *wpa_s, in wpas_mac_addr_rand_scan_clear() argument
2885 wpa_s->mac_addr_rand_enable &= ~type; in wpas_mac_addr_rand_scan_clear()
2888 os_free(wpa_s->mac_addr_scan); in wpas_mac_addr_rand_scan_clear()
2889 wpa_s->mac_addr_scan = NULL; in wpas_mac_addr_rand_scan_clear()
2893 os_free(wpa_s->mac_addr_sched_scan); in wpas_mac_addr_rand_scan_clear()
2894 wpa_s->mac_addr_sched_scan = NULL; in wpas_mac_addr_rand_scan_clear()
2898 os_free(wpa_s->mac_addr_pno); in wpas_mac_addr_rand_scan_clear()
2899 wpa_s->mac_addr_pno = NULL; in wpas_mac_addr_rand_scan_clear()
2904 int wpas_mac_addr_rand_scan_set(struct wpa_supplicant *wpa_s, in wpas_mac_addr_rand_scan_set() argument
2910 if ((wpa_s->mac_addr_rand_supported & type) != type ) { in wpas_mac_addr_rand_scan_set()
2913 type, wpa_s->mac_addr_rand_supported); in wpas_mac_addr_rand_scan_set()
2917 wpas_mac_addr_rand_scan_clear(wpa_s, type); in wpas_mac_addr_rand_scan_set()
2928 wpa_s->mac_addr_scan = tmp; in wpas_mac_addr_rand_scan_set()
2930 wpa_s->mac_addr_sched_scan = tmp; in wpas_mac_addr_rand_scan_set()
2932 wpa_s->mac_addr_pno = tmp; in wpas_mac_addr_rand_scan_set()
2941 wpa_s->mac_addr_rand_enable |= type; in wpas_mac_addr_rand_scan_set()
2946 int wpas_mac_addr_rand_scan_get_mask(struct wpa_supplicant *wpa_s, in wpas_mac_addr_rand_scan_get_mask() argument
2951 if ((wpa_s->mac_addr_rand_enable & type) != type) in wpas_mac_addr_rand_scan_get_mask()
2955 to_copy = wpa_s->mac_addr_scan; in wpas_mac_addr_rand_scan_get_mask()
2957 to_copy = wpa_s->mac_addr_sched_scan; in wpas_mac_addr_rand_scan_get_mask()
2959 to_copy = wpa_s->mac_addr_pno; in wpas_mac_addr_rand_scan_get_mask()
2972 int wpas_abort_ongoing_scan(struct wpa_supplicant *wpa_s) in wpas_abort_ongoing_scan() argument
2975 struct wpa_radio *radio = wpa_s->radio; in wpas_abort_ongoing_scan()
2978 if (work->wpa_s != wpa_s || !work->started || in wpas_abort_ongoing_scan()
2982 wpa_dbg(wpa_s, MSG_DEBUG, "Abort an ongoing scan"); in wpas_abort_ongoing_scan()
2983 return wpa_drv_abort_scan(wpa_s, wpa_s->curr_scan_cookie); in wpas_abort_ongoing_scan()
2986 wpa_dbg(wpa_s, MSG_DEBUG, "No ongoing scan/p2p-scan found to abort"); in wpas_abort_ongoing_scan()
2991 int wpas_sched_scan_plans_set(struct wpa_supplicant *wpa_s, const char *cmd) in wpas_sched_scan_plans_set() argument
3002 os_free(wpa_s->sched_scan_plans); in wpas_sched_scan_plans_set()
3003 wpa_s->sched_scan_plans = NULL; in wpas_sched_scan_plans_set()
3004 wpa_s->sched_scan_plans_num = 0; in wpas_sched_scan_plans_set()
3028 if (scan_plan->interval > wpa_s->max_sched_scan_plan_interval) { in wpas_sched_scan_plans_set()
3032 wpa_s->max_sched_scan_plan_interval); in wpas_sched_scan_plans_set()
3034 wpa_s->max_sched_scan_plan_interval; in wpas_sched_scan_plans_set()
3050 wpa_s->max_sched_scan_plan_iterations) { in wpas_sched_scan_plans_set()
3054 wpa_s->max_sched_scan_plan_iterations); in wpas_sched_scan_plans_set()
3056 wpa_s->max_sched_scan_plan_iterations; in wpas_sched_scan_plans_set()
3078 if (num > wpa_s->max_sched_scan_plans) { in wpas_sched_scan_plans_set()
3081 wpa_s->max_sched_scan_plans); in wpas_sched_scan_plans_set()
3084 wpa_s->max_sched_scan_plans - 1); in wpas_sched_scan_plans_set()
3085 os_memcpy(&scan_plans[wpa_s->max_sched_scan_plans - 1], in wpas_sched_scan_plans_set()
3087 num = wpa_s->max_sched_scan_plans; in wpas_sched_scan_plans_set()
3090 os_free(wpa_s->sched_scan_plans); in wpas_sched_scan_plans_set()
3091 wpa_s->sched_scan_plans = scan_plans; in wpas_sched_scan_plans_set()
3092 wpa_s->sched_scan_plans_num = num; in wpas_sched_scan_plans_set()
3111 void wpas_scan_reset_sched_scan(struct wpa_supplicant *wpa_s) in wpas_scan_reset_sched_scan() argument
3113 wpa_s->normal_scans = 0; in wpas_scan_reset_sched_scan()
3114 if (wpa_s->sched_scanning) { in wpas_scan_reset_sched_scan()
3115 wpa_s->sched_scan_timed_out = 0; in wpas_scan_reset_sched_scan()
3116 wpa_s->prev_sched_ssid = NULL; in wpas_scan_reset_sched_scan()
3117 wpa_supplicant_cancel_sched_scan(wpa_s); in wpas_scan_reset_sched_scan()
3122 void wpas_scan_restart_sched_scan(struct wpa_supplicant *wpa_s) in wpas_scan_restart_sched_scan() argument
3125 wpa_s->sched_scan_timed_out = 1; in wpas_scan_restart_sched_scan()
3126 wpa_s->prev_sched_ssid = NULL; in wpas_scan_restart_sched_scan()
3127 wpa_supplicant_cancel_sched_scan(wpa_s); in wpas_scan_restart_sched_scan()