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>
28 #include <net/cfg80211.h>
30 #define LIBIPW_VERSION "git-1.1.13"
32 #define LIBIPW_DATA_LEN 2304
33 /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
36 The figure in section 7.1.2 suggests a body size of up to 2312
37 bytes is allowed, which is a bit confusing, I suspect this
38 represents the 2304 bytes of real data, plus a possible 8 bytes of
39 WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
41 #define LIBIPW_1ADDR_LEN 10
42 #define LIBIPW_2ADDR_LEN 16
43 #define LIBIPW_3ADDR_LEN 24
44 #define LIBIPW_4ADDR_LEN 30
45 #define LIBIPW_FCS_LEN 4
46 #define LIBIPW_HLEN (LIBIPW_4ADDR_LEN)
47 #define LIBIPW_FRAME_LEN (LIBIPW_DATA_LEN + LIBIPW_HLEN)
49 #define MIN_FRAG_THRESHOLD 256U
50 #define MAX_FRAG_THRESHOLD 2346U
53 #define LIBIPW_QCTL_TID 0x000F
57 #ifdef CONFIG_LIBIPW_DEBUG
58 extern u32 libipw_debug_level
;
59 #define LIBIPW_DEBUG(level, fmt, args...) \
60 do { if (libipw_debug_level & (level)) \
61 printk(KERN_DEBUG "libipw: %s " fmt, __func__ , ## args); } while (0)
63 #define LIBIPW_DEBUG(level, fmt, args...) do {} while (0)
64 #endif /* CONFIG_LIBIPW_DEBUG */
67 * To use the debug system:
69 * If you are defining a new debug classification, simply add it to the #define
70 * list here in the form of:
72 * #define LIBIPW_DL_xxxx VALUE
74 * shifting value to the left one bit from the previous entry. xxxx should be
75 * the name of the classification (for example, WEP)
77 * You then need to either add a LIBIPW_xxxx_DEBUG() macro definition for your
78 * classification, or use LIBIPW_DEBUG(LIBIPW_DL_xxxx, ...) whenever you want
79 * to send output to that classification.
81 * To add your debug level to the list of levels seen when you perform
83 * % cat /proc/net/ieee80211/debug_level
85 * you simply need to add your entry to the libipw_debug_level array.
87 * If you do not see debug_level in /proc/net/ieee80211 then you do not have
88 * CONFIG_LIBIPW_DEBUG defined in your kernel configuration
92 #define LIBIPW_DL_INFO (1<<0)
93 #define LIBIPW_DL_WX (1<<1)
94 #define LIBIPW_DL_SCAN (1<<2)
95 #define LIBIPW_DL_STATE (1<<3)
96 #define LIBIPW_DL_MGMT (1<<4)
97 #define LIBIPW_DL_FRAG (1<<5)
98 #define LIBIPW_DL_DROP (1<<7)
100 #define LIBIPW_DL_TX (1<<8)
101 #define LIBIPW_DL_RX (1<<9)
102 #define LIBIPW_DL_QOS (1<<31)
104 #define LIBIPW_ERROR(f, a...) printk(KERN_ERR "libipw: " f, ## a)
105 #define LIBIPW_WARNING(f, a...) printk(KERN_WARNING "libipw: " f, ## a)
106 #define LIBIPW_DEBUG_INFO(f, a...) LIBIPW_DEBUG(LIBIPW_DL_INFO, f, ## a)
108 #define LIBIPW_DEBUG_WX(f, a...) LIBIPW_DEBUG(LIBIPW_DL_WX, f, ## a)
109 #define LIBIPW_DEBUG_SCAN(f, a...) LIBIPW_DEBUG(LIBIPW_DL_SCAN, f, ## a)
110 #define LIBIPW_DEBUG_STATE(f, a...) LIBIPW_DEBUG(LIBIPW_DL_STATE, f, ## a)
111 #define LIBIPW_DEBUG_MGMT(f, a...) LIBIPW_DEBUG(LIBIPW_DL_MGMT, f, ## a)
112 #define LIBIPW_DEBUG_FRAG(f, a...) LIBIPW_DEBUG(LIBIPW_DL_FRAG, f, ## a)
113 #define LIBIPW_DEBUG_DROP(f, a...) LIBIPW_DEBUG(LIBIPW_DL_DROP, f, ## a)
114 #define LIBIPW_DEBUG_TX(f, a...) LIBIPW_DEBUG(LIBIPW_DL_TX, f, ## a)
115 #define LIBIPW_DEBUG_RX(f, a...) LIBIPW_DEBUG(LIBIPW_DL_RX, f, ## a)
116 #define LIBIPW_DEBUG_QOS(f, a...) LIBIPW_DEBUG(LIBIPW_DL_QOS, f, ## a)
117 #include <linux/netdevice.h>
118 #include <linux/if_arp.h> /* ARPHRD_ETHER */
121 #define WIRELESS_SPY /* enable iwspy support */
123 #include <net/iw_handler.h> /* new driver API */
125 #define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
127 #ifndef ETH_P_80211_RAW
128 #define ETH_P_80211_RAW (ETH_P_ECONET + 1)
131 /* IEEE 802.11 defines */
133 #define P80211_OUI_LEN 3
135 struct libipw_snap_hdr
{
137 u8 dsap
; /* always 0xAA */
138 u8 ssap
; /* always 0xAA */
139 u8 ctrl
; /* always 0x03 */
140 u8 oui
[P80211_OUI_LEN
]; /* organizational universal id */
144 #define SNAP_SIZE sizeof(struct libipw_snap_hdr)
146 #define WLAN_FC_GET_VERS(fc) ((fc) & IEEE80211_FCTL_VERS)
147 #define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE)
148 #define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE)
150 #define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG)
151 #define WLAN_GET_SEQ_SEQ(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
153 #define LIBIPW_STATMASK_SIGNAL (1<<0)
154 #define LIBIPW_STATMASK_RSSI (1<<1)
155 #define LIBIPW_STATMASK_NOISE (1<<2)
156 #define LIBIPW_STATMASK_RATE (1<<3)
157 #define LIBIPW_STATMASK_WEMASK 0x7
159 #define LIBIPW_CCK_MODULATION (1<<0)
160 #define LIBIPW_OFDM_MODULATION (1<<1)
162 #define LIBIPW_24GHZ_BAND (1<<0)
163 #define LIBIPW_52GHZ_BAND (1<<1)
165 #define LIBIPW_CCK_RATE_1MB 0x02
166 #define LIBIPW_CCK_RATE_2MB 0x04
167 #define LIBIPW_CCK_RATE_5MB 0x0B
168 #define LIBIPW_CCK_RATE_11MB 0x16
169 #define LIBIPW_OFDM_RATE_6MB 0x0C
170 #define LIBIPW_OFDM_RATE_9MB 0x12
171 #define LIBIPW_OFDM_RATE_12MB 0x18
172 #define LIBIPW_OFDM_RATE_18MB 0x24
173 #define LIBIPW_OFDM_RATE_24MB 0x30
174 #define LIBIPW_OFDM_RATE_36MB 0x48
175 #define LIBIPW_OFDM_RATE_48MB 0x60
176 #define LIBIPW_OFDM_RATE_54MB 0x6C
177 #define LIBIPW_BASIC_RATE_MASK 0x80
179 #define LIBIPW_CCK_RATE_1MB_MASK (1<<0)
180 #define LIBIPW_CCK_RATE_2MB_MASK (1<<1)
181 #define LIBIPW_CCK_RATE_5MB_MASK (1<<2)
182 #define LIBIPW_CCK_RATE_11MB_MASK (1<<3)
183 #define LIBIPW_OFDM_RATE_6MB_MASK (1<<4)
184 #define LIBIPW_OFDM_RATE_9MB_MASK (1<<5)
185 #define LIBIPW_OFDM_RATE_12MB_MASK (1<<6)
186 #define LIBIPW_OFDM_RATE_18MB_MASK (1<<7)
187 #define LIBIPW_OFDM_RATE_24MB_MASK (1<<8)
188 #define LIBIPW_OFDM_RATE_36MB_MASK (1<<9)
189 #define LIBIPW_OFDM_RATE_48MB_MASK (1<<10)
190 #define LIBIPW_OFDM_RATE_54MB_MASK (1<<11)
192 #define LIBIPW_CCK_RATES_MASK 0x0000000F
193 #define LIBIPW_CCK_BASIC_RATES_MASK (LIBIPW_CCK_RATE_1MB_MASK | \
194 LIBIPW_CCK_RATE_2MB_MASK)
195 #define LIBIPW_CCK_DEFAULT_RATES_MASK (LIBIPW_CCK_BASIC_RATES_MASK | \
196 LIBIPW_CCK_RATE_5MB_MASK | \
197 LIBIPW_CCK_RATE_11MB_MASK)
199 #define LIBIPW_OFDM_RATES_MASK 0x00000FF0
200 #define LIBIPW_OFDM_BASIC_RATES_MASK (LIBIPW_OFDM_RATE_6MB_MASK | \
201 LIBIPW_OFDM_RATE_12MB_MASK | \
202 LIBIPW_OFDM_RATE_24MB_MASK)
203 #define LIBIPW_OFDM_DEFAULT_RATES_MASK (LIBIPW_OFDM_BASIC_RATES_MASK | \
204 LIBIPW_OFDM_RATE_9MB_MASK | \
205 LIBIPW_OFDM_RATE_18MB_MASK | \
206 LIBIPW_OFDM_RATE_36MB_MASK | \
207 LIBIPW_OFDM_RATE_48MB_MASK | \
208 LIBIPW_OFDM_RATE_54MB_MASK)
209 #define LIBIPW_DEFAULT_RATES_MASK (LIBIPW_OFDM_DEFAULT_RATES_MASK | \
210 LIBIPW_CCK_DEFAULT_RATES_MASK)
212 #define LIBIPW_NUM_OFDM_RATES 8
213 #define LIBIPW_NUM_CCK_RATES 4
214 #define LIBIPW_OFDM_SHIFT_MASK_A 4
216 /* NOTE: This data is for statistical purposes; not all hardware provides this
217 * information for frames received.
218 * For libipw_rx_mgt, you need to set at least the 'len' parameter.
220 struct libipw_rx_stats
{
225 u16 rate
; /* in 100 kbps */
235 /* IEEE 802.11 requires that STA supports concurrent reception of at least
236 * three fragmented frames. This define can be increased to support more
237 * concurrent frames, but it should be noted that each entry can consume about
238 * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
239 #define LIBIPW_FRAG_CACHE_LEN 4
241 struct libipw_frag_entry
{
242 unsigned long first_frag_time
;
244 unsigned int last_frag
;
246 u8 src_addr
[ETH_ALEN
];
247 u8 dst_addr
[ETH_ALEN
];
250 struct libipw_stats
{
251 unsigned int tx_unicast_frames
;
252 unsigned int tx_multicast_frames
;
253 unsigned int tx_fragments
;
254 unsigned int tx_unicast_octets
;
255 unsigned int tx_multicast_octets
;
256 unsigned int tx_deferred_transmissions
;
257 unsigned int tx_single_retry_frames
;
258 unsigned int tx_multiple_retry_frames
;
259 unsigned int tx_retry_limit_exceeded
;
260 unsigned int tx_discards
;
261 unsigned int rx_unicast_frames
;
262 unsigned int rx_multicast_frames
;
263 unsigned int rx_fragments
;
264 unsigned int rx_unicast_octets
;
265 unsigned int rx_multicast_octets
;
266 unsigned int rx_fcs_errors
;
267 unsigned int rx_discards_no_buffer
;
268 unsigned int tx_discards_wrong_sa
;
269 unsigned int rx_discards_undecryptable
;
270 unsigned int rx_message_in_msg_fragments
;
271 unsigned int rx_message_in_bad_msg_fragments
;
274 struct libipw_device
;
276 #define SEC_KEY_1 (1<<0)
277 #define SEC_KEY_2 (1<<1)
278 #define SEC_KEY_3 (1<<2)
279 #define SEC_KEY_4 (1<<3)
280 #define SEC_ACTIVE_KEY (1<<4)
281 #define SEC_AUTH_MODE (1<<5)
282 #define SEC_UNICAST_GROUP (1<<6)
283 #define SEC_LEVEL (1<<7)
284 #define SEC_ENABLED (1<<8)
285 #define SEC_ENCRYPT (1<<9)
287 #define SEC_LEVEL_0 0 /* None */
288 #define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */
289 #define SEC_LEVEL_2 2 /* Level 1 + TKIP */
290 #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
291 #define SEC_LEVEL_3 4 /* Level 2 + CCMP */
293 #define SEC_ALG_NONE 0
294 #define SEC_ALG_WEP 1
295 #define SEC_ALG_TKIP 2
296 #define SEC_ALG_CCMP 3
299 #define WEP_KEY_LEN 13
300 #define SCM_KEY_LEN 32
301 #define SCM_TEMPORAL_KEY_LENGTH 16
303 struct libipw_security
{
304 u16 active_key
:2, enabled
:1, unicast_uses_group
:1, encrypt
:1;
306 u8 encode_alg
[WEP_KEYS
];
307 u8 key_sizes
[WEP_KEYS
];
308 u8 keys
[WEP_KEYS
][SCM_KEY_LEN
];
315 802.11 data frame from AP
317 ,-------------------------------------------------------------------.
318 Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
319 |------|------|---------|---------|---------|------|---------|------|
320 Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs |
321 | | tion | (BSSID) | | | ence | data | |
322 `-------------------------------------------------------------------'
328 #define BEACON_PROBE_SSID_ID_POSITION 12
330 struct libipw_hdr_1addr
{
337 struct libipw_hdr_2addr
{
345 struct libipw_hdr_3addr
{
346 /* New members MUST be added within the __struct_group() macro below. */
347 __struct_group(libipw_hdr_3addr_hdr
, hdr
, __packed
,
357 static_assert(offsetof(struct libipw_hdr_3addr
, payload
) == sizeof(struct libipw_hdr_3addr_hdr
),
358 "struct member likely outside of __struct_group()");
360 struct libipw_hdr_4addr
{
371 struct libipw_hdr_3addrqos
{
382 struct libipw_info_element
{
389 * These are the data types that can make up management packets
395 u8 current_ap[ETH_ALEN];
398 u16 association_id:14, reserved:2;
406 struct libipw_hdr_3addr_hdr header
;
414 struct libipw_channel_switch
{
422 struct libipw_action
{
423 struct libipw_hdr_3addr_hdr header
;
427 struct libipw_action_exchange
{
430 struct libipw_channel_switch channel_switch
;
435 struct libipw_disassoc
{
436 struct libipw_hdr_3addr_hdr header
;
440 /* Alias deauth for disassoc */
441 #define libipw_deauth libipw_disassoc
443 struct libipw_probe_request
{
444 struct libipw_hdr_3addr_hdr header
;
445 /* SSID, supported rates */
449 struct libipw_probe_response
{
450 struct libipw_hdr_3addr_hdr header
;
451 __le32 time_stamp
[2];
452 __le16 beacon_interval
;
454 /* SSID, supported rates, FH params, DS params,
455 * CF params, IBSS params, TIM (if beacon), RSN */
459 /* Alias beacon for probe_response */
460 #define libipw_beacon libipw_probe_response
462 struct libipw_reassoc_request
{
463 struct libipw_hdr_3addr_hdr header
;
465 __le16 listen_interval
;
466 u8 current_ap
[ETH_ALEN
];
470 struct libipw_assoc_response
{
471 struct libipw_hdr_3addr_hdr header
;
475 /* supported rates */
486 struct sk_buff
*fragments
[] __counted_by(nr_frags
);
489 /* SWEEP TABLE ENTRIES NUMBER */
490 #define MAX_SWEEP_TAB_ENTRIES 42
491 #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
492 /* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs
493 * only use 8, and then use extended rates for the remaining supported
494 * rates. Other APs, however, stick all of their supported rates on the
495 * main rates information element... */
496 #define MAX_RATES_LENGTH ((u8)12)
497 #define MAX_RATES_EX_LENGTH ((u8)16)
498 #define MAX_NETWORK_COUNT 128
500 #define CRC_LENGTH 4U
502 #define MAX_WPA_IE_LEN 64
504 #define NETWORK_HAS_OFDM (1<<1)
505 #define NETWORK_HAS_CCK (1<<2)
508 #define NETWORK_HAS_QOS_PARAMETERS (1<<3)
509 #define NETWORK_HAS_QOS_INFORMATION (1<<4)
510 #define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \
511 NETWORK_HAS_QOS_INFORMATION)
514 #define NETWORK_HAS_POWER_CONSTRAINT (1<<5)
515 #define NETWORK_HAS_CSA (1<<6)
516 #define NETWORK_HAS_QUIET (1<<7)
517 #define NETWORK_HAS_IBSS_DFS (1<<8)
518 #define NETWORK_HAS_TPC_REPORT (1<<9)
520 #define NETWORK_HAS_ERP_VALUE (1<<10)
522 #define QOS_QUEUE_NUM 4
523 #define QOS_OUI_LEN 3
524 #define QOS_OUI_TYPE 2
525 #define QOS_ELEMENT_ID 221
526 #define QOS_OUI_INFO_SUB_TYPE 0
527 #define QOS_OUI_PARAM_SUB_TYPE 1
528 #define QOS_VERSION_1 1
529 #define QOS_AIFSN_MIN_VALUE 2
531 struct libipw_qos_information_element
{
541 struct libipw_qos_ac_parameter
{
547 struct libipw_qos_parameter_info
{
548 struct libipw_qos_information_element info_element
;
550 struct libipw_qos_ac_parameter ac_params_record
[QOS_QUEUE_NUM
];
553 struct libipw_qos_parameters
{
554 __le16 cw_min
[QOS_QUEUE_NUM
];
555 __le16 cw_max
[QOS_QUEUE_NUM
];
556 u8 aifs
[QOS_QUEUE_NUM
];
557 u8 flag
[QOS_QUEUE_NUM
];
558 __le16 tx_op_limit
[QOS_QUEUE_NUM
];
561 struct libipw_qos_data
{
562 struct libipw_qos_parameters parameters
;
569 struct libipw_tim_parameters
{
574 /*******************************************************/
576 struct libipw_tpc_report
{
581 struct libipw_channel_map
{
592 struct libipw_quiet
{
599 struct libipw_network
{
600 /* These entries are used to identify a unique network */
603 /* Ensure null-terminated for any debug msgs */
604 u8 ssid
[IW_ESSID_MAX_SIZE
+ 1];
607 struct libipw_qos_data qos_data
;
609 /* These are network statistics */
610 struct libipw_rx_stats stats
;
612 u8 rates
[MAX_RATES_LENGTH
];
614 u8 rates_ex
[MAX_RATES_EX_LENGTH
];
616 unsigned long last_scanned
;
625 u8 wpa_ie
[MAX_WPA_IE_LEN
];
627 u8 rsn_ie
[MAX_WPA_IE_LEN
];
629 struct libipw_tim_parameters tim
;
633 /* Power Constraint - mandatory if spctrm mgmt required */
636 /* TPC Report - mandatory if spctrm mgmt required */
637 struct libipw_tpc_report tpc_report
;
639 /* Channel Switch Announcement - optional if spctrm mgmt required */
640 struct libipw_csa csa
;
642 /* Quiet - optional if spctrm mgmt required */
643 struct libipw_quiet quiet
;
645 struct list_head list
;
649 LIBIPW_UNINITIALIZED
= 0,
653 LIBIPW_AUTHENTICATING
,
654 LIBIPW_AUTHENTICATED
,
658 #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
659 #define DEFAULT_FTS 2346
661 #define CFG_LIBIPW_RESERVE_FCS (1<<0)
662 #define CFG_LIBIPW_COMPUTE_FCS (1<<1)
663 #define CFG_LIBIPW_RTS (1<<2)
665 #define LIBIPW_24GHZ_MIN_CHANNEL 1
666 #define LIBIPW_24GHZ_MAX_CHANNEL 14
667 #define LIBIPW_24GHZ_CHANNELS (LIBIPW_24GHZ_MAX_CHANNEL - \
668 LIBIPW_24GHZ_MIN_CHANNEL + 1)
670 #define LIBIPW_52GHZ_MIN_CHANNEL 34
671 #define LIBIPW_52GHZ_MAX_CHANNEL 165
672 #define LIBIPW_52GHZ_CHANNELS (LIBIPW_52GHZ_MAX_CHANNEL - \
673 LIBIPW_52GHZ_MIN_CHANNEL + 1)
676 LIBIPW_CH_PASSIVE_ONLY
= (1 << 0),
677 LIBIPW_CH_80211H_RULES
= (1 << 1),
678 LIBIPW_CH_B_ONLY
= (1 << 2),
679 LIBIPW_CH_NO_IBSS
= (1 << 3),
680 LIBIPW_CH_UNIFORM_SPREADING
= (1 << 4),
681 LIBIPW_CH_RADAR_DETECT
= (1 << 5),
682 LIBIPW_CH_INVALID
= (1 << 6),
685 struct libipw_channel
{
686 u32 freq
; /* in MHz */
689 u8 max_power
; /* in dBm */
696 struct libipw_channel bg
[LIBIPW_24GHZ_CHANNELS
];
697 struct libipw_channel a
[LIBIPW_52GHZ_CHANNELS
];
700 #define NUM_WEP_KEYS 4
703 IEEE80211_CRYPTO_TKIP_COUNTERMEASURES
= (1 << 0),
708 struct libipw_crypto_ops
{
710 struct list_head list
;
712 /* init new crypto context (e.g., allocate private data space,
713 * select IV, etc.); returns NULL on failure or pointer to allocated
714 * private data on success */
715 void *(*init
) (int keyidx
);
717 /* deinitialize crypto context and free allocated private data */
718 void (*deinit
) (void *priv
);
720 /* encrypt/decrypt return < 0 on error or >= 0 on success. The return
721 * value from decrypt_mpdu is passed as the keyidx value for
722 * decrypt_msdu. skb must have enough head and tail room for the
723 * encryption; if not, error will be returned; these functions are
724 * called for all MPDUs (i.e., fragments).
726 int (*encrypt_mpdu
) (struct sk_buff
* skb
, int hdr_len
, void *priv
);
727 int (*decrypt_mpdu
) (struct sk_buff
* skb
, int hdr_len
, void *priv
);
729 /* These functions are called for full MSDUs, i.e. full frames.
730 * These can be NULL if full MSDU operations are not needed. */
731 int (*encrypt_msdu
) (struct sk_buff
* skb
, int hdr_len
, void *priv
);
732 int (*decrypt_msdu
) (struct sk_buff
* skb
, int keyidx
, int hdr_len
,
735 int (*set_key
) (void *key
, int len
, u8
* seq
, void *priv
);
736 int (*get_key
) (void *key
, int len
, u8
* seq
, void *priv
);
738 /* procfs handler for printing out key information and possible
740 void (*print_stats
) (struct seq_file
*m
, void *priv
);
742 /* Crypto specific flag get/set for configuration settings */
743 unsigned long (*get_flags
) (void *priv
);
744 unsigned long (*set_flags
) (unsigned long flags
, void *priv
);
746 /* maximum number of bytes added by encryption; encrypt buf is
747 * allocated with extra_prefix_len bytes, copy of in_buf, and
748 * extra_postfix_len; encrypt need not use all this space, but
749 * the result must start at the beginning of the buffer and correct
750 * length must be returned */
751 int extra_mpdu_prefix_len
, extra_mpdu_postfix_len
;
752 int extra_msdu_prefix_len
, extra_msdu_postfix_len
;
754 struct module
*owner
;
757 struct libipw_crypt_info
{
759 /* Most clients will already have a lock,
760 so just point to that. */
763 struct libipw_crypt_data
*crypt
[NUM_WEP_KEYS
];
764 int tx_keyidx
; /* default TX key index (crypt[tx_keyidx]) */
765 struct list_head crypt_deinit_list
;
766 struct timer_list crypt_deinit_timer
;
770 struct libipw_device
{
771 struct net_device
*dev
;
772 struct wireless_dev wdev
;
773 struct libipw_security sec
;
775 /* Bookkeeping structures */
776 struct libipw_stats ieee_stats
;
778 struct libipw_geo geo
;
779 struct ieee80211_supported_band bg_band
;
780 struct ieee80211_supported_band a_band
;
782 /* Probe / Beacon management */
783 struct list_head network_free_list
;
784 struct list_head network_list
;
785 struct libipw_network
*networks
[MAX_NETWORK_COUNT
];
789 int iw_mode
; /* operating mode (IW_MODE_*) */
790 struct iw_spy_data spy_data
; /* iwspy support */
795 int tx_headroom
; /* Set to size of any additional room needed at front
796 * of allocated Tx SKBs */
799 /* WEP and other encryption related settings at the device level */
800 int open_wep
; /* Set to 1 to allow unencrypted frames */
802 /* If the host performs {en,de}cryption, then set to 1 */
804 int host_encrypt_msdu
;
806 /* host performs multicast decryption */
809 /* host should strip IV and ICV from protected frames */
810 /* meaningful only when hardware decryption is being used */
811 int host_strip_iv_icv
;
814 int ieee802_1x
; /* is IEEE 802.1X used */
818 int drop_unencrypted
;
823 struct libipw_crypt_info crypt_info
;
825 int bcrx_sta_key
; /* use individual keys to override default keys even
826 * with RX of broad/multicast frames */
828 /* Fragmentation structures */
829 struct libipw_frag_entry frag_cache
[LIBIPW_FRAG_CACHE_LEN
];
830 unsigned int frag_next_idx
;
831 u16 fts
; /* Fragmentation Threshold */
832 u16 rts
; /* RTS threshold */
834 /* Association info */
837 enum libipw_state state
;
839 int mode
; /* A, B, G */
840 int modulation
; /* CCK, OFDM */
841 int freq_band
; /* 2.4Ghz, 5.2Ghz, Mixed */
842 int abg_true
; /* ABG flag */
847 u16 prev_seq_ctl
; /* used to drop duplicate frames */
849 /* Callback functions */
850 void (*set_security
) (struct net_device
* dev
,
851 struct libipw_security
* sec
);
852 netdev_tx_t (*hard_start_xmit
) (struct libipw_txb
* txb
,
853 struct net_device
* dev
, int pri
);
854 int (*is_queue_full
) (struct net_device
* dev
, int pri
);
856 int (*handle_management
) (struct net_device
* dev
,
857 struct libipw_network
* network
, u16 type
);
858 int (*is_qos_active
) (struct net_device
*dev
, struct sk_buff
*skb
);
860 /* Typical STA methods */
861 int (*handle_auth
) (struct net_device
* dev
,
862 struct libipw_auth
* auth
);
863 int (*handle_deauth
) (struct net_device
* dev
,
864 struct libipw_deauth
* auth
);
865 int (*handle_action
) (struct net_device
* dev
,
866 struct libipw_action
* action
,
867 struct libipw_rx_stats
* stats
);
868 int (*handle_disassoc
) (struct net_device
* dev
,
869 struct libipw_disassoc
* assoc
);
870 int (*handle_beacon
) (struct net_device
* dev
,
871 struct libipw_beacon
* beacon
,
872 struct libipw_network
* network
);
873 int (*handle_probe_response
) (struct net_device
* dev
,
874 struct libipw_probe_response
* resp
,
875 struct libipw_network
* network
);
876 int (*handle_probe_request
) (struct net_device
* dev
,
877 struct libipw_probe_request
* req
,
878 struct libipw_rx_stats
* stats
);
879 int (*handle_assoc_response
) (struct net_device
* dev
,
880 struct libipw_assoc_response
* resp
,
881 struct libipw_network
* network
);
883 /* Typical AP methods */
884 int (*handle_assoc_request
) (struct net_device
* dev
);
885 int (*handle_reassoc_request
) (struct net_device
* dev
,
886 struct libipw_reassoc_request
* req
);
888 /* This must be the last item so that it points to the data
889 * allocated beyond this structure by alloc_libipw */
893 #define IEEE_A (1<<0)
894 #define IEEE_B (1<<1)
895 #define IEEE_G (1<<2)
896 #define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
898 static inline void *libipw_priv(struct net_device
*dev
)
900 return ((struct libipw_device
*)netdev_priv(dev
))->priv
;
903 static inline int libipw_is_valid_mode(struct libipw_device
*ieee
,
907 * It is possible for both access points and our device to support
908 * combinations of modes, so as long as there is one valid combination
909 * of ap/device supported modes, then return success
912 if ((mode
& IEEE_A
) &&
913 (ieee
->modulation
& LIBIPW_OFDM_MODULATION
) &&
914 (ieee
->freq_band
& LIBIPW_52GHZ_BAND
))
917 if ((mode
& IEEE_G
) &&
918 (ieee
->modulation
& LIBIPW_OFDM_MODULATION
) &&
919 (ieee
->freq_band
& LIBIPW_24GHZ_BAND
))
922 if ((mode
& IEEE_B
) &&
923 (ieee
->modulation
& LIBIPW_CCK_MODULATION
) &&
924 (ieee
->freq_band
& LIBIPW_24GHZ_BAND
))
930 static inline int libipw_get_hdrlen(u16 fc
)
932 int hdrlen
= LIBIPW_3ADDR_LEN
;
933 u16 stype
= WLAN_FC_GET_STYPE(fc
);
935 switch (WLAN_FC_GET_TYPE(fc
)) {
936 case IEEE80211_FTYPE_DATA
:
937 if ((fc
& IEEE80211_FCTL_FROMDS
) && (fc
& IEEE80211_FCTL_TODS
))
938 hdrlen
= LIBIPW_4ADDR_LEN
;
939 if (stype
& IEEE80211_STYPE_QOS_DATA
)
942 case IEEE80211_FTYPE_CTL
:
943 switch (WLAN_FC_GET_STYPE(fc
)) {
944 case IEEE80211_STYPE_CTS
:
945 case IEEE80211_STYPE_ACK
:
946 hdrlen
= LIBIPW_1ADDR_LEN
;
949 hdrlen
= LIBIPW_2ADDR_LEN
;
958 static inline u8
*libipw_get_payload(struct ieee80211_hdr
*hdr
)
960 switch (libipw_get_hdrlen(le16_to_cpu(hdr
->frame_control
))) {
961 case LIBIPW_1ADDR_LEN
:
962 return ((struct libipw_hdr_1addr
*)hdr
)->payload
;
963 case LIBIPW_2ADDR_LEN
:
964 return ((struct libipw_hdr_2addr
*)hdr
)->payload
;
965 case LIBIPW_3ADDR_LEN
:
966 return ((struct libipw_hdr_3addr
*)hdr
)->payload
;
967 case LIBIPW_4ADDR_LEN
:
968 return ((struct libipw_hdr_4addr
*)hdr
)->payload
;
973 static inline int libipw_is_ofdm_rate(u8 rate
)
975 switch (rate
& ~LIBIPW_BASIC_RATE_MASK
) {
976 case LIBIPW_OFDM_RATE_6MB
:
977 case LIBIPW_OFDM_RATE_9MB
:
978 case LIBIPW_OFDM_RATE_12MB
:
979 case LIBIPW_OFDM_RATE_18MB
:
980 case LIBIPW_OFDM_RATE_24MB
:
981 case LIBIPW_OFDM_RATE_36MB
:
982 case LIBIPW_OFDM_RATE_48MB
:
983 case LIBIPW_OFDM_RATE_54MB
:
989 static inline int libipw_is_cck_rate(u8 rate
)
991 switch (rate
& ~LIBIPW_BASIC_RATE_MASK
) {
992 case LIBIPW_CCK_RATE_1MB
:
993 case LIBIPW_CCK_RATE_2MB
:
994 case LIBIPW_CCK_RATE_5MB
:
995 case LIBIPW_CCK_RATE_11MB
:
1002 void free_libipw(struct net_device
*dev
, int monitor
);
1003 struct net_device
*alloc_libipw(int sizeof_priv
, int monitor
);
1005 void libipw_networks_age(struct libipw_device
*ieee
, unsigned long age_secs
);
1007 int libipw_set_encryption(struct libipw_device
*ieee
);
1010 netdev_tx_t
libipw_xmit(struct sk_buff
*skb
, struct net_device
*dev
);
1011 void libipw_txb_free(struct libipw_txb
*);
1014 void libipw_rx_any(struct libipw_device
*ieee
, struct sk_buff
*skb
,
1015 struct libipw_rx_stats
*stats
);
1016 int libipw_rx(struct libipw_device
*ieee
, struct sk_buff
*skb
,
1017 struct libipw_rx_stats
*rx_stats
);
1018 /* make sure to set stats->len */
1019 void libipw_rx_mgt(struct libipw_device
*ieee
, struct libipw_hdr_4addr
*header
,
1020 struct libipw_rx_stats
*stats
);
1023 const struct libipw_geo
*libipw_get_geo(struct libipw_device
*ieee
);
1024 void libipw_set_geo(struct libipw_device
*ieee
, const struct libipw_geo
*geo
);
1026 int libipw_is_valid_channel(struct libipw_device
*ieee
, u8 channel
);
1027 int libipw_channel_to_index(struct libipw_device
*ieee
, u8 channel
);
1028 u8
libipw_freq_to_channel(struct libipw_device
*ieee
, u32 freq
);
1029 u8
libipw_get_channel_flags(struct libipw_device
*ieee
, u8 channel
);
1030 const struct libipw_channel
*libipw_get_channel(struct libipw_device
*ieee
,
1032 u32
libipw_channel_to_freq(struct libipw_device
*ieee
, u8 channel
);
1035 int libipw_wx_get_scan(struct libipw_device
*ieee
, struct iw_request_info
*info
,
1036 union iwreq_data
*wrqu
, char *key
);
1037 int libipw_wx_set_encode(struct libipw_device
*ieee
,
1038 struct iw_request_info
*info
, union iwreq_data
*wrqu
,
1040 int libipw_wx_get_encode(struct libipw_device
*ieee
,
1041 struct iw_request_info
*info
, union iwreq_data
*wrqu
,
1043 int libipw_wx_set_encodeext(struct libipw_device
*ieee
,
1044 struct iw_request_info
*info
,
1045 union iwreq_data
*wrqu
, char *extra
);
1046 int libipw_wx_get_encodeext(struct libipw_device
*ieee
,
1047 struct iw_request_info
*info
,
1048 union iwreq_data
*wrqu
, char *extra
);
1050 static inline void libipw_increment_scans(struct libipw_device
*ieee
)
1055 static inline int libipw_get_scans(struct libipw_device
*ieee
)
1060 struct libipw_crypt_data
{
1061 struct list_head list
; /* delayed deletion list */
1062 const struct libipw_crypto_ops
*ops
;
1067 int libipw_crypt_info_init(struct libipw_crypt_info
*info
, char *name
,
1069 void libipw_crypt_info_free(struct libipw_crypt_info
*info
);
1070 int libipw_register_crypto_ops(const struct libipw_crypto_ops
*ops
);
1071 int libipw_unregister_crypto_ops(const struct libipw_crypto_ops
*ops
);
1072 const struct libipw_crypto_ops
*libipw_get_crypto_ops(const char *name
);
1073 void libipw_crypt_delayed_deinit(struct libipw_crypt_info
*info
,
1074 struct libipw_crypt_data
**crypt
);
1076 /* must be called in the listed order */
1077 int libipw_crypto_init(void);
1078 int libipw_crypto_ccmp_init(void);
1079 int libipw_crypto_tkip_init(void);
1080 int libipw_crypto_wep_init(void);
1082 void libipw_crypto_wep_exit(void);
1083 void libipw_crypto_tkip_exit(void);
1084 void libipw_crypto_ccmp_exit(void);
1085 void libipw_crypto_exit(void);
1088 int ipw_wx_set_spy(struct net_device
*dev
, struct iw_request_info
*info
,
1089 union iwreq_data
*wrqu
, char *extra
);
1090 int ipw_wx_get_spy(struct net_device
*dev
, struct iw_request_info
*info
,
1091 union iwreq_data
*wrqu
, char *extra
);
1092 int ipw_wx_set_thrspy(struct net_device
*dev
, struct iw_request_info
*info
,
1093 union iwreq_data
*wrqu
, char *extra
);
1094 int ipw_wx_get_thrspy(struct net_device
*dev
, struct iw_request_info
*info
,
1095 union iwreq_data
*wrqu
, char *extra
);
1096 void libipw_spy_update(struct net_device
*dev
, unsigned char *address
,
1097 struct iw_quality
*wstats
);
1099 #endif /* LIBIPW_H */