2 * WPA Supplicant - Scanning
3 * Copyright (c) 2003-2010, Jouni Malinen <j@w1.fi>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * Alternatively, this software may be distributed under the terms of BSD
12 * See README and COPYING for more details.
15 #include "utils/includes.h"
17 #include "utils/common.h"
18 #include "utils/eloop.h"
19 #include "common/ieee802_11_defs.h"
21 #include "wpa_supplicant_i.h"
24 #include "wps_supplicant.h"
25 #include "p2p_supplicant.h"
32 static void wpa_supplicant_gen_assoc_event(struct wpa_supplicant
*wpa_s
)
34 struct wpa_ssid
*ssid
;
35 union wpa_event_data data
;
37 ssid
= wpa_supplicant_get_ssid(wpa_s
);
41 if (wpa_s
->current_ssid
== NULL
) {
42 wpa_s
->current_ssid
= ssid
;
43 if (wpa_s
->current_ssid
!= NULL
)
44 wpas_notify_network_changed(wpa_s
);
46 wpa_supplicant_initiate_eapol(wpa_s
);
47 wpa_printf(MSG_DEBUG
, "Already associated with a configured network - "
48 "generating associated event");
49 os_memset(&data
, 0, sizeof(data
));
50 wpa_supplicant_event(wpa_s
, EVENT_ASSOC
, &data
);
55 static int wpas_wps_in_use(struct wpa_config
*conf
,
56 enum wps_request_type
*req_type
)
58 struct wpa_ssid
*ssid
;
61 for (ssid
= conf
->ssid
; ssid
; ssid
= ssid
->next
) {
62 if (!(ssid
->key_mgmt
& WPA_KEY_MGMT_WPS
))
66 *req_type
= wpas_wps_get_req_type(ssid
);
67 if (!ssid
->eap
.phase1
)
70 if (os_strstr(ssid
->eap
.phase1
, "pbc=1"))
76 #endif /* CONFIG_WPS */
79 int wpa_supplicant_enabled_networks(struct wpa_config
*conf
)
81 struct wpa_ssid
*ssid
= conf
->ssid
;
91 static void wpa_supplicant_assoc_try(struct wpa_supplicant
*wpa_s
,
92 struct wpa_ssid
*ssid
)
100 /* ap_scan=2 mode - try to associate with each SSID. */
102 wpa_printf(MSG_DEBUG
, "wpa_supplicant_scan: Reached "
103 "end of scan list - go back to beginning");
104 wpa_s
->prev_scan_ssid
= WILDCARD_SSID_SCAN
;
105 wpa_supplicant_req_scan(wpa_s
, 0, 0);
109 /* Continue from the next SSID on the next attempt. */
110 wpa_s
->prev_scan_ssid
= ssid
;
112 /* Start from the beginning of the SSID list. */
113 wpa_s
->prev_scan_ssid
= WILDCARD_SSID_SCAN
;
115 wpa_supplicant_associate(wpa_s
, NULL
, ssid
);
119 static int int_array_len(const int *a
)
122 for (i
= 0; a
&& a
[i
]; i
++)
128 static void int_array_concat(int **res
, const int *a
)
133 reslen
= int_array_len(*res
);
134 alen
= int_array_len(a
);
136 n
= os_realloc(*res
, (reslen
+ alen
+ 1) * sizeof(int));
142 for (i
= 0; i
<= alen
; i
++)
143 n
[reslen
+ i
] = a
[i
];
148 static int freq_cmp(const void *a
, const void *b
)
161 static void int_array_sort_unique(int *a
)
169 alen
= int_array_len(a
);
170 qsort(a
, alen
, sizeof(int), freq_cmp
);
174 while (a
[i
] && a
[j
]) {
187 int wpa_supplicant_trigger_scan(struct wpa_supplicant
*wpa_s
,
188 struct wpa_driver_scan_params
*params
)
192 wpa_supplicant_notify_scanning(wpa_s
, 1);
194 if (wpa_s
->drv_flags
& WPA_DRIVER_FLAGS_USER_SPACE_MLME
)
195 ret
= ieee80211_sta_req_scan(wpa_s
, params
);
197 ret
= wpa_drv_scan(wpa_s
, params
);
200 wpa_supplicant_notify_scanning(wpa_s
, 0);
201 wpas_notify_scan_done(wpa_s
, 0);
209 static struct wpa_driver_scan_filter
*
210 wpa_supplicant_build_filter_ssids(struct wpa_config
*conf
, size_t *num_ssids
)
212 struct wpa_driver_scan_filter
*ssids
;
213 struct wpa_ssid
*ssid
;
217 if (!conf
->filter_ssids
)
220 for (count
= 0, ssid
= conf
->ssid
; ssid
; ssid
= ssid
->next
) {
221 if (ssid
->ssid
&& ssid
->ssid_len
)
226 ssids
= os_zalloc(count
* sizeof(struct wpa_driver_scan_filter
));
230 for (ssid
= conf
->ssid
; ssid
; ssid
= ssid
->next
) {
231 if (!ssid
->ssid
|| !ssid
->ssid_len
)
233 os_memcpy(ssids
[*num_ssids
].ssid
, ssid
->ssid
, ssid
->ssid_len
);
234 ssids
[*num_ssids
].ssid_len
= ssid
->ssid_len
;
242 static void wpa_supplicant_scan(void *eloop_ctx
, void *timeout_ctx
)
244 struct wpa_supplicant
*wpa_s
= eloop_ctx
;
245 struct wpa_ssid
*ssid
;
246 int scan_req
= 0, ret
;
247 struct wpabuf
*wps_ie
= NULL
;
250 enum wps_request_type req_type
= WPS_REQ_ENROLLEE_INFO
;
251 #endif /* CONFIG_WPS */
252 struct wpa_driver_scan_params params
;
254 enum wpa_states prev_state
;
256 if (wpa_s
->wpa_state
== WPA_INTERFACE_DISABLED
) {
257 wpa_printf(MSG_DEBUG
, "Skip scan - interface disabled");
261 if (wpa_s
->disconnected
&& !wpa_s
->scan_req
) {
262 wpa_supplicant_set_state(wpa_s
, WPA_DISCONNECTED
);
266 if (!wpa_supplicant_enabled_networks(wpa_s
->conf
) &&
268 wpa_printf(MSG_DEBUG
, "No enabled networks - do not scan");
269 wpa_supplicant_set_state(wpa_s
, WPA_INACTIVE
);
273 if (wpa_s
->conf
->ap_scan
!= 0 &&
274 (wpa_s
->drv_flags
& WPA_DRIVER_FLAGS_WIRED
)) {
275 wpa_printf(MSG_DEBUG
, "Using wired authentication - "
276 "overriding ap_scan configuration");
277 wpa_s
->conf
->ap_scan
= 0;
278 wpas_notify_ap_scan_changed(wpa_s
);
281 if (wpa_s
->conf
->ap_scan
== 0) {
282 wpa_supplicant_gen_assoc_event(wpa_s
);
286 if ((wpa_s
->drv_flags
& WPA_DRIVER_FLAGS_USER_SPACE_MLME
) ||
287 wpa_s
->conf
->ap_scan
== 2)
290 max_ssids
= wpa_s
->max_scan_ssids
;
291 if (max_ssids
> WPAS_MAX_SCAN_SSIDS
)
292 max_ssids
= WPAS_MAX_SCAN_SSIDS
;
296 wps
= wpas_wps_in_use(wpa_s
->conf
, &req_type
);
297 #endif /* CONFIG_WPS */
299 scan_req
= wpa_s
->scan_req
;
302 os_memset(¶ms
, 0, sizeof(params
));
304 prev_state
= wpa_s
->wpa_state
;
305 if (wpa_s
->wpa_state
== WPA_DISCONNECTED
||
306 wpa_s
->wpa_state
== WPA_INACTIVE
)
307 wpa_supplicant_set_state(wpa_s
, WPA_SCANNING
);
309 /* Find the starting point from which to continue scanning */
310 ssid
= wpa_s
->conf
->ssid
;
311 if (wpa_s
->prev_scan_ssid
!= WILDCARD_SSID_SCAN
) {
313 if (ssid
== wpa_s
->prev_scan_ssid
) {
321 if (scan_req
!= 2 && (wpa_s
->conf
->ap_scan
== 2 ||
322 wpa_s
->connect_without_scan
)) {
323 wpa_s
->connect_without_scan
= 0;
324 wpa_supplicant_assoc_try(wpa_s
, ssid
);
326 } else if (wpa_s
->conf
->ap_scan
== 2) {
328 * User-initiated scan request in ap_scan == 2; scan with
333 struct wpa_ssid
*start
= ssid
, *tssid
;
335 if (ssid
== NULL
&& max_ssids
> 1)
336 ssid
= wpa_s
->conf
->ssid
;
338 if (!ssid
->disabled
&& ssid
->scan_ssid
) {
339 wpa_hexdump_ascii(MSG_DEBUG
, "Scan SSID",
340 ssid
->ssid
, ssid
->ssid_len
);
341 params
.ssids
[params
.num_ssids
].ssid
=
343 params
.ssids
[params
.num_ssids
].ssid_len
=
346 if (params
.num_ssids
+ 1 >= max_ssids
)
352 if (ssid
== NULL
&& max_ssids
> 1 &&
353 start
!= wpa_s
->conf
->ssid
)
354 ssid
= wpa_s
->conf
->ssid
;
357 for (tssid
= wpa_s
->conf
->ssid
; tssid
; tssid
= tssid
->next
) {
360 if ((params
.freqs
|| !freqs_set
) && tssid
->scan_freq
) {
361 int_array_concat(¶ms
.freqs
,
364 os_free(params
.freqs
);
369 int_array_sort_unique(params
.freqs
);
373 wpa_s
->prev_scan_ssid
= ssid
;
375 wpa_printf(MSG_DEBUG
, "Include wildcard SSID in the "
379 wpa_printf(MSG_DEBUG
, "Starting AP scan for specific SSID(s)");
381 wpa_s
->prev_scan_ssid
= WILDCARD_SSID_SCAN
;
383 wpa_printf(MSG_DEBUG
, "Starting AP scan for wildcard SSID");
387 wpa_s
->wps
->dev
.p2p
= 1;
390 req_type
= WPS_REQ_ENROLLEE_INFO
;
393 if (params
.freqs
== NULL
&& wpa_s
->p2p_in_provisioning
&&
395 /* Optimize provisioning state scan based on GO information */
396 if (wpa_s
->p2p_in_provisioning
< 5 &&
397 wpa_s
->go_params
->freq
> 0) {
398 wpa_printf(MSG_DEBUG
, "P2P: Scan only GO preferred "
400 wpa_s
->go_params
->freq
);
401 params
.freqs
= os_zalloc(2 * sizeof(int));
403 params
.freqs
[0] = wpa_s
->go_params
->freq
;
404 } else if (wpa_s
->p2p_in_provisioning
< 8 &&
405 wpa_s
->go_params
->freq_list
[0]) {
406 wpa_printf(MSG_DEBUG
, "P2P: Scan only common "
408 int_array_concat(¶ms
.freqs
,
409 wpa_s
->go_params
->freq_list
);
411 int_array_sort_unique(params
.freqs
);
413 wpa_s
->p2p_in_provisioning
++;
415 #endif /* CONFIG_P2P */
418 if (params
.freqs
== NULL
&& wpa_s
->after_wps
&& wpa_s
->wps_freq
) {
420 * Optimize post-provisioning scan based on channel used
421 * during provisioning.
423 wpa_printf(MSG_DEBUG
, "WPS: Scan only frequency %u MHz that "
424 "was used during provisioning", wpa_s
->wps_freq
);
425 params
.freqs
= os_zalloc(2 * sizeof(int));
427 params
.freqs
[0] = wpa_s
->wps_freq
;
432 wps_ie
= wps_build_probe_req_ie(wps
== 2, &wpa_s
->wps
->dev
,
433 wpa_s
->wps
->uuid
, req_type
);
435 params
.extra_ies
= wpabuf_head(wps_ie
);
436 params
.extra_ies_len
= wpabuf_len(wps_ie
);
439 #endif /* CONFIG_WPS */
443 if (wpabuf_resize(&wps_ie
, 100) == 0) {
444 wpas_p2p_scan_ie(wpa_s
, wps_ie
);
445 params
.extra_ies
= wpabuf_head(wps_ie
);
446 params
.extra_ies_len
= wpabuf_len(wps_ie
);
449 #endif /* CONFIG_P2P */
451 if (params
.freqs
== NULL
&& wpa_s
->next_scan_freqs
) {
452 wpa_printf(MSG_DEBUG
, "Optimize scan based on previously "
453 "generated frequency list");
454 params
.freqs
= wpa_s
->next_scan_freqs
;
456 os_free(wpa_s
->next_scan_freqs
);
457 wpa_s
->next_scan_freqs
= NULL
;
459 params
.filter_ssids
= wpa_supplicant_build_filter_ssids(
460 wpa_s
->conf
, ¶ms
.num_filter_ssids
);
462 ret
= wpa_supplicant_trigger_scan(wpa_s
, ¶ms
);
465 os_free(params
.freqs
);
466 os_free(params
.filter_ssids
);
469 wpa_printf(MSG_WARNING
, "Failed to initiate AP scan.");
470 if (prev_state
!= wpa_s
->wpa_state
)
471 wpa_supplicant_set_state(wpa_s
, prev_state
);
472 wpa_supplicant_req_scan(wpa_s
, 1, 0);
478 * wpa_supplicant_req_scan - Schedule a scan for neighboring access points
479 * @wpa_s: Pointer to wpa_supplicant data
480 * @sec: Number of seconds after which to scan
481 * @usec: Number of microseconds after which to scan
483 * This function is used to schedule a scan for neighboring access points after
484 * the specified time.
486 void wpa_supplicant_req_scan(struct wpa_supplicant
*wpa_s
, int sec
, int usec
)
488 /* If there's at least one network that should be specifically scanned
489 * then don't cancel the scan and reschedule. Some drivers do
490 * background scanning which generates frequent scan results, and that
491 * causes the specific SSID scan to get continually pushed back and
492 * never happen, which causes hidden APs to never get probe-scanned.
494 if (eloop_is_timeout_registered(wpa_supplicant_scan
, wpa_s
, NULL
) &&
495 wpa_s
->conf
->ap_scan
== 1) {
496 struct wpa_ssid
*ssid
= wpa_s
->conf
->ssid
;
499 if (!ssid
->disabled
&& ssid
->scan_ssid
)
504 wpa_msg(wpa_s
, MSG_DEBUG
, "Not rescheduling scan to "
505 "ensure that specific SSID scans occur");
510 wpa_msg(wpa_s
, MSG_DEBUG
, "Setting scan request: %d sec %d usec",
512 eloop_cancel_timeout(wpa_supplicant_scan
, wpa_s
, NULL
);
513 eloop_register_timeout(sec
, usec
, wpa_supplicant_scan
, wpa_s
, NULL
);
518 * wpa_supplicant_cancel_scan - Cancel a scheduled scan request
519 * @wpa_s: Pointer to wpa_supplicant data
521 * This function is used to cancel a scan request scheduled with
522 * wpa_supplicant_req_scan().
524 void wpa_supplicant_cancel_scan(struct wpa_supplicant
*wpa_s
)
526 wpa_msg(wpa_s
, MSG_DEBUG
, "Cancelling scan request");
527 eloop_cancel_timeout(wpa_supplicant_scan
, wpa_s
, NULL
);
531 void wpa_supplicant_notify_scanning(struct wpa_supplicant
*wpa_s
,
534 if (wpa_s
->scanning
!= scanning
) {
535 wpa_s
->scanning
= scanning
;
536 wpas_notify_scanning(wpa_s
);
541 static int wpa_scan_get_max_rate(const struct wpa_scan_res
*res
)
547 ie
= wpa_scan_get_ie(res
, WLAN_EID_SUPP_RATES
);
548 for (i
= 0; ie
&& i
< ie
[1]; i
++) {
549 if ((ie
[i
+ 2] & 0x7f) > rate
)
550 rate
= ie
[i
+ 2] & 0x7f;
553 ie
= wpa_scan_get_ie(res
, WLAN_EID_EXT_SUPP_RATES
);
554 for (i
= 0; ie
&& i
< ie
[1]; i
++) {
555 if ((ie
[i
+ 2] & 0x7f) > rate
)
556 rate
= ie
[i
+ 2] & 0x7f;
563 const u8
* wpa_scan_get_ie(const struct wpa_scan_res
*res
, u8 ie
)
567 pos
= (const u8
*) (res
+ 1);
568 end
= pos
+ res
->ie_len
;
570 while (pos
+ 1 < end
) {
571 if (pos
+ 2 + pos
[1] > end
)
582 const u8
* wpa_scan_get_vendor_ie(const struct wpa_scan_res
*res
,
587 pos
= (const u8
*) (res
+ 1);
588 end
= pos
+ res
->ie_len
;
590 while (pos
+ 1 < end
) {
591 if (pos
+ 2 + pos
[1] > end
)
593 if (pos
[0] == WLAN_EID_VENDOR_SPECIFIC
&& pos
[1] >= 4 &&
594 vendor_type
== WPA_GET_BE32(&pos
[2]))
603 struct wpabuf
* wpa_scan_get_vendor_ie_multi(const struct wpa_scan_res
*res
,
609 buf
= wpabuf_alloc(res
->ie_len
);
613 pos
= (const u8
*) (res
+ 1);
614 end
= pos
+ res
->ie_len
;
616 while (pos
+ 1 < end
) {
617 if (pos
+ 2 + pos
[1] > end
)
619 if (pos
[0] == WLAN_EID_VENDOR_SPECIFIC
&& pos
[1] >= 4 &&
620 vendor_type
== WPA_GET_BE32(&pos
[2]))
621 wpabuf_put_data(buf
, pos
+ 2 + 4, pos
[1] - 4);
625 if (wpabuf_len(buf
) == 0) {
634 struct wpabuf
* wpa_scan_get_vendor_ie_multi_beacon(
635 const struct wpa_scan_res
*res
, u32 vendor_type
)
640 if (res
->beacon_ie_len
== 0)
642 buf
= wpabuf_alloc(res
->beacon_ie_len
);
646 pos
= (const u8
*) (res
+ 1);
648 end
= pos
+ res
->beacon_ie_len
;
650 while (pos
+ 1 < end
) {
651 if (pos
+ 2 + pos
[1] > end
)
653 if (pos
[0] == WLAN_EID_VENDOR_SPECIFIC
&& pos
[1] >= 4 &&
654 vendor_type
== WPA_GET_BE32(&pos
[2]))
655 wpabuf_put_data(buf
, pos
+ 2 + 4, pos
[1] - 4);
659 if (wpabuf_len(buf
) == 0) {
668 /* Compare function for sorting scan results. Return >0 if @b is considered
670 static int wpa_scan_result_compar(const void *a
, const void *b
)
672 struct wpa_scan_res
**_wa
= (void *) a
;
673 struct wpa_scan_res
**_wb
= (void *) b
;
674 struct wpa_scan_res
*wa
= *_wa
;
675 struct wpa_scan_res
*wb
= *_wb
;
676 int wpa_a
, wpa_b
, maxrate_a
, maxrate_b
;
678 /* WPA/WPA2 support preferred */
679 wpa_a
= wpa_scan_get_vendor_ie(wa
, WPA_IE_VENDOR_TYPE
) != NULL
||
680 wpa_scan_get_ie(wa
, WLAN_EID_RSN
) != NULL
;
681 wpa_b
= wpa_scan_get_vendor_ie(wb
, WPA_IE_VENDOR_TYPE
) != NULL
||
682 wpa_scan_get_ie(wb
, WLAN_EID_RSN
) != NULL
;
689 /* privacy support preferred */
690 if ((wa
->caps
& IEEE80211_CAP_PRIVACY
) == 0 &&
691 (wb
->caps
& IEEE80211_CAP_PRIVACY
))
693 if ((wa
->caps
& IEEE80211_CAP_PRIVACY
) &&
694 (wb
->caps
& IEEE80211_CAP_PRIVACY
) == 0)
697 /* best/max rate preferred if signal level close enough XXX */
698 if ((wa
->level
&& wb
->level
&& abs(wb
->level
- wa
->level
) < 5) ||
699 (wa
->qual
&& wb
->qual
&& abs(wb
->qual
- wa
->qual
) < 10)) {
700 maxrate_a
= wpa_scan_get_max_rate(wa
);
701 maxrate_b
= wpa_scan_get_max_rate(wb
);
702 if (maxrate_a
!= maxrate_b
)
703 return maxrate_b
- maxrate_a
;
706 /* use freq for channel preference */
708 /* all things being equal, use signal level; if signal levels are
709 * identical, use quality values since some drivers may only report
710 * that value and leave the signal level zero */
711 if (wb
->level
== wa
->level
)
712 return wb
->qual
- wa
->qual
;
713 return wb
->level
- wa
->level
;
718 /* Compare function for sorting scan results when searching a WPS AP for
719 * provisioning. Return >0 if @b is considered better. */
720 static int wpa_scan_result_wps_compar(const void *a
, const void *b
)
722 struct wpa_scan_res
**_wa
= (void *) a
;
723 struct wpa_scan_res
**_wb
= (void *) b
;
724 struct wpa_scan_res
*wa
= *_wa
;
725 struct wpa_scan_res
*wb
= *_wb
;
726 int uses_wps_a
, uses_wps_b
;
727 struct wpabuf
*wps_a
, *wps_b
;
730 /* Optimization - check WPS IE existence before allocated memory and
731 * doing full reassembly. */
732 uses_wps_a
= wpa_scan_get_vendor_ie(wa
, WPS_IE_VENDOR_TYPE
) != NULL
;
733 uses_wps_b
= wpa_scan_get_vendor_ie(wb
, WPS_IE_VENDOR_TYPE
) != NULL
;
734 if (uses_wps_a
&& !uses_wps_b
)
736 if (!uses_wps_a
&& uses_wps_b
)
739 if (uses_wps_a
&& uses_wps_b
) {
740 wps_a
= wpa_scan_get_vendor_ie_multi(wa
, WPS_IE_VENDOR_TYPE
);
741 wps_b
= wpa_scan_get_vendor_ie_multi(wb
, WPS_IE_VENDOR_TYPE
);
742 res
= wps_ap_priority_compar(wps_a
, wps_b
);
750 * Do not use current AP security policy as a sorting criteria during
751 * WPS provisioning step since the AP may get reconfigured at the
752 * completion of provisioning.
755 /* all things being equal, use signal level; if signal levels are
756 * identical, use quality values since some drivers may only report
757 * that value and leave the signal level zero */
758 if (wb
->level
== wa
->level
)
759 return wb
->qual
- wa
->qual
;
760 return wb
->level
- wa
->level
;
762 #endif /* CONFIG_WPS */
766 * wpa_supplicant_get_scan_results - Get scan results
767 * @wpa_s: Pointer to wpa_supplicant data
768 * @info: Information about what was scanned or %NULL if not available
769 * @new_scan: Whether a new scan was performed
770 * Returns: Scan results, %NULL on failure
772 * This function request the current scan results from the driver and updates
773 * the local BSS list wpa_s->bss. The caller is responsible for freeing the
774 * results with wpa_scan_results_free().
776 struct wpa_scan_results
*
777 wpa_supplicant_get_scan_results(struct wpa_supplicant
*wpa_s
,
778 struct scan_info
*info
, int new_scan
)
780 struct wpa_scan_results
*scan_res
;
782 int (*compar
)(const void *, const void *) = wpa_scan_result_compar
;
784 if (wpa_s
->drv_flags
& WPA_DRIVER_FLAGS_USER_SPACE_MLME
)
785 scan_res
= ieee80211_sta_get_scan_results(wpa_s
);
787 scan_res
= wpa_drv_get_scan_results2(wpa_s
);
788 if (scan_res
== NULL
) {
789 wpa_printf(MSG_DEBUG
, "Failed to get scan results");
794 if (wpas_wps_in_progress(wpa_s
)) {
795 wpa_printf(MSG_DEBUG
, "WPS: Order scan results with WPS "
796 "provisioning rules");
797 compar
= wpa_scan_result_wps_compar
;
799 #endif /* CONFIG_WPS */
801 qsort(scan_res
->res
, scan_res
->num
, sizeof(struct wpa_scan_res
*),
804 wpa_bss_update_start(wpa_s
);
805 for (i
= 0; i
< scan_res
->num
; i
++)
806 wpa_bss_update_scan_res(wpa_s
, scan_res
->res
[i
]);
807 wpa_bss_update_end(wpa_s
, info
, new_scan
);
813 int wpa_supplicant_update_scan_results(struct wpa_supplicant
*wpa_s
)
815 struct wpa_scan_results
*scan_res
;
816 scan_res
= wpa_supplicant_get_scan_results(wpa_s
, NULL
, 0);
817 if (scan_res
== NULL
)
819 wpa_scan_results_free(scan_res
);
825 void wpa_scan_results_free(struct wpa_scan_results
*res
)
832 for (i
= 0; i
< res
->num
; i
++)
833 os_free(res
->res
[i
]);