Commit d5184cac authored by Harvey Harrison's avatar Harvey Harrison Committed by John W. Linville

mac80211: wpa.c use new access helpers

Signed-off-by: default avatarHarvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 6693be71
...@@ -24,46 +24,22 @@ static int ieee80211_get_hdr_info(const struct sk_buff *skb, u8 **sa, u8 **da, ...@@ -24,46 +24,22 @@ static int ieee80211_get_hdr_info(const struct sk_buff *skb, u8 **sa, u8 **da,
{ {
struct ieee80211_hdr *hdr; struct ieee80211_hdr *hdr;
size_t hdrlen; size_t hdrlen;
u16 fc; __le16 fc;
int a4_included;
u8 *pos;
hdr = (struct ieee80211_hdr *) skb->data; hdr = (struct ieee80211_hdr *)skb->data;
fc = le16_to_cpu(hdr->frame_control); fc = hdr->frame_control;
hdrlen = 24;
if ((fc & (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) ==
(IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) {
hdrlen += ETH_ALEN;
*sa = hdr->addr4;
*da = hdr->addr3;
} else if (fc & IEEE80211_FCTL_FROMDS) {
*sa = hdr->addr3;
*da = hdr->addr1;
} else if (fc & IEEE80211_FCTL_TODS) {
*sa = hdr->addr2;
*da = hdr->addr3;
} else {
*sa = hdr->addr2;
*da = hdr->addr1;
}
if (fc & 0x80) hdrlen = ieee80211_hdrlen(fc);
hdrlen += 2;
*sa = ieee80211_get_SA(hdr);
*da = ieee80211_get_DA(hdr);
*data = skb->data + hdrlen; *data = skb->data + hdrlen;
*data_len = skb->len - hdrlen; *data_len = skb->len - hdrlen;
a4_included = (fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) == if (ieee80211_is_data_qos(fc))
(IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS); *qos_tid = (*ieee80211_get_qos_ctl(hdr) & 0x0f) | 0x80;
if ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA && else
fc & IEEE80211_STYPE_QOS_DATA) {
pos = (u8 *) &hdr->addr4;
if (a4_included)
pos += 6;
*qos_tid = pos[0] & 0x0f;
*qos_tid |= 0x80; /* qos_included flag */
} else
*qos_tid = 0; *qos_tid = 0;
return skb->len < hdrlen ? -1 : 0; return skb->len < hdrlen ? -1 : 0;
...@@ -186,8 +162,8 @@ static int tkip_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb) ...@@ -186,8 +162,8 @@ static int tkip_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb)
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
struct ieee80211_key *key = tx->key; struct ieee80211_key *key = tx->key;
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
int hdrlen, len, tail; unsigned int hdrlen;
u16 fc; int len, tail;
u8 *pos; u8 *pos;
info->control.icv_len = TKIP_ICV_LEN; info->control.icv_len = TKIP_ICV_LEN;
...@@ -200,8 +176,7 @@ static int tkip_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb) ...@@ -200,8 +176,7 @@ static int tkip_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb)
return 0; return 0;
} }
fc = le16_to_cpu(hdr->frame_control); hdrlen = ieee80211_hdrlen(hdr->frame_control);
hdrlen = ieee80211_get_hdrlen(fc);
len = skb->len - hdrlen; len = skb->len - hdrlen;
if (tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) if (tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)
...@@ -272,14 +247,12 @@ ieee80211_rx_result ...@@ -272,14 +247,12 @@ ieee80211_rx_result
ieee80211_crypto_tkip_decrypt(struct ieee80211_rx_data *rx) ieee80211_crypto_tkip_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;
u16 fc;
int hdrlen, res, hwaccel = 0, wpa_test = 0; int hdrlen, res, hwaccel = 0, wpa_test = 0;
struct ieee80211_key *key = rx->key; struct ieee80211_key *key = rx->key;
struct sk_buff *skb = rx->skb; struct sk_buff *skb = rx->skb;
DECLARE_MAC_BUF(mac); DECLARE_MAC_BUF(mac);
fc = le16_to_cpu(hdr->frame_control); hdrlen = ieee80211_hdrlen(hdr->frame_control);
hdrlen = ieee80211_get_hdrlen(fc);
if ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA) if ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA)
return RX_CONTINUE; return RX_CONTINUE;
...@@ -427,7 +400,6 @@ static int ccmp_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb) ...@@ -427,7 +400,6 @@ static int ccmp_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb)
struct ieee80211_key *key = tx->key; struct ieee80211_key *key = tx->key;
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
int hdrlen, len, tail; int hdrlen, len, tail;
u16 fc;
u8 *pos, *pn, *b_0, *aad, *scratch; u8 *pos, *pn, *b_0, *aad, *scratch;
int i; int i;
...@@ -446,8 +418,7 @@ static int ccmp_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb) ...@@ -446,8 +418,7 @@ static int ccmp_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb)
b_0 = scratch + 3 * AES_BLOCK_LEN; b_0 = scratch + 3 * AES_BLOCK_LEN;
aad = scratch + 4 * AES_BLOCK_LEN; aad = scratch + 4 * AES_BLOCK_LEN;
fc = le16_to_cpu(hdr->frame_control); hdrlen = ieee80211_hdrlen(hdr->frame_control);
hdrlen = ieee80211_get_hdrlen(fc);
len = skb->len - hdrlen; len = skb->len - hdrlen;
if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)
...@@ -516,7 +487,6 @@ ieee80211_rx_result ...@@ -516,7 +487,6 @@ ieee80211_rx_result
ieee80211_crypto_ccmp_decrypt(struct ieee80211_rx_data *rx) 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;
u16 fc;
int hdrlen; int hdrlen;
struct ieee80211_key *key = rx->key; struct ieee80211_key *key = rx->key;
struct sk_buff *skb = rx->skb; struct sk_buff *skb = rx->skb;
...@@ -524,8 +494,7 @@ ieee80211_crypto_ccmp_decrypt(struct ieee80211_rx_data *rx) ...@@ -524,8 +494,7 @@ ieee80211_crypto_ccmp_decrypt(struct ieee80211_rx_data *rx)
int data_len; int data_len;
DECLARE_MAC_BUF(mac); DECLARE_MAC_BUF(mac);
fc = le16_to_cpu(hdr->frame_control); hdrlen = ieee80211_hdrlen(hdr->frame_control);
hdrlen = ieee80211_get_hdrlen(fc);
if ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA) if ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA)
return RX_CONTINUE; return RX_CONTINUE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment