Commit 5dab9e7d authored by Jes Sorensen's avatar Jes Sorensen Committed by Greg Kroah-Hartman

staging: rtl8723au: rtw_cfg80211_ap_set_encryption(): Use key_params->cipher...

staging: rtl8723au: rtw_cfg80211_ap_set_encryption(): Use key_params->cipher to determine encryption

Passing strings around for something we have defines for is just
silly.
Signed-off-by: default avatarJes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent ef80f1f5
...@@ -501,7 +501,8 @@ static int set_wep_key(struct rtw_adapter *padapter, u8 *key, u16 keylen, ...@@ -501,7 +501,8 @@ static int set_wep_key(struct rtw_adapter *padapter, u8 *key, u16 keylen,
static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, static int rtw_cfg80211_ap_set_encryption(struct net_device *dev,
struct ieee_param *param, struct ieee_param *param,
u32 param_len) u32 param_len,
struct key_params *keyparms)
{ {
int ret = 0; int ret = 0;
u16 wep_key_len; u16 wep_key_len;
...@@ -549,7 +550,8 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, ...@@ -549,7 +550,8 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev,
goto exit; goto exit;
} }
if (strcmp(param->u.crypt.alg, "WEP") == 0 && (psta == NULL)) { if (!psta && (keyparms->cipher == WLAN_CIPHER_SUITE_WEP40 ||
keyparms->cipher == WLAN_CIPHER_SUITE_WEP104)) {
DBG_8723A("r871x_set_encryption, crypt.alg = WEP\n"); DBG_8723A("r871x_set_encryption, crypt.alg = WEP\n");
wep_key_idx = param->u.crypt.idx; wep_key_idx = param->u.crypt.idx;
...@@ -598,7 +600,8 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, ...@@ -598,7 +600,8 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev,
if (!psta && check_fwstate(pmlmepriv, WIFI_AP_STATE)) { /* group key */ if (!psta && check_fwstate(pmlmepriv, WIFI_AP_STATE)) { /* group key */
if (param->u.crypt.set_tx == 0) { /* group key */ if (param->u.crypt.set_tx == 0) { /* group key */
if (strcmp(param->u.crypt.alg, "WEP") == 0) { if (keyparms->cipher == WLAN_CIPHER_SUITE_WEP40 ||
keyparms->cipher == WLAN_CIPHER_SUITE_WEP104) {
DBG_8723A("%s, set group_key, WEP\n", __func__); DBG_8723A("%s, set group_key, WEP\n", __func__);
memcpy(psecuritypriv-> memcpy(psecuritypriv->
...@@ -613,7 +616,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, ...@@ -613,7 +616,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev,
WLAN_CIPHER_SUITE_WEP104; WLAN_CIPHER_SUITE_WEP104;
} }
} else if (strcmp(param->u.crypt.alg, "TKIP") == 0) { } else if (keyparms->cipher == WLAN_CIPHER_SUITE_TKIP) {
DBG_8723A("%s, set group_key, TKIP\n", DBG_8723A("%s, set group_key, TKIP\n",
__func__); __func__);
...@@ -638,7 +641,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, ...@@ -638,7 +641,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev,
psecuritypriv->busetkipkey = 1; psecuritypriv->busetkipkey = 1;
} else if (strcmp(param->u.crypt.alg, "CCMP") == 0) { } else if (keyparms->cipher == WLAN_CIPHER_SUITE_CCMP) {
DBG_8723A("%s, set group_key, CCMP\n", DBG_8723A("%s, set group_key, CCMP\n",
__func__); __func__);
...@@ -692,7 +695,10 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, ...@@ -692,7 +695,10 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev,
(param->u.crypt.key_len > (param->u.crypt.key_len >
16 ? 16 : param->u.crypt.key_len)); 16 ? 16 : param->u.crypt.key_len));
if (!strcmp(param->u.crypt.alg, "WEP")) { if (keyparms->cipher ==
WLAN_CIPHER_SUITE_WEP40 ||
keyparms->cipher ==
WLAN_CIPHER_SUITE_WEP104) {
DBG_8723A("%s, set pairwise key, WEP\n", DBG_8723A("%s, set pairwise key, WEP\n",
__func__); __func__);
...@@ -701,11 +707,13 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, ...@@ -701,11 +707,13 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev,
psta->dot118021XPrivacy = psta->dot118021XPrivacy =
WLAN_CIPHER_SUITE_WEP104; WLAN_CIPHER_SUITE_WEP104;
} }
} else if (!strcmp(param->u.crypt.alg, "TKIP")) { } else if (keyparms->cipher ==
WLAN_CIPHER_SUITE_TKIP) {
DBG_8723A("%s, set pairwise key, " DBG_8723A("%s, set pairwise key, "
"TKIP\n", __func__); "TKIP\n", __func__);
psta->dot118021XPrivacy = WLAN_CIPHER_SUITE_TKIP; psta->dot118021XPrivacy =
WLAN_CIPHER_SUITE_TKIP;
/* DEBUG_ERR("set key length :param->u.crypt.key_len =%d\n", param->u.crypt.key_len); */ /* DEBUG_ERR("set key length :param->u.crypt.key_len =%d\n", param->u.crypt.key_len); */
/* set mic key */ /* set mic key */
...@@ -716,12 +724,13 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, ...@@ -716,12 +724,13 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev,
psecuritypriv->busetkipkey = 1; psecuritypriv->busetkipkey = 1;
} else if (!strcmp(param->u.crypt.alg, "CCMP")) { } else if (keyparms->cipher ==
WLAN_CIPHER_SUITE_CCMP) {
DBG_8723A("%s, set pairwise key, " DBG_8723A("%s, set pairwise key, "
"CCMP\n", __func__); "CCMP\n", __func__);
psta->dot118021XPrivacy = WLAN_CIPHER_SUITE_CCMP; psta->dot118021XPrivacy =
WLAN_CIPHER_SUITE_CCMP;
} else { } else {
DBG_8723A("%s, set pairwise key, " DBG_8723A("%s, set pairwise key, "
"none\n", __func__); "none\n", __func__);
...@@ -735,7 +744,10 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, ...@@ -735,7 +744,10 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev,
psta->bpairwise_key_installed = true; psta->bpairwise_key_installed = true;
} else { /* group key??? */ } else { /* group key??? */
if (!strcmp(param->u.crypt.alg, "WEP")) { if (keyparms->cipher ==
WLAN_CIPHER_SUITE_WEP40 ||
keyparms->cipher ==
WLAN_CIPHER_SUITE_WEP104) {
memcpy(psecuritypriv-> memcpy(psecuritypriv->
dot118021XGrpKey[param->u.crypt. dot118021XGrpKey[param->u.crypt.
idx].skey, idx].skey,
...@@ -751,7 +763,8 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, ...@@ -751,7 +763,8 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev,
dot118021XGrpPrivacy = dot118021XGrpPrivacy =
WLAN_CIPHER_SUITE_WEP104; WLAN_CIPHER_SUITE_WEP104;
} }
} else if (!strcmp(param->u.crypt.alg, "TKIP")) { } else if (keyparms->cipher ==
WLAN_CIPHER_SUITE_TKIP) {
psecuritypriv->dot118021XGrpPrivacy = psecuritypriv->dot118021XGrpPrivacy =
WLAN_CIPHER_SUITE_TKIP; WLAN_CIPHER_SUITE_TKIP;
...@@ -780,7 +793,8 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, ...@@ -780,7 +793,8 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev,
psecuritypriv->busetkipkey = 1; psecuritypriv->busetkipkey = 1;
} else if (!strcmp(param->u.crypt.alg, "CCMP")) { } else if (keyparms->cipher ==
WLAN_CIPHER_SUITE_CCMP) {
psecuritypriv->dot118021XGrpPrivacy = psecuritypriv->dot118021XGrpPrivacy =
WLAN_CIPHER_SUITE_CCMP; WLAN_CIPHER_SUITE_CCMP;
...@@ -1099,7 +1113,8 @@ static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev, ...@@ -1099,7 +1113,8 @@ static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev,
if (mac_addr) if (mac_addr)
ether_addr_copy(param->sta_addr, mac_addr); ether_addr_copy(param->sta_addr, mac_addr);
ret = rtw_cfg80211_ap_set_encryption(ndev, param, param_len); ret = rtw_cfg80211_ap_set_encryption(ndev, param, param_len,
params);
#endif #endif
} else { } else {
DBG_8723A("error! fw_state = 0x%x, iftype =%d\n", DBG_8723A("error! fw_state = 0x%x, iftype =%d\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment