aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/wpa.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/mac80211/wpa.c')
-rw-r--r--net/mac80211/wpa.c63
1 files changed, 16 insertions, 47 deletions
diff --git a/net/mac80211/wpa.c b/net/mac80211/wpa.c
index 9f6fd20374e1..9834cecaca35 100644
--- a/net/mac80211/wpa.c
+++ b/net/mac80211/wpa.c
@@ -24,46 +24,22 @@ static int ieee80211_get_hdr_info(const struct sk_buff *skb, u8 **sa, u8 **da,
24{ 24{
25 struct ieee80211_hdr *hdr; 25 struct ieee80211_hdr *hdr;
26 size_t hdrlen; 26 size_t hdrlen;
27 u16 fc; 27 __le16 fc;
28 int a4_included;
29 u8 *pos;
30 28
31 hdr = (struct ieee80211_hdr *) skb->data; 29 hdr = (struct ieee80211_hdr *)skb->data;
32 fc = le16_to_cpu(hdr->frame_control); 30 fc = hdr->frame_control;
33
34 hdrlen = 24;
35 if ((fc & (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) ==
36 (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) {
37 hdrlen += ETH_ALEN;
38 *sa = hdr->addr4;
39 *da = hdr->addr3;
40 } else if (fc & IEEE80211_FCTL_FROMDS) {
41 *sa = hdr->addr3;
42 *da = hdr->addr1;
43 } else if (fc & IEEE80211_FCTL_TODS) {
44 *sa = hdr->addr2;
45 *da = hdr->addr3;
46 } else {
47 *sa = hdr->addr2;
48 *da = hdr->addr1;
49 }
50 31
51 if (fc & 0x80) 32 hdrlen = ieee80211_hdrlen(fc);
52 hdrlen += 2; 33
34 *sa = ieee80211_get_SA(hdr);
35 *da = ieee80211_get_DA(hdr);
53 36
54 *data = skb->data + hdrlen; 37 *data = skb->data + hdrlen;
55 *data_len = skb->len - hdrlen; 38 *data_len = skb->len - hdrlen;
56 39
57 a4_included = (fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) == 40 if (ieee80211_is_data_qos(fc))
58 (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS); 41 *qos_tid = (*ieee80211_get_qos_ctl(hdr) & 0x0f) | 0x80;
59 if ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA && 42 else
60 fc & IEEE80211_STYPE_QOS_DATA) {
61 pos = (u8 *) &hdr->addr4;
62 if (a4_included)
63 pos += 6;
64 *qos_tid = pos[0] & 0x0f;
65 *qos_tid |= 0x80; /* qos_included flag */
66 } else
67 *qos_tid = 0; 43 *qos_tid = 0;
68 44
69 return skb->len < hdrlen ? -1 : 0; 45 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 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 162 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
187 struct ieee80211_key *key = tx->key; 163 struct ieee80211_key *key = tx->key;
188 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 164 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
189 int hdrlen, len, tail; 165 unsigned int hdrlen;
190 u16 fc; 166 int len, tail;
191 u8 *pos; 167 u8 *pos;
192 168
193 info->control.icv_len = TKIP_ICV_LEN; 169 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 return 0; 176 return 0;
201 } 177 }
202 178
203 fc = le16_to_cpu(hdr->frame_control); 179 hdrlen = ieee80211_hdrlen(hdr->frame_control);
204 hdrlen = ieee80211_get_hdrlen(fc);
205 len = skb->len - hdrlen; 180 len = skb->len - hdrlen;
206 181
207 if (tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) 182 if (tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)
@@ -272,14 +247,12 @@ ieee80211_rx_result
272ieee80211_crypto_tkip_decrypt(struct ieee80211_rx_data *rx) 247ieee80211_crypto_tkip_decrypt(struct ieee80211_rx_data *rx)
273{ 248{
274 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data; 249 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data;
275 u16 fc;
276 int hdrlen, res, hwaccel = 0, wpa_test = 0; 250 int hdrlen, res, hwaccel = 0, wpa_test = 0;
277 struct ieee80211_key *key = rx->key; 251 struct ieee80211_key *key = rx->key;
278 struct sk_buff *skb = rx->skb; 252 struct sk_buff *skb = rx->skb;
279 DECLARE_MAC_BUF(mac); 253 DECLARE_MAC_BUF(mac);
280 254
281 fc = le16_to_cpu(hdr->frame_control); 255 hdrlen = ieee80211_hdrlen(hdr->frame_control);
282 hdrlen = ieee80211_get_hdrlen(fc);
283 256
284 if ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA) 257 if ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA)
285 return RX_CONTINUE; 258 return RX_CONTINUE;
@@ -427,7 +400,6 @@ static int ccmp_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb)
427 struct ieee80211_key *key = tx->key; 400 struct ieee80211_key *key = tx->key;
428 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 401 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
429 int hdrlen, len, tail; 402 int hdrlen, len, tail;
430 u16 fc;
431 u8 *pos, *pn, *b_0, *aad, *scratch; 403 u8 *pos, *pn, *b_0, *aad, *scratch;
432 int i; 404 int i;
433 405
@@ -446,8 +418,7 @@ static int ccmp_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb)
446 b_0 = scratch + 3 * AES_BLOCK_LEN; 418 b_0 = scratch + 3 * AES_BLOCK_LEN;
447 aad = scratch + 4 * AES_BLOCK_LEN; 419 aad = scratch + 4 * AES_BLOCK_LEN;
448 420
449 fc = le16_to_cpu(hdr->frame_control); 421 hdrlen = ieee80211_hdrlen(hdr->frame_control);
450 hdrlen = ieee80211_get_hdrlen(fc);
451 len = skb->len - hdrlen; 422 len = skb->len - hdrlen;
452 423
453 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) 424 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)
@@ -516,7 +487,6 @@ ieee80211_rx_result
516ieee80211_crypto_ccmp_decrypt(struct ieee80211_rx_data *rx) 487ieee80211_crypto_ccmp_decrypt(struct ieee80211_rx_data *rx)
517{ 488{
518 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data; 489 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data;
519 u16 fc;
520 int hdrlen; 490 int hdrlen;
521 struct ieee80211_key *key = rx->key; 491 struct ieee80211_key *key = rx->key;
522 struct sk_buff *skb = rx->skb; 492 struct sk_buff *skb = rx->skb;
@@ -524,8 +494,7 @@ ieee80211_crypto_ccmp_decrypt(struct ieee80211_rx_data *rx)
524 int data_len; 494 int data_len;
525 DECLARE_MAC_BUF(mac); 495 DECLARE_MAC_BUF(mac);
526 496
527 fc = le16_to_cpu(hdr->frame_control); 497 hdrlen = ieee80211_hdrlen(hdr->frame_control);
528 hdrlen = ieee80211_get_hdrlen(fc);
529 498
530 if ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA) 499 if ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA)
531 return RX_CONTINUE; 500 return RX_CONTINUE;