aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/wpa.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2008-02-25 10:27:43 -0500
committerJohn W. Linville <linville@tuxdriver.com>2008-03-06 15:30:46 -0500
commit5cf121c3cdb955583bf0c5d28c992b7968a4aa1a (patch)
tree7bfd1a667f4703f3e6627d176b9a3f374c2db069 /net/mac80211/wpa.c
parent7495883bdd07e6a233f8a7f3d85c085c1618a203 (diff)
mac80211: split ieee80211_txrx_data
Split it into ieee80211_tx_data and ieee80211_rx_data to clarify usage/flag usage and remove the stupid union thing. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/wpa.c')
-rw-r--r--net/mac80211/wpa.c80
1 files changed, 40 insertions, 40 deletions
diff --git a/net/mac80211/wpa.c b/net/mac80211/wpa.c
index b35e51c6ce0c..df0b7341efc8 100644
--- a/net/mac80211/wpa.c
+++ b/net/mac80211/wpa.c
@@ -71,7 +71,7 @@ static int ieee80211_get_hdr_info(const struct sk_buff *skb, u8 **sa, u8 **da,
71 71
72 72
73ieee80211_tx_result 73ieee80211_tx_result
74ieee80211_tx_h_michael_mic_add(struct ieee80211_txrx_data *tx) 74ieee80211_tx_h_michael_mic_add(struct ieee80211_tx_data *tx)
75{ 75{
76 u8 *data, *sa, *da, *key, *mic, qos_tid; 76 u8 *data, *sa, *da, *key, *mic, qos_tid;
77 size_t data_len; 77 size_t data_len;
@@ -90,7 +90,7 @@ ieee80211_tx_h_michael_mic_add(struct ieee80211_txrx_data *tx)
90 return TX_DROP; 90 return TX_DROP;
91 91
92 if ((tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) && 92 if ((tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) &&
93 !(tx->flags & IEEE80211_TXRXD_FRAGMENTED) && 93 !(tx->flags & IEEE80211_TX_FRAGMENTED) &&
94 !(tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) && 94 !(tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) &&
95 !wpa_test) { 95 !wpa_test) {
96 /* hwaccel - with no need for preallocated room for Michael MIC 96 /* hwaccel - with no need for preallocated room for Michael MIC
@@ -124,7 +124,7 @@ ieee80211_tx_h_michael_mic_add(struct ieee80211_txrx_data *tx)
124 124
125 125
126ieee80211_rx_result 126ieee80211_rx_result
127ieee80211_rx_h_michael_mic_verify(struct ieee80211_txrx_data *rx) 127ieee80211_rx_h_michael_mic_verify(struct ieee80211_rx_data *rx)
128{ 128{
129 u8 *data, *sa, *da, *key = NULL, qos_tid; 129 u8 *data, *sa, *da, *key = NULL, qos_tid;
130 size_t data_len; 130 size_t data_len;
@@ -139,7 +139,7 @@ ieee80211_rx_h_michael_mic_verify(struct ieee80211_txrx_data *rx)
139 /* 139 /*
140 * No way to verify the MIC if the hardware stripped it 140 * No way to verify the MIC if the hardware stripped it
141 */ 141 */
142 if (rx->u.rx.status->flag & RX_FLAG_MMIC_STRIPPED) 142 if (rx->status->flag & RX_FLAG_MMIC_STRIPPED)
143 return RX_CONTINUE; 143 return RX_CONTINUE;
144 144
145 if (!rx->key || rx->key->conf.alg != ALG_TKIP || 145 if (!rx->key || rx->key->conf.alg != ALG_TKIP ||
@@ -161,7 +161,7 @@ ieee80211_rx_h_michael_mic_verify(struct ieee80211_txrx_data *rx)
161 ALG_TKIP_TEMP_AUTH_TX_MIC_KEY]; 161 ALG_TKIP_TEMP_AUTH_TX_MIC_KEY];
162 michael_mic(key, da, sa, qos_tid & 0x0f, data, data_len, mic); 162 michael_mic(key, da, sa, qos_tid & 0x0f, data, data_len, mic);
163 if (memcmp(mic, data + data_len, MICHAEL_MIC_LEN) != 0 || wpa_test) { 163 if (memcmp(mic, data + data_len, MICHAEL_MIC_LEN) != 0 || wpa_test) {
164 if (!(rx->flags & IEEE80211_TXRXD_RXRA_MATCH)) 164 if (!(rx->flags & IEEE80211_RX_RA_MATCH))
165 return RX_DROP_UNUSABLE; 165 return RX_DROP_UNUSABLE;
166 166
167 printk(KERN_DEBUG "%s: invalid Michael MIC in data frame from " 167 printk(KERN_DEBUG "%s: invalid Michael MIC in data frame from "
@@ -176,14 +176,14 @@ ieee80211_rx_h_michael_mic_verify(struct ieee80211_txrx_data *rx)
176 skb_trim(skb, skb->len - MICHAEL_MIC_LEN); 176 skb_trim(skb, skb->len - MICHAEL_MIC_LEN);
177 177
178 /* update IV in key information to be able to detect replays */ 178 /* update IV in key information to be able to detect replays */
179 rx->key->u.tkip.iv32_rx[rx->u.rx.queue] = rx->u.rx.tkip_iv32; 179 rx->key->u.tkip.iv32_rx[rx->queue] = rx->tkip_iv32;
180 rx->key->u.tkip.iv16_rx[rx->u.rx.queue] = rx->u.rx.tkip_iv16; 180 rx->key->u.tkip.iv16_rx[rx->queue] = rx->tkip_iv16;
181 181
182 return RX_CONTINUE; 182 return RX_CONTINUE;
183} 183}
184 184
185 185
186static int tkip_encrypt_skb(struct ieee80211_txrx_data *tx, 186static int tkip_encrypt_skb(struct ieee80211_tx_data *tx,
187 struct sk_buff *skb, int test) 187 struct sk_buff *skb, int test)
188{ 188{
189 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 189 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
@@ -228,7 +228,7 @@ static int tkip_encrypt_skb(struct ieee80211_txrx_data *tx,
228 0x7f), 228 0x7f),
229 (u8) key->u.tkip.iv16); 229 (u8) key->u.tkip.iv16);
230 230
231 tx->u.tx.control->key_idx = tx->key->conf.hw_key_idx; 231 tx->control->key_idx = tx->key->conf.hw_key_idx;
232 return 0; 232 return 0;
233 } 233 }
234 234
@@ -243,30 +243,30 @@ static int tkip_encrypt_skb(struct ieee80211_txrx_data *tx,
243 243
244 244
245ieee80211_tx_result 245ieee80211_tx_result
246ieee80211_crypto_tkip_encrypt(struct ieee80211_txrx_data *tx) 246ieee80211_crypto_tkip_encrypt(struct ieee80211_tx_data *tx)
247{ 247{
248 struct sk_buff *skb = tx->skb; 248 struct sk_buff *skb = tx->skb;
249 int wpa_test = 0, test = 0; 249 int wpa_test = 0, test = 0;
250 250
251 tx->u.tx.control->icv_len = TKIP_ICV_LEN; 251 tx->control->icv_len = TKIP_ICV_LEN;
252 tx->u.tx.control->iv_len = TKIP_IV_LEN; 252 tx->control->iv_len = TKIP_IV_LEN;
253 ieee80211_tx_set_iswep(tx); 253 ieee80211_tx_set_protected(tx);
254 254
255 if ((tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) && 255 if ((tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) &&
256 !(tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV) && 256 !(tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV) &&
257 !wpa_test) { 257 !wpa_test) {
258 /* hwaccel - with no need for preallocated room for IV/ICV */ 258 /* hwaccel - with no need for preallocated room for IV/ICV */
259 tx->u.tx.control->key_idx = tx->key->conf.hw_key_idx; 259 tx->control->key_idx = tx->key->conf.hw_key_idx;
260 return TX_CONTINUE; 260 return TX_CONTINUE;
261 } 261 }
262 262
263 if (tkip_encrypt_skb(tx, skb, test) < 0) 263 if (tkip_encrypt_skb(tx, skb, test) < 0)
264 return TX_DROP; 264 return TX_DROP;
265 265
266 if (tx->u.tx.extra_frag) { 266 if (tx->extra_frag) {
267 int i; 267 int i;
268 for (i = 0; i < tx->u.tx.num_extra_frag; i++) { 268 for (i = 0; i < tx->num_extra_frag; i++) {
269 if (tkip_encrypt_skb(tx, tx->u.tx.extra_frag[i], test) 269 if (tkip_encrypt_skb(tx, tx->extra_frag[i], test)
270 < 0) 270 < 0)
271 return TX_DROP; 271 return TX_DROP;
272 } 272 }
@@ -277,7 +277,7 @@ ieee80211_crypto_tkip_encrypt(struct ieee80211_txrx_data *tx)
277 277
278 278
279ieee80211_rx_result 279ieee80211_rx_result
280ieee80211_crypto_tkip_decrypt(struct ieee80211_txrx_data *rx) 280ieee80211_crypto_tkip_decrypt(struct ieee80211_rx_data *rx)
281{ 281{
282 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data; 282 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data;
283 u16 fc; 283 u16 fc;
@@ -295,8 +295,8 @@ ieee80211_crypto_tkip_decrypt(struct ieee80211_txrx_data *rx)
295 if (!rx->sta || skb->len - hdrlen < 12) 295 if (!rx->sta || skb->len - hdrlen < 12)
296 return RX_DROP_UNUSABLE; 296 return RX_DROP_UNUSABLE;
297 297
298 if (rx->u.rx.status->flag & RX_FLAG_DECRYPTED) { 298 if (rx->status->flag & RX_FLAG_DECRYPTED) {
299 if (rx->u.rx.status->flag & RX_FLAG_IV_STRIPPED) { 299 if (rx->status->flag & RX_FLAG_IV_STRIPPED) {
300 /* 300 /*
301 * Hardware took care of all processing, including 301 * Hardware took care of all processing, including
302 * replay protection, and stripped the ICV/IV so 302 * replay protection, and stripped the ICV/IV so
@@ -312,9 +312,9 @@ ieee80211_crypto_tkip_decrypt(struct ieee80211_txrx_data *rx)
312 res = ieee80211_tkip_decrypt_data(rx->local->wep_rx_tfm, 312 res = ieee80211_tkip_decrypt_data(rx->local->wep_rx_tfm,
313 key, skb->data + hdrlen, 313 key, skb->data + hdrlen,
314 skb->len - hdrlen, rx->sta->addr, 314 skb->len - hdrlen, rx->sta->addr,
315 hwaccel, rx->u.rx.queue, 315 hwaccel, rx->queue,
316 &rx->u.rx.tkip_iv32, 316 &rx->tkip_iv32,
317 &rx->u.rx.tkip_iv16); 317 &rx->tkip_iv16);
318 if (res != TKIP_DECRYPT_OK || wpa_test) { 318 if (res != TKIP_DECRYPT_OK || wpa_test) {
319#ifdef CONFIG_MAC80211_DEBUG 319#ifdef CONFIG_MAC80211_DEBUG
320 if (net_ratelimit()) 320 if (net_ratelimit())
@@ -429,7 +429,7 @@ static inline int ccmp_hdr2pn(u8 *pn, u8 *hdr)
429} 429}
430 430
431 431
432static int ccmp_encrypt_skb(struct ieee80211_txrx_data *tx, 432static int ccmp_encrypt_skb(struct ieee80211_tx_data *tx,
433 struct sk_buff *skb, int test) 433 struct sk_buff *skb, int test)
434{ 434{
435 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 435 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
@@ -478,7 +478,7 @@ static int ccmp_encrypt_skb(struct ieee80211_txrx_data *tx,
478 478
479 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) { 479 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) {
480 /* hwaccel - with preallocated room for CCMP header */ 480 /* hwaccel - with preallocated room for CCMP header */
481 tx->u.tx.control->key_idx = key->conf.hw_key_idx; 481 tx->control->key_idx = key->conf.hw_key_idx;
482 return 0; 482 return 0;
483 } 483 }
484 484
@@ -492,30 +492,30 @@ static int ccmp_encrypt_skb(struct ieee80211_txrx_data *tx,
492 492
493 493
494ieee80211_tx_result 494ieee80211_tx_result
495ieee80211_crypto_ccmp_encrypt(struct ieee80211_txrx_data *tx) 495ieee80211_crypto_ccmp_encrypt(struct ieee80211_tx_data *tx)
496{ 496{
497 struct sk_buff *skb = tx->skb; 497 struct sk_buff *skb = tx->skb;
498 int test = 0; 498 int test = 0;
499 499
500 tx->u.tx.control->icv_len = CCMP_MIC_LEN; 500 tx->control->icv_len = CCMP_MIC_LEN;
501 tx->u.tx.control->iv_len = CCMP_HDR_LEN; 501 tx->control->iv_len = CCMP_HDR_LEN;
502 ieee80211_tx_set_iswep(tx); 502 ieee80211_tx_set_protected(tx);
503 503
504 if ((tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) && 504 if ((tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) &&
505 !(tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) { 505 !(tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) {
506 /* hwaccel - with no need for preallocated room for CCMP " 506 /* hwaccel - with no need for preallocated room for CCMP "
507 * header or MIC fields */ 507 * header or MIC fields */
508 tx->u.tx.control->key_idx = tx->key->conf.hw_key_idx; 508 tx->control->key_idx = tx->key->conf.hw_key_idx;
509 return TX_CONTINUE; 509 return TX_CONTINUE;
510 } 510 }
511 511
512 if (ccmp_encrypt_skb(tx, skb, test) < 0) 512 if (ccmp_encrypt_skb(tx, skb, test) < 0)
513 return TX_DROP; 513 return TX_DROP;
514 514
515 if (tx->u.tx.extra_frag) { 515 if (tx->extra_frag) {
516 int i; 516 int i;
517 for (i = 0; i < tx->u.tx.num_extra_frag; i++) { 517 for (i = 0; i < tx->num_extra_frag; i++) {
518 if (ccmp_encrypt_skb(tx, tx->u.tx.extra_frag[i], test) 518 if (ccmp_encrypt_skb(tx, tx->extra_frag[i], test)
519 < 0) 519 < 0)
520 return TX_DROP; 520 return TX_DROP;
521 } 521 }
@@ -526,7 +526,7 @@ ieee80211_crypto_ccmp_encrypt(struct ieee80211_txrx_data *tx)
526 526
527 527
528ieee80211_rx_result 528ieee80211_rx_result
529ieee80211_crypto_ccmp_decrypt(struct ieee80211_txrx_data *rx) 529ieee80211_crypto_ccmp_decrypt(struct ieee80211_rx_data *rx)
530{ 530{
531 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data; 531 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data;
532 u16 fc; 532 u16 fc;
@@ -547,15 +547,15 @@ ieee80211_crypto_ccmp_decrypt(struct ieee80211_txrx_data *rx)
547 if (!rx->sta || data_len < 0) 547 if (!rx->sta || data_len < 0)
548 return RX_DROP_UNUSABLE; 548 return RX_DROP_UNUSABLE;
549 549
550 if ((rx->u.rx.status->flag & RX_FLAG_DECRYPTED) && 550 if ((rx->status->flag & RX_FLAG_DECRYPTED) &&
551 (rx->u.rx.status->flag & RX_FLAG_IV_STRIPPED)) 551 (rx->status->flag & RX_FLAG_IV_STRIPPED))
552 return RX_CONTINUE; 552 return RX_CONTINUE;
553 553
554 (void) ccmp_hdr2pn(pn, skb->data + hdrlen); 554 (void) ccmp_hdr2pn(pn, skb->data + hdrlen);
555 555
556 if (memcmp(pn, key->u.ccmp.rx_pn[rx->u.rx.queue], CCMP_PN_LEN) <= 0) { 556 if (memcmp(pn, key->u.ccmp.rx_pn[rx->queue], CCMP_PN_LEN) <= 0) {
557#ifdef CONFIG_MAC80211_DEBUG 557#ifdef CONFIG_MAC80211_DEBUG
558 u8 *ppn = key->u.ccmp.rx_pn[rx->u.rx.queue]; 558 u8 *ppn = key->u.ccmp.rx_pn[rx->queue];
559 559
560 printk(KERN_DEBUG "%s: CCMP replay detected for RX frame from " 560 printk(KERN_DEBUG "%s: CCMP replay detected for RX frame from "
561 "%s (RX PN %02x%02x%02x%02x%02x%02x <= prev. PN " 561 "%s (RX PN %02x%02x%02x%02x%02x%02x <= prev. PN "
@@ -568,7 +568,7 @@ ieee80211_crypto_ccmp_decrypt(struct ieee80211_txrx_data *rx)
568 return RX_DROP_UNUSABLE; 568 return RX_DROP_UNUSABLE;
569 } 569 }
570 570
571 if (!(rx->u.rx.status->flag & RX_FLAG_DECRYPTED)) { 571 if (!(rx->status->flag & RX_FLAG_DECRYPTED)) {
572 /* hardware didn't decrypt/verify MIC */ 572 /* hardware didn't decrypt/verify MIC */
573 u8 *scratch, *b_0, *aad; 573 u8 *scratch, *b_0, *aad;
574 574
@@ -593,7 +593,7 @@ ieee80211_crypto_ccmp_decrypt(struct ieee80211_txrx_data *rx)
593 } 593 }
594 } 594 }
595 595
596 memcpy(key->u.ccmp.rx_pn[rx->u.rx.queue], pn, CCMP_PN_LEN); 596 memcpy(key->u.ccmp.rx_pn[rx->queue], pn, CCMP_PN_LEN);
597 597
598 /* Remove CCMP header and MIC */ 598 /* Remove CCMP header and MIC */
599 skb_trim(skb, skb->len - CCMP_MIC_LEN); 599 skb_trim(skb, skb->len - CCMP_MIC_LEN);