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