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