]> err.no Git - linux-2.6/blobdiff - net/mac80211/wpa.c
mac80211: fix cfg80211 hooks for master interface
[linux-2.6] / net / mac80211 / wpa.c
index 241c932d3b6ce6342a6653ea27a3da4c2e1373c8..2f33df0dcccfb0f3a04b993d8d134bf7dbde45a9 100644 (file)
@@ -28,19 +28,16 @@ ieee80211_tx_h_michael_mic_add(struct ieee80211_tx_data *tx)
        size_t data_len;
        unsigned int hdrlen;
        struct ieee80211_hdr *hdr;
-       u16 fc;
        struct sk_buff *skb = tx->skb;
        int authenticator;
        int wpa_test = 0;
        int tail;
 
-       fc = tx->fc;
-
+       hdr = (struct ieee80211_hdr *)skb->data;
        if (!tx->key || tx->key->conf.alg != ALG_TKIP || skb->len < 24 ||
-           !WLAN_FC_DATA_PRESENT(fc))
+           !ieee80211_is_data_present(hdr->frame_control))
                return TX_CONTINUE;
 
-       hdr = (struct ieee80211_hdr *)skb->data;
        hdrlen = ieee80211_hdrlen(hdr->frame_control);
        if (skb->len < hdrlen)
                return TX_DROP;
@@ -90,25 +87,23 @@ ieee80211_rx_h_michael_mic_verify(struct ieee80211_rx_data *rx)
        size_t data_len;
        unsigned int hdrlen;
        struct ieee80211_hdr *hdr;
-       u16 fc;
        u8 mic[MICHAEL_MIC_LEN];
        struct sk_buff *skb = rx->skb;
        int authenticator = 1, wpa_test = 0;
        DECLARE_MAC_BUF(mac);
 
-       fc = rx->fc;
-
        /*
         * No way to verify the MIC if the hardware stripped it
         */
        if (rx->status->flag & RX_FLAG_MMIC_STRIPPED)
                return RX_CONTINUE;
 
+       hdr = (struct ieee80211_hdr *)skb->data;
        if (!rx->key || rx->key->conf.alg != ALG_TKIP ||
-           !(rx->fc & IEEE80211_FCTL_PROTECTED) || !WLAN_FC_DATA_PRESENT(fc))
+           !ieee80211_has_protected(hdr->frame_control) ||
+           !ieee80211_is_data_present(hdr->frame_control))
                return RX_CONTINUE;
 
-       hdr = (struct ieee80211_hdr *)skb->data;
        hdrlen = ieee80211_hdrlen(hdr->frame_control);
        if (skb->len < hdrlen + MICHAEL_MIC_LEN)
                return RX_DROP_UNUSABLE;
@@ -239,7 +234,7 @@ ieee80211_crypto_tkip_decrypt(struct ieee80211_rx_data *rx)
 
        hdrlen = ieee80211_hdrlen(hdr->frame_control);
 
-       if ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA)
+       if (!ieee80211_is_data(hdr->frame_control))
                return RX_CONTINUE;
 
        if (!rx->sta || skb->len - hdrlen < 12)
@@ -279,16 +274,20 @@ ieee80211_crypto_tkip_decrypt(struct ieee80211_rx_data *rx)
 }
 
 
-static void ccmp_special_blocks(struct sk_buff *skb, u8 *pn, u8 *b_0, u8 *aad,
+static void ccmp_special_blocks(struct sk_buff *skb, u8 *pn, u8 *scratch,
                                int encrypted)
 {
        __le16 mask_fc;
        int a4_included;
        u8 qos_tid;
+       u8 *b_0, *aad;
        u16 data_len, len_a;
        unsigned int hdrlen;
        struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
 
+       b_0 = scratch + 3 * AES_BLOCK_LEN;
+       aad = scratch + 4 * AES_BLOCK_LEN;
+
        /*
         * Mask FC: zero subtype b4 b5 b6
         * Retry, PwrMgt, MoreData; set Protected
@@ -372,7 +371,7 @@ static int ccmp_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb)
        struct ieee80211_key *key = tx->key;
        struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
        int hdrlen, len, tail;
-       u8 *pos, *pn, *b_0, *aad, *scratch;
+       u8 *pos, *pn;
        int i;
 
        info->control.icv_len = CCMP_MIC_LEN;
@@ -386,10 +385,6 @@ static int ccmp_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb)
                return 0;
        }
 
-       scratch = key->u.ccmp.tx_crypto_buf;
-       b_0 = scratch + 3 * AES_BLOCK_LEN;
-       aad = scratch + 4 * AES_BLOCK_LEN;
-
        hdrlen = ieee80211_hdrlen(hdr->frame_control);
        len = skb->len - hdrlen;
 
@@ -425,8 +420,8 @@ static int ccmp_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb)
        }
 
        pos += CCMP_HDR_LEN;
-       ccmp_special_blocks(skb, pn, b_0, aad, 0);
-       ieee80211_aes_ccm_encrypt(key->u.ccmp.tfm, scratch, b_0, aad, pos, len,
+       ccmp_special_blocks(skb, pn, key->u.ccmp.tx_crypto_buf, 0);
+       ieee80211_aes_ccm_encrypt(key->u.ccmp.tfm, key->u.ccmp.tx_crypto_buf, pos, len,
                                  pos, skb_put(skb, CCMP_MIC_LEN));
 
        return 0;
@@ -458,7 +453,7 @@ ieee80211_crypto_ccmp_encrypt(struct ieee80211_tx_data *tx)
 ieee80211_rx_result
 ieee80211_crypto_ccmp_decrypt(struct ieee80211_rx_data *rx)
 {
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data;
+       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data;
        int hdrlen;
        struct ieee80211_key *key = rx->key;
        struct sk_buff *skb = rx->skb;
@@ -468,7 +463,7 @@ ieee80211_crypto_ccmp_decrypt(struct ieee80211_rx_data *rx)
 
        hdrlen = ieee80211_hdrlen(hdr->frame_control);
 
-       if ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA)
+       if (!ieee80211_is_data(hdr->frame_control))
                return RX_CONTINUE;
 
        data_len = skb->len - hdrlen - CCMP_HDR_LEN - CCMP_MIC_LEN;
@@ -488,16 +483,10 @@ ieee80211_crypto_ccmp_decrypt(struct ieee80211_rx_data *rx)
 
        if (!(rx->status->flag & RX_FLAG_DECRYPTED)) {
                /* hardware didn't decrypt/verify MIC */
-               u8 *scratch, *b_0, *aad;
-
-               scratch = key->u.ccmp.rx_crypto_buf;
-               b_0 = scratch + 3 * AES_BLOCK_LEN;
-               aad = scratch + 4 * AES_BLOCK_LEN;
-
-               ccmp_special_blocks(skb, pn, b_0, aad, 1);
+               ccmp_special_blocks(skb, pn, key->u.ccmp.rx_crypto_buf, 1);
 
                if (ieee80211_aes_ccm_decrypt(
-                           key->u.ccmp.tfm, scratch, b_0, aad,
+                           key->u.ccmp.tfm, key->u.ccmp.rx_crypto_buf,
                            skb->data + hdrlen + CCMP_HDR_LEN, data_len,
                            skb->data + skb->len - CCMP_MIC_LEN,
                            skb->data + hdrlen + CCMP_HDR_LEN)) {