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 "libipw: %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 #define LIBIPW_DL_INFO (1<<0)
83 #define LIBIPW_DL_WX (1<<1)
84 #define LIBIPW_DL_SCAN (1<<2)
85 #define LIBIPW_DL_STATE (1<<3)
86 #define LIBIPW_DL_MGMT (1<<4)
87 #define LIBIPW_DL_FRAG (1<<5)
88 #define LIBIPW_DL_DROP (1<<7)
90 #define LIBIPW_DL_TX (1<<8)
91 #define LIBIPW_DL_RX (1<<9)
92 #define LIBIPW_DL_QOS (1<<31)
94 #define LIBIPW_ERROR(f, a...) printk(KERN_ERR "libipw: " f, ## a)
95 #define LIBIPW_WARNING(f, a...) printk(KERN_WARNING "libipw: " f, ## a)
96 #define LIBIPW_DEBUG_INFO(f, a...) LIBIPW_DEBUG(LIBIPW_DL_INFO, f, ## a)
98 #define LIBIPW_DEBUG_WX(f, a...) LIBIPW_DEBUG(LIBIPW_DL_WX, f, ## a)
99 #define LIBIPW_DEBUG_SCAN(f, a...) LIBIPW_DEBUG(LIBIPW_DL_SCAN, f, ## a)
100 #define LIBIPW_DEBUG_STATE(f, a...) LIBIPW_DEBUG(LIBIPW_DL_STATE, f, ## a)
101 #define LIBIPW_DEBUG_MGMT(f, a...) LIBIPW_DEBUG(LIBIPW_DL_MGMT, f, ## a)
102 #define LIBIPW_DEBUG_FRAG(f, a...) LIBIPW_DEBUG(LIBIPW_DL_FRAG, f, ## a)
103 #define LIBIPW_DEBUG_DROP(f, a...) LIBIPW_DEBUG(LIBIPW_DL_DROP, f, ## a)
104 #define LIBIPW_DEBUG_TX(f, a...) LIBIPW_DEBUG(LIBIPW_DL_TX, f, ## a)
105 #define LIBIPW_DEBUG_RX(f, a...) LIBIPW_DEBUG(LIBIPW_DL_RX, f, ## a)
106 #define LIBIPW_DEBUG_QOS(f, a...) LIBIPW_DEBUG(LIBIPW_DL_QOS, f, ## a)
107 #include <linux/netdevice.h>
108 #include <linux/if_arp.h> /* ARPHRD_ETHER */
111 #define WIRELESS_SPY /* enable iwspy support */
113 #include <net/iw_handler.h> /* new driver API */
115 #define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
117 #ifndef ETH_P_80211_RAW
118 #define ETH_P_80211_RAW (ETH_P_ECONET + 1)
121 /* IEEE 802.11 defines */
123 #define P80211_OUI_LEN 3
125 struct libipw_snap_hdr
{
127 u8 dsap
; /* always 0xAA */
128 u8 ssap
; /* always 0xAA */
129 u8 ctrl
; /* always 0x03 */
130 u8 oui
[P80211_OUI_LEN
]; /* organizational universal id */
134 #define SNAP_SIZE sizeof(struct libipw_snap_hdr)
136 #define WLAN_FC_GET_VERS(fc) ((fc) & IEEE80211_FCTL_VERS)
137 #define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE)
138 #define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE)
140 #define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG)
141 #define WLAN_GET_SEQ_SEQ(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
143 #define LIBIPW_STATMASK_SIGNAL (1<<0)
144 #define LIBIPW_STATMASK_RSSI (1<<1)
145 #define LIBIPW_STATMASK_NOISE (1<<2)
146 #define LIBIPW_STATMASK_RATE (1<<3)
147 #define LIBIPW_STATMASK_WEMASK 0x7
149 #define LIBIPW_CCK_MODULATION (1<<0)
150 #define LIBIPW_OFDM_MODULATION (1<<1)
152 #define LIBIPW_24GHZ_BAND (1<<0)
153 #define LIBIPW_52GHZ_BAND (1<<1)
155 #define LIBIPW_CCK_RATE_1MB 0x02
156 #define LIBIPW_CCK_RATE_2MB 0x04
157 #define LIBIPW_CCK_RATE_5MB 0x0B
158 #define LIBIPW_CCK_RATE_11MB 0x16
159 #define LIBIPW_OFDM_RATE_6MB 0x0C
160 #define LIBIPW_OFDM_RATE_9MB 0x12
161 #define LIBIPW_OFDM_RATE_12MB 0x18
162 #define LIBIPW_OFDM_RATE_18MB 0x24
163 #define LIBIPW_OFDM_RATE_24MB 0x30
164 #define LIBIPW_OFDM_RATE_36MB 0x48
165 #define LIBIPW_OFDM_RATE_48MB 0x60
166 #define LIBIPW_OFDM_RATE_54MB 0x6C
167 #define LIBIPW_BASIC_RATE_MASK 0x80
169 #define LIBIPW_CCK_RATE_1MB_MASK (1<<0)
170 #define LIBIPW_CCK_RATE_2MB_MASK (1<<1)
171 #define LIBIPW_CCK_RATE_5MB_MASK (1<<2)
172 #define LIBIPW_CCK_RATE_11MB_MASK (1<<3)
173 #define LIBIPW_OFDM_RATE_6MB_MASK (1<<4)
174 #define LIBIPW_OFDM_RATE_9MB_MASK (1<<5)
175 #define LIBIPW_OFDM_RATE_12MB_MASK (1<<6)
176 #define LIBIPW_OFDM_RATE_18MB_MASK (1<<7)
177 #define LIBIPW_OFDM_RATE_24MB_MASK (1<<8)
178 #define LIBIPW_OFDM_RATE_36MB_MASK (1<<9)
179 #define LIBIPW_OFDM_RATE_48MB_MASK (1<<10)
180 #define LIBIPW_OFDM_RATE_54MB_MASK (1<<11)
182 #define LIBIPW_CCK_RATES_MASK 0x0000000F
183 #define LIBIPW_CCK_BASIC_RATES_MASK (LIBIPW_CCK_RATE_1MB_MASK | \
184 LIBIPW_CCK_RATE_2MB_MASK)
185 #define LIBIPW_CCK_DEFAULT_RATES_MASK (LIBIPW_CCK_BASIC_RATES_MASK | \
186 LIBIPW_CCK_RATE_5MB_MASK | \
187 LIBIPW_CCK_RATE_11MB_MASK)
189 #define LIBIPW_OFDM_RATES_MASK 0x00000FF0
190 #define LIBIPW_OFDM_BASIC_RATES_MASK (LIBIPW_OFDM_RATE_6MB_MASK | \
191 LIBIPW_OFDM_RATE_12MB_MASK | \
192 LIBIPW_OFDM_RATE_24MB_MASK)
193 #define LIBIPW_OFDM_DEFAULT_RATES_MASK (LIBIPW_OFDM_BASIC_RATES_MASK | \
194 LIBIPW_OFDM_RATE_9MB_MASK | \
195 LIBIPW_OFDM_RATE_18MB_MASK | \
196 LIBIPW_OFDM_RATE_36MB_MASK | \
197 LIBIPW_OFDM_RATE_48MB_MASK | \
198 LIBIPW_OFDM_RATE_54MB_MASK)
199 #define LIBIPW_DEFAULT_RATES_MASK (LIBIPW_OFDM_DEFAULT_RATES_MASK | \
200 LIBIPW_CCK_DEFAULT_RATES_MASK)
202 #define LIBIPW_NUM_OFDM_RATES 8
203 #define LIBIPW_NUM_CCK_RATES 4
204 #define LIBIPW_OFDM_SHIFT_MASK_A 4
206 /* NOTE: This data is for statistical purposes; not all hardware provides this
207 * information for frames received.
208 * For libipw_rx_mgt, you need to set at least the 'len' parameter.
210 struct libipw_rx_stats
{
215 u16 rate
; /* in 100 kbps */
225 /* IEEE 802.11 requires that STA supports concurrent reception of at least
226 * three fragmented frames. This define can be increased to support more
227 * concurrent frames, but it should be noted that each entry can consume about
228 * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
229 #define LIBIPW_FRAG_CACHE_LEN 4
231 struct libipw_frag_entry
{
232 unsigned long first_frag_time
;
234 unsigned int last_frag
;
236 u8 src_addr
[ETH_ALEN
];
237 u8 dst_addr
[ETH_ALEN
];
240 struct libipw_stats
{
241 unsigned int tx_unicast_frames
;
242 unsigned int tx_multicast_frames
;
243 unsigned int tx_fragments
;
244 unsigned int tx_unicast_octets
;
245 unsigned int tx_multicast_octets
;
246 unsigned int tx_deferred_transmissions
;
247 unsigned int tx_single_retry_frames
;
248 unsigned int tx_multiple_retry_frames
;
249 unsigned int tx_retry_limit_exceeded
;
250 unsigned int tx_discards
;
251 unsigned int rx_unicast_frames
;
252 unsigned int rx_multicast_frames
;
253 unsigned int rx_fragments
;
254 unsigned int rx_unicast_octets
;
255 unsigned int rx_multicast_octets
;
256 unsigned int rx_fcs_errors
;
257 unsigned int rx_discards_no_buffer
;
258 unsigned int tx_discards_wrong_sa
;
259 unsigned int rx_discards_undecryptable
;
260 unsigned int rx_message_in_msg_fragments
;
261 unsigned int rx_message_in_bad_msg_fragments
;
264 struct libipw_device
;
266 #define SEC_KEY_1 (1<<0)
267 #define SEC_KEY_2 (1<<1)
268 #define SEC_KEY_3 (1<<2)
269 #define SEC_KEY_4 (1<<3)
270 #define SEC_ACTIVE_KEY (1<<4)
271 #define SEC_AUTH_MODE (1<<5)
272 #define SEC_UNICAST_GROUP (1<<6)
273 #define SEC_LEVEL (1<<7)
274 #define SEC_ENABLED (1<<8)
275 #define SEC_ENCRYPT (1<<9)
277 #define SEC_LEVEL_0 0 /* None */
278 #define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */
279 #define SEC_LEVEL_2 2 /* Level 1 + TKIP */
280 #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
281 #define SEC_LEVEL_3 4 /* Level 2 + CCMP */
283 #define SEC_ALG_NONE 0
284 #define SEC_ALG_WEP 1
285 #define SEC_ALG_TKIP 2
286 #define SEC_ALG_CCMP 3
289 #define WEP_KEY_LEN 13
290 #define SCM_KEY_LEN 32
291 #define SCM_TEMPORAL_KEY_LENGTH 16
293 struct libipw_security
{
294 u16 active_key
:2, enabled
:1, unicast_uses_group
:1, encrypt
:1;
296 u8 encode_alg
[WEP_KEYS
];
297 u8 key_sizes
[WEP_KEYS
];
298 u8 keys
[WEP_KEYS
][SCM_KEY_LEN
];
305 802.11 data frame from AP
307 ,-------------------------------------------------------------------.
308 Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
309 |------|------|---------|---------|---------|------|---------|------|
310 Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs |
311 | | tion | (BSSID) | | | ence | data | |
312 `-------------------------------------------------------------------'
318 #define BEACON_PROBE_SSID_ID_POSITION 12
320 struct libipw_hdr_1addr
{
327 struct libipw_hdr_2addr
{
335 struct libipw_hdr_3addr
{
345 struct libipw_hdr_4addr
{
356 struct libipw_hdr_3addrqos
{
367 struct libipw_info_element
{
374 * These are the data types that can make up management packets
380 u8 current_ap[ETH_ALEN];
383 u16 association_id:14, reserved:2;
391 struct libipw_hdr_3addr header
;
396 struct libipw_info_element info_element
[0];
399 struct libipw_channel_switch
{
407 struct libipw_action
{
408 struct libipw_hdr_3addr header
;
412 struct libipw_action_exchange
{
414 struct libipw_info_element info_element
[0];
416 struct libipw_channel_switch channel_switch
;
421 struct libipw_disassoc
{
422 struct libipw_hdr_3addr header
;
426 /* Alias deauth for disassoc */
427 #define libipw_deauth libipw_disassoc
429 struct libipw_probe_request
{
430 struct libipw_hdr_3addr header
;
431 /* SSID, supported rates */
432 struct libipw_info_element info_element
[0];
435 struct libipw_probe_response
{
436 struct libipw_hdr_3addr header
;
437 __le32 time_stamp
[2];
438 __le16 beacon_interval
;
440 /* SSID, supported rates, FH params, DS params,
441 * CF params, IBSS params, TIM (if beacon), RSN */
442 struct libipw_info_element info_element
[0];
445 /* Alias beacon for probe_response */
446 #define libipw_beacon libipw_probe_response
448 struct libipw_assoc_request
{
449 struct libipw_hdr_3addr header
;
451 __le16 listen_interval
;
452 /* SSID, supported rates, RSN */
453 struct libipw_info_element info_element
[0];
456 struct libipw_reassoc_request
{
457 struct libipw_hdr_3addr header
;
459 __le16 listen_interval
;
460 u8 current_ap
[ETH_ALEN
];
461 struct libipw_info_element info_element
[0];
464 struct libipw_assoc_response
{
465 struct libipw_hdr_3addr header
;
469 /* supported rates */
470 struct libipw_info_element info_element
[0];
480 struct sk_buff
*fragments
[0];
483 /* SWEEP TABLE ENTRIES NUMBER */
484 #define MAX_SWEEP_TAB_ENTRIES 42
485 #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
486 /* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs
487 * only use 8, and then use extended rates for the remaining supported
488 * rates. Other APs, however, stick all of their supported rates on the
489 * main rates information element... */
490 #define MAX_RATES_LENGTH ((u8)12)
491 #define MAX_RATES_EX_LENGTH ((u8)16)
492 #define MAX_NETWORK_COUNT 128
494 #define CRC_LENGTH 4U
496 #define MAX_WPA_IE_LEN 64
498 #define NETWORK_HAS_OFDM (1<<1)
499 #define NETWORK_HAS_CCK (1<<2)
502 #define NETWORK_HAS_QOS_PARAMETERS (1<<3)
503 #define NETWORK_HAS_QOS_INFORMATION (1<<4)
504 #define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \
505 NETWORK_HAS_QOS_INFORMATION)
508 #define NETWORK_HAS_POWER_CONSTRAINT (1<<5)
509 #define NETWORK_HAS_CSA (1<<6)
510 #define NETWORK_HAS_QUIET (1<<7)
511 #define NETWORK_HAS_IBSS_DFS (1<<8)
512 #define NETWORK_HAS_TPC_REPORT (1<<9)
514 #define NETWORK_HAS_ERP_VALUE (1<<10)
516 #define QOS_QUEUE_NUM 4
517 #define QOS_OUI_LEN 3
518 #define QOS_OUI_TYPE 2
519 #define QOS_ELEMENT_ID 221
520 #define QOS_OUI_INFO_SUB_TYPE 0
521 #define QOS_OUI_PARAM_SUB_TYPE 1
522 #define QOS_VERSION_1 1
523 #define QOS_AIFSN_MIN_VALUE 2
525 struct libipw_qos_information_element
{
535 struct libipw_qos_ac_parameter
{
541 struct libipw_qos_parameter_info
{
542 struct libipw_qos_information_element info_element
;
544 struct libipw_qos_ac_parameter ac_params_record
[QOS_QUEUE_NUM
];
547 struct libipw_qos_parameters
{
548 __le16 cw_min
[QOS_QUEUE_NUM
];
549 __le16 cw_max
[QOS_QUEUE_NUM
];
550 u8 aifs
[QOS_QUEUE_NUM
];
551 u8 flag
[QOS_QUEUE_NUM
];
552 __le16 tx_op_limit
[QOS_QUEUE_NUM
];
555 struct libipw_qos_data
{
556 struct libipw_qos_parameters parameters
;
563 struct libipw_tim_parameters
{
568 /*******************************************************/
570 enum { /* libipw_basic_report.map */
571 LIBIPW_BASIC_MAP_BSS
= (1 << 0),
572 LIBIPW_BASIC_MAP_OFDM
= (1 << 1),
573 LIBIPW_BASIC_MAP_UNIDENTIFIED
= (1 << 2),
574 LIBIPW_BASIC_MAP_RADAR
= (1 << 3),
575 LIBIPW_BASIC_MAP_UNMEASURED
= (1 << 4),
576 /* Bits 5-7 are reserved */
579 struct libipw_basic_report
{
586 enum { /* libipw_measurement_request.mode */
587 /* Bit 0 is reserved */
588 LIBIPW_MEASUREMENT_ENABLE
= (1 << 1),
589 LIBIPW_MEASUREMENT_REQUEST
= (1 << 2),
590 LIBIPW_MEASUREMENT_REPORT
= (1 << 3),
591 /* Bits 4-7 are reserved */
595 LIBIPW_REPORT_BASIC
= 0, /* required */
596 LIBIPW_REPORT_CCA
= 1, /* optional */
597 LIBIPW_REPORT_RPI
= 2, /* optional */
601 struct libipw_measurement_params
{
607 struct libipw_measurement_request
{
608 struct libipw_info_element ie
;
612 struct libipw_measurement_params params
[0];
615 struct libipw_measurement_report
{
616 struct libipw_info_element ie
;
621 struct libipw_basic_report basic
[0];
625 struct libipw_tpc_report
{
630 struct libipw_channel_map
{
635 struct libipw_ibss_dfs
{
636 struct libipw_info_element ie
;
638 u8 recovery_interval
;
639 struct libipw_channel_map channel_map
[0];
648 struct libipw_quiet
{
655 struct libipw_network
{
656 /* These entries are used to identify a unique network */
659 /* Ensure null-terminated for any debug msgs */
660 u8 ssid
[IW_ESSID_MAX_SIZE
+ 1];
663 struct libipw_qos_data qos_data
;
665 /* These are network statistics */
666 struct libipw_rx_stats stats
;
668 u8 rates
[MAX_RATES_LENGTH
];
670 u8 rates_ex
[MAX_RATES_EX_LENGTH
];
672 unsigned long last_scanned
;
681 u8 wpa_ie
[MAX_WPA_IE_LEN
];
683 u8 rsn_ie
[MAX_WPA_IE_LEN
];
685 struct libipw_tim_parameters tim
;
689 /* Power Constraint - mandatory if spctrm mgmt required */
692 /* TPC Report - mandatory if spctrm mgmt required */
693 struct libipw_tpc_report tpc_report
;
695 /* IBSS DFS - mandatory if spctrm mgmt required and IBSS
696 * NOTE: This is variable length and so must be allocated dynamically */
697 struct libipw_ibss_dfs
*ibss_dfs
;
699 /* Channel Switch Announcement - optional if spctrm mgmt required */
700 struct libipw_csa csa
;
702 /* Quiet - optional if spctrm mgmt required */
703 struct libipw_quiet quiet
;
705 struct list_head list
;
709 LIBIPW_UNINITIALIZED
= 0,
713 LIBIPW_AUTHENTICATING
,
714 LIBIPW_AUTHENTICATED
,
718 #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
719 #define DEFAULT_FTS 2346
721 #define CFG_LIBIPW_RESERVE_FCS (1<<0)
722 #define CFG_LIBIPW_COMPUTE_FCS (1<<1)
723 #define CFG_LIBIPW_RTS (1<<2)
725 #define LIBIPW_24GHZ_MIN_CHANNEL 1
726 #define LIBIPW_24GHZ_MAX_CHANNEL 14
727 #define LIBIPW_24GHZ_CHANNELS (LIBIPW_24GHZ_MAX_CHANNEL - \
728 LIBIPW_24GHZ_MIN_CHANNEL + 1)
730 #define LIBIPW_52GHZ_MIN_CHANNEL 34
731 #define LIBIPW_52GHZ_MAX_CHANNEL 165
732 #define LIBIPW_52GHZ_CHANNELS (LIBIPW_52GHZ_MAX_CHANNEL - \
733 LIBIPW_52GHZ_MIN_CHANNEL + 1)
736 LIBIPW_CH_PASSIVE_ONLY
= (1 << 0),
737 LIBIPW_CH_80211H_RULES
= (1 << 1),
738 LIBIPW_CH_B_ONLY
= (1 << 2),
739 LIBIPW_CH_NO_IBSS
= (1 << 3),
740 LIBIPW_CH_UNIFORM_SPREADING
= (1 << 4),
741 LIBIPW_CH_RADAR_DETECT
= (1 << 5),
742 LIBIPW_CH_INVALID
= (1 << 6),
745 struct libipw_channel
{
746 u32 freq
; /* in MHz */
749 u8 max_power
; /* in dBm */
756 struct libipw_channel bg
[LIBIPW_24GHZ_CHANNELS
];
757 struct libipw_channel a
[LIBIPW_52GHZ_CHANNELS
];
760 struct libipw_device
{
761 struct net_device
*dev
;
762 struct wireless_dev wdev
;
763 struct libipw_security sec
;
765 /* Bookkeeping structures */
766 struct libipw_stats ieee_stats
;
768 struct libipw_geo geo
;
769 struct ieee80211_supported_band bg_band
;
770 struct ieee80211_supported_band a_band
;
772 /* Probe / Beacon management */
773 struct list_head network_free_list
;
774 struct list_head network_list
;
775 struct libipw_network
*networks
[MAX_NETWORK_COUNT
];
779 int iw_mode
; /* operating mode (IW_MODE_*) */
780 struct iw_spy_data spy_data
; /* iwspy support */
784 int tx_headroom
; /* Set to size of any additional room needed at front
785 * of allocated Tx SKBs */
788 /* WEP and other encryption related settings at the device level */
789 int open_wep
; /* Set to 1 to allow unencrypted frames */
791 int reset_on_keychange
; /* Set to 1 if the HW needs to be reset on
794 /* If the host performs {en,de}cryption, then set to 1 */
796 int host_encrypt_msdu
;
798 /* host performs multicast decryption */
801 /* host should strip IV and ICV from protected frames */
802 /* meaningful only when hardware decryption is being used */
803 int host_strip_iv_icv
;
806 int ieee802_1x
; /* is IEEE 802.1X used */
810 int drop_unencrypted
;
815 struct lib80211_crypt_info crypt_info
;
817 int bcrx_sta_key
; /* use individual keys to override default keys even
818 * with RX of broad/multicast frames */
820 /* Fragmentation structures */
821 struct libipw_frag_entry frag_cache
[LIBIPW_FRAG_CACHE_LEN
];
822 unsigned int frag_next_idx
;
823 u16 fts
; /* Fragmentation Threshold */
824 u16 rts
; /* RTS threshold */
826 /* Association info */
829 enum libipw_state state
;
831 int mode
; /* A, B, G */
832 int modulation
; /* CCK, OFDM */
833 int freq_band
; /* 2.4Ghz, 5.2Ghz, Mixed */
834 int abg_true
; /* ABG flag */
839 u16 prev_seq_ctl
; /* used to drop duplicate frames */
841 /* Callback functions */
842 void (*set_security
) (struct net_device
* dev
,
843 struct libipw_security
* sec
);
844 netdev_tx_t (*hard_start_xmit
) (struct libipw_txb
* txb
,
845 struct net_device
* dev
, int pri
);
846 int (*reset_port
) (struct net_device
* dev
);
847 int (*is_queue_full
) (struct net_device
* dev
, int pri
);
849 int (*handle_management
) (struct net_device
* dev
,
850 struct libipw_network
* network
, u16 type
);
851 int (*is_qos_active
) (struct net_device
*dev
, struct sk_buff
*skb
);
853 /* Typical STA methods */
854 int (*handle_auth
) (struct net_device
* dev
,
855 struct libipw_auth
* auth
);
856 int (*handle_deauth
) (struct net_device
* dev
,
857 struct libipw_deauth
* auth
);
858 int (*handle_action
) (struct net_device
* dev
,
859 struct libipw_action
* action
,
860 struct libipw_rx_stats
* stats
);
861 int (*handle_disassoc
) (struct net_device
* dev
,
862 struct libipw_disassoc
* assoc
);
863 int (*handle_beacon
) (struct net_device
* dev
,
864 struct libipw_beacon
* beacon
,
865 struct libipw_network
* network
);
866 int (*handle_probe_response
) (struct net_device
* dev
,
867 struct libipw_probe_response
* resp
,
868 struct libipw_network
* network
);
869 int (*handle_probe_request
) (struct net_device
* dev
,
870 struct libipw_probe_request
* req
,
871 struct libipw_rx_stats
* stats
);
872 int (*handle_assoc_response
) (struct net_device
* dev
,
873 struct libipw_assoc_response
* resp
,
874 struct libipw_network
* network
);
876 /* Typical AP methods */
877 int (*handle_assoc_request
) (struct net_device
* dev
);
878 int (*handle_reassoc_request
) (struct net_device
* dev
,
879 struct libipw_reassoc_request
* req
);
881 /* This must be the last item so that it points to the data
882 * allocated beyond this structure by alloc_libipw */
886 #define IEEE_A (1<<0)
887 #define IEEE_B (1<<1)
888 #define IEEE_G (1<<2)
889 #define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
891 static inline void *libipw_priv(struct net_device
*dev
)
893 return ((struct libipw_device
*)netdev_priv(dev
))->priv
;
896 static inline int libipw_is_valid_mode(struct libipw_device
*ieee
,
900 * It is possible for both access points and our device to support
901 * combinations of modes, so as long as there is one valid combination
902 * of ap/device supported modes, then return success
905 if ((mode
& IEEE_A
) &&
906 (ieee
->modulation
& LIBIPW_OFDM_MODULATION
) &&
907 (ieee
->freq_band
& LIBIPW_52GHZ_BAND
))
910 if ((mode
& IEEE_G
) &&
911 (ieee
->modulation
& LIBIPW_OFDM_MODULATION
) &&
912 (ieee
->freq_band
& LIBIPW_24GHZ_BAND
))
915 if ((mode
& IEEE_B
) &&
916 (ieee
->modulation
& LIBIPW_CCK_MODULATION
) &&
917 (ieee
->freq_band
& LIBIPW_24GHZ_BAND
))
923 static inline int libipw_get_hdrlen(u16 fc
)
925 int hdrlen
= LIBIPW_3ADDR_LEN
;
926 u16 stype
= WLAN_FC_GET_STYPE(fc
);
928 switch (WLAN_FC_GET_TYPE(fc
)) {
929 case IEEE80211_FTYPE_DATA
:
930 if ((fc
& IEEE80211_FCTL_FROMDS
) && (fc
& IEEE80211_FCTL_TODS
))
931 hdrlen
= LIBIPW_4ADDR_LEN
;
932 if (stype
& IEEE80211_STYPE_QOS_DATA
)
935 case IEEE80211_FTYPE_CTL
:
936 switch (WLAN_FC_GET_STYPE(fc
)) {
937 case IEEE80211_STYPE_CTS
:
938 case IEEE80211_STYPE_ACK
:
939 hdrlen
= LIBIPW_1ADDR_LEN
;
942 hdrlen
= LIBIPW_2ADDR_LEN
;
951 static inline u8
*libipw_get_payload(struct ieee80211_hdr
*hdr
)
953 switch (libipw_get_hdrlen(le16_to_cpu(hdr
->frame_control
))) {
954 case LIBIPW_1ADDR_LEN
:
955 return ((struct libipw_hdr_1addr
*)hdr
)->payload
;
956 case LIBIPW_2ADDR_LEN
:
957 return ((struct libipw_hdr_2addr
*)hdr
)->payload
;
958 case LIBIPW_3ADDR_LEN
:
959 return ((struct libipw_hdr_3addr
*)hdr
)->payload
;
960 case LIBIPW_4ADDR_LEN
:
961 return ((struct libipw_hdr_4addr
*)hdr
)->payload
;
966 static inline int libipw_is_ofdm_rate(u8 rate
)
968 switch (rate
& ~LIBIPW_BASIC_RATE_MASK
) {
969 case LIBIPW_OFDM_RATE_6MB
:
970 case LIBIPW_OFDM_RATE_9MB
:
971 case LIBIPW_OFDM_RATE_12MB
:
972 case LIBIPW_OFDM_RATE_18MB
:
973 case LIBIPW_OFDM_RATE_24MB
:
974 case LIBIPW_OFDM_RATE_36MB
:
975 case LIBIPW_OFDM_RATE_48MB
:
976 case LIBIPW_OFDM_RATE_54MB
:
982 static inline int libipw_is_cck_rate(u8 rate
)
984 switch (rate
& ~LIBIPW_BASIC_RATE_MASK
) {
985 case LIBIPW_CCK_RATE_1MB
:
986 case LIBIPW_CCK_RATE_2MB
:
987 case LIBIPW_CCK_RATE_5MB
:
988 case LIBIPW_CCK_RATE_11MB
:
995 extern void free_libipw(struct net_device
*dev
, int monitor
);
996 extern struct net_device
*alloc_libipw(int sizeof_priv
, int monitor
);
997 extern int libipw_change_mtu(struct net_device
*dev
, int new_mtu
);
999 extern void libipw_networks_age(struct libipw_device
*ieee
,
1000 unsigned long age_secs
);
1002 extern int libipw_set_encryption(struct libipw_device
*ieee
);
1005 extern netdev_tx_t
libipw_xmit(struct sk_buff
*skb
,
1006 struct net_device
*dev
);
1007 extern void libipw_txb_free(struct libipw_txb
*);
1010 extern void libipw_rx_any(struct libipw_device
*ieee
,
1011 struct sk_buff
*skb
, struct libipw_rx_stats
*stats
);
1012 extern int libipw_rx(struct libipw_device
*ieee
, struct sk_buff
*skb
,
1013 struct libipw_rx_stats
*rx_stats
);
1014 /* make sure to set stats->len */
1015 extern void libipw_rx_mgt(struct libipw_device
*ieee
,
1016 struct libipw_hdr_4addr
*header
,
1017 struct libipw_rx_stats
*stats
);
1018 extern void libipw_network_reset(struct libipw_network
*network
);
1021 extern const struct libipw_geo
*libipw_get_geo(struct libipw_device
1023 extern int libipw_set_geo(struct libipw_device
*ieee
,
1024 const struct libipw_geo
*geo
);
1026 extern int libipw_is_valid_channel(struct libipw_device
*ieee
,
1028 extern int libipw_channel_to_index(struct libipw_device
*ieee
,
1030 extern u8
libipw_freq_to_channel(struct libipw_device
*ieee
, u32 freq
);
1031 extern u8
libipw_get_channel_flags(struct libipw_device
*ieee
,
1033 extern const struct libipw_channel
*libipw_get_channel(struct
1036 extern u32
libipw_channel_to_freq(struct libipw_device
* ieee
,
1040 extern int libipw_wx_get_scan(struct libipw_device
*ieee
,
1041 struct iw_request_info
*info
,
1042 union iwreq_data
*wrqu
, char *key
);
1043 extern int libipw_wx_set_encode(struct libipw_device
*ieee
,
1044 struct iw_request_info
*info
,
1045 union iwreq_data
*wrqu
, char *key
);
1046 extern int libipw_wx_get_encode(struct libipw_device
*ieee
,
1047 struct iw_request_info
*info
,
1048 union iwreq_data
*wrqu
, char *key
);
1049 extern int libipw_wx_set_encodeext(struct libipw_device
*ieee
,
1050 struct iw_request_info
*info
,
1051 union iwreq_data
*wrqu
, char *extra
);
1052 extern int libipw_wx_get_encodeext(struct libipw_device
*ieee
,
1053 struct iw_request_info
*info
,
1054 union iwreq_data
*wrqu
, char *extra
);
1056 static inline void libipw_increment_scans(struct libipw_device
*ieee
)
1061 static inline int libipw_get_scans(struct libipw_device
*ieee
)
1066 #endif /* LIBIPW_H */