hostapd: add pending patches
[openwrt/openwrt.git] / package / hostapd / patches / 601-wpa_supplicant-add-new-config-params-to-be-used-with.patch
1 From 4bb69d15477e0f2b00e166845341dc933de47c58 Mon Sep 17 00:00:00 2001
2 From: Antonio Quartulli <ordex@autistici.org>
3 Date: Sun, 3 Jun 2012 18:22:56 +0200
4 Subject: [PATCHv2 601/602] wpa_supplicant: add new config params to be used
5 with the ibss join command
6
7 Signed-hostap: Antonio Quartulli <ordex@autistici.org>
8 ---
9 src/drivers/driver.h | 6 +++
10 wpa_supplicant/config.c | 96 +++++++++++++++++++++++++++++++++++++++
11 wpa_supplicant/config_ssid.h | 6 +++
12 wpa_supplicant/wpa_supplicant.c | 23 +++++++---
13 4 files changed, 124 insertions(+), 7 deletions(-)
14
15 diff --git a/src/drivers/driver.h b/src/drivers/driver.h
16 index 5ee92f7..d204148 100644
17 --- a/src/drivers/driver.h
18 +++ b/src/drivers/driver.h
19 @@ -19,6 +19,7 @@
20
21 #define WPA_SUPPLICANT_DRIVER_VERSION 4
22
23 +#include "drivers/nl80211_copy.h"
24 #include "common/defs.h"
25
26 #define HOSTAPD_CHAN_DISABLED 0x00000001
27 @@ -332,6 +333,11 @@ struct wpa_driver_associate_params {
28 */
29 int freq;
30
31 + int beacon_interval;
32 + int fixed_freq;
33 + unsigned char rates[NL80211_MAX_SUPP_RATES];
34 + int mcast_rate;
35 +
36 /**
37 * bg_scan_period - Background scan period in seconds, 0 to disable
38 * background scan, or -1 to indicate no change to default driver
39 diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c
40 index c423bc3..be566ee 100644
41 --- a/wpa_supplicant/config.c
42 +++ b/wpa_supplicant/config.c
43 @@ -14,6 +14,7 @@
44 #include "rsn_supp/wpa.h"
45 #include "eap_peer/eap.h"
46 #include "p2p/p2p.h"
47 +#include "drivers/nl80211_copy.h"
48 #include "config.h"
49
50
51 @@ -1431,6 +1432,97 @@ static char * wpa_config_write_p2p_client_list(const struct parse_data *data,
52
53 #endif /* CONFIG_P2P */
54
55 +static int wpa_config_parse_mcast_rate(const struct parse_data *data,
56 + struct wpa_ssid *ssid, int line,
57 + const char *value)
58 +{
59 + ssid->mcast_rate = (int)(strtod(value, NULL) * 10);
60 +
61 + return 0;
62 +}
63 +
64 +#ifndef NO_CONFIG_WRITE
65 +static char * wpa_config_write_mcast_rate(const struct parse_data *data,
66 + struct wpa_ssid *ssid)
67 +{
68 + char *value;
69 + int res;
70 +
71 + if (!ssid->mcast_rate == 0)
72 + return NULL;
73 +
74 + value = os_malloc(6); /* longest: 300.0 */
75 + if (value == NULL)
76 + return NULL;
77 + res = os_snprintf(value, 5, "%.1f", (double)ssid->mcast_rate / 10);
78 + if (res < 0) {
79 + os_free(value);
80 + return NULL;
81 + }
82 + return value;
83 +}
84 +#endif /* NO_CONFIG_WRITE */
85 +
86 +static int wpa_config_parse_rates(const struct parse_data *data,
87 + struct wpa_ssid *ssid, int line,
88 + const char *value)
89 +{
90 + int i;
91 + char *pos, *r, *sptr, *end;
92 + double rate;
93 +
94 + pos = (char *)value;
95 + r = strtok_r(pos, ",", &sptr);
96 + i = 0;
97 + while (pos && i < NL80211_MAX_SUPP_RATES) {
98 + rate = 0.0;
99 + if (r)
100 + rate = strtod(r, &end);
101 + ssid->rates[i] = rate * 2;
102 + if (*end != '\0' || rate * 2 != ssid->rates[i])
103 + return 1;
104 +
105 + i++;
106 + r = strtok_r(NULL, ",", &sptr);
107 + }
108 +
109 + return 0;
110 +}
111 +
112 +#ifndef NO_CONFIG_WRITE
113 +static char * wpa_config_write_rates(const struct parse_data *data,
114 + struct wpa_ssid *ssid)
115 +{
116 + char *value, *pos;
117 + int res, i;
118 +
119 + if (ssid->rates[0] <= 0)
120 + return NULL;
121 +
122 + value = os_malloc(6 * NL80211_MAX_SUPP_RATES + 1);
123 + if (value == NULL)
124 + return NULL;
125 + pos = value;
126 + for (i = 0; i < NL80211_MAX_SUPP_RATES - 1; i++) {
127 + res = os_snprintf(pos, 6, "%.1f,", (double)ssid->rates[i] / 2);
128 + if (res < 0) {
129 + os_free(value);
130 + return NULL;
131 + }
132 + pos += res;
133 + }
134 + res = os_snprintf(pos, 6, "%.1f",
135 + (double)ssid->rates[NL80211_MAX_SUPP_RATES - 1] / 2);
136 + if (res < 0) {
137 + os_free(value);
138 + return NULL;
139 + }
140 +
141 + value[6 * NL80211_MAX_SUPP_RATES] = '\0';
142 + return value;
143 +}
144 +#endif /* NO_CONFIG_WRITE */
145 +
146 /* Helper macros for network block parser */
147
148 #ifdef OFFSET
149 @@ -1605,6 +1697,10 @@ static const struct parse_data ssid_fields[] = {
150 { STR(ht_mcs) },
151 #endif /* CONFIG_HT_OVERRIDES */
152 { INT(ap_max_inactivity) },
153 + { INT_RANGE(fixed_freq, 0, 1) },
154 + { INT_RANGE(beacon_interval, 0, 1000) },
155 + { FUNC(rates) },
156 + { FUNC(mcast_rate) },
157 };
158
159 #undef OFFSET
160 diff --git a/wpa_supplicant/config_ssid.h b/wpa_supplicant/config_ssid.h
161 index 80d4382..8d152a4 100644
162 --- a/wpa_supplicant/config_ssid.h
163 +++ b/wpa_supplicant/config_ssid.h
164 @@ -11,6 +11,7 @@
165
166 #include "common/defs.h"
167 #include "eap_peer/eap_config.h"
168 +#include "drivers/nl80211_copy.h"
169
170 #define MAX_SSID_LEN 32
171
172 @@ -499,6 +500,11 @@ struct wpa_ssid {
173 * By default: 300 seconds.
174 */
175 int ap_max_inactivity;
176 +
177 + int fixed_freq;
178 + int beacon_interval;
179 + unsigned char rates[NL80211_MAX_SUPP_RATES];
180 + double mcast_rate;
181 };
182
183 #endif /* CONFIG_SSID_H */
184 diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
185 index cc85f1e..1473d91 100644
186 --- a/wpa_supplicant/wpa_supplicant.c
187 +++ b/wpa_supplicant/wpa_supplicant.c
188 @@ -1395,15 +1395,24 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
189 params.ssid_len = ssid->ssid_len;
190 }
191
192 - if (ssid->mode == WPAS_MODE_IBSS && ssid->bssid_set &&
193 - wpa_s->conf->ap_scan == 2) {
194 - params.bssid = ssid->bssid;
195 - params.fixed_bssid = 1;
196 + if (ssid->mode == WPAS_MODE_IBSS) {
197 + if (ssid->bssid_set && wpa_s->conf->ap_scan == 2) {
198 + params.bssid = ssid->bssid;
199 + params.fixed_bssid = 1;
200 + }
201 + if (ssid->frequency > 0 && params.freq == 0)
202 + /* Initial channel for IBSS */
203 + params.freq = ssid->frequency;
204 + params.fixed_freq = ssid->fixed_freq;
205 + params.beacon_interval = ssid->beacon_interval;
206 + i = 0;
207 + while (i < NL80211_MAX_SUPP_RATES) {
208 + params.rates[i] = ssid->rates[i];
209 + i++;
210 + }
211 + params.mcast_rate = ssid->mcast_rate;
212 }
213
214 - if (ssid->mode == WPAS_MODE_IBSS && ssid->frequency > 0 &&
215 - params.freq == 0)
216 - params.freq = ssid->frequency; /* Initial channel for IBSS */
217 params.wpa_ie = wpa_ie;
218 params.wpa_ie_len = wpa_ie_len;
219 params.pairwise_suite = cipher_pairwise;
220 --
221 1.7.9.4
222