Lines Matching refs:wpa_s
25 static void wpa_supplicant_gen_assoc_event(struct wpa_supplicant *wpa_s)
30 ssid = wpa_supplicant_get_ssid(wpa_s);
34 if (wpa_s->current_ssid == NULL) {
35 wpa_s->current_ssid = ssid;
36 if (wpa_s->current_ssid != NULL)
37 wpas_notify_network_changed(wpa_s);
39 wpa_supplicant_initiate_eapol(wpa_s);
40 wpa_dbg(wpa_s, MSG_DEBUG, "Already associated with a configured "
43 wpa_supplicant_event(wpa_s, EVENT_ASSOC, &data);
48 static int wpas_wps_in_use(struct wpa_supplicant *wpa_s,
54 for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next) {
68 if (!wpa_s->global->p2p_disabled && wpa_s->global->p2p) {
69 wpa_s->wps->dev.p2p = 1;
95 static void wpa_supplicant_assoc_try(struct wpa_supplicant *wpa_s,
106 wpa_dbg(wpa_s, MSG_DEBUG, "wpa_supplicant_assoc_try: Reached "
108 wpa_s->prev_scan_ssid = WILDCARD_SSID_SCAN;
109 wpa_supplicant_req_scan(wpa_s, 0, 0);
114 wpa_s->prev_scan_ssid = ssid;
117 wpa_s->prev_scan_ssid = WILDCARD_SSID_SCAN;
119 wpa_supplicant_associate(wpa_s, NULL, ssid);
191 int wpa_supplicant_trigger_scan(struct wpa_supplicant *wpa_s,
196 wpa_supplicant_notify_scanning(wpa_s, 1);
198 ret = wpa_drv_scan(wpa_s, params);
200 wpa_supplicant_notify_scanning(wpa_s, 0);
201 wpas_notify_scan_done(wpa_s, 0);
203 wpa_s->scan_runs++;
204 wpa_s->normal_scans++;
214 struct wpa_supplicant *wpa_s = eloop_ctx;
216 wpa_dbg(wpa_s, MSG_DEBUG, "Starting delayed sched scan");
218 if (wpa_supplicant_req_sched_scan(wpa_s))
219 wpa_supplicant_req_scan(wpa_s, 0, 0);
226 struct wpa_supplicant *wpa_s = eloop_ctx;
228 wpa_dbg(wpa_s, MSG_DEBUG, "Sched scan timeout - stopping it");
230 wpa_s->sched_scan_timed_out = 1;
231 wpa_supplicant_cancel_sched_scan(wpa_s);
236 wpa_supplicant_start_sched_scan(struct wpa_supplicant *wpa_s,
242 wpa_supplicant_notify_scanning(wpa_s, 1);
244 ret = wpa_drv_sched_scan(wpa_s, params, interval * 1000);
246 wpa_supplicant_notify_scanning(wpa_s, 0);
248 wpa_s->sched_scanning = 1;
250 wpa_supplicant_notify_scanning(wpa_s, 1);
258 static int wpa_supplicant_stop_sched_scan(struct wpa_supplicant *wpa_s)
262 ret = wpa_drv_stop_sched_scan(wpa_s);
264 wpa_dbg(wpa_s, MSG_DEBUG, "stopping sched_scan failed!");
307 struct wpa_supplicant *wpa_s, struct wpa_driver_scan_params *params)
310 if (params->freqs == NULL && wpa_s->p2p_in_provisioning &&
311 wpa_s->go_params) {
313 if (wpa_s->p2p_in_provisioning < 5 &&
314 wpa_s->go_params->freq > 0) {
315 wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Scan only GO "
317 wpa_s->go_params->freq);
320 params->freqs[0] = wpa_s->go_params->freq;
321 } else if (wpa_s->p2p_in_provisioning < 8 &&
322 wpa_s->go_params->freq_list[0]) {
323 wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Scan only common "
326 wpa_s->go_params->freq_list);
330 wpa_s->p2p_in_provisioning++;
335 if (params->freqs == NULL && wpa_s->after_wps && wpa_s->wps_freq) {
340 wpa_dbg(wpa_s, MSG_DEBUG, "WPS: Scan only frequency %u MHz "
341 "that was used during provisioning", wpa_s->wps_freq);
344 params->freqs[0] = wpa_s->wps_freq;
345 wpa_s->after_wps--;
348 if (params->freqs == NULL && wpa_s->known_wps_freq && wpa_s->wps_freq)
351 wpa_dbg(wpa_s, MSG_DEBUG, "WPS: Scan only frequency %u MHz",
352 wpa_s->wps_freq);
355 params->freqs[0] = wpa_s->wps_freq;
356 wpa_s->known_wps_freq = 0; /* only do this once */
363 static void wpas_add_interworking_elements(struct wpa_supplicant *wpa_s,
366 if (wpa_s->conf->interworking == 0)
377 wpabuf_put_u8(buf, is_zero_ether_addr(wpa_s->conf->hessid) ? 1 :
379 wpabuf_put_u8(buf, wpa_s->conf->access_network_type);
381 if (!is_zero_ether_addr(wpa_s->conf->hessid))
382 wpabuf_put_data(buf, wpa_s->conf->hessid, ETH_ALEN);
388 wpa_supplicant_extra_ies(struct wpa_supplicant *wpa_s,
398 if (wpa_s->conf->interworking &&
400 wpas_add_interworking_elements(wpa_s, extra_ie);
404 wps = wpas_wps_in_use(wpa_s, &req_type);
408 wps_ie = wps_build_probe_req_ie(wps == 2, &wpa_s->wps->dev,
409 wpa_s->wps->uuid, req_type,
420 size_t ielen = p2p_scan_ie_buf_len(wpa_s->global->p2p);
422 wpas_p2p_scan_ie(wpa_s, extra_ie);
434 struct wpa_supplicant *wpa_s = eloop_ctx;
442 if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) {
443 wpa_dbg(wpa_s, MSG_DEBUG, "Skip scan - interface disabled");
447 if (wpa_s->disconnected && !wpa_s->scan_req) {
448 wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
452 if (!wpa_supplicant_enabled_networks(wpa_s->conf) &&
453 !wpa_s->scan_req) {
454 wpa_dbg(wpa_s, MSG_DEBUG, "No enabled networks - do not scan");
455 wpa_supplicant_set_state(wpa_s, WPA_INACTIVE);
459 if (wpa_s->conf->ap_scan != 0 &&
460 (wpa_s->drv_flags & WPA_DRIVER_FLAGS_WIRED)) {
461 wpa_dbg(wpa_s, MSG_DEBUG, "Using wired authentication - "
463 wpa_s->conf->ap_scan = 0;
464 wpas_notify_ap_scan_changed(wpa_s);
467 if (wpa_s->conf->ap_scan == 0) {
468 wpa_supplicant_gen_assoc_event(wpa_s);
473 if (wpas_p2p_in_progress(wpa_s)) {
474 if (wpa_s->wpa_state == WPA_SCANNING) {
475 wpa_dbg(wpa_s, MSG_DEBUG, "Delay station mode scan "
477 wpa_supplicant_req_scan(wpa_s, 5, 0);
479 wpa_dbg(wpa_s, MSG_DEBUG, "Do not request scan while "
486 if (wpa_s->conf->ap_scan == 2)
489 max_ssids = wpa_s->max_scan_ssids;
494 scan_req = wpa_s->scan_req;
495 wpa_s->scan_req = 0;
499 prev_state = wpa_s->wpa_state;
500 if (wpa_s->wpa_state == WPA_DISCONNECTED ||
501 wpa_s->wpa_state == WPA_INACTIVE)
502 wpa_supplicant_set_state(wpa_s, WPA_SCANNING);
504 if (scan_req != 2 && wpa_s->connect_without_scan) {
505 for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next) {
506 if (ssid == wpa_s->connect_without_scan)
509 wpa_s->connect_without_scan = NULL;
513 wpa_supplicant_associate(wpa_s, NULL, ssid);
519 ssid = wpa_s->conf->ssid;
520 if (wpa_s->prev_scan_ssid != WILDCARD_SSID_SCAN) {
522 if (ssid == wpa_s->prev_scan_ssid) {
530 if (scan_req != 2 && wpa_s->conf->ap_scan == 2) {
531 wpa_s->connect_without_scan = NULL;
532 wpa_s->prev_scan_wildcard = 0;
533 wpa_supplicant_assoc_try(wpa_s, ssid);
536 } else if (wpa_s->conf->ap_scan == 2) {
547 ssid = wpa_s->conf->ssid;
564 start != wpa_s->conf->ssid)
565 ssid = wpa_s->conf->ssid;
568 for (tssid = wpa_s->conf->ssid; tssid; tssid = tssid->next) {
589 if (!wpa_s->prev_scan_wildcard) {
592 wpa_s->prev_scan_wildcard = 1;
593 wpa_dbg(wpa_s, MSG_DEBUG, "Starting AP scan for "
596 wpa_s->prev_scan_ssid = ssid;
597 wpa_s->prev_scan_wildcard = 0;
598 wpa_dbg(wpa_s, MSG_DEBUG,
605 wpa_s->prev_scan_ssid = ssid;
606 wpa_dbg(wpa_s, MSG_DEBUG, "Include wildcard SSID in "
610 wpa_s->prev_scan_ssid = WILDCARD_SSID_SCAN;
612 wpa_dbg(wpa_s, MSG_DEBUG, "Starting AP scan for wildcard "
616 wpa_supplicant_optimize_freqs(wpa_s, ¶ms);
617 extra_ie = wpa_supplicant_extra_ies(wpa_s, ¶ms);
619 if (params.freqs == NULL && wpa_s->next_scan_freqs) {
620 wpa_dbg(wpa_s, MSG_DEBUG, "Optimize scan based on previously "
622 params.freqs = wpa_s->next_scan_freqs;
624 os_free(wpa_s->next_scan_freqs);
625 wpa_s->next_scan_freqs = NULL;
628 wpa_s->conf, ¶ms.num_filter_ssids);
635 if (wpa_s->p2p_in_provisioning) {
644 ret = wpa_supplicant_trigger_scan(wpa_s, ¶ms);
651 wpa_msg(wpa_s, MSG_WARNING, "Failed to initiate AP scan");
652 if (prev_state != wpa_s->wpa_state)
653 wpa_supplicant_set_state(wpa_s, prev_state);
654 wpa_supplicant_req_scan(wpa_s, 1, 0);
661 * @wpa_s: Pointer to wpa_supplicant data
668 void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec)
677 if (eloop_is_timeout_registered(wpa_supplicant_scan, wpa_s, NULL) &&
678 wpa_s->conf->ap_scan == 1) {
679 struct wpa_ssid *ssid = wpa_s->conf->ssid;
687 wpa_dbg(wpa_s, MSG_DEBUG, "Not rescheduling scan to "
693 wpa_dbg(wpa_s, MSG_DEBUG, "Setting scan request: %d sec %d usec",
695 eloop_cancel_timeout(wpa_supplicant_scan, wpa_s, NULL);
696 eloop_register_timeout(sec, usec, wpa_supplicant_scan, wpa_s, NULL);
702 * @wpa_s: Pointer to wpa_supplicant data
709 int wpa_supplicant_delayed_sched_scan(struct wpa_supplicant *wpa_s,
712 if (!wpa_s->sched_scan_supported)
717 wpa_s, NULL);
725 * @wpa_s: Pointer to wpa_supplicant data
730 int wpa_supplicant_req_sched_scan(struct wpa_supplicant *wpa_s)
741 if (!wpa_s->sched_scan_supported)
744 if (wpa_s->max_sched_scan_ssids > WPAS_MAX_SCAN_SSIDS)
747 max_sched_scan_ssids = wpa_s->max_sched_scan_ssids;
751 if (wpa_s->sched_scanning) {
752 wpa_dbg(wpa_s, MSG_DEBUG, "Already sched scanning");
757 for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next) {
767 if (wpa_s->normal_scans < 3 &&
768 (need_ssids <= wpa_s->max_scan_ssids ||
769 wpa_s->max_scan_ssids >= (int) max_sched_scan_ssids)) {
777 wpa_dbg(wpa_s, MSG_DEBUG, "Use normal scan instead of "
779 wpa_s->normal_scans);
786 params.filter_ssids = os_zalloc(wpa_s->max_match_sets *
789 prev_state = wpa_s->wpa_state;
791 if (wpa_s->wpa_state == WPA_DISCONNECTED ||
792 wpa_s->wpa_state == WPA_INACTIVE)
793 wpa_supplicant_set_state(wpa_s, WPA_SCANNING);
797 ssid = wpa_s->conf->ssid;
798 if (wpa_s->prev_sched_ssid) {
800 if (ssid == wpa_s->prev_sched_ssid) {
808 if (!ssid || !wpa_s->prev_sched_ssid) {
809 wpa_dbg(wpa_s, MSG_DEBUG, "Beginning of SSID list");
811 wpa_s->sched_scan_interval = 10;
812 wpa_s->sched_scan_timeout = max_sched_scan_ssids * 2;
813 wpa_s->first_sched_scan = 1;
814 ssid = wpa_s->conf->ssid;
815 wpa_s->prev_sched_ssid = ssid;
819 wpa_dbg(wpa_s, MSG_DEBUG, "Add wildcard SSID to sched_scan");
827 if (params.num_filter_ssids < wpa_s->max_match_sets &&
829 wpa_dbg(wpa_s, MSG_DEBUG, "add to filter ssid: %s",
838 wpa_dbg(wpa_s, MSG_DEBUG, "Not enough room for SSID "
848 wpa_dbg(wpa_s, MSG_DEBUG,
857 wpa_s->prev_sched_ssid = ssid;
863 wpa_s->prev_sched_ssid = ssid;
872 if (wpa_s->wps)
873 wps_ie = wpa_supplicant_extra_ies(wpa_s, ¶ms);
875 if (ssid || !wpa_s->first_sched_scan) {
876 wpa_dbg(wpa_s, MSG_DEBUG,
878 wpa_s->sched_scan_interval);
880 wpa_dbg(wpa_s, MSG_DEBUG,
882 wpa_s->sched_scan_interval, wpa_s->sched_scan_timeout);
885 ret = wpa_supplicant_start_sched_scan(wpa_s, ¶ms,
886 wpa_s->sched_scan_interval);
890 wpa_msg(wpa_s, MSG_WARNING, "Failed to initiate sched scan");
891 if (prev_state != wpa_s->wpa_state)
892 wpa_supplicant_set_state(wpa_s, prev_state);
897 if (ssid || !wpa_s->first_sched_scan) {
898 wpa_s->sched_scan_timed_out = 0;
899 eloop_register_timeout(wpa_s->sched_scan_timeout, 0,
901 wpa_s, NULL);
902 wpa_s->first_sched_scan = 0;
903 wpa_s->sched_scan_timeout /= 2;
904 wpa_s->sched_scan_interval *= 2;
913 * @wpa_s: Pointer to wpa_supplicant data
918 void wpa_supplicant_cancel_scan(struct wpa_supplicant *wpa_s)
920 wpa_dbg(wpa_s, MSG_DEBUG, "Cancelling scan request");
921 eloop_cancel_timeout(wpa_supplicant_scan, wpa_s, NULL);
923 wpa_supplicant_notify_scanning(wpa_s, 0);
930 * @wpa_s: Pointer to wpa_supplicant data
934 void wpa_supplicant_cancel_sched_scan(struct wpa_supplicant *wpa_s)
936 if (!wpa_s->sched_scanning)
939 wpa_dbg(wpa_s, MSG_DEBUG, "Cancelling sched scan");
940 eloop_cancel_timeout(wpa_supplicant_sched_scan_timeout, wpa_s, NULL);
941 wpa_supplicant_stop_sched_scan(wpa_s);
945 void wpa_supplicant_notify_scanning(struct wpa_supplicant *wpa_s,
948 if (wpa_s->scanning != scanning) {
950 if(!wpa_s->sched_scanning)
951 wpa_s->scanning = scanning;
953 wpa_s->scanning = scanning;
955 wpas_notify_scanning(wpa_s);
1244 * @wpa_s: Pointer to wpa_supplicant data
1250 * the local BSS list wpa_s->bss. The caller is responsible for freeing the
1254 wpa_supplicant_get_scan_results(struct wpa_supplicant *wpa_s,
1261 scan_res = wpa_drv_get_scan_results2(wpa_s);
1263 wpa_dbg(wpa_s, MSG_DEBUG, "Failed to get scan results");
1268 if (wpas_wps_in_progress(wpa_s)) {
1269 wpa_dbg(wpa_s, MSG_DEBUG, "WPS: Order scan results with WPS "
1279 wpa_bss_update_start(wpa_s);
1281 wpa_s, scan_res->res[i]);
1282 wpa_bss_update_end(wpa_s, info, new_scan);
1288 int wpa_supplicant_update_scan_results(struct wpa_supplicant *wpa_s)
1291 scan_res = wpa_supplicant_get_scan_results(wpa_s, NULL, 0);