1 From b9329c5dfeed7d5c55d2117d8dfe326fc40c8fb1 Mon Sep 17 00:00:00 2001
2 From: Antonio Quartulli <ordex@autistici.org>
3 Date: Tue, 3 Jul 2012 00:36:24 +0200
4 Subject: [PATCH] wpa_s: support htmode param
6 possible values are HT20, HT40-, HT40+ and NOHT
8 Signed-off-by: Antonio Quartulli <ordex@autistici.org>
10 src/drivers/driver.h | 2 ++
11 src/drivers/driver_nl80211.c | 16 ++++++++++
12 wpa_supplicant/config.c | 66 +++++++++++++++++++++++++++++++++++++++
13 wpa_supplicant/config_ssid.h | 2 ++
14 wpa_supplicant/wpa_supplicant.c | 2 ++
15 5 files changed, 88 insertions(+)
17 diff --git a/src/drivers/driver.h b/src/drivers/driver.h
18 index dda2fbc..28bd181 100644
19 --- a/src/drivers/driver.h
20 +++ b/src/drivers/driver.h
21 @@ -337,6 +337,8 @@ struct wpa_driver_associate_params {
23 unsigned char rates[NL80211_MAX_SUPP_RATES];
26 + unsigned int htmode;
29 * bg_scan_period - Background scan period in seconds, 0 to disable
30 diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
31 index 9783c96..d1257a7 100644
32 --- a/src/drivers/driver_nl80211.c
33 +++ b/src/drivers/driver_nl80211.c
34 @@ -6493,6 +6493,22 @@ retry:
35 NLA_PUT_U32(msg, NL80211_ATTR_MCAST_RATE, params->mcast_rate);
38 + if (params->ht_set) {
39 + switch(params->htmode) {
40 + case NL80211_CHAN_HT20:
41 + wpa_printf(MSG_DEBUG, " * ht=HT20");
43 + case NL80211_CHAN_HT40PLUS:
44 + wpa_printf(MSG_DEBUG, " * ht=HT40+");
46 + case NL80211_CHAN_HT40MINUS:
47 + wpa_printf(MSG_DEBUG, " * ht=HT40-");
50 + NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE,
54 ret = nl80211_set_conn_keys(params, msg);
57 diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c
58 index 3d6c0e6..d96b2ea 100644
59 --- a/wpa_supplicant/config.c
60 +++ b/wpa_supplicant/config.c
61 @@ -1468,6 +1468,71 @@ static char * wpa_config_write_mcast_rate(const struct parse_data *data,
63 #endif /* NO_CONFIG_WRITE */
65 +static int wpa_config_parse_htmode(const struct parse_data *data,
66 + struct wpa_ssid *ssid, int line,
70 + static const struct {
74 + { .name = "HT20", .val = NL80211_CHAN_HT20, },
75 + { .name = "HT40+", .val = NL80211_CHAN_HT40PLUS, },
76 + { .name = "HT40-", .val = NL80211_CHAN_HT40MINUS, },
77 + { .name = "NOHT", .val = NL80211_CHAN_NO_HT, },
80 + for (i = 0; i < 4; i++) {
81 + if (strcasecmp(htmap[i].name, value) == 0) {
82 + ssid->htmode = htmap[i].val;
91 +#ifndef NO_CONFIG_WRITE
92 +static char * wpa_config_write_htmode(const struct parse_data *data,
93 + struct wpa_ssid *ssid)
98 + value = os_malloc(6); /* longest: HT40+ */
102 + switch(ssid->htmode) {
103 + case NL80211_CHAN_HT20:
104 + res = os_snprintf(value, 4, "HT20");
106 + case NL80211_CHAN_HT40PLUS:
107 + res = os_snprintf(value, 5, "HT40+");
109 + case NL80211_CHAN_HT40MINUS:
110 + res = os_snprintf(value, 5, "HT40-");
112 + case NL80211_CHAN_NO_HT:
113 + res = os_snprintf(value, 4, "NOHT");
127 +#endif /* NO_CONFIG_WRITE */
130 static int wpa_config_parse_rates(const struct parse_data *data,
131 struct wpa_ssid *ssid, int line,
133 @@ -1706,6 +1771,7 @@ static const struct parse_data ssid_fields[] = {
134 { INT_RANGE(beacon_interval, 0, 1000) },
136 { FUNC(mcast_rate) },
141 diff --git a/wpa_supplicant/config_ssid.h b/wpa_supplicant/config_ssid.h
142 index 8d152a4..7143277 100644
143 --- a/wpa_supplicant/config_ssid.h
144 +++ b/wpa_supplicant/config_ssid.h
145 @@ -505,6 +505,8 @@ struct wpa_ssid {
147 unsigned char rates[NL80211_MAX_SUPP_RATES];
150 + unsigned int htmode;
153 #endif /* CONFIG_SSID_H */
154 diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
155 index 59efa16..fc8762f 100644
156 --- a/wpa_supplicant/wpa_supplicant.c
157 +++ b/wpa_supplicant/wpa_supplicant.c
158 @@ -1379,6 +1379,8 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
161 params.mcast_rate = ssid->mcast_rate;
162 + params.ht_set = ssid->ht_set;
163 + params.htmode = ssid->htmode;
166 params.wpa_ie = wpa_ie;