Skip to content

Commit

Permalink
[PATCH] ieee80211: Renamed ieee80211_hdr to ieee80211_hdr_3addr
Browse files Browse the repository at this point in the history
tree e9c18b2c8e5ad446a4d213243c2dcf9fd1652a7b
parent 4e97ad6ae7084a4f741e94e76c41c68bc7c5a76a
author James Ketrenos <jketreno@linux.intel.com> 1124444315 -0500
committer James Ketrenos <jketreno@linux.intel.com> 1127312922 -0500

Renamed ieee80211_hdr to ieee80211_hdr_3addr and modified ieee80211_hdr
to just contain the frame_ctrl and duration_id.

Changed uses of ieee80211_hdr to ieee80211_hdr_4addr or
ieee80211_hdr_3addr based on what was expected for that portion of code.

NOTE: This requires changes to ipw2100, ipw2200, hostap, and atmel
drivers.

Signed-off-by: James Ketrenos <jketreno@linux.intel.com>
Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
  • Loading branch information
James Ketrenos authored and Jeff Garzik committed Sep 22, 2005
1 parent e0d369d commit ee34af3
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 64 deletions.
117 changes: 90 additions & 27 deletions include/net/ieee80211.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,33 +33,13 @@
represents the 2304 bytes of real data, plus a possible 8 bytes of
WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */

#define IEEE80211_HLEN 30
#define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)

struct ieee80211_hdr {
__le16 frame_ctl;
__le16 duration_id;
u8 addr1[ETH_ALEN];
u8 addr2[ETH_ALEN];
u8 addr3[ETH_ALEN];
__le16 seq_ctl;
u8 addr4[ETH_ALEN];
} __attribute__ ((packed));

struct ieee80211_hdr_3addr {
__le16 frame_ctl;
__le16 duration_id;
u8 addr1[ETH_ALEN];
u8 addr2[ETH_ALEN];
u8 addr3[ETH_ALEN];
__le16 seq_ctl;
} __attribute__ ((packed));

#define IEEE80211_1ADDR_LEN 10
#define IEEE80211_2ADDR_LEN 16
#define IEEE80211_3ADDR_LEN 24
#define IEEE80211_4ADDR_LEN 30
#define IEEE80211_FCS_LEN 4
#define IEEE80211_HLEN (IEEE80211_4ADDR_LEN)
#define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)

#define MIN_FRAG_THRESHOLD 256U
#define MAX_FRAG_THRESHOLD 2346U
Expand Down Expand Up @@ -515,6 +495,51 @@ enum ieee80211_mfie {
MFIE_TYPE_GENERIC = 221,
};

/* Minimal header; can be used for passing 802.11 frames with sufficient
* information to determine what type of underlying data type is actually
* stored in the data. */
struct ieee80211_hdr {
u16 frame_ctl;
u16 duration_id;
u8 payload[0];
} __attribute__ ((packed));

struct ieee80211_hdr_1addr {
u16 frame_ctl;
u16 duration_id;
u8 addr1[ETH_ALEN];
u8 payload[0];
} __attribute__ ((packed));

struct ieee80211_hdr_2addr {
u16 frame_ctl;
u16 duration_id;
u8 addr1[ETH_ALEN];
u8 addr2[ETH_ALEN];
u8 payload[0];
} __attribute__ ((packed));

struct ieee80211_hdr_3addr {
u16 frame_ctl;
u16 duration_id;
u8 addr1[ETH_ALEN];
u8 addr2[ETH_ALEN];
u8 addr3[ETH_ALEN];
u16 seq_ctl;
u8 payload[0];
} __attribute__ ((packed));

struct ieee80211_hdr_4addr {
u16 frame_ctl;
u16 duration_id;
u8 addr1[ETH_ALEN];
u8 addr2[ETH_ALEN];
u8 addr3[ETH_ALEN];
u16 seq_ctl;
u8 addr4[ETH_ALEN];
u8 payload[0];
} __attribute__ ((packed));

struct ieee80211_info_element {
u8 id;
u8 len;
Expand All @@ -538,14 +563,25 @@ struct ieee80211_info_element {
u16 status;
*/

struct ieee80211_authentication {
struct ieee80211_auth {
struct ieee80211_hdr_3addr header;
__le16 algorithm;
__le16 transaction;
__le16 status;
struct ieee80211_info_element info_element[0];
} __attribute__ ((packed));

struct ieee80211_disassoc {
struct ieee80211_hdr_3addr header;
u16 reason_code;
struct ieee80211_info_element info_element[0];
} __attribute__ ((packed));

struct ieee80211_probe_request {
struct ieee80211_hdr_3addr header;
struct ieee80211_info_element info_element[0];
} __attribute__ ((packed));

struct ieee80211_probe_response {
struct ieee80211_hdr_3addr header;
u32 time_stamp[2];
Expand All @@ -554,14 +590,25 @@ struct ieee80211_probe_response {
struct ieee80211_info_element info_element[0];
} __attribute__ ((packed));

struct ieee80211_assoc_request_frame {
/* Alias beacon for probe_response */
#define ieee80211_beacon ieee80211_probe_response

struct ieee80211_assoc_request {
struct ieee80211_hdr_3addr header;
u16 capability;
u16 listen_interval;
struct ieee80211_info_element info_element[0];
} __attribute__ ((packed));

struct ieee80211_reassoc_request {
struct ieee80211_hdr_3addr header;
__le16 capability;
__le16 listen_interval;
u8 current_ap[ETH_ALEN];
struct ieee80211_info_element info_element[0];
} __attribute__ ((packed));

struct ieee80211_assoc_response_frame {
struct ieee80211_assoc_response {
struct ieee80211_hdr_3addr header;
__le16 capability;
__le16 status;
Expand All @@ -572,7 +619,8 @@ struct ieee80211_assoc_response_frame {
struct ieee80211_txb {
u8 nr_frags;
u8 encrypted;
u16 reserved;
u8 rts_included;
u8 reserved;
u16 frag_size;
u16 payload_size;
struct sk_buff *fragments[0];
Expand Down Expand Up @@ -803,6 +851,21 @@ extern inline int ieee80211_get_hdrlen(u16 fc)
return hdrlen;
}

extern inline u8 *ieee80211_get_payload(struct ieee80211_hdr *hdr)
{
switch (ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl))) {
case IEEE80211_1ADDR_LEN:
return ((struct ieee80211_hdr_1addr *)hdr)->payload;
case IEEE80211_2ADDR_LEN:
return ((struct ieee80211_hdr_2addr *)hdr)->payload;
case IEEE80211_3ADDR_LEN:
return ((struct ieee80211_hdr_3addr *)hdr)->payload;
case IEEE80211_4ADDR_LEN:
return ((struct ieee80211_hdr_4addr *)hdr)->payload;
}

}

/* ieee80211.c */
extern void free_ieee80211(struct net_device *dev);
extern struct net_device *alloc_ieee80211(int sizeof_priv);
Expand All @@ -817,7 +880,7 @@ extern void ieee80211_txb_free(struct ieee80211_txb *);
extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
struct ieee80211_rx_stats *rx_stats);
extern void ieee80211_rx_mgt(struct ieee80211_device *ieee,
struct ieee80211_hdr *header,
struct ieee80211_hdr_4addr *header,
struct ieee80211_rx_stats *stats);

/* ieee80211_wx.c */
Expand Down
10 changes: 5 additions & 5 deletions net/ieee80211/ieee80211_crypt_ccmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ static inline void xor_block(u8 * b, u8 * a, size_t len)
}

static void ccmp_init_blocks(struct crypto_tfm *tfm,
struct ieee80211_hdr *hdr,
struct ieee80211_hdr_4addr *hdr,
u8 * pn, size_t dlen, u8 * b0, u8 * auth, u8 * s0)
{
u8 *pos, qc = 0;
Expand Down Expand Up @@ -196,7 +196,7 @@ static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
struct ieee80211_ccmp_data *key = priv;
int data_len, i, blocks, last, len;
u8 *pos, *mic;
struct ieee80211_hdr *hdr;
struct ieee80211_hdr_4addr *hdr;
u8 *b0 = key->tx_b0;
u8 *b = key->tx_b;
u8 *e = key->tx_e;
Expand Down Expand Up @@ -229,7 +229,7 @@ static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
*pos++ = key->tx_pn[1];
*pos++ = key->tx_pn[0];

hdr = (struct ieee80211_hdr *)skb->data;
hdr = (struct ieee80211_hdr_4addr *)skb->data;
ccmp_init_blocks(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0);

blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN;
Expand Down Expand Up @@ -258,7 +258,7 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
{
struct ieee80211_ccmp_data *key = priv;
u8 keyidx, *pos;
struct ieee80211_hdr *hdr;
struct ieee80211_hdr_4addr *hdr;
u8 *b0 = key->rx_b0;
u8 *b = key->rx_b;
u8 *a = key->rx_a;
Expand All @@ -272,7 +272,7 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
return -1;
}

hdr = (struct ieee80211_hdr *)skb->data;
hdr = (struct ieee80211_hdr_4addr *)skb->data;
pos = skb->data + hdr_len;
keyidx = pos[3];
if (!(keyidx & (1 << 5))) {
Expand Down
27 changes: 14 additions & 13 deletions net/ieee80211/ieee80211_crypt_tkip.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,11 @@ static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
struct ieee80211_tkip_data *tkey = priv;
int len;
u8 rc4key[16], *pos, *icv;
struct ieee80211_hdr *hdr;
struct ieee80211_hdr_4addr *hdr;
u32 crc;
struct scatterlist sg;

hdr = (struct ieee80211_hdr *)skb->data;
hdr = (struct ieee80211_hdr_4addr *)skb->data;

if (tkey->ieee->tkip_countermeasures) {
if (net_ratelimit()) {
Expand Down Expand Up @@ -334,13 +334,13 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
u8 keyidx, *pos;
u32 iv32;
u16 iv16;
struct ieee80211_hdr *hdr;
struct ieee80211_hdr_4addr *hdr;
u8 icv[4];
u32 crc;
struct scatterlist sg;
int plen;

hdr = (struct ieee80211_hdr *)skb->data;
hdr = (struct ieee80211_hdr_4addr *)skb->data;

if (tkey->ieee->tkip_countermeasures) {
if (net_ratelimit()) {
Expand Down Expand Up @@ -466,9 +466,9 @@ static int michael_mic(struct ieee80211_tkip_data *tkey, u8 * key, u8 * hdr,

static void michael_mic_hdr(struct sk_buff *skb, u8 * hdr)
{
struct ieee80211_hdr *hdr11;
struct ieee80211_hdr_4addr *hdr11;

hdr11 = (struct ieee80211_hdr *)skb->data;
hdr11 = (struct ieee80211_hdr_4addr *)skb->data;
switch (le16_to_cpu(hdr11->frame_ctl) &
(IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) {
case IEEE80211_FCTL_TODS:
Expand Down Expand Up @@ -517,7 +517,8 @@ static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len,

#if WIRELESS_EXT >= 18
static void ieee80211_michael_mic_failure(struct net_device *dev,
struct ieee80211_hdr *hdr, int keyidx)
struct ieee80211_hdr_4addr *hdr,
int keyidx)
{
union iwreq_data wrqu;
struct iw_michaelmicfailure ev;
Expand All @@ -537,7 +538,8 @@ static void ieee80211_michael_mic_failure(struct net_device *dev,
}
#elif WIRELESS_EXT >= 15
static void ieee80211_michael_mic_failure(struct net_device *dev,
struct ieee80211_hdr *hdr, int keyidx)
struct ieee80211_hdr_4addr *hdr,
int keyidx)
{
union iwreq_data wrqu;
char buf[128];
Expand All @@ -551,9 +553,8 @@ static void ieee80211_michael_mic_failure(struct net_device *dev,
wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf);
}
#else /* WIRELESS_EXT >= 15 */
static inline void ieee80211_michael_mic_failure(struct net_device *dev,
struct ieee80211_hdr *hdr,
int keyidx)
static inline void ieee80211_michael_mic_failure(struct net_device *dev, struct ieee80211_hdr_4addr
*hdr, int keyidx)
{
}
#endif /* WIRELESS_EXT >= 15 */
Expand All @@ -572,8 +573,8 @@ static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx,
skb->data + hdr_len, skb->len - 8 - hdr_len, mic))
return -1;
if (memcmp(mic, skb->data + skb->len - 8, 8) != 0) {
struct ieee80211_hdr *hdr;
hdr = (struct ieee80211_hdr *)skb->data;
struct ieee80211_hdr_4addr *hdr;
hdr = (struct ieee80211_hdr_4addr *)skb->data;
printk(KERN_DEBUG "%s: Michael MIC verification failed for "
"MSDU from " MAC_FMT " keyidx=%d\n",
skb->dev ? skb->dev->name : "N/A", MAC_ARG(hdr->addr2),
Expand Down
Loading

0 comments on commit ee34af3

Please sign in to comment.