提交 1443b653 编写于 作者: D Dan Williams 提交者: David S. Miller

[PATCH] libertas: rename WLAN_802_11_KEY to enc_key and clean up usage

It doesn't touch hardware and therefore doesn't need endian notations
either.
Signed-off-by: NDan Williams <dcbw@redhat.com>
Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
上级 0c9ca690
...@@ -307,7 +307,7 @@ static int assoc_helper_wep_keys(wlan_private *priv, ...@@ -307,7 +307,7 @@ static int assoc_helper_wep_keys(wlan_private *priv,
/* Copy WEP keys into adapter wep key fields */ /* Copy WEP keys into adapter wep key fields */
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
memcpy(&adapter->wep_keys[i], &assoc_req->wep_keys[i], memcpy(&adapter->wep_keys[i], &assoc_req->wep_keys[i],
sizeof(struct WLAN_802_11_KEY)); sizeof(struct enc_key));
} }
adapter->wep_tx_keyidx = assoc_req->wep_tx_keyidx; adapter->wep_tx_keyidx = assoc_req->wep_tx_keyidx;
...@@ -703,7 +703,7 @@ struct assoc_request * wlan_get_association_request(wlan_adapter *adapter) ...@@ -703,7 +703,7 @@ struct assoc_request * wlan_get_association_request(wlan_adapter *adapter)
int i; int i;
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
memcpy(&assoc_req->wep_keys[i], &adapter->wep_keys[i], memcpy(&assoc_req->wep_keys[i], &adapter->wep_keys[i],
sizeof(struct WLAN_802_11_KEY)); sizeof(struct enc_key));
} }
} }
...@@ -712,12 +712,12 @@ struct assoc_request * wlan_get_association_request(wlan_adapter *adapter) ...@@ -712,12 +712,12 @@ struct assoc_request * wlan_get_association_request(wlan_adapter *adapter)
if (!test_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags)) { if (!test_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags)) {
memcpy(&assoc_req->wpa_mcast_key, &adapter->wpa_mcast_key, memcpy(&assoc_req->wpa_mcast_key, &adapter->wpa_mcast_key,
sizeof(struct WLAN_802_11_KEY)); sizeof(struct enc_key));
} }
if (!test_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags)) { if (!test_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags)) {
memcpy(&assoc_req->wpa_unicast_key, &adapter->wpa_unicast_key, memcpy(&assoc_req->wpa_unicast_key, &adapter->wpa_unicast_key,
sizeof(struct WLAN_802_11_KEY)); sizeof(struct enc_key));
} }
if (!test_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags)) { if (!test_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags)) {
......
...@@ -181,7 +181,7 @@ static int wlan_cmd_802_11_set_wep(wlan_private * priv, ...@@ -181,7 +181,7 @@ static int wlan_cmd_802_11_set_wep(wlan_private * priv,
/* 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 WLAN_802_11_KEY * pkey = &assoc_req->wep_keys[i]; struct enc_key * pkey = &assoc_req->wep_keys[i];
switch (pkey->len) { switch (pkey->len) {
case KEY_LEN_WEP_40: case KEY_LEN_WEP_40:
...@@ -249,10 +249,8 @@ static int wlan_cmd_802_11_enable_rsn(wlan_private * priv, ...@@ -249,10 +249,8 @@ static int wlan_cmd_802_11_enable_rsn(wlan_private * priv,
static void set_one_wpa_key(struct MrvlIEtype_keyParamSet * pkeyparamset, static void set_one_wpa_key(struct MrvlIEtype_keyParamSet * pkeyparamset,
struct WLAN_802_11_KEY * pkey) struct enc_key * pkey)
{ {
pkeyparamset->keytypeid = cpu_to_le16(pkey->type);
if (pkey->flags & KEY_INFO_WPA_ENABLED) { if (pkey->flags & KEY_INFO_WPA_ENABLED) {
pkeyparamset->keyinfo |= cpu_to_le16(KEY_INFO_WPA_ENABLED); pkeyparamset->keyinfo |= cpu_to_le16(KEY_INFO_WPA_ENABLED);
} }
...@@ -264,6 +262,7 @@ static void set_one_wpa_key(struct MrvlIEtype_keyParamSet * pkeyparamset, ...@@ -264,6 +262,7 @@ static void set_one_wpa_key(struct MrvlIEtype_keyParamSet * pkeyparamset,
} }
pkeyparamset->type = cpu_to_le16(TLV_TYPE_KEY_MATERIAL); pkeyparamset->type = cpu_to_le16(TLV_TYPE_KEY_MATERIAL);
pkeyparamset->keytypeid = cpu_to_le16(pkey->type);
pkeyparamset->keylen = cpu_to_le16(pkey->len); pkeyparamset->keylen = cpu_to_le16(pkey->len);
memcpy(pkeyparamset->key, pkey->key, pkey->len); memcpy(pkeyparamset->key, pkey->key, pkey->len);
pkeyparamset->length = cpu_to_le16( sizeof(pkeyparamset->keytypeid) pkeyparamset->length = cpu_to_le16( sizeof(pkeyparamset->keytypeid)
......
...@@ -321,11 +321,12 @@ static int wlan_ret_802_11_key_material(wlan_private * priv, ...@@ -321,11 +321,12 @@ static int wlan_ret_802_11_key_material(wlan_private * priv,
while (buf_ptr < resp_end) { while (buf_ptr < resp_end) {
struct MrvlIEtype_keyParamSet * pkeyparamset = struct MrvlIEtype_keyParamSet * pkeyparamset =
(struct MrvlIEtype_keyParamSet *) buf_ptr; (struct MrvlIEtype_keyParamSet *) buf_ptr;
struct WLAN_802_11_KEY * pkey; struct enc_key * pkey;
u16 key_info = le16_to_cpu(pkeyparamset->keyinfo);
u16 param_set_len = le16_to_cpu(pkeyparamset->length); u16 param_set_len = le16_to_cpu(pkeyparamset->length);
u8 * end;
u16 key_len = le16_to_cpu(pkeyparamset->keylen); u16 key_len = le16_to_cpu(pkeyparamset->keylen);
u16 key_flags = le16_to_cpu(pkeyparamset->keyinfo);
u16 key_type = le16_to_cpu(pkeyparamset->keytypeid);
u8 * end;
end = (u8 *) pkeyparamset + sizeof (pkeyparamset->type) end = (u8 *) pkeyparamset + sizeof (pkeyparamset->type)
+ sizeof (pkeyparamset->length) + sizeof (pkeyparamset->length)
...@@ -334,20 +335,20 @@ static int wlan_ret_802_11_key_material(wlan_private * priv, ...@@ -334,20 +335,20 @@ static int wlan_ret_802_11_key_material(wlan_private * priv,
if (end > resp_end) if (end > resp_end)
break; break;
if (key_info & KEY_INFO_WPA_UNICAST) if (key_flags & KEY_INFO_WPA_UNICAST)
pkey = &adapter->wpa_unicast_key; pkey = &adapter->wpa_unicast_key;
else if (key_info & KEY_INFO_WPA_MCAST) else if (key_flags & KEY_INFO_WPA_MCAST)
pkey = &adapter->wpa_mcast_key; pkey = &adapter->wpa_mcast_key;
else else
break; break;
/* Copy returned key into driver */ /* Copy returned key into driver */
memset(pkey, 0, sizeof(struct WLAN_802_11_KEY)); memset(pkey, 0, sizeof(struct enc_key));
if (key_len > sizeof(pkey->key)) if (key_len > sizeof(pkey->key))
break; break;
pkey->type = le16_to_cpu(pkeyparamset->keytypeid); pkey->type = key_type;
pkey->flags = le16_to_cpu(pkeyparamset->keyinfo); pkey->flags = key_flags;
pkey->len = le16_to_cpu(pkeyparamset->keylen); pkey->len = key_len;
memcpy(pkey->key, pkeyparamset->key, pkey->len); memcpy(pkey->key, pkeyparamset->key, pkey->len);
buf_ptr = end + 1; buf_ptr = end + 1;
......
...@@ -218,9 +218,6 @@ static inline void lbs_dbg_hex(char *prompt, u8 * buf, int len) ...@@ -218,9 +218,6 @@ static inline void lbs_dbg_hex(char *prompt, u8 * buf, int len)
#define CMD_F_HOSTCMD (1 << 0) #define CMD_F_HOSTCMD (1 << 0)
#define FW_CAPINFO_WPA (1 << 0) #define FW_CAPINFO_WPA (1 << 0)
/** WPA key LENGTH*/
#define MRVL_MAX_KEY_WPA_KEY_LENGTH 32
#define KEY_LEN_WPA_AES 16 #define KEY_LEN_WPA_AES 16
#define KEY_LEN_WPA_TKIP 32 #define KEY_LEN_WPA_TKIP 32
#define KEY_LEN_WEP_104 13 #define KEY_LEN_WEP_104 13
......
...@@ -188,12 +188,12 @@ struct assoc_request { ...@@ -188,12 +188,12 @@ struct assoc_request {
u8 bssid[ETH_ALEN]; u8 bssid[ETH_ALEN];
/** WEP keys */ /** WEP keys */
struct WLAN_802_11_KEY wep_keys[4]; struct enc_key wep_keys[4];
u16 wep_tx_keyidx; u16 wep_tx_keyidx;
/** WPA keys */ /** WPA keys */
struct WLAN_802_11_KEY wpa_mcast_key; struct enc_key wpa_mcast_key;
struct WLAN_802_11_KEY wpa_unicast_key; struct enc_key wpa_unicast_key;
struct wlan_802_11_security secinfo; struct wlan_802_11_security secinfo;
...@@ -335,12 +335,12 @@ struct _wlan_adapter { ...@@ -335,12 +335,12 @@ struct _wlan_adapter {
struct wlan_802_11_security secinfo; struct wlan_802_11_security secinfo;
/** WEP keys */ /** WEP keys */
struct WLAN_802_11_KEY wep_keys[4]; struct enc_key wep_keys[4];
u16 wep_tx_keyidx; u16 wep_tx_keyidx;
/** WPA keys */ /** WPA keys */
struct WLAN_802_11_KEY wpa_mcast_key; struct enc_key wpa_mcast_key;
struct WLAN_802_11_KEY wpa_unicast_key; struct enc_key wpa_unicast_key;
/** WPA Information Elements*/ /** WPA Information Elements*/
u8 wpa_ie[MAX_WPA_IE_LEN]; u8 wpa_ie[MAX_WPA_IE_LEN];
......
...@@ -181,7 +181,7 @@ static void wlan_init_adapter(wlan_private * priv) ...@@ -181,7 +181,7 @@ static void wlan_init_adapter(wlan_private * priv)
adapter->secinfo.wep_enabled = 0; adapter->secinfo.wep_enabled = 0;
for (i = 0; i < sizeof(adapter->wep_keys) / sizeof(adapter->wep_keys[0]); for (i = 0; i < sizeof(adapter->wep_keys) / sizeof(adapter->wep_keys[0]);
i++) i++)
memset(&adapter->wep_keys[i], 0, sizeof(struct WLAN_802_11_KEY)); memset(&adapter->wep_keys[i], 0, sizeof(struct enc_key));
adapter->wep_tx_keyidx = 0; adapter->wep_tx_keyidx = 0;
adapter->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; adapter->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
adapter->mode = IW_MODE_INFRA; adapter->mode = IW_MODE_INFRA;
......
...@@ -83,16 +83,12 @@ struct cmd_ctrl_node { ...@@ -83,16 +83,12 @@ struct cmd_ctrl_node {
wait_queue_head_t cmdwait_q; wait_queue_head_t cmdwait_q;
}; };
/* WLAN_802_11_KEY /* Generic structure to hold all key types. */
* struct enc_key {
* Generic structure to hold all key types. key type (WEP40, WEP104, TKIP, AES) u16 len;
* is determined from the keylength field. u16 flags; /* KEY_INFO_* from wlan_defs.h */
*/ u16 type; /* KEY_TYPE_* from wlan_defs.h */
struct WLAN_802_11_KEY { u8 key[32];
__le32 len;
__le32 flags; /* KEY_INFO_* from wlan_defs.h */
u8 key[MRVL_MAX_KEY_WPA_KEY_LENGTH];
__le16 type; /* KEY_TYPE_* from wlan_defs.h */
}; };
struct IE_WPA { struct IE_WPA {
......
...@@ -1325,7 +1325,7 @@ static int wlan_set_wep_key(struct assoc_request *assoc_req, ...@@ -1325,7 +1325,7 @@ static int wlan_set_wep_key(struct assoc_request *assoc_req,
int set_tx_key) int set_tx_key)
{ {
int ret = 0; int ret = 0;
struct WLAN_802_11_KEY *pkey; struct enc_key *pkey;
lbs_deb_enter(LBS_DEB_WEXT); lbs_deb_enter(LBS_DEB_WEXT);
...@@ -1344,7 +1344,7 @@ static int wlan_set_wep_key(struct assoc_request *assoc_req, ...@@ -1344,7 +1344,7 @@ static int wlan_set_wep_key(struct assoc_request *assoc_req,
pkey = &assoc_req->wep_keys[index]; pkey = &assoc_req->wep_keys[index];
if (key_length > 0) { if (key_length > 0) {
memset(pkey, 0, sizeof(struct WLAN_802_11_KEY)); memset(pkey, 0, sizeof(struct enc_key));
pkey->type = KEY_TYPE_ID_WEP; pkey->type = KEY_TYPE_ID_WEP;
/* Standardize the key length */ /* Standardize the key length */
...@@ -1412,11 +1412,11 @@ static void disable_wpa(struct assoc_request *assoc_req) ...@@ -1412,11 +1412,11 @@ static void disable_wpa(struct assoc_request *assoc_req)
{ {
lbs_deb_enter(LBS_DEB_WEXT); lbs_deb_enter(LBS_DEB_WEXT);
memset(&assoc_req->wpa_mcast_key, 0, sizeof (struct WLAN_802_11_KEY)); memset(&assoc_req->wpa_mcast_key, 0, sizeof (struct enc_key));
assoc_req->wpa_mcast_key.flags = KEY_INFO_WPA_MCAST; assoc_req->wpa_mcast_key.flags = KEY_INFO_WPA_MCAST;
set_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags); set_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags);
memset(&assoc_req->wpa_unicast_key, 0, sizeof (struct WLAN_802_11_KEY)); memset(&assoc_req->wpa_unicast_key, 0, sizeof (struct enc_key));
assoc_req->wpa_unicast_key.flags = KEY_INFO_WPA_UNICAST; assoc_req->wpa_unicast_key.flags = KEY_INFO_WPA_UNICAST;
set_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags); set_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags);
...@@ -1567,7 +1567,7 @@ static int wlan_get_encodeext(struct net_device *dev, ...@@ -1567,7 +1567,7 @@ static int wlan_get_encodeext(struct net_device *dev,
&& (adapter->secinfo.WPAenabled || && (adapter->secinfo.WPAenabled ||
adapter->secinfo.WPA2enabled)) { adapter->secinfo.WPA2enabled)) {
/* WPA */ /* WPA */
struct WLAN_802_11_KEY * pkey = NULL; struct enc_key * pkey = NULL;
if ( adapter->wpa_mcast_key.len if ( adapter->wpa_mcast_key.len
&& (adapter->wpa_mcast_key.flags & KEY_INFO_WPA_ENABLED)) && (adapter->wpa_mcast_key.flags & KEY_INFO_WPA_ENABLED))
...@@ -1679,7 +1679,7 @@ static int wlan_set_encodeext(struct net_device *dev, ...@@ -1679,7 +1679,7 @@ static int wlan_set_encodeext(struct net_device *dev,
if (set_tx_key) if (set_tx_key)
set_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags); set_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags);
} else if ((alg == IW_ENCODE_ALG_TKIP) || (alg == IW_ENCODE_ALG_CCMP)) { } else if ((alg == IW_ENCODE_ALG_TKIP) || (alg == IW_ENCODE_ALG_CCMP)) {
struct WLAN_802_11_KEY * pkey; struct enc_key * pkey;
/* validate key length */ /* validate key length */
if (((alg == IW_ENCODE_ALG_TKIP) if (((alg == IW_ENCODE_ALG_TKIP)
...@@ -1702,7 +1702,7 @@ static int wlan_set_encodeext(struct net_device *dev, ...@@ -1702,7 +1702,7 @@ static int wlan_set_encodeext(struct net_device *dev,
set_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags); set_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags);
} }
memset(pkey, 0, sizeof (struct WLAN_802_11_KEY)); memset(pkey, 0, sizeof (struct enc_key));
memcpy(pkey->key, ext->key, ext->key_len); memcpy(pkey->key, ext->key, ext->key_len);
pkey->len = ext->key_len; pkey->len = ext->key_len;
if (pkey->len) if (pkey->len)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册