1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Merged with mainline ieee80211.h in Aug 2004. Original ieee802_11
4 * remains copyright by the original authors
6 * Portions of the merged code are based on Host AP (software wireless
7 * LAN access point) driver for Intersil Prism2/2.5/3.
9 * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
11 * Copyright (c) 2002-2003, Jouni Malinen <j@w1.fi>
13 * Adaption to a generic IEEE 802.11 stack by James Ketrenos
14 * <jketreno@linux.intel.com>
15 * Copyright (c) 2004-2005, Intel Corporation
18 * 1.0.x -- Initial version
19 * 1.1.x -- Added radiotap, QoS, TIM, libipw_geo APIs,
20 * various structure changes, and crypto API init method
24 #include <linux/if_ether.h> /* ETH_ALEN */
25 #include <linux/kernel.h> /* ARRAY_SIZE */
26 #include <linux/wireless.h>
27 #include <linux/ieee80211.h>
29 #include <net/lib80211.h>
30 #include <net/cfg80211.h>
32 #define LIBIPW_VERSION "git-1.1.13"
34 #define LIBIPW_DATA_LEN 2304
35 /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
38 The figure in section 7.1.2 suggests a body size of up to 2312
39 bytes is allowed, which is a bit confusing, I suspect this
40 represents the 2304 bytes of real data, plus a possible 8 bytes of
41 WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
43 #define LIBIPW_1ADDR_LEN 10
44 #define LIBIPW_2ADDR_LEN 16
45 #define LIBIPW_3ADDR_LEN 24
46 #define LIBIPW_4ADDR_LEN 30
47 #define LIBIPW_FCS_LEN 4
48 #define LIBIPW_HLEN (LIBIPW_4ADDR_LEN)
49 #define LIBIPW_FRAME_LEN (LIBIPW_DATA_LEN + LIBIPW_HLEN)
51 #define MIN_FRAG_THRESHOLD 256U
52 #define MAX_FRAG_THRESHOLD 2346U
55 #define LIBIPW_QCTL_TID 0x000F
59 #ifdef CONFIG_LIBIPW_DEBUG
60 extern u32 libipw_debug_level
;
61 #define LIBIPW_DEBUG(level, fmt, args...) \
62 do { if (libipw_debug_level & (level)) \
63 printk(KERN_DEBUG "libipw: %c %s " fmt, \
64 in_interrupt() ? 'I' : 'U', __func__ , ## args); } while (0)
66 #define LIBIPW_DEBUG(level, fmt, args...) do {} while (0)
67 #endif /* CONFIG_LIBIPW_DEBUG */
70 * To use the debug system:
72 * If you are defining a new debug classification, simply add it to the #define
73 * list here in the form of:
75 * #define LIBIPW_DL_xxxx VALUE
77 * shifting value to the left one bit from the previous entry. xxxx should be
78 * the name of the classification (for example, WEP)
80 * You then need to either add a LIBIPW_xxxx_DEBUG() macro definition for your
81 * classification, or use LIBIPW_DEBUG(LIBIPW_DL_xxxx, ...) whenever you want
82 * to send output to that classification.
84 * To add your debug level to the list of levels seen when you perform
86 * % cat /proc/net/ieee80211/debug_level
88 * you simply need to add your entry to the libipw_debug_level array.
90 * If you do not see debug_level in /proc/net/ieee80211 then you do not have
91 * CONFIG_LIBIPW_DEBUG defined in your kernel configuration
95 #define LIBIPW_DL_INFO (1<<0)
96 #define LIBIPW_DL_WX (1<<1)
97 #define LIBIPW_DL_SCAN (1<<2)
98 #define LIBIPW_DL_STATE (1<<3)
99 #define LIBIPW_DL_MGMT (1<<4)
100 #define LIBIPW_DL_FRAG (1<<5)
101 #define LIBIPW_DL_DROP (1<<7)
103 #define LIBIPW_DL_TX (1<<8)
104 #define LIBIPW_DL_RX (1<<9)
105 #define LIBIPW_DL_QOS (1<<31)
107 #define LIBIPW_ERROR(f, a...) printk(KERN_ERR "libipw: " f, ## a)
108 #define LIBIPW_WARNING(f, a...) printk(KERN_WARNING "libipw: " f, ## a)
109 #define LIBIPW_DEBUG_INFO(f, a...) LIBIPW_DEBUG(LIBIPW_DL_INFO, f, ## a)
111 #define LIBIPW_DEBUG_WX(f, a...) LIBIPW_DEBUG(LIBIPW_DL_WX, f, ## a)
112 #define LIBIPW_DEBUG_SCAN(f, a...) LIBIPW_DEBUG(LIBIPW_DL_SCAN, f, ## a)
113 #define LIBIPW_DEBUG_STATE(f, a...) LIBIPW_DEBUG(LIBIPW_DL_STATE, f, ## a)
114 #define LIBIPW_DEBUG_MGMT(f, a...) LIBIPW_DEBUG(LIBIPW_DL_MGMT, f, ## a)
115 #define LIBIPW_DEBUG_FRAG(f, a...) LIBIPW_DEBUG(LIBIPW_DL_FRAG, f, ## a)
116 #define LIBIPW_DEBUG_DROP(f, a...) LIBIPW_DEBUG(LIBIPW_DL_DROP, f, ## a)
117 #define LIBIPW_DEBUG_TX(f, a...) LIBIPW_DEBUG(LIBIPW_DL_TX, f, ## a)
118 #define LIBIPW_DEBUG_RX(f, a...) LIBIPW_DEBUG(LIBIPW_DL_RX, f, ## a)
119 #define LIBIPW_DEBUG_QOS(f, a...) LIBIPW_DEBUG(LIBIPW_DL_QOS, f, ## a)
120 #include <linux/netdevice.h>
121 #include <linux/if_arp.h> /* ARPHRD_ETHER */
124 #define WIRELESS_SPY /* enable iwspy support */
126 #include <net/iw_handler.h> /* new driver API */
128 #define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
130 #ifndef ETH_P_80211_RAW
131 #define ETH_P_80211_RAW (ETH_P_ECONET + 1)
134 /* IEEE 802.11 defines */
136 #define P80211_OUI_LEN 3
138 struct libipw_snap_hdr
{
140 u8 dsap
; /* always 0xAA */
141 u8 ssap
; /* always 0xAA */
142 u8 ctrl
; /* always 0x03 */
143 u8 oui
[P80211_OUI_LEN
]; /* organizational universal id */
147 #define SNAP_SIZE sizeof(struct libipw_snap_hdr)
149 #define WLAN_FC_GET_VERS(fc) ((fc) & IEEE80211_FCTL_VERS)
150 #define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE)
151 #define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE)
153 #define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG)
154 #define WLAN_GET_SEQ_SEQ(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
156 #define LIBIPW_STATMASK_SIGNAL (1<<0)
157 #define LIBIPW_STATMASK_RSSI (1<<1)
158 #define LIBIPW_STATMASK_NOISE (1<<2)
159 #define LIBIPW_STATMASK_RATE (1<<3)
160 #define LIBIPW_STATMASK_WEMASK 0x7
162 #define LIBIPW_CCK_MODULATION (1<<0)
163 #define LIBIPW_OFDM_MODULATION (1<<1)
165 #define LIBIPW_24GHZ_BAND (1<<0)
166 #define LIBIPW_52GHZ_BAND (1<<1)
168 #define LIBIPW_CCK_RATE_1MB 0x02
169 #define LIBIPW_CCK_RATE_2MB 0x04
170 #define LIBIPW_CCK_RATE_5MB 0x0B
171 #define LIBIPW_CCK_RATE_11MB 0x16
172 #define LIBIPW_OFDM_RATE_6MB 0x0C
173 #define LIBIPW_OFDM_RATE_9MB 0x12
174 #define LIBIPW_OFDM_RATE_12MB 0x18
175 #define LIBIPW_OFDM_RATE_18MB 0x24
176 #define LIBIPW_OFDM_RATE_24MB 0x30
177 #define LIBIPW_OFDM_RATE_36MB 0x48
178 #define LIBIPW_OFDM_RATE_48MB 0x60
179 #define LIBIPW_OFDM_RATE_54MB 0x6C
180 #define LIBIPW_BASIC_RATE_MASK 0x80
182 #define LIBIPW_CCK_RATE_1MB_MASK (1<<0)
183 #define LIBIPW_CCK_RATE_2MB_MASK (1<<1)
184 #define LIBIPW_CCK_RATE_5MB_MASK (1<<2)
185 #define LIBIPW_CCK_RATE_11MB_MASK (1<<3)
186 #define LIBIPW_OFDM_RATE_6MB_MASK (1<<4)
187 #define LIBIPW_OFDM_RATE_9MB_MASK (1<<5)
188 #define LIBIPW_OFDM_RATE_12MB_MASK (1<<6)
189 #define LIBIPW_OFDM_RATE_18MB_MASK (1<<7)
190 #define LIBIPW_OFDM_RATE_24MB_MASK (1<<8)
191 #define LIBIPW_OFDM_RATE_36MB_MASK (1<<9)
192 #define LIBIPW_OFDM_RATE_48MB_MASK (1<<10)
193 #define LIBIPW_OFDM_RATE_54MB_MASK (1<<11)
195 #define LIBIPW_CCK_RATES_MASK 0x0000000F
196 #define LIBIPW_CCK_BASIC_RATES_MASK (LIBIPW_CCK_RATE_1MB_MASK | \
197 LIBIPW_CCK_RATE_2MB_MASK)
198 #define LIBIPW_CCK_DEFAULT_RATES_MASK (LIBIPW_CCK_BASIC_RATES_MASK | \
199 LIBIPW_CCK_RATE_5MB_MASK | \
200 LIBIPW_CCK_RATE_11MB_MASK)
202 #define LIBIPW_OFDM_RATES_MASK 0x00000FF0
203 #define LIBIPW_OFDM_BASIC_RATES_MASK (LIBIPW_OFDM_RATE_6MB_MASK | \
204 LIBIPW_OFDM_RATE_12MB_MASK | \
205 LIBIPW_OFDM_RATE_24MB_MASK)
206 #define LIBIPW_OFDM_DEFAULT_RATES_MASK (LIBIPW_OFDM_BASIC_RATES_MASK | \
207 LIBIPW_OFDM_RATE_9MB_MASK | \
208 LIBIPW_OFDM_RATE_18MB_MASK | \
209 LIBIPW_OFDM_RATE_36MB_MASK | \
210 LIBIPW_OFDM_RATE_48MB_MASK | \
211 LIBIPW_OFDM_RATE_54MB_MASK)
212 #define LIBIPW_DEFAULT_RATES_MASK (LIBIPW_OFDM_DEFAULT_RATES_MASK | \
213 LIBIPW_CCK_DEFAULT_RATES_MASK)
215 #define LIBIPW_NUM_OFDM_RATES 8
216 #define LIBIPW_NUM_CCK_RATES 4
217 #define LIBIPW_OFDM_SHIFT_MASK_A 4
219 /* NOTE: This data is for statistical purposes; not all hardware provides this
220 * information for frames received.
221 * For libipw_rx_mgt, you need to set at least the 'len' parameter.
223 struct libipw_rx_stats
{
228 u16 rate
; /* in 100 kbps */
238 /* IEEE 802.11 requires that STA supports concurrent reception of at least
239 * three fragmented frames. This define can be increased to support more
240 * concurrent frames, but it should be noted that each entry can consume about
241 * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
242 #define LIBIPW_FRAG_CACHE_LEN 4
244 struct libipw_frag_entry
{
245 unsigned long first_frag_time
;
247 unsigned int last_frag
;
249 u8 src_addr
[ETH_ALEN
];
250 u8 dst_addr
[ETH_ALEN
];
253 struct libipw_stats
{
254 unsigned int tx_unicast_frames
;
255 unsigned int tx_multicast_frames
;
256 unsigned int tx_fragments
;
257 unsigned int tx_unicast_octets
;
258 unsigned int tx_multicast_octets
;
259 unsigned int tx_deferred_transmissions
;
260 unsigned int tx_single_retry_frames
;
261 unsigned int tx_multiple_retry_frames
;
262 unsigned int tx_retry_limit_exceeded
;
263 unsigned int tx_discards
;
264 unsigned int rx_unicast_frames
;
265 unsigned int rx_multicast_frames
;
266 unsigned int rx_fragments
;
267 unsigned int rx_unicast_octets
;
268 unsigned int rx_multicast_octets
;
269 unsigned int rx_fcs_errors
;
270 unsigned int rx_discards_no_buffer
;
271 unsigned int tx_discards_wrong_sa
;
272 unsigned int rx_discards_undecryptable
;
273 unsigned int rx_message_in_msg_fragments
;
274 unsigned int rx_message_in_bad_msg_fragments
;
277 struct libipw_device
;
279 #define SEC_KEY_1 (1<<0)
280 #define SEC_KEY_2 (1<<1)
281 #define SEC_KEY_3 (1<<2)
282 #define SEC_KEY_4 (1<<3)
283 #define SEC_ACTIVE_KEY (1<<4)
284 #define SEC_AUTH_MODE (1<<5)
285 #define SEC_UNICAST_GROUP (1<<6)
286 #define SEC_LEVEL (1<<7)
287 #define SEC_ENABLED (1<<8)
288 #define SEC_ENCRYPT (1<<9)
290 #define SEC_LEVEL_0 0 /* None */
291 #define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */
292 #define SEC_LEVEL_2 2 /* Level 1 + TKIP */
293 #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
294 #define SEC_LEVEL_3 4 /* Level 2 + CCMP */
296 #define SEC_ALG_NONE 0
297 #define SEC_ALG_WEP 1
298 #define SEC_ALG_TKIP 2
299 #define SEC_ALG_CCMP 3
302 #define WEP_KEY_LEN 13
303 #define SCM_KEY_LEN 32
304 #define SCM_TEMPORAL_KEY_LENGTH 16
306 struct libipw_security
{
307 u16 active_key
:2, enabled
:1, unicast_uses_group
:1, encrypt
:1;
309 u8 encode_alg
[WEP_KEYS
];
310 u8 key_sizes
[WEP_KEYS
];
311 u8 keys
[WEP_KEYS
][SCM_KEY_LEN
];
318 802.11 data frame from AP
320 ,-------------------------------------------------------------------.
321 Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
322 |------|------|---------|---------|---------|------|---------|------|
323 Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs |
324 | | tion | (BSSID) | | | ence | data | |
325 `-------------------------------------------------------------------'
331 #define BEACON_PROBE_SSID_ID_POSITION 12
333 struct libipw_hdr_1addr
{
340 struct libipw_hdr_2addr
{
348 struct libipw_hdr_3addr
{
358 struct libipw_hdr_4addr
{
369 struct libipw_hdr_3addrqos
{
380 struct libipw_info_element
{
387 * These are the data types that can make up management packets
393 u8 current_ap[ETH_ALEN];
396 u16 association_id:14, reserved:2;
404 struct libipw_hdr_3addr header
;
409 struct libipw_info_element info_element
[0];
412 struct libipw_channel_switch
{
420 struct libipw_action
{
421 struct libipw_hdr_3addr header
;
425 struct libipw_action_exchange
{
427 struct libipw_info_element info_element
[0];
429 struct libipw_channel_switch channel_switch
;
434 struct libipw_disassoc
{
435 struct libipw_hdr_3addr header
;
439 /* Alias deauth for disassoc */
440 #define libipw_deauth libipw_disassoc
442 struct libipw_probe_request
{
443 struct libipw_hdr_3addr header
;
444 /* SSID, supported rates */
445 struct libipw_info_element info_element
[0];
448 struct libipw_probe_response
{
449 struct libipw_hdr_3addr header
;
450 __le32 time_stamp
[2];
451 __le16 beacon_interval
;
453 /* SSID, supported rates, FH params, DS params,
454 * CF params, IBSS params, TIM (if beacon), RSN */
455 struct libipw_info_element info_element
[0];
458 /* Alias beacon for probe_response */
459 #define libipw_beacon libipw_probe_response
461 struct libipw_assoc_request
{
462 struct libipw_hdr_3addr header
;
464 __le16 listen_interval
;
465 /* SSID, supported rates, RSN */
466 struct libipw_info_element info_element
[0];
469 struct libipw_reassoc_request
{
470 struct libipw_hdr_3addr header
;
472 __le16 listen_interval
;
473 u8 current_ap
[ETH_ALEN
];
474 struct libipw_info_element info_element
[0];
477 struct libipw_assoc_response
{
478 struct libipw_hdr_3addr header
;
482 /* supported rates */
483 struct libipw_info_element info_element
[0];
493 struct sk_buff
*fragments
[0];
496 /* SWEEP TABLE ENTRIES NUMBER */
497 #define MAX_SWEEP_TAB_ENTRIES 42
498 #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
499 /* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs
500 * only use 8, and then use extended rates for the remaining supported
501 * rates. Other APs, however, stick all of their supported rates on the
502 * main rates information element... */
503 #define MAX_RATES_LENGTH ((u8)12)
504 #define MAX_RATES_EX_LENGTH ((u8)16)
505 #define MAX_NETWORK_COUNT 128
507 #define CRC_LENGTH 4U
509 #define MAX_WPA_IE_LEN 64
511 #define NETWORK_HAS_OFDM (1<<1)
512 #define NETWORK_HAS_CCK (1<<2)
515 #define NETWORK_HAS_QOS_PARAMETERS (1<<3)
516 #define NETWORK_HAS_QOS_INFORMATION (1<<4)
517 #define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \
518 NETWORK_HAS_QOS_INFORMATION)
521 #define NETWORK_HAS_POWER_CONSTRAINT (1<<5)
522 #define NETWORK_HAS_CSA (1<<6)
523 #define NETWORK_HAS_QUIET (1<<7)
524 #define NETWORK_HAS_IBSS_DFS (1<<8)
525 #define NETWORK_HAS_TPC_REPORT (1<<9)
527 #define NETWORK_HAS_ERP_VALUE (1<<10)
529 #define QOS_QUEUE_NUM 4
530 #define QOS_OUI_LEN 3
531 #define QOS_OUI_TYPE 2
532 #define QOS_ELEMENT_ID 221
533 #define QOS_OUI_INFO_SUB_TYPE 0
534 #define QOS_OUI_PARAM_SUB_TYPE 1
535 #define QOS_VERSION_1 1
536 #define QOS_AIFSN_MIN_VALUE 2
538 struct libipw_qos_information_element
{
548 struct libipw_qos_ac_parameter
{
554 struct libipw_qos_parameter_info
{
555 struct libipw_qos_information_element info_element
;
557 struct libipw_qos_ac_parameter ac_params_record
[QOS_QUEUE_NUM
];
560 struct libipw_qos_parameters
{
561 __le16 cw_min
[QOS_QUEUE_NUM
];
562 __le16 cw_max
[QOS_QUEUE_NUM
];
563 u8 aifs
[QOS_QUEUE_NUM
];
564 u8 flag
[QOS_QUEUE_NUM
];
565 __le16 tx_op_limit
[QOS_QUEUE_NUM
];
568 struct libipw_qos_data
{
569 struct libipw_qos_parameters parameters
;
576 struct libipw_tim_parameters
{
581 /*******************************************************/
583 struct libipw_tpc_report
{
588 struct libipw_channel_map
{
593 struct libipw_ibss_dfs
{
594 struct libipw_info_element ie
;
596 u8 recovery_interval
;
597 struct libipw_channel_map channel_map
[0];
606 struct libipw_quiet
{
613 struct libipw_network
{
614 /* These entries are used to identify a unique network */
617 /* Ensure null-terminated for any debug msgs */
618 u8 ssid
[IW_ESSID_MAX_SIZE
+ 1];
621 struct libipw_qos_data qos_data
;
623 /* These are network statistics */
624 struct libipw_rx_stats stats
;
626 u8 rates
[MAX_RATES_LENGTH
];
628 u8 rates_ex
[MAX_RATES_EX_LENGTH
];
630 unsigned long last_scanned
;
639 u8 wpa_ie
[MAX_WPA_IE_LEN
];
641 u8 rsn_ie
[MAX_WPA_IE_LEN
];
643 struct libipw_tim_parameters tim
;
647 /* Power Constraint - mandatory if spctrm mgmt required */
650 /* TPC Report - mandatory if spctrm mgmt required */
651 struct libipw_tpc_report tpc_report
;
653 /* Channel Switch Announcement - optional if spctrm mgmt required */
654 struct libipw_csa csa
;
656 /* Quiet - optional if spctrm mgmt required */
657 struct libipw_quiet quiet
;
659 struct list_head list
;
663 LIBIPW_UNINITIALIZED
= 0,
667 LIBIPW_AUTHENTICATING
,
668 LIBIPW_AUTHENTICATED
,
672 #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
673 #define DEFAULT_FTS 2346
675 #define CFG_LIBIPW_RESERVE_FCS (1<<0)
676 #define CFG_LIBIPW_COMPUTE_FCS (1<<1)
677 #define CFG_LIBIPW_RTS (1<<2)
679 #define LIBIPW_24GHZ_MIN_CHANNEL 1
680 #define LIBIPW_24GHZ_MAX_CHANNEL 14
681 #define LIBIPW_24GHZ_CHANNELS (LIBIPW_24GHZ_MAX_CHANNEL - \
682 LIBIPW_24GHZ_MIN_CHANNEL + 1)
684 #define LIBIPW_52GHZ_MIN_CHANNEL 34
685 #define LIBIPW_52GHZ_MAX_CHANNEL 165
686 #define LIBIPW_52GHZ_CHANNELS (LIBIPW_52GHZ_MAX_CHANNEL - \
687 LIBIPW_52GHZ_MIN_CHANNEL + 1)
690 LIBIPW_CH_PASSIVE_ONLY
= (1 << 0),
691 LIBIPW_CH_80211H_RULES
= (1 << 1),
692 LIBIPW_CH_B_ONLY
= (1 << 2),
693 LIBIPW_CH_NO_IBSS
= (1 << 3),
694 LIBIPW_CH_UNIFORM_SPREADING
= (1 << 4),
695 LIBIPW_CH_RADAR_DETECT
= (1 << 5),
696 LIBIPW_CH_INVALID
= (1 << 6),
699 struct libipw_channel
{
700 u32 freq
; /* in MHz */
703 u8 max_power
; /* in dBm */
710 struct libipw_channel bg
[LIBIPW_24GHZ_CHANNELS
];
711 struct libipw_channel a
[LIBIPW_52GHZ_CHANNELS
];
714 struct libipw_device
{
715 struct net_device
*dev
;
716 struct wireless_dev wdev
;
717 struct libipw_security sec
;
719 /* Bookkeeping structures */
720 struct libipw_stats ieee_stats
;
722 struct libipw_geo geo
;
723 struct ieee80211_supported_band bg_band
;
724 struct ieee80211_supported_band a_band
;
726 /* Probe / Beacon management */
727 struct list_head network_free_list
;
728 struct list_head network_list
;
729 struct libipw_network
*networks
[MAX_NETWORK_COUNT
];
733 int iw_mode
; /* operating mode (IW_MODE_*) */
734 struct iw_spy_data spy_data
; /* iwspy support */
738 int tx_headroom
; /* Set to size of any additional room needed at front
739 * of allocated Tx SKBs */
742 /* WEP and other encryption related settings at the device level */
743 int open_wep
; /* Set to 1 to allow unencrypted frames */
745 /* If the host performs {en,de}cryption, then set to 1 */
747 int host_encrypt_msdu
;
749 /* host performs multicast decryption */
752 /* host should strip IV and ICV from protected frames */
753 /* meaningful only when hardware decryption is being used */
754 int host_strip_iv_icv
;
757 int ieee802_1x
; /* is IEEE 802.1X used */
761 int drop_unencrypted
;
766 struct lib80211_crypt_info crypt_info
;
768 int bcrx_sta_key
; /* use individual keys to override default keys even
769 * with RX of broad/multicast frames */
771 /* Fragmentation structures */
772 struct libipw_frag_entry frag_cache
[LIBIPW_FRAG_CACHE_LEN
];
773 unsigned int frag_next_idx
;
774 u16 fts
; /* Fragmentation Threshold */
775 u16 rts
; /* RTS threshold */
777 /* Association info */
780 enum libipw_state state
;
782 int mode
; /* A, B, G */
783 int modulation
; /* CCK, OFDM */
784 int freq_band
; /* 2.4Ghz, 5.2Ghz, Mixed */
785 int abg_true
; /* ABG flag */
790 u16 prev_seq_ctl
; /* used to drop duplicate frames */
792 /* Callback functions */
793 void (*set_security
) (struct net_device
* dev
,
794 struct libipw_security
* sec
);
795 netdev_tx_t (*hard_start_xmit
) (struct libipw_txb
* txb
,
796 struct net_device
* dev
, int pri
);
797 int (*is_queue_full
) (struct net_device
* dev
, int pri
);
799 int (*handle_management
) (struct net_device
* dev
,
800 struct libipw_network
* network
, u16 type
);
801 int (*is_qos_active
) (struct net_device
*dev
, struct sk_buff
*skb
);
803 /* Typical STA methods */
804 int (*handle_auth
) (struct net_device
* dev
,
805 struct libipw_auth
* auth
);
806 int (*handle_deauth
) (struct net_device
* dev
,
807 struct libipw_deauth
* auth
);
808 int (*handle_action
) (struct net_device
* dev
,
809 struct libipw_action
* action
,
810 struct libipw_rx_stats
* stats
);
811 int (*handle_disassoc
) (struct net_device
* dev
,
812 struct libipw_disassoc
* assoc
);
813 int (*handle_beacon
) (struct net_device
* dev
,
814 struct libipw_beacon
* beacon
,
815 struct libipw_network
* network
);
816 int (*handle_probe_response
) (struct net_device
* dev
,
817 struct libipw_probe_response
* resp
,
818 struct libipw_network
* network
);
819 int (*handle_probe_request
) (struct net_device
* dev
,
820 struct libipw_probe_request
* req
,
821 struct libipw_rx_stats
* stats
);
822 int (*handle_assoc_response
) (struct net_device
* dev
,
823 struct libipw_assoc_response
* resp
,
824 struct libipw_network
* network
);
826 /* Typical AP methods */
827 int (*handle_assoc_request
) (struct net_device
* dev
);
828 int (*handle_reassoc_request
) (struct net_device
* dev
,
829 struct libipw_reassoc_request
* req
);
831 /* This must be the last item so that it points to the data
832 * allocated beyond this structure by alloc_libipw */
836 #define IEEE_A (1<<0)
837 #define IEEE_B (1<<1)
838 #define IEEE_G (1<<2)
839 #define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
841 static inline void *libipw_priv(struct net_device
*dev
)
843 return ((struct libipw_device
*)netdev_priv(dev
))->priv
;
846 static inline int libipw_is_valid_mode(struct libipw_device
*ieee
,
850 * It is possible for both access points and our device to support
851 * combinations of modes, so as long as there is one valid combination
852 * of ap/device supported modes, then return success
855 if ((mode
& IEEE_A
) &&
856 (ieee
->modulation
& LIBIPW_OFDM_MODULATION
) &&
857 (ieee
->freq_band
& LIBIPW_52GHZ_BAND
))
860 if ((mode
& IEEE_G
) &&
861 (ieee
->modulation
& LIBIPW_OFDM_MODULATION
) &&
862 (ieee
->freq_band
& LIBIPW_24GHZ_BAND
))
865 if ((mode
& IEEE_B
) &&
866 (ieee
->modulation
& LIBIPW_CCK_MODULATION
) &&
867 (ieee
->freq_band
& LIBIPW_24GHZ_BAND
))
873 static inline int libipw_get_hdrlen(u16 fc
)
875 int hdrlen
= LIBIPW_3ADDR_LEN
;
876 u16 stype
= WLAN_FC_GET_STYPE(fc
);
878 switch (WLAN_FC_GET_TYPE(fc
)) {
879 case IEEE80211_FTYPE_DATA
:
880 if ((fc
& IEEE80211_FCTL_FROMDS
) && (fc
& IEEE80211_FCTL_TODS
))
881 hdrlen
= LIBIPW_4ADDR_LEN
;
882 if (stype
& IEEE80211_STYPE_QOS_DATA
)
885 case IEEE80211_FTYPE_CTL
:
886 switch (WLAN_FC_GET_STYPE(fc
)) {
887 case IEEE80211_STYPE_CTS
:
888 case IEEE80211_STYPE_ACK
:
889 hdrlen
= LIBIPW_1ADDR_LEN
;
892 hdrlen
= LIBIPW_2ADDR_LEN
;
901 static inline u8
*libipw_get_payload(struct ieee80211_hdr
*hdr
)
903 switch (libipw_get_hdrlen(le16_to_cpu(hdr
->frame_control
))) {
904 case LIBIPW_1ADDR_LEN
:
905 return ((struct libipw_hdr_1addr
*)hdr
)->payload
;
906 case LIBIPW_2ADDR_LEN
:
907 return ((struct libipw_hdr_2addr
*)hdr
)->payload
;
908 case LIBIPW_3ADDR_LEN
:
909 return ((struct libipw_hdr_3addr
*)hdr
)->payload
;
910 case LIBIPW_4ADDR_LEN
:
911 return ((struct libipw_hdr_4addr
*)hdr
)->payload
;
916 static inline int libipw_is_ofdm_rate(u8 rate
)
918 switch (rate
& ~LIBIPW_BASIC_RATE_MASK
) {
919 case LIBIPW_OFDM_RATE_6MB
:
920 case LIBIPW_OFDM_RATE_9MB
:
921 case LIBIPW_OFDM_RATE_12MB
:
922 case LIBIPW_OFDM_RATE_18MB
:
923 case LIBIPW_OFDM_RATE_24MB
:
924 case LIBIPW_OFDM_RATE_36MB
:
925 case LIBIPW_OFDM_RATE_48MB
:
926 case LIBIPW_OFDM_RATE_54MB
:
932 static inline int libipw_is_cck_rate(u8 rate
)
934 switch (rate
& ~LIBIPW_BASIC_RATE_MASK
) {
935 case LIBIPW_CCK_RATE_1MB
:
936 case LIBIPW_CCK_RATE_2MB
:
937 case LIBIPW_CCK_RATE_5MB
:
938 case LIBIPW_CCK_RATE_11MB
:
945 void free_libipw(struct net_device
*dev
, int monitor
);
946 struct net_device
*alloc_libipw(int sizeof_priv
, int monitor
);
948 void libipw_networks_age(struct libipw_device
*ieee
, unsigned long age_secs
);
950 int libipw_set_encryption(struct libipw_device
*ieee
);
953 netdev_tx_t
libipw_xmit(struct sk_buff
*skb
, struct net_device
*dev
);
954 void libipw_txb_free(struct libipw_txb
*);
957 void libipw_rx_any(struct libipw_device
*ieee
, struct sk_buff
*skb
,
958 struct libipw_rx_stats
*stats
);
959 int libipw_rx(struct libipw_device
*ieee
, struct sk_buff
*skb
,
960 struct libipw_rx_stats
*rx_stats
);
961 /* make sure to set stats->len */
962 void libipw_rx_mgt(struct libipw_device
*ieee
, struct libipw_hdr_4addr
*header
,
963 struct libipw_rx_stats
*stats
);
966 const struct libipw_geo
*libipw_get_geo(struct libipw_device
*ieee
);
967 void libipw_set_geo(struct libipw_device
*ieee
, const struct libipw_geo
*geo
);
969 int libipw_is_valid_channel(struct libipw_device
*ieee
, u8 channel
);
970 int libipw_channel_to_index(struct libipw_device
*ieee
, u8 channel
);
971 u8
libipw_freq_to_channel(struct libipw_device
*ieee
, u32 freq
);
972 u8
libipw_get_channel_flags(struct libipw_device
*ieee
, u8 channel
);
973 const struct libipw_channel
*libipw_get_channel(struct libipw_device
*ieee
,
975 u32
libipw_channel_to_freq(struct libipw_device
*ieee
, u8 channel
);
978 int libipw_wx_get_scan(struct libipw_device
*ieee
, struct iw_request_info
*info
,
979 union iwreq_data
*wrqu
, char *key
);
980 int libipw_wx_set_encode(struct libipw_device
*ieee
,
981 struct iw_request_info
*info
, union iwreq_data
*wrqu
,
983 int libipw_wx_get_encode(struct libipw_device
*ieee
,
984 struct iw_request_info
*info
, union iwreq_data
*wrqu
,
986 int libipw_wx_set_encodeext(struct libipw_device
*ieee
,
987 struct iw_request_info
*info
,
988 union iwreq_data
*wrqu
, char *extra
);
989 int libipw_wx_get_encodeext(struct libipw_device
*ieee
,
990 struct iw_request_info
*info
,
991 union iwreq_data
*wrqu
, char *extra
);
993 static inline void libipw_increment_scans(struct libipw_device
*ieee
)
998 static inline int libipw_get_scans(struct libipw_device
*ieee
)
1003 #endif /* LIBIPW_H */