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