staging: rtl8723au: Make rtw_check_bcn_info23() take a ieee80211_mgmt pointer
authorJes Sorensen <Jes.Sorensen@redhat.com>
Tue, 15 Apr 2014 17:43:58 +0000 (19:43 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 15 Apr 2014 18:04:00 +0000 (11:04 -0700)
Clean up the code by passing a struct ieee80211_mgmt pointer instead
of a raw frame pointer. In addition check we receive a beacon frame,
anything else here is an error.

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
drivers/staging/rtl8723au/core/rtw_wlan_util.c
drivers/staging/rtl8723au/include/rtw_mlme_ext.h

index f810d8f8e3848b5d480c64a18550490495769dcf..a79861e4250cd4845face6259d9991f5db240b0f 100644 (file)
@@ -795,7 +795,7 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
                    (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) {
                        psta = rtw_get_stainfo23a(pstapriv, mgmt->sa);
                        if (psta) {
-                               ret = rtw_check_bcn_info23a(padapter, pframe,
+                               ret = rtw_check_bcn_info23a(padapter, mgmt,
                                                            pkt_len);
                                if (!ret) {
                                        DBG_8723A_LEVEL(_drv_always_,
index 17e32071b51404e842252e6897dff92bf4fede1f..ac9d39a7c4f4e578180800087cc5c77e64ea72a1 100644 (file)
@@ -856,7 +856,8 @@ void VCS_update23a(struct rtw_adapter *padapter, struct sta_info *psta)
        }
 }
 
-int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, u8 *pframe, u32 packet_len)
+int rtw_check_bcn_info23a(struct rtw_adapter *Adapter,
+                         struct ieee80211_mgmt *mgmt, u32 packet_len)
 {
        unsigned int            len;
        unsigned char           *p;
@@ -874,12 +875,16 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, u8 *pframe, u32 packet_le
        u32 bcn_channel;
        unsigned short  ht_cap_info;
        unsigned char   ht_info_infos_0;
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) pframe;
-       u8 *pbssid = hdr->addr3;
 
        if (is_client_associated_to_ap23a(Adapter) == false)
                return true;
 
+       if (unlikely(!ieee80211_is_beacon(mgmt->frame_control))) {
+               printk(KERN_WARNING "%s: received a non beacon frame!\n",
+                      __func__);
+               return false;
+       }
+
        len = packet_len - sizeof(struct ieee80211_hdr_3addr);
 
        if (len > MAX_IE_SZ) {
@@ -887,23 +892,24 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, u8 *pframe, u32 packet_le
                return _FAIL;
        }
 
-       if (memcmp(cur_network->network.MacAddress, pbssid, 6)) {
-               DBG_8723A("Oops: rtw_check_network_encrypt linked but recv other bssid bcn\n" MAC_FMT MAC_FMT,
-                               MAC_ARG(pbssid), MAC_ARG(cur_network->network.MacAddress));
+       if (memcmp(cur_network->network.MacAddress, mgmt->bssid, 6)) {
+               DBG_8723A("Oops: rtw_check_network_encrypt linked but recv "
+                         "other bssid bcn\n" MAC_FMT MAC_FMT,
+                         MAC_ARG(mgmt->bssid),
+                         MAC_ARG(cur_network->network.MacAddress));
                return true;
        }
 
        bssid = (struct wlan_bssid_ex *)kzalloc(sizeof(struct wlan_bssid_ex),
                GFP_ATOMIC);
 
-       if (ieee80211_is_beacon(hdr->frame_control))
-               bssid->reserved = 1;
+       bssid->reserved = 1;
 
        bssid->Length = sizeof(struct wlan_bssid_ex) - MAX_IE_SZ + len;
 
        /* below is to copy the information element */
        bssid->IELength = len;
-       memcpy(bssid->IEs, (pframe + sizeof(struct ieee80211_hdr_3addr)), bssid->IELength);
+       memcpy(bssid->IEs, &mgmt->u, bssid->IELength);
 
        /* check bw and channel offset */
        /* parsing HT_CAP_IE */
index 7f1cef124ee806ac32e76d8c5256a5713b161957..275f891b6c641f717ea889896c99e44f9ac58185 100644 (file)
@@ -533,7 +533,8 @@ void VCS_update23a(struct rtw_adapter *padapter, struct sta_info *psta);
 
 void update_beacon23a_info(struct rtw_adapter *padapter, u8 *pframe, uint len,
                        struct sta_info *psta);
-int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, u8 *pframe, u32 packet_len);
+int rtw_check_bcn_info23a(struct rtw_adapter *Adapter,
+                         struct ieee80211_mgmt *mgmt, u32 packet_len);
 void update_IOT_info23a(struct rtw_adapter *padapter);
 void update_capinfo23a(struct rtw_adapter *Adapter, u16 updateCap);
 void update_wireless_mode23a(struct rtw_adapter * padapter);