2 * WPA Supplicant - Scanning
3 * Copyright (c) 2003-2010, Jouni Malinen <j@w1.fi>
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
9 #include "utils/includes.h"
11 #include "utils/common.h"
12 #include "utils/eloop.h"
13 #include "common/ieee802_11_defs.h"
15 #include "wpa_supplicant_i.h"
17 #include "wps_supplicant.h"
18 #include "p2p_supplicant.h"
20 #include "hs20_supplicant.h"
26 static void wpa_supplicant_gen_assoc_event(struct wpa_supplicant
*wpa_s
)
28 struct wpa_ssid
*ssid
;
29 union wpa_event_data data
;
31 ssid
= wpa_supplicant_get_ssid(wpa_s
);
35 if (wpa_s
->current_ssid
== NULL
) {
36 wpa_s
->current_ssid
= ssid
;
37 if (wpa_s
->current_ssid
!= NULL
)
38 wpas_notify_network_changed(wpa_s
);
40 wpa_supplicant_initiate_eapol(wpa_s
);
41 wpa_dbg(wpa_s
, MSG_DEBUG
, "Already associated with a configured "
42 "network - generating associated event");
43 os_memset(&data
, 0, sizeof(data
));
44 wpa_supplicant_event(wpa_s
, EVENT_ASSOC
, &data
);
49 static int wpas_wps_in_use(struct wpa_supplicant
*wpa_s
,
50 enum wps_request_type
*req_type
)
52 struct wpa_ssid
*ssid
;
55 for (ssid
= wpa_s
->conf
->ssid
; ssid
; ssid
= ssid
->next
) {
56 if (!(ssid
->key_mgmt
& WPA_KEY_MGMT_WPS
))
60 *req_type
= wpas_wps_get_req_type(ssid
);
61 if (!ssid
->eap
.phase1
)
64 if (os_strstr(ssid
->eap
.phase1
, "pbc=1"))
69 if (!wpa_s
->global
->p2p_disabled
&& wpa_s
->global
->p2p
&&
70 !wpa_s
->conf
->p2p_disabled
) {
71 wpa_s
->wps
->dev
.p2p
= 1;
74 *req_type
= WPS_REQ_ENROLLEE_INFO
;
77 #endif /* CONFIG_P2P */
81 #endif /* CONFIG_WPS */
84 int wpa_supplicant_enabled_networks(struct wpa_supplicant
*wpa_s
)
86 struct wpa_ssid
*ssid
= wpa_s
->conf
->ssid
;
87 int count
= 0, disabled
= 0;
89 if (!wpas_network_disabled(wpa_s
, ssid
))
95 if (wpa_s
->conf
->cred
&& wpa_s
->conf
->interworking
&&
96 wpa_s
->conf
->auto_interworking
)
98 if (count
== 0 && disabled
> 0) {
99 wpa_dbg(wpa_s
, MSG_DEBUG
, "No enabled networks (%d disabled "
100 "networks)", disabled
);
106 static void wpa_supplicant_assoc_try(struct wpa_supplicant
*wpa_s
,
107 struct wpa_ssid
*ssid
)
110 if (!wpas_network_disabled(wpa_s
, ssid
))
115 /* ap_scan=2 mode - try to associate with each SSID. */
117 wpa_dbg(wpa_s
, MSG_DEBUG
, "wpa_supplicant_assoc_try: Reached "
118 "end of scan list - go back to beginning");
119 wpa_s
->prev_scan_ssid
= WILDCARD_SSID_SCAN
;
120 wpa_supplicant_req_scan(wpa_s
, 0, 0);
124 /* Continue from the next SSID on the next attempt. */
125 wpa_s
->prev_scan_ssid
= ssid
;
127 /* Start from the beginning of the SSID list. */
128 wpa_s
->prev_scan_ssid
= WILDCARD_SSID_SCAN
;
130 wpa_supplicant_associate(wpa_s
, NULL
, ssid
);
134 static int int_array_len(const int *a
)
137 for (i
= 0; a
&& a
[i
]; i
++)
143 static void int_array_concat(int **res
, const int *a
)
148 reslen
= int_array_len(*res
);
149 alen
= int_array_len(a
);
151 n
= os_realloc_array(*res
, reslen
+ alen
+ 1, sizeof(int));
157 for (i
= 0; i
<= alen
; i
++)
158 n
[reslen
+ i
] = a
[i
];
163 static int freq_cmp(const void *a
, const void *b
)
176 static void int_array_sort_unique(int *a
)
184 alen
= int_array_len(a
);
185 qsort(a
, alen
, sizeof(int), freq_cmp
);
189 while (a
[i
] && a
[j
]) {
202 int wpa_supplicant_trigger_scan(struct wpa_supplicant
*wpa_s
,
203 struct wpa_driver_scan_params
*params
)
207 wpa_supplicant_notify_scanning(wpa_s
, 1);
209 ret
= wpa_drv_scan(wpa_s
, params
);
211 wpa_supplicant_notify_scanning(wpa_s
, 0);
212 wpas_notify_scan_done(wpa_s
, 0);
215 wpa_s
->normal_scans
++;
223 wpa_supplicant_delayed_sched_scan_timeout(void *eloop_ctx
, void *timeout_ctx
)
225 struct wpa_supplicant
*wpa_s
= eloop_ctx
;
227 wpa_dbg(wpa_s
, MSG_DEBUG
, "Starting delayed sched scan");
229 if (wpa_supplicant_req_sched_scan(wpa_s
))
230 wpa_supplicant_req_scan(wpa_s
, 0, 0);
235 wpa_supplicant_sched_scan_timeout(void *eloop_ctx
, void *timeout_ctx
)
237 struct wpa_supplicant
*wpa_s
= eloop_ctx
;
239 wpa_dbg(wpa_s
, MSG_DEBUG
, "Sched scan timeout - stopping it");
241 wpa_s
->sched_scan_timed_out
= 1;
242 wpa_supplicant_cancel_sched_scan(wpa_s
);
247 wpa_supplicant_start_sched_scan(struct wpa_supplicant
*wpa_s
,
248 struct wpa_driver_scan_params
*params
,
253 wpa_supplicant_notify_scanning(wpa_s
, 1);
254 ret
= wpa_drv_sched_scan(wpa_s
, params
, interval
* 1000);
256 wpa_supplicant_notify_scanning(wpa_s
, 0);
258 wpa_s
->sched_scanning
= 1;
264 static int wpa_supplicant_stop_sched_scan(struct wpa_supplicant
*wpa_s
)
268 ret
= wpa_drv_stop_sched_scan(wpa_s
);
270 wpa_dbg(wpa_s
, MSG_DEBUG
, "stopping sched_scan failed!");
271 /* TODO: what to do if stopping fails? */
279 static struct wpa_driver_scan_filter
*
280 wpa_supplicant_build_filter_ssids(struct wpa_config
*conf
, size_t *num_ssids
)
282 struct wpa_driver_scan_filter
*ssids
;
283 struct wpa_ssid
*ssid
;
287 if (!conf
->filter_ssids
)
290 for (count
= 0, ssid
= conf
->ssid
; ssid
; ssid
= ssid
->next
) {
291 if (ssid
->ssid
&& ssid
->ssid_len
)
296 ssids
= os_zalloc(count
* sizeof(struct wpa_driver_scan_filter
));
300 for (ssid
= conf
->ssid
; ssid
; ssid
= ssid
->next
) {
301 if (!ssid
->ssid
|| !ssid
->ssid_len
)
303 os_memcpy(ssids
[*num_ssids
].ssid
, ssid
->ssid
, ssid
->ssid_len
);
304 ssids
[*num_ssids
].ssid_len
= ssid
->ssid_len
;
312 static void wpa_supplicant_optimize_freqs(
313 struct wpa_supplicant
*wpa_s
, struct wpa_driver_scan_params
*params
)
316 if (params
->freqs
== NULL
&& wpa_s
->p2p_in_provisioning
&&
318 /* Optimize provisioning state scan based on GO information */
319 if (wpa_s
->p2p_in_provisioning
< 5 &&
320 wpa_s
->go_params
->freq
> 0) {
321 wpa_dbg(wpa_s
, MSG_DEBUG
, "P2P: Scan only GO "
322 "preferred frequency %d MHz",
323 wpa_s
->go_params
->freq
);
324 params
->freqs
= os_zalloc(2 * sizeof(int));
326 params
->freqs
[0] = wpa_s
->go_params
->freq
;
327 } else if (wpa_s
->p2p_in_provisioning
< 8 &&
328 wpa_s
->go_params
->freq_list
[0]) {
329 wpa_dbg(wpa_s
, MSG_DEBUG
, "P2P: Scan only common "
331 int_array_concat(¶ms
->freqs
,
332 wpa_s
->go_params
->freq_list
);
334 int_array_sort_unique(params
->freqs
);
336 wpa_s
->p2p_in_provisioning
++;
338 #endif /* CONFIG_P2P */
341 if (params
->freqs
== NULL
&& wpa_s
->after_wps
&& wpa_s
->wps_freq
) {
343 * Optimize post-provisioning scan based on channel used
344 * during provisioning.
346 wpa_dbg(wpa_s
, MSG_DEBUG
, "WPS: Scan only frequency %u MHz "
347 "that was used during provisioning", wpa_s
->wps_freq
);
348 params
->freqs
= os_zalloc(2 * sizeof(int));
350 params
->freqs
[0] = wpa_s
->wps_freq
;
354 if (params
->freqs
== NULL
&& wpa_s
->known_wps_freq
&& wpa_s
->wps_freq
)
356 /* Optimize provisioning scan based on already known channel */
357 wpa_dbg(wpa_s
, MSG_DEBUG
, "WPS: Scan only frequency %u MHz",
359 params
->freqs
= os_zalloc(2 * sizeof(int));
361 params
->freqs
[0] = wpa_s
->wps_freq
;
362 wpa_s
->known_wps_freq
= 0; /* only do this once */
364 #endif /* CONFIG_WPS */
368 #ifdef CONFIG_INTERWORKING
369 static void wpas_add_interworking_elements(struct wpa_supplicant
*wpa_s
,
372 if (wpa_s
->conf
->interworking
== 0)
375 wpabuf_put_u8(buf
, WLAN_EID_EXT_CAPAB
);
376 wpabuf_put_u8(buf
, 4);
377 wpabuf_put_u8(buf
, 0x00);
378 wpabuf_put_u8(buf
, 0x00);
379 wpabuf_put_u8(buf
, 0x00);
380 wpabuf_put_u8(buf
, 0x80); /* Bit 31 - Interworking */
382 wpabuf_put_u8(buf
, WLAN_EID_INTERWORKING
);
383 wpabuf_put_u8(buf
, is_zero_ether_addr(wpa_s
->conf
->hessid
) ? 1 :
385 wpabuf_put_u8(buf
, wpa_s
->conf
->access_network_type
);
387 if (!is_zero_ether_addr(wpa_s
->conf
->hessid
))
388 wpabuf_put_data(buf
, wpa_s
->conf
->hessid
, ETH_ALEN
);
390 #endif /* CONFIG_INTERWORKING */
393 static struct wpabuf
* wpa_supplicant_extra_ies(struct wpa_supplicant
*wpa_s
)
395 struct wpabuf
*extra_ie
= NULL
;
398 enum wps_request_type req_type
= WPS_REQ_ENROLLEE_INFO
;
399 #endif /* CONFIG_WPS */
401 #ifdef CONFIG_INTERWORKING
402 if (wpa_s
->conf
->interworking
&&
403 wpabuf_resize(&extra_ie
, 100) == 0)
404 wpas_add_interworking_elements(wpa_s
, extra_ie
);
405 #endif /* CONFIG_INTERWORKING */
408 wps
= wpas_wps_in_use(wpa_s
, &req_type
);
411 struct wpabuf
*wps_ie
;
412 wps_ie
= wps_build_probe_req_ie(wps
== 2 ? DEV_PW_PUSHBUTTON
:
415 wpa_s
->wps
->uuid
, req_type
,
418 if (wpabuf_resize(&extra_ie
, wpabuf_len(wps_ie
)) == 0)
419 wpabuf_put_buf(extra_ie
, wps_ie
);
426 size_t ielen
= p2p_scan_ie_buf_len(wpa_s
->global
->p2p
);
427 if (wpabuf_resize(&extra_ie
, ielen
) == 0)
428 wpas_p2p_scan_ie(wpa_s
, extra_ie
);
430 #endif /* CONFIG_P2P */
432 #endif /* CONFIG_WPS */
441 * Check whether there are any enabled networks or credentials that could be
442 * used for a non-P2P connection.
444 static int non_p2p_network_enabled(struct wpa_supplicant
*wpa_s
)
446 struct wpa_ssid
*ssid
;
448 for (ssid
= wpa_s
->conf
->ssid
; ssid
; ssid
= ssid
->next
) {
449 if (wpas_network_disabled(wpa_s
, ssid
))
451 if (!ssid
->p2p_group
)
455 if (wpa_s
->conf
->cred
&& wpa_s
->conf
->interworking
&&
456 wpa_s
->conf
->auto_interworking
)
464 * Find the operating frequency of any other virtual interface that is using
465 * the same radio concurrently.
467 static int shared_vif_oper_freq(struct wpa_supplicant
*wpa_s
)
469 const char *rn
, *rn2
;
470 struct wpa_supplicant
*ifs
;
473 if (!wpa_s
->driver
->get_radio_name
)
476 rn
= wpa_s
->driver
->get_radio_name(wpa_s
->drv_priv
);
477 if (rn
== NULL
|| rn
[0] == '\0')
480 for (ifs
= wpa_s
->global
->ifaces
; ifs
; ifs
= ifs
->next
) {
481 if (ifs
== wpa_s
|| !ifs
->driver
->get_radio_name
)
484 rn2
= ifs
->driver
->get_radio_name(ifs
->drv_priv
);
485 if (!rn2
|| os_strcmp(rn
, rn2
) != 0)
488 if (ifs
->current_ssid
== NULL
|| ifs
->assoc_freq
== 0)
491 if (ifs
->current_ssid
->mode
== WPAS_MODE_AP
||
492 ifs
->current_ssid
->mode
== WPAS_MODE_P2P_GO
)
493 return ifs
->current_ssid
->frequency
;
494 if (wpa_drv_get_bssid(ifs
, bssid
) == 0)
495 return ifs
->assoc_freq
;
501 #endif /* CONFIG_P2P */
504 static void wpa_supplicant_scan(void *eloop_ctx
, void *timeout_ctx
)
506 struct wpa_supplicant
*wpa_s
= eloop_ctx
;
507 struct wpa_ssid
*ssid
;
508 int scan_req
= 0, ret
;
509 struct wpabuf
*extra_ie
= NULL
;
510 struct wpa_driver_scan_params params
;
511 struct wpa_driver_scan_params
*scan_params
;
513 enum wpa_states prev_state
;
515 if (wpa_s
->wpa_state
== WPA_INTERFACE_DISABLED
) {
516 wpa_dbg(wpa_s
, MSG_DEBUG
, "Skip scan - interface disabled");
520 if (wpa_s
->disconnected
&& !wpa_s
->scan_req
) {
521 wpa_dbg(wpa_s
, MSG_DEBUG
, "Disconnected - do not scan");
522 wpa_supplicant_set_state(wpa_s
, WPA_DISCONNECTED
);
526 if (!wpa_supplicant_enabled_networks(wpa_s
) &&
528 wpa_dbg(wpa_s
, MSG_DEBUG
, "No enabled networks - do not scan");
529 wpa_supplicant_set_state(wpa_s
, WPA_INACTIVE
);
531 wpa_s
->sta_scan_pending
= 0;
532 #endif /* CONFIG_P2P */
536 if (wpa_s
->conf
->ap_scan
!= 0 &&
537 (wpa_s
->drv_flags
& WPA_DRIVER_FLAGS_WIRED
)) {
538 wpa_dbg(wpa_s
, MSG_DEBUG
, "Using wired authentication - "
539 "overriding ap_scan configuration");
540 wpa_s
->conf
->ap_scan
= 0;
541 wpas_notify_ap_scan_changed(wpa_s
);
544 if (wpa_s
->conf
->ap_scan
== 0) {
545 wpa_supplicant_gen_assoc_event(wpa_s
);
550 if (wpas_p2p_in_progress(wpa_s
)) {
551 if (wpa_s
->sta_scan_pending
&&
552 wpas_p2p_in_progress(wpa_s
) == 2 &&
553 wpa_s
->global
->p2p_cb_on_scan_complete
) {
554 wpa_dbg(wpa_s
, MSG_DEBUG
, "Process pending station "
555 "mode scan during P2P search");
557 wpa_dbg(wpa_s
, MSG_DEBUG
, "Delay station mode scan "
558 "while P2P operation is in progress");
559 wpa_s
->sta_scan_pending
= 1;
560 wpa_supplicant_req_scan(wpa_s
, 5, 0);
564 #endif /* CONFIG_P2P */
566 if (wpa_s
->conf
->ap_scan
== 2)
569 max_ssids
= wpa_s
->max_scan_ssids
;
570 if (max_ssids
> WPAS_MAX_SCAN_SSIDS
)
571 max_ssids
= WPAS_MAX_SCAN_SSIDS
;
574 scan_req
= wpa_s
->scan_req
;
577 os_memset(¶ms
, 0, sizeof(params
));
579 prev_state
= wpa_s
->wpa_state
;
580 if (wpa_s
->wpa_state
== WPA_DISCONNECTED
||
581 wpa_s
->wpa_state
== WPA_INACTIVE
)
582 wpa_supplicant_set_state(wpa_s
, WPA_SCANNING
);
585 * If autoscan has set its own scanning parameters
587 if (wpa_s
->autoscan_params
!= NULL
) {
588 scan_params
= wpa_s
->autoscan_params
;
592 if (scan_req
!= 2 && wpa_s
->connect_without_scan
) {
593 for (ssid
= wpa_s
->conf
->ssid
; ssid
; ssid
= ssid
->next
) {
594 if (ssid
== wpa_s
->connect_without_scan
)
597 wpa_s
->connect_without_scan
= NULL
;
599 wpa_printf(MSG_DEBUG
, "Start a pre-selected network "
600 "without scan step");
601 wpa_supplicant_associate(wpa_s
, NULL
, ssid
);
607 if ((wpa_s
->p2p_in_provisioning
|| wpa_s
->show_group_started
) &&
609 wpa_printf(MSG_DEBUG
, "P2P: Use specific SSID for scan during "
610 "P2P group formation");
611 params
.ssids
[0].ssid
= wpa_s
->go_params
->ssid
;
612 params
.ssids
[0].ssid_len
= wpa_s
->go_params
->ssid_len
;
613 params
.num_ssids
= 1;
616 #endif /* CONFIG_P2P */
618 /* Find the starting point from which to continue scanning */
619 ssid
= wpa_s
->conf
->ssid
;
620 if (wpa_s
->prev_scan_ssid
!= WILDCARD_SSID_SCAN
) {
622 if (ssid
== wpa_s
->prev_scan_ssid
) {
630 if (scan_req
!= 2 && wpa_s
->conf
->ap_scan
== 2) {
631 wpa_s
->connect_without_scan
= NULL
;
632 wpa_s
->prev_scan_wildcard
= 0;
633 wpa_supplicant_assoc_try(wpa_s
, ssid
);
635 } else if (wpa_s
->conf
->ap_scan
== 2) {
637 * User-initiated scan request in ap_scan == 2; scan with
642 struct wpa_ssid
*start
= ssid
, *tssid
;
644 if (ssid
== NULL
&& max_ssids
> 1)
645 ssid
= wpa_s
->conf
->ssid
;
647 if (!wpas_network_disabled(wpa_s
, ssid
) &&
649 wpa_hexdump_ascii(MSG_DEBUG
, "Scan SSID",
650 ssid
->ssid
, ssid
->ssid_len
);
651 params
.ssids
[params
.num_ssids
].ssid
=
653 params
.ssids
[params
.num_ssids
].ssid_len
=
656 if (params
.num_ssids
+ 1 >= max_ssids
)
662 if (ssid
== NULL
&& max_ssids
> 1 &&
663 start
!= wpa_s
->conf
->ssid
)
664 ssid
= wpa_s
->conf
->ssid
;
667 for (tssid
= wpa_s
->conf
->ssid
; tssid
; tssid
= tssid
->next
) {
668 if (wpas_network_disabled(wpa_s
, tssid
))
670 if ((params
.freqs
|| !freqs_set
) && tssid
->scan_freq
) {
671 int_array_concat(¶ms
.freqs
,
674 os_free(params
.freqs
);
679 int_array_sort_unique(params
.freqs
);
682 if (ssid
&& max_ssids
== 1) {
684 * If the driver is limited to 1 SSID at a time interleave
685 * wildcard SSID scans with specific SSID scans to avoid
686 * waiting a long time for a wildcard scan.
688 if (!wpa_s
->prev_scan_wildcard
) {
689 params
.ssids
[0].ssid
= NULL
;
690 params
.ssids
[0].ssid_len
= 0;
691 wpa_s
->prev_scan_wildcard
= 1;
692 wpa_dbg(wpa_s
, MSG_DEBUG
, "Starting AP scan for "
693 "wildcard SSID (Interleave with specific)");
695 wpa_s
->prev_scan_ssid
= ssid
;
696 wpa_s
->prev_scan_wildcard
= 0;
697 wpa_dbg(wpa_s
, MSG_DEBUG
,
698 "Starting AP scan for specific SSID: %s",
699 wpa_ssid_txt(ssid
->ssid
, ssid
->ssid_len
));
704 wpa_s
->prev_scan_ssid
= ssid
;
705 wpa_dbg(wpa_s
, MSG_DEBUG
, "Include wildcard SSID in "
709 wpa_s
->prev_scan_ssid
= WILDCARD_SSID_SCAN
;
711 wpa_dbg(wpa_s
, MSG_DEBUG
, "Starting AP scan for wildcard "
716 #endif /* CONFIG_P2P */
718 wpa_supplicant_optimize_freqs(wpa_s
, ¶ms
);
719 extra_ie
= wpa_supplicant_extra_ies(wpa_s
);
722 if (wpa_s
->conf
->hs20
&& wpabuf_resize(&extra_ie
, 6) == 0)
723 wpas_hs20_add_indication(extra_ie
);
724 #endif /* CONFIG_HS20 */
726 if (params
.freqs
== NULL
&& wpa_s
->next_scan_freqs
) {
727 wpa_dbg(wpa_s
, MSG_DEBUG
, "Optimize scan based on previously "
728 "generated frequency list");
729 params
.freqs
= wpa_s
->next_scan_freqs
;
731 os_free(wpa_s
->next_scan_freqs
);
732 wpa_s
->next_scan_freqs
= NULL
;
734 params
.filter_ssids
= wpa_supplicant_build_filter_ssids(
735 wpa_s
->conf
, ¶ms
.num_filter_ssids
);
737 params
.extra_ies
= wpabuf_head(extra_ie
);
738 params
.extra_ies_len
= wpabuf_len(extra_ie
);
742 if (wpa_s
->p2p_in_provisioning
||
743 (wpa_s
->show_group_started
&& wpa_s
->go_params
)) {
745 * The interface may not yet be in P2P mode, so we have to
746 * explicitly request P2P probe to disable CCK rates.
748 params
.p2p_probe
= 1;
750 #endif /* CONFIG_P2P */
752 scan_params
= ¶ms
;
757 * If the driver does not support multi-channel concurrency and a
758 * virtual interface that shares the same radio with the wpa_s interface
759 * is operating there may not be need to scan other channels apart from
760 * the current operating channel on the other virtual interface. Filter
761 * out other channels in case we are trying to find a connection for a
762 * station interface when we are not configured to prefer station
763 * connection and a concurrent operation is already in process.
765 if (wpa_s
->scan_for_connection
&& !scan_req
&&
766 !scan_params
->freqs
&& !params
.freqs
&&
767 wpas_is_p2p_prioritized(wpa_s
) &&
768 !(wpa_s
->drv_flags
& WPA_DRIVER_FLAGS_MULTI_CHANNEL_CONCURRENT
) &&
769 wpa_s
->p2p_group_interface
== NOT_P2P_GROUP_INTERFACE
&&
770 non_p2p_network_enabled(wpa_s
)) {
771 int freq
= shared_vif_oper_freq(wpa_s
);
773 wpa_dbg(wpa_s
, MSG_DEBUG
, "P2P: Scan only the current "
774 "operating channel (%d MHz) since driver does "
775 "not support multi-channel concurrency", freq
);
776 params
.freqs
= os_zalloc(sizeof(int) * 2);
778 params
.freqs
[0] = freq
;
779 scan_params
->freqs
= params
.freqs
;
782 #endif /* CONFIG_P2P */
784 ret
= wpa_supplicant_trigger_scan(wpa_s
, scan_params
);
786 wpabuf_free(extra_ie
);
787 os_free(params
.freqs
);
788 os_free(params
.filter_ssids
);
791 wpa_msg(wpa_s
, MSG_WARNING
, "Failed to initiate AP scan");
792 if (prev_state
!= wpa_s
->wpa_state
)
793 wpa_supplicant_set_state(wpa_s
, prev_state
);
794 /* Restore scan_req since we will try to scan again */
795 wpa_s
->scan_req
= scan_req
;
796 wpa_supplicant_req_scan(wpa_s
, 1, 0);
798 wpa_s
->scan_for_connection
= 0;
804 * wpa_supplicant_req_scan - Schedule a scan for neighboring access points
805 * @wpa_s: Pointer to wpa_supplicant data
806 * @sec: Number of seconds after which to scan
807 * @usec: Number of microseconds after which to scan
809 * This function is used to schedule a scan for neighboring access points after
810 * the specified time.
812 void wpa_supplicant_req_scan(struct wpa_supplicant
*wpa_s
, int sec
, int usec
)
814 /* If there's at least one network that should be specifically scanned
815 * then don't cancel the scan and reschedule. Some drivers do
816 * background scanning which generates frequent scan results, and that
817 * causes the specific SSID scan to get continually pushed back and
818 * never happen, which causes hidden APs to never get probe-scanned.
820 if (eloop_is_timeout_registered(wpa_supplicant_scan
, wpa_s
, NULL
) &&
821 wpa_s
->conf
->ap_scan
== 1) {
822 struct wpa_ssid
*ssid
= wpa_s
->conf
->ssid
;
825 if (!wpas_network_disabled(wpa_s
, ssid
) &&
831 wpa_dbg(wpa_s
, MSG_DEBUG
, "Not rescheduling scan to "
832 "ensure that specific SSID scans occur");
837 wpa_dbg(wpa_s
, MSG_DEBUG
, "Setting scan request: %d sec %d usec",
839 eloop_cancel_timeout(wpa_supplicant_scan
, wpa_s
, NULL
);
840 eloop_register_timeout(sec
, usec
, wpa_supplicant_scan
, wpa_s
, NULL
);
845 * wpa_supplicant_delayed_sched_scan - Request a delayed scheduled scan
846 * @wpa_s: Pointer to wpa_supplicant data
847 * @sec: Number of seconds after which to scan
848 * @usec: Number of microseconds after which to scan
850 * This function is used to schedule periodic scans for neighboring
851 * access points after the specified time.
853 int wpa_supplicant_delayed_sched_scan(struct wpa_supplicant
*wpa_s
,
856 if (!wpa_s
->sched_scan_supported
)
859 eloop_register_timeout(sec
, usec
,
860 wpa_supplicant_delayed_sched_scan_timeout
,
868 * wpa_supplicant_req_sched_scan - Start a periodic scheduled scan
869 * @wpa_s: Pointer to wpa_supplicant data
871 * This function is used to schedule periodic scans for neighboring
872 * access points repeating the scan continuously.
874 int wpa_supplicant_req_sched_scan(struct wpa_supplicant
*wpa_s
)
876 struct wpa_driver_scan_params params
;
877 struct wpa_driver_scan_params
*scan_params
;
878 enum wpa_states prev_state
;
879 struct wpa_ssid
*ssid
= NULL
;
880 struct wpabuf
*extra_ie
= NULL
;
882 unsigned int max_sched_scan_ssids
;
886 if (!wpa_s
->sched_scan_supported
)
889 if (wpa_s
->max_sched_scan_ssids
> WPAS_MAX_SCAN_SSIDS
)
890 max_sched_scan_ssids
= WPAS_MAX_SCAN_SSIDS
;
892 max_sched_scan_ssids
= wpa_s
->max_sched_scan_ssids
;
893 if (max_sched_scan_ssids
< 1 || wpa_s
->conf
->disable_scan_offload
)
896 if (wpa_s
->sched_scanning
) {
897 wpa_dbg(wpa_s
, MSG_DEBUG
, "Already sched scanning");
902 for (ssid
= wpa_s
->conf
->ssid
; ssid
; ssid
= ssid
->next
) {
903 if (!wpas_network_disabled(wpa_s
, ssid
) && !ssid
->scan_ssid
) {
904 /* Use wildcard SSID to find this network */
906 } else if (!wpas_network_disabled(wpa_s
, ssid
) &&
911 if (!wpas_network_disabled(wpa_s
, ssid
) &&
912 ssid
->key_mgmt
== WPA_KEY_MGMT_WPS
) {
914 * Normal scan is more reliable and faster for WPS
915 * operations and since these are for short periods of
916 * time, the benefit of trying to use sched_scan would
919 wpa_dbg(wpa_s
, MSG_DEBUG
, "Use normal scan instead of "
920 "sched_scan for WPS");
923 #endif /* CONFIG_WPS */
928 if (wpa_s
->normal_scans
< 3 &&
929 (need_ssids
<= wpa_s
->max_scan_ssids
||
930 wpa_s
->max_scan_ssids
>= (int) max_sched_scan_ssids
)) {
932 * When normal scan can speed up operations, use that for the
933 * first operations before starting the sched_scan to allow
934 * user space sleep more. We do this only if the normal scan
935 * has functionality that is suitable for this or if the
936 * sched_scan does not have better support for multiple SSIDs.
938 wpa_dbg(wpa_s
, MSG_DEBUG
, "Use normal scan instead of "
939 "sched_scan for initial scans (normal_scans=%d)",
940 wpa_s
->normal_scans
);
944 os_memset(¶ms
, 0, sizeof(params
));
946 /* If we can't allocate space for the filters, we just don't filter */
947 params
.filter_ssids
= os_zalloc(wpa_s
->max_match_sets
*
948 sizeof(struct wpa_driver_scan_filter
));
950 prev_state
= wpa_s
->wpa_state
;
951 if (wpa_s
->wpa_state
== WPA_DISCONNECTED
||
952 wpa_s
->wpa_state
== WPA_INACTIVE
)
953 wpa_supplicant_set_state(wpa_s
, WPA_SCANNING
);
955 if (wpa_s
->autoscan_params
!= NULL
) {
956 scan_params
= wpa_s
->autoscan_params
;
960 /* Find the starting point from which to continue scanning */
961 ssid
= wpa_s
->conf
->ssid
;
962 if (wpa_s
->prev_sched_ssid
) {
964 if (ssid
== wpa_s
->prev_sched_ssid
) {
972 if (!ssid
|| !wpa_s
->prev_sched_ssid
) {
973 wpa_dbg(wpa_s
, MSG_DEBUG
, "Beginning of SSID list");
975 if (wpa_s
->sched_scan_interval
== 0)
976 wpa_s
->sched_scan_interval
= 10;
977 wpa_s
->sched_scan_timeout
= max_sched_scan_ssids
* 2;
978 wpa_s
->first_sched_scan
= 1;
979 ssid
= wpa_s
->conf
->ssid
;
980 wpa_s
->prev_sched_ssid
= ssid
;
984 wpa_dbg(wpa_s
, MSG_DEBUG
, "Add wildcard SSID to sched_scan");
989 if (wpas_network_disabled(wpa_s
, ssid
))
992 if (params
.num_filter_ssids
< wpa_s
->max_match_sets
&&
993 params
.filter_ssids
&& ssid
->ssid
&& ssid
->ssid_len
) {
994 wpa_dbg(wpa_s
, MSG_DEBUG
, "add to filter ssid: %s",
995 wpa_ssid_txt(ssid
->ssid
, ssid
->ssid_len
));
996 os_memcpy(params
.filter_ssids
[params
.num_filter_ssids
].ssid
,
997 ssid
->ssid
, ssid
->ssid_len
);
998 params
.filter_ssids
[params
.num_filter_ssids
].ssid_len
=
1000 params
.num_filter_ssids
++;
1001 } else if (params
.filter_ssids
&& ssid
->ssid
&& ssid
->ssid_len
)
1003 wpa_dbg(wpa_s
, MSG_DEBUG
, "Not enough room for SSID "
1004 "filter for sched_scan - drop filter");
1005 os_free(params
.filter_ssids
);
1006 params
.filter_ssids
= NULL
;
1007 params
.num_filter_ssids
= 0;
1010 if (ssid
->scan_ssid
&& ssid
->ssid
&& ssid
->ssid_len
) {
1011 if (params
.num_ssids
== max_sched_scan_ssids
)
1012 break; /* only room for broadcast SSID */
1013 wpa_dbg(wpa_s
, MSG_DEBUG
,
1014 "add to active scan ssid: %s",
1015 wpa_ssid_txt(ssid
->ssid
, ssid
->ssid_len
));
1016 params
.ssids
[params
.num_ssids
].ssid
=
1018 params
.ssids
[params
.num_ssids
].ssid_len
=
1021 if (params
.num_ssids
>= max_sched_scan_ssids
) {
1022 wpa_s
->prev_sched_ssid
= ssid
;
1026 (wpas_network_disabled(wpa_s
, ssid
) ||
1033 wpa_s
->prev_sched_ssid
= ssid
;
1037 if (params
.num_filter_ssids
== 0) {
1038 os_free(params
.filter_ssids
);
1039 params
.filter_ssids
= NULL
;
1042 extra_ie
= wpa_supplicant_extra_ies(wpa_s
);
1044 params
.extra_ies
= wpabuf_head(extra_ie
);
1045 params
.extra_ies_len
= wpabuf_len(extra_ie
);
1048 scan_params
= ¶ms
;
1051 if (ssid
|| !wpa_s
->first_sched_scan
) {
1052 wpa_dbg(wpa_s
, MSG_DEBUG
,
1053 "Starting sched scan: interval %d timeout %d",
1054 wpa_s
->sched_scan_interval
, wpa_s
->sched_scan_timeout
);
1056 wpa_dbg(wpa_s
, MSG_DEBUG
,
1057 "Starting sched scan: interval %d (no timeout)",
1058 wpa_s
->sched_scan_interval
);
1061 ret
= wpa_supplicant_start_sched_scan(wpa_s
, scan_params
,
1062 wpa_s
->sched_scan_interval
);
1063 wpabuf_free(extra_ie
);
1064 os_free(params
.filter_ssids
);
1066 wpa_msg(wpa_s
, MSG_WARNING
, "Failed to initiate sched scan");
1067 if (prev_state
!= wpa_s
->wpa_state
)
1068 wpa_supplicant_set_state(wpa_s
, prev_state
);
1072 /* If we have more SSIDs to scan, add a timeout so we scan them too */
1073 if (ssid
|| !wpa_s
->first_sched_scan
) {
1074 wpa_s
->sched_scan_timed_out
= 0;
1075 eloop_register_timeout(wpa_s
->sched_scan_timeout
, 0,
1076 wpa_supplicant_sched_scan_timeout
,
1078 wpa_s
->first_sched_scan
= 0;
1079 wpa_s
->sched_scan_timeout
/= 2;
1080 wpa_s
->sched_scan_interval
*= 2;
1088 * wpa_supplicant_cancel_scan - Cancel a scheduled scan request
1089 * @wpa_s: Pointer to wpa_supplicant data
1091 * This function is used to cancel a scan request scheduled with
1092 * wpa_supplicant_req_scan().
1094 void wpa_supplicant_cancel_scan(struct wpa_supplicant
*wpa_s
)
1096 wpa_dbg(wpa_s
, MSG_DEBUG
, "Cancelling scan request");
1097 eloop_cancel_timeout(wpa_supplicant_scan
, wpa_s
, NULL
);
1102 * wpa_supplicant_cancel_sched_scan - Stop running scheduled scans
1103 * @wpa_s: Pointer to wpa_supplicant data
1105 * This function is used to stop a periodic scheduled scan.
1107 void wpa_supplicant_cancel_sched_scan(struct wpa_supplicant
*wpa_s
)
1109 if (!wpa_s
->sched_scanning
)
1112 wpa_dbg(wpa_s
, MSG_DEBUG
, "Cancelling sched scan");
1113 eloop_cancel_timeout(wpa_supplicant_sched_scan_timeout
, wpa_s
, NULL
);
1114 wpa_supplicant_stop_sched_scan(wpa_s
);
1118 void wpa_supplicant_notify_scanning(struct wpa_supplicant
*wpa_s
,
1121 if (wpa_s
->scanning
!= scanning
) {
1122 wpa_s
->scanning
= scanning
;
1123 wpas_notify_scanning(wpa_s
);
1128 static int wpa_scan_get_max_rate(const struct wpa_scan_res
*res
)
1134 ie
= wpa_scan_get_ie(res
, WLAN_EID_SUPP_RATES
);
1135 for (i
= 0; ie
&& i
< ie
[1]; i
++) {
1136 if ((ie
[i
+ 2] & 0x7f) > rate
)
1137 rate
= ie
[i
+ 2] & 0x7f;
1140 ie
= wpa_scan_get_ie(res
, WLAN_EID_EXT_SUPP_RATES
);
1141 for (i
= 0; ie
&& i
< ie
[1]; i
++) {
1142 if ((ie
[i
+ 2] & 0x7f) > rate
)
1143 rate
= ie
[i
+ 2] & 0x7f;
1150 const u8
* wpa_scan_get_ie(const struct wpa_scan_res
*res
, u8 ie
)
1152 const u8
*end
, *pos
;
1154 pos
= (const u8
*) (res
+ 1);
1155 end
= pos
+ res
->ie_len
;
1157 while (pos
+ 1 < end
) {
1158 if (pos
+ 2 + pos
[1] > end
)
1169 const u8
* wpa_scan_get_vendor_ie(const struct wpa_scan_res
*res
,
1172 const u8
*end
, *pos
;
1174 pos
= (const u8
*) (res
+ 1);
1175 end
= pos
+ res
->ie_len
;
1177 while (pos
+ 1 < end
) {
1178 if (pos
+ 2 + pos
[1] > end
)
1180 if (pos
[0] == WLAN_EID_VENDOR_SPECIFIC
&& pos
[1] >= 4 &&
1181 vendor_type
== WPA_GET_BE32(&pos
[2]))
1190 struct wpabuf
* wpa_scan_get_vendor_ie_multi(const struct wpa_scan_res
*res
,
1194 const u8
*end
, *pos
;
1196 buf
= wpabuf_alloc(res
->ie_len
);
1200 pos
= (const u8
*) (res
+ 1);
1201 end
= pos
+ res
->ie_len
;
1203 while (pos
+ 1 < end
) {
1204 if (pos
+ 2 + pos
[1] > end
)
1206 if (pos
[0] == WLAN_EID_VENDOR_SPECIFIC
&& pos
[1] >= 4 &&
1207 vendor_type
== WPA_GET_BE32(&pos
[2]))
1208 wpabuf_put_data(buf
, pos
+ 2 + 4, pos
[1] - 4);
1212 if (wpabuf_len(buf
) == 0) {
1221 struct wpabuf
* wpa_scan_get_vendor_ie_multi_beacon(
1222 const struct wpa_scan_res
*res
, u32 vendor_type
)
1225 const u8
*end
, *pos
;
1227 if (res
->beacon_ie_len
== 0)
1229 buf
= wpabuf_alloc(res
->beacon_ie_len
);
1233 pos
= (const u8
*) (res
+ 1);
1235 end
= pos
+ res
->beacon_ie_len
;
1237 while (pos
+ 1 < end
) {
1238 if (pos
+ 2 + pos
[1] > end
)
1240 if (pos
[0] == WLAN_EID_VENDOR_SPECIFIC
&& pos
[1] >= 4 &&
1241 vendor_type
== WPA_GET_BE32(&pos
[2]))
1242 wpabuf_put_data(buf
, pos
+ 2 + 4, pos
[1] - 4);
1246 if (wpabuf_len(buf
) == 0) {
1256 * Channels with a great SNR can operate at full rate. What is a great SNR?
1257 * This doc https://supportforums.cisco.com/docs/DOC-12954 says, "the general
1258 * rule of thumb is that any SNR above 20 is good." This one
1259 * http://www.cisco.com/en/US/tech/tk722/tk809/technologies_q_and_a_item09186a00805e9a96.shtml#qa23
1260 * recommends 25 as a minimum SNR for 54 Mbps data rate. 30 is chosen here as a
1261 * conservative value.
1263 #define GREAT_SNR 30
1265 /* Compare function for sorting scan results. Return >0 if @b is considered
1267 static int wpa_scan_result_compar(const void *a
, const void *b
)
1269 #define IS_5GHZ(n) (n > 4000)
1270 #define MIN(a,b) a < b ? a : b
1271 struct wpa_scan_res
**_wa
= (void *) a
;
1272 struct wpa_scan_res
**_wb
= (void *) b
;
1273 struct wpa_scan_res
*wa
= *_wa
;
1274 struct wpa_scan_res
*wb
= *_wb
;
1275 int wpa_a
, wpa_b
, maxrate_a
, maxrate_b
;
1278 /* WPA/WPA2 support preferred */
1279 wpa_a
= wpa_scan_get_vendor_ie(wa
, WPA_IE_VENDOR_TYPE
) != NULL
||
1280 wpa_scan_get_ie(wa
, WLAN_EID_RSN
) != NULL
;
1281 wpa_b
= wpa_scan_get_vendor_ie(wb
, WPA_IE_VENDOR_TYPE
) != NULL
||
1282 wpa_scan_get_ie(wb
, WLAN_EID_RSN
) != NULL
;
1284 if (wpa_b
&& !wpa_a
)
1286 if (!wpa_b
&& wpa_a
)
1289 /* privacy support preferred */
1290 if ((wa
->caps
& IEEE80211_CAP_PRIVACY
) == 0 &&
1291 (wb
->caps
& IEEE80211_CAP_PRIVACY
))
1293 if ((wa
->caps
& IEEE80211_CAP_PRIVACY
) &&
1294 (wb
->caps
& IEEE80211_CAP_PRIVACY
) == 0)
1297 if ((wa
->flags
& wb
->flags
& WPA_SCAN_LEVEL_DBM
) &&
1298 !((wa
->flags
| wb
->flags
) & WPA_SCAN_NOISE_INVALID
)) {
1299 snr_a
= MIN(wa
->level
- wa
->noise
, GREAT_SNR
);
1300 snr_b
= MIN(wb
->level
- wb
->noise
, GREAT_SNR
);
1302 /* Not suitable information to calculate SNR, so use level */
1307 /* best/max rate preferred if SNR close enough */
1308 if ((snr_a
&& snr_b
&& abs(snr_b
- snr_a
) < 5) ||
1309 (wa
->qual
&& wb
->qual
&& abs(wb
->qual
- wa
->qual
) < 10)) {
1310 maxrate_a
= wpa_scan_get_max_rate(wa
);
1311 maxrate_b
= wpa_scan_get_max_rate(wb
);
1312 if (maxrate_a
!= maxrate_b
)
1313 return maxrate_b
- maxrate_a
;
1314 if (IS_5GHZ(wa
->freq
) ^ IS_5GHZ(wb
->freq
))
1315 return IS_5GHZ(wa
->freq
) ? -1 : 1;
1318 /* use freq for channel preference */
1320 /* all things being equal, use SNR; if SNRs are
1321 * identical, use quality values since some drivers may only report
1322 * that value and leave the signal level zero */
1324 return wb
->qual
- wa
->qual
;
1325 return snr_b
- snr_a
;
1332 /* Compare function for sorting scan results when searching a WPS AP for
1333 * provisioning. Return >0 if @b is considered better. */
1334 static int wpa_scan_result_wps_compar(const void *a
, const void *b
)
1336 struct wpa_scan_res
**_wa
= (void *) a
;
1337 struct wpa_scan_res
**_wb
= (void *) b
;
1338 struct wpa_scan_res
*wa
= *_wa
;
1339 struct wpa_scan_res
*wb
= *_wb
;
1340 int uses_wps_a
, uses_wps_b
;
1341 struct wpabuf
*wps_a
, *wps_b
;
1344 /* Optimization - check WPS IE existence before allocated memory and
1345 * doing full reassembly. */
1346 uses_wps_a
= wpa_scan_get_vendor_ie(wa
, WPS_IE_VENDOR_TYPE
) != NULL
;
1347 uses_wps_b
= wpa_scan_get_vendor_ie(wb
, WPS_IE_VENDOR_TYPE
) != NULL
;
1348 if (uses_wps_a
&& !uses_wps_b
)
1350 if (!uses_wps_a
&& uses_wps_b
)
1353 if (uses_wps_a
&& uses_wps_b
) {
1354 wps_a
= wpa_scan_get_vendor_ie_multi(wa
, WPS_IE_VENDOR_TYPE
);
1355 wps_b
= wpa_scan_get_vendor_ie_multi(wb
, WPS_IE_VENDOR_TYPE
);
1356 res
= wps_ap_priority_compar(wps_a
, wps_b
);
1364 * Do not use current AP security policy as a sorting criteria during
1365 * WPS provisioning step since the AP may get reconfigured at the
1366 * completion of provisioning.
1369 /* all things being equal, use signal level; if signal levels are
1370 * identical, use quality values since some drivers may only report
1371 * that value and leave the signal level zero */
1372 if (wb
->level
== wa
->level
)
1373 return wb
->qual
- wa
->qual
;
1374 return wb
->level
- wa
->level
;
1376 #endif /* CONFIG_WPS */
1379 static void dump_scan_res(struct wpa_scan_results
*scan_res
)
1381 #ifndef CONFIG_NO_STDOUT_DEBUG
1384 if (scan_res
->res
== NULL
|| scan_res
->num
== 0)
1387 wpa_printf(MSG_EXCESSIVE
, "Sorted scan results");
1389 for (i
= 0; i
< scan_res
->num
; i
++) {
1390 struct wpa_scan_res
*r
= scan_res
->res
[i
];
1392 if ((r
->flags
& (WPA_SCAN_LEVEL_DBM
| WPA_SCAN_NOISE_INVALID
))
1393 == WPA_SCAN_LEVEL_DBM
) {
1394 int snr
= r
->level
- r
->noise
;
1395 wpa_printf(MSG_EXCESSIVE
, MACSTR
" freq=%d qual=%d "
1396 "noise=%d level=%d snr=%d%s flags=0x%x",
1397 MAC2STR(r
->bssid
), r
->freq
, r
->qual
,
1398 r
->noise
, r
->level
, snr
,
1399 snr
>= GREAT_SNR
? "*" : "", r
->flags
);
1401 wpa_printf(MSG_EXCESSIVE
, MACSTR
" freq=%d qual=%d "
1402 "noise=%d level=%d flags=0x%x",
1403 MAC2STR(r
->bssid
), r
->freq
, r
->qual
,
1404 r
->noise
, r
->level
, r
->flags
);
1406 pos
= (u8
*) (r
+ 1);
1408 wpa_hexdump(MSG_EXCESSIVE
, "IEs", pos
, r
->ie_len
);
1410 if (r
->beacon_ie_len
)
1411 wpa_hexdump(MSG_EXCESSIVE
, "Beacon IEs",
1412 pos
, r
->beacon_ie_len
);
1414 #endif /* CONFIG_NO_STDOUT_DEBUG */
1418 int wpa_supplicant_filter_bssid_match(struct wpa_supplicant
*wpa_s
,
1423 if (wpa_s
->bssid_filter
== NULL
)
1426 for (i
= 0; i
< wpa_s
->bssid_filter_count
; i
++) {
1427 if (os_memcmp(wpa_s
->bssid_filter
+ i
* ETH_ALEN
, bssid
,
1436 static void filter_scan_res(struct wpa_supplicant
*wpa_s
,
1437 struct wpa_scan_results
*res
)
1441 if (wpa_s
->bssid_filter
== NULL
)
1444 for (i
= 0, j
= 0; i
< res
->num
; i
++) {
1445 if (wpa_supplicant_filter_bssid_match(wpa_s
,
1446 res
->res
[i
]->bssid
)) {
1447 res
->res
[j
++] = res
->res
[i
];
1449 os_free(res
->res
[i
]);
1454 if (res
->num
!= j
) {
1455 wpa_printf(MSG_DEBUG
, "Filtered out %d scan results",
1456 (int) (res
->num
- j
));
1463 * wpa_supplicant_get_scan_results - Get scan results
1464 * @wpa_s: Pointer to wpa_supplicant data
1465 * @info: Information about what was scanned or %NULL if not available
1466 * @new_scan: Whether a new scan was performed
1467 * Returns: Scan results, %NULL on failure
1469 * This function request the current scan results from the driver and updates
1470 * the local BSS list wpa_s->bss. The caller is responsible for freeing the
1471 * results with wpa_scan_results_free().
1473 struct wpa_scan_results
*
1474 wpa_supplicant_get_scan_results(struct wpa_supplicant
*wpa_s
,
1475 struct scan_info
*info
, int new_scan
)
1477 struct wpa_scan_results
*scan_res
;
1479 int (*compar
)(const void *, const void *) = wpa_scan_result_compar
;
1481 scan_res
= wpa_drv_get_scan_results2(wpa_s
);
1482 if (scan_res
== NULL
) {
1483 wpa_dbg(wpa_s
, MSG_DEBUG
, "Failed to get scan results");
1486 filter_scan_res(wpa_s
, scan_res
);
1489 if (wpas_wps_in_progress(wpa_s
)) {
1490 wpa_dbg(wpa_s
, MSG_DEBUG
, "WPS: Order scan results with WPS "
1491 "provisioning rules");
1492 compar
= wpa_scan_result_wps_compar
;
1494 #endif /* CONFIG_WPS */
1496 qsort(scan_res
->res
, scan_res
->num
, sizeof(struct wpa_scan_res
*),
1498 dump_scan_res(scan_res
);
1500 wpa_bss_update_start(wpa_s
);
1501 for (i
= 0; i
< scan_res
->num
; i
++)
1502 wpa_bss_update_scan_res(wpa_s
, scan_res
->res
[i
]);
1503 wpa_bss_update_end(wpa_s
, info
, new_scan
);
1509 int wpa_supplicant_update_scan_results(struct wpa_supplicant
*wpa_s
)
1511 struct wpa_scan_results
*scan_res
;
1512 scan_res
= wpa_supplicant_get_scan_results(wpa_s
, NULL
, 0);
1513 if (scan_res
== NULL
)
1515 wpa_scan_results_free(scan_res
);