wpa_supplicant/scan.c
struct wpa_scan_results *
wpa_supplicant_get_scan_results(struct wpa_supplicant *wpa_s,
				struct scan_info *info, int new_scan)
{
	struct wpa_scan_results *scan_res;
	size_t i;
	int (*compar)(const void *, const void *) = wpa_scan_result_compar;

	scan_res = wpa_drv_get_scan_results2(wpa_s);
	if (scan_res == NULL) {
		wpa_dbg(wpa_s, MSG_DEBUG, "Failed to get scan results");
		return NULL;
	}
	if (scan_res->fetch_time.sec == 0) {
		/*
		 * Make sure we have a valid timestamp if the driver wrapper
		 * does not set this.
		 */
		os_get_reltime(&scan_res->fetch_time);
	}
	filter_scan_res(wpa_s, scan_res);

	for (i = 0; i < scan_res->num; i++) {
		struct wpa_scan_res *scan_res_item = scan_res->res[i];

		scan_snr(scan_res_item);
		scan_est_throughput(wpa_s, scan_res_item);
	}

#ifdef CONFIG_WPS
	if (wpas_wps_searching(wpa_s)) {
		wpa_dbg(wpa_s, MSG_DEBUG, "WPS: Order scan results with WPS "
			"provisioning rules");
		compar = wpa_scan_result_wps_compar;
	}
#endif /* CONFIG_WPS */

	qsort(scan_res->res, scan_res->num, sizeof(struct wpa_scan_res *),
	      compar);
	dump_scan_res(scan_res);

	wpa_bss_update_start(wpa_s);
	for (i = 0; i < scan_res->num; i++)
		wpa_bss_update_scan_res(wpa_s, scan_res->res[i],
					&scan_res->fetch_time);
	wpa_bss_update_end(wpa_s, info, new_scan);

	return scan_res;
}
/**
 * wpa_supplicant_get_scan_results - Get scan results
 * @wpa_s: Pointer to wpa_supplicant data
 * @info: Information about what was scanned or %NULL if not available
 * @new_scan: Whether a new scan was performed
 * Returns: Scan results, %NULL on failure
 *
 * This function request the current scan results from the driver and updates
 * the local BSS list wpa_s->bss. The caller is responsible for freeing the
 * results with wpa_scan_results_free().
 */
Get scan results
@wpa_s: Pointer to wpa_supplicant data
@info: Information about what was scanned or %NULL if not available
@new_scan: Whether a new scan was performed
Returns: Scan results, %NULL on failure

This function request the current scan results from the driver and updates
the local BSS list wpa_s->bss. The caller is responsible for freeing the
results with wpa_scan_results_free().
Get scan results @wpa_s : Pointer to wpa_supplicant data @info : Information about what was scanned or %NULL if not available @new_scan : Whether a new scan was performed Returns : Scan results %NULL on failure This function request the current scan results from the driver and updates the local BSS list wpa_s - > bss . The caller is responsible for freeing the results with wpa_scan_results_free () .
struct wpa_scan_results *
wpa_supplicant_get_scan_results(struct wpa_supplicant *wpa_s,
				struct scan_info *info, int new_scan)
{
	struct wpa_scan_results *scan_res;
	size_t i;
	int (*compar)(const void *, const void *) = wpa_scan_result_compar;
	scan_res = wpa_drv_get_scan_results2(wpa_s);
	if (scan_res == NULL) {
		wpa_dbg(wpa_s, MSG_DEBUG, "Failed to get scan results");
		return NULL;
	}
	if (scan_res->fetch_time.sec == 0) {
		os_get_reltime(&scan_res->fetch_time);
	}
	filter_scan_res(wpa_s, scan_res);
	for (i = 0; i < scan_res->num; i++) {
		struct wpa_scan_res *scan_res_item = scan_res->res[i];
		scan_snr(scan_res_item);
		scan_est_throughput(wpa_s, scan_res_item);
	}
#ifdef CONFIG_WPS
	if (wpas_wps_searching(wpa_s)) {
		wpa_dbg(wpa_s, MSG_DEBUG, "WPS: Order scan results with WPS "
			"provisioning rules");
		compar = wpa_scan_result_wps_compar;
	}
#endif 
	qsort(scan_res->res, scan_res->num, sizeof(struct wpa_scan_res *),
	      compar);
	dump_scan_res(scan_res);
	wpa_bss_update_start(wpa_s);
	for (i = 0; i < scan_res->num; i++)
		wpa_bss_update_scan_res(wpa_s, scan_res->res[i],
					&scan_res->fetch_time);
	wpa_bss_update_end(wpa_s, info, new_scan);
	return scan_res;
}
struct wpa_scan_results * wpa_supplicant_get_scan_results ( struct wpa_supplicant * wpa_s , struct scan_info * info , int new_scan ) { struct wpa_scan_results * scan_res ; size_t i ; int ( * compar ) ( const void * , const void * ) = wpa_scan_result_compar ; scan_res = wpa_drv_get_scan_results2 ( wpa_s ) ; if ( scan_res == NULL ) { wpa_dbg ( wpa_s , MSG_DEBUG , " " ) ; return NULL ; } if ( scan_res -> fetch_time . sec == 0 ) { os_get_reltime ( & scan_res -> fetch_time ) ; } filter_scan_res ( wpa_s , scan_res ) ; for ( i = 0 ; i < scan_res -> num ; i ++ ) { struct wpa_scan_res * scan_res_item = scan_res -> res [ i ] ; scan_snr ( scan_res_item ) ; scan_est_throughput ( wpa_s , scan_res_item ) ; } #ifdef CONFIG_WPS if ( wpas_wps_searching ( wpa_s ) ) { wpa_dbg ( wpa_s , MSG_DEBUG , " " " " ) ; compar = wpa_scan_result_wps_compar ; } #endif qsort ( scan_res -> res , scan_res -> num , sizeof ( struct wpa_scan_res * ) , compar ) ; dump_scan_res ( scan_res ) ; wpa_bss_update_start ( wpa_s ) ; for ( i = 0 ; i < scan_res -> num ; i ++ ) wpa_bss_update_scan_res ( wpa_s , scan_res -> res [ i ] , & scan_res -> fetch_time ) ; wpa_bss_update_end ( wpa_s , info , new_scan ) ; return scan_res ; }
wpa_supplicant_get_scan_results - Get scan results
 @wpa_s: Pointer to wpa_supplicant data
 @info: Information about what was scanned or %NULL if not available
 @new_scan: Whether a new scan was performed
 Returns: Scan results, %NULL on failure
wpa_supplicant_get_scan_results - Get scan results @wpa_s : Pointer to wpa_supplicant data @info : Information about what was scanned or %NULL if not available @new_scan : Whether a new scan was performed Returns : Scan results %NULL on failure
/*
		 * Make sure we have a valid timestamp if the driver wrapper
		 * does not set this.
		 */ /* CONFIG_WPS */