hostapd: fix ap+sta issues
[openwrt/svn-archive/archive.git] / package / hostapd / patches / 604-wpa_s-support-htmode-param.patch
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
5
6 possible values are HT20, HT40-, HT40+ and NOHT
7
8 Signed-off-by: Antonio Quartulli <ordex@autistici.org>
9 ---
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(+)
16
17 --- a/src/drivers/driver.h
18 +++ b/src/drivers/driver.h
19 @@ -337,6 +337,8 @@ struct wpa_driver_associate_params {
20 int fixed_freq;
21 unsigned char rates[NL80211_MAX_SUPP_RATES];
22 int mcast_rate;
23 + int ht_set;
24 + unsigned int htmode;
25
26 /**
27 * bg_scan_period - Background scan period in seconds, 0 to disable
28 --- a/src/drivers/driver_nl80211.c
29 +++ b/src/drivers/driver_nl80211.c
30 @@ -6545,6 +6545,22 @@ retry:
31 NLA_PUT_U32(msg, NL80211_ATTR_MCAST_RATE, params->mcast_rate);
32 }
33
34 + if (params->ht_set) {
35 + switch(params->htmode) {
36 + case NL80211_CHAN_HT20:
37 + wpa_printf(MSG_DEBUG, " * ht=HT20");
38 + break;
39 + case NL80211_CHAN_HT40PLUS:
40 + wpa_printf(MSG_DEBUG, " * ht=HT40+");
41 + break;
42 + case NL80211_CHAN_HT40MINUS:
43 + wpa_printf(MSG_DEBUG, " * ht=HT40-");
44 + break;
45 + }
46 + NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE,
47 + params->htmode);
48 + }
49 +
50 ret = nl80211_set_conn_keys(params, msg);
51 if (ret)
52 goto nla_put_failure;
53 --- a/wpa_supplicant/config.c
54 +++ b/wpa_supplicant/config.c
55 @@ -1463,6 +1463,71 @@ static char * wpa_config_write_mcast_rat
56 }
57 #endif /* NO_CONFIG_WRITE */
58
59 +static int wpa_config_parse_htmode(const struct parse_data *data,
60 + struct wpa_ssid *ssid, int line,
61 + const char *value)
62 +{
63 + int i;
64 + static const struct {
65 + const char *name;
66 + unsigned int val;
67 + } htmap[] = {
68 + { .name = "HT20", .val = NL80211_CHAN_HT20, },
69 + { .name = "HT40+", .val = NL80211_CHAN_HT40PLUS, },
70 + { .name = "HT40-", .val = NL80211_CHAN_HT40MINUS, },
71 + { .name = "NOHT", .val = NL80211_CHAN_NO_HT, },
72 + };
73 + ssid->ht_set = 0;;
74 + for (i = 0; i < 4; i++) {
75 + if (strcasecmp(htmap[i].name, value) == 0) {
76 + ssid->htmode = htmap[i].val;
77 + ssid->ht_set = 1;
78 + break;
79 + }
80 + }
81 +
82 + return 0;
83 +}
84 +
85 +#ifndef NO_CONFIG_WRITE
86 +static char * wpa_config_write_htmode(const struct parse_data *data,
87 + struct wpa_ssid *ssid)
88 +{
89 + char *value;
90 + int res;
91 +
92 + value = os_malloc(6); /* longest: HT40+ */
93 + if (value == NULL)
94 + return NULL;
95 +
96 + switch(ssid->htmode) {
97 + case NL80211_CHAN_HT20:
98 + res = os_snprintf(value, 4, "HT20");
99 + break;
100 + case NL80211_CHAN_HT40PLUS:
101 + res = os_snprintf(value, 5, "HT40+");
102 + break;
103 + case NL80211_CHAN_HT40MINUS:
104 + res = os_snprintf(value, 5, "HT40-");
105 + break;
106 + case NL80211_CHAN_NO_HT:
107 + res = os_snprintf(value, 4, "NOHT");
108 + break;
109 + default:
110 + os_free(value);
111 + return NULL;
112 + }
113 +
114 + if (res < 0) {
115 + os_free(value);
116 + return NULL;
117 + }
118 +
119 + return value;
120 +}
121 +#endif /* NO_CONFIG_WRITE */
122 +
123 +
124 static int wpa_config_parse_rates(const struct parse_data *data,
125 struct wpa_ssid *ssid, int line,
126 const char *value)
127 @@ -1701,6 +1766,7 @@ static const struct parse_data ssid_fiel
128 { INT_RANGE(beacon_interval, 0, 1000) },
129 { FUNC(rates) },
130 { FUNC(mcast_rate) },
131 + { FUNC(htmode) },
132 };
133
134 #undef OFFSET
135 --- a/wpa_supplicant/config_ssid.h
136 +++ b/wpa_supplicant/config_ssid.h
137 @@ -505,6 +505,8 @@ struct wpa_ssid {
138 int beacon_interval;
139 unsigned char rates[NL80211_MAX_SUPP_RATES];
140 double mcast_rate;
141 + int ht_set;
142 + unsigned int htmode;
143 };
144
145 #endif /* CONFIG_SSID_H */
146 --- a/wpa_supplicant/wpa_supplicant.c
147 +++ b/wpa_supplicant/wpa_supplicant.c
148 @@ -1411,6 +1411,8 @@ void wpa_supplicant_associate(struct wpa
149 i++;
150 }
151 params.mcast_rate = ssid->mcast_rate;
152 + params.ht_set = ssid->ht_set;
153 + params.htmode = ssid->htmode;
154 }
155
156 params.wpa_ie = wpa_ie;