aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/wep.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2007-09-26 09:19:41 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:53:14 -0400
commit6a22a59d487e7fe509b457b72497593e402911c0 (patch)
treea4bfd02cdea7e1cec690101bc119b515f3dc445c /net/mac80211/wep.c
parent4f0d18e26f8bc4c6507b69aa0080d0fae807c990 (diff)
[PATCH] mac80211: consolidate encryption
Currently we run through all crypto handlers for each transmitted frame although we already know which one will be used. This changes the code to invoke only the needed handler. It also moves the wep code into wep.c. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/wep.c')
-rw-r--r--net/mac80211/wep.c57
1 files changed, 54 insertions, 3 deletions
diff --git a/net/mac80211/wep.c b/net/mac80211/wep.c
index e785fe1f78ed..16fee142f984 100644
--- a/net/mac80211/wep.c
+++ b/net/mac80211/wep.c
@@ -80,9 +80,9 @@ static void ieee80211_wep_get_iv(struct ieee80211_local *local,
80} 80}
81 81
82 82
83u8 * ieee80211_wep_add_iv(struct ieee80211_local *local, 83static u8 *ieee80211_wep_add_iv(struct ieee80211_local *local,
84 struct sk_buff *skb, 84 struct sk_buff *skb,
85 struct ieee80211_key *key) 85 struct ieee80211_key *key)
86{ 86{
87 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 87 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
88 u16 fc; 88 u16 fc;
@@ -350,3 +350,54 @@ ieee80211_crypto_wep_decrypt(struct ieee80211_txrx_data *rx)
350 350
351 return TXRX_CONTINUE; 351 return TXRX_CONTINUE;
352} 352}
353
354static int wep_encrypt_skb(struct ieee80211_txrx_data *tx, struct sk_buff *skb)
355{
356 if (!(tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) {
357 if (ieee80211_wep_encrypt(tx->local, skb, tx->key))
358 return -1;
359 } else {
360 tx->u.tx.control->key_idx = tx->key->conf.hw_key_idx;
361 if (tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV) {
362 if (!ieee80211_wep_add_iv(tx->local, skb, tx->key))
363 return -1;
364 }
365 }
366 return 0;
367}
368
369ieee80211_txrx_result
370ieee80211_crypto_wep_encrypt(struct ieee80211_txrx_data *tx)
371{
372 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx->skb->data;
373 u16 fc;
374
375 fc = le16_to_cpu(hdr->frame_control);
376
377 if (((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA &&
378 ((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_MGMT ||
379 (fc & IEEE80211_FCTL_STYPE) != IEEE80211_STYPE_AUTH)))
380 return TXRX_CONTINUE;
381
382 tx->u.tx.control->iv_len = WEP_IV_LEN;
383 tx->u.tx.control->icv_len = WEP_ICV_LEN;
384 ieee80211_tx_set_iswep(tx);
385
386 if (wep_encrypt_skb(tx, tx->skb) < 0) {
387 I802_DEBUG_INC(tx->local->tx_handlers_drop_wep);
388 return TXRX_DROP;
389 }
390
391 if (tx->u.tx.extra_frag) {
392 int i;
393 for (i = 0; i < tx->u.tx.num_extra_frag; i++) {
394 if (wep_encrypt_skb(tx, tx->u.tx.extra_frag[i]) < 0) {
395 I802_DEBUG_INC(tx->local->
396 tx_handlers_drop_wep);
397 return TXRX_DROP;
398 }
399 }
400 }
401
402 return TXRX_CONTINUE;
403}