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()
91 int wpa_supplicant_enabled_networks(struct wpa_supplicant *wpa_s) in wpa_supplicant_enabled_networks() argument
93 struct wpa_ssid *ssid = wpa_s->conf->ssid; in wpa_supplicant_enabled_networks()
96 if (wpa_s->p2p_mgmt) in wpa_supplicant_enabled_networks()
100 if (!wpas_network_disabled(wpa_s, ssid)) in wpa_supplicant_enabled_networks()
106 if (wpa_s->conf->cred && wpa_s->conf->interworking && in wpa_supplicant_enabled_networks()
107 wpa_s->conf->auto_interworking) in wpa_supplicant_enabled_networks()
110 wpa_dbg(wpa_s, MSG_DEBUG, "No enabled networks (%d disabled " in wpa_supplicant_enabled_networks()
117 static void wpa_supplicant_assoc_try(struct wpa_supplicant *wpa_s, in wpa_supplicant_assoc_try() argument
123 if (!wpas_network_disabled(wpa_s, ssid)) { in wpa_supplicant_assoc_try()
124 int temp_disabled = wpas_temp_disabled(wpa_s, ssid); in wpa_supplicant_assoc_try()
138 wpa_dbg(wpa_s, MSG_DEBUG, "wpa_supplicant_assoc_try: Reached " in wpa_supplicant_assoc_try()
140 wpa_s->prev_scan_ssid = WILDCARD_SSID_SCAN; in wpa_supplicant_assoc_try()
141 wpa_supplicant_req_scan(wpa_s, min_temp_disabled, 0); in wpa_supplicant_assoc_try()
146 wpa_s->prev_scan_ssid = ssid; in wpa_supplicant_assoc_try()
149 wpa_s->prev_scan_ssid = WILDCARD_SSID_SCAN; in wpa_supplicant_assoc_try()
151 wpa_supplicant_associate(wpa_s, NULL, ssid); in wpa_supplicant_assoc_try()
157 struct wpa_supplicant *wpa_s = work->wpa_s; in wpas_trigger_scan_cb() local
166 wpa_supplicant_notify_scanning(wpa_s, 0); in wpas_trigger_scan_cb()
167 wpas_notify_scan_done(wpa_s, 0); in wpas_trigger_scan_cb()
168 wpa_s->scan_work = NULL; in wpas_trigger_scan_cb()
172 if (wpas_update_random_addr_disassoc(wpa_s) < 0) { in wpas_trigger_scan_cb()
173 wpa_msg(wpa_s, MSG_INFO, in wpas_trigger_scan_cb()
176 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_SCAN_FAILED "ret=-1"); in wpas_trigger_scan_cb()
181 wpa_supplicant_notify_scanning(wpa_s, 1); in wpas_trigger_scan_cb()
183 if (wpa_s->clear_driver_scan_cache) { in wpas_trigger_scan_cb()
188 ret = wpa_drv_scan(wpa_s, params); in wpas_trigger_scan_cb()
199 wpa_s->curr_scan_cookie = params->scan_cookie; in wpas_trigger_scan_cb()
203 int retry = wpa_s->last_scan_req != MANUAL_SCAN_REQ && in wpas_trigger_scan_cb()
204 !wpa_s->beacon_rep_data.token; in wpas_trigger_scan_cb()
206 if (wpa_s->disconnected) in wpas_trigger_scan_cb()
209 wpa_supplicant_notify_scanning(wpa_s, 0); in wpas_trigger_scan_cb()
210 wpas_notify_scan_done(wpa_s, 0); in wpas_trigger_scan_cb()
211 if (wpa_s->wpa_state == WPA_SCANNING) in wpas_trigger_scan_cb()
212 wpa_supplicant_set_state(wpa_s, in wpas_trigger_scan_cb()
213 wpa_s->scan_prev_wpa_state); in wpas_trigger_scan_cb()
214 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_SCAN_FAILED "ret=%d%s", in wpas_trigger_scan_cb()
220 wpa_s->scan_req = wpa_s->last_scan_req; in wpas_trigger_scan_cb()
221 wpa_supplicant_req_scan(wpa_s, 1, 0); in wpas_trigger_scan_cb()
222 } else if (wpa_s->scan_res_handler) { in wpas_trigger_scan_cb()
224 wpa_s->scan_res_handler = NULL; in wpas_trigger_scan_cb()
227 if (wpa_s->beacon_rep_data.token) in wpas_trigger_scan_cb()
228 wpas_rrm_refuse_request(wpa_s); in wpas_trigger_scan_cb()
233 os_get_reltime(&wpa_s->scan_trigger_time); in wpas_trigger_scan_cb()
234 wpa_s->scan_runs++; in wpas_trigger_scan_cb()
235 wpa_s->normal_scans++; in wpas_trigger_scan_cb()
236 wpa_s->own_scan_requested = 1; in wpas_trigger_scan_cb()
237 wpa_s->clear_driver_scan_cache = 0; in wpas_trigger_scan_cb()
238 wpa_s->scan_work = work; in wpas_trigger_scan_cb()
248 int wpa_supplicant_trigger_scan(struct wpa_supplicant *wpa_s, in wpa_supplicant_trigger_scan() argument
253 if (wpa_s->scan_work) { in wpa_supplicant_trigger_scan()
254 wpa_dbg(wpa_s, MSG_INFO, "Reject scan trigger since one is already pending"); in wpa_supplicant_trigger_scan()
260 radio_add_work(wpa_s, 0, "scan", 0, wpas_trigger_scan_cb, ctx) < 0) in wpa_supplicant_trigger_scan()
263 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_SCAN_FAILED "ret=-1"); in wpa_supplicant_trigger_scan()
274 struct wpa_supplicant *wpa_s = eloop_ctx; in wpa_supplicant_delayed_sched_scan_timeout() local
276 wpa_dbg(wpa_s, MSG_DEBUG, "Starting delayed sched scan"); in wpa_supplicant_delayed_sched_scan_timeout()
278 if (wpa_supplicant_req_sched_scan(wpa_s)) in wpa_supplicant_delayed_sched_scan_timeout()
279 wpa_supplicant_req_scan(wpa_s, 0, 0); in wpa_supplicant_delayed_sched_scan_timeout()
286 struct wpa_supplicant *wpa_s = eloop_ctx; in wpa_supplicant_sched_scan_timeout() local
288 wpa_dbg(wpa_s, MSG_DEBUG, "Sched scan timeout - stopping it"); in wpa_supplicant_sched_scan_timeout()
290 wpa_s->sched_scan_timed_out = 1; in wpa_supplicant_sched_scan_timeout()
291 wpa_supplicant_cancel_sched_scan(wpa_s); in wpa_supplicant_sched_scan_timeout()
296 wpa_supplicant_start_sched_scan(struct wpa_supplicant *wpa_s, in wpa_supplicant_start_sched_scan() argument
301 wpa_supplicant_notify_scanning(wpa_s, 1); in wpa_supplicant_start_sched_scan()
302 ret = wpa_drv_sched_scan(wpa_s, params); in wpa_supplicant_start_sched_scan()
304 wpa_supplicant_notify_scanning(wpa_s, 0); in wpa_supplicant_start_sched_scan()
306 wpa_s->sched_scanning = 1; in wpa_supplicant_start_sched_scan()
312 static int wpa_supplicant_stop_sched_scan(struct wpa_supplicant *wpa_s) in wpa_supplicant_stop_sched_scan() argument
316 ret = wpa_drv_stop_sched_scan(wpa_s); in wpa_supplicant_stop_sched_scan()
318 wpa_dbg(wpa_s, MSG_DEBUG, "stopping sched_scan failed!"); in wpa_supplicant_stop_sched_scan()
361 struct wpa_supplicant *wpa_s, struct wpa_driver_scan_params *params) in wpa_supplicant_optimize_freqs() argument
364 if (params->freqs == NULL && wpa_s->p2p_in_provisioning && in wpa_supplicant_optimize_freqs()
365 wpa_s->go_params) { in wpa_supplicant_optimize_freqs()
367 if (wpa_s->p2p_in_provisioning < 5 && in wpa_supplicant_optimize_freqs()
368 wpa_s->go_params->freq > 0) { in wpa_supplicant_optimize_freqs()
369 wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Scan only GO " in wpa_supplicant_optimize_freqs()
371 wpa_s->go_params->freq); in wpa_supplicant_optimize_freqs()
374 params->freqs[0] = wpa_s->go_params->freq; in wpa_supplicant_optimize_freqs()
375 } else if (wpa_s->p2p_in_provisioning < 8 && in wpa_supplicant_optimize_freqs()
376 wpa_s->go_params->freq_list[0]) { in wpa_supplicant_optimize_freqs()
377 wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Scan only common " in wpa_supplicant_optimize_freqs()
380 wpa_s->go_params->freq_list); in wpa_supplicant_optimize_freqs()
384 wpa_s->p2p_in_provisioning++; in wpa_supplicant_optimize_freqs()
387 if (params->freqs == NULL && wpa_s->p2p_in_invitation) { in wpa_supplicant_optimize_freqs()
392 if (wpa_s->p2p_in_invitation < 5 && in wpa_supplicant_optimize_freqs()
393 wpa_s->p2p_invite_go_freq > 0) { in wpa_supplicant_optimize_freqs()
394 wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Scan only GO preferred frequency %d MHz during invitation", in wpa_supplicant_optimize_freqs()
395 wpa_s->p2p_invite_go_freq); in wpa_supplicant_optimize_freqs()
398 params->freqs[0] = wpa_s->p2p_invite_go_freq; in wpa_supplicant_optimize_freqs()
400 wpa_s->p2p_in_invitation++; in wpa_supplicant_optimize_freqs()
401 if (wpa_s->p2p_in_invitation > 20) { in wpa_supplicant_optimize_freqs()
408 wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Clear p2p_in_invitation"); in wpa_supplicant_optimize_freqs()
409 wpa_s->p2p_in_invitation = 0; in wpa_supplicant_optimize_freqs()
415 if (params->freqs == NULL && wpa_s->after_wps && wpa_s->wps_freq) { in wpa_supplicant_optimize_freqs()
420 wpa_dbg(wpa_s, MSG_DEBUG, "WPS: Scan only frequency %u MHz " in wpa_supplicant_optimize_freqs()
421 "that was used during provisioning", wpa_s->wps_freq); in wpa_supplicant_optimize_freqs()
424 params->freqs[0] = wpa_s->wps_freq; in wpa_supplicant_optimize_freqs()
425 wpa_s->after_wps--; in wpa_supplicant_optimize_freqs()
426 } else if (wpa_s->after_wps) in wpa_supplicant_optimize_freqs()
427 wpa_s->after_wps--; in wpa_supplicant_optimize_freqs()
429 if (params->freqs == NULL && wpa_s->known_wps_freq && wpa_s->wps_freq) in wpa_supplicant_optimize_freqs()
432 wpa_dbg(wpa_s, MSG_DEBUG, "WPS: Scan only frequency %u MHz", in wpa_supplicant_optimize_freqs()
433 wpa_s->wps_freq); in wpa_supplicant_optimize_freqs()
436 params->freqs[0] = wpa_s->wps_freq; in wpa_supplicant_optimize_freqs()
437 wpa_s->known_wps_freq = 0; /* only do this once */ in wpa_supplicant_optimize_freqs()
444 static void wpas_add_interworking_elements(struct wpa_supplicant *wpa_s, in wpas_add_interworking_elements() argument
448 wpabuf_put_u8(buf, is_zero_ether_addr(wpa_s->conf->hessid) ? 1 : in wpas_add_interworking_elements()
450 wpabuf_put_u8(buf, wpa_s->conf->access_network_type); in wpas_add_interworking_elements()
452 if (!is_zero_ether_addr(wpa_s->conf->hessid)) in wpas_add_interworking_elements()
453 wpabuf_put_data(buf, wpa_s->conf->hessid, ETH_ALEN); in wpas_add_interworking_elements()
459 static void wpas_fils_req_param_add_max_channel(struct wpa_supplicant *wpa_s, in wpas_fils_req_param_add_max_channel() argument
485 void wpa_supplicant_set_default_scan_ies(struct wpa_supplicant *wpa_s) in wpa_supplicant_set_default_scan_ies() argument
493 if (wpa_s->p2p_group_interface == P2P_GROUP_INTERFACE_CLIENT) in wpa_supplicant_set_default_scan_ies()
497 wpa_drv_get_ext_capa(wpa_s, type); in wpa_supplicant_set_default_scan_ies()
499 ext_capab_len = wpas_build_ext_capab(wpa_s, ext_capab, in wpa_supplicant_set_default_scan_ies()
506 if (wpa_s->enable_oce & OCE_STA) in wpa_supplicant_set_default_scan_ies()
507 wpas_fils_req_param_add_max_channel(wpa_s, &default_ies); in wpa_supplicant_set_default_scan_ies()
510 wpas_mbo_scan_ie(wpa_s, default_ies); in wpa_supplicant_set_default_scan_ies()
514 wpa_drv_set_default_scan_ies(wpa_s, wpabuf_head(default_ies), in wpa_supplicant_set_default_scan_ies()
520 static struct wpabuf * wpa_supplicant_extra_ies(struct wpa_supplicant *wpa_s) in wpa_supplicant_extra_ies() argument
531 if (wpa_s->p2p_group_interface == P2P_GROUP_INTERFACE_CLIENT) in wpa_supplicant_extra_ies()
532 wpa_drv_get_ext_capa(wpa_s, WPA_IF_P2P_CLIENT); in wpa_supplicant_extra_ies()
535 wpa_drv_get_ext_capa(wpa_s, WPA_IF_STATION); in wpa_supplicant_extra_ies()
537 ext_capab_len = wpas_build_ext_capab(wpa_s, ext_capab, in wpa_supplicant_extra_ies()
544 if (wpa_s->conf->interworking && in wpa_supplicant_extra_ies()
546 wpas_add_interworking_elements(wpa_s, extra_ie); in wpa_supplicant_extra_ies()
550 if (wpa_s->enable_oce & OCE_STA) in wpa_supplicant_extra_ies()
551 wpas_fils_req_param_add_max_channel(wpa_s, &extra_ie); in wpa_supplicant_extra_ies()
555 wps = wpas_wps_in_use(wpa_s, &req_type); in wpa_supplicant_extra_ies()
561 &wpa_s->wps->dev, in wpa_supplicant_extra_ies()
562 wpa_s->wps->uuid, req_type, in wpa_supplicant_extra_ies()
573 size_t ielen = p2p_scan_ie_buf_len(wpa_s->global->p2p); in wpa_supplicant_extra_ies()
575 wpas_p2p_scan_ie(wpa_s, extra_ie); in wpa_supplicant_extra_ies()
579 wpa_supplicant_mesh_add_scan_ie(wpa_s, &extra_ie); in wpa_supplicant_extra_ies()
584 if (wpa_s->conf->hs20 && wpabuf_resize(&extra_ie, 9) == 0) in wpa_supplicant_extra_ies()
589 if (wpa_s->fst_ies && in wpa_supplicant_extra_ies()
590 wpabuf_resize(&extra_ie, wpabuf_len(wpa_s->fst_ies)) == 0) in wpa_supplicant_extra_ies()
591 wpabuf_put_buf(extra_ie, wpa_s->fst_ies); in wpa_supplicant_extra_ies()
597 wpas_mbo_scan_ie(wpa_s, extra_ie); in wpa_supplicant_extra_ies()
600 if (wpa_s->vendor_elem[VENDOR_ELEM_PROBE_REQ]) { in wpa_supplicant_extra_ies()
601 struct wpabuf *buf = wpa_s->vendor_elem[VENDOR_ELEM_PROBE_REQ]; in wpa_supplicant_extra_ies()
617 static int non_p2p_network_enabled(struct wpa_supplicant *wpa_s) in non_p2p_network_enabled() argument
621 for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next) { in non_p2p_network_enabled()
622 if (wpas_network_disabled(wpa_s, ssid)) in non_p2p_network_enabled()
628 if (wpa_s->conf->cred && wpa_s->conf->interworking && in non_p2p_network_enabled()
629 wpa_s->conf->auto_interworking) in non_p2p_network_enabled()
638 static void wpa_setband_scan_freqs_list(struct wpa_supplicant *wpa_s, in wpa_setband_scan_freqs_list() argument
646 mode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes, band); in wpa_setband_scan_freqs_list()
664 static void wpa_setband_scan_freqs(struct wpa_supplicant *wpa_s, in wpa_setband_scan_freqs() argument
667 if (wpa_s->hw.modes == NULL) in wpa_setband_scan_freqs()
671 if (wpa_s->setband == WPA_SETBAND_5G) in wpa_setband_scan_freqs()
672 wpa_setband_scan_freqs_list(wpa_s, HOSTAPD_MODE_IEEE80211A, in wpa_setband_scan_freqs()
674 else if (wpa_s->setband == WPA_SETBAND_2G) in wpa_setband_scan_freqs()
675 wpa_setband_scan_freqs_list(wpa_s, HOSTAPD_MODE_IEEE80211G, in wpa_setband_scan_freqs()
680 static void wpa_add_scan_ssid(struct wpa_supplicant *wpa_s, in wpa_add_scan_ssid() argument
707 static void wpa_add_owe_scan_ssid(struct wpa_supplicant *wpa_s, in wpa_add_owe_scan_ssid() argument
720 dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) { in wpa_add_owe_scan_ssid()
753 wpa_add_scan_ssid(wpa_s, params, max_ssids, in wpa_add_owe_scan_ssid()
761 static void wpa_set_scan_ssids(struct wpa_supplicant *wpa_s, in wpa_set_scan_ssids() argument
774 for (i = 0; i < wpa_s->scan_id_count; i++) { in wpa_set_scan_ssids()
775 ssid = wpa_config_get_network(wpa_s->conf, wpa_s->scan_id[i]); in wpa_set_scan_ssids()
779 wpa_add_scan_ssid(wpa_s, params, max_ssids, in wpa_set_scan_ssids()
785 wpa_add_owe_scan_ssid(wpa_s, params, ssid, max_ssids); in wpa_set_scan_ssids()
788 wpa_s->scan_id_count = 0; in wpa_set_scan_ssids()
792 static int wpa_set_ssids_from_scan_req(struct wpa_supplicant *wpa_s, in wpa_set_ssids_from_scan_req() argument
798 if (wpa_s->ssids_from_scan_req == NULL || in wpa_set_ssids_from_scan_req()
799 wpa_s->num_ssids_from_scan_req == 0) in wpa_set_ssids_from_scan_req()
802 if (wpa_s->num_ssids_from_scan_req > max_ssids) { in wpa_set_ssids_from_scan_req()
803 wpa_s->num_ssids_from_scan_req = max_ssids; in wpa_set_ssids_from_scan_req()
808 for (i = 0; i < wpa_s->num_ssids_from_scan_req; i++) { in wpa_set_ssids_from_scan_req()
809 params->ssids[i].ssid = wpa_s->ssids_from_scan_req[i].ssid; in wpa_set_ssids_from_scan_req()
811 wpa_s->ssids_from_scan_req[i].ssid_len; in wpa_set_ssids_from_scan_req()
817 params->num_ssids = wpa_s->num_ssids_from_scan_req; in wpa_set_ssids_from_scan_req()
818 wpa_s->num_ssids_from_scan_req = 0; in wpa_set_ssids_from_scan_req()
825 struct wpa_supplicant *wpa_s = eloop_ctx; in wpa_supplicant_scan() local
834 wpa_s->ignore_post_flush_scan_res = 0; in wpa_supplicant_scan()
836 if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) { in wpa_supplicant_scan()
837 wpa_dbg(wpa_s, MSG_DEBUG, "Skip scan - interface disabled"); in wpa_supplicant_scan()
841 if (wpa_s->disconnected && wpa_s->scan_req == NORMAL_SCAN_REQ) { in wpa_supplicant_scan()
842 wpa_dbg(wpa_s, MSG_DEBUG, "Disconnected - do not scan"); in wpa_supplicant_scan()
843 wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED); in wpa_supplicant_scan()
847 if (wpa_s->scanning) { in wpa_supplicant_scan()
852 wpa_dbg(wpa_s, MSG_DEBUG, "Already scanning - Reschedule the incoming scan req"); in wpa_supplicant_scan()
853 wpa_supplicant_req_scan(wpa_s, 1, 0); in wpa_supplicant_scan()
857 if (!wpa_supplicant_enabled_networks(wpa_s) && in wpa_supplicant_scan()
858 wpa_s->scan_req == NORMAL_SCAN_REQ) { in wpa_supplicant_scan()
859 wpa_dbg(wpa_s, MSG_DEBUG, "No enabled networks - do not scan"); in wpa_supplicant_scan()
860 wpa_supplicant_set_state(wpa_s, WPA_INACTIVE); in wpa_supplicant_scan()
864 if (wpa_s->conf->ap_scan != 0 && in wpa_supplicant_scan()
865 (wpa_s->drv_flags & WPA_DRIVER_FLAGS_WIRED)) { in wpa_supplicant_scan()
866 wpa_dbg(wpa_s, MSG_DEBUG, "Using wired authentication - " in wpa_supplicant_scan()
868 wpa_s->conf->ap_scan = 0; in wpa_supplicant_scan()
869 wpas_notify_ap_scan_changed(wpa_s); in wpa_supplicant_scan()
872 if (wpa_s->conf->ap_scan == 0) { in wpa_supplicant_scan()
873 wpa_supplicant_gen_assoc_event(wpa_s); in wpa_supplicant_scan()
878 if (wpa_s->scan_req != MANUAL_SCAN_REQ && in wpa_supplicant_scan()
879 wpa_s->connect_without_scan) { in wpa_supplicant_scan()
881 for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next) { in wpa_supplicant_scan()
882 if (ssid == wpa_s->connect_without_scan) in wpa_supplicant_scan()
887 p2p_in_prog = wpas_p2p_in_progress(wpa_s); in wpa_supplicant_scan()
891 wpa_dbg(wpa_s, MSG_DEBUG, "Delay station mode scan while P2P operation is in progress"); in wpa_supplicant_scan()
892 wpa_supplicant_req_scan(wpa_s, 5, 0); in wpa_supplicant_scan()
905 if (wpa_s->pno || wpa_s->pno_sched_pending) { in wpa_supplicant_scan()
906 wpa_dbg(wpa_s, MSG_DEBUG, "Defer scan - PNO is in progress"); in wpa_supplicant_scan()
907 wpa_supplicant_req_scan(wpa_s, 0, 100000); in wpa_supplicant_scan()
911 if (wpa_s->conf->ap_scan == 2) in wpa_supplicant_scan()
914 max_ssids = wpa_s->max_scan_ssids; in wpa_supplicant_scan()
919 wpa_s->last_scan_req = wpa_s->scan_req; in wpa_supplicant_scan()
920 wpa_s->scan_req = NORMAL_SCAN_REQ; in wpa_supplicant_scan()
923 wpa_s->connect_without_scan = NULL; in wpa_supplicant_scan()
927 wpa_supplicant_associate(wpa_s, NULL, ssid); in wpa_supplicant_scan()
934 wpa_s->scan_prev_wpa_state = wpa_s->wpa_state; in wpa_supplicant_scan()
935 if (wpa_s->wpa_state == WPA_DISCONNECTED || in wpa_supplicant_scan()
936 wpa_s->wpa_state == WPA_INACTIVE) in wpa_supplicant_scan()
937 wpa_supplicant_set_state(wpa_s, WPA_SCANNING); in wpa_supplicant_scan()
942 if (wpa_s->autoscan_params != NULL) { in wpa_supplicant_scan()
943 scan_params = wpa_s->autoscan_params; in wpa_supplicant_scan()
947 if (wpa_s->last_scan_req == MANUAL_SCAN_REQ && in wpa_supplicant_scan()
948 wpa_set_ssids_from_scan_req(wpa_s, &params, max_ssids)) { in wpa_supplicant_scan()
954 if ((wpa_s->p2p_in_provisioning || wpa_s->show_group_started) && in wpa_supplicant_scan()
955 wpa_s->go_params && !wpa_s->conf->passive_scan) { in wpa_supplicant_scan()
957 wpa_s->p2p_in_provisioning, in wpa_supplicant_scan()
958 wpa_s->show_group_started); in wpa_supplicant_scan()
959 params.ssids[0].ssid = wpa_s->go_params->ssid; in wpa_supplicant_scan()
960 params.ssids[0].ssid_len = wpa_s->go_params->ssid_len; in wpa_supplicant_scan()
965 if (wpa_s->p2p_in_invitation) { in wpa_supplicant_scan()
966 if (wpa_s->current_ssid) { in wpa_supplicant_scan()
968 params.ssids[0].ssid = wpa_s->current_ssid->ssid; in wpa_supplicant_scan()
970 wpa_s->current_ssid->ssid_len; in wpa_supplicant_scan()
980 ssid = wpa_s->conf->ssid; in wpa_supplicant_scan()
981 if (wpa_s->prev_scan_ssid != WILDCARD_SSID_SCAN) { in wpa_supplicant_scan()
983 if (ssid == wpa_s->prev_scan_ssid) { in wpa_supplicant_scan()
991 if (wpa_s->last_scan_req != MANUAL_SCAN_REQ && in wpa_supplicant_scan()
993 !wpa_s->ap_iface && in wpa_supplicant_scan()
995 wpa_s->conf->ap_scan == 2) { in wpa_supplicant_scan()
996 wpa_s->connect_without_scan = NULL; in wpa_supplicant_scan()
997 wpa_s->prev_scan_wildcard = 0; in wpa_supplicant_scan()
998 wpa_supplicant_assoc_try(wpa_s, ssid); in wpa_supplicant_scan()
1000 } else if (wpa_s->conf->ap_scan == 2) { in wpa_supplicant_scan()
1006 } else if (wpa_s->reattach && wpa_s->current_ssid != NULL) { in wpa_supplicant_scan()
1012 ssid = wpa_s->current_ssid; in wpa_supplicant_scan()
1025 params.freqs[0] = wpa_s->assoc_freq; in wpa_supplicant_scan()
1033 wpa_s->reattach = 0; in wpa_supplicant_scan()
1038 ssid = wpa_s->conf->ssid; in wpa_supplicant_scan()
1040 if (!wpas_network_disabled(wpa_s, ssid) && in wpa_supplicant_scan()
1053 if (!wpas_network_disabled(wpa_s, ssid)) { in wpa_supplicant_scan()
1059 wpa_add_owe_scan_ssid(wpa_s, &params, ssid, in wpa_supplicant_scan()
1067 start != wpa_s->conf->ssid) in wpa_supplicant_scan()
1068 ssid = wpa_s->conf->ssid; in wpa_supplicant_scan()
1071 if (wpa_s->scan_id_count && in wpa_supplicant_scan()
1072 wpa_s->last_scan_req == MANUAL_SCAN_REQ) in wpa_supplicant_scan()
1073 wpa_set_scan_ssids(wpa_s, &params, max_ssids); in wpa_supplicant_scan()
1075 for (tssid = wpa_s->conf->ssid; in wpa_supplicant_scan()
1076 wpa_s->last_scan_req != MANUAL_SCAN_REQ && tssid; in wpa_supplicant_scan()
1078 if (wpas_network_disabled(wpa_s, tssid)) in wpa_supplicant_scan()
1098 if (!wpa_s->prev_scan_wildcard) { in wpa_supplicant_scan()
1101 wpa_s->prev_scan_wildcard = 1; in wpa_supplicant_scan()
1102 wpa_dbg(wpa_s, MSG_DEBUG, "Starting AP scan for " in wpa_supplicant_scan()
1105 wpa_s->prev_scan_ssid = ssid; in wpa_supplicant_scan()
1106 wpa_s->prev_scan_wildcard = 0; in wpa_supplicant_scan()
1107 wpa_dbg(wpa_s, MSG_DEBUG, in wpa_supplicant_scan()
1114 wpa_s->prev_scan_ssid = ssid; in wpa_supplicant_scan()
1115 wpa_dbg(wpa_s, MSG_DEBUG, "Include wildcard SSID in " in wpa_supplicant_scan()
1118 } else if (wpa_s->last_scan_req == MANUAL_SCAN_REQ && in wpa_supplicant_scan()
1119 wpa_s->manual_scan_passive && params.num_ssids == 0) { in wpa_supplicant_scan()
1120 wpa_dbg(wpa_s, MSG_DEBUG, "Use passive scan based on manual request"); in wpa_supplicant_scan()
1121 } else if (wpa_s->conf->passive_scan) { in wpa_supplicant_scan()
1122 wpa_dbg(wpa_s, MSG_DEBUG, in wpa_supplicant_scan()
1125 wpa_s->prev_scan_ssid = WILDCARD_SSID_SCAN; in wpa_supplicant_scan()
1127 wpa_dbg(wpa_s, MSG_DEBUG, "Starting AP scan for wildcard " in wpa_supplicant_scan()
1132 wpa_supplicant_optimize_freqs(wpa_s, &params); in wpa_supplicant_scan()
1133 extra_ie = wpa_supplicant_extra_ies(wpa_s); in wpa_supplicant_scan()
1135 if (wpa_s->last_scan_req == MANUAL_SCAN_REQ && in wpa_supplicant_scan()
1136 wpa_s->manual_scan_only_new) { in wpa_supplicant_scan()
1142 if (wpa_s->last_scan_req == MANUAL_SCAN_REQ && params.freqs == NULL && in wpa_supplicant_scan()
1143 wpa_s->manual_scan_freqs) { in wpa_supplicant_scan()
1144 wpa_dbg(wpa_s, MSG_DEBUG, "Limit manual scan to specified channels"); in wpa_supplicant_scan()
1145 params.freqs = wpa_s->manual_scan_freqs; in wpa_supplicant_scan()
1146 wpa_s->manual_scan_freqs = NULL; in wpa_supplicant_scan()
1149 if (params.freqs == NULL && wpa_s->select_network_scan_freqs) { in wpa_supplicant_scan()
1150 wpa_dbg(wpa_s, MSG_DEBUG, in wpa_supplicant_scan()
1152 params.freqs = wpa_s->select_network_scan_freqs; in wpa_supplicant_scan()
1153 wpa_s->select_network_scan_freqs = NULL; in wpa_supplicant_scan()
1156 if (params.freqs == NULL && wpa_s->next_scan_freqs) { in wpa_supplicant_scan()
1157 wpa_dbg(wpa_s, MSG_DEBUG, "Optimize scan based on previously " in wpa_supplicant_scan()
1159 params.freqs = wpa_s->next_scan_freqs; in wpa_supplicant_scan()
1161 os_free(wpa_s->next_scan_freqs); in wpa_supplicant_scan()
1162 wpa_s->next_scan_freqs = NULL; in wpa_supplicant_scan()
1163 wpa_setband_scan_freqs(wpa_s, &params); in wpa_supplicant_scan()
1166 if (wpa_s->conf->freq_list && !params.freqs) { in wpa_supplicant_scan()
1167 wpa_dbg(wpa_s, MSG_DEBUG, in wpa_supplicant_scan()
1169 int_array_concat(&params.freqs, wpa_s->conf->freq_list); in wpa_supplicant_scan()
1173 if (wpa_s->conf->scan_cur_freq && !params.freqs) { in wpa_supplicant_scan()
1174 unsigned int num = wpa_s->num_multichan_concurrent; in wpa_supplicant_scan()
1178 num = get_shared_radio_freqs(wpa_s, params.freqs, num); in wpa_supplicant_scan()
1180 wpa_dbg(wpa_s, MSG_DEBUG, "Scan only the " in wpa_supplicant_scan()
1191 if (wpa_s->enable_oce & OCE_STA) in wpa_supplicant_scan()
1196 wpa_s->conf, &params.num_filter_ssids); in wpa_supplicant_scan()
1203 if (wpa_s->p2p_in_provisioning || wpa_s->p2p_in_invitation || in wpa_supplicant_scan()
1204 (wpa_s->show_group_started && wpa_s->go_params)) { in wpa_supplicant_scan()
1213 if ((wpa_s->mac_addr_rand_enable & MAC_ADDR_RAND_SCAN) && in wpa_supplicant_scan()
1214 wpa_s->wpa_state <= WPA_SCANNING) { in wpa_supplicant_scan()
1216 if (wpa_s->mac_addr_scan) { in wpa_supplicant_scan()
1217 params.mac_addr = wpa_s->mac_addr_scan; in wpa_supplicant_scan()
1218 params.mac_addr_mask = wpa_s->mac_addr_scan + ETH_ALEN; in wpa_supplicant_scan()
1222 if (!is_zero_ether_addr(wpa_s->next_scan_bssid)) { in wpa_supplicant_scan()
1225 params.bssid = wpa_s->next_scan_bssid; in wpa_supplicant_scan()
1226 bss = wpa_bss_get_bssid_latest(wpa_s, params.bssid); in wpa_supplicant_scan()
1231 wpa_dbg(wpa_s, MSG_DEBUG, in wpa_supplicant_scan()
1237 wpa_dbg(wpa_s, MSG_DEBUG, in wpa_supplicant_scan()
1256 if (wpa_s->scan_for_connection && in wpa_supplicant_scan()
1257 wpa_s->last_scan_req == NORMAL_SCAN_REQ && in wpa_supplicant_scan()
1259 wpas_is_p2p_prioritized(wpa_s) && in wpa_supplicant_scan()
1260 wpa_s->p2p_group_interface == NOT_P2P_GROUP_INTERFACE && in wpa_supplicant_scan()
1261 non_p2p_network_enabled(wpa_s)) { in wpa_supplicant_scan()
1262 unsigned int num = wpa_s->num_multichan_concurrent; in wpa_supplicant_scan()
1266 num = get_shared_radio_freqs(wpa_s, params.freqs, num); in wpa_supplicant_scan()
1267 if (num > 0 && num == wpa_s->num_multichan_concurrent) { in wpa_supplicant_scan()
1268 …wpa_dbg(wpa_s, MSG_DEBUG, "Scan only the current operating channels since all channels are already… in wpa_supplicant_scan()
1277 ret = wpa_supplicant_trigger_scan(wpa_s, scan_params); in wpa_supplicant_scan()
1279 if (ret && wpa_s->last_scan_req == MANUAL_SCAN_REQ && params.freqs && in wpa_supplicant_scan()
1280 !wpa_s->manual_scan_freqs) { in wpa_supplicant_scan()
1282 wpa_s->manual_scan_freqs = params.freqs; in wpa_supplicant_scan()
1291 wpa_msg(wpa_s, MSG_WARNING, "Failed to initiate AP scan"); in wpa_supplicant_scan()
1292 if (wpa_s->scan_prev_wpa_state != wpa_s->wpa_state) in wpa_supplicant_scan()
1293 wpa_supplicant_set_state(wpa_s, in wpa_supplicant_scan()
1294 wpa_s->scan_prev_wpa_state); in wpa_supplicant_scan()
1296 wpa_s->scan_req = wpa_s->last_scan_req; in wpa_supplicant_scan()
1297 wpa_supplicant_req_scan(wpa_s, 1, 0); in wpa_supplicant_scan()
1299 wpa_s->scan_for_connection = 0; in wpa_supplicant_scan()
1301 wpa_s->interworking_fast_assoc_tried = 0; in wpa_supplicant_scan()
1304 os_memset(wpa_s->next_scan_bssid, 0, ETH_ALEN); in wpa_supplicant_scan()
1309 void wpa_supplicant_update_scan_int(struct wpa_supplicant *wpa_s, int sec) in wpa_supplicant_update_scan_int() argument
1314 cancelled = eloop_cancel_timeout_one(wpa_supplicant_scan, wpa_s, NULL, in wpa_supplicant_update_scan_int()
1326 wpa_supplicant_scan, wpa_s, NULL); in wpa_supplicant_update_scan_int()
1328 wpa_s->scan_interval = sec; in wpa_supplicant_update_scan_int()
1341 void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec) in wpa_supplicant_req_scan() argument
1345 if (wpa_s->p2p_mgmt) { in wpa_supplicant_req_scan()
1346 wpa_dbg(wpa_s, MSG_DEBUG, in wpa_supplicant_req_scan()
1352 res = eloop_deplete_timeout(sec, usec, wpa_supplicant_scan, wpa_s, in wpa_supplicant_req_scan()
1355 wpa_dbg(wpa_s, MSG_DEBUG, "Rescheduling scan request: %d.%06d sec", in wpa_supplicant_req_scan()
1358 …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()
1361 wpa_dbg(wpa_s, MSG_DEBUG, "Setting scan request: %d.%06d sec", in wpa_supplicant_req_scan()
1363 eloop_register_timeout(sec, usec, wpa_supplicant_scan, wpa_s, NULL); in wpa_supplicant_req_scan()
1378 int wpa_supplicant_delayed_sched_scan(struct wpa_supplicant *wpa_s, in wpa_supplicant_delayed_sched_scan() argument
1381 if (!wpa_s->sched_scan_supported) in wpa_supplicant_delayed_sched_scan()
1386 wpa_s, NULL); in wpa_supplicant_delayed_sched_scan()
1393 wpa_scan_set_relative_rssi_params(struct wpa_supplicant *wpa_s, in wpa_scan_set_relative_rssi_params() argument
1396 if (wpa_s->wpa_state != WPA_COMPLETED || in wpa_scan_set_relative_rssi_params()
1397 !(wpa_s->drv_flags & WPA_DRIVER_FLAGS_SCHED_SCAN_RELATIVE_RSSI) || in wpa_scan_set_relative_rssi_params()
1398 wpa_s->srp.relative_rssi_set == 0) in wpa_scan_set_relative_rssi_params()
1402 params->relative_rssi = wpa_s->srp.relative_rssi; in wpa_scan_set_relative_rssi_params()
1404 if (wpa_s->srp.relative_adjust_rssi == 0) in wpa_scan_set_relative_rssi_params()
1407 params->relative_adjust_band = wpa_s->srp.relative_adjust_band; in wpa_scan_set_relative_rssi_params()
1408 params->relative_adjust_rssi = wpa_s->srp.relative_adjust_rssi; in wpa_scan_set_relative_rssi_params()
1420 int wpa_supplicant_req_sched_scan(struct wpa_supplicant *wpa_s) in wpa_supplicant_req_sched_scan() argument
1433 if (!wpa_s->sched_scan_supported) in wpa_supplicant_req_sched_scan()
1436 if (wpa_s->max_sched_scan_ssids > WPAS_MAX_SCAN_SSIDS) in wpa_supplicant_req_sched_scan()
1439 max_sched_scan_ssids = wpa_s->max_sched_scan_ssids; in wpa_supplicant_req_sched_scan()
1440 if (max_sched_scan_ssids < 1 || wpa_s->conf->disable_scan_offload) in wpa_supplicant_req_sched_scan()
1443 wpa_s->sched_scan_stop_req = 0; in wpa_supplicant_req_sched_scan()
1445 if (wpa_s->sched_scanning) { in wpa_supplicant_req_sched_scan()
1446 wpa_dbg(wpa_s, MSG_DEBUG, "Already sched scanning"); in wpa_supplicant_req_sched_scan()
1451 for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next) { in wpa_supplicant_req_sched_scan()
1452 if (!wpas_network_disabled(wpa_s, ssid) && !ssid->scan_ssid) { in wpa_supplicant_req_sched_scan()
1455 } else if (!wpas_network_disabled(wpa_s, ssid) && in wpa_supplicant_req_sched_scan()
1460 if (!wpas_network_disabled(wpa_s, ssid) && in wpa_supplicant_req_sched_scan()
1468 wpa_dbg(wpa_s, MSG_DEBUG, "Use normal scan instead of " in wpa_supplicant_req_sched_scan()
1477 if (wpa_s->normal_scans < 3 && in wpa_supplicant_req_sched_scan()
1478 (need_ssids <= wpa_s->max_scan_ssids || in wpa_supplicant_req_sched_scan()
1479 wpa_s->max_scan_ssids >= (int) max_sched_scan_ssids)) { in wpa_supplicant_req_sched_scan()
1487 wpa_dbg(wpa_s, MSG_DEBUG, "Use normal scan instead of " in wpa_supplicant_req_sched_scan()
1489 wpa_s->normal_scans); in wpa_supplicant_req_sched_scan()
1496 params.filter_ssids = os_calloc(wpa_s->max_match_sets, in wpa_supplicant_req_sched_scan()
1499 prev_state = wpa_s->wpa_state; in wpa_supplicant_req_sched_scan()
1500 if (wpa_s->wpa_state == WPA_DISCONNECTED || in wpa_supplicant_req_sched_scan()
1501 wpa_s->wpa_state == WPA_INACTIVE) in wpa_supplicant_req_sched_scan()
1502 wpa_supplicant_set_state(wpa_s, WPA_SCANNING); in wpa_supplicant_req_sched_scan()
1504 if (wpa_s->autoscan_params != NULL) { in wpa_supplicant_req_sched_scan()
1505 scan_params = wpa_s->autoscan_params; in wpa_supplicant_req_sched_scan()
1510 ssid = wpa_s->conf->ssid; in wpa_supplicant_req_sched_scan()
1511 if (wpa_s->prev_sched_ssid) { in wpa_supplicant_req_sched_scan()
1513 if (ssid == wpa_s->prev_sched_ssid) { in wpa_supplicant_req_sched_scan()
1521 if (!ssid || !wpa_s->prev_sched_ssid) { in wpa_supplicant_req_sched_scan()
1522 wpa_dbg(wpa_s, MSG_DEBUG, "Beginning of SSID list"); in wpa_supplicant_req_sched_scan()
1523 wpa_s->sched_scan_timeout = max_sched_scan_ssids * 2; in wpa_supplicant_req_sched_scan()
1524 wpa_s->first_sched_scan = 1; in wpa_supplicant_req_sched_scan()
1525 ssid = wpa_s->conf->ssid; in wpa_supplicant_req_sched_scan()
1526 wpa_s->prev_sched_ssid = ssid; in wpa_supplicant_req_sched_scan()
1530 wpa_dbg(wpa_s, MSG_DEBUG, "Add wildcard SSID to sched_scan"); in wpa_supplicant_req_sched_scan()
1535 if (wpas_network_disabled(wpa_s, ssid)) in wpa_supplicant_req_sched_scan()
1538 if (params.num_filter_ssids < wpa_s->max_match_sets && in wpa_supplicant_req_sched_scan()
1540 wpa_dbg(wpa_s, MSG_DEBUG, "add to filter ssid: %s", in wpa_supplicant_req_sched_scan()
1549 wpa_dbg(wpa_s, MSG_DEBUG, "Not enough room for SSID " in wpa_supplicant_req_sched_scan()
1559 wpa_dbg(wpa_s, MSG_DEBUG, in wpa_supplicant_req_sched_scan()
1568 wpa_s->prev_sched_ssid = ssid; in wpa_supplicant_req_sched_scan()
1572 (wpas_network_disabled(wpa_s, ssid) || in wpa_supplicant_req_sched_scan()
1579 wpa_s->prev_sched_ssid = ssid; in wpa_supplicant_req_sched_scan()
1588 extra_ie = wpa_supplicant_extra_ies(wpa_s); in wpa_supplicant_req_sched_scan()
1594 if (wpa_s->conf->filter_rssi) in wpa_supplicant_req_sched_scan()
1595 params.filter_rssi = wpa_s->conf->filter_rssi; in wpa_supplicant_req_sched_scan()
1598 if (wpa_s->conf->freq_list && !params.freqs) { in wpa_supplicant_req_sched_scan()
1599 wpa_dbg(wpa_s, MSG_DEBUG, in wpa_supplicant_req_sched_scan()
1601 int_array_concat(&params.freqs, wpa_s->conf->freq_list); in wpa_supplicant_req_sched_scan()
1605 if (wpa_s->enable_oce & OCE_STA) in wpa_supplicant_req_sched_scan()
1612 wpa_s->sched_scan_timed_out = 0; in wpa_supplicant_req_sched_scan()
1619 if (wpa_s->sched_scan_plans_num == 1 || in wpa_supplicant_req_sched_scan()
1620 (wpa_s->sched_scan_plans_num && !ssid && wpa_s->first_sched_scan)) { in wpa_supplicant_req_sched_scan()
1621 params.sched_scan_plans = wpa_s->sched_scan_plans; in wpa_supplicant_req_sched_scan()
1622 params.sched_scan_plans_num = wpa_s->sched_scan_plans_num; in wpa_supplicant_req_sched_scan()
1623 } else if (wpa_s->sched_scan_plans_num > 1) { in wpa_supplicant_req_sched_scan()
1624 wpa_dbg(wpa_s, MSG_DEBUG, in wpa_supplicant_req_sched_scan()
1627 &wpa_s->sched_scan_plans[wpa_s->sched_scan_plans_num - in wpa_supplicant_req_sched_scan()
1631 if (wpa_s->conf->sched_scan_interval) in wpa_supplicant_req_sched_scan()
1632 scan_plan.interval = wpa_s->conf->sched_scan_interval; in wpa_supplicant_req_sched_scan()
1636 if (scan_plan.interval > wpa_s->max_sched_scan_plan_interval) { in wpa_supplicant_req_sched_scan()
1640 wpa_s->max_sched_scan_plan_interval); in wpa_supplicant_req_sched_scan()
1642 wpa_s->max_sched_scan_plan_interval; in wpa_supplicant_req_sched_scan()
1650 params.sched_scan_start_delay = wpa_s->conf->sched_scan_start_delay; in wpa_supplicant_req_sched_scan()
1652 if (ssid || !wpa_s->first_sched_scan) { in wpa_supplicant_req_sched_scan()
1653 wpa_dbg(wpa_s, MSG_DEBUG, in wpa_supplicant_req_sched_scan()
1657 wpa_s->sched_scan_timeout); in wpa_supplicant_req_sched_scan()
1659 wpa_dbg(wpa_s, MSG_DEBUG, in wpa_supplicant_req_sched_scan()
1664 wpa_setband_scan_freqs(wpa_s, scan_params); in wpa_supplicant_req_sched_scan()
1666 if ((wpa_s->mac_addr_rand_enable & MAC_ADDR_RAND_SCHED_SCAN) && in wpa_supplicant_req_sched_scan()
1667 wpa_s->wpa_state <= WPA_SCANNING) { in wpa_supplicant_req_sched_scan()
1669 if (wpa_s->mac_addr_sched_scan) { in wpa_supplicant_req_sched_scan()
1670 params.mac_addr = wpa_s->mac_addr_sched_scan; in wpa_supplicant_req_sched_scan()
1671 params.mac_addr_mask = wpa_s->mac_addr_sched_scan + in wpa_supplicant_req_sched_scan()
1676 wpa_scan_set_relative_rssi_params(wpa_s, scan_params); in wpa_supplicant_req_sched_scan()
1678 ret = wpa_supplicant_start_sched_scan(wpa_s, scan_params); in wpa_supplicant_req_sched_scan()
1682 wpa_msg(wpa_s, MSG_WARNING, "Failed to initiate sched scan"); in wpa_supplicant_req_sched_scan()
1683 if (prev_state != wpa_s->wpa_state) in wpa_supplicant_req_sched_scan()
1684 wpa_supplicant_set_state(wpa_s, prev_state); in wpa_supplicant_req_sched_scan()
1689 if (ssid || !wpa_s->first_sched_scan) { in wpa_supplicant_req_sched_scan()
1690 wpa_s->sched_scan_timed_out = 0; in wpa_supplicant_req_sched_scan()
1691 eloop_register_timeout(wpa_s->sched_scan_timeout, 0, in wpa_supplicant_req_sched_scan()
1693 wpa_s, NULL); in wpa_supplicant_req_sched_scan()
1694 wpa_s->first_sched_scan = 0; in wpa_supplicant_req_sched_scan()
1695 wpa_s->sched_scan_timeout /= 2; in wpa_supplicant_req_sched_scan()
1697 if ((unsigned int) wpa_s->sched_scan_timeout < in wpa_supplicant_req_sched_scan()
1700 wpa_s->max_sched_scan_plan_interval) { in wpa_supplicant_req_sched_scan()
1702 wpa_s->sched_scan_timeout = max_sched_scan_ssids * 2; in wpa_supplicant_req_sched_scan()
1708 wpa_s->prev_sched_ssid = NULL; in wpa_supplicant_req_sched_scan()
1721 void wpa_supplicant_cancel_scan(struct wpa_supplicant *wpa_s) in wpa_supplicant_cancel_scan() argument
1723 wpa_dbg(wpa_s, MSG_DEBUG, "Cancelling scan request"); in wpa_supplicant_cancel_scan()
1724 eloop_cancel_timeout(wpa_supplicant_scan, wpa_s, NULL); in wpa_supplicant_cancel_scan()
1734 void wpa_supplicant_cancel_delayed_sched_scan(struct wpa_supplicant *wpa_s) in wpa_supplicant_cancel_delayed_sched_scan() argument
1736 if (!wpa_s->sched_scan_supported) in wpa_supplicant_cancel_delayed_sched_scan()
1739 wpa_dbg(wpa_s, MSG_DEBUG, "Cancelling delayed sched scan"); in wpa_supplicant_cancel_delayed_sched_scan()
1741 wpa_s, NULL); in wpa_supplicant_cancel_delayed_sched_scan()
1751 void wpa_supplicant_cancel_sched_scan(struct wpa_supplicant *wpa_s) in wpa_supplicant_cancel_sched_scan() argument
1753 if (!wpa_s->sched_scanning) in wpa_supplicant_cancel_sched_scan()
1756 if (wpa_s->sched_scanning) in wpa_supplicant_cancel_sched_scan()
1757 wpa_s->sched_scan_stop_req = 1; in wpa_supplicant_cancel_sched_scan()
1759 wpa_dbg(wpa_s, MSG_DEBUG, "Cancelling sched scan"); in wpa_supplicant_cancel_sched_scan()
1760 eloop_cancel_timeout(wpa_supplicant_sched_scan_timeout, wpa_s, NULL); in wpa_supplicant_cancel_sched_scan()
1761 wpa_supplicant_stop_sched_scan(wpa_s); in wpa_supplicant_cancel_sched_scan()
1775 void wpa_supplicant_notify_scanning(struct wpa_supplicant *wpa_s, in wpa_supplicant_notify_scanning() argument
1778 if (wpa_s->scanning != scanning) { in wpa_supplicant_notify_scanning()
1779 wpa_s->scanning = scanning; in wpa_supplicant_notify_scanning()
1780 wpas_notify_scanning(wpa_s); in wpa_supplicant_notify_scanning()
2114 int wpa_supplicant_filter_bssid_match(struct wpa_supplicant *wpa_s, in wpa_supplicant_filter_bssid_match() argument
2119 if (wpa_s->bssid_filter == NULL) in wpa_supplicant_filter_bssid_match()
2122 for (i = 0; i < wpa_s->bssid_filter_count; i++) { in wpa_supplicant_filter_bssid_match()
2123 if (os_memcmp(wpa_s->bssid_filter + i * ETH_ALEN, bssid, in wpa_supplicant_filter_bssid_match()
2132 void filter_scan_res(struct wpa_supplicant *wpa_s, in filter_scan_res() argument
2137 if (wpa_s->bssid_filter == NULL) in filter_scan_res()
2141 if (wpa_supplicant_filter_bssid_match(wpa_s, in filter_scan_res()
2250 void scan_est_throughput(struct wpa_supplicant *wpa_s, in scan_est_throughput() argument
2253 enum local_hw_capab capab = wpa_s->hw_capab; in scan_est_throughput()
2352 wpa_supplicant_get_scan_results(struct wpa_supplicant *wpa_s, in wpa_supplicant_get_scan_results() argument
2359 scan_res = wpa_drv_get_scan_results2(wpa_s); in wpa_supplicant_get_scan_results()
2361 wpa_dbg(wpa_s, MSG_DEBUG, "Failed to get scan results"); in wpa_supplicant_get_scan_results()
2371 filter_scan_res(wpa_s, scan_res); in wpa_supplicant_get_scan_results()
2377 scan_est_throughput(wpa_s, scan_res_item); in wpa_supplicant_get_scan_results()
2381 if (wpas_wps_searching(wpa_s)) { in wpa_supplicant_get_scan_results()
2382 wpa_dbg(wpa_s, MSG_DEBUG, "WPS: Order scan results with WPS " in wpa_supplicant_get_scan_results()
2394 if (wpa_s->ignore_post_flush_scan_res) { in wpa_supplicant_get_scan_results()
2398 wpa_dbg(wpa_s, MSG_DEBUG, in wpa_supplicant_get_scan_results()
2400 wpa_s->ignore_post_flush_scan_res = 0; in wpa_supplicant_get_scan_results()
2404 wpa_bss_update_start(wpa_s); in wpa_supplicant_get_scan_results()
2406 wpa_bss_update_scan_res(wpa_s, scan_res->res[i], in wpa_supplicant_get_scan_results()
2408 wpa_bss_update_end(wpa_s, info, new_scan); in wpa_supplicant_get_scan_results()
2426 int wpa_supplicant_update_scan_results(struct wpa_supplicant *wpa_s) in wpa_supplicant_update_scan_results() argument
2429 scan_res = wpa_supplicant_get_scan_results(wpa_s, NULL, 0); in wpa_supplicant_update_scan_results()
2441 void scan_only_handler(struct wpa_supplicant *wpa_s, in scan_only_handler() argument
2444 wpa_dbg(wpa_s, MSG_DEBUG, "Scan-only results received"); in scan_only_handler()
2445 if (wpa_s->last_scan_req == MANUAL_SCAN_REQ && in scan_only_handler()
2446 wpa_s->manual_scan_use_id && wpa_s->own_scan_running) { in scan_only_handler()
2447 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_SCAN_RESULTS "id=%u", in scan_only_handler()
2448 wpa_s->manual_scan_id); in scan_only_handler()
2449 wpa_s->manual_scan_use_id = 0; in scan_only_handler()
2451 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_SCAN_RESULTS); in scan_only_handler()
2453 wpas_notify_scan_results(wpa_s); in scan_only_handler()
2454 wpas_notify_scan_done(wpa_s, 1); in scan_only_handler()
2455 if (wpa_s->scan_work) { in scan_only_handler()
2456 struct wpa_radio_work *work = wpa_s->scan_work; in scan_only_handler()
2457 wpa_s->scan_work = NULL; in scan_only_handler()
2461 if (wpa_s->wpa_state == WPA_SCANNING) in scan_only_handler()
2462 wpa_supplicant_set_state(wpa_s, wpa_s->scan_prev_wpa_state); in scan_only_handler()
2466 int wpas_scan_scheduled(struct wpa_supplicant *wpa_s) in wpas_scan_scheduled() argument
2468 return eloop_is_timeout_registered(wpa_supplicant_scan, wpa_s, NULL); in wpas_scan_scheduled()
2603 int wpas_start_pno(struct wpa_supplicant *wpa_s) in wpas_start_pno() argument
2612 if (!wpa_s->sched_scan_supported) in wpas_start_pno()
2615 if (wpa_s->max_sched_scan_ssids > WPAS_MAX_SCAN_SSIDS) in wpas_start_pno()
2618 max_sched_scan_ssids = wpa_s->max_sched_scan_ssids; in wpas_start_pno()
2622 if (wpa_s->pno || wpa_s->pno_sched_pending) in wpas_start_pno()
2625 if ((wpa_s->wpa_state > WPA_SCANNING) && in wpas_start_pno()
2626 (wpa_s->wpa_state < WPA_COMPLETED)) { in wpas_start_pno()
2631 if (wpa_s->wpa_state == WPA_SCANNING) { in wpas_start_pno()
2632 wpa_supplicant_cancel_scan(wpa_s); in wpas_start_pno()
2633 if (wpa_s->sched_scanning) { in wpas_start_pno()
2636 wpa_supplicant_cancel_sched_scan(wpa_s); in wpas_start_pno()
2637 wpa_s->pno_sched_pending = 1; in wpas_start_pno()
2642 if (wpa_s->sched_scan_stop_req) { in wpas_start_pno()
2645 wpa_s->pno_sched_pending = 1; in wpas_start_pno()
2652 ssid = wpa_s->conf->ssid; in wpas_start_pno()
2654 if (!wpas_network_disabled(wpa_s, ssid)) { in wpas_start_pno()
2678 if (num_match_ssid > wpa_s->max_match_sets) { in wpas_start_pno()
2679 num_match_ssid = wpa_s->max_match_sets; in wpas_start_pno()
2680 wpa_dbg(wpa_s, MSG_DEBUG, "PNO: Too many SSIDs to match"); in wpas_start_pno()
2689 ssid = wpa_s->conf->pssid[prio]; in wpas_start_pno()
2691 if (!wpas_network_disabled(wpa_s, ssid)) { in wpas_start_pno()
2709 else if (prio + 1 == wpa_s->conf->num_prio) in wpas_start_pno()
2712 ssid = wpa_s->conf->pssid[++prio]; in wpas_start_pno()
2715 if (wpa_s->conf->filter_rssi) in wpas_start_pno()
2716 params.filter_rssi = wpa_s->conf->filter_rssi; in wpas_start_pno()
2718 if (wpa_s->sched_scan_plans_num) { in wpas_start_pno()
2719 params.sched_scan_plans = wpa_s->sched_scan_plans; in wpas_start_pno()
2720 params.sched_scan_plans_num = wpa_s->sched_scan_plans_num; in wpas_start_pno()
2723 if (wpa_s->conf->sched_scan_interval) in wpas_start_pno()
2724 scan_plan.interval = wpa_s->conf->sched_scan_interval; in wpas_start_pno()
2733 params.sched_scan_start_delay = wpa_s->conf->sched_scan_start_delay; in wpas_start_pno()
2735 if (params.freqs == NULL && wpa_s->manual_sched_scan_freqs) { in wpas_start_pno()
2736 wpa_dbg(wpa_s, MSG_DEBUG, "Limit sched scan to specified channels"); in wpas_start_pno()
2737 params.freqs = wpa_s->manual_sched_scan_freqs; in wpas_start_pno()
2740 if ((wpa_s->mac_addr_rand_enable & MAC_ADDR_RAND_PNO) && in wpas_start_pno()
2741 wpa_s->wpa_state <= WPA_SCANNING) { in wpas_start_pno()
2743 if (wpa_s->mac_addr_pno) { in wpas_start_pno()
2744 params.mac_addr = wpa_s->mac_addr_pno; in wpas_start_pno()
2745 params.mac_addr_mask = wpa_s->mac_addr_pno + ETH_ALEN; in wpas_start_pno()
2749 wpa_scan_set_relative_rssi_params(wpa_s, &params); in wpas_start_pno()
2751 ret = wpa_supplicant_start_sched_scan(wpa_s, &params); in wpas_start_pno()
2754 wpa_s->pno = 1; in wpas_start_pno()
2756 wpa_msg(wpa_s, MSG_ERROR, "Failed to schedule PNO"); in wpas_start_pno()
2761 int wpas_stop_pno(struct wpa_supplicant *wpa_s) in wpas_stop_pno() argument
2765 if (!wpa_s->pno) in wpas_stop_pno()
2768 ret = wpa_supplicant_stop_sched_scan(wpa_s); in wpas_stop_pno()
2769 wpa_s->sched_scan_stop_req = 1; in wpas_stop_pno()
2771 wpa_s->pno = 0; in wpas_stop_pno()
2772 wpa_s->pno_sched_pending = 0; in wpas_stop_pno()
2774 if (wpa_s->wpa_state == WPA_SCANNING) in wpas_stop_pno()
2775 wpa_supplicant_req_scan(wpa_s, 0, 0); in wpas_stop_pno()
2781 void wpas_mac_addr_rand_scan_clear(struct wpa_supplicant *wpa_s, in wpas_mac_addr_rand_scan_clear() argument
2785 wpa_s->mac_addr_rand_enable &= ~type; in wpas_mac_addr_rand_scan_clear()
2788 os_free(wpa_s->mac_addr_scan); in wpas_mac_addr_rand_scan_clear()
2789 wpa_s->mac_addr_scan = NULL; in wpas_mac_addr_rand_scan_clear()
2793 os_free(wpa_s->mac_addr_sched_scan); in wpas_mac_addr_rand_scan_clear()
2794 wpa_s->mac_addr_sched_scan = NULL; in wpas_mac_addr_rand_scan_clear()
2798 os_free(wpa_s->mac_addr_pno); in wpas_mac_addr_rand_scan_clear()
2799 wpa_s->mac_addr_pno = NULL; in wpas_mac_addr_rand_scan_clear()
2804 int wpas_mac_addr_rand_scan_set(struct wpa_supplicant *wpa_s, in wpas_mac_addr_rand_scan_set() argument
2810 if ((wpa_s->mac_addr_rand_supported & type) != type ) { in wpas_mac_addr_rand_scan_set()
2813 type, wpa_s->mac_addr_rand_supported); in wpas_mac_addr_rand_scan_set()
2817 wpas_mac_addr_rand_scan_clear(wpa_s, type); in wpas_mac_addr_rand_scan_set()
2828 wpa_s->mac_addr_scan = tmp; in wpas_mac_addr_rand_scan_set()
2830 wpa_s->mac_addr_sched_scan = tmp; in wpas_mac_addr_rand_scan_set()
2832 wpa_s->mac_addr_pno = tmp; in wpas_mac_addr_rand_scan_set()
2841 wpa_s->mac_addr_rand_enable |= type; in wpas_mac_addr_rand_scan_set()
2846 int wpas_abort_ongoing_scan(struct wpa_supplicant *wpa_s) in wpas_abort_ongoing_scan() argument
2849 struct wpa_radio *radio = wpa_s->radio; in wpas_abort_ongoing_scan()
2852 if (work->wpa_s != wpa_s || !work->started || in wpas_abort_ongoing_scan()
2856 wpa_dbg(wpa_s, MSG_DEBUG, "Abort an ongoing scan"); in wpas_abort_ongoing_scan()
2857 return wpa_drv_abort_scan(wpa_s, wpa_s->curr_scan_cookie); in wpas_abort_ongoing_scan()
2860 wpa_dbg(wpa_s, MSG_DEBUG, "No ongoing scan/p2p-scan found to abort"); in wpas_abort_ongoing_scan()
2865 int wpas_sched_scan_plans_set(struct wpa_supplicant *wpa_s, const char *cmd) in wpas_sched_scan_plans_set() argument
2876 os_free(wpa_s->sched_scan_plans); in wpas_sched_scan_plans_set()
2877 wpa_s->sched_scan_plans = NULL; in wpas_sched_scan_plans_set()
2878 wpa_s->sched_scan_plans_num = 0; in wpas_sched_scan_plans_set()
2902 if (scan_plan->interval > wpa_s->max_sched_scan_plan_interval) { in wpas_sched_scan_plans_set()
2906 wpa_s->max_sched_scan_plan_interval); in wpas_sched_scan_plans_set()
2908 wpa_s->max_sched_scan_plan_interval; in wpas_sched_scan_plans_set()
2924 wpa_s->max_sched_scan_plan_iterations) { in wpas_sched_scan_plans_set()
2928 wpa_s->max_sched_scan_plan_iterations); in wpas_sched_scan_plans_set()
2930 wpa_s->max_sched_scan_plan_iterations; in wpas_sched_scan_plans_set()
2952 if (num > wpa_s->max_sched_scan_plans) { in wpas_sched_scan_plans_set()
2955 wpa_s->max_sched_scan_plans); in wpas_sched_scan_plans_set()
2958 wpa_s->max_sched_scan_plans - 1); in wpas_sched_scan_plans_set()
2959 os_memcpy(&scan_plans[wpa_s->max_sched_scan_plans - 1], in wpas_sched_scan_plans_set()
2961 num = wpa_s->max_sched_scan_plans; in wpas_sched_scan_plans_set()
2964 os_free(wpa_s->sched_scan_plans); in wpas_sched_scan_plans_set()
2965 wpa_s->sched_scan_plans = scan_plans; in wpas_sched_scan_plans_set()
2966 wpa_s->sched_scan_plans_num = num; in wpas_sched_scan_plans_set()
2985 void wpas_scan_reset_sched_scan(struct wpa_supplicant *wpa_s) in wpas_scan_reset_sched_scan() argument
2987 wpa_s->normal_scans = 0; in wpas_scan_reset_sched_scan()
2988 if (wpa_s->sched_scanning) { in wpas_scan_reset_sched_scan()
2989 wpa_s->sched_scan_timed_out = 0; in wpas_scan_reset_sched_scan()
2990 wpa_s->prev_sched_ssid = NULL; in wpas_scan_reset_sched_scan()
2991 wpa_supplicant_cancel_sched_scan(wpa_s); in wpas_scan_reset_sched_scan()
2996 void wpas_scan_restart_sched_scan(struct wpa_supplicant *wpa_s) in wpas_scan_restart_sched_scan() argument
2999 wpa_s->sched_scan_timed_out = 1; in wpas_scan_restart_sched_scan()
3000 wpa_s->prev_sched_ssid = NULL; in wpas_scan_restart_sched_scan()
3001 wpa_supplicant_cancel_sched_scan(wpa_s); in wpas_scan_restart_sched_scan()