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 <j@w1.fi>
12 * Adaption to a generic IEEE 802.11 stack by James Ketrenos
13 * <jketreno@linux.intel.com>
14 * Copyright (c) 2004-2005, 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
22 * 1.0.x -- Initial version
23 * 1.1.x -- Added radiotap, QoS, TIM, libipw_geo APIs,
24 * various structure changes, and crypto API init method
28 #include <linux/if_ether.h> /* ETH_ALEN */
29 #include <linux/kernel.h> /* ARRAY_SIZE */
30 #include <linux/wireless.h>
31 #include <linux/ieee80211.h>
33 #include <net/lib80211.h>
34 #include <net/cfg80211.h>
36 #define LIBIPW_VERSION "git-1.1.13"
38 #define LIBIPW_DATA_LEN 2304
39 /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
42 The figure in section 7.1.2 suggests a body size of up to 2312
43 bytes is allowed, which is a bit confusing, I suspect this
44 represents the 2304 bytes of real data, plus a possible 8 bytes of
45 WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
47 #define LIBIPW_1ADDR_LEN 10
48 #define LIBIPW_2ADDR_LEN 16
49 #define LIBIPW_3ADDR_LEN 24
50 #define LIBIPW_4ADDR_LEN 30
51 #define LIBIPW_FCS_LEN 4
52 #define LIBIPW_HLEN (LIBIPW_4ADDR_LEN)
53 #define LIBIPW_FRAME_LEN (LIBIPW_DATA_LEN + LIBIPW_HLEN)
55 #define MIN_FRAG_THRESHOLD 256U
56 #define MAX_FRAG_THRESHOLD 2346U
59 #define LIBIPW_QCTL_TID 0x000F
63 #ifdef CONFIG_LIBIPW_DEBUG
64 extern u32 libipw_debug_level
;
65 #define LIBIPW_DEBUG(level, fmt, args...) \
66 do { if (libipw_debug_level & (level)) \
67 printk(KERN_DEBUG "ieee80211: %c %s " fmt, \
68 in_interrupt() ? 'I' : 'U', __func__ , ## args); } while (0)
69 static inline bool libipw_ratelimit_debug(u32 level
)
71 return (libipw_debug_level
& level
) && net_ratelimit();
74 #define LIBIPW_DEBUG(level, fmt, args...) do {} while (0)
75 static inline bool libipw_ratelimit_debug(u32 level
)
79 #endif /* CONFIG_LIBIPW_DEBUG */
82 * To use the debug system:
84 * If you are defining a new debug classification, simply add it to the #define
85 * list here in the form of:
87 * #define LIBIPW_DL_xxxx VALUE
89 * shifting value to the left one bit from the previous entry. xxxx should be
90 * the name of the classification (for example, WEP)
92 * You then need to either add a LIBIPW_xxxx_DEBUG() macro definition for your
93 * classification, or use LIBIPW_DEBUG(LIBIPW_DL_xxxx, ...) whenever you want
94 * to send output to that classification.
96 * To add your debug level to the list of levels seen when you perform
98 * % cat /proc/net/ieee80211/debug_level
100 * you simply need to add your entry to the libipw_debug_level array.
102 * If you do not see debug_level in /proc/net/ieee80211 then you do not have
103 * CONFIG_LIBIPW_DEBUG defined in your kernel configuration
107 #define LIBIPW_DL_INFO (1<<0)
108 #define LIBIPW_DL_WX (1<<1)
109 #define LIBIPW_DL_SCAN (1<<2)
110 #define LIBIPW_DL_STATE (1<<3)
111 #define LIBIPW_DL_MGMT (1<<4)
112 #define LIBIPW_DL_FRAG (1<<5)
113 #define LIBIPW_DL_DROP (1<<7)
115 #define LIBIPW_DL_TX (1<<8)
116 #define LIBIPW_DL_RX (1<<9)
117 #define LIBIPW_DL_QOS (1<<31)
119 #define LIBIPW_ERROR(f, a...) printk(KERN_ERR "ieee80211: " f, ## a)
120 #define LIBIPW_WARNING(f, a...) printk(KERN_WARNING "ieee80211: " f, ## a)
121 #define LIBIPW_DEBUG_INFO(f, a...) LIBIPW_DEBUG(LIBIPW_DL_INFO, f, ## a)
123 #define LIBIPW_DEBUG_WX(f, a...) LIBIPW_DEBUG(LIBIPW_DL_WX, f, ## a)
124 #define LIBIPW_DEBUG_SCAN(f, a...) LIBIPW_DEBUG(LIBIPW_DL_SCAN, f, ## a)
125 #define LIBIPW_DEBUG_STATE(f, a...) LIBIPW_DEBUG(LIBIPW_DL_STATE, f, ## a)
126 #define LIBIPW_DEBUG_MGMT(f, a...) LIBIPW_DEBUG(LIBIPW_DL_MGMT, f, ## a)
127 #define LIBIPW_DEBUG_FRAG(f, a...) LIBIPW_DEBUG(LIBIPW_DL_FRAG, f, ## a)
128 #define LIBIPW_DEBUG_DROP(f, a...) LIBIPW_DEBUG(LIBIPW_DL_DROP, f, ## a)
129 #define LIBIPW_DEBUG_TX(f, a...) LIBIPW_DEBUG(LIBIPW_DL_TX, f, ## a)
130 #define LIBIPW_DEBUG_RX(f, a...) LIBIPW_DEBUG(LIBIPW_DL_RX, f, ## a)
131 #define LIBIPW_DEBUG_QOS(f, a...) LIBIPW_DEBUG(LIBIPW_DL_QOS, f, ## a)
132 #include <linux/netdevice.h>
133 #include <linux/if_arp.h> /* ARPHRD_ETHER */
136 #define WIRELESS_SPY /* enable iwspy support */
138 #include <net/iw_handler.h> /* new driver API */
140 #define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
142 #ifndef ETH_P_80211_RAW
143 #define ETH_P_80211_RAW (ETH_P_ECONET + 1)
146 /* IEEE 802.11 defines */
148 #define P80211_OUI_LEN 3
150 struct libipw_snap_hdr
{
152 u8 dsap
; /* always 0xAA */
153 u8 ssap
; /* always 0xAA */
154 u8 ctrl
; /* always 0x03 */
155 u8 oui
[P80211_OUI_LEN
]; /* organizational universal id */
157 } __attribute__ ((packed
));
159 #define SNAP_SIZE sizeof(struct libipw_snap_hdr)
161 #define WLAN_FC_GET_VERS(fc) ((fc) & IEEE80211_FCTL_VERS)
162 #define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE)
163 #define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE)
165 #define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG)
166 #define WLAN_GET_SEQ_SEQ(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
168 #define LIBIPW_STATMASK_SIGNAL (1<<0)
169 #define LIBIPW_STATMASK_RSSI (1<<1)
170 #define LIBIPW_STATMASK_NOISE (1<<2)
171 #define LIBIPW_STATMASK_RATE (1<<3)
172 #define LIBIPW_STATMASK_WEMASK 0x7
174 #define LIBIPW_CCK_MODULATION (1<<0)
175 #define LIBIPW_OFDM_MODULATION (1<<1)
177 #define LIBIPW_24GHZ_BAND (1<<0)
178 #define LIBIPW_52GHZ_BAND (1<<1)
180 #define LIBIPW_CCK_RATE_1MB 0x02
181 #define LIBIPW_CCK_RATE_2MB 0x04
182 #define LIBIPW_CCK_RATE_5MB 0x0B
183 #define LIBIPW_CCK_RATE_11MB 0x16
184 #define LIBIPW_OFDM_RATE_6MB 0x0C
185 #define LIBIPW_OFDM_RATE_9MB 0x12
186 #define LIBIPW_OFDM_RATE_12MB 0x18
187 #define LIBIPW_OFDM_RATE_18MB 0x24
188 #define LIBIPW_OFDM_RATE_24MB 0x30
189 #define LIBIPW_OFDM_RATE_36MB 0x48
190 #define LIBIPW_OFDM_RATE_48MB 0x60
191 #define LIBIPW_OFDM_RATE_54MB 0x6C
192 #define LIBIPW_BASIC_RATE_MASK 0x80
194 #define LIBIPW_CCK_RATE_1MB_MASK (1<<0)
195 #define LIBIPW_CCK_RATE_2MB_MASK (1<<1)
196 #define LIBIPW_CCK_RATE_5MB_MASK (1<<2)
197 #define LIBIPW_CCK_RATE_11MB_MASK (1<<3)
198 #define LIBIPW_OFDM_RATE_6MB_MASK (1<<4)
199 #define LIBIPW_OFDM_RATE_9MB_MASK (1<<5)
200 #define LIBIPW_OFDM_RATE_12MB_MASK (1<<6)
201 #define LIBIPW_OFDM_RATE_18MB_MASK (1<<7)
202 #define LIBIPW_OFDM_RATE_24MB_MASK (1<<8)
203 #define LIBIPW_OFDM_RATE_36MB_MASK (1<<9)
204 #define LIBIPW_OFDM_RATE_48MB_MASK (1<<10)
205 #define LIBIPW_OFDM_RATE_54MB_MASK (1<<11)
207 #define LIBIPW_CCK_RATES_MASK 0x0000000F
208 #define LIBIPW_CCK_BASIC_RATES_MASK (LIBIPW_CCK_RATE_1MB_MASK | \
209 LIBIPW_CCK_RATE_2MB_MASK)
210 #define LIBIPW_CCK_DEFAULT_RATES_MASK (LIBIPW_CCK_BASIC_RATES_MASK | \
211 LIBIPW_CCK_RATE_5MB_MASK | \
212 LIBIPW_CCK_RATE_11MB_MASK)
214 #define LIBIPW_OFDM_RATES_MASK 0x00000FF0
215 #define LIBIPW_OFDM_BASIC_RATES_MASK (LIBIPW_OFDM_RATE_6MB_MASK | \
216 LIBIPW_OFDM_RATE_12MB_MASK | \
217 LIBIPW_OFDM_RATE_24MB_MASK)
218 #define LIBIPW_OFDM_DEFAULT_RATES_MASK (LIBIPW_OFDM_BASIC_RATES_MASK | \
219 LIBIPW_OFDM_RATE_9MB_MASK | \
220 LIBIPW_OFDM_RATE_18MB_MASK | \
221 LIBIPW_OFDM_RATE_36MB_MASK | \
222 LIBIPW_OFDM_RATE_48MB_MASK | \
223 LIBIPW_OFDM_RATE_54MB_MASK)
224 #define LIBIPW_DEFAULT_RATES_MASK (LIBIPW_OFDM_DEFAULT_RATES_MASK | \
225 LIBIPW_CCK_DEFAULT_RATES_MASK)
227 #define LIBIPW_NUM_OFDM_RATES 8
228 #define LIBIPW_NUM_CCK_RATES 4
229 #define LIBIPW_OFDM_SHIFT_MASK_A 4
231 /* NOTE: This data is for statistical purposes; not all hardware provides this
232 * information for frames received.
233 * For libipw_rx_mgt, you need to set at least the 'len' parameter.
235 struct libipw_rx_stats
{
240 u16 rate
; /* in 100 kbps */
250 /* IEEE 802.11 requires that STA supports concurrent reception of at least
251 * three fragmented frames. This define can be increased to support more
252 * concurrent frames, but it should be noted that each entry can consume about
253 * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
254 #define LIBIPW_FRAG_CACHE_LEN 4
256 struct libipw_frag_entry
{
257 unsigned long first_frag_time
;
259 unsigned int last_frag
;
261 u8 src_addr
[ETH_ALEN
];
262 u8 dst_addr
[ETH_ALEN
];
265 struct libipw_stats
{
266 unsigned int tx_unicast_frames
;
267 unsigned int tx_multicast_frames
;
268 unsigned int tx_fragments
;
269 unsigned int tx_unicast_octets
;
270 unsigned int tx_multicast_octets
;
271 unsigned int tx_deferred_transmissions
;
272 unsigned int tx_single_retry_frames
;
273 unsigned int tx_multiple_retry_frames
;
274 unsigned int tx_retry_limit_exceeded
;
275 unsigned int tx_discards
;
276 unsigned int rx_unicast_frames
;
277 unsigned int rx_multicast_frames
;
278 unsigned int rx_fragments
;
279 unsigned int rx_unicast_octets
;
280 unsigned int rx_multicast_octets
;
281 unsigned int rx_fcs_errors
;
282 unsigned int rx_discards_no_buffer
;
283 unsigned int tx_discards_wrong_sa
;
284 unsigned int rx_discards_undecryptable
;
285 unsigned int rx_message_in_msg_fragments
;
286 unsigned int rx_message_in_bad_msg_fragments
;
289 struct libipw_device
;
291 #define SEC_KEY_1 (1<<0)
292 #define SEC_KEY_2 (1<<1)
293 #define SEC_KEY_3 (1<<2)
294 #define SEC_KEY_4 (1<<3)
295 #define SEC_ACTIVE_KEY (1<<4)
296 #define SEC_AUTH_MODE (1<<5)
297 #define SEC_UNICAST_GROUP (1<<6)
298 #define SEC_LEVEL (1<<7)
299 #define SEC_ENABLED (1<<8)
300 #define SEC_ENCRYPT (1<<9)
302 #define SEC_LEVEL_0 0 /* None */
303 #define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */
304 #define SEC_LEVEL_2 2 /* Level 1 + TKIP */
305 #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
306 #define SEC_LEVEL_3 4 /* Level 2 + CCMP */
308 #define SEC_ALG_NONE 0
309 #define SEC_ALG_WEP 1
310 #define SEC_ALG_TKIP 2
311 #define SEC_ALG_CCMP 3
314 #define WEP_KEY_LEN 13
315 #define SCM_KEY_LEN 32
316 #define SCM_TEMPORAL_KEY_LENGTH 16
318 struct libipw_security
{
319 u16 active_key
:2, enabled
:1, unicast_uses_group
:1, encrypt
:1;
321 u8 encode_alg
[WEP_KEYS
];
322 u8 key_sizes
[WEP_KEYS
];
323 u8 keys
[WEP_KEYS
][SCM_KEY_LEN
];
326 } __attribute__ ((packed
));
330 802.11 data frame from AP
332 ,-------------------------------------------------------------------.
333 Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
334 |------|------|---------|---------|---------|------|---------|------|
335 Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs |
336 | | tion | (BSSID) | | | ence | data | |
337 `-------------------------------------------------------------------'
343 #define BEACON_PROBE_SSID_ID_POSITION 12
345 struct libipw_hdr_1addr
{
350 } __attribute__ ((packed
));
352 struct libipw_hdr_2addr
{
358 } __attribute__ ((packed
));
360 struct libipw_hdr_3addr
{
368 } __attribute__ ((packed
));
370 struct libipw_hdr_4addr
{
379 } __attribute__ ((packed
));
381 struct libipw_hdr_3addrqos
{
390 } __attribute__ ((packed
));
392 struct libipw_info_element
{
396 } __attribute__ ((packed
));
399 * These are the data types that can make up management packets
405 u8 current_ap[ETH_ALEN];
408 u16 association_id:14, reserved:2;
409 } __attribute__ ((packed));
416 struct libipw_hdr_3addr header
;
421 struct libipw_info_element info_element
[0];
422 } __attribute__ ((packed
));
424 struct libipw_channel_switch
{
430 } __attribute__ ((packed
));
432 struct libipw_action
{
433 struct libipw_hdr_3addr header
;
437 struct libipw_action_exchange
{
439 struct libipw_info_element info_element
[0];
441 struct libipw_channel_switch channel_switch
;
444 } __attribute__ ((packed
));
446 struct libipw_disassoc
{
447 struct libipw_hdr_3addr header
;
449 } __attribute__ ((packed
));
451 /* Alias deauth for disassoc */
452 #define libipw_deauth libipw_disassoc
454 struct libipw_probe_request
{
455 struct libipw_hdr_3addr header
;
456 /* SSID, supported rates */
457 struct libipw_info_element info_element
[0];
458 } __attribute__ ((packed
));
460 struct libipw_probe_response
{
461 struct libipw_hdr_3addr header
;
462 __le32 time_stamp
[2];
463 __le16 beacon_interval
;
465 /* SSID, supported rates, FH params, DS params,
466 * CF params, IBSS params, TIM (if beacon), RSN */
467 struct libipw_info_element info_element
[0];
468 } __attribute__ ((packed
));
470 /* Alias beacon for probe_response */
471 #define libipw_beacon libipw_probe_response
473 struct libipw_assoc_request
{
474 struct libipw_hdr_3addr header
;
476 __le16 listen_interval
;
477 /* SSID, supported rates, RSN */
478 struct libipw_info_element info_element
[0];
479 } __attribute__ ((packed
));
481 struct libipw_reassoc_request
{
482 struct libipw_hdr_3addr header
;
484 __le16 listen_interval
;
485 u8 current_ap
[ETH_ALEN
];
486 struct libipw_info_element info_element
[0];
487 } __attribute__ ((packed
));
489 struct libipw_assoc_response
{
490 struct libipw_hdr_3addr header
;
494 /* supported rates */
495 struct libipw_info_element info_element
[0];
496 } __attribute__ ((packed
));
505 struct sk_buff
*fragments
[0];
508 /* SWEEP TABLE ENTRIES NUMBER */
509 #define MAX_SWEEP_TAB_ENTRIES 42
510 #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
511 /* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs
512 * only use 8, and then use extended rates for the remaining supported
513 * rates. Other APs, however, stick all of their supported rates on the
514 * main rates information element... */
515 #define MAX_RATES_LENGTH ((u8)12)
516 #define MAX_RATES_EX_LENGTH ((u8)16)
517 #define MAX_NETWORK_COUNT 128
519 #define CRC_LENGTH 4U
521 #define MAX_WPA_IE_LEN 64
523 #define NETWORK_HAS_OFDM (1<<1)
524 #define NETWORK_HAS_CCK (1<<2)
527 #define NETWORK_HAS_QOS_PARAMETERS (1<<3)
528 #define NETWORK_HAS_QOS_INFORMATION (1<<4)
529 #define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \
530 NETWORK_HAS_QOS_INFORMATION)
533 #define NETWORK_HAS_POWER_CONSTRAINT (1<<5)
534 #define NETWORK_HAS_CSA (1<<6)
535 #define NETWORK_HAS_QUIET (1<<7)
536 #define NETWORK_HAS_IBSS_DFS (1<<8)
537 #define NETWORK_HAS_TPC_REPORT (1<<9)
539 #define NETWORK_HAS_ERP_VALUE (1<<10)
541 #define QOS_QUEUE_NUM 4
542 #define QOS_OUI_LEN 3
543 #define QOS_OUI_TYPE 2
544 #define QOS_ELEMENT_ID 221
545 #define QOS_OUI_INFO_SUB_TYPE 0
546 #define QOS_OUI_PARAM_SUB_TYPE 1
547 #define QOS_VERSION_1 1
548 #define QOS_AIFSN_MIN_VALUE 2
550 struct libipw_qos_information_element
{
558 } __attribute__ ((packed
));
560 struct libipw_qos_ac_parameter
{
564 } __attribute__ ((packed
));
566 struct libipw_qos_parameter_info
{
567 struct libipw_qos_information_element info_element
;
569 struct libipw_qos_ac_parameter ac_params_record
[QOS_QUEUE_NUM
];
570 } __attribute__ ((packed
));
572 struct libipw_qos_parameters
{
573 __le16 cw_min
[QOS_QUEUE_NUM
];
574 __le16 cw_max
[QOS_QUEUE_NUM
];
575 u8 aifs
[QOS_QUEUE_NUM
];
576 u8 flag
[QOS_QUEUE_NUM
];
577 __le16 tx_op_limit
[QOS_QUEUE_NUM
];
578 } __attribute__ ((packed
));
580 struct libipw_qos_data
{
581 struct libipw_qos_parameters parameters
;
588 struct libipw_tim_parameters
{
591 } __attribute__ ((packed
));
593 /*******************************************************/
595 enum { /* libipw_basic_report.map */
596 LIBIPW_BASIC_MAP_BSS
= (1 << 0),
597 LIBIPW_BASIC_MAP_OFDM
= (1 << 1),
598 LIBIPW_BASIC_MAP_UNIDENTIFIED
= (1 << 2),
599 LIBIPW_BASIC_MAP_RADAR
= (1 << 3),
600 LIBIPW_BASIC_MAP_UNMEASURED
= (1 << 4),
601 /* Bits 5-7 are reserved */
604 struct libipw_basic_report
{
609 } __attribute__ ((packed
));
611 enum { /* libipw_measurement_request.mode */
612 /* Bit 0 is reserved */
613 LIBIPW_MEASUREMENT_ENABLE
= (1 << 1),
614 LIBIPW_MEASUREMENT_REQUEST
= (1 << 2),
615 LIBIPW_MEASUREMENT_REPORT
= (1 << 3),
616 /* Bits 4-7 are reserved */
620 LIBIPW_REPORT_BASIC
= 0, /* required */
621 LIBIPW_REPORT_CCA
= 1, /* optional */
622 LIBIPW_REPORT_RPI
= 2, /* optional */
626 struct libipw_measurement_params
{
630 } __attribute__ ((packed
));
632 struct libipw_measurement_request
{
633 struct libipw_info_element ie
;
637 struct libipw_measurement_params params
[0];
638 } __attribute__ ((packed
));
640 struct libipw_measurement_report
{
641 struct libipw_info_element ie
;
646 struct libipw_basic_report basic
[0];
648 } __attribute__ ((packed
));
650 struct libipw_tpc_report
{
653 } __attribute__ ((packed
));
655 struct libipw_channel_map
{
658 } __attribute__ ((packed
));
660 struct libipw_ibss_dfs
{
661 struct libipw_info_element ie
;
663 u8 recovery_interval
;
664 struct libipw_channel_map channel_map
[0];
671 } __attribute__ ((packed
));
673 struct libipw_quiet
{
678 } __attribute__ ((packed
));
680 struct libipw_network
{
681 /* These entries are used to identify a unique network */
684 /* Ensure null-terminated for any debug msgs */
685 u8 ssid
[IW_ESSID_MAX_SIZE
+ 1];
688 struct libipw_qos_data qos_data
;
690 /* These are network statistics */
691 struct libipw_rx_stats stats
;
693 u8 rates
[MAX_RATES_LENGTH
];
695 u8 rates_ex
[MAX_RATES_EX_LENGTH
];
697 unsigned long last_scanned
;
706 u8 wpa_ie
[MAX_WPA_IE_LEN
];
708 u8 rsn_ie
[MAX_WPA_IE_LEN
];
710 struct libipw_tim_parameters tim
;
714 /* Power Constraint - mandatory if spctrm mgmt required */
717 /* TPC Report - mandatory if spctrm mgmt required */
718 struct libipw_tpc_report tpc_report
;
720 /* IBSS DFS - mandatory if spctrm mgmt required and IBSS
721 * NOTE: This is variable length and so must be allocated dynamically */
722 struct libipw_ibss_dfs
*ibss_dfs
;
724 /* Channel Switch Announcement - optional if spctrm mgmt required */
725 struct libipw_csa csa
;
727 /* Quiet - optional if spctrm mgmt required */
728 struct libipw_quiet quiet
;
730 struct list_head list
;
734 LIBIPW_UNINITIALIZED
= 0,
738 LIBIPW_AUTHENTICATING
,
739 LIBIPW_AUTHENTICATED
,
743 #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
744 #define DEFAULT_FTS 2346
746 #define CFG_LIBIPW_RESERVE_FCS (1<<0)
747 #define CFG_LIBIPW_COMPUTE_FCS (1<<1)
748 #define CFG_LIBIPW_RTS (1<<2)
750 #define LIBIPW_24GHZ_MIN_CHANNEL 1
751 #define LIBIPW_24GHZ_MAX_CHANNEL 14
752 #define LIBIPW_24GHZ_CHANNELS (LIBIPW_24GHZ_MAX_CHANNEL - \
753 LIBIPW_24GHZ_MIN_CHANNEL + 1)
755 #define LIBIPW_52GHZ_MIN_CHANNEL 34
756 #define LIBIPW_52GHZ_MAX_CHANNEL 165
757 #define LIBIPW_52GHZ_CHANNELS (LIBIPW_52GHZ_MAX_CHANNEL - \
758 LIBIPW_52GHZ_MIN_CHANNEL + 1)
761 LIBIPW_CH_PASSIVE_ONLY
= (1 << 0),
762 LIBIPW_CH_80211H_RULES
= (1 << 1),
763 LIBIPW_CH_B_ONLY
= (1 << 2),
764 LIBIPW_CH_NO_IBSS
= (1 << 3),
765 LIBIPW_CH_UNIFORM_SPREADING
= (1 << 4),
766 LIBIPW_CH_RADAR_DETECT
= (1 << 5),
767 LIBIPW_CH_INVALID
= (1 << 6),
770 struct libipw_channel
{
771 u32 freq
; /* in MHz */
774 u8 max_power
; /* in dBm */
781 struct libipw_channel bg
[LIBIPW_24GHZ_CHANNELS
];
782 struct libipw_channel a
[LIBIPW_52GHZ_CHANNELS
];
785 struct libipw_device
{
786 struct net_device
*dev
;
787 struct wireless_dev wdev
;
788 struct libipw_security sec
;
790 /* Bookkeeping structures */
791 struct libipw_stats ieee_stats
;
793 struct libipw_geo geo
;
794 struct ieee80211_supported_band bg_band
;
795 struct ieee80211_supported_band a_band
;
797 /* Probe / Beacon management */
798 struct list_head network_free_list
;
799 struct list_head network_list
;
800 struct libipw_network
*networks
;
804 int iw_mode
; /* operating mode (IW_MODE_*) */
805 struct iw_spy_data spy_data
; /* iwspy support */
809 int tx_headroom
; /* Set to size of any additional room needed at front
810 * of allocated Tx SKBs */
813 /* WEP and other encryption related settings at the device level */
814 int open_wep
; /* Set to 1 to allow unencrypted frames */
816 int reset_on_keychange
; /* Set to 1 if the HW needs to be reset on
819 /* If the host performs {en,de}cryption, then set to 1 */
821 int host_encrypt_msdu
;
823 /* host performs multicast decryption */
826 /* host should strip IV and ICV from protected frames */
827 /* meaningful only when hardware decryption is being used */
828 int host_strip_iv_icv
;
832 int ieee802_1x
; /* is IEEE 802.1X used */
836 int drop_unencrypted
;
841 struct lib80211_crypt_info crypt_info
;
843 int bcrx_sta_key
; /* use individual keys to override default keys even
844 * with RX of broad/multicast frames */
846 /* Fragmentation structures */
847 struct libipw_frag_entry frag_cache
[LIBIPW_FRAG_CACHE_LEN
];
848 unsigned int frag_next_idx
;
849 u16 fts
; /* Fragmentation Threshold */
850 u16 rts
; /* RTS threshold */
852 /* Association info */
855 enum libipw_state state
;
857 int mode
; /* A, B, G */
858 int modulation
; /* CCK, OFDM */
859 int freq_band
; /* 2.4Ghz, 5.2Ghz, Mixed */
860 int abg_true
; /* ABG flag */
865 u16 prev_seq_ctl
; /* used to drop duplicate frames */
867 /* Callback functions */
868 void (*set_security
) (struct net_device
* dev
,
869 struct libipw_security
* sec
);
870 netdev_tx_t (*hard_start_xmit
) (struct libipw_txb
* txb
,
871 struct net_device
* dev
, int pri
);
872 int (*reset_port
) (struct net_device
* dev
);
873 int (*is_queue_full
) (struct net_device
* dev
, int pri
);
875 int (*handle_management
) (struct net_device
* dev
,
876 struct libipw_network
* network
, u16 type
);
877 int (*is_qos_active
) (struct net_device
*dev
, struct sk_buff
*skb
);
879 /* Typical STA methods */
880 int (*handle_auth
) (struct net_device
* dev
,
881 struct libipw_auth
* auth
);
882 int (*handle_deauth
) (struct net_device
* dev
,
883 struct libipw_deauth
* auth
);
884 int (*handle_action
) (struct net_device
* dev
,
885 struct libipw_action
* action
,
886 struct libipw_rx_stats
* stats
);
887 int (*handle_disassoc
) (struct net_device
* dev
,
888 struct libipw_disassoc
* assoc
);
889 int (*handle_beacon
) (struct net_device
* dev
,
890 struct libipw_beacon
* beacon
,
891 struct libipw_network
* network
);
892 int (*handle_probe_response
) (struct net_device
* dev
,
893 struct libipw_probe_response
* resp
,
894 struct libipw_network
* network
);
895 int (*handle_probe_request
) (struct net_device
* dev
,
896 struct libipw_probe_request
* req
,
897 struct libipw_rx_stats
* stats
);
898 int (*handle_assoc_response
) (struct net_device
* dev
,
899 struct libipw_assoc_response
* resp
,
900 struct libipw_network
* network
);
902 /* Typical AP methods */
903 int (*handle_assoc_request
) (struct net_device
* dev
);
904 int (*handle_reassoc_request
) (struct net_device
* dev
,
905 struct libipw_reassoc_request
* req
);
907 /* This must be the last item so that it points to the data
908 * allocated beyond this structure by alloc_ieee80211 */
912 #define IEEE_A (1<<0)
913 #define IEEE_B (1<<1)
914 #define IEEE_G (1<<2)
915 #define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
917 static inline void *libipw_priv(struct net_device
*dev
)
919 return ((struct libipw_device
*)netdev_priv(dev
))->priv
;
922 static inline int libipw_is_valid_mode(struct libipw_device
*ieee
,
926 * It is possible for both access points and our device to support
927 * combinations of modes, so as long as there is one valid combination
928 * of ap/device supported modes, then return success
931 if ((mode
& IEEE_A
) &&
932 (ieee
->modulation
& LIBIPW_OFDM_MODULATION
) &&
933 (ieee
->freq_band
& LIBIPW_52GHZ_BAND
))
936 if ((mode
& IEEE_G
) &&
937 (ieee
->modulation
& LIBIPW_OFDM_MODULATION
) &&
938 (ieee
->freq_band
& LIBIPW_24GHZ_BAND
))
941 if ((mode
& IEEE_B
) &&
942 (ieee
->modulation
& LIBIPW_CCK_MODULATION
) &&
943 (ieee
->freq_band
& LIBIPW_24GHZ_BAND
))
949 static inline int libipw_get_hdrlen(u16 fc
)
951 int hdrlen
= LIBIPW_3ADDR_LEN
;
952 u16 stype
= WLAN_FC_GET_STYPE(fc
);
954 switch (WLAN_FC_GET_TYPE(fc
)) {
955 case IEEE80211_FTYPE_DATA
:
956 if ((fc
& IEEE80211_FCTL_FROMDS
) && (fc
& IEEE80211_FCTL_TODS
))
957 hdrlen
= LIBIPW_4ADDR_LEN
;
958 if (stype
& IEEE80211_STYPE_QOS_DATA
)
961 case IEEE80211_FTYPE_CTL
:
962 switch (WLAN_FC_GET_STYPE(fc
)) {
963 case IEEE80211_STYPE_CTS
:
964 case IEEE80211_STYPE_ACK
:
965 hdrlen
= LIBIPW_1ADDR_LEN
;
968 hdrlen
= LIBIPW_2ADDR_LEN
;
977 static inline u8
*libipw_get_payload(struct ieee80211_hdr
*hdr
)
979 switch (libipw_get_hdrlen(le16_to_cpu(hdr
->frame_control
))) {
980 case LIBIPW_1ADDR_LEN
:
981 return ((struct libipw_hdr_1addr
*)hdr
)->payload
;
982 case LIBIPW_2ADDR_LEN
:
983 return ((struct libipw_hdr_2addr
*)hdr
)->payload
;
984 case LIBIPW_3ADDR_LEN
:
985 return ((struct libipw_hdr_3addr
*)hdr
)->payload
;
986 case LIBIPW_4ADDR_LEN
:
987 return ((struct libipw_hdr_4addr
*)hdr
)->payload
;
992 static inline int libipw_is_ofdm_rate(u8 rate
)
994 switch (rate
& ~LIBIPW_BASIC_RATE_MASK
) {
995 case LIBIPW_OFDM_RATE_6MB
:
996 case LIBIPW_OFDM_RATE_9MB
:
997 case LIBIPW_OFDM_RATE_12MB
:
998 case LIBIPW_OFDM_RATE_18MB
:
999 case LIBIPW_OFDM_RATE_24MB
:
1000 case LIBIPW_OFDM_RATE_36MB
:
1001 case LIBIPW_OFDM_RATE_48MB
:
1002 case LIBIPW_OFDM_RATE_54MB
:
1008 static inline int libipw_is_cck_rate(u8 rate
)
1010 switch (rate
& ~LIBIPW_BASIC_RATE_MASK
) {
1011 case LIBIPW_CCK_RATE_1MB
:
1012 case LIBIPW_CCK_RATE_2MB
:
1013 case LIBIPW_CCK_RATE_5MB
:
1014 case LIBIPW_CCK_RATE_11MB
:
1021 extern void free_ieee80211(struct net_device
*dev
, int monitor
);
1022 extern struct net_device
*alloc_ieee80211(int sizeof_priv
, int monitor
);
1023 extern int libipw_change_mtu(struct net_device
*dev
, int new_mtu
);
1025 extern void libipw_networks_age(struct libipw_device
*ieee
,
1026 unsigned long age_secs
);
1028 extern int libipw_set_encryption(struct libipw_device
*ieee
);
1031 extern netdev_tx_t
libipw_xmit(struct sk_buff
*skb
,
1032 struct net_device
*dev
);
1033 extern void libipw_txb_free(struct libipw_txb
*);
1036 extern void libipw_rx_any(struct libipw_device
*ieee
,
1037 struct sk_buff
*skb
, struct libipw_rx_stats
*stats
);
1038 extern int libipw_rx(struct libipw_device
*ieee
, struct sk_buff
*skb
,
1039 struct libipw_rx_stats
*rx_stats
);
1040 /* make sure to set stats->len */
1041 extern void libipw_rx_mgt(struct libipw_device
*ieee
,
1042 struct libipw_hdr_4addr
*header
,
1043 struct libipw_rx_stats
*stats
);
1044 extern void libipw_network_reset(struct libipw_network
*network
);
1047 extern const struct libipw_geo
*libipw_get_geo(struct libipw_device
1049 extern int libipw_set_geo(struct libipw_device
*ieee
,
1050 const struct libipw_geo
*geo
);
1052 extern int libipw_is_valid_channel(struct libipw_device
*ieee
,
1054 extern int libipw_channel_to_index(struct libipw_device
*ieee
,
1056 extern u8
libipw_freq_to_channel(struct libipw_device
*ieee
, u32 freq
);
1057 extern u8
libipw_get_channel_flags(struct libipw_device
*ieee
,
1059 extern const struct libipw_channel
*libipw_get_channel(struct
1062 extern u32
libipw_channel_to_freq(struct libipw_device
* ieee
,
1066 extern int libipw_wx_get_scan(struct libipw_device
*ieee
,
1067 struct iw_request_info
*info
,
1068 union iwreq_data
*wrqu
, char *key
);
1069 extern int libipw_wx_set_encode(struct libipw_device
*ieee
,
1070 struct iw_request_info
*info
,
1071 union iwreq_data
*wrqu
, char *key
);
1072 extern int libipw_wx_get_encode(struct libipw_device
*ieee
,
1073 struct iw_request_info
*info
,
1074 union iwreq_data
*wrqu
, char *key
);
1075 extern int libipw_wx_set_encodeext(struct libipw_device
*ieee
,
1076 struct iw_request_info
*info
,
1077 union iwreq_data
*wrqu
, char *extra
);
1078 extern int libipw_wx_get_encodeext(struct libipw_device
*ieee
,
1079 struct iw_request_info
*info
,
1080 union iwreq_data
*wrqu
, char *extra
);
1082 static inline void libipw_increment_scans(struct libipw_device
*ieee
)
1087 static inline int libipw_get_scans(struct libipw_device
*ieee
)
1092 #endif /* LIBIPW_H */