c6053f095338125fdad1a766ef2d2d9ee4ba04c2
[openwrt/staging/xback.git] /
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 --- a/src/drivers/driver.h
16 +++ b/src/drivers/driver.h
17 @@ -19,6 +19,7 @@
18
19 #define WPA_SUPPLICANT_DRIVER_VERSION 4
20
21 +#include "ap/sta_info.h"
22 #include "common/defs.h"
23 #include "common/ieee802_11_defs.h"
24 #include "utils/list.h"
25 @@ -587,6 +588,9 @@ struct wpa_driver_associate_params {
26 * responsible for selecting with which BSS to associate. */
27 const u8 *bssid;
28
29 + unsigned char rates[WLAN_SUPP_RATES_MAX];
30 + int mcast_rate;
31 +
32 /**
33 * bssid_hint - BSSID of a proposed AP
34 *
35 --- a/wpa_supplicant/config.c
36 +++ b/wpa_supplicant/config.c
37 @@ -16,6 +16,7 @@
38 #include "eap_peer/eap.h"
39 #include "p2p/p2p.h"
40 #include "fst/fst.h"
41 +#include "ap/sta_info.h"
42 #include "config.h"
43
44
45 @@ -1816,6 +1817,97 @@ static char * wpa_config_write_mesh_basi
46 #endif /* CONFIG_MESH */
47
48
49 +static int wpa_config_parse_mcast_rate(const struct parse_data *data,
50 + struct wpa_ssid *ssid, int line,
51 + const char *value)
52 +{
53 + ssid->mcast_rate = (int)(strtod(value, NULL) * 10);
54 +
55 + return 0;
56 +}
57 +
58 +#ifndef NO_CONFIG_WRITE
59 +static char * wpa_config_write_mcast_rate(const struct parse_data *data,
60 + struct wpa_ssid *ssid)
61 +{
62 + char *value;
63 + int res;
64 +
65 + if (!ssid->mcast_rate == 0)
66 + return NULL;
67 +
68 + value = os_malloc(6); /* longest: 300.0 */
69 + if (value == NULL)
70 + return NULL;
71 + res = os_snprintf(value, 5, "%.1f", (double)ssid->mcast_rate / 10);
72 + if (res < 0) {
73 + os_free(value);
74 + return NULL;
75 + }
76 + return value;
77 +}
78 +#endif /* NO_CONFIG_WRITE */
79 +
80 +static int wpa_config_parse_rates(const struct parse_data *data,
81 + struct wpa_ssid *ssid, int line,
82 + const char *value)
83 +{
84 + int i;
85 + char *pos, *r, *sptr, *end;
86 + double rate;
87 +
88 + pos = (char *)value;
89 + r = strtok_r(pos, ",", &sptr);
90 + i = 0;
91 + while (pos && i < WLAN_SUPP_RATES_MAX) {
92 + rate = 0.0;
93 + if (r)
94 + rate = strtod(r, &end);
95 + ssid->rates[i] = rate * 2;
96 + if (*end != '\0' || rate * 2 != ssid->rates[i])
97 + return 1;
98 +
99 + i++;
100 + r = strtok_r(NULL, ",", &sptr);
101 + }
102 +
103 + return 0;
104 +}
105 +
106 +#ifndef NO_CONFIG_WRITE
107 +static char * wpa_config_write_rates(const struct parse_data *data,
108 + struct wpa_ssid *ssid)
109 +{
110 + char *value, *pos;
111 + int res, i;
112 +
113 + if (ssid->rates[0] <= 0)
114 + return NULL;
115 +
116 + value = os_malloc(6 * WLAN_SUPP_RATES_MAX + 1);
117 + if (value == NULL)
118 + return NULL;
119 + pos = value;
120 + for (i = 0; i < WLAN_SUPP_RATES_MAX - 1; i++) {
121 + res = os_snprintf(pos, 6, "%.1f,", (double)ssid->rates[i] / 2);
122 + if (res < 0) {
123 + os_free(value);
124 + return NULL;
125 + }
126 + pos += res;
127 + }
128 + res = os_snprintf(pos, 6, "%.1f",
129 + (double)ssid->rates[WLAN_SUPP_RATES_MAX - 1] / 2);
130 + if (res < 0) {
131 + os_free(value);
132 + return NULL;
133 + }
134 +
135 + value[6 * WLAN_SUPP_RATES_MAX] = '\0';
136 + return value;
137 +}
138 +#endif /* NO_CONFIG_WRITE */
139 +
140 /* Helper macros for network block parser */
141
142 #ifdef OFFSET
143 @@ -2048,6 +2140,9 @@ static const struct parse_data ssid_fiel
144 { INT(ap_max_inactivity) },
145 { INT(dtim_period) },
146 { INT(beacon_int) },
147 + { INT_RANGE(fixed_freq, 0, 1) },
148 + { FUNC(rates) },
149 + { FUNC(mcast_rate) },
150 #ifdef CONFIG_MACSEC
151 { INT_RANGE(macsec_policy, 0, 1) },
152 #endif /* CONFIG_MACSEC */
153 --- a/wpa_supplicant/config_ssid.h
154 +++ b/wpa_supplicant/config_ssid.h
155 @@ -10,8 +10,10 @@
156 #define CONFIG_SSID_H
157
158 #include "common/defs.h"
159 +#include "ap/sta_info.h"
160 #include "utils/list.h"
161 #include "eap_peer/eap_config.h"
162 +#include "drivers/nl80211_copy.h"
163
164
165 #define DEFAULT_EAP_WORKAROUND ((unsigned int) -1)
166 @@ -719,6 +721,9 @@ struct wpa_ssid {
167 */
168 void *parent_cred;
169
170 + unsigned char rates[WLAN_SUPP_RATES_MAX];
171 + double mcast_rate;
172 +
173 #ifdef CONFIG_MACSEC
174 /**
175 * macsec_policy - Determines the policy for MACsec secure session
176 --- a/wpa_supplicant/wpa_supplicant.c
177 +++ b/wpa_supplicant/wpa_supplicant.c
178 @@ -2527,6 +2527,13 @@ static void wpas_start_assoc_cb(struct w
179 params.beacon_int = ssid->beacon_int;
180 else
181 params.beacon_int = wpa_s->conf->beacon_int;
182 + params.fixed_freq = ssid->fixed_freq;
183 + i = 0;
184 + while (i < WLAN_SUPP_RATES_MAX) {
185 + params.rates[i] = ssid->rates[i];
186 + i++;
187 + }
188 + params.mcast_rate = ssid->mcast_rate;
189 }
190
191 params.wpa_ie = wpa_ie;