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
7 Signed-hostap: Antonio Quartulli <ordex@autistici.org>
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(-)
15 --- a/src/drivers/driver.h
16 +++ b/src/drivers/driver.h
19 #define WPA_SUPPLICANT_DRIVER_VERSION 4
21 +#include "drivers/nl80211_copy.h"
22 #include "common/defs.h"
23 #include "utils/list.h"
25 @@ -414,6 +415,11 @@ struct wpa_driver_associate_params {
26 * responsible for selecting with which BSS to associate. */
29 + int beacon_interval;
31 + unsigned char rates[NL80211_MAX_SUPP_RATES];
35 * bssid_hint - BSSID of a proposed AP
37 --- a/wpa_supplicant/config.c
38 +++ b/wpa_supplicant/config.c
40 #include "rsn_supp/wpa.h"
41 #include "eap_peer/eap.h"
43 +#include "drivers/nl80211_copy.h"
47 @@ -1527,6 +1528,97 @@ static char * wpa_config_write_psk_list(
49 #endif /* CONFIG_P2P */
51 +static int wpa_config_parse_mcast_rate(const struct parse_data *data,
52 + struct wpa_ssid *ssid, int line,
55 + ssid->mcast_rate = (int)(strtod(value, NULL) * 10);
60 +#ifndef NO_CONFIG_WRITE
61 +static char * wpa_config_write_mcast_rate(const struct parse_data *data,
62 + struct wpa_ssid *ssid)
67 + if (!ssid->mcast_rate == 0)
70 + value = os_malloc(6); /* longest: 300.0 */
73 + res = os_snprintf(value, 5, "%.1f", (double)ssid->mcast_rate / 10);
80 +#endif /* NO_CONFIG_WRITE */
82 +static int wpa_config_parse_rates(const struct parse_data *data,
83 + struct wpa_ssid *ssid, int line,
87 + char *pos, *r, *sptr, *end;
90 + pos = (char *)value;
91 + r = strtok_r(pos, ",", &sptr);
93 + while (pos && i < NL80211_MAX_SUPP_RATES) {
96 + rate = strtod(r, &end);
97 + ssid->rates[i] = rate * 2;
98 + if (*end != '\0' || rate * 2 != ssid->rates[i])
102 + r = strtok_r(NULL, ",", &sptr);
108 +#ifndef NO_CONFIG_WRITE
109 +static char * wpa_config_write_rates(const struct parse_data *data,
110 + struct wpa_ssid *ssid)
115 + if (ssid->rates[0] <= 0)
118 + value = os_malloc(6 * NL80211_MAX_SUPP_RATES + 1);
122 + for (i = 0; i < NL80211_MAX_SUPP_RATES - 1; i++) {
123 + res = os_snprintf(pos, 6, "%.1f,", (double)ssid->rates[i] / 2);
130 + res = os_snprintf(pos, 6, "%.1f",
131 + (double)ssid->rates[NL80211_MAX_SUPP_RATES - 1] / 2);
137 + value[6 * NL80211_MAX_SUPP_RATES] = '\0';
140 +#endif /* NO_CONFIG_WRITE */
142 /* Helper macros for network block parser */
145 @@ -1733,6 +1825,9 @@ static const struct parse_data ssid_fiel
146 { INT(ap_max_inactivity) },
147 { INT(dtim_period) },
149 + { INT_RANGE(fixed_freq, 0, 1) },
151 + { FUNC(mcast_rate) },
153 { INT_RANGE(macsec_policy, 0, 1) },
154 #endif /* CONFIG_MACSEC */
155 --- a/wpa_supplicant/config_ssid.h
156 +++ b/wpa_supplicant/config_ssid.h
158 #include "common/defs.h"
159 #include "utils/list.h"
160 #include "eap_peer/eap_config.h"
161 +#include "drivers/nl80211_copy.h"
163 #define MAX_SSID_LEN 32
165 @@ -637,6 +638,10 @@ struct wpa_ssid {
170 + unsigned char rates[NL80211_MAX_SUPP_RATES];
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 @@ -1805,6 +1805,13 @@ static void wpas_start_assoc_cb(struct w
179 params.beacon_int = ssid->beacon_int;
181 params.beacon_int = wpa_s->conf->beacon_int;
182 + params.fixed_freq = ssid->fixed_freq;
184 + while (i < NL80211_MAX_SUPP_RATES) {
185 + params.rates[i] = ssid->rates[i];
188 + params.mcast_rate = ssid->mcast_rate;
191 params.wpa_ie = wpa_ie;