staging: r8188eu: use ieee80211 helpers in validate_recv_mgnt_frame
authorMartin Kaiser <martin@kaiser.cx>
Sun, 3 Apr 2022 16:38:18 +0000 (18:38 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 4 Apr 2022 14:30:55 +0000 (16:30 +0200)
Use the ieee80211 helpers to detect the frame subtype in
and to parse mac addresses in validate_recv_mgnt_frame.

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
Link: https://lore.kernel.org/r/20220403163818.357173-3-martin@kaiser.cx
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/r8188eu/core/rtw_recv.c

index 8fa07d3..1a79c3f 100644 (file)
@@ -915,24 +915,24 @@ static void validate_recv_mgnt_frame(struct adapter *padapter,
                                     struct recv_frame *precv_frame)
 {
        struct sta_info *psta;
+       struct ieee80211_hdr *hdr;
 
        precv_frame = recvframe_chk_defrag(padapter, precv_frame);
        if (!precv_frame)
                return;
 
-       /* for rx pkt statistics */
-       psta = rtw_get_stainfo(&padapter->stapriv, GetAddr2Ptr(precv_frame->rx_data));
+       hdr = (struct ieee80211_hdr *)precv_frame->rx_data;
+       psta = rtw_get_stainfo(&padapter->stapriv, hdr->addr2);
        if (psta) {
                psta->sta_stats.rx_mgnt_pkts++;
-               if (GetFrameSubType(precv_frame->rx_data) == WIFI_BEACON) {
+               if (ieee80211_is_beacon(hdr->frame_control))
                        psta->sta_stats.rx_beacon_pkts++;
-               } else if (GetFrameSubType(precv_frame->rx_data) == WIFI_PROBEREQ) {
+               else if (ieee80211_is_probe_req(hdr->frame_control))
                        psta->sta_stats.rx_probereq_pkts++;
-               } else if (GetFrameSubType(precv_frame->rx_data) == WIFI_PROBERSP) {
-                       if (!memcmp(padapter->eeprompriv.mac_addr, GetAddr1Ptr(precv_frame->rx_data), ETH_ALEN))
+               else if (ieee80211_is_probe_resp(hdr->frame_control)) {
+                       if (!memcmp(padapter->eeprompriv.mac_addr, hdr->addr1, ETH_ALEN))
                                psta->sta_stats.rx_probersp_pkts++;
-                       else if (is_broadcast_mac_addr(GetAddr1Ptr(precv_frame->rx_data)) ||
-                                is_multicast_mac_addr(GetAddr1Ptr(precv_frame->rx_data)))
+                       else if (is_broadcast_mac_addr(hdr->addr1) || is_multicast_mac_addr(hdr->addr1))
                                psta->sta_stats.rx_probersp_bm_pkts++;
                        else
                                psta->sta_stats.rx_probersp_uo_pkts++;