mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-03 17:51:57 +09:00
staging: rtl8723au: Make rtw_cfg80211_add_wep() take a struct rtw_wep_key
This allows the removal of the ugly struct ndis_8802_11_wep and simplify rtw_cfg80211_add_wep(). In addition remove unused element ndiswep from struct security_priv. Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
6893c8ebba
commit
deff11554f
@@ -142,7 +142,6 @@ struct security_priv {
|
||||
u32 ndisauthtype; /* enum ndis_802_11_auth_mode */
|
||||
u32 ndisencryptstatus; /* NDIS_802_11_ENCRYPTION_STATUS */
|
||||
struct wlan_bssid_ex sec_bss; /* for joinbss (h2c buffer) usage */
|
||||
struct ndis_802_11_wep ndiswep;
|
||||
u8 assoc_info[600];
|
||||
u8 szofcapability[256]; /* for wpa2 usage */
|
||||
u8 oidassociation[512]; /* for wpa/wpa2 usage */
|
||||
|
||||
@@ -99,13 +99,6 @@ struct ndis_802_11_key {
|
||||
u8 KeyMaterial[32]; /* variable length depending on above field */
|
||||
};
|
||||
|
||||
struct ndis_802_11_wep {
|
||||
u32 Length; /* Length of this structure */
|
||||
u32 KeyIndex; /* 0 is the per-client key, 1-N are global */
|
||||
u32 KeyLength; /* length of key in bytes */
|
||||
u8 KeyMaterial[16];/* variable length depending on above field */
|
||||
};
|
||||
|
||||
enum NDIS_802_11_STATUS_TYPE {
|
||||
Ndis802_11StatusType_Authentication,
|
||||
Ndis802_11StatusType_MediaStreamMode,
|
||||
|
||||
@@ -1936,22 +1936,19 @@ exit:
|
||||
}
|
||||
|
||||
static int rtw_cfg80211_add_wep(struct rtw_adapter *padapter,
|
||||
struct ndis_802_11_wep *wep)
|
||||
struct rtw_wep_key *wep, u8 keyid)
|
||||
{
|
||||
int keyid, res;
|
||||
int res;
|
||||
struct security_priv *psecuritypriv = &padapter->securitypriv;
|
||||
|
||||
keyid = wep->KeyIndex & 0x3fffffff;
|
||||
|
||||
if (keyid >= 4) {
|
||||
if (keyid >= NUM_WEP_KEYS) {
|
||||
RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_,
|
||||
("%s:keyid>4 =>fail\n", __func__));
|
||||
res = _FAIL;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
switch (wep->KeyLength)
|
||||
{
|
||||
switch (wep->keylen) {
|
||||
case 5:
|
||||
psecuritypriv->dot11PrivacyAlgrthm = WLAN_CIPHER_SUITE_WEP40;
|
||||
RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_,
|
||||
@@ -1971,14 +1968,10 @@ static int rtw_cfg80211_add_wep(struct rtw_adapter *padapter,
|
||||
}
|
||||
|
||||
RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_,
|
||||
("%s:before memcpy, wep->KeyLength = 0x%x "
|
||||
"wep->KeyIndex = 0x%x keyid =%x\n", __func__,
|
||||
wep->KeyLength, wep->KeyIndex, keyid));
|
||||
("%s:before memcpy, wep->KeyLength = 0x%x keyid =%x\n",
|
||||
__func__, wep->keylen, keyid));
|
||||
|
||||
memcpy(&psecuritypriv->wep_key[keyid].key, &wep->KeyMaterial,
|
||||
wep->KeyLength);
|
||||
|
||||
psecuritypriv->wep_key[keyid].keylen = wep->KeyLength;
|
||||
memcpy(&psecuritypriv->wep_key[keyid], wep, sizeof(struct rtw_wep_key));
|
||||
|
||||
psecuritypriv->dot11PrivacyKeyIndex = keyid;
|
||||
|
||||
@@ -2176,57 +2169,43 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev,
|
||||
if ((psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_Shared ||
|
||||
psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_Auto) &&
|
||||
sme->key) {
|
||||
u32 wep_key_idx, wep_key_len, wep_total_len;
|
||||
struct ndis_802_11_wep *pwep = NULL;
|
||||
struct rtw_wep_key wep_key;
|
||||
u8 wep_key_idx, wep_key_len;
|
||||
DBG_8723A("%s(): Shared/Auto WEP\n", __func__);
|
||||
|
||||
wep_key_idx = sme->key_idx;
|
||||
wep_key_len = sme->key_len;
|
||||
|
||||
if (sme->key_idx > WEP_KEYS) {
|
||||
if (wep_key_idx > WEP_KEYS || !wep_key_len ||
|
||||
wep_key_len > WLAN_KEY_LEN_WEP104) {
|
||||
ret = -EINVAL;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (wep_key_len > 0) {
|
||||
wep_key_len = wep_key_len <= 5 ? 5 : 13;
|
||||
wep_total_len =
|
||||
wep_key_len +
|
||||
offsetof(struct ndis_802_11_wep, KeyMaterial);
|
||||
pwep = (struct ndis_802_11_wep *)kmalloc(wep_total_len,
|
||||
GFP_KERNEL);
|
||||
if (pwep == NULL) {
|
||||
DBG_8723A(" wpa_set_encryption: pwep "
|
||||
"allocate fail !!!\n");
|
||||
ret = -ENOMEM;
|
||||
goto exit;
|
||||
}
|
||||
wep_key_len = wep_key_len <= 5 ? 5 : 13;
|
||||
|
||||
memset(pwep, 0, wep_total_len);
|
||||
memset(&wep_key, 0, sizeof(struct rtw_wep_key));
|
||||
|
||||
pwep->KeyLength = wep_key_len;
|
||||
pwep->Length = wep_total_len;
|
||||
wep_key.keylen = wep_key_len;
|
||||
|
||||
if (wep_key_len == 13) {
|
||||
padapter->securitypriv.dot11PrivacyAlgrthm =
|
||||
WLAN_CIPHER_SUITE_WEP104;
|
||||
padapter->securitypriv.dot118021XGrpPrivacy =
|
||||
WLAN_CIPHER_SUITE_WEP104;
|
||||
}
|
||||
if (wep_key_len == 13) {
|
||||
padapter->securitypriv.dot11PrivacyAlgrthm =
|
||||
WLAN_CIPHER_SUITE_WEP104;
|
||||
padapter->securitypriv.dot118021XGrpPrivacy =
|
||||
WLAN_CIPHER_SUITE_WEP104;
|
||||
} else {
|
||||
ret = -EINVAL;
|
||||
goto exit;
|
||||
padapter->securitypriv.dot11PrivacyAlgrthm =
|
||||
WLAN_CIPHER_SUITE_WEP40;
|
||||
padapter->securitypriv.dot118021XGrpPrivacy =
|
||||
WLAN_CIPHER_SUITE_WEP40;
|
||||
}
|
||||
|
||||
pwep->KeyIndex = wep_key_idx;
|
||||
memcpy(wep_key.key, (void *)sme->key, wep_key.keylen);
|
||||
|
||||
memcpy(pwep->KeyMaterial, (void *)sme->key, pwep->KeyLength);
|
||||
|
||||
if (rtw_cfg80211_add_wep(padapter, pwep) != _SUCCESS)
|
||||
if (rtw_cfg80211_add_wep(padapter, &wep_key, wep_key_idx) !=
|
||||
_SUCCESS)
|
||||
ret = -EOPNOTSUPP;
|
||||
|
||||
kfree(pwep);
|
||||
|
||||
if (ret < 0)
|
||||
goto exit;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user