1 Add a scan result cache to improve roaming speed if the driver gave us a background scan before losing the connection.
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
11 + * scan_cache - controls the time in seconds after the last scan results
12 + * before a new scan may be initiated
17 * ctrl_interface - Parameters for the control interface
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
28 +static int wpa_config_process_scan_cache(struct wpa_config *config, char *pos)
30 + config->scan_cache = atoi(pos);
31 + wpa_printf(MSG_DEBUG, "scan_cache=%d", config->scan_cache);
36 static int wpa_config_process_fast_reauth(struct wpa_config *config, char *pos)
39 if (os_strncmp(pos, "ap_scan=", 8) == 0)
40 return wpa_config_process_ap_scan(config, pos + 8);
42 + if (os_strncmp(pos, "scan_cache=", 11) == 0)
43 + return wpa_config_process_scan_cache(config, pos + 11);
45 if (os_strncmp(pos, "fast_reauth=", 12) == 0)
46 return wpa_config_process_fast_reauth(config, pos + 12);
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
62 if (wpa_s->conf->ap_scan == 2 || wpa_s->disconnected)
65 + if (wpa_s->wpa_state > WPA_ASSOCIATED)
68 while (selected == NULL) {
69 for (prio = 0; prio < wpa_s->conf->num_prio; prio++) {
70 selected = wpa_supplicant_select_bss(
72 rsn_preauth_scan_results(wpa_s->wpa, wpa_s->scan_res);
74 wpa_printf(MSG_DEBUG, "No suitable AP found.");
81 + os_get_time(&wpa_s->last_scan_results);
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) {
88 * Quick recovery if the initial scan results were not
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);
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
104 struct wpa_client_mlme mlme;
106 int driver_4way_handshake;
107 + struct os_time last_scan_results;
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);
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
124 wpa_supplicant_event(wpa_s, EVENT_ASSOC, &data);
127 +int wpa_supplicant_may_scan(struct wpa_supplicant *wpa_s)
129 + struct os_time time;
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))
140 static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx)
144 wpa_s->prev_scan_ssid = BROADCAST_SSID_SCAN;
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 @@
160 struct wpa_supplicant *wpa_s = ctx;
162 + if (wpa_s->wpa_state < WPA_ASSOCIATING)
165 wpa_printf(MSG_DEBUG, "RX EAPOL from " MACSTR, MAC2STR(src_addr));
166 wpa_hexdump(MSG_MSGDUMP, "RX EAPOL", buf, len);