Commit | Line | Data |
---|---|---|
b453872c JG |
1 | /* |
2 | * Merged with mainline ieee80211.h in Aug 2004. Original ieee802_11 | |
3 | * remains copyright by the original authors | |
4 | * | |
5 | * Portions of the merged code are based on Host AP (software wireless | |
6 | * LAN access point) driver for Intersil Prism2/2.5/3. | |
7 | * | |
8 | * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen | |
85d32e7b JM |
9 | * <j@w1.fi> |
10 | * Copyright (c) 2002-2003, Jouni Malinen <j@w1.fi> | |
b453872c JG |
11 | * |
12 | * Adaption to a generic IEEE 802.11 stack by James Ketrenos | |
13 | * <jketreno@linux.intel.com> | |
ebeaddcc | 14 | * Copyright (c) 2004-2005, Intel Corporation |
b453872c JG |
15 | * |
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 | |
19 | * more details. | |
31696160 JK |
20 | * |
21 | * API Version History | |
22 | * 1.0.x -- Initial version | |
b0a4e7d8 | 23 | * 1.1.x -- Added radiotap, QoS, TIM, libipw_geo APIs, |
31696160 | 24 | * various structure changes, and crypto API init method |
b453872c | 25 | */ |
b0a4e7d8 JL |
26 | #ifndef LIBIPW_H |
27 | #define LIBIPW_H | |
74079fdc JK |
28 | #include <linux/if_ether.h> /* ETH_ALEN */ |
29 | #include <linux/kernel.h> /* ARRAY_SIZE */ | |
b7721ff9 | 30 | #include <linux/wireless.h> |
72118015 | 31 | #include <linux/ieee80211.h> |
b453872c | 32 | |
274bfb8d | 33 | #include <net/lib80211.h> |
a3caa99e | 34 | #include <net/cfg80211.h> |
274bfb8d | 35 | |
b0a4e7d8 | 36 | #define LIBIPW_VERSION "git-1.1.13" |
31696160 | 37 | |
b0a4e7d8 | 38 | #define LIBIPW_DATA_LEN 2304 |
b453872c JG |
39 | /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section |
40 | 6.2.1.1.2. | |
41 | ||
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) */ | |
46 | ||
b0a4e7d8 JL |
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) | |
b453872c JG |
54 | |
55 | #define MIN_FRAG_THRESHOLD 256U | |
56 | #define MAX_FRAG_THRESHOLD 2346U | |
57 | ||
ea284152 | 58 | /* QOS control */ |
b0a4e7d8 | 59 | #define LIBIPW_QCTL_TID 0x000F |
ea284152 | 60 | |
b453872c JG |
61 | /* debug macros */ |
62 | ||
3756162b | 63 | #ifdef CONFIG_LIBIPW_DEBUG |
b0a4e7d8 JL |
64 | extern u32 libipw_debug_level; |
65 | #define LIBIPW_DEBUG(level, fmt, args...) \ | |
66 | do { if (libipw_debug_level & (level)) \ | |
27ae60f8 | 67 | printk(KERN_DEBUG "libipw: %c %s " fmt, \ |
d5c003b4 | 68 | in_interrupt() ? 'I' : 'U', __func__ , ## args); } while (0) |
b453872c | 69 | #else |
b0a4e7d8 | 70 | #define LIBIPW_DEBUG(level, fmt, args...) do {} while (0) |
3756162b | 71 | #endif /* CONFIG_LIBIPW_DEBUG */ |
e88187ee | 72 | |
b453872c | 73 | /* |
e88187ee | 74 | * To use the debug system: |
b453872c JG |
75 | * |
76 | * If you are defining a new debug classification, simply add it to the #define | |
77 | * list here in the form of: | |
78 | * | |
b0a4e7d8 | 79 | * #define LIBIPW_DL_xxxx VALUE |
b453872c JG |
80 | * |
81 | * shifting value to the left one bit from the previous entry. xxxx should be | |
82 | * the name of the classification (for example, WEP) | |
83 | * | |
b0a4e7d8 JL |
84 | * You then need to either add a LIBIPW_xxxx_DEBUG() macro definition for your |
85 | * classification, or use LIBIPW_DEBUG(LIBIPW_DL_xxxx, ...) whenever you want | |
b453872c JG |
86 | * to send output to that classification. |
87 | * | |
88 | * To add your debug level to the list of levels seen when you perform | |
89 | * | |
91cb70c1 | 90 | * % cat /proc/net/ieee80211/debug_level |
b453872c | 91 | * |
b0a4e7d8 | 92 | * you simply need to add your entry to the libipw_debug_level array. |
b453872c | 93 | * |
91cb70c1 | 94 | * If you do not see debug_level in /proc/net/ieee80211 then you do not have |
3756162b | 95 | * CONFIG_LIBIPW_DEBUG defined in your kernel configuration |
b453872c JG |
96 | * |
97 | */ | |
98 | ||
b0a4e7d8 JL |
99 | #define LIBIPW_DL_INFO (1<<0) |
100 | #define LIBIPW_DL_WX (1<<1) | |
101 | #define LIBIPW_DL_SCAN (1<<2) | |
102 | #define LIBIPW_DL_STATE (1<<3) | |
103 | #define LIBIPW_DL_MGMT (1<<4) | |
104 | #define LIBIPW_DL_FRAG (1<<5) | |
105 | #define LIBIPW_DL_DROP (1<<7) | |
106 | ||
107 | #define LIBIPW_DL_TX (1<<8) | |
108 | #define LIBIPW_DL_RX (1<<9) | |
109 | #define LIBIPW_DL_QOS (1<<31) | |
110 | ||
27ae60f8 PR |
111 | #define LIBIPW_ERROR(f, a...) printk(KERN_ERR "libipw: " f, ## a) |
112 | #define LIBIPW_WARNING(f, a...) printk(KERN_WARNING "libipw: " f, ## a) | |
b0a4e7d8 JL |
113 | #define LIBIPW_DEBUG_INFO(f, a...) LIBIPW_DEBUG(LIBIPW_DL_INFO, f, ## a) |
114 | ||
115 | #define LIBIPW_DEBUG_WX(f, a...) LIBIPW_DEBUG(LIBIPW_DL_WX, f, ## a) | |
116 | #define LIBIPW_DEBUG_SCAN(f, a...) LIBIPW_DEBUG(LIBIPW_DL_SCAN, f, ## a) | |
117 | #define LIBIPW_DEBUG_STATE(f, a...) LIBIPW_DEBUG(LIBIPW_DL_STATE, f, ## a) | |
118 | #define LIBIPW_DEBUG_MGMT(f, a...) LIBIPW_DEBUG(LIBIPW_DL_MGMT, f, ## a) | |
119 | #define LIBIPW_DEBUG_FRAG(f, a...) LIBIPW_DEBUG(LIBIPW_DL_FRAG, f, ## a) | |
120 | #define LIBIPW_DEBUG_DROP(f, a...) LIBIPW_DEBUG(LIBIPW_DL_DROP, f, ## a) | |
121 | #define LIBIPW_DEBUG_TX(f, a...) LIBIPW_DEBUG(LIBIPW_DL_TX, f, ## a) | |
122 | #define LIBIPW_DEBUG_RX(f, a...) LIBIPW_DEBUG(LIBIPW_DL_RX, f, ## a) | |
123 | #define LIBIPW_DEBUG_QOS(f, a...) LIBIPW_DEBUG(LIBIPW_DL_QOS, f, ## a) | |
b453872c | 124 | #include <linux/netdevice.h> |
74079fdc | 125 | #include <linux/if_arp.h> /* ARPHRD_ETHER */ |
b453872c JG |
126 | |
127 | #ifndef WIRELESS_SPY | |
099c5bb1 | 128 | #define WIRELESS_SPY /* enable iwspy support */ |
b453872c | 129 | #endif |
099c5bb1 | 130 | #include <net/iw_handler.h> /* new driver API */ |
b453872c | 131 | |
74079fdc | 132 | #define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */ |
b453872c JG |
133 | |
134 | #ifndef ETH_P_80211_RAW | |
135 | #define ETH_P_80211_RAW (ETH_P_ECONET + 1) | |
136 | #endif | |
137 | ||
138 | /* IEEE 802.11 defines */ | |
139 | ||
140 | #define P80211_OUI_LEN 3 | |
141 | ||
b0a4e7d8 | 142 | struct libipw_snap_hdr { |
b453872c | 143 | |
74079fdc JK |
144 | u8 dsap; /* always 0xAA */ |
145 | u8 ssap; /* always 0xAA */ | |
146 | u8 ctrl; /* always 0x03 */ | |
147 | u8 oui[P80211_OUI_LEN]; /* organizational universal id */ | |
b453872c | 148 | |
ba2d3587 | 149 | } __packed; |
b453872c | 150 | |
b0a4e7d8 | 151 | #define SNAP_SIZE sizeof(struct libipw_snap_hdr) |
b453872c | 152 | |
f13baae4 | 153 | #define WLAN_FC_GET_VERS(fc) ((fc) & IEEE80211_FCTL_VERS) |
b453872c JG |
154 | #define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE) |
155 | #define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE) | |
156 | ||
157 | #define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG) | |
3eb54605 | 158 | #define WLAN_GET_SEQ_SEQ(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4) |
b453872c | 159 | |
b0a4e7d8 JL |
160 | #define LIBIPW_STATMASK_SIGNAL (1<<0) |
161 | #define LIBIPW_STATMASK_RSSI (1<<1) | |
162 | #define LIBIPW_STATMASK_NOISE (1<<2) | |
163 | #define LIBIPW_STATMASK_RATE (1<<3) | |
164 | #define LIBIPW_STATMASK_WEMASK 0x7 | |
165 | ||
166 | #define LIBIPW_CCK_MODULATION (1<<0) | |
167 | #define LIBIPW_OFDM_MODULATION (1<<1) | |
168 | ||
169 | #define LIBIPW_24GHZ_BAND (1<<0) | |
170 | #define LIBIPW_52GHZ_BAND (1<<1) | |
171 | ||
172 | #define LIBIPW_CCK_RATE_1MB 0x02 | |
173 | #define LIBIPW_CCK_RATE_2MB 0x04 | |
174 | #define LIBIPW_CCK_RATE_5MB 0x0B | |
175 | #define LIBIPW_CCK_RATE_11MB 0x16 | |
176 | #define LIBIPW_OFDM_RATE_6MB 0x0C | |
177 | #define LIBIPW_OFDM_RATE_9MB 0x12 | |
178 | #define LIBIPW_OFDM_RATE_12MB 0x18 | |
179 | #define LIBIPW_OFDM_RATE_18MB 0x24 | |
180 | #define LIBIPW_OFDM_RATE_24MB 0x30 | |
181 | #define LIBIPW_OFDM_RATE_36MB 0x48 | |
182 | #define LIBIPW_OFDM_RATE_48MB 0x60 | |
183 | #define LIBIPW_OFDM_RATE_54MB 0x6C | |
184 | #define LIBIPW_BASIC_RATE_MASK 0x80 | |
185 | ||
186 | #define LIBIPW_CCK_RATE_1MB_MASK (1<<0) | |
187 | #define LIBIPW_CCK_RATE_2MB_MASK (1<<1) | |
188 | #define LIBIPW_CCK_RATE_5MB_MASK (1<<2) | |
189 | #define LIBIPW_CCK_RATE_11MB_MASK (1<<3) | |
190 | #define LIBIPW_OFDM_RATE_6MB_MASK (1<<4) | |
191 | #define LIBIPW_OFDM_RATE_9MB_MASK (1<<5) | |
192 | #define LIBIPW_OFDM_RATE_12MB_MASK (1<<6) | |
193 | #define LIBIPW_OFDM_RATE_18MB_MASK (1<<7) | |
194 | #define LIBIPW_OFDM_RATE_24MB_MASK (1<<8) | |
195 | #define LIBIPW_OFDM_RATE_36MB_MASK (1<<9) | |
196 | #define LIBIPW_OFDM_RATE_48MB_MASK (1<<10) | |
197 | #define LIBIPW_OFDM_RATE_54MB_MASK (1<<11) | |
198 | ||
199 | #define LIBIPW_CCK_RATES_MASK 0x0000000F | |
200 | #define LIBIPW_CCK_BASIC_RATES_MASK (LIBIPW_CCK_RATE_1MB_MASK | \ | |
201 | LIBIPW_CCK_RATE_2MB_MASK) | |
202 | #define LIBIPW_CCK_DEFAULT_RATES_MASK (LIBIPW_CCK_BASIC_RATES_MASK | \ | |
203 | LIBIPW_CCK_RATE_5MB_MASK | \ | |
204 | LIBIPW_CCK_RATE_11MB_MASK) | |
205 | ||
206 | #define LIBIPW_OFDM_RATES_MASK 0x00000FF0 | |
207 | #define LIBIPW_OFDM_BASIC_RATES_MASK (LIBIPW_OFDM_RATE_6MB_MASK | \ | |
208 | LIBIPW_OFDM_RATE_12MB_MASK | \ | |
209 | LIBIPW_OFDM_RATE_24MB_MASK) | |
210 | #define LIBIPW_OFDM_DEFAULT_RATES_MASK (LIBIPW_OFDM_BASIC_RATES_MASK | \ | |
211 | LIBIPW_OFDM_RATE_9MB_MASK | \ | |
212 | LIBIPW_OFDM_RATE_18MB_MASK | \ | |
213 | LIBIPW_OFDM_RATE_36MB_MASK | \ | |
214 | LIBIPW_OFDM_RATE_48MB_MASK | \ | |
215 | LIBIPW_OFDM_RATE_54MB_MASK) | |
216 | #define LIBIPW_DEFAULT_RATES_MASK (LIBIPW_OFDM_DEFAULT_RATES_MASK | \ | |
217 | LIBIPW_CCK_DEFAULT_RATES_MASK) | |
218 | ||
219 | #define LIBIPW_NUM_OFDM_RATES 8 | |
220 | #define LIBIPW_NUM_CCK_RATES 4 | |
221 | #define LIBIPW_OFDM_SHIFT_MASK_A 4 | |
b453872c | 222 | |
b453872c | 223 | /* NOTE: This data is for statistical purposes; not all hardware provides this |
c9fa7d5d | 224 | * information for frames received. |
b0a4e7d8 | 225 | * For libipw_rx_mgt, you need to set at least the 'len' parameter. |
c9fa7d5d | 226 | */ |
b0a4e7d8 | 227 | struct libipw_rx_stats { |
b453872c JG |
228 | u32 mac_time; |
229 | s8 rssi; | |
230 | u8 signal; | |
231 | u8 noise; | |
74079fdc | 232 | u16 rate; /* in 100 kbps */ |
b453872c JG |
233 | u8 received_channel; |
234 | u8 control; | |
235 | u8 mask; | |
236 | u8 freq; | |
237 | u16 len; | |
b79e20b6 ZY |
238 | u64 tsf; |
239 | u32 beacon_time; | |
b453872c JG |
240 | }; |
241 | ||
242 | /* IEEE 802.11 requires that STA supports concurrent reception of at least | |
243 | * three fragmented frames. This define can be increased to support more | |
244 | * concurrent frames, but it should be noted that each entry can consume about | |
245 | * 2 kB of RAM and increasing cache size will slow down frame reassembly. */ | |
b0a4e7d8 | 246 | #define LIBIPW_FRAG_CACHE_LEN 4 |
b453872c | 247 | |
b0a4e7d8 | 248 | struct libipw_frag_entry { |
b453872c JG |
249 | unsigned long first_frag_time; |
250 | unsigned int seq; | |
251 | unsigned int last_frag; | |
252 | struct sk_buff *skb; | |
253 | u8 src_addr[ETH_ALEN]; | |
254 | u8 dst_addr[ETH_ALEN]; | |
255 | }; | |
256 | ||
b0a4e7d8 | 257 | struct libipw_stats { |
b453872c JG |
258 | unsigned int tx_unicast_frames; |
259 | unsigned int tx_multicast_frames; | |
260 | unsigned int tx_fragments; | |
261 | unsigned int tx_unicast_octets; | |
262 | unsigned int tx_multicast_octets; | |
263 | unsigned int tx_deferred_transmissions; | |
264 | unsigned int tx_single_retry_frames; | |
265 | unsigned int tx_multiple_retry_frames; | |
266 | unsigned int tx_retry_limit_exceeded; | |
267 | unsigned int tx_discards; | |
268 | unsigned int rx_unicast_frames; | |
269 | unsigned int rx_multicast_frames; | |
270 | unsigned int rx_fragments; | |
271 | unsigned int rx_unicast_octets; | |
272 | unsigned int rx_multicast_octets; | |
273 | unsigned int rx_fcs_errors; | |
274 | unsigned int rx_discards_no_buffer; | |
275 | unsigned int tx_discards_wrong_sa; | |
276 | unsigned int rx_discards_undecryptable; | |
277 | unsigned int rx_message_in_msg_fragments; | |
278 | unsigned int rx_message_in_bad_msg_fragments; | |
279 | }; | |
280 | ||
b0a4e7d8 | 281 | struct libipw_device; |
b453872c | 282 | |
f1bf6638 JK |
283 | #define SEC_KEY_1 (1<<0) |
284 | #define SEC_KEY_2 (1<<1) | |
285 | #define SEC_KEY_3 (1<<2) | |
286 | #define SEC_KEY_4 (1<<3) | |
287 | #define SEC_ACTIVE_KEY (1<<4) | |
288 | #define SEC_AUTH_MODE (1<<5) | |
289 | #define SEC_UNICAST_GROUP (1<<6) | |
290 | #define SEC_LEVEL (1<<7) | |
291 | #define SEC_ENABLED (1<<8) | |
259bf1fd | 292 | #define SEC_ENCRYPT (1<<9) |
f1bf6638 JK |
293 | |
294 | #define SEC_LEVEL_0 0 /* None */ | |
295 | #define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */ | |
296 | #define SEC_LEVEL_2 2 /* Level 1 + TKIP */ | |
297 | #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */ | |
298 | #define SEC_LEVEL_3 4 /* Level 2 + CCMP */ | |
299 | ||
e0d369d1 JK |
300 | #define SEC_ALG_NONE 0 |
301 | #define SEC_ALG_WEP 1 | |
302 | #define SEC_ALG_TKIP 2 | |
303 | #define SEC_ALG_CCMP 3 | |
304 | ||
f1bf6638 JK |
305 | #define WEP_KEYS 4 |
306 | #define WEP_KEY_LEN 13 | |
307 | #define SCM_KEY_LEN 32 | |
308 | #define SCM_TEMPORAL_KEY_LENGTH 16 | |
b453872c | 309 | |
b0a4e7d8 | 310 | struct libipw_security { |
0f202aa2 JL |
311 | u16 active_key:2, enabled:1, unicast_uses_group:1, encrypt:1; |
312 | u8 auth_mode; | |
e0d369d1 | 313 | u8 encode_alg[WEP_KEYS]; |
b453872c | 314 | u8 key_sizes[WEP_KEYS]; |
f1bf6638 | 315 | u8 keys[WEP_KEYS][SCM_KEY_LEN]; |
b453872c JG |
316 | u8 level; |
317 | u16 flags; | |
ba2d3587 | 318 | } __packed; |
b453872c | 319 | |
b453872c JG |
320 | /* |
321 | ||
322 | 802.11 data frame from AP | |
323 | ||
324 | ,-------------------------------------------------------------------. | |
325 | Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 | | |
326 | |------|------|---------|---------|---------|------|---------|------| | |
327 | Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs | | |
328 | | | tion | (BSSID) | | | ence | data | | | |
329 | `-------------------------------------------------------------------' | |
330 | ||
331 | Total: 28-2340 bytes | |
332 | ||
333 | */ | |
334 | ||
b453872c JG |
335 | #define BEACON_PROBE_SSID_ID_POSITION 12 |
336 | ||
b0a4e7d8 | 337 | struct libipw_hdr_1addr { |
cdcfc210 JK |
338 | __le16 frame_ctl; |
339 | __le16 duration_id; | |
ee34af37 JK |
340 | u8 addr1[ETH_ALEN]; |
341 | u8 payload[0]; | |
ba2d3587 | 342 | } __packed; |
ee34af37 | 343 | |
b0a4e7d8 | 344 | struct libipw_hdr_2addr { |
cdcfc210 JK |
345 | __le16 frame_ctl; |
346 | __le16 duration_id; | |
ee34af37 JK |
347 | u8 addr1[ETH_ALEN]; |
348 | u8 addr2[ETH_ALEN]; | |
349 | u8 payload[0]; | |
ba2d3587 | 350 | } __packed; |
ee34af37 | 351 | |
b0a4e7d8 | 352 | struct libipw_hdr_3addr { |
cdcfc210 JK |
353 | __le16 frame_ctl; |
354 | __le16 duration_id; | |
ee34af37 JK |
355 | u8 addr1[ETH_ALEN]; |
356 | u8 addr2[ETH_ALEN]; | |
357 | u8 addr3[ETH_ALEN]; | |
cdcfc210 | 358 | __le16 seq_ctl; |
ee34af37 | 359 | u8 payload[0]; |
ba2d3587 | 360 | } __packed; |
ee34af37 | 361 | |
b0a4e7d8 | 362 | struct libipw_hdr_4addr { |
cdcfc210 JK |
363 | __le16 frame_ctl; |
364 | __le16 duration_id; | |
ee34af37 JK |
365 | u8 addr1[ETH_ALEN]; |
366 | u8 addr2[ETH_ALEN]; | |
367 | u8 addr3[ETH_ALEN]; | |
cdcfc210 | 368 | __le16 seq_ctl; |
ee34af37 JK |
369 | u8 addr4[ETH_ALEN]; |
370 | u8 payload[0]; | |
ba2d3587 | 371 | } __packed; |
ee34af37 | 372 | |
b0a4e7d8 | 373 | struct libipw_hdr_3addrqos { |
cdcfc210 JK |
374 | __le16 frame_ctl; |
375 | __le16 duration_id; | |
9e8571af JK |
376 | u8 addr1[ETH_ALEN]; |
377 | u8 addr2[ETH_ALEN]; | |
378 | u8 addr3[ETH_ALEN]; | |
cdcfc210 | 379 | __le16 seq_ctl; |
9e8571af | 380 | u8 payload[0]; |
cdcfc210 | 381 | __le16 qos_ctl; |
ba2d3587 | 382 | } __packed; |
9e8571af | 383 | |
b0a4e7d8 | 384 | struct libipw_info_element { |
b453872c JG |
385 | u8 id; |
386 | u8 len; | |
387 | u8 data[0]; | |
ba2d3587 | 388 | } __packed; |
b453872c JG |
389 | |
390 | /* | |
391 | * These are the data types that can make up management packets | |
392 | * | |
393 | u16 auth_algorithm; | |
394 | u16 auth_sequence; | |
395 | u16 beacon_interval; | |
396 | u16 capability; | |
397 | u8 current_ap[ETH_ALEN]; | |
398 | u16 listen_interval; | |
399 | struct { | |
400 | u16 association_id:14, reserved:2; | |
ba2d3587 | 401 | } __packed; |
b453872c JG |
402 | u32 time_stamp[2]; |
403 | u16 reason; | |
404 | u16 status; | |
405 | */ | |
406 | ||
b0a4e7d8 JL |
407 | struct libipw_auth { |
408 | struct libipw_hdr_3addr header; | |
099c5bb1 JB |
409 | __le16 algorithm; |
410 | __le16 transaction; | |
411 | __le16 status; | |
e5658d3e | 412 | /* challenge */ |
b0a4e7d8 | 413 | struct libipw_info_element info_element[0]; |
ba2d3587 | 414 | } __packed; |
b453872c | 415 | |
b0a4e7d8 | 416 | struct libipw_channel_switch { |
b79e20b6 ZY |
417 | u8 id; |
418 | u8 len; | |
419 | u8 mode; | |
420 | u8 channel; | |
421 | u8 count; | |
ba2d3587 | 422 | } __packed; |
b79e20b6 | 423 | |
b0a4e7d8 JL |
424 | struct libipw_action { |
425 | struct libipw_hdr_3addr header; | |
b79e20b6 ZY |
426 | u8 category; |
427 | u8 action; | |
428 | union { | |
b0a4e7d8 | 429 | struct libipw_action_exchange { |
b79e20b6 | 430 | u8 token; |
b0a4e7d8 | 431 | struct libipw_info_element info_element[0]; |
b79e20b6 | 432 | } exchange; |
b0a4e7d8 | 433 | struct libipw_channel_switch channel_switch; |
b79e20b6 ZY |
434 | |
435 | } format; | |
ba2d3587 | 436 | } __packed; |
b79e20b6 | 437 | |
b0a4e7d8 JL |
438 | struct libipw_disassoc { |
439 | struct libipw_hdr_3addr header; | |
e5658d3e | 440 | __le16 reason; |
ba2d3587 | 441 | } __packed; |
ee34af37 | 442 | |
e5658d3e | 443 | /* Alias deauth for disassoc */ |
b0a4e7d8 | 444 | #define libipw_deauth libipw_disassoc |
e5658d3e | 445 | |
b0a4e7d8 JL |
446 | struct libipw_probe_request { |
447 | struct libipw_hdr_3addr header; | |
e5658d3e | 448 | /* SSID, supported rates */ |
b0a4e7d8 | 449 | struct libipw_info_element info_element[0]; |
ba2d3587 | 450 | } __packed; |
ee34af37 | 451 | |
b0a4e7d8 JL |
452 | struct libipw_probe_response { |
453 | struct libipw_hdr_3addr header; | |
d9e94d56 | 454 | __le32 time_stamp[2]; |
099c5bb1 JB |
455 | __le16 beacon_interval; |
456 | __le16 capability; | |
e5658d3e JK |
457 | /* SSID, supported rates, FH params, DS params, |
458 | * CF params, IBSS params, TIM (if beacon), RSN */ | |
b0a4e7d8 | 459 | struct libipw_info_element info_element[0]; |
ba2d3587 | 460 | } __packed; |
b453872c | 461 | |
ee34af37 | 462 | /* Alias beacon for probe_response */ |
b0a4e7d8 | 463 | #define libipw_beacon libipw_probe_response |
ee34af37 | 464 | |
b0a4e7d8 JL |
465 | struct libipw_assoc_request { |
466 | struct libipw_hdr_3addr header; | |
cdcfc210 JK |
467 | __le16 capability; |
468 | __le16 listen_interval; | |
e5658d3e | 469 | /* SSID, supported rates, RSN */ |
b0a4e7d8 | 470 | struct libipw_info_element info_element[0]; |
ba2d3587 | 471 | } __packed; |
ee34af37 | 472 | |
b0a4e7d8 JL |
473 | struct libipw_reassoc_request { |
474 | struct libipw_hdr_3addr header; | |
099c5bb1 JB |
475 | __le16 capability; |
476 | __le16 listen_interval; | |
b453872c | 477 | u8 current_ap[ETH_ALEN]; |
b0a4e7d8 | 478 | struct libipw_info_element info_element[0]; |
ba2d3587 | 479 | } __packed; |
b453872c | 480 | |
b0a4e7d8 JL |
481 | struct libipw_assoc_response { |
482 | struct libipw_hdr_3addr header; | |
099c5bb1 JB |
483 | __le16 capability; |
484 | __le16 status; | |
485 | __le16 aid; | |
e5658d3e | 486 | /* supported rates */ |
b0a4e7d8 | 487 | struct libipw_info_element info_element[0]; |
ba2d3587 | 488 | } __packed; |
b453872c | 489 | |
b0a4e7d8 | 490 | struct libipw_txb { |
b453872c JG |
491 | u8 nr_frags; |
492 | u8 encrypted; | |
ee34af37 JK |
493 | u8 rts_included; |
494 | u8 reserved; | |
d9e94d56 AV |
495 | u16 frag_size; |
496 | u16 payload_size; | |
b453872c JG |
497 | struct sk_buff *fragments[0]; |
498 | }; | |
499 | ||
099c5bb1 | 500 | /* SWEEP TABLE ENTRIES NUMBER */ |
b453872c JG |
501 | #define MAX_SWEEP_TAB_ENTRIES 42 |
502 | #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7 | |
503 | /* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs | |
504 | * only use 8, and then use extended rates for the remaining supported | |
505 | * rates. Other APs, however, stick all of their supported rates on the | |
506 | * main rates information element... */ | |
507 | #define MAX_RATES_LENGTH ((u8)12) | |
508 | #define MAX_RATES_EX_LENGTH ((u8)16) | |
509 | #define MAX_NETWORK_COUNT 128 | |
510 | ||
511 | #define CRC_LENGTH 4U | |
512 | ||
513 | #define MAX_WPA_IE_LEN 64 | |
514 | ||
9e8571af JK |
515 | #define NETWORK_HAS_OFDM (1<<1) |
516 | #define NETWORK_HAS_CCK (1<<2) | |
517 | ||
518 | /* QoS structure */ | |
519 | #define NETWORK_HAS_QOS_PARAMETERS (1<<3) | |
520 | #define NETWORK_HAS_QOS_INFORMATION (1<<4) | |
b79e20b6 ZY |
521 | #define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \ |
522 | NETWORK_HAS_QOS_INFORMATION) | |
523 | ||
524 | /* 802.11h */ | |
525 | #define NETWORK_HAS_POWER_CONSTRAINT (1<<5) | |
526 | #define NETWORK_HAS_CSA (1<<6) | |
527 | #define NETWORK_HAS_QUIET (1<<7) | |
528 | #define NETWORK_HAS_IBSS_DFS (1<<8) | |
529 | #define NETWORK_HAS_TPC_REPORT (1<<9) | |
9e8571af | 530 | |
d8e2be90 DD |
531 | #define NETWORK_HAS_ERP_VALUE (1<<10) |
532 | ||
9e8571af JK |
533 | #define QOS_QUEUE_NUM 4 |
534 | #define QOS_OUI_LEN 3 | |
535 | #define QOS_OUI_TYPE 2 | |
536 | #define QOS_ELEMENT_ID 221 | |
537 | #define QOS_OUI_INFO_SUB_TYPE 0 | |
538 | #define QOS_OUI_PARAM_SUB_TYPE 1 | |
539 | #define QOS_VERSION_1 1 | |
540 | #define QOS_AIFSN_MIN_VALUE 2 | |
541 | ||
b0a4e7d8 | 542 | struct libipw_qos_information_element { |
9e8571af JK |
543 | u8 elementID; |
544 | u8 length; | |
545 | u8 qui[QOS_OUI_LEN]; | |
546 | u8 qui_type; | |
547 | u8 qui_subtype; | |
548 | u8 version; | |
549 | u8 ac_info; | |
ba2d3587 | 550 | } __packed; |
9e8571af | 551 | |
b0a4e7d8 | 552 | struct libipw_qos_ac_parameter { |
9e8571af JK |
553 | u8 aci_aifsn; |
554 | u8 ecw_min_max; | |
cdcfc210 | 555 | __le16 tx_op_limit; |
ba2d3587 | 556 | } __packed; |
9e8571af | 557 | |
b0a4e7d8 JL |
558 | struct libipw_qos_parameter_info { |
559 | struct libipw_qos_information_element info_element; | |
9e8571af | 560 | u8 reserved; |
b0a4e7d8 | 561 | struct libipw_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM]; |
ba2d3587 | 562 | } __packed; |
9e8571af | 563 | |
b0a4e7d8 | 564 | struct libipw_qos_parameters { |
cdcfc210 JK |
565 | __le16 cw_min[QOS_QUEUE_NUM]; |
566 | __le16 cw_max[QOS_QUEUE_NUM]; | |
9e8571af JK |
567 | u8 aifs[QOS_QUEUE_NUM]; |
568 | u8 flag[QOS_QUEUE_NUM]; | |
cdcfc210 | 569 | __le16 tx_op_limit[QOS_QUEUE_NUM]; |
ba2d3587 | 570 | } __packed; |
9e8571af | 571 | |
b0a4e7d8 JL |
572 | struct libipw_qos_data { |
573 | struct libipw_qos_parameters parameters; | |
9e8571af JK |
574 | int active; |
575 | int supported; | |
576 | u8 param_count; | |
577 | u8 old_param_count; | |
578 | }; | |
579 | ||
b0a4e7d8 | 580 | struct libipw_tim_parameters { |
9e8571af JK |
581 | u8 tim_count; |
582 | u8 tim_period; | |
ba2d3587 | 583 | } __packed; |
9e8571af JK |
584 | |
585 | /*******************************************************/ | |
b453872c | 586 | |
b0a4e7d8 JL |
587 | enum { /* libipw_basic_report.map */ |
588 | LIBIPW_BASIC_MAP_BSS = (1 << 0), | |
589 | LIBIPW_BASIC_MAP_OFDM = (1 << 1), | |
590 | LIBIPW_BASIC_MAP_UNIDENTIFIED = (1 << 2), | |
591 | LIBIPW_BASIC_MAP_RADAR = (1 << 3), | |
592 | LIBIPW_BASIC_MAP_UNMEASURED = (1 << 4), | |
b79e20b6 ZY |
593 | /* Bits 5-7 are reserved */ |
594 | ||
595 | }; | |
b0a4e7d8 | 596 | struct libipw_basic_report { |
b79e20b6 ZY |
597 | u8 channel; |
598 | __le64 start_time; | |
599 | __le16 duration; | |
600 | u8 map; | |
ba2d3587 | 601 | } __packed; |
b79e20b6 | 602 | |
b0a4e7d8 | 603 | enum { /* libipw_measurement_request.mode */ |
b79e20b6 | 604 | /* Bit 0 is reserved */ |
b0a4e7d8 JL |
605 | LIBIPW_MEASUREMENT_ENABLE = (1 << 1), |
606 | LIBIPW_MEASUREMENT_REQUEST = (1 << 2), | |
607 | LIBIPW_MEASUREMENT_REPORT = (1 << 3), | |
b79e20b6 ZY |
608 | /* Bits 4-7 are reserved */ |
609 | }; | |
610 | ||
611 | enum { | |
b0a4e7d8 JL |
612 | LIBIPW_REPORT_BASIC = 0, /* required */ |
613 | LIBIPW_REPORT_CCA = 1, /* optional */ | |
614 | LIBIPW_REPORT_RPI = 2, /* optional */ | |
b79e20b6 ZY |
615 | /* 3-255 reserved */ |
616 | }; | |
617 | ||
b0a4e7d8 | 618 | struct libipw_measurement_params { |
b79e20b6 ZY |
619 | u8 channel; |
620 | __le64 start_time; | |
621 | __le16 duration; | |
ba2d3587 | 622 | } __packed; |
b79e20b6 | 623 | |
b0a4e7d8 JL |
624 | struct libipw_measurement_request { |
625 | struct libipw_info_element ie; | |
b79e20b6 ZY |
626 | u8 token; |
627 | u8 mode; | |
628 | u8 type; | |
b0a4e7d8 | 629 | struct libipw_measurement_params params[0]; |
ba2d3587 | 630 | } __packed; |
b79e20b6 | 631 | |
b0a4e7d8 JL |
632 | struct libipw_measurement_report { |
633 | struct libipw_info_element ie; | |
b79e20b6 ZY |
634 | u8 token; |
635 | u8 mode; | |
636 | u8 type; | |
637 | union { | |
b0a4e7d8 | 638 | struct libipw_basic_report basic[0]; |
b79e20b6 | 639 | } u; |
ba2d3587 | 640 | } __packed; |
b79e20b6 | 641 | |
b0a4e7d8 | 642 | struct libipw_tpc_report { |
b79e20b6 ZY |
643 | u8 transmit_power; |
644 | u8 link_margin; | |
ba2d3587 | 645 | } __packed; |
b79e20b6 | 646 | |
b0a4e7d8 | 647 | struct libipw_channel_map { |
b79e20b6 ZY |
648 | u8 channel; |
649 | u8 map; | |
ba2d3587 | 650 | } __packed; |
b79e20b6 | 651 | |
b0a4e7d8 JL |
652 | struct libipw_ibss_dfs { |
653 | struct libipw_info_element ie; | |
b79e20b6 ZY |
654 | u8 owner[ETH_ALEN]; |
655 | u8 recovery_interval; | |
b0a4e7d8 | 656 | struct libipw_channel_map channel_map[0]; |
b79e20b6 ZY |
657 | }; |
658 | ||
b0a4e7d8 | 659 | struct libipw_csa { |
b79e20b6 ZY |
660 | u8 mode; |
661 | u8 channel; | |
662 | u8 count; | |
ba2d3587 | 663 | } __packed; |
b79e20b6 | 664 | |
b0a4e7d8 | 665 | struct libipw_quiet { |
b79e20b6 ZY |
666 | u8 count; |
667 | u8 period; | |
668 | u8 duration; | |
669 | u8 offset; | |
ba2d3587 | 670 | } __packed; |
b79e20b6 | 671 | |
b0a4e7d8 | 672 | struct libipw_network { |
b453872c JG |
673 | /* These entries are used to identify a unique network */ |
674 | u8 bssid[ETH_ALEN]; | |
675 | u8 channel; | |
676 | /* Ensure null-terminated for any debug msgs */ | |
677 | u8 ssid[IW_ESSID_MAX_SIZE + 1]; | |
678 | u8 ssid_len; | |
679 | ||
b0a4e7d8 | 680 | struct libipw_qos_data qos_data; |
9e8571af | 681 | |
b453872c | 682 | /* These are network statistics */ |
b0a4e7d8 | 683 | struct libipw_rx_stats stats; |
b453872c JG |
684 | u16 capability; |
685 | u8 rates[MAX_RATES_LENGTH]; | |
686 | u8 rates_len; | |
687 | u8 rates_ex[MAX_RATES_EX_LENGTH]; | |
688 | u8 rates_ex_len; | |
689 | unsigned long last_scanned; | |
690 | u8 mode; | |
b79e20b6 | 691 | u32 flags; |
b453872c JG |
692 | u32 last_associate; |
693 | u32 time_stamp[2]; | |
694 | u16 beacon_interval; | |
695 | u16 listen_interval; | |
696 | u16 atim_window; | |
42c94e43 | 697 | u8 erp_value; |
b453872c JG |
698 | u8 wpa_ie[MAX_WPA_IE_LEN]; |
699 | size_t wpa_ie_len; | |
700 | u8 rsn_ie[MAX_WPA_IE_LEN]; | |
701 | size_t rsn_ie_len; | |
b0a4e7d8 | 702 | struct libipw_tim_parameters tim; |
b79e20b6 ZY |
703 | |
704 | /* 802.11h info */ | |
705 | ||
706 | /* Power Constraint - mandatory if spctrm mgmt required */ | |
707 | u8 power_constraint; | |
708 | ||
709 | /* TPC Report - mandatory if spctrm mgmt required */ | |
b0a4e7d8 | 710 | struct libipw_tpc_report tpc_report; |
b79e20b6 ZY |
711 | |
712 | /* IBSS DFS - mandatory if spctrm mgmt required and IBSS | |
713 | * NOTE: This is variable length and so must be allocated dynamically */ | |
b0a4e7d8 | 714 | struct libipw_ibss_dfs *ibss_dfs; |
b79e20b6 ZY |
715 | |
716 | /* Channel Switch Announcement - optional if spctrm mgmt required */ | |
b0a4e7d8 | 717 | struct libipw_csa csa; |
b79e20b6 ZY |
718 | |
719 | /* Quiet - optional if spctrm mgmt required */ | |
b0a4e7d8 | 720 | struct libipw_quiet quiet; |
b79e20b6 | 721 | |
b453872c JG |
722 | struct list_head list; |
723 | }; | |
724 | ||
b0a4e7d8 JL |
725 | enum libipw_state { |
726 | LIBIPW_UNINITIALIZED = 0, | |
727 | LIBIPW_INITIALIZED, | |
728 | LIBIPW_ASSOCIATING, | |
729 | LIBIPW_ASSOCIATED, | |
730 | LIBIPW_AUTHENTICATING, | |
731 | LIBIPW_AUTHENTICATED, | |
732 | LIBIPW_SHUTDOWN | |
b453872c JG |
733 | }; |
734 | ||
735 | #define DEFAULT_MAX_SCAN_AGE (15 * HZ) | |
736 | #define DEFAULT_FTS 2346 | |
b453872c | 737 | |
b0a4e7d8 JL |
738 | #define CFG_LIBIPW_RESERVE_FCS (1<<0) |
739 | #define CFG_LIBIPW_COMPUTE_FCS (1<<1) | |
740 | #define CFG_LIBIPW_RTS (1<<2) | |
b453872c | 741 | |
b0a4e7d8 JL |
742 | #define LIBIPW_24GHZ_MIN_CHANNEL 1 |
743 | #define LIBIPW_24GHZ_MAX_CHANNEL 14 | |
744 | #define LIBIPW_24GHZ_CHANNELS (LIBIPW_24GHZ_MAX_CHANNEL - \ | |
745 | LIBIPW_24GHZ_MIN_CHANNEL + 1) | |
02cda6ae | 746 | |
b0a4e7d8 JL |
747 | #define LIBIPW_52GHZ_MIN_CHANNEL 34 |
748 | #define LIBIPW_52GHZ_MAX_CHANNEL 165 | |
749 | #define LIBIPW_52GHZ_CHANNELS (LIBIPW_52GHZ_MAX_CHANNEL - \ | |
750 | LIBIPW_52GHZ_MIN_CHANNEL + 1) | |
02cda6ae JK |
751 | |
752 | enum { | |
b0a4e7d8 JL |
753 | LIBIPW_CH_PASSIVE_ONLY = (1 << 0), |
754 | LIBIPW_CH_80211H_RULES = (1 << 1), | |
755 | LIBIPW_CH_B_ONLY = (1 << 2), | |
756 | LIBIPW_CH_NO_IBSS = (1 << 3), | |
757 | LIBIPW_CH_UNIFORM_SPREADING = (1 << 4), | |
758 | LIBIPW_CH_RADAR_DETECT = (1 << 5), | |
759 | LIBIPW_CH_INVALID = (1 << 6), | |
02cda6ae JK |
760 | }; |
761 | ||
b0a4e7d8 | 762 | struct libipw_channel { |
74f49033 | 763 | u32 freq; /* in MHz */ |
02cda6ae JK |
764 | u8 channel; |
765 | u8 flags; | |
74f49033 | 766 | u8 max_power; /* in dBm */ |
02cda6ae JK |
767 | }; |
768 | ||
b0a4e7d8 | 769 | struct libipw_geo { |
02cda6ae JK |
770 | u8 name[4]; |
771 | u8 bg_channels; | |
772 | u8 a_channels; | |
b0a4e7d8 JL |
773 | struct libipw_channel bg[LIBIPW_24GHZ_CHANNELS]; |
774 | struct libipw_channel a[LIBIPW_52GHZ_CHANNELS]; | |
02cda6ae JK |
775 | }; |
776 | ||
b0a4e7d8 | 777 | struct libipw_device { |
b453872c | 778 | struct net_device *dev; |
a3caa99e | 779 | struct wireless_dev wdev; |
b0a4e7d8 | 780 | struct libipw_security sec; |
b453872c JG |
781 | |
782 | /* Bookkeeping structures */ | |
b0a4e7d8 | 783 | struct libipw_stats ieee_stats; |
b453872c | 784 | |
b0a4e7d8 | 785 | struct libipw_geo geo; |
a3caa99e JL |
786 | struct ieee80211_supported_band bg_band; |
787 | struct ieee80211_supported_band a_band; | |
02cda6ae | 788 | |
b453872c JG |
789 | /* Probe / Beacon management */ |
790 | struct list_head network_free_list; | |
791 | struct list_head network_list; | |
8e59340e | 792 | struct libipw_network *networks[MAX_NETWORK_COUNT]; |
b453872c JG |
793 | int scans; |
794 | int scan_age; | |
795 | ||
74079fdc JK |
796 | int iw_mode; /* operating mode (IW_MODE_*) */ |
797 | struct iw_spy_data spy_data; /* iwspy support */ | |
b453872c JG |
798 | |
799 | spinlock_t lock; | |
800 | ||
74079fdc JK |
801 | int tx_headroom; /* Set to size of any additional room needed at front |
802 | * of allocated Tx SKBs */ | |
b453872c JG |
803 | u32 config; |
804 | ||
805 | /* WEP and other encryption related settings at the device level */ | |
74079fdc | 806 | int open_wep; /* Set to 1 to allow unencrypted frames */ |
b453872c | 807 | |
b453872c JG |
808 | /* If the host performs {en,de}cryption, then set to 1 */ |
809 | int host_encrypt; | |
1264fc04 | 810 | int host_encrypt_msdu; |
b453872c | 811 | int host_decrypt; |
ccd0fda3 JK |
812 | /* host performs multicast decryption */ |
813 | int host_mc_decrypt; | |
814 | ||
c9308b06 DD |
815 | /* host should strip IV and ICV from protected frames */ |
816 | /* meaningful only when hardware decryption is being used */ | |
817 | int host_strip_iv_icv; | |
818 | ||
1264fc04 | 819 | int host_open_frag; |
74079fdc | 820 | int ieee802_1x; /* is IEEE 802.1X used */ |
b453872c JG |
821 | |
822 | /* WPA data */ | |
823 | int wpa_enabled; | |
824 | int drop_unencrypted; | |
b453872c JG |
825 | int privacy_invoked; |
826 | size_t wpa_ie_len; | |
827 | u8 *wpa_ie; | |
828 | ||
274bfb8d | 829 | struct lib80211_crypt_info crypt_info; |
b453872c | 830 | |
74079fdc JK |
831 | int bcrx_sta_key; /* use individual keys to override default keys even |
832 | * with RX of broad/multicast frames */ | |
b453872c JG |
833 | |
834 | /* Fragmentation structures */ | |
b0a4e7d8 | 835 | struct libipw_frag_entry frag_cache[LIBIPW_FRAG_CACHE_LEN]; |
b453872c | 836 | unsigned int frag_next_idx; |
74079fdc | 837 | u16 fts; /* Fragmentation Threshold */ |
3cdd00c5 | 838 | u16 rts; /* RTS threshold */ |
b453872c JG |
839 | |
840 | /* Association info */ | |
841 | u8 bssid[ETH_ALEN]; | |
842 | ||
b0a4e7d8 | 843 | enum libipw_state state; |
b453872c | 844 | |
74079fdc JK |
845 | int mode; /* A, B, G */ |
846 | int modulation; /* CCK, OFDM */ | |
847 | int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */ | |
3bc5ed68 | 848 | int abg_true; /* ABG flag */ |
b453872c | 849 | |
b1b508e1 JK |
850 | int perfect_rssi; |
851 | int worst_rssi; | |
852 | ||
837925df LF |
853 | u16 prev_seq_ctl; /* used to drop duplicate frames */ |
854 | ||
b453872c | 855 | /* Callback functions */ |
74079fdc | 856 | void (*set_security) (struct net_device * dev, |
b0a4e7d8 | 857 | struct libipw_security * sec); |
d0cf9c0d SH |
858 | netdev_tx_t (*hard_start_xmit) (struct libipw_txb * txb, |
859 | struct net_device * dev, int pri); | |
3f552bbf JK |
860 | int (*is_queue_full) (struct net_device * dev, int pri); |
861 | ||
9e8571af | 862 | int (*handle_management) (struct net_device * dev, |
b0a4e7d8 | 863 | struct libipw_network * network, u16 type); |
73858062 | 864 | int (*is_qos_active) (struct net_device *dev, struct sk_buff *skb); |
9e8571af | 865 | |
3f552bbf JK |
866 | /* Typical STA methods */ |
867 | int (*handle_auth) (struct net_device * dev, | |
b0a4e7d8 | 868 | struct libipw_auth * auth); |
31b59eae | 869 | int (*handle_deauth) (struct net_device * dev, |
b0a4e7d8 | 870 | struct libipw_deauth * auth); |
b79e20b6 | 871 | int (*handle_action) (struct net_device * dev, |
b0a4e7d8 JL |
872 | struct libipw_action * action, |
873 | struct libipw_rx_stats * stats); | |
3f552bbf | 874 | int (*handle_disassoc) (struct net_device * dev, |
b0a4e7d8 | 875 | struct libipw_disassoc * assoc); |
3f552bbf | 876 | int (*handle_beacon) (struct net_device * dev, |
b0a4e7d8 JL |
877 | struct libipw_beacon * beacon, |
878 | struct libipw_network * network); | |
3f552bbf | 879 | int (*handle_probe_response) (struct net_device * dev, |
b0a4e7d8 JL |
880 | struct libipw_probe_response * resp, |
881 | struct libipw_network * network); | |
42c94e43 | 882 | int (*handle_probe_request) (struct net_device * dev, |
b0a4e7d8 JL |
883 | struct libipw_probe_request * req, |
884 | struct libipw_rx_stats * stats); | |
3f552bbf | 885 | int (*handle_assoc_response) (struct net_device * dev, |
b0a4e7d8 JL |
886 | struct libipw_assoc_response * resp, |
887 | struct libipw_network * network); | |
3f552bbf JK |
888 | |
889 | /* Typical AP methods */ | |
890 | int (*handle_assoc_request) (struct net_device * dev); | |
891 | int (*handle_reassoc_request) (struct net_device * dev, | |
b0a4e7d8 | 892 | struct libipw_reassoc_request * req); |
b453872c JG |
893 | |
894 | /* This must be the last item so that it points to the data | |
27ae60f8 | 895 | * allocated beyond this structure by alloc_libipw */ |
b453872c JG |
896 | u8 priv[0]; |
897 | }; | |
898 | ||
899 | #define IEEE_A (1<<0) | |
900 | #define IEEE_B (1<<1) | |
901 | #define IEEE_G (1<<2) | |
902 | #define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G) | |
903 | ||
b0a4e7d8 | 904 | static inline void *libipw_priv(struct net_device *dev) |
b453872c | 905 | { |
b0a4e7d8 | 906 | return ((struct libipw_device *)netdev_priv(dev))->priv; |
b453872c JG |
907 | } |
908 | ||
b0a4e7d8 | 909 | static inline int libipw_is_valid_mode(struct libipw_device *ieee, |
74079fdc | 910 | int mode) |
b453872c JG |
911 | { |
912 | /* | |
913 | * It is possible for both access points and our device to support | |
914 | * combinations of modes, so as long as there is one valid combination | |
915 | * of ap/device supported modes, then return success | |
916 | * | |
917 | */ | |
918 | if ((mode & IEEE_A) && | |
b0a4e7d8 JL |
919 | (ieee->modulation & LIBIPW_OFDM_MODULATION) && |
920 | (ieee->freq_band & LIBIPW_52GHZ_BAND)) | |
b453872c JG |
921 | return 1; |
922 | ||
923 | if ((mode & IEEE_G) && | |
b0a4e7d8 JL |
924 | (ieee->modulation & LIBIPW_OFDM_MODULATION) && |
925 | (ieee->freq_band & LIBIPW_24GHZ_BAND)) | |
b453872c JG |
926 | return 1; |
927 | ||
928 | if ((mode & IEEE_B) && | |
b0a4e7d8 JL |
929 | (ieee->modulation & LIBIPW_CCK_MODULATION) && |
930 | (ieee->freq_band & LIBIPW_24GHZ_BAND)) | |
b453872c JG |
931 | return 1; |
932 | ||
933 | return 0; | |
934 | } | |
935 | ||
b0a4e7d8 | 936 | static inline int libipw_get_hdrlen(u16 fc) |
b453872c | 937 | { |
b0a4e7d8 | 938 | int hdrlen = LIBIPW_3ADDR_LEN; |
9e8571af | 939 | u16 stype = WLAN_FC_GET_STYPE(fc); |
b453872c JG |
940 | |
941 | switch (WLAN_FC_GET_TYPE(fc)) { | |
942 | case IEEE80211_FTYPE_DATA: | |
943 | if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS)) | |
b0a4e7d8 | 944 | hdrlen = LIBIPW_4ADDR_LEN; |
9e8571af JK |
945 | if (stype & IEEE80211_STYPE_QOS_DATA) |
946 | hdrlen += 2; | |
b453872c JG |
947 | break; |
948 | case IEEE80211_FTYPE_CTL: | |
949 | switch (WLAN_FC_GET_STYPE(fc)) { | |
950 | case IEEE80211_STYPE_CTS: | |
951 | case IEEE80211_STYPE_ACK: | |
b0a4e7d8 | 952 | hdrlen = LIBIPW_1ADDR_LEN; |
b453872c JG |
953 | break; |
954 | default: | |
b0a4e7d8 | 955 | hdrlen = LIBIPW_2ADDR_LEN; |
b453872c JG |
956 | break; |
957 | } | |
958 | break; | |
959 | } | |
960 | ||
961 | return hdrlen; | |
962 | } | |
963 | ||
b0a4e7d8 | 964 | static inline u8 *libipw_get_payload(struct ieee80211_hdr *hdr) |
ee34af37 | 965 | { |
b0a4e7d8 JL |
966 | switch (libipw_get_hdrlen(le16_to_cpu(hdr->frame_control))) { |
967 | case LIBIPW_1ADDR_LEN: | |
968 | return ((struct libipw_hdr_1addr *)hdr)->payload; | |
969 | case LIBIPW_2ADDR_LEN: | |
970 | return ((struct libipw_hdr_2addr *)hdr)->payload; | |
971 | case LIBIPW_3ADDR_LEN: | |
972 | return ((struct libipw_hdr_3addr *)hdr)->payload; | |
973 | case LIBIPW_4ADDR_LEN: | |
974 | return ((struct libipw_hdr_4addr *)hdr)->payload; | |
ee34af37 | 975 | } |
cea00da3 | 976 | return NULL; |
ee34af37 JK |
977 | } |
978 | ||
b0a4e7d8 | 979 | static inline int libipw_is_ofdm_rate(u8 rate) |
7c254d3d | 980 | { |
b0a4e7d8 JL |
981 | switch (rate & ~LIBIPW_BASIC_RATE_MASK) { |
982 | case LIBIPW_OFDM_RATE_6MB: | |
983 | case LIBIPW_OFDM_RATE_9MB: | |
984 | case LIBIPW_OFDM_RATE_12MB: | |
985 | case LIBIPW_OFDM_RATE_18MB: | |
986 | case LIBIPW_OFDM_RATE_24MB: | |
987 | case LIBIPW_OFDM_RATE_36MB: | |
988 | case LIBIPW_OFDM_RATE_48MB: | |
989 | case LIBIPW_OFDM_RATE_54MB: | |
7c254d3d ID |
990 | return 1; |
991 | } | |
992 | return 0; | |
993 | } | |
994 | ||
b0a4e7d8 | 995 | static inline int libipw_is_cck_rate(u8 rate) |
7c254d3d | 996 | { |
b0a4e7d8 JL |
997 | switch (rate & ~LIBIPW_BASIC_RATE_MASK) { |
998 | case LIBIPW_CCK_RATE_1MB: | |
999 | case LIBIPW_CCK_RATE_2MB: | |
1000 | case LIBIPW_CCK_RATE_5MB: | |
1001 | case LIBIPW_CCK_RATE_11MB: | |
7c254d3d ID |
1002 | return 1; |
1003 | } | |
1004 | return 0; | |
1005 | } | |
1006 | ||
27ae60f8 PR |
1007 | /* libipw.c */ |
1008 | extern void free_libipw(struct net_device *dev, int monitor); | |
1009 | extern struct net_device *alloc_libipw(int sizeof_priv, int monitor); | |
b0a4e7d8 | 1010 | extern int libipw_change_mtu(struct net_device *dev, int new_mtu); |
b453872c | 1011 | |
b0a4e7d8 | 1012 | extern void libipw_networks_age(struct libipw_device *ieee, |
c3d72b96 DW |
1013 | unsigned long age_secs); |
1014 | ||
b0a4e7d8 | 1015 | extern int libipw_set_encryption(struct libipw_device *ieee); |
b453872c | 1016 | |
b0a4e7d8 | 1017 | /* libipw_tx.c */ |
d0cf9c0d SH |
1018 | extern netdev_tx_t libipw_xmit(struct sk_buff *skb, |
1019 | struct net_device *dev); | |
b0a4e7d8 | 1020 | extern void libipw_txb_free(struct libipw_txb *); |
b453872c | 1021 | |
b0a4e7d8 JL |
1022 | /* libipw_rx.c */ |
1023 | extern void libipw_rx_any(struct libipw_device *ieee, | |
1024 | struct sk_buff *skb, struct libipw_rx_stats *stats); | |
1025 | extern int libipw_rx(struct libipw_device *ieee, struct sk_buff *skb, | |
1026 | struct libipw_rx_stats *rx_stats); | |
c9fa7d5d | 1027 | /* make sure to set stats->len */ |
b0a4e7d8 JL |
1028 | extern void libipw_rx_mgt(struct libipw_device *ieee, |
1029 | struct libipw_hdr_4addr *header, | |
1030 | struct libipw_rx_stats *stats); | |
1031 | extern void libipw_network_reset(struct libipw_network *network); | |
b453872c | 1032 | |
b0a4e7d8 JL |
1033 | /* libipw_geo.c */ |
1034 | extern const struct libipw_geo *libipw_get_geo(struct libipw_device | |
02cda6ae | 1035 | *ieee); |
b0a4e7d8 JL |
1036 | extern int libipw_set_geo(struct libipw_device *ieee, |
1037 | const struct libipw_geo *geo); | |
02cda6ae | 1038 | |
b0a4e7d8 | 1039 | extern int libipw_is_valid_channel(struct libipw_device *ieee, |
02cda6ae | 1040 | u8 channel); |
b0a4e7d8 | 1041 | extern int libipw_channel_to_index(struct libipw_device *ieee, |
02cda6ae | 1042 | u8 channel); |
b0a4e7d8 JL |
1043 | extern u8 libipw_freq_to_channel(struct libipw_device *ieee, u32 freq); |
1044 | extern u8 libipw_get_channel_flags(struct libipw_device *ieee, | |
b79e20b6 | 1045 | u8 channel); |
b0a4e7d8 JL |
1046 | extern const struct libipw_channel *libipw_get_channel(struct |
1047 | libipw_device | |
b79e20b6 | 1048 | *ieee, u8 channel); |
b0a4e7d8 | 1049 | extern u32 libipw_channel_to_freq(struct libipw_device * ieee, |
f5cdf306 | 1050 | u8 channel); |
02cda6ae | 1051 | |
b0a4e7d8 JL |
1052 | /* libipw_wx.c */ |
1053 | extern int libipw_wx_get_scan(struct libipw_device *ieee, | |
b453872c JG |
1054 | struct iw_request_info *info, |
1055 | union iwreq_data *wrqu, char *key); | |
b0a4e7d8 | 1056 | extern int libipw_wx_set_encode(struct libipw_device *ieee, |
b453872c JG |
1057 | struct iw_request_info *info, |
1058 | union iwreq_data *wrqu, char *key); | |
b0a4e7d8 | 1059 | extern int libipw_wx_get_encode(struct libipw_device *ieee, |
b453872c JG |
1060 | struct iw_request_info *info, |
1061 | union iwreq_data *wrqu, char *key); | |
b0a4e7d8 | 1062 | extern int libipw_wx_set_encodeext(struct libipw_device *ieee, |
e0d369d1 JK |
1063 | struct iw_request_info *info, |
1064 | union iwreq_data *wrqu, char *extra); | |
b0a4e7d8 | 1065 | extern int libipw_wx_get_encodeext(struct libipw_device *ieee, |
e0d369d1 JK |
1066 | struct iw_request_info *info, |
1067 | union iwreq_data *wrqu, char *extra); | |
b453872c | 1068 | |
b0a4e7d8 | 1069 | static inline void libipw_increment_scans(struct libipw_device *ieee) |
b453872c JG |
1070 | { |
1071 | ieee->scans++; | |
1072 | } | |
1073 | ||
b0a4e7d8 | 1074 | static inline int libipw_get_scans(struct libipw_device *ieee) |
b453872c JG |
1075 | { |
1076 | return ieee->scans; | |
1077 | } | |
1078 | ||
b0a4e7d8 | 1079 | #endif /* LIBIPW_H */ |