Commit 5cf121c3 authored by Johannes Berg's avatar Johannes Berg Committed by John W. Linville

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: default avatarJohannes Berg <johannes@sipsolutions.net>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 7495883b
...@@ -142,26 +142,51 @@ typedef unsigned __bitwise__ ieee80211_tx_result; ...@@ -142,26 +142,51 @@ typedef unsigned __bitwise__ ieee80211_tx_result;
#define TX_DROP ((__force ieee80211_tx_result) 1u) #define TX_DROP ((__force ieee80211_tx_result) 1u)
#define TX_QUEUED ((__force ieee80211_tx_result) 2u) #define TX_QUEUED ((__force ieee80211_tx_result) 2u)
#define IEEE80211_TX_FRAGMENTED BIT(0)
#define IEEE80211_TX_UNICAST BIT(1)
#define IEEE80211_TX_PS_BUFFERED BIT(2)
#define IEEE80211_TX_PROBE_LAST_FRAG BIT(3)
#define IEEE80211_TX_INJECTED BIT(4)
struct ieee80211_tx_data {
struct sk_buff *skb;
struct net_device *dev;
struct ieee80211_local *local;
struct ieee80211_sub_if_data *sdata;
struct sta_info *sta;
u16 fc, ethertype;
struct ieee80211_key *key;
unsigned int flags;
struct ieee80211_tx_control *control;
struct ieee80211_channel *channel;
struct ieee80211_rate *rate;
/* use this rate (if set) for last fragment; rate can
* be set to lower rate for the first fragments, e.g.,
* when using CTS protection with IEEE 802.11g. */
struct ieee80211_rate *last_frag_rate;
/* Extra fragments (in addition to the first fragment
* in skb) */
int num_extra_frag;
struct sk_buff **extra_frag;
};
typedef unsigned __bitwise__ ieee80211_rx_result; typedef unsigned __bitwise__ ieee80211_rx_result;
#define RX_CONTINUE ((__force ieee80211_rx_result) 0u) #define RX_CONTINUE ((__force ieee80211_rx_result) 0u)
#define RX_DROP_UNUSABLE ((__force ieee80211_rx_result) 1u) #define RX_DROP_UNUSABLE ((__force ieee80211_rx_result) 1u)
#define RX_DROP_MONITOR ((__force ieee80211_rx_result) 2u) #define RX_DROP_MONITOR ((__force ieee80211_rx_result) 2u)
#define RX_QUEUED ((__force ieee80211_rx_result) 3u) #define RX_QUEUED ((__force ieee80211_rx_result) 3u)
#define IEEE80211_RX_IN_SCAN BIT(0)
/* flags used in struct ieee80211_txrx_data.flags */
/* whether the MSDU was fragmented */
#define IEEE80211_TXRXD_FRAGMENTED BIT(0)
#define IEEE80211_TXRXD_TXUNICAST BIT(1)
#define IEEE80211_TXRXD_TXPS_BUFFERED BIT(2)
#define IEEE80211_TXRXD_TXPROBE_LAST_FRAG BIT(3)
#define IEEE80211_TXRXD_RXIN_SCAN BIT(4)
/* frame is destined to interface currently processed (incl. multicast frames) */ /* frame is destined to interface currently processed (incl. multicast frames) */
#define IEEE80211_TXRXD_RXRA_MATCH BIT(5) #define IEEE80211_RX_RA_MATCH BIT(1)
#define IEEE80211_TXRXD_TX_INJECTED BIT(6) #define IEEE80211_RX_AMSDU BIT(2)
#define IEEE80211_TXRXD_RX_AMSDU BIT(7) #define IEEE80211_RX_CMNTR_REPORTED BIT(3)
#define IEEE80211_TXRXD_RX_CMNTR_REPORTED BIT(8) #define IEEE80211_RX_FRAGMENTED BIT(4)
struct ieee80211_txrx_data {
struct ieee80211_rx_data {
struct sk_buff *skb; struct sk_buff *skb;
struct net_device *dev; struct net_device *dev;
struct ieee80211_local *local; struct ieee80211_local *local;
...@@ -170,31 +195,14 @@ struct ieee80211_txrx_data { ...@@ -170,31 +195,14 @@ struct ieee80211_txrx_data {
u16 fc, ethertype; u16 fc, ethertype;
struct ieee80211_key *key; struct ieee80211_key *key;
unsigned int flags; unsigned int flags;
union {
struct { struct ieee80211_rx_status *status;
struct ieee80211_tx_control *control; struct ieee80211_rate *rate;
struct ieee80211_channel *channel; int sent_ps_buffered;
struct ieee80211_rate *rate; int queue;
/* use this rate (if set) for last fragment; rate can int load;
* be set to lower rate for the first fragments, e.g., u32 tkip_iv32;
* when using CTS protection with IEEE 802.11g. */ u16 tkip_iv16;
struct ieee80211_rate *last_frag_rate;
/* Extra fragments (in addition to the first fragment
* in skb) */
int num_extra_frag;
struct sk_buff **extra_frag;
} tx;
struct {
struct ieee80211_rx_status *status;
struct ieee80211_rate *rate;
int sent_ps_buffered;
int queue;
int load;
u32 tkip_iv32;
u16 tkip_iv16;
} rx;
} u;
}; };
/* flags used in struct ieee80211_tx_packet_data.flags */ /* flags used in struct ieee80211_tx_packet_data.flags */
...@@ -842,7 +850,7 @@ static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr) ...@@ -842,7 +850,7 @@ static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr)
int ieee80211_hw_config(struct ieee80211_local *local); int ieee80211_hw_config(struct ieee80211_local *local);
int ieee80211_if_config(struct net_device *dev); int ieee80211_if_config(struct net_device *dev);
int ieee80211_if_config_beacon(struct net_device *dev); int ieee80211_if_config_beacon(struct net_device *dev);
void ieee80211_tx_set_iswep(struct ieee80211_txrx_data *tx); void ieee80211_tx_set_protected(struct ieee80211_tx_data *tx);
int ieee80211_if_update_wds(struct net_device *dev, u8 *remote_addr); int ieee80211_if_update_wds(struct net_device *dev, u8 *remote_addr);
void ieee80211_if_setup(struct net_device *dev); void ieee80211_if_setup(struct net_device *dev);
int ieee80211_hw_config_ht(struct ieee80211_local *local, int enable_ht, int ieee80211_hw_config_ht(struct ieee80211_local *local, int enable_ht,
......
This diff is collapsed.
This diff is collapsed.
...@@ -165,17 +165,17 @@ int ieee80211_get_mesh_hdrlen(struct ieee80211s_hdr *meshhdr) ...@@ -165,17 +165,17 @@ int ieee80211_get_mesh_hdrlen(struct ieee80211s_hdr *meshhdr)
} }
} }
void ieee80211_tx_set_iswep(struct ieee80211_txrx_data *tx) void ieee80211_tx_set_protected(struct ieee80211_tx_data *tx)
{ {
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx->skb->data; struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx->skb->data;
hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED); hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED);
if (tx->u.tx.extra_frag) { if (tx->extra_frag) {
struct ieee80211_hdr *fhdr; struct ieee80211_hdr *fhdr;
int i; int i;
for (i = 0; i < tx->u.tx.num_extra_frag; i++) { for (i = 0; i < tx->num_extra_frag; i++) {
fhdr = (struct ieee80211_hdr *) fhdr = (struct ieee80211_hdr *)
tx->u.tx.extra_frag[i]->data; tx->extra_frag[i]->data;
fhdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED); fhdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED);
} }
} }
......
...@@ -306,14 +306,14 @@ u8 * ieee80211_wep_is_weak_iv(struct sk_buff *skb, struct ieee80211_key *key) ...@@ -306,14 +306,14 @@ u8 * ieee80211_wep_is_weak_iv(struct sk_buff *skb, struct ieee80211_key *key)
} }
ieee80211_rx_result ieee80211_rx_result
ieee80211_crypto_wep_decrypt(struct ieee80211_txrx_data *rx) ieee80211_crypto_wep_decrypt(struct ieee80211_rx_data *rx)
{ {
if ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA && if ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA &&
((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_MGMT || ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_MGMT ||
(rx->fc & IEEE80211_FCTL_STYPE) != IEEE80211_STYPE_AUTH)) (rx->fc & IEEE80211_FCTL_STYPE) != IEEE80211_STYPE_AUTH))
return RX_CONTINUE; return RX_CONTINUE;
if (!(rx->u.rx.status->flag & RX_FLAG_DECRYPTED)) { if (!(rx->status->flag & RX_FLAG_DECRYPTED)) {
if (ieee80211_wep_decrypt(rx->local, rx->skb, rx->key)) { if (ieee80211_wep_decrypt(rx->local, rx->skb, rx->key)) {
#ifdef CONFIG_MAC80211_DEBUG #ifdef CONFIG_MAC80211_DEBUG
if (net_ratelimit()) if (net_ratelimit())
...@@ -322,7 +322,7 @@ ieee80211_crypto_wep_decrypt(struct ieee80211_txrx_data *rx) ...@@ -322,7 +322,7 @@ ieee80211_crypto_wep_decrypt(struct ieee80211_txrx_data *rx)
#endif /* CONFIG_MAC80211_DEBUG */ #endif /* CONFIG_MAC80211_DEBUG */
return RX_DROP_UNUSABLE; return RX_DROP_UNUSABLE;
} }
} else if (!(rx->u.rx.status->flag & RX_FLAG_IV_STRIPPED)) { } else if (!(rx->status->flag & RX_FLAG_IV_STRIPPED)) {
ieee80211_wep_remove_iv(rx->local, rx->skb, rx->key); ieee80211_wep_remove_iv(rx->local, rx->skb, rx->key);
/* remove ICV */ /* remove ICV */
skb_trim(rx->skb, rx->skb->len - 4); skb_trim(rx->skb, rx->skb->len - 4);
...@@ -331,13 +331,13 @@ ieee80211_crypto_wep_decrypt(struct ieee80211_txrx_data *rx) ...@@ -331,13 +331,13 @@ ieee80211_crypto_wep_decrypt(struct ieee80211_txrx_data *rx)
return RX_CONTINUE; return RX_CONTINUE;
} }
static int wep_encrypt_skb(struct ieee80211_txrx_data *tx, struct sk_buff *skb) static int wep_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb)
{ {
if (!(tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) { if (!(tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) {
if (ieee80211_wep_encrypt(tx->local, skb, tx->key)) if (ieee80211_wep_encrypt(tx->local, skb, tx->key))
return -1; return -1;
} else { } else {
tx->u.tx.control->key_idx = tx->key->conf.hw_key_idx; tx->control->key_idx = tx->key->conf.hw_key_idx;
if (tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV) { if (tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV) {
if (!ieee80211_wep_add_iv(tx->local, skb, tx->key)) if (!ieee80211_wep_add_iv(tx->local, skb, tx->key))
return -1; return -1;
...@@ -347,21 +347,21 @@ static int wep_encrypt_skb(struct ieee80211_txrx_data *tx, struct sk_buff *skb) ...@@ -347,21 +347,21 @@ static int wep_encrypt_skb(struct ieee80211_txrx_data *tx, struct sk_buff *skb)
} }
ieee80211_tx_result ieee80211_tx_result
ieee80211_crypto_wep_encrypt(struct ieee80211_txrx_data *tx) ieee80211_crypto_wep_encrypt(struct ieee80211_tx_data *tx)
{ {
tx->u.tx.control->iv_len = WEP_IV_LEN; tx->control->iv_len = WEP_IV_LEN;
tx->u.tx.control->icv_len = WEP_ICV_LEN; tx->control->icv_len = WEP_ICV_LEN;
ieee80211_tx_set_iswep(tx); ieee80211_tx_set_protected(tx);
if (wep_encrypt_skb(tx, tx->skb) < 0) { if (wep_encrypt_skb(tx, tx->skb) < 0) {
I802_DEBUG_INC(tx->local->tx_handlers_drop_wep); I802_DEBUG_INC(tx->local->tx_handlers_drop_wep);
return TX_DROP; return TX_DROP;
} }
if (tx->u.tx.extra_frag) { if (tx->extra_frag) {
int i; int i;
for (i = 0; i < tx->u.tx.num_extra_frag; i++) { for (i = 0; i < tx->num_extra_frag; i++) {
if (wep_encrypt_skb(tx, tx->u.tx.extra_frag[i]) < 0) { if (wep_encrypt_skb(tx, tx->extra_frag[i]) < 0) {
I802_DEBUG_INC(tx->local-> I802_DEBUG_INC(tx->local->
tx_handlers_drop_wep); tx_handlers_drop_wep);
return TX_DROP; return TX_DROP;
......
...@@ -29,8 +29,8 @@ int ieee80211_wep_decrypt(struct ieee80211_local *local, struct sk_buff *skb, ...@@ -29,8 +29,8 @@ int ieee80211_wep_decrypt(struct ieee80211_local *local, struct sk_buff *skb,
u8 * ieee80211_wep_is_weak_iv(struct sk_buff *skb, struct ieee80211_key *key); u8 * ieee80211_wep_is_weak_iv(struct sk_buff *skb, struct ieee80211_key *key);
ieee80211_rx_result ieee80211_rx_result
ieee80211_crypto_wep_decrypt(struct ieee80211_txrx_data *rx); ieee80211_crypto_wep_decrypt(struct ieee80211_rx_data *rx);
ieee80211_tx_result ieee80211_tx_result
ieee80211_crypto_wep_encrypt(struct ieee80211_txrx_data *tx); ieee80211_crypto_wep_encrypt(struct ieee80211_tx_data *tx);
#endif /* WEP_H */ #endif /* WEP_H */
...@@ -71,7 +71,7 @@ static int ieee80211_get_hdr_info(const struct sk_buff *skb, u8 **sa, u8 **da, ...@@ -71,7 +71,7 @@ static int ieee80211_get_hdr_info(const struct sk_buff *skb, u8 **sa, u8 **da,
ieee80211_tx_result ieee80211_tx_result
ieee80211_tx_h_michael_mic_add(struct ieee80211_txrx_data *tx) ieee80211_tx_h_michael_mic_add(struct ieee80211_tx_data *tx)
{ {
u8 *data, *sa, *da, *key, *mic, qos_tid; u8 *data, *sa, *da, *key, *mic, qos_tid;
size_t data_len; size_t data_len;
...@@ -90,7 +90,7 @@ ieee80211_tx_h_michael_mic_add(struct ieee80211_txrx_data *tx) ...@@ -90,7 +90,7 @@ ieee80211_tx_h_michael_mic_add(struct ieee80211_txrx_data *tx)
return TX_DROP; return TX_DROP;
if ((tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) && if ((tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) &&
!(tx->flags & IEEE80211_TXRXD_FRAGMENTED) && !(tx->flags & IEEE80211_TX_FRAGMENTED) &&
!(tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) && !(tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) &&
!wpa_test) { !wpa_test) {
/* hwaccel - with no need for preallocated room for Michael MIC /* 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,7 +124,7 @@ ieee80211_tx_h_michael_mic_add(struct ieee80211_txrx_data *tx)
ieee80211_rx_result ieee80211_rx_result
ieee80211_rx_h_michael_mic_verify(struct ieee80211_txrx_data *rx) ieee80211_rx_h_michael_mic_verify(struct ieee80211_rx_data *rx)
{ {
u8 *data, *sa, *da, *key = NULL, qos_tid; u8 *data, *sa, *da, *key = NULL, qos_tid;
size_t data_len; size_t data_len;
...@@ -139,7 +139,7 @@ ieee80211_rx_h_michael_mic_verify(struct ieee80211_txrx_data *rx) ...@@ -139,7 +139,7 @@ ieee80211_rx_h_michael_mic_verify(struct ieee80211_txrx_data *rx)
/* /*
* No way to verify the MIC if the hardware stripped it * No way to verify the MIC if the hardware stripped it
*/ */
if (rx->u.rx.status->flag & RX_FLAG_MMIC_STRIPPED) if (rx->status->flag & RX_FLAG_MMIC_STRIPPED)
return RX_CONTINUE; return RX_CONTINUE;
if (!rx->key || rx->key->conf.alg != ALG_TKIP || 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,7 +161,7 @@ ieee80211_rx_h_michael_mic_verify(struct ieee80211_txrx_data *rx)
ALG_TKIP_TEMP_AUTH_TX_MIC_KEY]; ALG_TKIP_TEMP_AUTH_TX_MIC_KEY];
michael_mic(key, da, sa, qos_tid & 0x0f, data, data_len, mic); michael_mic(key, da, sa, qos_tid & 0x0f, data, data_len, mic);
if (memcmp(mic, data + data_len, MICHAEL_MIC_LEN) != 0 || wpa_test) { if (memcmp(mic, data + data_len, MICHAEL_MIC_LEN) != 0 || wpa_test) {
if (!(rx->flags & IEEE80211_TXRXD_RXRA_MATCH)) if (!(rx->flags & IEEE80211_RX_RA_MATCH))
return RX_DROP_UNUSABLE; return RX_DROP_UNUSABLE;
printk(KERN_DEBUG "%s: invalid Michael MIC in data frame from " 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,14 +176,14 @@ ieee80211_rx_h_michael_mic_verify(struct ieee80211_txrx_data *rx)
skb_trim(skb, skb->len - MICHAEL_MIC_LEN); skb_trim(skb, skb->len - MICHAEL_MIC_LEN);
/* update IV in key information to be able to detect replays */ /* update IV in key information to be able to detect replays */
rx->key->u.tkip.iv32_rx[rx->u.rx.queue] = rx->u.rx.tkip_iv32; rx->key->u.tkip.iv32_rx[rx->queue] = rx->tkip_iv32;
rx->key->u.tkip.iv16_rx[rx->u.rx.queue] = rx->u.rx.tkip_iv16; rx->key->u.tkip.iv16_rx[rx->queue] = rx->tkip_iv16;
return RX_CONTINUE; return RX_CONTINUE;
} }
static int tkip_encrypt_skb(struct ieee80211_txrx_data *tx, static int tkip_encrypt_skb(struct ieee80211_tx_data *tx,
struct sk_buff *skb, int test) struct sk_buff *skb, int test)
{ {
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
...@@ -228,7 +228,7 @@ static int tkip_encrypt_skb(struct ieee80211_txrx_data *tx, ...@@ -228,7 +228,7 @@ static int tkip_encrypt_skb(struct ieee80211_txrx_data *tx,
0x7f), 0x7f),
(u8) key->u.tkip.iv16); (u8) key->u.tkip.iv16);
tx->u.tx.control->key_idx = tx->key->conf.hw_key_idx; tx->control->key_idx = tx->key->conf.hw_key_idx;
return 0; return 0;
} }
...@@ -243,30 +243,30 @@ static int tkip_encrypt_skb(struct ieee80211_txrx_data *tx, ...@@ -243,30 +243,30 @@ static int tkip_encrypt_skb(struct ieee80211_txrx_data *tx,
ieee80211_tx_result ieee80211_tx_result
ieee80211_crypto_tkip_encrypt(struct ieee80211_txrx_data *tx) ieee80211_crypto_tkip_encrypt(struct ieee80211_tx_data *tx)
{ {
struct sk_buff *skb = tx->skb; struct sk_buff *skb = tx->skb;
int wpa_test = 0, test = 0; int wpa_test = 0, test = 0;
tx->u.tx.control->icv_len = TKIP_ICV_LEN; tx->control->icv_len = TKIP_ICV_LEN;
tx->u.tx.control->iv_len = TKIP_IV_LEN; tx->control->iv_len = TKIP_IV_LEN;
ieee80211_tx_set_iswep(tx); ieee80211_tx_set_protected(tx);
if ((tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) && if ((tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) &&
!(tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV) && !(tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV) &&
!wpa_test) { !wpa_test) {
/* hwaccel - with no need for preallocated room for IV/ICV */ /* hwaccel - with no need for preallocated room for IV/ICV */
tx->u.tx.control->key_idx = tx->key->conf.hw_key_idx; tx->control->key_idx = tx->key->conf.hw_key_idx;
return TX_CONTINUE; return TX_CONTINUE;
} }
if (tkip_encrypt_skb(tx, skb, test) < 0) if (tkip_encrypt_skb(tx, skb, test) < 0)
return TX_DROP; return TX_DROP;
if (tx->u.tx.extra_frag) { if (tx->extra_frag) {
int i; int i;
for (i = 0; i < tx->u.tx.num_extra_frag; i++) { for (i = 0; i < tx->num_extra_frag; i++) {
if (tkip_encrypt_skb(tx, tx->u.tx.extra_frag[i], test) if (tkip_encrypt_skb(tx, tx->extra_frag[i], test)
< 0) < 0)
return TX_DROP; return TX_DROP;
} }
...@@ -277,7 +277,7 @@ ieee80211_crypto_tkip_encrypt(struct ieee80211_txrx_data *tx) ...@@ -277,7 +277,7 @@ ieee80211_crypto_tkip_encrypt(struct ieee80211_txrx_data *tx)
ieee80211_rx_result ieee80211_rx_result
ieee80211_crypto_tkip_decrypt(struct ieee80211_txrx_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; u16 fc;
...@@ -295,8 +295,8 @@ ieee80211_crypto_tkip_decrypt(struct ieee80211_txrx_data *rx) ...@@ -295,8 +295,8 @@ ieee80211_crypto_tkip_decrypt(struct ieee80211_txrx_data *rx)
if (!rx->sta || skb->len - hdrlen < 12) if (!rx->sta || skb->len - hdrlen < 12)
return RX_DROP_UNUSABLE; return RX_DROP_UNUSABLE;
if (rx->u.rx.status->flag & RX_FLAG_DECRYPTED) { if (rx->status->flag & RX_FLAG_DECRYPTED) {
if (rx->u.rx.status->flag & RX_FLAG_IV_STRIPPED) { if (rx->status->flag & RX_FLAG_IV_STRIPPED) {
/* /*
* Hardware took care of all processing, including * Hardware took care of all processing, including
* replay protection, and stripped the ICV/IV so * replay protection, and stripped the ICV/IV so
...@@ -312,9 +312,9 @@ ieee80211_crypto_tkip_decrypt(struct ieee80211_txrx_data *rx) ...@@ -312,9 +312,9 @@ ieee80211_crypto_tkip_decrypt(struct ieee80211_txrx_data *rx)
res = ieee80211_tkip_decrypt_data(rx->local->wep_rx_tfm, res = ieee80211_tkip_decrypt_data(rx->local->wep_rx_tfm,
key, skb->data + hdrlen, key, skb->data + hdrlen,
skb->len - hdrlen, rx->sta->addr, skb->len - hdrlen, rx->sta->addr,
hwaccel, rx->u.rx.queue, hwaccel, rx->queue,
&rx->u.rx.tkip_iv32, &rx->tkip_iv32,
&rx->u.rx.tkip_iv16); &rx->tkip_iv16);
if (res != TKIP_DECRYPT_OK || wpa_test) { if (res != TKIP_DECRYPT_OK || wpa_test) {
#ifdef CONFIG_MAC80211_DEBUG #ifdef CONFIG_MAC80211_DEBUG
if (net_ratelimit()) if (net_ratelimit())
...@@ -429,7 +429,7 @@ static inline int ccmp_hdr2pn(u8 *pn, u8 *hdr) ...@@ -429,7 +429,7 @@ static inline int ccmp_hdr2pn(u8 *pn, u8 *hdr)
} }
static int ccmp_encrypt_skb(struct ieee80211_txrx_data *tx, static int ccmp_encrypt_skb(struct ieee80211_tx_data *tx,
struct sk_buff *skb, int test) struct sk_buff *skb, int test)
{ {
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
...@@ -478,7 +478,7 @@ static int ccmp_encrypt_skb(struct ieee80211_txrx_data *tx, ...@@ -478,7 +478,7 @@ static int ccmp_encrypt_skb(struct ieee80211_txrx_data *tx,
if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) { if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) {
/* hwaccel - with preallocated room for CCMP header */ /* hwaccel - with preallocated room for CCMP header */
tx->u.tx.control->key_idx = key->conf.hw_key_idx; tx->control->key_idx = key->conf.hw_key_idx;
return 0; return 0;
} }
...@@ -492,30 +492,30 @@ static int ccmp_encrypt_skb(struct ieee80211_txrx_data *tx, ...@@ -492,30 +492,30 @@ static int ccmp_encrypt_skb(struct ieee80211_txrx_data *tx,
ieee80211_tx_result ieee80211_tx_result
ieee80211_crypto_ccmp_encrypt(struct ieee80211_txrx_data *tx) ieee80211_crypto_ccmp_encrypt(struct ieee80211_tx_data *tx)
{ {
struct sk_buff *skb = tx->skb; struct sk_buff *skb = tx->skb;
int test = 0; int test = 0;
tx->u.tx.control->icv_len = CCMP_MIC_LEN; tx->control->icv_len = CCMP_MIC_LEN;
tx->u.tx.control->iv_len = CCMP_HDR_LEN; tx->control->iv_len = CCMP_HDR_LEN;
ieee80211_tx_set_iswep(tx); ieee80211_tx_set_protected(tx);
if ((tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) && if ((tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) &&
!(tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) { !(tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) {
/* hwaccel - with no need for preallocated room for CCMP " /* hwaccel - with no need for preallocated room for CCMP "
* header or MIC fields */ * header or MIC fields */
tx->u.tx.control->key_idx = tx->key->conf.hw_key_idx; tx->control->key_idx = tx->key->conf.hw_key_idx;
return TX_CONTINUE; return TX_CONTINUE;
} }
if (ccmp_encrypt_skb(tx, skb, test) < 0) if (ccmp_encrypt_skb(tx, skb, test) < 0)
return TX_DROP; return TX_DROP;
if (tx->u.tx.extra_frag) { if (tx->extra_frag) {
int i; int i;
for (i = 0; i < tx->u.tx.num_extra_frag; i++) { for (i = 0; i < tx->num_extra_frag; i++) {
if (ccmp_encrypt_skb(tx, tx->u.tx.extra_frag[i], test) if (ccmp_encrypt_skb(tx, tx->extra_frag[i], test)
< 0) < 0)
return TX_DROP; return TX_DROP;
} }
...@@ -526,7 +526,7 @@ ieee80211_crypto_ccmp_encrypt(struct ieee80211_txrx_data *tx) ...@@ -526,7 +526,7 @@ ieee80211_crypto_ccmp_encrypt(struct ieee80211_txrx_data *tx)
ieee80211_rx_result ieee80211_rx_result
ieee80211_crypto_ccmp_decrypt(struct ieee80211_txrx_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; u16 fc;
...@@ -547,15 +547,15 @@ ieee80211_crypto_ccmp_decrypt(struct ieee80211_txrx_data *rx) ...@@ -547,15 +547,15 @@ ieee80211_crypto_ccmp_decrypt(struct ieee80211_txrx_data *rx)
if (!rx->sta || data_len < 0) if (!rx->sta || data_len < 0)
return RX_DROP_UNUSABLE; return RX_DROP_UNUSABLE;
if ((rx->u.rx.status->flag & RX_FLAG_DECRYPTED) && if ((rx->status->flag & RX_FLAG_DECRYPTED) &&
(rx->u.rx.status->flag & RX_FLAG_IV_STRIPPED)) (rx->status->flag & RX_FLAG_IV_STRIPPED))
return RX_CONTINUE; return RX_CONTINUE;
(void) ccmp_hdr2pn(pn, skb->data + hdrlen); (void) ccmp_hdr2pn(pn, skb->data + hdrlen);
if (memcmp(pn, key->u.ccmp.rx_pn[rx->u.rx.queue], CCMP_PN_LEN) <= 0) { if (memcmp(pn, key->u.ccmp.rx_pn[rx->queue], CCMP_PN_LEN) <= 0) {
#ifdef CONFIG_MAC80211_DEBUG #ifdef CONFIG_MAC80211_DEBUG
u8 *ppn = key->u.ccmp.rx_pn[rx->u.rx.queue]; u8 *ppn = key->u.ccmp.rx_pn[rx->queue];
printk(KERN_DEBUG "%s: CCMP replay detected for RX frame from " printk(KERN_DEBUG "%s: CCMP replay detected for RX frame from "
"%s (RX PN %02x%02x%02x%02x%02x%02x <= prev. PN " "%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,7 +568,7 @@ ieee80211_crypto_ccmp_decrypt(struct ieee80211_txrx_data *rx)
return RX_DROP_UNUSABLE; return RX_DROP_UNUSABLE;
} }
if (!(rx->u.rx.status->flag & RX_FLAG_DECRYPTED)) { if (!(rx->status->flag & RX_FLAG_DECRYPTED)) {
/* hardware didn't decrypt/verify MIC */ /* hardware didn't decrypt/verify MIC */
u8 *scratch, *b_0, *aad; u8 *scratch, *b_0, *aad;
...@@ -593,7 +593,7 @@ ieee80211_crypto_ccmp_decrypt(struct ieee80211_txrx_data *rx) ...@@ -593,7 +593,7 @@ ieee80211_crypto_ccmp_decrypt(struct ieee80211_txrx_data *rx)
} }
} }
memcpy(key->u.ccmp.rx_pn[rx->u.rx.queue], pn, CCMP_PN_LEN); memcpy(key->u.ccmp.rx_pn[rx->queue], pn, CCMP_PN_LEN);
/* Remove CCMP header and MIC */ /* Remove CCMP header and MIC */
skb_trim(skb, skb->len - CCMP_MIC_LEN); skb_trim(skb, skb->len - CCMP_MIC_LEN);
......
...@@ -14,18 +14,18 @@ ...@@ -14,18 +14,18 @@
#include "ieee80211_i.h" #include "ieee80211_i.h"
ieee80211_tx_result ieee80211_tx_result
ieee80211_tx_h_michael_mic_add(struct ieee80211_txrx_data *tx); ieee80211_tx_h_michael_mic_add(struct ieee80211_tx_data *tx);
ieee80211_rx_result ieee80211_rx_result
ieee80211_rx_h_michael_mic_verify(struct ieee80211_txrx_data *rx); ieee80211_rx_h_michael_mic_verify(struct ieee80211_rx_data *rx);
ieee80211_tx_result ieee80211_tx_result
ieee80211_crypto_tkip_encrypt(struct ieee80211_txrx_data *tx); ieee80211_crypto_tkip_encrypt(struct ieee80211_tx_data *tx);
ieee80211_rx_result ieee80211_rx_result
ieee80211_crypto_tkip_decrypt(struct ieee80211_txrx_data *rx); ieee80211_crypto_tkip_decrypt(struct ieee80211_rx_data *rx);
ieee80211_tx_result ieee80211_tx_result
ieee80211_crypto_ccmp_encrypt(struct ieee80211_txrx_data *tx); ieee80211_crypto_ccmp_encrypt(struct ieee80211_tx_data *tx);
ieee80211_rx_result ieee80211_rx_result
ieee80211_crypto_ccmp_decrypt(struct ieee80211_txrx_data *rx); ieee80211_crypto_ccmp_decrypt(struct ieee80211_rx_data *rx);
#endif /* WPA_H */ #endif /* WPA_H */
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