blob: 70755c1336d573d93f7fafb9aa60aef0fa2143db [file] [log] [blame]
Jeff Garzikb4538722005-05-12 22:48:20 -04001/*
2 * Merged with mainline ieee80211.h in Aug 2004. Original ieee802_11
3 * remains copyright by the original authors
4 *
5 * Portions of the merged code are based on Host AP (software wireless
6 * LAN access point) driver for Intersil Prism2/2.5/3.
7 *
8 * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
Jouni Malinen85d32e72007-03-24 17:15:30 -07009 * <j@w1.fi>
10 * Copyright (c) 2002-2003, Jouni Malinen <j@w1.fi>
Jeff Garzikb4538722005-05-12 22:48:20 -040011 *
12 * Adaption to a generic IEEE 802.11 stack by James Ketrenos
13 * <jketreno@linux.intel.com>
James Ketrenosebeaddc2005-09-21 11:58:43 -050014 * Copyright (c) 2004-2005, Intel Corporation
Jeff Garzikb4538722005-05-12 22:48:20 -040015 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License version 2 as
18 * published by the Free Software Foundation. See README and COPYING for
19 * more details.
James Ketrenos31696162005-09-21 11:58:46 -050020 *
21 * API Version History
22 * 1.0.x -- Initial version
23 * 1.1.x -- Added radiotap, QoS, TIM, ieee80211_geo APIs,
24 * various structure changes, and crypto API init method
Jeff Garzikb4538722005-05-12 22:48:20 -040025 */
26#ifndef IEEE80211_H
27#define IEEE80211_H
James Ketrenos74079fd2005-09-13 17:35:21 -050028#include <linux/if_ether.h> /* ETH_ALEN */
29#include <linux/kernel.h> /* ARRAY_SIZE */
Adrian Bunkb7721ff2005-07-22 23:39:12 +020030#include <linux/wireless.h>
John W. Linville72118012008-09-30 21:43:03 -040031#include <linux/ieee80211.h>
Jeff Garzikb4538722005-05-12 22:48:20 -040032
John W. Linville274bfb82008-10-29 11:35:05 -040033#include <net/lib80211.h>
34
Zhu Yi45a62ab2006-04-13 17:17:54 +080035#define IEEE80211_VERSION "git-1.1.13"
James Ketrenos31696162005-09-21 11:58:46 -050036
Jeff Garzikb4538722005-05-12 22:48:20 -040037#define IEEE80211_DATA_LEN 2304
38/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
39 6.2.1.1.2.
40
41 The figure in section 7.1.2 suggests a body size of up to 2312
42 bytes is allowed, which is a bit confusing, I suspect this
43 represents the 2304 bytes of real data, plus a possible 8 bytes of
44 WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
45
Jiri Benc286d9742005-05-24 15:10:18 +020046#define IEEE80211_1ADDR_LEN 10
47#define IEEE80211_2ADDR_LEN 16
Jeff Garzikb4538722005-05-12 22:48:20 -040048#define IEEE80211_3ADDR_LEN 24
49#define IEEE80211_4ADDR_LEN 30
50#define IEEE80211_FCS_LEN 4
James Ketrenosee34af32005-09-21 11:54:36 -050051#define IEEE80211_HLEN (IEEE80211_4ADDR_LEN)
52#define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
Jeff Garzikb4538722005-05-12 22:48:20 -040053
54#define MIN_FRAG_THRESHOLD 256U
55#define MAX_FRAG_THRESHOLD 2346U
56
Zhu Yiea284152006-04-13 17:17:06 +080057/* QOS control */
58#define IEEE80211_QCTL_TID 0x000F
59
Jeff Garzikb4538722005-05-12 22:48:20 -040060/* debug macros */
61
Helmut Schaa37561622009-03-06 12:02:25 +010062#ifdef CONFIG_LIBIPW_DEBUG
Jeff Garzikb4538722005-05-12 22:48:20 -040063extern u32 ieee80211_debug_level;
64#define IEEE80211_DEBUG(level, fmt, args...) \
65do { if (ieee80211_debug_level & (level)) \
66 printk(KERN_DEBUG "ieee80211: %c %s " fmt, \
Harvey Harrisond5c003b2008-10-15 22:01:24 -070067 in_interrupt() ? 'I' : 'U', __func__ , ## args); } while (0)
Guillaume Chazarain92468c52007-11-19 10:07:00 +010068static inline bool ieee80211_ratelimit_debug(u32 level)
69{
70 return (ieee80211_debug_level & level) && net_ratelimit();
71}
Jeff Garzikb4538722005-05-12 22:48:20 -040072#else
73#define IEEE80211_DEBUG(level, fmt, args...) do {} while (0)
Guillaume Chazarain92468c52007-11-19 10:07:00 +010074static inline bool ieee80211_ratelimit_debug(u32 level)
75{
76 return false;
77}
Helmut Schaa37561622009-03-06 12:02:25 +010078#endif /* CONFIG_LIBIPW_DEBUG */
Jiri Bence88187e2005-08-25 20:00:53 -040079
Jeff Garzikb4538722005-05-12 22:48:20 -040080/*
Jiri Bence88187e2005-08-25 20:00:53 -040081 * To use the debug system:
Jeff Garzikb4538722005-05-12 22:48:20 -040082 *
83 * If you are defining a new debug classification, simply add it to the #define
84 * list here in the form of:
85 *
86 * #define IEEE80211_DL_xxxx VALUE
87 *
88 * shifting value to the left one bit from the previous entry. xxxx should be
89 * the name of the classification (for example, WEP)
90 *
91 * You then need to either add a IEEE80211_xxxx_DEBUG() macro definition for your
92 * classification, or use IEEE80211_DEBUG(IEEE80211_DL_xxxx, ...) whenever you want
93 * to send output to that classification.
94 *
95 * To add your debug level to the list of levels seen when you perform
96 *
Jouni Malinen91cb70c2005-08-28 10:51:34 -070097 * % cat /proc/net/ieee80211/debug_level
Jeff Garzikb4538722005-05-12 22:48:20 -040098 *
Jouni Malinen91cb70c2005-08-28 10:51:34 -070099 * you simply need to add your entry to the ieee80211_debug_level array.
Jeff Garzikb4538722005-05-12 22:48:20 -0400100 *
Jouni Malinen91cb70c2005-08-28 10:51:34 -0700101 * If you do not see debug_level in /proc/net/ieee80211 then you do not have
Helmut Schaa37561622009-03-06 12:02:25 +0100102 * CONFIG_LIBIPW_DEBUG defined in your kernel configuration
Jeff Garzikb4538722005-05-12 22:48:20 -0400103 *
104 */
105
106#define IEEE80211_DL_INFO (1<<0)
107#define IEEE80211_DL_WX (1<<1)
108#define IEEE80211_DL_SCAN (1<<2)
109#define IEEE80211_DL_STATE (1<<3)
110#define IEEE80211_DL_MGMT (1<<4)
111#define IEEE80211_DL_FRAG (1<<5)
Jeff Garzikb4538722005-05-12 22:48:20 -0400112#define IEEE80211_DL_DROP (1<<7)
113
114#define IEEE80211_DL_TX (1<<8)
115#define IEEE80211_DL_RX (1<<9)
James Ketrenos9e8571a2005-09-21 11:56:33 -0500116#define IEEE80211_DL_QOS (1<<31)
Jeff Garzikb4538722005-05-12 22:48:20 -0400117
118#define IEEE80211_ERROR(f, a...) printk(KERN_ERR "ieee80211: " f, ## a)
119#define IEEE80211_WARNING(f, a...) printk(KERN_WARNING "ieee80211: " f, ## a)
120#define IEEE80211_DEBUG_INFO(f, a...) IEEE80211_DEBUG(IEEE80211_DL_INFO, f, ## a)
121
122#define IEEE80211_DEBUG_WX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_WX, f, ## a)
123#define IEEE80211_DEBUG_SCAN(f, a...) IEEE80211_DEBUG(IEEE80211_DL_SCAN, f, ## a)
124#define IEEE80211_DEBUG_STATE(f, a...) IEEE80211_DEBUG(IEEE80211_DL_STATE, f, ## a)
125#define IEEE80211_DEBUG_MGMT(f, a...) IEEE80211_DEBUG(IEEE80211_DL_MGMT, f, ## a)
126#define IEEE80211_DEBUG_FRAG(f, a...) IEEE80211_DEBUG(IEEE80211_DL_FRAG, f, ## a)
Jeff Garzikb4538722005-05-12 22:48:20 -0400127#define IEEE80211_DEBUG_DROP(f, a...) IEEE80211_DEBUG(IEEE80211_DL_DROP, f, ## a)
128#define IEEE80211_DEBUG_TX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_TX, f, ## a)
129#define IEEE80211_DEBUG_RX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_RX, f, ## a)
James Ketrenos9e8571a2005-09-21 11:56:33 -0500130#define IEEE80211_DEBUG_QOS(f, a...) IEEE80211_DEBUG(IEEE80211_DL_QOS, f, ## a)
Jeff Garzikb4538722005-05-12 22:48:20 -0400131#include <linux/netdevice.h>
James Ketrenos74079fd2005-09-13 17:35:21 -0500132#include <linux/if_arp.h> /* ARPHRD_ETHER */
Jeff Garzikb4538722005-05-12 22:48:20 -0400133
134#ifndef WIRELESS_SPY
Jiri Benc099c5bb2005-08-25 20:15:10 -0400135#define WIRELESS_SPY /* enable iwspy support */
Jeff Garzikb4538722005-05-12 22:48:20 -0400136#endif
Jiri Benc099c5bb2005-08-25 20:15:10 -0400137#include <net/iw_handler.h> /* new driver API */
Jeff Garzikb4538722005-05-12 22:48:20 -0400138
James Ketrenos74079fd2005-09-13 17:35:21 -0500139#define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
Jeff Garzikb4538722005-05-12 22:48:20 -0400140
141#ifndef ETH_P_80211_RAW
142#define ETH_P_80211_RAW (ETH_P_ECONET + 1)
143#endif
144
145/* IEEE 802.11 defines */
146
147#define P80211_OUI_LEN 3
148
149struct ieee80211_snap_hdr {
150
James Ketrenos74079fd2005-09-13 17:35:21 -0500151 u8 dsap; /* always 0xAA */
152 u8 ssap; /* always 0xAA */
153 u8 ctrl; /* always 0x03 */
154 u8 oui[P80211_OUI_LEN]; /* organizational universal id */
Jeff Garzikb4538722005-05-12 22:48:20 -0400155
156} __attribute__ ((packed));
157
158#define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
159
Jiri Bencf13baae2005-08-25 20:11:46 -0400160#define WLAN_FC_GET_VERS(fc) ((fc) & IEEE80211_FCTL_VERS)
Jeff Garzikb4538722005-05-12 22:48:20 -0400161#define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE)
162#define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE)
163
164#define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG)
Zhu Yi3eb54602006-12-18 17:26:13 +0800165#define WLAN_GET_SEQ_SEQ(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
Jeff Garzikb4538722005-05-12 22:48:20 -0400166
Jeff Garzikb4538722005-05-12 22:48:20 -0400167#define IEEE80211_STATMASK_SIGNAL (1<<0)
168#define IEEE80211_STATMASK_RSSI (1<<1)
169#define IEEE80211_STATMASK_NOISE (1<<2)
170#define IEEE80211_STATMASK_RATE (1<<3)
171#define IEEE80211_STATMASK_WEMASK 0x7
172
Jeff Garzikb4538722005-05-12 22:48:20 -0400173#define IEEE80211_CCK_MODULATION (1<<0)
174#define IEEE80211_OFDM_MODULATION (1<<1)
175
176#define IEEE80211_24GHZ_BAND (1<<0)
177#define IEEE80211_52GHZ_BAND (1<<1)
178
179#define IEEE80211_CCK_RATE_1MB 0x02
180#define IEEE80211_CCK_RATE_2MB 0x04
181#define IEEE80211_CCK_RATE_5MB 0x0B
182#define IEEE80211_CCK_RATE_11MB 0x16
183#define IEEE80211_OFDM_RATE_6MB 0x0C
184#define IEEE80211_OFDM_RATE_9MB 0x12
185#define IEEE80211_OFDM_RATE_12MB 0x18
186#define IEEE80211_OFDM_RATE_18MB 0x24
187#define IEEE80211_OFDM_RATE_24MB 0x30
188#define IEEE80211_OFDM_RATE_36MB 0x48
189#define IEEE80211_OFDM_RATE_48MB 0x60
190#define IEEE80211_OFDM_RATE_54MB 0x6C
191#define IEEE80211_BASIC_RATE_MASK 0x80
192
193#define IEEE80211_CCK_RATE_1MB_MASK (1<<0)
194#define IEEE80211_CCK_RATE_2MB_MASK (1<<1)
195#define IEEE80211_CCK_RATE_5MB_MASK (1<<2)
196#define IEEE80211_CCK_RATE_11MB_MASK (1<<3)
197#define IEEE80211_OFDM_RATE_6MB_MASK (1<<4)
198#define IEEE80211_OFDM_RATE_9MB_MASK (1<<5)
199#define IEEE80211_OFDM_RATE_12MB_MASK (1<<6)
200#define IEEE80211_OFDM_RATE_18MB_MASK (1<<7)
201#define IEEE80211_OFDM_RATE_24MB_MASK (1<<8)
202#define IEEE80211_OFDM_RATE_36MB_MASK (1<<9)
203#define IEEE80211_OFDM_RATE_48MB_MASK (1<<10)
204#define IEEE80211_OFDM_RATE_54MB_MASK (1<<11)
205
206#define IEEE80211_CCK_RATES_MASK 0x0000000F
207#define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \
208 IEEE80211_CCK_RATE_2MB_MASK)
209#define IEEE80211_CCK_DEFAULT_RATES_MASK (IEEE80211_CCK_BASIC_RATES_MASK | \
210 IEEE80211_CCK_RATE_5MB_MASK | \
211 IEEE80211_CCK_RATE_11MB_MASK)
212
213#define IEEE80211_OFDM_RATES_MASK 0x00000FF0
214#define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \
215 IEEE80211_OFDM_RATE_12MB_MASK | \
216 IEEE80211_OFDM_RATE_24MB_MASK)
217#define IEEE80211_OFDM_DEFAULT_RATES_MASK (IEEE80211_OFDM_BASIC_RATES_MASK | \
218 IEEE80211_OFDM_RATE_9MB_MASK | \
219 IEEE80211_OFDM_RATE_18MB_MASK | \
220 IEEE80211_OFDM_RATE_36MB_MASK | \
221 IEEE80211_OFDM_RATE_48MB_MASK | \
222 IEEE80211_OFDM_RATE_54MB_MASK)
223#define IEEE80211_DEFAULT_RATES_MASK (IEEE80211_OFDM_DEFAULT_RATES_MASK | \
224 IEEE80211_CCK_DEFAULT_RATES_MASK)
225
226#define IEEE80211_NUM_OFDM_RATES 8
227#define IEEE80211_NUM_CCK_RATES 4
228#define IEEE80211_OFDM_SHIFT_MASK_A 4
229
Jeff Garzikb4538722005-05-12 22:48:20 -0400230/* NOTE: This data is for statistical purposes; not all hardware provides this
Johannes Bergc9fa7d52005-12-27 02:14:13 +0100231 * information for frames received.
232 * For ieee80211_rx_mgt, you need to set at least the 'len' parameter.
233 */
Jeff Garzikb4538722005-05-12 22:48:20 -0400234struct ieee80211_rx_stats {
235 u32 mac_time;
236 s8 rssi;
237 u8 signal;
238 u8 noise;
James Ketrenos74079fd2005-09-13 17:35:21 -0500239 u16 rate; /* in 100 kbps */
Jeff Garzikb4538722005-05-12 22:48:20 -0400240 u8 received_channel;
241 u8 control;
242 u8 mask;
243 u8 freq;
244 u16 len;
Zhu Yib79e20b2006-01-19 16:21:27 +0800245 u64 tsf;
246 u32 beacon_time;
Jeff Garzikb4538722005-05-12 22:48:20 -0400247};
248
249/* IEEE 802.11 requires that STA supports concurrent reception of at least
250 * three fragmented frames. This define can be increased to support more
251 * concurrent frames, but it should be noted that each entry can consume about
252 * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
253#define IEEE80211_FRAG_CACHE_LEN 4
254
255struct ieee80211_frag_entry {
256 unsigned long first_frag_time;
257 unsigned int seq;
258 unsigned int last_frag;
259 struct sk_buff *skb;
260 u8 src_addr[ETH_ALEN];
261 u8 dst_addr[ETH_ALEN];
262};
263
264struct ieee80211_stats {
265 unsigned int tx_unicast_frames;
266 unsigned int tx_multicast_frames;
267 unsigned int tx_fragments;
268 unsigned int tx_unicast_octets;
269 unsigned int tx_multicast_octets;
270 unsigned int tx_deferred_transmissions;
271 unsigned int tx_single_retry_frames;
272 unsigned int tx_multiple_retry_frames;
273 unsigned int tx_retry_limit_exceeded;
274 unsigned int tx_discards;
275 unsigned int rx_unicast_frames;
276 unsigned int rx_multicast_frames;
277 unsigned int rx_fragments;
278 unsigned int rx_unicast_octets;
279 unsigned int rx_multicast_octets;
280 unsigned int rx_fcs_errors;
281 unsigned int rx_discards_no_buffer;
282 unsigned int tx_discards_wrong_sa;
283 unsigned int rx_discards_undecryptable;
284 unsigned int rx_message_in_msg_fragments;
285 unsigned int rx_message_in_bad_msg_fragments;
286};
287
288struct ieee80211_device;
289
James Ketrenosf1bf6632005-09-21 11:53:54 -0500290#define SEC_KEY_1 (1<<0)
291#define SEC_KEY_2 (1<<1)
292#define SEC_KEY_3 (1<<2)
293#define SEC_KEY_4 (1<<3)
294#define SEC_ACTIVE_KEY (1<<4)
295#define SEC_AUTH_MODE (1<<5)
296#define SEC_UNICAST_GROUP (1<<6)
297#define SEC_LEVEL (1<<7)
298#define SEC_ENABLED (1<<8)
James Ketrenos259bf1f2005-09-21 11:54:22 -0500299#define SEC_ENCRYPT (1<<9)
Jeff Garzikb4538722005-05-12 22:48:20 -0400300
James Ketrenosf1bf6632005-09-21 11:53:54 -0500301#define SEC_LEVEL_0 0 /* None */
302#define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */
303#define SEC_LEVEL_2 2 /* Level 1 + TKIP */
304#define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
305#define SEC_LEVEL_3 4 /* Level 2 + CCMP */
Jeff Garzikb4538722005-05-12 22:48:20 -0400306
James Ketrenose0d369d2005-09-21 11:54:30 -0500307#define SEC_ALG_NONE 0
308#define SEC_ALG_WEP 1
309#define SEC_ALG_TKIP 2
310#define SEC_ALG_CCMP 3
311
James Ketrenosf1bf6632005-09-21 11:53:54 -0500312#define WEP_KEYS 4
313#define WEP_KEY_LEN 13
314#define SCM_KEY_LEN 32
315#define SCM_TEMPORAL_KEY_LENGTH 16
Jeff Garzikb4538722005-05-12 22:48:20 -0400316
317struct ieee80211_security {
John W. Linville0f202aa2008-12-08 14:51:41 -0500318 u16 active_key:2, enabled:1, unicast_uses_group:1, encrypt:1;
319 u8 auth_mode;
James Ketrenose0d369d2005-09-21 11:54:30 -0500320 u8 encode_alg[WEP_KEYS];
Jeff Garzikb4538722005-05-12 22:48:20 -0400321 u8 key_sizes[WEP_KEYS];
James Ketrenosf1bf6632005-09-21 11:53:54 -0500322 u8 keys[WEP_KEYS][SCM_KEY_LEN];
Jeff Garzikb4538722005-05-12 22:48:20 -0400323 u8 level;
324 u16 flags;
325} __attribute__ ((packed));
326
Jeff Garzikb4538722005-05-12 22:48:20 -0400327/*
328
329 802.11 data frame from AP
330
331 ,-------------------------------------------------------------------.
332Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
333 |------|------|---------|---------|---------|------|---------|------|
334Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs |
335 | | tion | (BSSID) | | | ence | data | |
336 `-------------------------------------------------------------------'
337
338Total: 28-2340 bytes
339
340*/
341
Jeff Garzikb4538722005-05-12 22:48:20 -0400342#define BEACON_PROBE_SSID_ID_POSITION 12
343
James Ketrenosee34af32005-09-21 11:54:36 -0500344struct ieee80211_hdr_1addr {
James Ketrenoscdcfc212005-09-21 11:56:49 -0500345 __le16 frame_ctl;
346 __le16 duration_id;
James Ketrenosee34af32005-09-21 11:54:36 -0500347 u8 addr1[ETH_ALEN];
348 u8 payload[0];
349} __attribute__ ((packed));
350
351struct ieee80211_hdr_2addr {
James Ketrenoscdcfc212005-09-21 11:56:49 -0500352 __le16 frame_ctl;
353 __le16 duration_id;
James Ketrenosee34af32005-09-21 11:54:36 -0500354 u8 addr1[ETH_ALEN];
355 u8 addr2[ETH_ALEN];
356 u8 payload[0];
357} __attribute__ ((packed));
358
359struct ieee80211_hdr_3addr {
James Ketrenoscdcfc212005-09-21 11:56:49 -0500360 __le16 frame_ctl;
361 __le16 duration_id;
James Ketrenosee34af32005-09-21 11:54:36 -0500362 u8 addr1[ETH_ALEN];
363 u8 addr2[ETH_ALEN];
364 u8 addr3[ETH_ALEN];
James Ketrenoscdcfc212005-09-21 11:56:49 -0500365 __le16 seq_ctl;
James Ketrenosee34af32005-09-21 11:54:36 -0500366 u8 payload[0];
367} __attribute__ ((packed));
368
369struct ieee80211_hdr_4addr {
James Ketrenoscdcfc212005-09-21 11:56:49 -0500370 __le16 frame_ctl;
371 __le16 duration_id;
James Ketrenosee34af32005-09-21 11:54:36 -0500372 u8 addr1[ETH_ALEN];
373 u8 addr2[ETH_ALEN];
374 u8 addr3[ETH_ALEN];
James Ketrenoscdcfc212005-09-21 11:56:49 -0500375 __le16 seq_ctl;
James Ketrenosee34af32005-09-21 11:54:36 -0500376 u8 addr4[ETH_ALEN];
377 u8 payload[0];
378} __attribute__ ((packed));
379
James Ketrenos9e8571a2005-09-21 11:56:33 -0500380struct ieee80211_hdr_3addrqos {
James Ketrenoscdcfc212005-09-21 11:56:49 -0500381 __le16 frame_ctl;
382 __le16 duration_id;
James Ketrenos9e8571a2005-09-21 11:56:33 -0500383 u8 addr1[ETH_ALEN];
384 u8 addr2[ETH_ALEN];
385 u8 addr3[ETH_ALEN];
James Ketrenoscdcfc212005-09-21 11:56:49 -0500386 __le16 seq_ctl;
James Ketrenos9e8571a2005-09-21 11:56:33 -0500387 u8 payload[0];
James Ketrenoscdcfc212005-09-21 11:56:49 -0500388 __le16 qos_ctl;
James Ketrenos9e8571a2005-09-21 11:56:33 -0500389} __attribute__ ((packed));
390
Jeff Garzikb4538722005-05-12 22:48:20 -0400391struct ieee80211_info_element {
392 u8 id;
393 u8 len;
394 u8 data[0];
395} __attribute__ ((packed));
396
397/*
398 * These are the data types that can make up management packets
399 *
400 u16 auth_algorithm;
401 u16 auth_sequence;
402 u16 beacon_interval;
403 u16 capability;
404 u8 current_ap[ETH_ALEN];
405 u16 listen_interval;
406 struct {
407 u16 association_id:14, reserved:2;
408 } __attribute__ ((packed));
409 u32 time_stamp[2];
410 u16 reason;
411 u16 status;
412*/
413
James Ketrenosee34af32005-09-21 11:54:36 -0500414struct ieee80211_auth {
Jiri Benc286d9742005-05-24 15:10:18 +0200415 struct ieee80211_hdr_3addr header;
Jiri Benc099c5bb2005-08-25 20:15:10 -0400416 __le16 algorithm;
417 __le16 transaction;
418 __le16 status;
James Ketrenose5658d32005-09-21 11:58:56 -0500419 /* challenge */
James Ketrenos68e4e032005-09-13 17:37:22 -0500420 struct ieee80211_info_element info_element[0];
Jeff Garzikb4538722005-05-12 22:48:20 -0400421} __attribute__ ((packed));
422
Zhu Yib79e20b2006-01-19 16:21:27 +0800423struct ieee80211_channel_switch {
424 u8 id;
425 u8 len;
426 u8 mode;
427 u8 channel;
428 u8 count;
429} __attribute__ ((packed));
430
431struct ieee80211_action {
432 struct ieee80211_hdr_3addr header;
433 u8 category;
434 u8 action;
435 union {
436 struct ieee80211_action_exchange {
437 u8 token;
438 struct ieee80211_info_element info_element[0];
439 } exchange;
440 struct ieee80211_channel_switch channel_switch;
441
442 } format;
443} __attribute__ ((packed));
444
James Ketrenosee34af32005-09-21 11:54:36 -0500445struct ieee80211_disassoc {
446 struct ieee80211_hdr_3addr header;
James Ketrenose5658d32005-09-21 11:58:56 -0500447 __le16 reason;
James Ketrenosee34af32005-09-21 11:54:36 -0500448} __attribute__ ((packed));
449
James Ketrenose5658d32005-09-21 11:58:56 -0500450/* Alias deauth for disassoc */
Michael Wu604116a2005-09-28 15:16:46 -0500451#define ieee80211_deauth ieee80211_disassoc
James Ketrenose5658d32005-09-21 11:58:56 -0500452
James Ketrenosee34af32005-09-21 11:54:36 -0500453struct ieee80211_probe_request {
454 struct ieee80211_hdr_3addr header;
James Ketrenose5658d32005-09-21 11:58:56 -0500455 /* SSID, supported rates */
James Ketrenosee34af32005-09-21 11:54:36 -0500456 struct ieee80211_info_element info_element[0];
457} __attribute__ ((packed));
458
Jeff Garzikb4538722005-05-12 22:48:20 -0400459struct ieee80211_probe_response {
Jiri Benc286d9742005-05-24 15:10:18 +0200460 struct ieee80211_hdr_3addr header;
Al Virod9e94d52007-12-29 05:01:07 -0500461 __le32 time_stamp[2];
Jiri Benc099c5bb2005-08-25 20:15:10 -0400462 __le16 beacon_interval;
463 __le16 capability;
James Ketrenose5658d32005-09-21 11:58:56 -0500464 /* SSID, supported rates, FH params, DS params,
465 * CF params, IBSS params, TIM (if beacon), RSN */
James Ketrenos68e4e032005-09-13 17:37:22 -0500466 struct ieee80211_info_element info_element[0];
Jeff Garzikb4538722005-05-12 22:48:20 -0400467} __attribute__ ((packed));
468
James Ketrenosee34af32005-09-21 11:54:36 -0500469/* Alias beacon for probe_response */
470#define ieee80211_beacon ieee80211_probe_response
471
472struct ieee80211_assoc_request {
473 struct ieee80211_hdr_3addr header;
James Ketrenoscdcfc212005-09-21 11:56:49 -0500474 __le16 capability;
475 __le16 listen_interval;
James Ketrenose5658d32005-09-21 11:58:56 -0500476 /* SSID, supported rates, RSN */
James Ketrenosee34af32005-09-21 11:54:36 -0500477 struct ieee80211_info_element info_element[0];
478} __attribute__ ((packed));
479
480struct ieee80211_reassoc_request {
481 struct ieee80211_hdr_3addr header;
Jiri Benc099c5bb2005-08-25 20:15:10 -0400482 __le16 capability;
483 __le16 listen_interval;
Jeff Garzikb4538722005-05-12 22:48:20 -0400484 u8 current_ap[ETH_ALEN];
James Ketrenos68e4e032005-09-13 17:37:22 -0500485 struct ieee80211_info_element info_element[0];
Jeff Garzikb4538722005-05-12 22:48:20 -0400486} __attribute__ ((packed));
487
James Ketrenosee34af32005-09-21 11:54:36 -0500488struct ieee80211_assoc_response {
Jeff Garzikb4538722005-05-12 22:48:20 -0400489 struct ieee80211_hdr_3addr header;
Jiri Benc099c5bb2005-08-25 20:15:10 -0400490 __le16 capability;
491 __le16 status;
492 __le16 aid;
James Ketrenose5658d32005-09-21 11:58:56 -0500493 /* supported rates */
494 struct ieee80211_info_element info_element[0];
Jeff Garzikb4538722005-05-12 22:48:20 -0400495} __attribute__ ((packed));
496
Jeff Garzikb4538722005-05-12 22:48:20 -0400497struct ieee80211_txb {
498 u8 nr_frags;
499 u8 encrypted;
James Ketrenosee34af32005-09-21 11:54:36 -0500500 u8 rts_included;
501 u8 reserved;
Al Virod9e94d52007-12-29 05:01:07 -0500502 u16 frag_size;
503 u16 payload_size;
Jeff Garzikb4538722005-05-12 22:48:20 -0400504 struct sk_buff *fragments[0];
505};
506
Jiri Benc099c5bb2005-08-25 20:15:10 -0400507/* SWEEP TABLE ENTRIES NUMBER */
Jeff Garzikb4538722005-05-12 22:48:20 -0400508#define MAX_SWEEP_TAB_ENTRIES 42
509#define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
510/* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs
511 * only use 8, and then use extended rates for the remaining supported
512 * rates. Other APs, however, stick all of their supported rates on the
513 * main rates information element... */
514#define MAX_RATES_LENGTH ((u8)12)
515#define MAX_RATES_EX_LENGTH ((u8)16)
516#define MAX_NETWORK_COUNT 128
517
518#define CRC_LENGTH 4U
519
520#define MAX_WPA_IE_LEN 64
521
James Ketrenos9e8571a2005-09-21 11:56:33 -0500522#define NETWORK_HAS_OFDM (1<<1)
523#define NETWORK_HAS_CCK (1<<2)
524
525/* QoS structure */
526#define NETWORK_HAS_QOS_PARAMETERS (1<<3)
527#define NETWORK_HAS_QOS_INFORMATION (1<<4)
Zhu Yib79e20b2006-01-19 16:21:27 +0800528#define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \
529 NETWORK_HAS_QOS_INFORMATION)
530
531/* 802.11h */
532#define NETWORK_HAS_POWER_CONSTRAINT (1<<5)
533#define NETWORK_HAS_CSA (1<<6)
534#define NETWORK_HAS_QUIET (1<<7)
535#define NETWORK_HAS_IBSS_DFS (1<<8)
536#define NETWORK_HAS_TPC_REPORT (1<<9)
James Ketrenos9e8571a2005-09-21 11:56:33 -0500537
Daniel Draked8e2be92006-07-18 21:30:34 +0100538#define NETWORK_HAS_ERP_VALUE (1<<10)
539
James Ketrenos9e8571a2005-09-21 11:56:33 -0500540#define QOS_QUEUE_NUM 4
541#define QOS_OUI_LEN 3
542#define QOS_OUI_TYPE 2
543#define QOS_ELEMENT_ID 221
544#define QOS_OUI_INFO_SUB_TYPE 0
545#define QOS_OUI_PARAM_SUB_TYPE 1
546#define QOS_VERSION_1 1
547#define QOS_AIFSN_MIN_VALUE 2
548
549struct ieee80211_qos_information_element {
550 u8 elementID;
551 u8 length;
552 u8 qui[QOS_OUI_LEN];
553 u8 qui_type;
554 u8 qui_subtype;
555 u8 version;
556 u8 ac_info;
557} __attribute__ ((packed));
558
559struct ieee80211_qos_ac_parameter {
560 u8 aci_aifsn;
561 u8 ecw_min_max;
James Ketrenoscdcfc212005-09-21 11:56:49 -0500562 __le16 tx_op_limit;
James Ketrenos9e8571a2005-09-21 11:56:33 -0500563} __attribute__ ((packed));
564
565struct ieee80211_qos_parameter_info {
566 struct ieee80211_qos_information_element info_element;
567 u8 reserved;
568 struct ieee80211_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM];
569} __attribute__ ((packed));
570
571struct ieee80211_qos_parameters {
James Ketrenoscdcfc212005-09-21 11:56:49 -0500572 __le16 cw_min[QOS_QUEUE_NUM];
573 __le16 cw_max[QOS_QUEUE_NUM];
James Ketrenos9e8571a2005-09-21 11:56:33 -0500574 u8 aifs[QOS_QUEUE_NUM];
575 u8 flag[QOS_QUEUE_NUM];
James Ketrenoscdcfc212005-09-21 11:56:49 -0500576 __le16 tx_op_limit[QOS_QUEUE_NUM];
James Ketrenos9e8571a2005-09-21 11:56:33 -0500577} __attribute__ ((packed));
578
579struct ieee80211_qos_data {
580 struct ieee80211_qos_parameters parameters;
581 int active;
582 int supported;
583 u8 param_count;
584 u8 old_param_count;
585};
586
587struct ieee80211_tim_parameters {
588 u8 tim_count;
589 u8 tim_period;
590} __attribute__ ((packed));
591
592/*******************************************************/
Jeff Garzikb4538722005-05-12 22:48:20 -0400593
Zhu Yib79e20b2006-01-19 16:21:27 +0800594enum { /* ieee80211_basic_report.map */
595 IEEE80211_BASIC_MAP_BSS = (1 << 0),
596 IEEE80211_BASIC_MAP_OFDM = (1 << 1),
597 IEEE80211_BASIC_MAP_UNIDENTIFIED = (1 << 2),
598 IEEE80211_BASIC_MAP_RADAR = (1 << 3),
599 IEEE80211_BASIC_MAP_UNMEASURED = (1 << 4),
600 /* Bits 5-7 are reserved */
601
602};
603struct ieee80211_basic_report {
604 u8 channel;
605 __le64 start_time;
606 __le16 duration;
607 u8 map;
608} __attribute__ ((packed));
609
610enum { /* ieee80211_measurement_request.mode */
611 /* Bit 0 is reserved */
612 IEEE80211_MEASUREMENT_ENABLE = (1 << 1),
613 IEEE80211_MEASUREMENT_REQUEST = (1 << 2),
614 IEEE80211_MEASUREMENT_REPORT = (1 << 3),
615 /* Bits 4-7 are reserved */
616};
617
618enum {
619 IEEE80211_REPORT_BASIC = 0, /* required */
620 IEEE80211_REPORT_CCA = 1, /* optional */
621 IEEE80211_REPORT_RPI = 2, /* optional */
622 /* 3-255 reserved */
623};
624
625struct ieee80211_measurement_params {
626 u8 channel;
627 __le64 start_time;
628 __le16 duration;
629} __attribute__ ((packed));
630
631struct ieee80211_measurement_request {
632 struct ieee80211_info_element ie;
633 u8 token;
634 u8 mode;
635 u8 type;
636 struct ieee80211_measurement_params params[0];
637} __attribute__ ((packed));
638
639struct ieee80211_measurement_report {
640 struct ieee80211_info_element ie;
641 u8 token;
642 u8 mode;
643 u8 type;
644 union {
645 struct ieee80211_basic_report basic[0];
646 } u;
647} __attribute__ ((packed));
648
649struct ieee80211_tpc_report {
650 u8 transmit_power;
651 u8 link_margin;
652} __attribute__ ((packed));
653
654struct ieee80211_channel_map {
655 u8 channel;
656 u8 map;
657} __attribute__ ((packed));
658
659struct ieee80211_ibss_dfs {
660 struct ieee80211_info_element ie;
661 u8 owner[ETH_ALEN];
662 u8 recovery_interval;
663 struct ieee80211_channel_map channel_map[0];
664};
665
666struct ieee80211_csa {
667 u8 mode;
668 u8 channel;
669 u8 count;
670} __attribute__ ((packed));
671
672struct ieee80211_quiet {
673 u8 count;
674 u8 period;
675 u8 duration;
676 u8 offset;
677} __attribute__ ((packed));
678
Jeff Garzikb4538722005-05-12 22:48:20 -0400679struct ieee80211_network {
680 /* These entries are used to identify a unique network */
681 u8 bssid[ETH_ALEN];
682 u8 channel;
683 /* Ensure null-terminated for any debug msgs */
684 u8 ssid[IW_ESSID_MAX_SIZE + 1];
685 u8 ssid_len;
686
James Ketrenos9e8571a2005-09-21 11:56:33 -0500687 struct ieee80211_qos_data qos_data;
688
Jeff Garzikb4538722005-05-12 22:48:20 -0400689 /* These are network statistics */
690 struct ieee80211_rx_stats stats;
691 u16 capability;
692 u8 rates[MAX_RATES_LENGTH];
693 u8 rates_len;
694 u8 rates_ex[MAX_RATES_EX_LENGTH];
695 u8 rates_ex_len;
696 unsigned long last_scanned;
697 u8 mode;
Zhu Yib79e20b2006-01-19 16:21:27 +0800698 u32 flags;
Jeff Garzikb4538722005-05-12 22:48:20 -0400699 u32 last_associate;
700 u32 time_stamp[2];
701 u16 beacon_interval;
702 u16 listen_interval;
703 u16 atim_window;
James Ketrenos42c94e42005-09-21 11:58:29 -0500704 u8 erp_value;
Jeff Garzikb4538722005-05-12 22:48:20 -0400705 u8 wpa_ie[MAX_WPA_IE_LEN];
706 size_t wpa_ie_len;
707 u8 rsn_ie[MAX_WPA_IE_LEN];
708 size_t rsn_ie_len;
James Ketrenos9e8571a2005-09-21 11:56:33 -0500709 struct ieee80211_tim_parameters tim;
Zhu Yib79e20b2006-01-19 16:21:27 +0800710
711 /* 802.11h info */
712
713 /* Power Constraint - mandatory if spctrm mgmt required */
714 u8 power_constraint;
715
716 /* TPC Report - mandatory if spctrm mgmt required */
717 struct ieee80211_tpc_report tpc_report;
718
719 /* IBSS DFS - mandatory if spctrm mgmt required and IBSS
720 * NOTE: This is variable length and so must be allocated dynamically */
721 struct ieee80211_ibss_dfs *ibss_dfs;
722
723 /* Channel Switch Announcement - optional if spctrm mgmt required */
724 struct ieee80211_csa csa;
725
726 /* Quiet - optional if spctrm mgmt required */
727 struct ieee80211_quiet quiet;
728
Jeff Garzikb4538722005-05-12 22:48:20 -0400729 struct list_head list;
730};
731
732enum ieee80211_state {
733 IEEE80211_UNINITIALIZED = 0,
734 IEEE80211_INITIALIZED,
735 IEEE80211_ASSOCIATING,
736 IEEE80211_ASSOCIATED,
737 IEEE80211_AUTHENTICATING,
738 IEEE80211_AUTHENTICATED,
739 IEEE80211_SHUTDOWN
740};
741
742#define DEFAULT_MAX_SCAN_AGE (15 * HZ)
743#define DEFAULT_FTS 2346
Jeff Garzikb4538722005-05-12 22:48:20 -0400744
Jeff Garzikb4538722005-05-12 22:48:20 -0400745#define CFG_IEEE80211_RESERVE_FCS (1<<0)
746#define CFG_IEEE80211_COMPUTE_FCS (1<<1)
James Ketrenos3cdd00c2005-09-21 11:54:43 -0500747#define CFG_IEEE80211_RTS (1<<2)
Jeff Garzikb4538722005-05-12 22:48:20 -0400748
James Ketrenos02cda6a2005-09-21 11:56:38 -0500749#define IEEE80211_24GHZ_MIN_CHANNEL 1
750#define IEEE80211_24GHZ_MAX_CHANNEL 14
Jean Delvaref21709d2006-05-04 19:47:19 +0200751#define IEEE80211_24GHZ_CHANNELS (IEEE80211_24GHZ_MAX_CHANNEL - \
752 IEEE80211_24GHZ_MIN_CHANNEL + 1)
James Ketrenos02cda6a2005-09-21 11:56:38 -0500753
Zhu Yi4a99ac32006-01-19 16:21:19 +0800754#define IEEE80211_52GHZ_MIN_CHANNEL 34
James Ketrenos02cda6a2005-09-21 11:56:38 -0500755#define IEEE80211_52GHZ_MAX_CHANNEL 165
Jean Delvaref21709d2006-05-04 19:47:19 +0200756#define IEEE80211_52GHZ_CHANNELS (IEEE80211_52GHZ_MAX_CHANNEL - \
757 IEEE80211_52GHZ_MIN_CHANNEL + 1)
James Ketrenos02cda6a2005-09-21 11:56:38 -0500758
759enum {
760 IEEE80211_CH_PASSIVE_ONLY = (1 << 0),
Larry Finger74f49032006-05-30 11:55:42 -0500761 IEEE80211_CH_80211H_RULES = (1 << 1),
James Ketrenos02cda6a2005-09-21 11:56:38 -0500762 IEEE80211_CH_B_ONLY = (1 << 2),
763 IEEE80211_CH_NO_IBSS = (1 << 3),
764 IEEE80211_CH_UNIFORM_SPREADING = (1 << 4),
765 IEEE80211_CH_RADAR_DETECT = (1 << 5),
766 IEEE80211_CH_INVALID = (1 << 6),
767};
768
769struct ieee80211_channel {
Larry Finger74f49032006-05-30 11:55:42 -0500770 u32 freq; /* in MHz */
James Ketrenos02cda6a2005-09-21 11:56:38 -0500771 u8 channel;
772 u8 flags;
Larry Finger74f49032006-05-30 11:55:42 -0500773 u8 max_power; /* in dBm */
James Ketrenos02cda6a2005-09-21 11:56:38 -0500774};
775
776struct ieee80211_geo {
777 u8 name[4];
778 u8 bg_channels;
779 u8 a_channels;
780 struct ieee80211_channel bg[IEEE80211_24GHZ_CHANNELS];
781 struct ieee80211_channel a[IEEE80211_52GHZ_CHANNELS];
782};
783
Jeff Garzikb4538722005-05-12 22:48:20 -0400784struct ieee80211_device {
785 struct net_device *dev;
James Ketrenosf1bf6632005-09-21 11:53:54 -0500786 struct ieee80211_security sec;
Jeff Garzikb4538722005-05-12 22:48:20 -0400787
788 /* Bookkeeping structures */
Jeff Garzikb4538722005-05-12 22:48:20 -0400789 struct ieee80211_stats ieee_stats;
790
James Ketrenos02cda6a2005-09-21 11:56:38 -0500791 struct ieee80211_geo geo;
792
Jeff Garzikb4538722005-05-12 22:48:20 -0400793 /* Probe / Beacon management */
794 struct list_head network_free_list;
795 struct list_head network_list;
796 struct ieee80211_network *networks;
797 int scans;
798 int scan_age;
799
James Ketrenos74079fd2005-09-13 17:35:21 -0500800 int iw_mode; /* operating mode (IW_MODE_*) */
801 struct iw_spy_data spy_data; /* iwspy support */
Jeff Garzikb4538722005-05-12 22:48:20 -0400802
803 spinlock_t lock;
804
James Ketrenos74079fd2005-09-13 17:35:21 -0500805 int tx_headroom; /* Set to size of any additional room needed at front
806 * of allocated Tx SKBs */
Jeff Garzikb4538722005-05-12 22:48:20 -0400807 u32 config;
808
809 /* WEP and other encryption related settings at the device level */
James Ketrenos74079fd2005-09-13 17:35:21 -0500810 int open_wep; /* Set to 1 to allow unencrypted frames */
Jeff Garzikb4538722005-05-12 22:48:20 -0400811
James Ketrenos74079fd2005-09-13 17:35:21 -0500812 int reset_on_keychange; /* Set to 1 if the HW needs to be reset on
Jeff Garzikb4538722005-05-12 22:48:20 -0400813 * WEP key changes */
814
815 /* If the host performs {en,de}cryption, then set to 1 */
816 int host_encrypt;
James Ketrenos1264fc02005-09-21 11:54:53 -0500817 int host_encrypt_msdu;
Jeff Garzikb4538722005-05-12 22:48:20 -0400818 int host_decrypt;
James Ketrenosccd0fda2005-09-21 11:58:32 -0500819 /* host performs multicast decryption */
820 int host_mc_decrypt;
821
Daniel Drakec9308b02006-09-27 03:50:31 +0100822 /* host should strip IV and ICV from protected frames */
823 /* meaningful only when hardware decryption is being used */
824 int host_strip_iv_icv;
825
James Ketrenos1264fc02005-09-21 11:54:53 -0500826 int host_open_frag;
James Ketrenos31b59ea2005-09-21 11:58:49 -0500827 int host_build_iv;
James Ketrenos74079fd2005-09-13 17:35:21 -0500828 int ieee802_1x; /* is IEEE 802.1X used */
Jeff Garzikb4538722005-05-12 22:48:20 -0400829
830 /* WPA data */
831 int wpa_enabled;
832 int drop_unencrypted;
Jeff Garzikb4538722005-05-12 22:48:20 -0400833 int privacy_invoked;
834 size_t wpa_ie_len;
835 u8 *wpa_ie;
836
John W. Linville274bfb82008-10-29 11:35:05 -0400837 struct lib80211_crypt_info crypt_info;
Jeff Garzikb4538722005-05-12 22:48:20 -0400838
James Ketrenos74079fd2005-09-13 17:35:21 -0500839 int bcrx_sta_key; /* use individual keys to override default keys even
840 * with RX of broad/multicast frames */
Jeff Garzikb4538722005-05-12 22:48:20 -0400841
842 /* Fragmentation structures */
843 struct ieee80211_frag_entry frag_cache[IEEE80211_FRAG_CACHE_LEN];
844 unsigned int frag_next_idx;
James Ketrenos74079fd2005-09-13 17:35:21 -0500845 u16 fts; /* Fragmentation Threshold */
James Ketrenos3cdd00c2005-09-21 11:54:43 -0500846 u16 rts; /* RTS threshold */
Jeff Garzikb4538722005-05-12 22:48:20 -0400847
848 /* Association info */
849 u8 bssid[ETH_ALEN];
850
851 enum ieee80211_state state;
852
James Ketrenos74079fd2005-09-13 17:35:21 -0500853 int mode; /* A, B, G */
854 int modulation; /* CCK, OFDM */
855 int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */
James Ketrenos3bc5ed62005-09-13 17:48:54 -0500856 int abg_true; /* ABG flag */
Jeff Garzikb4538722005-05-12 22:48:20 -0400857
James Ketrenosb1b508e2005-09-13 17:27:19 -0500858 int perfect_rssi;
859 int worst_rssi;
860
Larry Finger837925d2006-10-03 18:49:32 -0500861 u16 prev_seq_ctl; /* used to drop duplicate frames */
862
Jeff Garzikb4538722005-05-12 22:48:20 -0400863 /* Callback functions */
James Ketrenos74079fd2005-09-13 17:35:21 -0500864 void (*set_security) (struct net_device * dev,
865 struct ieee80211_security * sec);
866 int (*hard_start_xmit) (struct ieee80211_txb * txb,
James Ketrenos9e8571a2005-09-21 11:56:33 -0500867 struct net_device * dev, int pri);
James Ketrenos74079fd2005-09-13 17:35:21 -0500868 int (*reset_port) (struct net_device * dev);
James Ketrenos3f552bb2005-09-21 11:54:47 -0500869 int (*is_queue_full) (struct net_device * dev, int pri);
870
James Ketrenos9e8571a2005-09-21 11:56:33 -0500871 int (*handle_management) (struct net_device * dev,
872 struct ieee80211_network * network, u16 type);
Zhu Yi738580622006-04-13 17:17:17 +0800873 int (*is_qos_active) (struct net_device *dev, struct sk_buff *skb);
James Ketrenos9e8571a2005-09-21 11:56:33 -0500874
James Ketrenos3f552bb2005-09-21 11:54:47 -0500875 /* Typical STA methods */
876 int (*handle_auth) (struct net_device * dev,
877 struct ieee80211_auth * auth);
James Ketrenos31b59ea2005-09-21 11:58:49 -0500878 int (*handle_deauth) (struct net_device * dev,
Zhu Yib79e20b2006-01-19 16:21:27 +0800879 struct ieee80211_deauth * auth);
880 int (*handle_action) (struct net_device * dev,
881 struct ieee80211_action * action,
882 struct ieee80211_rx_stats * stats);
James Ketrenos3f552bb2005-09-21 11:54:47 -0500883 int (*handle_disassoc) (struct net_device * dev,
884 struct ieee80211_disassoc * assoc);
885 int (*handle_beacon) (struct net_device * dev,
886 struct ieee80211_beacon * beacon,
887 struct ieee80211_network * network);
888 int (*handle_probe_response) (struct net_device * dev,
889 struct ieee80211_probe_response * resp,
890 struct ieee80211_network * network);
James Ketrenos42c94e42005-09-21 11:58:29 -0500891 int (*handle_probe_request) (struct net_device * dev,
892 struct ieee80211_probe_request * req,
893 struct ieee80211_rx_stats * stats);
James Ketrenos3f552bb2005-09-21 11:54:47 -0500894 int (*handle_assoc_response) (struct net_device * dev,
895 struct ieee80211_assoc_response * resp,
896 struct ieee80211_network * network);
897
898 /* Typical AP methods */
899 int (*handle_assoc_request) (struct net_device * dev);
900 int (*handle_reassoc_request) (struct net_device * dev,
901 struct ieee80211_reassoc_request * req);
Jeff Garzikb4538722005-05-12 22:48:20 -0400902
903 /* This must be the last item so that it points to the data
904 * allocated beyond this structure by alloc_ieee80211 */
905 u8 priv[0];
906};
907
908#define IEEE_A (1<<0)
909#define IEEE_B (1<<1)
910#define IEEE_G (1<<2)
911#define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
912
James Ketrenos9ba7e0d2005-09-21 11:58:24 -0500913static inline void *ieee80211_priv(struct net_device *dev)
Jeff Garzikb4538722005-05-12 22:48:20 -0400914{
915 return ((struct ieee80211_device *)netdev_priv(dev))->priv;
916}
917
James Ketrenos9ba7e0d2005-09-21 11:58:24 -0500918static inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee,
James Ketrenos74079fd2005-09-13 17:35:21 -0500919 int mode)
Jeff Garzikb4538722005-05-12 22:48:20 -0400920{
921 /*
922 * It is possible for both access points and our device to support
923 * combinations of modes, so as long as there is one valid combination
924 * of ap/device supported modes, then return success
925 *
926 */
927 if ((mode & IEEE_A) &&
928 (ieee->modulation & IEEE80211_OFDM_MODULATION) &&
929 (ieee->freq_band & IEEE80211_52GHZ_BAND))
930 return 1;
931
932 if ((mode & IEEE_G) &&
933 (ieee->modulation & IEEE80211_OFDM_MODULATION) &&
934 (ieee->freq_band & IEEE80211_24GHZ_BAND))
935 return 1;
936
937 if ((mode & IEEE_B) &&
938 (ieee->modulation & IEEE80211_CCK_MODULATION) &&
939 (ieee->freq_band & IEEE80211_24GHZ_BAND))
940 return 1;
941
942 return 0;
943}
944
James Ketrenos9ba7e0d2005-09-21 11:58:24 -0500945static inline int ieee80211_get_hdrlen(u16 fc)
Jeff Garzikb4538722005-05-12 22:48:20 -0400946{
Jiri Benc286d9742005-05-24 15:10:18 +0200947 int hdrlen = IEEE80211_3ADDR_LEN;
James Ketrenos9e8571a2005-09-21 11:56:33 -0500948 u16 stype = WLAN_FC_GET_STYPE(fc);
Jeff Garzikb4538722005-05-12 22:48:20 -0400949
950 switch (WLAN_FC_GET_TYPE(fc)) {
951 case IEEE80211_FTYPE_DATA:
952 if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
Jiri Benc286d9742005-05-24 15:10:18 +0200953 hdrlen = IEEE80211_4ADDR_LEN;
James Ketrenos9e8571a2005-09-21 11:56:33 -0500954 if (stype & IEEE80211_STYPE_QOS_DATA)
955 hdrlen += 2;
Jeff Garzikb4538722005-05-12 22:48:20 -0400956 break;
957 case IEEE80211_FTYPE_CTL:
958 switch (WLAN_FC_GET_STYPE(fc)) {
959 case IEEE80211_STYPE_CTS:
960 case IEEE80211_STYPE_ACK:
Jiri Benc286d9742005-05-24 15:10:18 +0200961 hdrlen = IEEE80211_1ADDR_LEN;
Jeff Garzikb4538722005-05-12 22:48:20 -0400962 break;
963 default:
Jiri Benc286d9742005-05-24 15:10:18 +0200964 hdrlen = IEEE80211_2ADDR_LEN;
Jeff Garzikb4538722005-05-12 22:48:20 -0400965 break;
966 }
967 break;
968 }
969
970 return hdrlen;
971}
972
James Ketrenos9ba7e0d2005-09-21 11:58:24 -0500973static inline u8 *ieee80211_get_payload(struct ieee80211_hdr *hdr)
James Ketrenosee34af32005-09-21 11:54:36 -0500974{
John W. Linville72118012008-09-30 21:43:03 -0400975 switch (ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_control))) {
James Ketrenosee34af32005-09-21 11:54:36 -0500976 case IEEE80211_1ADDR_LEN:
977 return ((struct ieee80211_hdr_1addr *)hdr)->payload;
978 case IEEE80211_2ADDR_LEN:
979 return ((struct ieee80211_hdr_2addr *)hdr)->payload;
980 case IEEE80211_3ADDR_LEN:
981 return ((struct ieee80211_hdr_3addr *)hdr)->payload;
982 case IEEE80211_4ADDR_LEN:
983 return ((struct ieee80211_hdr_4addr *)hdr)->payload;
984 }
Andrew Mortoncea00da2005-11-09 11:30:51 -0800985 return NULL;
James Ketrenosee34af32005-09-21 11:54:36 -0500986}
987
Ivo van Doorn7c254d32005-10-03 09:50:40 -0500988static inline int ieee80211_is_ofdm_rate(u8 rate)
989{
990 switch (rate & ~IEEE80211_BASIC_RATE_MASK) {
991 case IEEE80211_OFDM_RATE_6MB:
992 case IEEE80211_OFDM_RATE_9MB:
993 case IEEE80211_OFDM_RATE_12MB:
994 case IEEE80211_OFDM_RATE_18MB:
995 case IEEE80211_OFDM_RATE_24MB:
996 case IEEE80211_OFDM_RATE_36MB:
997 case IEEE80211_OFDM_RATE_48MB:
998 case IEEE80211_OFDM_RATE_54MB:
999 return 1;
1000 }
1001 return 0;
1002}
1003
1004static inline int ieee80211_is_cck_rate(u8 rate)
1005{
1006 switch (rate & ~IEEE80211_BASIC_RATE_MASK) {
1007 case IEEE80211_CCK_RATE_1MB:
1008 case IEEE80211_CCK_RATE_2MB:
1009 case IEEE80211_CCK_RATE_5MB:
1010 case IEEE80211_CCK_RATE_11MB:
1011 return 1;
1012 }
1013 return 0;
1014}
1015
Jeff Garzikb4538722005-05-12 22:48:20 -04001016/* ieee80211.c */
1017extern void free_ieee80211(struct net_device *dev);
1018extern struct net_device *alloc_ieee80211(int sizeof_priv);
Stephen Hemmingerd5b3b9a2009-03-20 19:36:39 +00001019extern int ieee80211_change_mtu(struct net_device *dev, int new_mtu);
Jeff Garzikb4538722005-05-12 22:48:20 -04001020
Dan Williamsc3d72b92009-02-11 13:26:06 -05001021extern void ieee80211_networks_age(struct ieee80211_device *ieee,
1022 unsigned long age_secs);
1023
Jeff Garzikb4538722005-05-12 22:48:20 -04001024extern int ieee80211_set_encryption(struct ieee80211_device *ieee);
1025
1026/* ieee80211_tx.c */
James Ketrenos74079fd2005-09-13 17:35:21 -05001027extern int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev);
Jeff Garzikb4538722005-05-12 22:48:20 -04001028extern void ieee80211_txb_free(struct ieee80211_txb *);
1029
Jeff Garzikb4538722005-05-12 22:48:20 -04001030/* ieee80211_rx.c */
Daniel Drakef2060f032006-07-18 21:38:05 +01001031extern void ieee80211_rx_any(struct ieee80211_device *ieee,
1032 struct sk_buff *skb, struct ieee80211_rx_stats *stats);
Jeff Garzikb4538722005-05-12 22:48:20 -04001033extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
1034 struct ieee80211_rx_stats *rx_stats);
Johannes Bergc9fa7d52005-12-27 02:14:13 +01001035/* make sure to set stats->len */
Jeff Garzikb4538722005-05-12 22:48:20 -04001036extern void ieee80211_rx_mgt(struct ieee80211_device *ieee,
James Ketrenosee34af32005-09-21 11:54:36 -05001037 struct ieee80211_hdr_4addr *header,
Jeff Garzikb4538722005-05-12 22:48:20 -04001038 struct ieee80211_rx_stats *stats);
Zhu Yib79e20b2006-01-19 16:21:27 +08001039extern void ieee80211_network_reset(struct ieee80211_network *network);
Jeff Garzikb4538722005-05-12 22:48:20 -04001040
James Ketrenos02cda6a2005-09-21 11:56:38 -05001041/* ieee80211_geo.c */
1042extern const struct ieee80211_geo *ieee80211_get_geo(struct ieee80211_device
1043 *ieee);
1044extern int ieee80211_set_geo(struct ieee80211_device *ieee,
1045 const struct ieee80211_geo *geo);
1046
1047extern int ieee80211_is_valid_channel(struct ieee80211_device *ieee,
1048 u8 channel);
1049extern int ieee80211_channel_to_index(struct ieee80211_device *ieee,
1050 u8 channel);
1051extern u8 ieee80211_freq_to_channel(struct ieee80211_device *ieee, u32 freq);
Zhu Yib79e20b2006-01-19 16:21:27 +08001052extern u8 ieee80211_get_channel_flags(struct ieee80211_device *ieee,
1053 u8 channel);
1054extern const struct ieee80211_channel *ieee80211_get_channel(struct
1055 ieee80211_device
1056 *ieee, u8 channel);
Larry Fingerf5cdf302007-04-21 17:56:29 -05001057extern u32 ieee80211_channel_to_freq(struct ieee80211_device * ieee,
1058 u8 channel);
James Ketrenos02cda6a2005-09-21 11:56:38 -05001059
Jiri Benc099c5bb2005-08-25 20:15:10 -04001060/* ieee80211_wx.c */
Jeff Garzikb4538722005-05-12 22:48:20 -04001061extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
1062 struct iw_request_info *info,
1063 union iwreq_data *wrqu, char *key);
1064extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
1065 struct iw_request_info *info,
1066 union iwreq_data *wrqu, char *key);
1067extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
1068 struct iw_request_info *info,
1069 union iwreq_data *wrqu, char *key);
James Ketrenose0d369d2005-09-21 11:54:30 -05001070extern int ieee80211_wx_set_encodeext(struct ieee80211_device *ieee,
1071 struct iw_request_info *info,
1072 union iwreq_data *wrqu, char *extra);
1073extern int ieee80211_wx_get_encodeext(struct ieee80211_device *ieee,
1074 struct iw_request_info *info,
1075 union iwreq_data *wrqu, char *extra);
Jeff Garzikb4538722005-05-12 22:48:20 -04001076
James Ketrenos9ba7e0d2005-09-21 11:58:24 -05001077static inline void ieee80211_increment_scans(struct ieee80211_device *ieee)
Jeff Garzikb4538722005-05-12 22:48:20 -04001078{
1079 ieee->scans++;
1080}
1081
James Ketrenos9ba7e0d2005-09-21 11:58:24 -05001082static inline int ieee80211_get_scans(struct ieee80211_device *ieee)
Jeff Garzikb4538722005-05-12 22:48:20 -04001083{
1084 return ieee->scans;
1085}
1086
James Ketrenos74079fd2005-09-13 17:35:21 -05001087#endif /* IEEE80211_H */