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 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
21 #define WPA_SUPPLICANT_DRIVER_VERSION 4
23 +#include "drivers/nl80211_copy.h"
24 #include "common/defs.h"
26 #define HOSTAPD_CHAN_DISABLED 0x00000001
27 @@ -332,6 +333,11 @@ struct wpa_driver_associate_params {
31 + int beacon_interval;
33 + unsigned char rates[NL80211_MAX_SUPP_RATES];
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
44 #include "rsn_supp/wpa.h"
45 #include "eap_peer/eap.h"
47 +#include "drivers/nl80211_copy.h"
51 @@ -1431,6 +1432,97 @@ static char * wpa_config_write_p2p_client_list(const struct parse_data *data,
53 #endif /* CONFIG_P2P */
55 +static int wpa_config_parse_mcast_rate(const struct parse_data *data,
56 + struct wpa_ssid *ssid, int line,
59 + ssid->mcast_rate = (int)(strtod(value, NULL) * 10);
64 +#ifndef NO_CONFIG_WRITE
65 +static char * wpa_config_write_mcast_rate(const struct parse_data *data,
66 + struct wpa_ssid *ssid)
71 + if (!ssid->mcast_rate == 0)
74 + value = os_malloc(6); /* longest: 300.0 */
77 + res = os_snprintf(value, 5, "%.1f", (double)ssid->mcast_rate / 10);
84 +#endif /* NO_CONFIG_WRITE */
86 +static int wpa_config_parse_rates(const struct parse_data *data,
87 + struct wpa_ssid *ssid, int line,
91 + char *pos, *r, *sptr, *end;
94 + pos = (char *)value;
95 + r = strtok_r(pos, ",", &sptr);
97 + while (pos && i < NL80211_MAX_SUPP_RATES) {
100 + rate = strtod(r, &end);
101 + ssid->rates[i] = rate * 2;
102 + if (*end != '\0' || rate * 2 != ssid->rates[i])
106 + r = strtok_r(NULL, ",", &sptr);
112 +#ifndef NO_CONFIG_WRITE
113 +static char * wpa_config_write_rates(const struct parse_data *data,
114 + struct wpa_ssid *ssid)
119 + if (ssid->rates[0] <= 0)
122 + value = os_malloc(6 * NL80211_MAX_SUPP_RATES + 1);
126 + for (i = 0; i < NL80211_MAX_SUPP_RATES - 1; i++) {
127 + res = os_snprintf(pos, 6, "%.1f,", (double)ssid->rates[i] / 2);
134 + res = os_snprintf(pos, 6, "%.1f",
135 + (double)ssid->rates[NL80211_MAX_SUPP_RATES - 1] / 2);
141 + value[6 * NL80211_MAX_SUPP_RATES] = '\0';
144 +#endif /* NO_CONFIG_WRITE */
146 /* Helper macros for network block parser */
149 @@ -1605,6 +1697,10 @@ static const struct parse_data ssid_fields[] = {
151 #endif /* CONFIG_HT_OVERRIDES */
152 { INT(ap_max_inactivity) },
153 + { INT_RANGE(fixed_freq, 0, 1) },
154 + { INT_RANGE(beacon_interval, 0, 1000) },
156 + { FUNC(mcast_rate) },
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
166 #include "common/defs.h"
167 #include "eap_peer/eap_config.h"
168 +#include "drivers/nl80211_copy.h"
170 #define MAX_SSID_LEN 32
172 @@ -499,6 +500,11 @@ struct wpa_ssid {
173 * By default: 300 seconds.
175 int ap_max_inactivity;
178 + int beacon_interval;
179 + unsigned char rates[NL80211_MAX_SUPP_RATES];
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;
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;
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;
207 + while (i < NL80211_MAX_SUPP_RATES) {
208 + params.rates[i] = ssid->rates[i];
211 + params.mcast_rate = ssid->mcast_rate;
214 - if (ssid->mode == WPAS_MODE_IBSS && ssid->frequency > 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;