aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/mwifiex/uap_cmd.c
diff options
context:
space:
mode:
authorAvinash Patil <patila@marvell.com>2012-06-15 15:21:54 -0400
committerJohn W. Linville <linville@tuxdriver.com>2012-06-20 15:14:23 -0400
commit5d66cb62954106d4abfb67bbb5a14cec57903cbb (patch)
tree1f8d0d7aad7f0fee844f8c0a78be1f8a17d86f2f /drivers/net/wireless/mwifiex/uap_cmd.c
parent2228125600b3031657b825502d1a1999e4c02566 (diff)
mwifiex: separate uAP WPA/WPA2 parsing from other BSS parameters
To enhance readability, create a separate function for parsing WPA/WPA2 related parameters from cfg80211_ap_settings. There is no functional change in this patch. Signed-off-by: Avinash Patil <patila@marvell.com> Signed-off-by: Bing Zhao <bzhao@marvell.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/mwifiex/uap_cmd.c')
-rw-r--r--drivers/net/wireless/mwifiex/uap_cmd.c147
1 files changed, 79 insertions, 68 deletions
diff --git a/drivers/net/wireless/mwifiex/uap_cmd.c b/drivers/net/wireless/mwifiex/uap_cmd.c
index 59e5ba4df02b..86a4432df7a8 100644
--- a/drivers/net/wireless/mwifiex/uap_cmd.c
+++ b/drivers/net/wireless/mwifiex/uap_cmd.c
@@ -162,6 +162,82 @@ void mwifiex_set_sys_config_invalid_data(struct mwifiex_uap_bss_param *config)
162} 162}
163 163
164/* This function parses BSS related parameters from structure 164/* This function parses BSS related parameters from structure
165 * and prepares TLVs specific to WPA/WPA2 security.
166 * These TLVs are appended to command buffer.
167 */
168static void
169mwifiex_uap_bss_wpa(u8 **tlv_buf, void *cmd_buf, u16 *param_size)
170{
171 struct host_cmd_tlv_pwk_cipher *pwk_cipher;
172 struct host_cmd_tlv_gwk_cipher *gwk_cipher;
173 struct host_cmd_tlv_passphrase *passphrase;
174 struct host_cmd_tlv_akmp *tlv_akmp;
175 struct mwifiex_uap_bss_param *bss_cfg = cmd_buf;
176 u16 cmd_size = *param_size;
177 u8 *tlv = *tlv_buf;
178
179 tlv_akmp = (struct host_cmd_tlv_akmp *)tlv;
180 tlv_akmp->tlv.type = cpu_to_le16(TLV_TYPE_UAP_AKMP);
181 tlv_akmp->tlv.len = cpu_to_le16(sizeof(struct host_cmd_tlv_akmp) -
182 sizeof(struct host_cmd_tlv));
183 tlv_akmp->key_mgmt_operation = cpu_to_le16(bss_cfg->key_mgmt_operation);
184 tlv_akmp->key_mgmt = cpu_to_le16(bss_cfg->key_mgmt);
185 cmd_size += sizeof(struct host_cmd_tlv_akmp);
186 tlv += sizeof(struct host_cmd_tlv_akmp);
187
188 if (bss_cfg->wpa_cfg.pairwise_cipher_wpa & VALID_CIPHER_BITMAP) {
189 pwk_cipher = (struct host_cmd_tlv_pwk_cipher *)tlv;
190 pwk_cipher->tlv.type = cpu_to_le16(TLV_TYPE_PWK_CIPHER);
191 pwk_cipher->tlv.len =
192 cpu_to_le16(sizeof(struct host_cmd_tlv_pwk_cipher) -
193 sizeof(struct host_cmd_tlv));
194 pwk_cipher->proto = cpu_to_le16(PROTOCOL_WPA);
195 pwk_cipher->cipher = bss_cfg->wpa_cfg.pairwise_cipher_wpa;
196 cmd_size += sizeof(struct host_cmd_tlv_pwk_cipher);
197 tlv += sizeof(struct host_cmd_tlv_pwk_cipher);
198 }
199
200 if (bss_cfg->wpa_cfg.pairwise_cipher_wpa2 & VALID_CIPHER_BITMAP) {
201 pwk_cipher = (struct host_cmd_tlv_pwk_cipher *)tlv;
202 pwk_cipher->tlv.type = cpu_to_le16(TLV_TYPE_PWK_CIPHER);
203 pwk_cipher->tlv.len =
204 cpu_to_le16(sizeof(struct host_cmd_tlv_pwk_cipher) -
205 sizeof(struct host_cmd_tlv));
206 pwk_cipher->proto = cpu_to_le16(PROTOCOL_WPA2);
207 pwk_cipher->cipher = bss_cfg->wpa_cfg.pairwise_cipher_wpa2;
208 cmd_size += sizeof(struct host_cmd_tlv_pwk_cipher);
209 tlv += sizeof(struct host_cmd_tlv_pwk_cipher);
210 }
211
212 if (bss_cfg->wpa_cfg.group_cipher & VALID_CIPHER_BITMAP) {
213 gwk_cipher = (struct host_cmd_tlv_gwk_cipher *)tlv;
214 gwk_cipher->tlv.type = cpu_to_le16(TLV_TYPE_GWK_CIPHER);
215 gwk_cipher->tlv.len =
216 cpu_to_le16(sizeof(struct host_cmd_tlv_gwk_cipher) -
217 sizeof(struct host_cmd_tlv));
218 gwk_cipher->cipher = bss_cfg->wpa_cfg.group_cipher;
219 cmd_size += sizeof(struct host_cmd_tlv_gwk_cipher);
220 tlv += sizeof(struct host_cmd_tlv_gwk_cipher);
221 }
222
223 if (bss_cfg->wpa_cfg.length) {
224 passphrase = (struct host_cmd_tlv_passphrase *)tlv;
225 passphrase->tlv.type = cpu_to_le16(TLV_TYPE_UAP_WPA_PASSPHRASE);
226 passphrase->tlv.len = cpu_to_le16(bss_cfg->wpa_cfg.length);
227 memcpy(passphrase->passphrase, bss_cfg->wpa_cfg.passphrase,
228 bss_cfg->wpa_cfg.length);
229 cmd_size += sizeof(struct host_cmd_tlv) +
230 bss_cfg->wpa_cfg.length;
231 tlv += sizeof(struct host_cmd_tlv) + bss_cfg->wpa_cfg.length;
232 }
233
234 *param_size = cmd_size;
235 *tlv_buf = tlv;
236
237 return;
238}
239
240/* This function parses BSS related parameters from structure
165 * and prepares TLVs. These TLVs are appended to command buffer. 241 * and prepares TLVs. These TLVs are appended to command buffer.
166*/ 242*/
167static int 243static int
@@ -175,12 +251,8 @@ mwifiex_uap_bss_param_prepare(u8 *tlv, void *cmd_buf, u16 *param_size)
175 struct host_cmd_tlv_frag_threshold *frag_threshold; 251 struct host_cmd_tlv_frag_threshold *frag_threshold;
176 struct host_cmd_tlv_rts_threshold *rts_threshold; 252 struct host_cmd_tlv_rts_threshold *rts_threshold;
177 struct host_cmd_tlv_retry_limit *retry_limit; 253 struct host_cmd_tlv_retry_limit *retry_limit;
178 struct host_cmd_tlv_pwk_cipher *pwk_cipher;
179 struct host_cmd_tlv_gwk_cipher *gwk_cipher;
180 struct host_cmd_tlv_encrypt_protocol *encrypt_protocol; 254 struct host_cmd_tlv_encrypt_protocol *encrypt_protocol;
181 struct host_cmd_tlv_auth_type *auth_type; 255 struct host_cmd_tlv_auth_type *auth_type;
182 struct host_cmd_tlv_passphrase *passphrase;
183 struct host_cmd_tlv_akmp *tlv_akmp;
184 struct mwifiex_ie_types_htcap *htcap; 256 struct mwifiex_ie_types_htcap *htcap;
185 struct mwifiex_uap_bss_param *bss_cfg = cmd_buf; 257 struct mwifiex_uap_bss_param *bss_cfg = cmd_buf;
186 u16 cmd_size = *param_size; 258 u16 cmd_size = *param_size;
@@ -271,70 +343,9 @@ mwifiex_uap_bss_param_prepare(u8 *tlv, void *cmd_buf, u16 *param_size)
271 } 343 }
272 if ((bss_cfg->protocol & PROTOCOL_WPA) || 344 if ((bss_cfg->protocol & PROTOCOL_WPA) ||
273 (bss_cfg->protocol & PROTOCOL_WPA2) || 345 (bss_cfg->protocol & PROTOCOL_WPA2) ||
274 (bss_cfg->protocol & PROTOCOL_EAP)) { 346 (bss_cfg->protocol & PROTOCOL_EAP))
275 tlv_akmp = (struct host_cmd_tlv_akmp *)tlv; 347 mwifiex_uap_bss_wpa(&tlv, cmd_buf, &cmd_size);
276 tlv_akmp->tlv.type = cpu_to_le16(TLV_TYPE_UAP_AKMP); 348
277 tlv_akmp->tlv.len =
278 cpu_to_le16(sizeof(struct host_cmd_tlv_akmp) -
279 sizeof(struct host_cmd_tlv));
280 tlv_akmp->key_mgmt_operation =
281 cpu_to_le16(bss_cfg->key_mgmt_operation);
282 tlv_akmp->key_mgmt = cpu_to_le16(bss_cfg->key_mgmt);
283 cmd_size += sizeof(struct host_cmd_tlv_akmp);
284 tlv += sizeof(struct host_cmd_tlv_akmp);
285
286 if (bss_cfg->wpa_cfg.pairwise_cipher_wpa &
287 VALID_CIPHER_BITMAP) {
288 pwk_cipher = (struct host_cmd_tlv_pwk_cipher *)tlv;
289 pwk_cipher->tlv.type =
290 cpu_to_le16(TLV_TYPE_PWK_CIPHER);
291 pwk_cipher->tlv.len = cpu_to_le16(
292 sizeof(struct host_cmd_tlv_pwk_cipher) -
293 sizeof(struct host_cmd_tlv));
294 pwk_cipher->proto = cpu_to_le16(PROTOCOL_WPA);
295 pwk_cipher->cipher =
296 bss_cfg->wpa_cfg.pairwise_cipher_wpa;
297 cmd_size += sizeof(struct host_cmd_tlv_pwk_cipher);
298 tlv += sizeof(struct host_cmd_tlv_pwk_cipher);
299 }
300 if (bss_cfg->wpa_cfg.pairwise_cipher_wpa2 &
301 VALID_CIPHER_BITMAP) {
302 pwk_cipher = (struct host_cmd_tlv_pwk_cipher *)tlv;
303 pwk_cipher->tlv.type = cpu_to_le16(TLV_TYPE_PWK_CIPHER);
304 pwk_cipher->tlv.len = cpu_to_le16(
305 sizeof(struct host_cmd_tlv_pwk_cipher) -
306 sizeof(struct host_cmd_tlv));
307 pwk_cipher->proto = cpu_to_le16(PROTOCOL_WPA2);
308 pwk_cipher->cipher =
309 bss_cfg->wpa_cfg.pairwise_cipher_wpa2;
310 cmd_size += sizeof(struct host_cmd_tlv_pwk_cipher);
311 tlv += sizeof(struct host_cmd_tlv_pwk_cipher);
312 }
313 if (bss_cfg->wpa_cfg.group_cipher & VALID_CIPHER_BITMAP) {
314 gwk_cipher = (struct host_cmd_tlv_gwk_cipher *)tlv;
315 gwk_cipher->tlv.type = cpu_to_le16(TLV_TYPE_GWK_CIPHER);
316 gwk_cipher->tlv.len = cpu_to_le16(
317 sizeof(struct host_cmd_tlv_gwk_cipher) -
318 sizeof(struct host_cmd_tlv));
319 gwk_cipher->cipher = bss_cfg->wpa_cfg.group_cipher;
320 cmd_size += sizeof(struct host_cmd_tlv_gwk_cipher);
321 tlv += sizeof(struct host_cmd_tlv_gwk_cipher);
322 }
323 if (bss_cfg->wpa_cfg.length) {
324 passphrase = (struct host_cmd_tlv_passphrase *)tlv;
325 passphrase->tlv.type =
326 cpu_to_le16(TLV_TYPE_UAP_WPA_PASSPHRASE);
327 passphrase->tlv.len =
328 cpu_to_le16(bss_cfg->wpa_cfg.length);
329 memcpy(passphrase->passphrase,
330 bss_cfg->wpa_cfg.passphrase,
331 bss_cfg->wpa_cfg.length);
332 cmd_size += sizeof(struct host_cmd_tlv) +
333 bss_cfg->wpa_cfg.length;
334 tlv += sizeof(struct host_cmd_tlv) +
335 bss_cfg->wpa_cfg.length;
336 }
337 }
338 if ((bss_cfg->auth_mode <= WLAN_AUTH_SHARED_KEY) || 349 if ((bss_cfg->auth_mode <= WLAN_AUTH_SHARED_KEY) ||
339 (bss_cfg->auth_mode == MWIFIEX_AUTH_MODE_AUTO)) { 350 (bss_cfg->auth_mode == MWIFIEX_AUTH_MODE_AUTO)) {
340 auth_type = (struct host_cmd_tlv_auth_type *)tlv; 351 auth_type = (struct host_cmd_tlv_auth_type *)tlv;