aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/libertas/cmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/libertas/cmd.c')
-rw-r--r--drivers/net/wireless/libertas/cmd.c57
1 files changed, 20 insertions, 37 deletions
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c
index 3d9ad0ec9542..05e25cef5fe3 100644
--- a/drivers/net/wireless/libertas/cmd.c
+++ b/drivers/net/wireless/libertas/cmd.c
@@ -240,74 +240,61 @@ int lbs_cmd_802_11_sleep_params(struct lbs_private *priv, uint16_t cmd_action,
240 return 0; 240 return 0;
241} 241}
242 242
243static int lbs_cmd_802_11_set_wep(struct lbs_private *priv, 243int lbs_cmd_802_11_set_wep(struct lbs_private *priv, uint16_t cmd_action,
244 struct cmd_ds_command *cmd, 244 struct assoc_request *assoc)
245 u32 cmd_act,
246 void * pdata_buf)
247{ 245{
248 struct cmd_ds_802_11_set_wep *wep = &cmd->params.wep; 246 struct cmd_ds_802_11_set_wep cmd;
249 int ret = 0; 247 int ret = 0;
250 struct assoc_request * assoc_req = pdata_buf;
251 248
252 lbs_deb_enter(LBS_DEB_CMD); 249 lbs_deb_enter(LBS_DEB_CMD);
253 250
254 cmd->command = cpu_to_le16(CMD_802_11_SET_WEP); 251 cmd.hdr.command = cpu_to_le16(CMD_802_11_SET_WEP);
255 cmd->size = cpu_to_le16(sizeof(*wep) + S_DS_GEN); 252 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
256
257 if (cmd_act == CMD_ACT_ADD) {
258 int i;
259 253
260 if (!assoc_req) { 254 cmd.action = cpu_to_le16(cmd_action);
261 lbs_deb_cmd("Invalid association request!\n");
262 ret = -1;
263 goto done;
264 }
265 255
266 wep->action = cpu_to_le16(CMD_ACT_ADD); 256 if (cmd_action == CMD_ACT_ADD) {
257 int i;
267 258
268 /* default tx key index */ 259 /* default tx key index */
269 wep->keyindex = cpu_to_le16((u16)(assoc_req->wep_tx_keyidx & 260 cmd.keyindex = cpu_to_le16(assoc->wep_tx_keyidx &
270 (u32)CMD_WEP_KEY_INDEX_MASK)); 261 CMD_WEP_KEY_INDEX_MASK);
271 262
272 /* Copy key types and material to host command structure */ 263 /* Copy key types and material to host command structure */
273 for (i = 0; i < 4; i++) { 264 for (i = 0; i < 4; i++) {
274 struct enc_key * pkey = &assoc_req->wep_keys[i]; 265 struct enc_key *pkey = &assoc->wep_keys[i];
275 266
276 switch (pkey->len) { 267 switch (pkey->len) {
277 case KEY_LEN_WEP_40: 268 case KEY_LEN_WEP_40:
278 wep->keytype[i] = CMD_TYPE_WEP_40_BIT; 269 cmd.keytype[i] = CMD_TYPE_WEP_40_BIT;
279 memmove(&wep->keymaterial[i], pkey->key, 270 memmove(cmd.keymaterial[i], pkey->key, pkey->len);
280 pkey->len);
281 lbs_deb_cmd("SET_WEP: add key %d (40 bit)\n", i); 271 lbs_deb_cmd("SET_WEP: add key %d (40 bit)\n", i);
282 break; 272 break;
283 case KEY_LEN_WEP_104: 273 case KEY_LEN_WEP_104:
284 wep->keytype[i] = CMD_TYPE_WEP_104_BIT; 274 cmd.keytype[i] = CMD_TYPE_WEP_104_BIT;
285 memmove(&wep->keymaterial[i], pkey->key, 275 memmove(cmd.keymaterial[i], pkey->key, pkey->len);
286 pkey->len);
287 lbs_deb_cmd("SET_WEP: add key %d (104 bit)\n", i); 276 lbs_deb_cmd("SET_WEP: add key %d (104 bit)\n", i);
288 break; 277 break;
289 case 0: 278 case 0:
290 break; 279 break;
291 default: 280 default:
292 lbs_deb_cmd("SET_WEP: invalid key %d, length %d\n", 281 lbs_deb_cmd("SET_WEP: invalid key %d, length %d\n",
293 i, pkey->len); 282 i, pkey->len);
294 ret = -1; 283 ret = -1;
295 goto done; 284 goto done;
296 break; 285 break;
297 } 286 }
298 } 287 }
299 } else if (cmd_act == CMD_ACT_REMOVE) { 288 } else if (cmd_action == CMD_ACT_REMOVE) {
300 /* ACT_REMOVE clears _all_ WEP keys */ 289 /* ACT_REMOVE clears _all_ WEP keys */
301 wep->action = cpu_to_le16(CMD_ACT_REMOVE);
302 290
303 /* default tx key index */ 291 /* default tx key index */
304 wep->keyindex = cpu_to_le16((u16)(priv->wep_tx_keyidx & 292 cmd.keyindex = cpu_to_le16(priv->wep_tx_keyidx &
305 (u32)CMD_WEP_KEY_INDEX_MASK)); 293 CMD_WEP_KEY_INDEX_MASK);
306 lbs_deb_cmd("SET_WEP: remove key %d\n", priv->wep_tx_keyidx); 294 lbs_deb_cmd("SET_WEP: remove key %d\n", priv->wep_tx_keyidx);
307 } 295 }
308 296
309 ret = 0; 297 ret = lbs_cmd_with_response(priv, CMD_802_11_SET_WEP, &cmd);
310
311done: 298done:
312 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); 299 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
313 return ret; 300 return ret;
@@ -1422,10 +1409,6 @@ int lbs_prepare_and_send_command(struct lbs_private *priv,
1422 ret = lbs_cmd_80211_deauthenticate(priv, cmdptr); 1409 ret = lbs_cmd_80211_deauthenticate(priv, cmdptr);
1423 break; 1410 break;
1424 1411
1425 case CMD_802_11_SET_WEP:
1426 ret = lbs_cmd_802_11_set_wep(priv, cmdptr, cmd_action, pdata_buf);
1427 break;
1428
1429 case CMD_802_11_AD_HOC_START: 1412 case CMD_802_11_AD_HOC_START:
1430 ret = lbs_cmd_80211_ad_hoc_start(priv, cmdptr, pdata_buf); 1413 ret = lbs_cmd_80211_ad_hoc_start(priv, cmdptr, pdata_buf);
1431 break; 1414 break;