staging: rtl8192e: Replace usage of RTLLIB_FCTL_DSTODS with function
authorPhilipp Hortmann <philipp.g.hortmann@gmail.com>
Fri, 15 Sep 2023 16:09:50 +0000 (18:09 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 17 Sep 2023 07:47:57 +0000 (09:47 +0200)
Replace usage of RTLLIB_FCTL_DSTODS with function ieee80211_has_a4() to
avoid proprietary code and to increase readability. To achieve this goal
it was required to change a parameter of function rtllib_rx_data_filter().

Signed-off-by: Philipp Hortmann <philipp.g.hortmann@gmail.com>
Link: https://lore.kernel.org/r/69f72a352b8129bcc6610c1355a41d966abf24d8.1694792595.git.philipp.g.hortmann@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8192e/rtllib.h
drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
drivers/staging/rtl8192e/rtllib_rx.c

index 47156eb8f46bbc38d12b4679a89d76dc7615d6c0..9179c3c14ab340c58c1d881a9cdbf475534c95bf 100644 (file)
@@ -338,7 +338,6 @@ enum rt_op_mode {
 #define RTLLIB_FCTL_FRAMETYPE  0x00fc
 #define RTLLIB_FCTL_TODS               0x0100
 #define RTLLIB_FCTL_FROMDS             0x0200
-#define RTLLIB_FCTL_DSTODS             0x0300
 #define RTLLIB_FCTL_MOREFRAGS  0x0400
 #define RTLLIB_FCTL_RETRY              0x0800
 #define RTLLIB_FCTL_PM         0x1000
index 8e4514cc132c52dc1e25cfc5437e7c4cbaff9e83..5621261d66b9b1d8387d6646531cc6307c112470 100644 (file)
@@ -92,8 +92,7 @@ static int ccmp_init_iv_and_aad(struct ieee80211_hdr *hdr,
        int a4_included, qc_included;
 
        fc = le16_to_cpu(hdr->frame_control);
-       a4_included = ((fc & (RTLLIB_FCTL_TODS | RTLLIB_FCTL_FROMDS)) ==
-                      (RTLLIB_FCTL_TODS | RTLLIB_FCTL_FROMDS));
+       a4_included = ieee80211_has_a4(hdr->frame_control);
 
        qc_included = ((WLAN_FC_GET_TYPE(fc) == RTLLIB_FTYPE_DATA) &&
                       (WLAN_FC_GET_STYPE(fc) & 0x80));
index 4d8c3869eb83553239df62838bdc4fc20426f9df..ef042dfd89cb29af12a8d04c0179b0696a9804b4 100644 (file)
@@ -97,7 +97,7 @@ rtllib_frag_cache_get(struct rtllib_device *ieee,
        struct ieee80211_qos_hdr_4addr *hdr_4addrqos;
        u8 tid;
 
-       if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS) &&
+       if (ieee80211_has_a4(hdr->frame_control) &&
            RTLLIB_QOS_HAS_SEQ(fc)) {
                hdr_4addrqos = (struct ieee80211_qos_hdr_4addr *)hdr;
                tid = le16_to_cpu(hdr_4addrqos->qos_ctrl) & RTLLIB_QCTL_TID;
@@ -166,7 +166,7 @@ static int rtllib_frag_cache_invalidate(struct rtllib_device *ieee,
        struct ieee80211_qos_hdr_4addr *hdr_4addrqos;
        u8 tid;
 
-       if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS) &&
+       if (ieee80211_has_a4(hdr->frame_control) &&
            RTLLIB_QOS_HAS_SEQ(fc)) {
                hdr_4addrqos = (struct ieee80211_qos_hdr_4addr *)hdr;
                tid = le16_to_cpu(hdr_4addrqos->qos_ctrl) & RTLLIB_QCTL_TID;
@@ -359,7 +359,7 @@ static int is_duplicate_packet(struct rtllib_device *ieee,
        struct ieee80211_qos_hdr_4addr *hdr_4addrqos;
        u8 tid;
 
-       if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS) &&
+       if (ieee80211_has_a4(header->frame_control) &&
            RTLLIB_QOS_HAS_SEQ(fc)) {
                hdr_4addrqos = (struct ieee80211_qos_hdr_4addr *)header;
                tid = le16_to_cpu(hdr_4addrqos->qos_ctrl) & RTLLIB_QCTL_TID;
@@ -968,16 +968,16 @@ static void rtllib_rx_extract_addr(struct rtllib_device *ieee,
        }
 }
 
-static int rtllib_rx_data_filter(struct rtllib_device *ieee, u16 fc,
+static int rtllib_rx_data_filter(struct rtllib_device *ieee, struct ieee80211_hdr *hdr,
                                 u8 *dst, u8 *src, u8 *bssid, u8 *addr2)
 {
        u8 type, stype;
-
+       u16 fc = le16_to_cpu(hdr->frame_control);
        type = WLAN_FC_GET_TYPE(fc);
        stype = WLAN_FC_GET_STYPE(fc);
 
        /* Filter frames from different BSS */
-       if (((fc & RTLLIB_FCTL_DSTODS) != RTLLIB_FCTL_DSTODS) &&
+       if (ieee80211_has_a4(hdr->frame_control) &&
            !ether_addr_equal(ieee->current_network.bssid, bssid) &&
            !is_zero_ether_addr(ieee->current_network.bssid)) {
                return -1;
@@ -1341,7 +1341,7 @@ static int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb,
        rtllib_rx_extract_addr(ieee, hdr, dst, src, bssid);
 
        /* Filter Data frames */
-       ret = rtllib_rx_data_filter(ieee, fc, dst, src, bssid, hdr->addr2);
+       ret = rtllib_rx_data_filter(ieee, hdr, dst, src, bssid, hdr->addr2);
        if (ret < 0)
                goto rx_dropped;