staging: rtl8723au: OnAuth23aClient23a(): Clean up using struct ieee80211_mgmt
authorJes Sorensen <Jes.Sorensen@redhat.com>
Tue, 15 Apr 2014 17:44:32 +0000 (19:44 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 15 Apr 2014 18:04:06 +0000 (11:04 -0700)
Use 80211_mgmt to determine offsets within the received frame. This
also removes a suspicious offset adjustment:

     offset = ieee80211_has_protected(hdr->frame_control) ? 4: 0;

which didn't make any sense, since it was only applied to determining
the auth, sequence number, and status, but wasn't applied to the
location of the IEs.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8723au/core/rtw_mlme_ext.c

index b5c1ab0..cfb4660 100644 (file)
@@ -1057,38 +1057,36 @@ auth_fail:
 static int
 OnAuth23aClient23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 {
-       unsigned int seq, status, algthm, offset;
+       unsigned int seq, status, algthm;
        unsigned int go2asoc = 0;
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
        struct sk_buff *skb = precv_frame->pkt;
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
-       const u8 *p, *pframe = skb->data;
-       int pkt_len = skb->len;
+       struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data;
+       const u8 *p;
+       u8 *pie;
+       int plen = skb->len;
 
        DBG_8723A("%s\n", __func__);
 
        /* check A1 matches or not */
-       if (!ether_addr_equal(myid(&padapter->eeprompriv),
-                             ieee80211_get_DA(hdr)))
+       if (!ether_addr_equal(myid(&padapter->eeprompriv), mgmt->da))
                return _SUCCESS;
 
        if (!(pmlmeinfo->state & WIFI_FW_AUTH_STATE))
                return _SUCCESS;
 
-       offset = ieee80211_has_protected(hdr->frame_control) ? 4: 0;
-
-       pframe += sizeof(struct ieee80211_hdr_3addr);
-       pkt_len -= sizeof(struct ieee80211_hdr_3addr);
+       pie = mgmt->u.auth.variable;
+       plen -= offsetof(struct ieee80211_mgmt, u.auth.variable);
 
-       algthm = le16_to_cpu(*(u16 *)(pframe + offset));
-       seq = le16_to_cpu(*(u16 *)(pframe + offset + 2));
-       status = le16_to_cpu(*(u16 *)(pframe + offset + 4));
+       algthm = le16_to_cpu(mgmt->u.auth.auth_alg);
+       seq = le16_to_cpu(mgmt->u.auth.auth_transaction);
+       status = le16_to_cpu(mgmt->u.auth.status_code);
 
        if (status) {
                DBG_8723A("clnt auth fail, status: %d\n", status);
                /*  pmlmeinfo->auth_algo == dot11AuthAlgrthm_Auto) */
-               if (status == 13) {
+               if (status == WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG) {
                        if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared)
                                pmlmeinfo->auth_algo = dot11AuthAlgrthm_Open;
                        else
@@ -1103,9 +1101,7 @@ OnAuth23aClient23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
        if (seq == 2) {
                if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) {
                        /*  legendary shared system */
-                       p = cfg80211_find_ie(WLAN_EID_CHALLENGE,
-                                            pframe + _AUTH_IE_OFFSET_,
-                                            pkt_len - _AUTH_IE_OFFSET_);
+                       p = cfg80211_find_ie(WLAN_EID_CHALLENGE, pie, plen);
 
                        if (!p) {
                                /* DBG_8723A("marc: no challenge text?\n"); */