build ieee80211 kernel support as modules on etrax
[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 --- a/wpa_supplicant/config.h
4 +++ b/wpa_supplicant/config.h
5 @@ -97,6 +97,12 @@
6 int ap_scan;
7
8 /**
9 + * scan_cache - controls the time in seconds after the last scan results
10 + * before a new scan may be initiated
11 + */
12 + int scan_cache;
13 +
14 + /**
15 * ctrl_interface - Parameters for the control interface
16 *
17 * If this is specified, %wpa_supplicant will open a control interface
18 --- a/wpa_supplicant/config_file.c
19 +++ b/wpa_supplicant/config_file.c
20 @@ -313,6 +313,13 @@
21 return 0;
22 }
23
24 +static int wpa_config_process_scan_cache(struct wpa_config *config, char *pos)
25 +{
26 + config->scan_cache = atoi(pos);
27 + wpa_printf(MSG_DEBUG, "scan_cache=%d", config->scan_cache);
28 + return 0;
29 +}
30 +
31
32 static int wpa_config_process_fast_reauth(struct wpa_config *config, char *pos)
33 {
34 @@ -446,6 +453,9 @@
35 if (os_strncmp(pos, "ap_scan=", 8) == 0)
36 return wpa_config_process_ap_scan(config, pos + 8);
37
38 + if (os_strncmp(pos, "scan_cache=", 11) == 0)
39 + return wpa_config_process_scan_cache(config, pos + 11);
40 +
41 if (os_strncmp(pos, "fast_reauth=", 12) == 0)
42 return wpa_config_process_fast_reauth(config, pos + 12);
43
44 @@ -819,6 +831,8 @@
45 fprintf(f, "eapol_version=%d\n", config->eapol_version);
46 if (config->ap_scan != DEFAULT_AP_SCAN)
47 fprintf(f, "ap_scan=%d\n", config->ap_scan);
48 + if (config->scan_cache != 0)
49 + fprintf(f, "scan_cache=%d\n", config->scan_cache);
50 if (config->fast_reauth != DEFAULT_FAST_REAUTH)
51 fprintf(f, "fast_reauth=%d\n", config->fast_reauth);
52 #ifdef EAP_TLS_OPENSSL
53 --- a/wpa_supplicant/events.c
54 +++ b/wpa_supplicant/events.c
55 @@ -601,6 +601,9 @@
56 if (wpa_s->conf->ap_scan == 2 || wpa_s->disconnected)
57 return;
58
59 + if (wpa_s->wpa_state > WPA_ASSOCIATED)
60 + goto done;
61 +
62 while (selected == NULL) {
63 for (prio = 0; prio < wpa_s->conf->num_prio; prio++) {
64 selected = wpa_supplicant_select_bss(
65 @@ -613,6 +616,7 @@
66 wpa_printf(MSG_DEBUG, "No APs found - clear blacklist "
67 "and try again");
68 wpa_blacklist_clear(wpa_s);
69 + memset(&wpa_s->last_scan_results, 0, sizeof(wpa_s->last_scan_results));
70 } else if (selected == NULL) {
71 break;
72 }
73 @@ -640,10 +644,12 @@
74 rsn_preauth_scan_results(wpa_s->wpa, wpa_s->scan_res);
75 } else {
76 wpa_printf(MSG_DEBUG, "No suitable AP found.");
77 - timeout = 5;
78 + timeout = 0;
79 goto req_scan;
80 }
81
82 +done:
83 + os_get_time(&wpa_s->last_scan_results);
84 return;
85
86 req_scan:
87 @@ -847,6 +853,9 @@
88 }
89 if (wpa_s->wpa_state >= WPA_ASSOCIATED)
90 wpa_supplicant_req_scan(wpa_s, 0, 100000);
91 + else if (wpa_s->wpa_state == WPA_ASSOCIATING)
92 + wpa_supplicant_req_auth_timeout(wpa_s, 0, 100000);
93 +
94 bssid = wpa_s->bssid;
95 if (os_memcmp(bssid, "\x00\x00\x00\x00\x00\x00", ETH_ALEN) == 0)
96 bssid = wpa_s->pending_bssid;
97 --- a/wpa_supplicant/wpa_supplicant_i.h
98 +++ b/wpa_supplicant/wpa_supplicant_i.h
99 @@ -334,6 +334,7 @@
100 struct wpa_client_mlme mlme;
101 int use_client_mlme;
102 int driver_4way_handshake;
103 + struct os_time last_scan_results;
104
105 int pending_mic_error_report;
106 int pending_mic_error_pairwise;
107 @@ -385,6 +387,7 @@
108
109 /* scan.c */
110 void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec);
111 +int wpa_supplicant_may_scan(struct wpa_supplicant *wpa_s);
112 void wpa_supplicant_cancel_scan(struct wpa_supplicant *wpa_s);
113
114 /* events.c */
115 --- a/wpa_supplicant/scan.c
116 +++ b/wpa_supplicant/scan.c
117 @@ -40,6 +40,18 @@
118 wpa_supplicant_event(wpa_s, EVENT_ASSOC, &data);
119 }
120
121 +int wpa_supplicant_may_scan(struct wpa_supplicant *wpa_s)
122 +{
123 + struct os_time time;
124 +
125 + if (wpa_s->conf->scan_cache > 0) {
126 + os_get_time(&time);
127 + time.sec -= wpa_s->conf->scan_cache;
128 + if (os_time_before(&time, &wpa_s->last_scan_results))
129 + return 0;
130 + }
131 + return 1;
132 +}
133
134 static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx)
135 {
136 @@ -150,8 +162,9 @@
137 } else
138 wpa_s->prev_scan_ssid = BROADCAST_SSID_SCAN;
139
140 - if (wpa_s->scan_res_tried == 0 && wpa_s->conf->ap_scan == 1 &&
141 - !wpa_s->use_client_mlme) {
142 + if (!wpa_supplicant_may_scan(wpa_s) ||
143 + (wpa_s->scan_res_tried == 0 && wpa_s->conf->ap_scan == 1 &&
144 + !wpa_s->use_client_mlme)) {
145 wpa_s->scan_res_tried++;
146 wpa_printf(MSG_DEBUG, "Trying to get current scan results "
147 "first without requesting a new scan to speed up "
148 --- a/wpa_supplicant/wpa_supplicant.c
149 +++ b/wpa_supplicant/wpa_supplicant.c
150 @@ -1441,6 +1441,9 @@
151 {
152 struct wpa_supplicant *wpa_s = ctx;
153
154 + if (wpa_s->wpa_state < WPA_ASSOCIATING)
155 + return;
156 +
157 wpa_printf(MSG_DEBUG, "RX EAPOL from " MACSTR, MAC2STR(src_addr));
158 wpa_hexdump(MSG_MSGDUMP, "RX EAPOL", buf, len);
159
This page took 0.051141 seconds and 5 git commands to generate.