fix wpa_cli compile
[openwrt.git] / package / wpa_supplicant / patches / 130-scanning.patch
1 Add a scan result cache to improve roaming speed if the driver gave us a background scan before losing the connection.
2
3 Index: wpa_supplicant-0.6.3/wpa_supplicant/config.h
4 ===================================================================
5 --- wpa_supplicant-0.6.3.orig/wpa_supplicant/config.h 2008-02-23 03:45:24.000000000 +0100
6 +++ wpa_supplicant-0.6.3/wpa_supplicant/config.h 2008-07-10 15:08:21.000000000 +0200
7 @@ -97,6 +97,12 @@
8 int ap_scan;
9
10 /**
11 + * scan_cache - controls the time in seconds after the last scan results
12 + * before a new scan may be initiated
13 + */
14 + int scan_cache;
15 +
16 + /**
17 * ctrl_interface - Parameters for the control interface
18 *
19 * If this is specified, %wpa_supplicant will open a control interface
20 Index: wpa_supplicant-0.6.3/wpa_supplicant/config_file.c
21 ===================================================================
22 --- wpa_supplicant-0.6.3.orig/wpa_supplicant/config_file.c 2008-02-23 03:45:24.000000000 +0100
23 +++ wpa_supplicant-0.6.3/wpa_supplicant/config_file.c 2008-07-10 15:59:38.000000000 +0200
24 @@ -312,6 +312,13 @@
25 return 0;
26 }
27
28 +static int wpa_config_process_scan_cache(struct wpa_config *config, char *pos)
29 +{
30 + config->scan_cache = atoi(pos);
31 + wpa_printf(MSG_DEBUG, "scan_cache=%d", config->scan_cache);
32 + return 0;
33 +}
34 +
35
36 static int wpa_config_process_fast_reauth(struct wpa_config *config, char *pos)
37 {
38 @@ -445,6 +452,9 @@
39 if (os_strncmp(pos, "ap_scan=", 8) == 0)
40 return wpa_config_process_ap_scan(config, pos + 8);
41
42 + if (os_strncmp(pos, "scan_cache=", 11) == 0)
43 + return wpa_config_process_scan_cache(config, pos + 11);
44 +
45 if (os_strncmp(pos, "fast_reauth=", 12) == 0)
46 return wpa_config_process_fast_reauth(config, pos + 12);
47
48 @@ -810,6 +820,8 @@
49 fprintf(f, "eapol_version=%d\n", config->eapol_version);
50 if (config->ap_scan != DEFAULT_AP_SCAN)
51 fprintf(f, "ap_scan=%d\n", config->ap_scan);
52 + if (config->scan_cache != 0)
53 + fprintf(f, "scan_cache=%d\n", config->scan_cache);
54 if (config->fast_reauth != DEFAULT_FAST_REAUTH)
55 fprintf(f, "fast_reauth=%d\n", config->fast_reauth);
56 #ifdef EAP_TLS_OPENSSL
57 Index: wpa_supplicant-0.6.3/wpa_supplicant/events.c
58 ===================================================================
59 --- wpa_supplicant-0.6.3.orig/wpa_supplicant/events.c 2008-07-10 13:27:03.000000000 +0200
60 +++ wpa_supplicant-0.6.3/wpa_supplicant/events.c 2008-07-10 17:18:53.000000000 +0200
61 @@ -555,6 +555,9 @@
62 if (wpa_s->conf->ap_scan == 2 || wpa_s->disconnected)
63 return;
64
65 + if (wpa_s->wpa_state > WPA_ASSOCIATED)
66 + goto done;
67 +
68 while (selected == NULL) {
69 for (prio = 0; prio < wpa_s->conf->num_prio; prio++) {
70 selected = wpa_supplicant_select_bss(
71 @@ -594,13 +597,16 @@
72 rsn_preauth_scan_results(wpa_s->wpa, wpa_s->scan_res);
73 } else {
74 wpa_printf(MSG_DEBUG, "No suitable AP found.");
75 - timeout = 5;
76 + timeout = 1;
77 goto req_scan;
78 }
79
80 +done:
81 + os_get_time(&wpa_s->last_scan_results);
82 return;
83
84 req_scan:
85 + memset(&wpa_s->last_scan_results, 0, sizeof(wpa_s->last_scan_results));
86 if (wpa_s->scan_res_tried == 1 && wpa_s->conf->ap_scan == 1) {
87 /*
88 * Quick recovery if the initial scan results were not
89 @@ -804,6 +810,9 @@
90 }
91 if (wpa_s->wpa_state >= WPA_ASSOCIATED)
92 wpa_supplicant_req_scan(wpa_s, 0, 100000);
93 + else if (wpa_s->wpa_state == WPA_ASSOCIATING)
94 + wpa_supplicant_req_auth_timeout(wpa_s, 0, 100000);
95 +
96 bssid = wpa_s->bssid;
97 if (os_memcmp(bssid, "\x00\x00\x00\x00\x00\x00", ETH_ALEN) == 0)
98 bssid = wpa_s->pending_bssid;
99 Index: wpa_supplicant-0.6.3/wpa_supplicant/wpa_supplicant_i.h
100 ===================================================================
101 --- wpa_supplicant-0.6.3.orig/wpa_supplicant/wpa_supplicant_i.h 2008-07-10 15:03:56.000000000 +0200
102 +++ wpa_supplicant-0.6.3/wpa_supplicant/wpa_supplicant_i.h 2008-07-10 15:16:17.000000000 +0200
103 @@ -334,6 +334,7 @@
104 struct wpa_client_mlme mlme;
105 int use_client_mlme;
106 int driver_4way_handshake;
107 + struct os_time last_scan_results;
108 };
109
110
111 @@ -381,6 +382,7 @@
112
113 /* scan.c */
114 void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec);
115 +int wpa_supplicant_may_scan(struct wpa_supplicant *wpa_s);
116 void wpa_supplicant_cancel_scan(struct wpa_supplicant *wpa_s);
117
118 /* events.c */
119 Index: wpa_supplicant-0.6.3/wpa_supplicant/scan.c
120 ===================================================================
121 --- wpa_supplicant-0.6.3.orig/wpa_supplicant/scan.c 2008-07-10 13:27:03.000000000 +0200
122 +++ wpa_supplicant-0.6.3/wpa_supplicant/scan.c 2008-07-10 16:24:31.000000000 +0200
123 @@ -40,6 +40,18 @@
124 wpa_supplicant_event(wpa_s, EVENT_ASSOC, &data);
125 }
126
127 +int wpa_supplicant_may_scan(struct wpa_supplicant *wpa_s)
128 +{
129 + struct os_time time;
130 +
131 + if (wpa_s->conf->scan_cache > 0) {
132 + os_get_time(&time);
133 + time.sec -= wpa_s->conf->scan_cache;
134 + if (os_time_before(&time, &wpa_s->last_scan_results))
135 + return 0;
136 + }
137 + return 1;
138 +}
139
140 static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx)
141 {
142 @@ -150,8 +162,9 @@
143 } else
144 wpa_s->prev_scan_ssid = BROADCAST_SSID_SCAN;
145
146 - if (wpa_s->scan_res_tried == 0 && wpa_s->conf->ap_scan == 1 &&
147 - !wpa_s->use_client_mlme) {
148 + if (!wpa_supplicant_may_scan(wpa_s) ||
149 + (wpa_s->scan_res_tried == 0 && wpa_s->conf->ap_scan == 1 &&
150 + !wpa_s->use_client_mlme)) {
151 wpa_s->scan_res_tried++;
152 wpa_printf(MSG_DEBUG, "Trying to get current scan results "
153 "first without requesting a new scan to speed up "
154 Index: wpa_supplicant-0.6.3/wpa_supplicant/wpa_supplicant.c
155 ===================================================================
156 --- wpa_supplicant-0.6.3.orig/wpa_supplicant/wpa_supplicant.c 2008-07-10 14:41:16.000000000 +0200
157 +++ wpa_supplicant-0.6.3/wpa_supplicant/wpa_supplicant.c 2008-07-10 18:45:59.000000000 +0200
158 @@ -1417,6 +1417,9 @@
159 {
160 struct wpa_supplicant *wpa_s = ctx;
161
162 + if (wpa_s->wpa_state < WPA_ASSOCIATING)
163 + return;
164 +
165 wpa_printf(MSG_DEBUG, "RX EAPOL from " MACSTR, MAC2STR(src_addr));
166 wpa_hexdump(MSG_MSGDUMP, "RX EAPOL", buf, len);
167
This page took 0.050356 seconds and 5 git commands to generate.