staging: rtl8723au: OnProbeReq23a(): Use struct ieee80211_mgmt
authorJes Sorensen <Jes.Sorensen@redhat.com>
Tue, 15 Apr 2014 17:44:22 +0000 (19:44 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 15 Apr 2014 18:04:04 +0000 (11:04 -0700)
Simplify parsing of probe request frame

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 0277ee63db0e6917df827391ad01983d8cee2075..0264eda4bf62296e8a8bf8973276fa2ee11c433a 100644 (file)
@@ -667,9 +667,8 @@ OnProbeReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
        struct wlan_bssid_ex *cur = &pmlmeinfo->network;
        struct sk_buff *skb = precv_frame->pkt;
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
-       u8 *pframe = skb->data;
-       uint len = skb->len;
+       struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data;
+       int len = skb->len;
        u8 is_valid_p2p_probereq = false;
 
        if (check_fwstate(pmlmepriv, WIFI_STATION_STATE))
@@ -680,10 +679,15 @@ OnProbeReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
                           WIFI_ADHOC_MASTER_STATE | WIFI_AP_STATE))
                return _SUCCESS;
 
-       pframe += (sizeof(struct ieee80211_hdr_3addr) + _PROBEREQ_IE_OFFSET_);
-       len -= (sizeof(struct ieee80211_hdr_3addr) + _PROBEREQ_IE_OFFSET_);
+       if (unlikely(!ieee80211_is_probe_req(mgmt->frame_control))) {
+               printk(KERN_WARNING "%s: Received non probe request frame\n",
+                      __func__);
+               return _FAIL;
+       }
 
-       ie = cfg80211_find_ie(WLAN_EID_SSID, pframe, len);
+       len -= offsetof(struct ieee80211_mgmt, u.probe_req.variable);
+
+       ie = cfg80211_find_ie(WLAN_EID_SSID, mgmt->u.probe_req.variable, len);
 
        /* check (wildcard) SSID */
        if (!ie)
@@ -698,10 +702,8 @@ OnProbeReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
        }
 
        if (check_fwstate(pmlmepriv, _FW_LINKED) &&
-           pmlmepriv->cur_network.join_res) {
-               issue_probersp23a(padapter, ieee80211_get_SA(hdr),
-                                 is_valid_p2p_probereq);
-       }
+           pmlmepriv->cur_network.join_res)
+               issue_probersp23a(padapter, mgmt->sa, is_valid_p2p_probereq);
 
 out:
        return _SUCCESS;