[package] base-files: clear ip addresses on interfaces that are about to be added...
[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 @@ struct wpa_config {
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 @@ -306,6 +306,13 @@ static int wpa_config_parse_int(const st
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_parse_str(const struct global_parse_data *data,
33 struct wpa_config *config, int line,
34 @@ -433,6 +440,7 @@ static const struct global_parse_data gl
35 #endif /* CONFIG_CTRL_IFACE */
36 { INT_RANGE(eapol_version, 1, 2) },
37 { INT(ap_scan) },
38 + { INT(scan_cache) },
39 { INT(fast_reauth) },
40 #ifdef EAP_TLS_OPENSSL
41 { STR(opensc_engine_path) },
42 @@ -835,6 +843,8 @@ static void wpa_config_write_global(FILE
43 fprintf(f, "eapol_version=%d\n", config->eapol_version);
44 if (config->ap_scan != DEFAULT_AP_SCAN)
45 fprintf(f, "ap_scan=%d\n", config->ap_scan);
46 + if (config->scan_cache != 0)
47 + fprintf(f, "scan_cache=%d\n", config->scan_cache);
48 if (config->fast_reauth != DEFAULT_FAST_REAUTH)
49 fprintf(f, "fast_reauth=%d\n", config->fast_reauth);
50 #ifdef EAP_TLS_OPENSSL
51 --- a/wpa_supplicant/events.c
52 +++ b/wpa_supplicant/events.c
53 @@ -541,7 +541,7 @@ wpa_supplicant_select_bss_non_wpa(struct
54 "BSSID mismatch");
55 continue;
56 }
57 -
58 +
59 if (!(ssid->key_mgmt & WPA_KEY_MGMT_NONE) &&
60 !(ssid->key_mgmt & WPA_KEY_MGMT_WPS) &&
61 !(ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X_NO_WPA))
62 @@ -551,7 +551,7 @@ wpa_supplicant_select_bss_non_wpa(struct
63 continue;
64 }
65
66 - if ((ssid->key_mgmt &
67 + if ((ssid->key_mgmt &
68 (WPA_KEY_MGMT_IEEE8021X | WPA_KEY_MGMT_PSK |
69 WPA_KEY_MGMT_FT_IEEE8021X | WPA_KEY_MGMT_FT_PSK |
70 WPA_KEY_MGMT_IEEE8021X_SHA256 |
71 @@ -640,6 +640,9 @@ static void wpa_supplicant_event_scan_re
72 wpa_s->disconnected)
73 return;
74
75 + if (wpa_s->wpa_state > WPA_ASSOCIATED)
76 + goto done;
77 +
78 while (selected == NULL) {
79 for (prio = 0; prio < wpa_s->conf->num_prio; prio++) {
80 selected = wpa_supplicant_select_bss(
81 @@ -652,6 +655,7 @@ static void wpa_supplicant_event_scan_re
82 wpa_printf(MSG_DEBUG, "No APs found - clear blacklist "
83 "and try again");
84 wpa_blacklist_clear(wpa_s);
85 + memset(&wpa_s->last_scan_results, 0, sizeof(wpa_s->last_scan_results));
86 wpa_s->blacklist_cleared++;
87 } else if (selected == NULL) {
88 break;
89 @@ -687,10 +691,12 @@ static void wpa_supplicant_event_scan_re
90 rsn_preauth_scan_results(wpa_s->wpa, wpa_s->scan_res);
91 } else {
92 wpa_printf(MSG_DEBUG, "No suitable AP found.");
93 - timeout = 5;
94 + timeout = 0;
95 goto req_scan;
96 }
97
98 +done:
99 + os_get_time(&wpa_s->last_scan_results);
100 return;
101
102 req_scan:
103 @@ -894,6 +900,9 @@ static void wpa_supplicant_event_disasso
104 }
105 if (wpa_s->wpa_state >= WPA_ASSOCIATED)
106 wpa_supplicant_req_scan(wpa_s, 0, 100000);
107 + else if (wpa_s->wpa_state == WPA_ASSOCIATING)
108 + wpa_supplicant_req_auth_timeout(wpa_s, 0, 100000);
109 +
110 bssid = wpa_s->bssid;
111 if (is_zero_ether_addr(bssid))
112 bssid = wpa_s->pending_bssid;
113 --- a/wpa_supplicant/wpa_supplicant_i.h
114 +++ b/wpa_supplicant/wpa_supplicant_i.h
115 @@ -350,6 +350,7 @@ struct wpa_supplicant {
116 struct wpa_client_mlme mlme;
117 int use_client_mlme;
118 int driver_4way_handshake;
119 + struct os_time last_scan_results;
120
121 int pending_mic_error_report;
122 int pending_mic_error_pairwise;
123 @@ -405,6 +406,7 @@ int wpa_supplicant_scard_init(struct wpa
124
125 /* scan.c */
126 void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec);
127 +int wpa_supplicant_may_scan(struct wpa_supplicant *wpa_s);
128 void wpa_supplicant_cancel_scan(struct wpa_supplicant *wpa_s);
129
130 /* events.c */
131 --- a/wpa_supplicant/scan.c
132 +++ b/wpa_supplicant/scan.c
133 @@ -40,6 +40,18 @@ static void wpa_supplicant_gen_assoc_eve
134 wpa_supplicant_event(wpa_s, EVENT_ASSOC, &data);
135 }
136
137 +int wpa_supplicant_may_scan(struct wpa_supplicant *wpa_s)
138 +{
139 + struct os_time time;
140 +
141 + if (wpa_s->conf->scan_cache > 0) {
142 + os_get_time(&time);
143 + time.sec -= wpa_s->conf->scan_cache;
144 + if (os_time_before(&time, &wpa_s->last_scan_results))
145 + return 0;
146 + }
147 + return 1;
148 +}
149
150 #ifdef CONFIG_WPS
151 static int wpas_wps_in_use(struct wpa_config *conf,
152 @@ -183,8 +195,9 @@ static void wpa_supplicant_scan(void *el
153 wps = wpas_wps_in_use(wpa_s->conf, &req_type);
154 #endif /* CONFIG_WPS */
155
156 - if (wpa_s->scan_res_tried == 0 && wpa_s->conf->ap_scan == 1 &&
157 - !wpa_s->use_client_mlme && wps != 2) {
158 + if (!wpa_supplicant_may_scan(wpa_s) ||
159 + (wpa_s->scan_res_tried == 0 && wpa_s->conf->ap_scan == 1 &&
160 + !wpa_s->use_client_mlme && wps != 2)) {
161 wpa_s->scan_res_tried++;
162 wpa_s->scan_req = scan_req;
163 wpa_printf(MSG_DEBUG, "Trying to get current scan results "
164 --- a/wpa_supplicant/wpa_supplicant.c
165 +++ b/wpa_supplicant/wpa_supplicant.c
166 @@ -1491,6 +1491,9 @@ void wpa_supplicant_rx_eapol(void *ctx,
167 {
168 struct wpa_supplicant *wpa_s = ctx;
169
170 + if (wpa_s->wpa_state < WPA_ASSOCIATING)
171 + return;
172 +
173 wpa_printf(MSG_DEBUG, "RX EAPOL from " MACSTR, MAC2STR(src_addr));
174 wpa_hexdump(MSG_MSGDUMP, "RX EAPOL", buf, len);
175
This page took 0.059584 seconds and 5 git commands to generate.