staging: rtl8192e: Replace struct rtllib_hdr_4addr in rtllib_crypt*.c
authorPhilipp Hortmann <philipp.g.hortmann@gmail.com>
Fri, 15 Sep 2023 16:07:43 +0000 (18:07 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 17 Sep 2023 07:47:56 +0000 (09:47 +0200)
Replace struct rtllib_hdr_4addr with struct ieee80211_hdr to avoid
proprietary code in rtllib_crypt_tkip.c and rtllib_crypt_ccmp.c.

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

index f88096bcb18152d37db59e1e7fbcc9990b540e5c..8e4514cc132c52dc1e25cfc5437e7c4cbaff9e83 100644 (file)
@@ -83,7 +83,7 @@ static void rtllib_ccmp_deinit(void *priv)
        kfree(priv);
 }
 
-static int ccmp_init_iv_and_aad(struct rtllib_hdr_4addr *hdr,
+static int ccmp_init_iv_and_aad(struct ieee80211_hdr *hdr,
                                u8 *pn, u8 *iv, u8 *aad)
 {
        u8 *pos, qc = 0;
@@ -91,7 +91,7 @@ static int ccmp_init_iv_and_aad(struct rtllib_hdr_4addr *hdr,
        u16 fc;
        int a4_included, qc_included;
 
-       fc = le16_to_cpu(hdr->frame_ctl);
+       fc = le16_to_cpu(hdr->frame_control);
        a4_included = ((fc & (RTLLIB_FCTL_TODS | RTLLIB_FCTL_FROMDS)) ==
                       (RTLLIB_FCTL_TODS | RTLLIB_FCTL_FROMDS));
 
@@ -134,7 +134,7 @@ static int ccmp_init_iv_and_aad(struct rtllib_hdr_4addr *hdr,
        memcpy(&aad[2], &hdr->addr1, ETH_ALEN);
        memcpy(&aad[8], &hdr->addr2, ETH_ALEN);
        memcpy(&aad[14], &hdr->addr3, ETH_ALEN);
-       pos = (u8 *)&hdr->seq_ctl;
+       pos = (u8 *)&hdr->seq_ctrl;
        aad[20] = pos[0] & 0x0f;
        aad[21] = 0; /* all bits masked */
        memset(aad + 22, 0, 8);
@@ -153,7 +153,7 @@ static int rtllib_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
        struct rtllib_ccmp_data *key = priv;
        int i;
        u8 *pos;
-       struct rtllib_hdr_4addr *hdr;
+       struct ieee80211_hdr *hdr;
        struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb +
                                    MAX_DEV_ADDR_SIZE);
        if (skb_headroom(skb) < CCMP_HDR_LEN ||
@@ -182,7 +182,7 @@ static int rtllib_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
        *pos++ = key->tx_pn[1];
        *pos++ = key->tx_pn[0];
 
-       hdr = (struct rtllib_hdr_4addr *)skb->data;
+       hdr = (struct ieee80211_hdr *)skb->data;
        if (!tcb_desc->bHwSec) {
                struct aead_request *req;
                struct scatterlist sg[2];
@@ -220,7 +220,7 @@ static int rtllib_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
 {
        struct rtllib_ccmp_data *key = priv;
        u8 keyidx, *pos;
-       struct rtllib_hdr_4addr *hdr;
+       struct ieee80211_hdr *hdr;
        struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb +
                                    MAX_DEV_ADDR_SIZE);
        u8 pn[6];
@@ -230,7 +230,7 @@ static int rtllib_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
                return -1;
        }
 
-       hdr = (struct rtllib_hdr_4addr *)skb->data;
+       hdr = (struct ieee80211_hdr *)skb->data;
        pos = skb->data + hdr_len;
        keyidx = pos[3];
        if (!(keyidx & (1 << 5))) {
index 9fdfcc017ee69a08f3c4520b0699d8745d6619af..b7f9ea0e4f5187b9756e20f4648ceb321586d368 100644 (file)
@@ -255,7 +255,7 @@ static int rtllib_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
        struct rtllib_tkip_data *tkey = priv;
        int len;
        u8 *pos;
-       struct rtllib_hdr_4addr *hdr;
+       struct ieee80211_hdr *hdr;
        struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb +
                                    MAX_DEV_ADDR_SIZE);
        int ret = 0;
@@ -266,7 +266,7 @@ static int rtllib_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
            skb->len < hdr_len)
                return -1;
 
-       hdr = (struct rtllib_hdr_4addr *)skb->data;
+       hdr = (struct ieee80211_hdr *)skb->data;
 
        if (!tcb_desc->bHwSec) {
                if (!tkey->tx_phase1_done) {
@@ -330,7 +330,7 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
        u8 keyidx, *pos;
        u32 iv32;
        u16 iv16;
-       struct rtllib_hdr_4addr *hdr;
+       struct ieee80211_hdr *hdr;
        struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb +
                                    MAX_DEV_ADDR_SIZE);
        u8 rc4key[16];
@@ -341,7 +341,7 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
        if (skb->len < hdr_len + 8 + 4)
                return -1;
 
-       hdr = (struct rtllib_hdr_4addr *)skb->data;
+       hdr = (struct ieee80211_hdr *)skb->data;
        pos = skb->data + hdr_len;
        keyidx = pos[3];
        if (!(keyidx & (1 << 5))) {
@@ -465,10 +465,10 @@ out:
 
 static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr)
 {
-       struct rtllib_hdr_4addr *hdr11;
+       struct ieee80211_hdr *hdr11;
 
-       hdr11 = (struct rtllib_hdr_4addr *)skb->data;
-       switch (le16_to_cpu(hdr11->frame_ctl) &
+       hdr11 = (struct ieee80211_hdr *)skb->data;
+       switch (le16_to_cpu(hdr11->frame_control) &
                (RTLLIB_FCTL_FROMDS | RTLLIB_FCTL_TODS)) {
        case RTLLIB_FCTL_TODS:
                ether_addr_copy(hdr, hdr11->addr3); /* DA */
@@ -501,9 +501,9 @@ static int rtllib_michael_mic_add(struct sk_buff *skb, int hdr_len, void *priv)
 {
        struct rtllib_tkip_data *tkey = priv;
        u8 *pos;
-       struct rtllib_hdr_4addr *hdr;
+       struct ieee80211_hdr *hdr;
 
-       hdr = (struct rtllib_hdr_4addr *)skb->data;
+       hdr = (struct ieee80211_hdr *)skb->data;
 
        if (skb_tailroom(skb) < 8 || skb->len < hdr_len) {
                netdev_dbg(skb->dev,
@@ -514,7 +514,7 @@ static int rtllib_michael_mic_add(struct sk_buff *skb, int hdr_len, void *priv)
 
        michael_mic_hdr(skb, tkey->tx_hdr);
 
-       if (RTLLIB_QOS_HAS_SEQ(le16_to_cpu(hdr->frame_ctl)))
+       if (RTLLIB_QOS_HAS_SEQ(le16_to_cpu(hdr->frame_control)))
                tkey->tx_hdr[12] = *(skb->data + hdr_len - 2) & 0x07;
        pos = skb_put(skb, 8);
        if (michael_mic(tkey->tx_tfm_michael, &tkey->key[16], tkey->tx_hdr,
@@ -525,7 +525,7 @@ static int rtllib_michael_mic_add(struct sk_buff *skb, int hdr_len, void *priv)
 }
 
 static void rtllib_michael_mic_failure(struct net_device *dev,
-                                      struct rtllib_hdr_4addr *hdr,
+                                      struct ieee80211_hdr *hdr,
                                       int keyidx)
 {
        union iwreq_data wrqu;
@@ -550,15 +550,15 @@ static int rtllib_michael_mic_verify(struct sk_buff *skb, int keyidx,
 {
        struct rtllib_tkip_data *tkey = priv;
        u8 mic[8];
-       struct rtllib_hdr_4addr *hdr;
+       struct ieee80211_hdr *hdr;
 
-       hdr = (struct rtllib_hdr_4addr *)skb->data;
+       hdr = (struct ieee80211_hdr *)skb->data;
 
        if (!tkey->key_set)
                return -1;
 
        michael_mic_hdr(skb, tkey->rx_hdr);
-       if (RTLLIB_QOS_HAS_SEQ(le16_to_cpu(hdr->frame_ctl)))
+       if (RTLLIB_QOS_HAS_SEQ(le16_to_cpu(hdr->frame_control)))
                tkey->rx_hdr[12] = *(skb->data + hdr_len - 2) & 0x07;
 
        if (michael_mic(tkey->rx_tfm_michael, &tkey->key[24], tkey->rx_hdr,
@@ -566,9 +566,9 @@ static int rtllib_michael_mic_verify(struct sk_buff *skb, int keyidx,
                return -1;
 
        if (memcmp(mic, skb->data + skb->len - 8, 8) != 0) {
-               struct rtllib_hdr_4addr *hdr;
+               struct ieee80211_hdr *hdr;
 
-               hdr = (struct rtllib_hdr_4addr *)skb->data;
+               hdr = (struct ieee80211_hdr *)skb->data;
                netdev_dbg(skb->dev,
                           "Michael MIC verification failed for MSDU from %pM keyidx=%d\n",
                           hdr->addr2, keyidx);