libertas: convert SET_WEP to a direct command

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
David Woodhouse 2007-12-18 00:18:05 -05:00 committed by David S. Miller
parent 3fbe104cec
commit f70dd4515a
5 changed files with 34 additions and 59 deletions

View file

@ -258,7 +258,7 @@ static int assoc_helper_channel(struct lbs_private *priv,
static int assoc_helper_wep_keys(struct lbs_private *priv, static int assoc_helper_wep_keys(struct lbs_private *priv,
struct assoc_request * assoc_req) struct assoc_request *assoc_req)
{ {
int i; int i;
int ret = 0; int ret = 0;
@ -266,22 +266,11 @@ static int assoc_helper_wep_keys(struct lbs_private *priv,
lbs_deb_enter(LBS_DEB_ASSOC); lbs_deb_enter(LBS_DEB_ASSOC);
/* Set or remove WEP keys */ /* Set or remove WEP keys */
if ( assoc_req->wep_keys[0].len if (assoc_req->wep_keys[0].len || assoc_req->wep_keys[1].len ||
|| assoc_req->wep_keys[1].len assoc_req->wep_keys[2].len || assoc_req->wep_keys[3].len)
|| assoc_req->wep_keys[2].len ret = lbs_cmd_802_11_set_wep(priv, CMD_ACT_ADD, assoc_req);
|| assoc_req->wep_keys[3].len) { else
ret = lbs_prepare_and_send_command(priv, ret = lbs_cmd_802_11_set_wep(priv, CMD_ACT_REMOVE, assoc_req);
CMD_802_11_SET_WEP,
CMD_ACT_ADD,
CMD_OPTION_WAITFORRSP,
0, assoc_req);
} else {
ret = lbs_prepare_and_send_command(priv,
CMD_802_11_SET_WEP,
CMD_ACT_REMOVE,
CMD_OPTION_WAITFORRSP,
0, NULL);
}
if (ret) if (ret)
goto out; goto out;
@ -291,6 +280,7 @@ static int assoc_helper_wep_keys(struct lbs_private *priv,
priv->currentpacketfilter |= CMD_ACT_MAC_WEP_ENABLE; priv->currentpacketfilter |= CMD_ACT_MAC_WEP_ENABLE;
else else
priv->currentpacketfilter &= ~CMD_ACT_MAC_WEP_ENABLE; priv->currentpacketfilter &= ~CMD_ACT_MAC_WEP_ENABLE;
ret = lbs_set_mac_packet_filter(priv); ret = lbs_set_mac_packet_filter(priv);
if (ret) if (ret)
goto out; goto out;
@ -300,7 +290,7 @@ static int assoc_helper_wep_keys(struct lbs_private *priv,
/* Copy WEP keys into priv wep key fields */ /* Copy WEP keys into priv wep key fields */
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
memcpy(&priv->wep_keys[i], &assoc_req->wep_keys[i], memcpy(&priv->wep_keys[i], &assoc_req->wep_keys[i],
sizeof(struct enc_key)); sizeof(struct enc_key));
} }
priv->wep_tx_keyidx = assoc_req->wep_tx_keyidx; priv->wep_tx_keyidx = assoc_req->wep_tx_keyidx;

View file

@ -240,74 +240,61 @@ int lbs_cmd_802_11_sleep_params(struct lbs_private *priv, uint16_t cmd_action,
return 0; return 0;
} }
static int lbs_cmd_802_11_set_wep(struct lbs_private *priv, int lbs_cmd_802_11_set_wep(struct lbs_private *priv, uint16_t cmd_action,
struct cmd_ds_command *cmd, struct assoc_request *assoc)
u32 cmd_act,
void * pdata_buf)
{ {
struct cmd_ds_802_11_set_wep *wep = &cmd->params.wep; struct cmd_ds_802_11_set_wep cmd;
int ret = 0; int ret = 0;
struct assoc_request * assoc_req = pdata_buf;
lbs_deb_enter(LBS_DEB_CMD); lbs_deb_enter(LBS_DEB_CMD);
cmd->command = cpu_to_le16(CMD_802_11_SET_WEP); cmd.hdr.command = cpu_to_le16(CMD_802_11_SET_WEP);
cmd->size = cpu_to_le16(sizeof(*wep) + S_DS_GEN); cmd.hdr.size = cpu_to_le16(sizeof(cmd));
if (cmd_act == CMD_ACT_ADD) { cmd.action = cpu_to_le16(cmd_action);
if (cmd_action == CMD_ACT_ADD) {
int i; int i;
if (!assoc_req) {
lbs_deb_cmd("Invalid association request!\n");
ret = -1;
goto done;
}
wep->action = cpu_to_le16(CMD_ACT_ADD);
/* default tx key index */ /* default tx key index */
wep->keyindex = cpu_to_le16((u16)(assoc_req->wep_tx_keyidx & cmd.keyindex = cpu_to_le16(assoc->wep_tx_keyidx &
(u32)CMD_WEP_KEY_INDEX_MASK)); CMD_WEP_KEY_INDEX_MASK);
/* Copy key types and material to host command structure */ /* Copy key types and material to host command structure */
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
struct enc_key * pkey = &assoc_req->wep_keys[i]; struct enc_key *pkey = &assoc->wep_keys[i];
switch (pkey->len) { switch (pkey->len) {
case KEY_LEN_WEP_40: case KEY_LEN_WEP_40:
wep->keytype[i] = CMD_TYPE_WEP_40_BIT; cmd.keytype[i] = CMD_TYPE_WEP_40_BIT;
memmove(&wep->keymaterial[i], pkey->key, memmove(cmd.keymaterial[i], pkey->key, pkey->len);
pkey->len);
lbs_deb_cmd("SET_WEP: add key %d (40 bit)\n", i); lbs_deb_cmd("SET_WEP: add key %d (40 bit)\n", i);
break; break;
case KEY_LEN_WEP_104: case KEY_LEN_WEP_104:
wep->keytype[i] = CMD_TYPE_WEP_104_BIT; cmd.keytype[i] = CMD_TYPE_WEP_104_BIT;
memmove(&wep->keymaterial[i], pkey->key, memmove(cmd.keymaterial[i], pkey->key, pkey->len);
pkey->len);
lbs_deb_cmd("SET_WEP: add key %d (104 bit)\n", i); lbs_deb_cmd("SET_WEP: add key %d (104 bit)\n", i);
break; break;
case 0: case 0:
break; break;
default: default:
lbs_deb_cmd("SET_WEP: invalid key %d, length %d\n", lbs_deb_cmd("SET_WEP: invalid key %d, length %d\n",
i, pkey->len); i, pkey->len);
ret = -1; ret = -1;
goto done; goto done;
break; break;
} }
} }
} else if (cmd_act == CMD_ACT_REMOVE) { } else if (cmd_action == CMD_ACT_REMOVE) {
/* ACT_REMOVE clears _all_ WEP keys */ /* ACT_REMOVE clears _all_ WEP keys */
wep->action = cpu_to_le16(CMD_ACT_REMOVE);
/* default tx key index */ /* default tx key index */
wep->keyindex = cpu_to_le16((u16)(priv->wep_tx_keyidx & cmd.keyindex = cpu_to_le16(priv->wep_tx_keyidx &
(u32)CMD_WEP_KEY_INDEX_MASK)); CMD_WEP_KEY_INDEX_MASK);
lbs_deb_cmd("SET_WEP: remove key %d\n", priv->wep_tx_keyidx); lbs_deb_cmd("SET_WEP: remove key %d\n", priv->wep_tx_keyidx);
} }
ret = 0; ret = lbs_cmd_with_response(priv, CMD_802_11_SET_WEP, &cmd);
done: done:
lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
return ret; return ret;
@ -1422,10 +1409,6 @@ int lbs_prepare_and_send_command(struct lbs_private *priv,
ret = lbs_cmd_80211_deauthenticate(priv, cmdptr); ret = lbs_cmd_80211_deauthenticate(priv, cmdptr);
break; break;
case CMD_802_11_SET_WEP:
ret = lbs_cmd_802_11_set_wep(priv, cmdptr, cmd_action, pdata_buf);
break;
case CMD_802_11_AD_HOC_START: case CMD_802_11_AD_HOC_START:
ret = lbs_cmd_80211_ad_hoc_start(priv, cmdptr, pdata_buf); ret = lbs_cmd_80211_ad_hoc_start(priv, cmdptr, pdata_buf);
break; break;

View file

@ -51,5 +51,7 @@ int lbs_cmd_802_11_inactivity_timeout(struct lbs_private *priv,
uint16_t cmd_action, uint16_t *timeout); uint16_t cmd_action, uint16_t *timeout);
int lbs_cmd_802_11_sleep_params(struct lbs_private *priv, uint16_t cmd_action, int lbs_cmd_802_11_sleep_params(struct lbs_private *priv, uint16_t cmd_action,
struct sleep_params *sp); struct sleep_params *sp);
int lbs_cmd_802_11_set_wep(struct lbs_private *priv, uint16_t cmd_action,
struct assoc_request *assoc);
#endif /* _LBS_CMD_H */ #endif /* _LBS_CMD_H */

View file

@ -490,7 +490,6 @@ static inline int handle_cmd_response(struct lbs_private *priv,
case CMD_RET(CMD_MAC_MULTICAST_ADR): case CMD_RET(CMD_MAC_MULTICAST_ADR):
case CMD_RET(CMD_MAC_CONTROL): case CMD_RET(CMD_MAC_CONTROL):
case CMD_RET(CMD_802_11_SET_WEP):
case CMD_RET(CMD_802_11_RESET): case CMD_RET(CMD_802_11_RESET):
case CMD_RET(CMD_802_11_AUTHENTICATE): case CMD_RET(CMD_802_11_AUTHENTICATE):
case CMD_RET(CMD_802_11_BEACON_STOP): case CMD_RET(CMD_802_11_BEACON_STOP):

View file

@ -256,6 +256,8 @@ struct cmd_ds_802_11_ad_hoc_result {
}; };
struct cmd_ds_802_11_set_wep { struct cmd_ds_802_11_set_wep {
struct cmd_header hdr;
/* ACT_ADD, ACT_REMOVE or ACT_ENABLE */ /* ACT_ADD, ACT_REMOVE or ACT_ENABLE */
__le16 action; __le16 action;
@ -263,8 +265,8 @@ struct cmd_ds_802_11_set_wep {
__le16 keyindex; __le16 keyindex;
/* 40, 128bit or TXWEP */ /* 40, 128bit or TXWEP */
u8 keytype[4]; uint8_t keytype[4];
u8 keymaterial[4][16]; uint8_t keymaterial[4][16];
}; };
struct cmd_ds_802_3_get_stat { struct cmd_ds_802_3_get_stat {
@ -688,7 +690,6 @@ struct cmd_ds_command {
struct cmd_ds_mac_control macctrl; struct cmd_ds_mac_control macctrl;
struct cmd_ds_802_11_associate associate; struct cmd_ds_802_11_associate associate;
struct cmd_ds_802_11_deauthenticate deauth; struct cmd_ds_802_11_deauthenticate deauth;
struct cmd_ds_802_11_set_wep wep;
struct cmd_ds_802_11_ad_hoc_start ads; struct cmd_ds_802_11_ad_hoc_start ads;
struct cmd_ds_802_11_reset reset; struct cmd_ds_802_11_reset reset;
struct cmd_ds_802_11_ad_hoc_result result; struct cmd_ds_802_11_ad_hoc_result result;