staging: rtl8723au: OnAssocReq23a(): Simplify parsing crypto info from the IE
This reduces the dependency of rtw_ieee802_11_parse_elems23a() which is only used in this function. Follow-on patches will remove the remaining dependencies and get rid of the function. Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
ab6fb7a503
commit
7d6925306c
|
@ -1144,7 +1144,7 @@ OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
|
||||||
u16 capab_info, listen_interval;
|
u16 capab_info, listen_interval;
|
||||||
struct rtw_ieee802_11_elems elems;
|
struct rtw_ieee802_11_elems elems;
|
||||||
struct sta_info *pstat;
|
struct sta_info *pstat;
|
||||||
unsigned char reassoc, *wpa_ie;
|
unsigned char reassoc;
|
||||||
unsigned char WMM_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01};
|
unsigned char WMM_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01};
|
||||||
int i, wpa_ie_len, left;
|
int i, wpa_ie_len, left;
|
||||||
unsigned char supportRate[16];
|
unsigned char supportRate[16];
|
||||||
|
@ -1158,10 +1158,11 @@ OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
|
||||||
struct sta_priv *pstapriv = &padapter->stapriv;
|
struct sta_priv *pstapriv = &padapter->stapriv;
|
||||||
struct sk_buff *skb = precv_frame->pkt;
|
struct sk_buff *skb = precv_frame->pkt;
|
||||||
struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data;
|
struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data;
|
||||||
const u8 *p;
|
const u8 *p, *wpa_ie, *wps_ie;
|
||||||
u8 *pos;
|
u8 *pos;
|
||||||
u8 *pframe = skb->data;
|
u8 *pframe = skb->data;
|
||||||
uint pkt_len = skb->len;
|
uint pkt_len = skb->len;
|
||||||
|
int r;
|
||||||
|
|
||||||
if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE)
|
if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE)
|
||||||
return _FAIL;
|
return _FAIL;
|
||||||
|
@ -1280,66 +1281,68 @@ OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
|
||||||
pstat->wpa_pairwise_cipher = 0;
|
pstat->wpa_pairwise_cipher = 0;
|
||||||
pstat->wpa2_pairwise_cipher = 0;
|
pstat->wpa2_pairwise_cipher = 0;
|
||||||
memset(pstat->wpa_ie, 0, sizeof(pstat->wpa_ie));
|
memset(pstat->wpa_ie, 0, sizeof(pstat->wpa_ie));
|
||||||
if (psecuritypriv->wpa_psk & BIT(1) && elems.rsn_ie) {
|
|
||||||
|
wpa_ie = cfg80211_find_ie(WLAN_EID_RSN, pos, left);
|
||||||
|
if (!wpa_ie)
|
||||||
|
wpa_ie = cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT,
|
||||||
|
WLAN_OUI_TYPE_MICROSOFT_WPA,
|
||||||
|
pos, left);
|
||||||
|
if (wpa_ie) {
|
||||||
int group_cipher = 0, pairwise_cipher = 0;
|
int group_cipher = 0, pairwise_cipher = 0;
|
||||||
|
|
||||||
wpa_ie = elems.rsn_ie;
|
wpa_ie_len = wpa_ie[1];
|
||||||
wpa_ie_len = elems.rsn_ie_len;
|
if (psecuritypriv->wpa_psk & BIT(1)) {
|
||||||
|
r = rtw_parse_wpa2_ie23a(wpa_ie, wpa_ie_len + 2,
|
||||||
|
&group_cipher,
|
||||||
|
&pairwise_cipher, NULL);
|
||||||
|
if (r == _SUCCESS) {
|
||||||
|
pstat->dot8021xalg = 1;/* psk, todo:802.1x */
|
||||||
|
pstat->wpa_psk |= BIT(1);
|
||||||
|
|
||||||
if (rtw_parse_wpa2_ie23a(wpa_ie - 2, wpa_ie_len + 2,
|
pstat->wpa2_group_cipher = group_cipher &
|
||||||
&group_cipher, &pairwise_cipher,
|
psecuritypriv->wpa2_group_cipher;
|
||||||
NULL) == _SUCCESS) {
|
pstat->wpa2_pairwise_cipher = pairwise_cipher &
|
||||||
pstat->dot8021xalg = 1;/* psk, todo:802.1x */
|
psecuritypriv->wpa2_pairwise_cipher;
|
||||||
pstat->wpa_psk |= BIT(1);
|
} else
|
||||||
|
status = WLAN_STATUS_INVALID_IE;
|
||||||
pstat->wpa2_group_cipher =
|
} else if (psecuritypriv->wpa_psk & BIT(0)) {
|
||||||
group_cipher&psecuritypriv->wpa2_group_cipher;
|
r = rtw_parse_wpa_ie23a(wpa_ie, wpa_ie_len + 2,
|
||||||
pstat->wpa2_pairwise_cipher =
|
&group_cipher, &pairwise_cipher,
|
||||||
pairwise_cipher&psecuritypriv->wpa2_pairwise_cipher;
|
NULL);
|
||||||
|
if (r == _SUCCESS) {
|
||||||
if (!pstat->wpa2_group_cipher)
|
pstat->dot8021xalg = 1;/* psk, todo:802.1x */
|
||||||
status = WLAN_REASON_INVALID_GROUP_CIPHER;
|
pstat->wpa_psk |= BIT(0);
|
||||||
|
|
||||||
if (!pstat->wpa2_pairwise_cipher)
|
|
||||||
status = WLAN_REASON_INVALID_PAIRWISE_CIPHER;
|
|
||||||
} else
|
|
||||||
status = WLAN_STATUS_INVALID_IE;
|
|
||||||
} else if (psecuritypriv->wpa_psk & BIT(0) && elems.wpa_ie) {
|
|
||||||
int group_cipher = 0, pairwise_cipher = 0;
|
|
||||||
|
|
||||||
wpa_ie = elems.wpa_ie;
|
|
||||||
wpa_ie_len = elems.wpa_ie_len;
|
|
||||||
|
|
||||||
if (rtw_parse_wpa_ie23a(wpa_ie - 2, wpa_ie_len + 2,
|
|
||||||
&group_cipher, &pairwise_cipher,
|
|
||||||
NULL) == _SUCCESS) {
|
|
||||||
pstat->dot8021xalg = 1;/* psk, todo:802.1x */
|
|
||||||
pstat->wpa_psk |= BIT(0);
|
|
||||||
|
|
||||||
pstat->wpa_group_cipher =
|
|
||||||
group_cipher&psecuritypriv->wpa_group_cipher;
|
|
||||||
pstat->wpa_pairwise_cipher =
|
|
||||||
pairwise_cipher&psecuritypriv->wpa_pairwise_cipher;
|
|
||||||
|
|
||||||
|
pstat->wpa_group_cipher = group_cipher &
|
||||||
|
psecuritypriv->wpa_group_cipher;
|
||||||
|
pstat->wpa_pairwise_cipher = pairwise_cipher &
|
||||||
|
psecuritypriv->wpa_pairwise_cipher;
|
||||||
|
} else
|
||||||
|
status = WLAN_STATUS_INVALID_IE;
|
||||||
|
} else {
|
||||||
|
wpa_ie = NULL;
|
||||||
|
wpa_ie_len = 0;
|
||||||
|
}
|
||||||
|
if (wpa_ie && status == WLAN_STATUS_SUCCESS) {
|
||||||
if (!pstat->wpa_group_cipher)
|
if (!pstat->wpa_group_cipher)
|
||||||
status = WLAN_STATUS_INVALID_GROUP_CIPHER;
|
status = WLAN_STATUS_INVALID_GROUP_CIPHER;
|
||||||
|
|
||||||
if (!pstat->wpa_pairwise_cipher)
|
if (!pstat->wpa_pairwise_cipher)
|
||||||
status = WLAN_STATUS_INVALID_PAIRWISE_CIPHER;
|
status = WLAN_STATUS_INVALID_PAIRWISE_CIPHER;
|
||||||
|
}
|
||||||
} else
|
|
||||||
status = WLAN_STATUS_INVALID_IE;
|
|
||||||
} else {
|
|
||||||
wpa_ie = NULL;
|
|
||||||
wpa_ie_len = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WLAN_STATUS_SUCCESS != status)
|
if (status != WLAN_STATUS_SUCCESS)
|
||||||
goto OnAssocReq23aFail;
|
goto OnAssocReq23aFail;
|
||||||
|
|
||||||
pstat->flags &= ~(WLAN_STA_WPS | WLAN_STA_MAYBE_WPS);
|
pstat->flags &= ~(WLAN_STA_WPS | WLAN_STA_MAYBE_WPS);
|
||||||
|
|
||||||
|
wps_ie = cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT,
|
||||||
|
WLAN_OUI_TYPE_MICROSOFT_WPS,
|
||||||
|
pos, left);
|
||||||
|
|
||||||
if (!wpa_ie) {
|
if (!wpa_ie) {
|
||||||
if (elems.wps_ie) {
|
if (wps_ie) {
|
||||||
DBG_8723A("STA included WPS IE in (Re)Association "
|
DBG_8723A("STA included WPS IE in (Re)Association "
|
||||||
"Request - assume WPS is used\n");
|
"Request - assume WPS is used\n");
|
||||||
pstat->flags |= WLAN_STA_WPS;
|
pstat->flags |= WLAN_STA_WPS;
|
||||||
|
@ -1386,10 +1389,9 @@ OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
|
||||||
goto OnAssocReq23aFail;
|
goto OnAssocReq23aFail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elems.wps_ie) {
|
if (wps_ie) {
|
||||||
DBG_8723A("STA included WPS IE in "
|
DBG_8723A("STA included WPS IE in (Re)Association "
|
||||||
"(Re)Association Request - WPS is "
|
"Request - WPS is used\n");
|
||||||
"used\n");
|
|
||||||
pstat->flags |= WLAN_STA_WPS;
|
pstat->flags |= WLAN_STA_WPS;
|
||||||
copy_len = 0;
|
copy_len = 0;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1399,7 +1401,6 @@ OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
|
||||||
|
|
||||||
if (copy_len > 0)
|
if (copy_len > 0)
|
||||||
memcpy(pstat->wpa_ie, wpa_ie - 2, copy_len);
|
memcpy(pstat->wpa_ie, wpa_ie - 2, copy_len);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check if there is WMM IE & support WWM-PS */
|
/* check if there is WMM IE & support WWM-PS */
|
||||||
|
|
Loading…
Reference in a new issue