blob: 6ba7424ffee2dc3a6193385a0f6b92250378214b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -1206,7 +1206,7 @@ static int wpa_supplicant_get_scan_resul
{
#define SCAN_AP_LIMIT 128
struct wpa_scan_result *results;
- int num, i;
+ int num, i, j;
struct wpa_scan_results *res;
results = os_malloc(SCAN_AP_LIMIT * sizeof(struct wpa_scan_result));
@@ -1303,6 +1303,21 @@ static int wpa_supplicant_get_scan_resul
res->res[res->num++] = r;
}
+ /* sort scan results by quality */
+ for(i = 0; i < num - 1; i++) {
+ for(j = i + 1; j < num; j++) {
+ struct wpa_scan_result tmp;
+
+ if (results[i].qual > results[j].qual)
+ continue;
+
+ os_memcpy(&tmp, &results[i], sizeof(tmp));
+ os_memcpy(&results[i], &results[j], sizeof(tmp));
+ os_memcpy(&results[j], &tmp, sizeof(tmp));
+ }
+ }
+
+
os_free(results);
wpa_s->scan_res = res;
|