2 * Merged with mainline ieee80211.h in Aug 2004. Original ieee802_11
3 * remains copyright by the original authors
5 * Portions of the merged code are based on Host AP (software wireless
6 * LAN access point) driver for Intersil Prism2/2.5/3.
8 * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
10 * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
12 * Adaption to a generic IEEE 802.11 stack by James Ketrenos
13 * <jketreno@linux.intel.com>
14 * Copyright (c) 2004, Intel Corporation
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
23 #include <linux/if_ether.h> /* ETH_ALEN */
25 #define IEEE80211_DATA_LEN 2304
26 /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
29 The figure in section 7.1.2 suggests a body size of up to 2312
30 bytes is allowed, which is a bit confusing, I suspect this
31 represents the 2304 bytes of real data, plus a possible 8 bytes of
32 WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
35 #define IEEE80211_HLEN 30
36 #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
38 struct ieee80211_hdr {
46 } __attribute__ ((packed));
48 #define IEEE80211_3ADDR_SIZE (24)
49 #define IEEE80211_4ADDR_SIZE (30)
51 #define MIN_FRAG_THRESHOLD 256U
52 #define MAX_FRAG_THRESHOLD 2342U
54 /* Frame control field constants */
55 #define IEEE80211_FCTL_VERS 0x0002
56 #define IEEE80211_FCTL_FTYPE 0x000c
57 #define IEEE80211_FCTL_STYPE 0x00f0
58 #define IEEE80211_FCTL_TODS 0x0100
59 #define IEEE80211_FCTL_FROMDS 0x0200
60 #define IEEE80211_FCTL_MOREFRAGS 0x0400
61 #define IEEE80211_FCTL_RETRY 0x0800
62 #define IEEE80211_FCTL_PM 0x1000
63 #define IEEE80211_FCTL_MOREDATA 0x2000
64 #define IEEE80211_FCTL_WEP 0x4000
65 #define IEEE80211_FCTL_ORDER 0x8000
67 #define IEEE80211_FTYPE_MGMT 0x0000
68 #define IEEE80211_FTYPE_CTL 0x0004
69 #define IEEE80211_FTYPE_DATA 0x0008
72 #define IEEE80211_STYPE_ASSOC_REQ 0x0000
73 #define IEEE80211_STYPE_ASSOC_RESP 0x0010
74 #define IEEE80211_STYPE_REASSOC_REQ 0x0020
75 #define IEEE80211_STYPE_REASSOC_RESP 0x0030
76 #define IEEE80211_STYPE_PROBE_REQ 0x0040
77 #define IEEE80211_STYPE_PROBE_RESP 0x0050
78 #define IEEE80211_STYPE_BEACON 0x0080
79 #define IEEE80211_STYPE_ATIM 0x0090
80 #define IEEE80211_STYPE_DISASSOC 0x00A0
81 #define IEEE80211_STYPE_AUTH 0x00B0
82 #define IEEE80211_STYPE_DEAUTH 0x00C0
85 #define IEEE80211_STYPE_PSPOLL 0x00A0
86 #define IEEE80211_STYPE_RTS 0x00B0
87 #define IEEE80211_STYPE_CTS 0x00C0
88 #define IEEE80211_STYPE_ACK 0x00D0
89 #define IEEE80211_STYPE_CFEND 0x00E0
90 #define IEEE80211_STYPE_CFENDACK 0x00F0
93 #define IEEE80211_STYPE_DATA 0x0000
94 #define IEEE80211_STYPE_DATA_CFACK 0x0010
95 #define IEEE80211_STYPE_DATA_CFPOLL 0x0020
96 #define IEEE80211_STYPE_DATA_CFACKPOLL 0x0030
97 #define IEEE80211_STYPE_NULLFUNC 0x0040
98 #define IEEE80211_STYPE_CFACK 0x0050
99 #define IEEE80211_STYPE_CFPOLL 0x0060
100 #define IEEE80211_STYPE_CFACKPOLL 0x0070
102 #define IEEE80211_SCTL_FRAG 0x000F
103 #define IEEE80211_SCTL_SEQ 0xFFF0
108 #ifdef CONFIG_IEEE80211_DEBUG
109 extern u32 ieee80211_debug_level;
110 #define IEEE80211_DEBUG(level, fmt, args...) \
111 do { if (ieee80211_debug_level & (level)) \
112 printk(KERN_DEBUG "ieee80211: %c %s " fmt, \
113 in_interrupt() ? 'I' : 'U', __FUNCTION__, ## args); } while (0)
115 #define IEEE80211_DEBUG(level, fmt, args...) do {} while (0);
116 #endif /* CONFIG_IEEE80211_DEBUG */
119 * To use the debug system;
121 * If you are defining a new debug classification, simply add it to the #define
122 * list here in the form of:
124 * #define IEEE80211_DL_xxxx VALUE
126 * shifting value to the left one bit from the previous entry. xxxx should be
127 * the name of the classification (for example, WEP)
129 * You then need to either add a IEEE80211_xxxx_DEBUG() macro definition for your
130 * classification, or use IEEE80211_DEBUG(IEEE80211_DL_xxxx, ...) whenever you want
131 * to send output to that classification.
133 * To add your debug level to the list of levels seen when you perform
135 * % cat /proc/net/ipw/debug_level
137 * you simply need to add your entry to the ipw_debug_levels array.
139 * If you do not see debug_level in /proc/net/ipw then you do not have
140 * CONFIG_IEEE80211_DEBUG defined in your kernel configuration
144 #define IEEE80211_DL_INFO BIT(0)
145 #define IEEE80211_DL_WX BIT(1)
146 #define IEEE80211_DL_SCAN BIT(2)
147 #define IEEE80211_DL_STATE BIT(3)
148 #define IEEE80211_DL_MGMT BIT(4)
149 #define IEEE80211_DL_FRAG BIT(5)
150 #define IEEE80211_DL_EAP BIT(6)
152 #define IEEE80211_ERROR(f, a...) printk(KERN_ERR "ieee80211: " f, ## a)
153 #define IEEE80211_WARNING(f, a...) printk(KERN_WARNING "ieee80211: " f, ## a)
154 #define IEEE80211_DEBUG_INFO(f, a...) IEEE80211_DEBUG(IEEE80211_DL_INFO, f, ## a)
156 #define IEEE80211_DEBUG_WX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_WX, f, ## a)
157 #define IEEE80211_DEBUG_SCAN(f, a...) IEEE80211_DEBUG(IEEE80211_DL_SCAN, f, ## a)
158 #define IEEE80211_DEBUG_STATE(f, a...) IEEE80211_DEBUG(IEEE80211_DL_STATE, f, ## a)
159 #define IEEE80211_DEBUG_MGMT(f, a...) IEEE80211_DEBUG(IEEE80211_DL_MGMT, f, ## a)
160 #define IEEE80211_DEBUG_FRAG(f, a...) IEEE80211_DEBUG(IEEE80211_DL_FRAG, f, ## a)
161 #define IEEE80211_DEBUG_EAP(f, a...) IEEE80211_DEBUG(IEEE80211_DL_EAP, f, ## a)
162 #include <linux/netdevice.h>
163 #include <linux/wireless.h>
164 #include <linux/if_arp.h> /* ARPHRD_ETHER */
167 #define WIRELESS_SPY // enable iwspy support
169 #include <net/iw_handler.h> // new driver API
171 #define BIT(x) (1 << (x))
174 #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
175 #endif /* ETH_P_PAE */
177 #define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
179 #ifndef ETH_P_80211_RAW
180 #define ETH_P_80211_RAW (ETH_P_ECONET + 1)
183 /* IEEE 802.11 defines */
185 #define P80211_OUI_LEN 3
187 struct ieee80211_snap_hdr {
189 u8 dsap; /* always 0xAA */
190 u8 ssap; /* always 0xAA */
191 u8 ctrl; /* always 0x03 */
192 u8 oui[P80211_OUI_LEN]; /* organizational universal id */
194 } __attribute__ ((packed));
196 #define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
198 #define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE)
199 #define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE)
201 #define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG)
202 #define WLAN_GET_SEQ_SEQ(seq) ((seq) & IEEE80211_SCTL_SEQ)
204 /* Authentication algorithms */
205 #define WLAN_AUTH_OPEN 0
206 #define WLAN_AUTH_SHARED_KEY 1
208 #define WLAN_AUTH_CHALLENGE_LEN 128
210 #define WLAN_CAPABILITY_BSS BIT(0)
211 #define WLAN_CAPABILITY_IBSS BIT(1)
212 #define WLAN_CAPABILITY_CF_POLLABLE BIT(2)
213 #define WLAN_CAPABILITY_CF_POLL_REQUEST BIT(3)
214 #define WLAN_CAPABILITY_PRIVACY BIT(4)
215 #define WLAN_CAPABILITY_SHORT_PREAMBLE BIT(5)
216 #define WLAN_CAPABILITY_PBCC BIT(6)
217 #define WLAN_CAPABILITY_CHANNEL_AGILITY BIT(7)
220 #define WLAN_STATUS_SUCCESS 0
221 #define WLAN_STATUS_UNSPECIFIED_FAILURE 1
222 #define WLAN_STATUS_CAPS_UNSUPPORTED 10
223 #define WLAN_STATUS_REASSOC_NO_ASSOC 11
224 #define WLAN_STATUS_ASSOC_DENIED_UNSPEC 12
225 #define WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG 13
226 #define WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION 14
227 #define WLAN_STATUS_CHALLENGE_FAIL 15
228 #define WLAN_STATUS_AUTH_TIMEOUT 16
229 #define WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA 17
230 #define WLAN_STATUS_ASSOC_DENIED_RATES 18
232 #define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19
233 #define WLAN_STATUS_ASSOC_DENIED_NOPBCC 20
234 #define WLAN_STATUS_ASSOC_DENIED_NOAGILITY 21
237 #define WLAN_REASON_UNSPECIFIED 1
238 #define WLAN_REASON_PREV_AUTH_NOT_VALID 2
239 #define WLAN_REASON_DEAUTH_LEAVING 3
240 #define WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY 4
241 #define WLAN_REASON_DISASSOC_AP_BUSY 5
242 #define WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA 6
243 #define WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA 7
244 #define WLAN_REASON_DISASSOC_STA_HAS_LEFT 8
245 #define WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH 9
248 /* Information Element IDs */
249 #define WLAN_EID_SSID 0
250 #define WLAN_EID_SUPP_RATES 1
251 #define WLAN_EID_FH_PARAMS 2
252 #define WLAN_EID_DS_PARAMS 3
253 #define WLAN_EID_CF_PARAMS 4
254 #define WLAN_EID_TIM 5
255 #define WLAN_EID_IBSS_PARAMS 6
256 #define WLAN_EID_CHALLENGE 16
257 #define WLAN_EID_RSN 48
258 #define WLAN_EID_GENERIC 221
260 #define IEEE80211_MGMT_HDR_LEN 24
261 #define IEEE80211_DATA_HDR3_LEN 24
262 #define IEEE80211_DATA_HDR4_LEN 30
265 #define IEEE80211_STATMASK_SIGNAL BIT(0)
266 #define IEEE80211_STATMASK_RSSI BIT(1)
267 #define IEEE80211_STATMASK_NOISE BIT(2)
268 #define IEEE80211_STATMASK_RATE BIT(3)
269 #define IEEE80211_STATMASK_WEMASK 0x7
272 #define IEEE80211_CCK_MODULATION BIT(0)
273 #define IEEE80211_OFDM_MODULATION BIT(1)
275 #define IEEE80211_24GHZ_BAND BIT(0)
276 #define IEEE80211_52GHZ_BAND BIT(1)
278 #define IEEE80211_CCK_RATE_1MB 0x02
279 #define IEEE80211_CCK_RATE_2MB 0x04
280 #define IEEE80211_CCK_RATE_5MB 0x0B
281 #define IEEE80211_CCK_RATE_11MB 0x16
282 #define IEEE80211_OFDM_RATE_6MB 0x0C
283 #define IEEE80211_OFDM_RATE_9MB 0x12
284 #define IEEE80211_OFDM_RATE_12MB 0x18
285 #define IEEE80211_OFDM_RATE_18MB 0x24
286 #define IEEE80211_OFDM_RATE_24MB 0x30
287 #define IEEE80211_OFDM_RATE_36MB 0x48
288 #define IEEE80211_OFDM_RATE_48MB 0x60
289 #define IEEE80211_OFDM_RATE_54MB 0x6C
290 #define IEEE80211_BASIC_RATE_MASK 0x80
292 #define IEEE80211_CCK_RATE_1MB_MASK BIT(0)
293 #define IEEE80211_CCK_RATE_2MB_MASK BIT(1)
294 #define IEEE80211_CCK_RATE_5MB_MASK BIT(2)
295 #define IEEE80211_CCK_RATE_11MB_MASK BIT(3)
296 #define IEEE80211_OFDM_RATE_6MB_MASK BIT(4)
297 #define IEEE80211_OFDM_RATE_9MB_MASK BIT(5)
298 #define IEEE80211_OFDM_RATE_12MB_MASK BIT(6)
299 #define IEEE80211_OFDM_RATE_18MB_MASK BIT(7)
300 #define IEEE80211_OFDM_RATE_24MB_MASK BIT(8)
301 #define IEEE80211_OFDM_RATE_36MB_MASK BIT(9)
302 #define IEEE80211_OFDM_RATE_48MB_MASK BIT(10)
303 #define IEEE80211_OFDM_RATE_54MB_MASK BIT(11)
305 #define IEEE80211_CCK_RATES_MASK 0x0000000F
306 #define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \
307 IEEE80211_CCK_RATE_2MB_MASK)
308 #define IEEE80211_CCK_DEFAULT_RATES_MASK (IEEE80211_CCK_BASIC_RATES_MASK | \
309 IEEE80211_CCK_RATE_5MB_MASK | \
310 IEEE80211_CCK_RATE_11MB_MASK)
312 #define IEEE80211_OFDM_RATES_MASK 0x00000FF0
313 #define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \
314 IEEE80211_OFDM_RATE_12MB_MASK | \
315 IEEE80211_OFDM_RATE_24MB_MASK)
316 #define IEEE80211_OFDM_DEFAULT_RATES_MASK (IEEE80211_OFDM_BASIC_RATES_MASK | \
317 IEEE80211_OFDM_RATE_9MB_MASK | \
318 IEEE80211_OFDM_RATE_18MB_MASK | \
319 IEEE80211_OFDM_RATE_36MB_MASK | \
320 IEEE80211_OFDM_RATE_48MB_MASK | \
321 IEEE80211_OFDM_RATE_54MB_MASK)
322 #define IEEE80211_DEFAULT_RATES_MASK (IEEE80211_OFDM_DEFAULT_RATES_MASK | \
323 IEEE80211_CCK_DEFAULT_RATES_MASK)
325 #define IEEE80211_NUM_OFDM_RATES 8
326 #define IEEE80211_NUM_CCK_RATES 4
327 #define IEEE80211_OFDM_SHIFT_MASK_A 4
332 /* NOTE: This data is for statistical purposes; not all hardware provides this
333 * information for frames received. Not setting these will not cause
334 * any adverse affects. */
335 struct ieee80211_rx_stats {
340 u16 rate; /* in 100 kbps */
348 /* IEEE 802.11 requires that STA supports concurrent reception of at least
349 * three fragmented frames. This define can be increased to support more
350 * concurrent frames, but it should be noted that each entry can consume about
351 * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
352 #define IEEE80211_FRAG_CACHE_LEN 4
354 struct ieee80211_frag_entry {
355 unsigned long first_frag_time;
357 unsigned int last_frag;
359 u8 src_addr[ETH_ALEN];
360 u8 dst_addr[ETH_ALEN];
363 struct ieee80211_stats {
364 unsigned int tx_unicast_frames;
365 unsigned int tx_multicast_frames;
366 unsigned int tx_fragments;
367 unsigned int tx_unicast_octets;
368 unsigned int tx_multicast_octets;
369 unsigned int tx_deferred_transmissions;
370 unsigned int tx_single_retry_frames;
371 unsigned int tx_multiple_retry_frames;
372 unsigned int tx_retry_limit_exceeded;
373 unsigned int tx_discards;
374 unsigned int rx_unicast_frames;
375 unsigned int rx_multicast_frames;
376 unsigned int rx_fragments;
377 unsigned int rx_unicast_octets;
378 unsigned int rx_multicast_octets;
379 unsigned int rx_fcs_errors;
380 unsigned int rx_discards_no_buffer;
381 unsigned int tx_discards_wrong_sa;
382 unsigned int rx_discards_wep_undecryptable;
383 unsigned int rx_message_in_msg_fragments;
384 unsigned int rx_message_in_bad_msg_fragments;
387 struct ieee80211_device;
389 #include "ieee80211_crypt.h"
391 #define SEC_KEY_1 BIT(0)
392 #define SEC_KEY_2 BIT(1)
393 #define SEC_KEY_3 BIT(2)
394 #define SEC_KEY_4 BIT(3)
395 #define SEC_ACTIVE_KEY BIT(4)
396 #define SEC_AUTH_MODE BIT(5)
397 #define SEC_UNICAST_GROUP BIT(6)
398 #define SEC_LEVEL BIT(7)
399 #define SEC_ENABLED BIT(8)
401 #define SEC_LEVEL_0 0 /* None */
402 #define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */
403 #define SEC_LEVEL_2 2 /* Level 1 + TKIP */
404 #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
405 #define SEC_LEVEL_3 4 /* Level 2 + CCMP */
408 #define WEP_KEY_LEN 13
410 struct ieee80211_security {
415 unicast_uses_group:1;
416 u8 key_sizes[WEP_KEYS];
417 u8 keys[WEP_KEYS][WEP_KEY_LEN];
420 } __attribute__ ((packed));
425 802.11 data frame from AP
427 ,-------------------------------------------------------------------.
428 Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
429 |------|------|---------|---------|---------|------|---------|------|
430 Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs |
431 | | tion | (BSSID) | | | ence | data | |
432 `-------------------------------------------------------------------'
438 struct ieee80211_header_data {
447 #define BEACON_PROBE_SSID_ID_POSITION 12
449 /* Management Frame Information Element Types */
450 #define MFIE_TYPE_SSID 0
451 #define MFIE_TYPE_RATES 1
452 #define MFIE_TYPE_FH_SET 2
453 #define MFIE_TYPE_DS_SET 3
454 #define MFIE_TYPE_CF_SET 4
455 #define MFIE_TYPE_TIM 5
456 #define MFIE_TYPE_IBSS_SET 6
457 #define MFIE_TYPE_CHALLENGE 16
458 #define MFIE_TYPE_RSN 48
459 #define MFIE_TYPE_RATES_EX 50
460 #define MFIE_TYPE_GENERIC 221
462 struct ieee80211_info_element_hdr {
465 } __attribute__ ((packed));
467 struct ieee80211_info_element {
471 } __attribute__ ((packed));
474 * These are the data types that can make up management packets
480 u8 current_ap[ETH_ALEN];
483 u16 association_id:14, reserved:2;
484 } __attribute__ ((packed));
490 struct ieee80211_authentication {
491 struct ieee80211_header_data header;
495 struct ieee80211_info_element info_element;
496 } __attribute__ ((packed));
499 struct ieee80211_probe_response {
500 struct ieee80211_header_data header;
504 struct ieee80211_info_element info_element;
505 } __attribute__ ((packed));
507 struct ieee80211_assoc_request_frame {
510 u8 current_ap[ETH_ALEN];
511 struct ieee80211_info_element info_element;
512 } __attribute__ ((packed));
514 struct ieee80211_helper_functions {
515 void (*set_security)(struct ieee80211_device *ieee,
516 struct ieee80211_security *sec);
518 /* these functions are defined in hardware model specific files
519 * (hostap_{cs,plx,pci}.c */
520 int (*card_present)(struct ieee80211_device *ieee);
521 void (*cor_sreset)(struct ieee80211_device *ieee);
522 int (*dev_open)(struct ieee80211_device *ieee);
523 int (*dev_close)(struct ieee80211_device *ieee);
524 void (*genesis_reset)(struct ieee80211_device *ieee, int hcr);
527 /* Turn on unencrypted packet filtering at the HW level */
528 void (*set_unencrypted_filter)(struct ieee80211_device *ieee, int flag);
530 /* the following functions are from hostap_hw.c, but they may have some
531 * hardware model specific code */
533 int (*hw_enable)(struct net_device *dev, int initial);
534 int (*hw_config)(struct net_device *dev, int initial);
535 void (*hw_reset)(struct net_device *dev);
536 void (*hw_shutdown)(struct net_device *dev, int no_disable);
537 int (*reset_port)(struct net_device *dev);
538 int (*tx)(struct sk_buff *skb, struct net_device *dev);
539 void (*schedule_reset)(struct ieee80211_device *ieee);
540 int (*tx_80211)(struct sk_buff *skb, struct net_device *dev);
545 /* SWEEP TABLE ENTRIES NUMBER*/
546 #define MAX_SWEEP_TAB_ENTRIES 42
547 #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
548 /* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs
549 * only use 8, and then use extended rates for the remaining supported
550 * rates. Other APs, however, stick all of their supported rates on the
551 * main rates information element... */
552 #define MAX_RATES_LENGTH ((u8)12)
553 #define MAX_RATES_EX_LENGTH ((u8)16)
554 #define MAX_NETWORK_COUNT 128
556 #define CRC_LENGTH 4U
558 #define MAX_WPA_IE_LEN 64
560 #define NETWORK_EMPTY_ESSID BIT(0)
561 #define NETWORK_HAS_OFDM BIT(1)
563 struct ieee80211_network {
566 struct ieee80211_rx_stats stats;
569 u8 rates[MAX_RATES_LENGTH];
571 u8 rates_ex[MAX_RATES_EX_LENGTH];
573 unsigned long last_scanned;
577 /* Ensure null-terminated for any debug msgs */
578 u8 ssid[IW_ESSID_MAX_SIZE + 1];
583 #ifdef CONFIG_IEEE80211_WPA
584 u8 wpa_ie[MAX_WPA_IE_LEN];
586 u8 rsn_ie[MAX_WPA_IE_LEN];
588 #endif /* CONFIG_IEEE80211_WPA */
589 struct list_head list;
592 enum ieee80211_state {
593 IEEE80211_UNINITIALIZED = 0,
594 IEEE80211_INITIALIZED,
595 IEEE80211_ASSOCIATING,
596 IEEE80211_ASSOCIATED,
597 IEEE80211_AUTHENTICATING,
598 IEEE80211_AUTHENTICATED,
602 #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
603 #define DEFAULT_FTS 2342
604 #define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
605 #define MAC_ARG(x) ((u8*)(x))[0],((u8*)(x))[1],((u8*)(x))[2],((u8*)(x))[3],((u8*)(x))[4],((u8*)(x))[5]
608 extern inline int is_multicast_ether_addr(const u8 *addr)
610 return ((addr[0] != 0xff) && (0x01 & addr[0]));
613 extern inline int is_broadcast_ether_addr(const u8 *addr)
615 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \
616 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
620 struct ieee80211_device {
621 struct net_device *dev;
623 /* Bookkeeping structures */
624 struct net_device_stats stats;
625 struct ieee80211_stats ieee_stats;
628 /* Probe / Beacon management */
629 struct list_head network_free_list;
630 struct list_head network_list;
631 struct ieee80211_network *networks;
635 int iw_mode; /* operating mode (IW_MODE_*) */
639 int tx_payload_only; /* set to 1 if HW only expects the Tx SKB
640 * to contain the payload (vs. a fully configured
641 * 802.11 header for a data frame) */
642 int tx_headroom; /* Set to size of any additional room needed at front
643 * of allocated Tx SKBs */
645 /* WEP and other encryption related settings at the device level */
646 int open_wep; /* Set to 1 to allow unencrypted frames */
648 int reset_on_keychange; /* Set to 1 if the HW needs to be reset on
651 /* If the host performs {en,de}cryption, then set to 1 */
655 #ifdef CONFIG_IEEE80211_WPA
658 int drop_unencrypted;
659 int tkip_countermeasures;
660 int ieee_802_1x; /* is IEEE 802.1X used */
664 #endif /* CONFIG_IEEE80211_WPA */
666 struct list_head crypt_deinit_list;
667 struct ieee80211_crypt_data *crypt[WEP_KEYS];
668 int tx_keyidx; /* default TX key index (crypt[tx_keyidx]) */
669 struct timer_list crypt_deinit_timer;
671 int bcrx_sta_key; /* use individual keys to override default keys even
672 * with RX of broad/multicast frames */
674 /* Fragmentation structures */
675 struct ieee80211_frag_entry frag_cache[IEEE80211_FRAG_CACHE_LEN];
676 unsigned int frag_next_idx;
677 u16 fts; /* Fragmentation Threshold */
679 /* Association info */
682 /* Callback vtable */
683 struct ieee80211_helper_functions *func;
685 enum ieee80211_state state;
687 int mode; /* A, B, G */
688 int modulation; /* CCK, OFDM */
689 int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */
690 int abg_ture; /* ABG flag */
696 #define IEEE_MASK (BIT(IEEE_A) | BIT(IEEE_B) | BIT(IEEE_G))
698 extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
700 /* Single white space is for Linksys APs */
701 if (essid_len == 1 && essid[0] == ' ')
704 /* Otherwise, if the entire essid is 0, we assume it is hidden */
707 if (essid[essid_len] != '\0')
715 extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode)
720 if (!(ieee->modulation & IEEE80211_OFDM_MODULATION) ||
721 !(ieee->freq_band & IEEE80211_52GHZ_BAND))
726 if (!(ieee->modulation & IEEE80211_CCK_MODULATION) ||
727 !(ieee->freq_band & IEEE80211_24GHZ_BAND))
732 if (!(ieee->modulation & IEEE80211_OFDM_MODULATION) ||
733 !(ieee->freq_band & IEEE80211_24GHZ_BAND))
740 extern inline int ieee80211_get_hdrlen(u16 fc)
744 switch (WLAN_FC_GET_TYPE(fc)) {
745 case IEEE80211_FTYPE_DATA:
746 if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
747 hdrlen = 30; /* Addr4 */
749 case IEEE80211_FTYPE_CTL:
750 switch (WLAN_FC_GET_STYPE(fc)) {
751 case IEEE80211_STYPE_CTS:
752 case IEEE80211_STYPE_ACK:
768 extern struct ieee80211_device * ieee80211_alloc(struct net_device *dev,
770 extern void ieee80211_free(struct ieee80211_device *ieee);
772 extern int ieee80211_set_encryption(struct ieee80211_device *ieee);
776 struct ieee80211_txb {
782 struct sk_buff *fragments[0];
785 extern struct ieee80211_txb *ieee80211_skb_to_txb(struct ieee80211_device *ieee,
786 struct sk_buff *skb);
787 extern void ieee80211_txb_free(struct ieee80211_txb *);
791 extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
792 struct ieee80211_rx_stats *rx_stats);
793 extern void ieee80211_rx_mgt(struct ieee80211_device *ieee,
794 struct ieee80211_hdr *header,
795 struct ieee80211_rx_stats *stats);
798 extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
799 struct iw_request_info *info,
800 union iwreq_data *wrqu, char *key);
801 extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
802 struct iw_request_info *info,
803 union iwreq_data *wrqu, char *key);
804 extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
805 struct iw_request_info *info,
806 union iwreq_data *wrqu, char *key);
809 extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee)
814 extern inline int ieee80211_get_scans(struct ieee80211_device *ieee)
819 static inline const char *escape_essid(const char *essid, u8 essid_len) {
820 static char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
821 const char *s = essid;
824 if (ieee80211_is_empty_essid(essid, essid_len)) {
825 memcpy(escaped, "<hidden>", sizeof("<hidden>"));
829 essid_len = min(essid_len, (u8)IW_ESSID_MAX_SIZE);
830 while (essid_len--) {
843 #ifndef offset_in_page
844 #define offset_in_page(p) ((unsigned long)(p) & ~PAGE_MASK)
847 #endif /* IEEE80211_H */