121042e41SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
2367a1092SKalle Valo /*
3367a1092SKalle Valo * Merged with mainline ieee80211.h in Aug 2004. Original ieee802_11
4367a1092SKalle Valo * remains copyright by the original authors
5367a1092SKalle Valo *
6367a1092SKalle Valo * Portions of the merged code are based on Host AP (software wireless
7367a1092SKalle Valo * LAN access point) driver for Intersil Prism2/2.5/3.
8367a1092SKalle Valo *
9367a1092SKalle Valo * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
10367a1092SKalle Valo * <j@w1.fi>
11367a1092SKalle Valo * Copyright (c) 2002-2003, Jouni Malinen <j@w1.fi>
12367a1092SKalle Valo *
13367a1092SKalle Valo * Adaption to a generic IEEE 802.11 stack by James Ketrenos
14367a1092SKalle Valo * <jketreno@linux.intel.com>
15367a1092SKalle Valo * Copyright (c) 2004-2005, Intel Corporation
16367a1092SKalle Valo *
17367a1092SKalle Valo * API Version History
18367a1092SKalle Valo * 1.0.x -- Initial version
19367a1092SKalle Valo * 1.1.x -- Added radiotap, QoS, TIM, libipw_geo APIs,
20367a1092SKalle Valo * various structure changes, and crypto API init method
21367a1092SKalle Valo */
22367a1092SKalle Valo #ifndef LIBIPW_H
23367a1092SKalle Valo #define LIBIPW_H
24367a1092SKalle Valo #include <linux/if_ether.h> /* ETH_ALEN */
25367a1092SKalle Valo #include <linux/kernel.h> /* ARRAY_SIZE */
26367a1092SKalle Valo #include <linux/wireless.h>
27367a1092SKalle Valo #include <linux/ieee80211.h>
28367a1092SKalle Valo
29367a1092SKalle Valo #include <net/lib80211.h>
30367a1092SKalle Valo #include <net/cfg80211.h>
31367a1092SKalle Valo
32367a1092SKalle Valo #define LIBIPW_VERSION "git-1.1.13"
33367a1092SKalle Valo
34367a1092SKalle Valo #define LIBIPW_DATA_LEN 2304
35367a1092SKalle Valo /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
36367a1092SKalle Valo 6.2.1.1.2.
37367a1092SKalle Valo
38367a1092SKalle Valo The figure in section 7.1.2 suggests a body size of up to 2312
39367a1092SKalle Valo bytes is allowed, which is a bit confusing, I suspect this
40367a1092SKalle Valo represents the 2304 bytes of real data, plus a possible 8 bytes of
41367a1092SKalle Valo WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
42367a1092SKalle Valo
43367a1092SKalle Valo #define LIBIPW_1ADDR_LEN 10
44367a1092SKalle Valo #define LIBIPW_2ADDR_LEN 16
45367a1092SKalle Valo #define LIBIPW_3ADDR_LEN 24
46367a1092SKalle Valo #define LIBIPW_4ADDR_LEN 30
47367a1092SKalle Valo #define LIBIPW_FCS_LEN 4
48367a1092SKalle Valo #define LIBIPW_HLEN (LIBIPW_4ADDR_LEN)
49367a1092SKalle Valo #define LIBIPW_FRAME_LEN (LIBIPW_DATA_LEN + LIBIPW_HLEN)
50367a1092SKalle Valo
51367a1092SKalle Valo #define MIN_FRAG_THRESHOLD 256U
52367a1092SKalle Valo #define MAX_FRAG_THRESHOLD 2346U
53367a1092SKalle Valo
54367a1092SKalle Valo /* QOS control */
55367a1092SKalle Valo #define LIBIPW_QCTL_TID 0x000F
56367a1092SKalle Valo
57367a1092SKalle Valo /* debug macros */
58367a1092SKalle Valo
59367a1092SKalle Valo #ifdef CONFIG_LIBIPW_DEBUG
60367a1092SKalle Valo extern u32 libipw_debug_level;
61367a1092SKalle Valo #define LIBIPW_DEBUG(level, fmt, args...) \
62367a1092SKalle Valo do { if (libipw_debug_level & (level)) \
63e4ff7d6bSSebastian Andrzej Siewior printk(KERN_DEBUG "libipw: %s " fmt, __func__ , ## args); } while (0)
64367a1092SKalle Valo #else
65367a1092SKalle Valo #define LIBIPW_DEBUG(level, fmt, args...) do {} while (0)
66367a1092SKalle Valo #endif /* CONFIG_LIBIPW_DEBUG */
67367a1092SKalle Valo
68367a1092SKalle Valo /*
69367a1092SKalle Valo * To use the debug system:
70367a1092SKalle Valo *
71367a1092SKalle Valo * If you are defining a new debug classification, simply add it to the #define
72367a1092SKalle Valo * list here in the form of:
73367a1092SKalle Valo *
74367a1092SKalle Valo * #define LIBIPW_DL_xxxx VALUE
75367a1092SKalle Valo *
76367a1092SKalle Valo * shifting value to the left one bit from the previous entry. xxxx should be
77367a1092SKalle Valo * the name of the classification (for example, WEP)
78367a1092SKalle Valo *
79367a1092SKalle Valo * You then need to either add a LIBIPW_xxxx_DEBUG() macro definition for your
80367a1092SKalle Valo * classification, or use LIBIPW_DEBUG(LIBIPW_DL_xxxx, ...) whenever you want
81367a1092SKalle Valo * to send output to that classification.
82367a1092SKalle Valo *
83367a1092SKalle Valo * To add your debug level to the list of levels seen when you perform
84367a1092SKalle Valo *
85367a1092SKalle Valo * % cat /proc/net/ieee80211/debug_level
86367a1092SKalle Valo *
87367a1092SKalle Valo * you simply need to add your entry to the libipw_debug_level array.
88367a1092SKalle Valo *
89367a1092SKalle Valo * If you do not see debug_level in /proc/net/ieee80211 then you do not have
90367a1092SKalle Valo * CONFIG_LIBIPW_DEBUG defined in your kernel configuration
91367a1092SKalle Valo *
92367a1092SKalle Valo */
93367a1092SKalle Valo
94367a1092SKalle Valo #define LIBIPW_DL_INFO (1<<0)
95367a1092SKalle Valo #define LIBIPW_DL_WX (1<<1)
96367a1092SKalle Valo #define LIBIPW_DL_SCAN (1<<2)
97367a1092SKalle Valo #define LIBIPW_DL_STATE (1<<3)
98367a1092SKalle Valo #define LIBIPW_DL_MGMT (1<<4)
99367a1092SKalle Valo #define LIBIPW_DL_FRAG (1<<5)
100367a1092SKalle Valo #define LIBIPW_DL_DROP (1<<7)
101367a1092SKalle Valo
102367a1092SKalle Valo #define LIBIPW_DL_TX (1<<8)
103367a1092SKalle Valo #define LIBIPW_DL_RX (1<<9)
104367a1092SKalle Valo #define LIBIPW_DL_QOS (1<<31)
105367a1092SKalle Valo
106367a1092SKalle Valo #define LIBIPW_ERROR(f, a...) printk(KERN_ERR "libipw: " f, ## a)
107367a1092SKalle Valo #define LIBIPW_WARNING(f, a...) printk(KERN_WARNING "libipw: " f, ## a)
108367a1092SKalle Valo #define LIBIPW_DEBUG_INFO(f, a...) LIBIPW_DEBUG(LIBIPW_DL_INFO, f, ## a)
109367a1092SKalle Valo
110367a1092SKalle Valo #define LIBIPW_DEBUG_WX(f, a...) LIBIPW_DEBUG(LIBIPW_DL_WX, f, ## a)
111367a1092SKalle Valo #define LIBIPW_DEBUG_SCAN(f, a...) LIBIPW_DEBUG(LIBIPW_DL_SCAN, f, ## a)
112367a1092SKalle Valo #define LIBIPW_DEBUG_STATE(f, a...) LIBIPW_DEBUG(LIBIPW_DL_STATE, f, ## a)
113367a1092SKalle Valo #define LIBIPW_DEBUG_MGMT(f, a...) LIBIPW_DEBUG(LIBIPW_DL_MGMT, f, ## a)
114367a1092SKalle Valo #define LIBIPW_DEBUG_FRAG(f, a...) LIBIPW_DEBUG(LIBIPW_DL_FRAG, f, ## a)
115367a1092SKalle Valo #define LIBIPW_DEBUG_DROP(f, a...) LIBIPW_DEBUG(LIBIPW_DL_DROP, f, ## a)
116367a1092SKalle Valo #define LIBIPW_DEBUG_TX(f, a...) LIBIPW_DEBUG(LIBIPW_DL_TX, f, ## a)
117367a1092SKalle Valo #define LIBIPW_DEBUG_RX(f, a...) LIBIPW_DEBUG(LIBIPW_DL_RX, f, ## a)
118367a1092SKalle Valo #define LIBIPW_DEBUG_QOS(f, a...) LIBIPW_DEBUG(LIBIPW_DL_QOS, f, ## a)
119367a1092SKalle Valo #include <linux/netdevice.h>
120367a1092SKalle Valo #include <linux/if_arp.h> /* ARPHRD_ETHER */
121367a1092SKalle Valo
122367a1092SKalle Valo #ifndef WIRELESS_SPY
123367a1092SKalle Valo #define WIRELESS_SPY /* enable iwspy support */
124367a1092SKalle Valo #endif
125367a1092SKalle Valo #include <net/iw_handler.h> /* new driver API */
126367a1092SKalle Valo
127367a1092SKalle Valo #define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
128367a1092SKalle Valo
129367a1092SKalle Valo #ifndef ETH_P_80211_RAW
130367a1092SKalle Valo #define ETH_P_80211_RAW (ETH_P_ECONET + 1)
131367a1092SKalle Valo #endif
132367a1092SKalle Valo
133367a1092SKalle Valo /* IEEE 802.11 defines */
134367a1092SKalle Valo
135367a1092SKalle Valo #define P80211_OUI_LEN 3
136367a1092SKalle Valo
137367a1092SKalle Valo struct libipw_snap_hdr {
138367a1092SKalle Valo
139367a1092SKalle Valo u8 dsap; /* always 0xAA */
140367a1092SKalle Valo u8 ssap; /* always 0xAA */
141367a1092SKalle Valo u8 ctrl; /* always 0x03 */
142367a1092SKalle Valo u8 oui[P80211_OUI_LEN]; /* organizational universal id */
143367a1092SKalle Valo
144367a1092SKalle Valo } __packed;
145367a1092SKalle Valo
146367a1092SKalle Valo #define SNAP_SIZE sizeof(struct libipw_snap_hdr)
147367a1092SKalle Valo
148367a1092SKalle Valo #define WLAN_FC_GET_VERS(fc) ((fc) & IEEE80211_FCTL_VERS)
149367a1092SKalle Valo #define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE)
150367a1092SKalle Valo #define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE)
151367a1092SKalle Valo
152367a1092SKalle Valo #define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG)
153367a1092SKalle Valo #define WLAN_GET_SEQ_SEQ(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
154367a1092SKalle Valo
155367a1092SKalle Valo #define LIBIPW_STATMASK_SIGNAL (1<<0)
156367a1092SKalle Valo #define LIBIPW_STATMASK_RSSI (1<<1)
157367a1092SKalle Valo #define LIBIPW_STATMASK_NOISE (1<<2)
158367a1092SKalle Valo #define LIBIPW_STATMASK_RATE (1<<3)
159367a1092SKalle Valo #define LIBIPW_STATMASK_WEMASK 0x7
160367a1092SKalle Valo
161367a1092SKalle Valo #define LIBIPW_CCK_MODULATION (1<<0)
162367a1092SKalle Valo #define LIBIPW_OFDM_MODULATION (1<<1)
163367a1092SKalle Valo
164367a1092SKalle Valo #define LIBIPW_24GHZ_BAND (1<<0)
165367a1092SKalle Valo #define LIBIPW_52GHZ_BAND (1<<1)
166367a1092SKalle Valo
167367a1092SKalle Valo #define LIBIPW_CCK_RATE_1MB 0x02
168367a1092SKalle Valo #define LIBIPW_CCK_RATE_2MB 0x04
169367a1092SKalle Valo #define LIBIPW_CCK_RATE_5MB 0x0B
170367a1092SKalle Valo #define LIBIPW_CCK_RATE_11MB 0x16
171367a1092SKalle Valo #define LIBIPW_OFDM_RATE_6MB 0x0C
172367a1092SKalle Valo #define LIBIPW_OFDM_RATE_9MB 0x12
173367a1092SKalle Valo #define LIBIPW_OFDM_RATE_12MB 0x18
174367a1092SKalle Valo #define LIBIPW_OFDM_RATE_18MB 0x24
175367a1092SKalle Valo #define LIBIPW_OFDM_RATE_24MB 0x30
176367a1092SKalle Valo #define LIBIPW_OFDM_RATE_36MB 0x48
177367a1092SKalle Valo #define LIBIPW_OFDM_RATE_48MB 0x60
178367a1092SKalle Valo #define LIBIPW_OFDM_RATE_54MB 0x6C
179367a1092SKalle Valo #define LIBIPW_BASIC_RATE_MASK 0x80
180367a1092SKalle Valo
181367a1092SKalle Valo #define LIBIPW_CCK_RATE_1MB_MASK (1<<0)
182367a1092SKalle Valo #define LIBIPW_CCK_RATE_2MB_MASK (1<<1)
183367a1092SKalle Valo #define LIBIPW_CCK_RATE_5MB_MASK (1<<2)
184367a1092SKalle Valo #define LIBIPW_CCK_RATE_11MB_MASK (1<<3)
185367a1092SKalle Valo #define LIBIPW_OFDM_RATE_6MB_MASK (1<<4)
186367a1092SKalle Valo #define LIBIPW_OFDM_RATE_9MB_MASK (1<<5)
187367a1092SKalle Valo #define LIBIPW_OFDM_RATE_12MB_MASK (1<<6)
188367a1092SKalle Valo #define LIBIPW_OFDM_RATE_18MB_MASK (1<<7)
189367a1092SKalle Valo #define LIBIPW_OFDM_RATE_24MB_MASK (1<<8)
190367a1092SKalle Valo #define LIBIPW_OFDM_RATE_36MB_MASK (1<<9)
191367a1092SKalle Valo #define LIBIPW_OFDM_RATE_48MB_MASK (1<<10)
192367a1092SKalle Valo #define LIBIPW_OFDM_RATE_54MB_MASK (1<<11)
193367a1092SKalle Valo
194367a1092SKalle Valo #define LIBIPW_CCK_RATES_MASK 0x0000000F
195367a1092SKalle Valo #define LIBIPW_CCK_BASIC_RATES_MASK (LIBIPW_CCK_RATE_1MB_MASK | \
196367a1092SKalle Valo LIBIPW_CCK_RATE_2MB_MASK)
197367a1092SKalle Valo #define LIBIPW_CCK_DEFAULT_RATES_MASK (LIBIPW_CCK_BASIC_RATES_MASK | \
198367a1092SKalle Valo LIBIPW_CCK_RATE_5MB_MASK | \
199367a1092SKalle Valo LIBIPW_CCK_RATE_11MB_MASK)
200367a1092SKalle Valo
201367a1092SKalle Valo #define LIBIPW_OFDM_RATES_MASK 0x00000FF0
202367a1092SKalle Valo #define LIBIPW_OFDM_BASIC_RATES_MASK (LIBIPW_OFDM_RATE_6MB_MASK | \
203367a1092SKalle Valo LIBIPW_OFDM_RATE_12MB_MASK | \
204367a1092SKalle Valo LIBIPW_OFDM_RATE_24MB_MASK)
205367a1092SKalle Valo #define LIBIPW_OFDM_DEFAULT_RATES_MASK (LIBIPW_OFDM_BASIC_RATES_MASK | \
206367a1092SKalle Valo LIBIPW_OFDM_RATE_9MB_MASK | \
207367a1092SKalle Valo LIBIPW_OFDM_RATE_18MB_MASK | \
208367a1092SKalle Valo LIBIPW_OFDM_RATE_36MB_MASK | \
209367a1092SKalle Valo LIBIPW_OFDM_RATE_48MB_MASK | \
210367a1092SKalle Valo LIBIPW_OFDM_RATE_54MB_MASK)
211367a1092SKalle Valo #define LIBIPW_DEFAULT_RATES_MASK (LIBIPW_OFDM_DEFAULT_RATES_MASK | \
212367a1092SKalle Valo LIBIPW_CCK_DEFAULT_RATES_MASK)
213367a1092SKalle Valo
214367a1092SKalle Valo #define LIBIPW_NUM_OFDM_RATES 8
215367a1092SKalle Valo #define LIBIPW_NUM_CCK_RATES 4
216367a1092SKalle Valo #define LIBIPW_OFDM_SHIFT_MASK_A 4
217367a1092SKalle Valo
218367a1092SKalle Valo /* NOTE: This data is for statistical purposes; not all hardware provides this
219367a1092SKalle Valo * information for frames received.
220367a1092SKalle Valo * For libipw_rx_mgt, you need to set at least the 'len' parameter.
221367a1092SKalle Valo */
222367a1092SKalle Valo struct libipw_rx_stats {
223367a1092SKalle Valo u32 mac_time;
224367a1092SKalle Valo s8 rssi;
225367a1092SKalle Valo u8 signal;
226367a1092SKalle Valo u8 noise;
227367a1092SKalle Valo u16 rate; /* in 100 kbps */
228367a1092SKalle Valo u8 received_channel;
229367a1092SKalle Valo u8 control;
230367a1092SKalle Valo u8 mask;
231367a1092SKalle Valo u8 freq;
232367a1092SKalle Valo u16 len;
233367a1092SKalle Valo u64 tsf;
234367a1092SKalle Valo u32 beacon_time;
235367a1092SKalle Valo };
236367a1092SKalle Valo
237367a1092SKalle Valo /* IEEE 802.11 requires that STA supports concurrent reception of at least
238367a1092SKalle Valo * three fragmented frames. This define can be increased to support more
239367a1092SKalle Valo * concurrent frames, but it should be noted that each entry can consume about
240367a1092SKalle Valo * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
241367a1092SKalle Valo #define LIBIPW_FRAG_CACHE_LEN 4
242367a1092SKalle Valo
243367a1092SKalle Valo struct libipw_frag_entry {
244367a1092SKalle Valo unsigned long first_frag_time;
245367a1092SKalle Valo unsigned int seq;
246367a1092SKalle Valo unsigned int last_frag;
247367a1092SKalle Valo struct sk_buff *skb;
248367a1092SKalle Valo u8 src_addr[ETH_ALEN];
249367a1092SKalle Valo u8 dst_addr[ETH_ALEN];
250367a1092SKalle Valo };
251367a1092SKalle Valo
252367a1092SKalle Valo struct libipw_stats {
253367a1092SKalle Valo unsigned int tx_unicast_frames;
254367a1092SKalle Valo unsigned int tx_multicast_frames;
255367a1092SKalle Valo unsigned int tx_fragments;
256367a1092SKalle Valo unsigned int tx_unicast_octets;
257367a1092SKalle Valo unsigned int tx_multicast_octets;
258367a1092SKalle Valo unsigned int tx_deferred_transmissions;
259367a1092SKalle Valo unsigned int tx_single_retry_frames;
260367a1092SKalle Valo unsigned int tx_multiple_retry_frames;
261367a1092SKalle Valo unsigned int tx_retry_limit_exceeded;
262367a1092SKalle Valo unsigned int tx_discards;
263367a1092SKalle Valo unsigned int rx_unicast_frames;
264367a1092SKalle Valo unsigned int rx_multicast_frames;
265367a1092SKalle Valo unsigned int rx_fragments;
266367a1092SKalle Valo unsigned int rx_unicast_octets;
267367a1092SKalle Valo unsigned int rx_multicast_octets;
268367a1092SKalle Valo unsigned int rx_fcs_errors;
269367a1092SKalle Valo unsigned int rx_discards_no_buffer;
270367a1092SKalle Valo unsigned int tx_discards_wrong_sa;
271367a1092SKalle Valo unsigned int rx_discards_undecryptable;
272367a1092SKalle Valo unsigned int rx_message_in_msg_fragments;
273367a1092SKalle Valo unsigned int rx_message_in_bad_msg_fragments;
274367a1092SKalle Valo };
275367a1092SKalle Valo
276367a1092SKalle Valo struct libipw_device;
277367a1092SKalle Valo
278367a1092SKalle Valo #define SEC_KEY_1 (1<<0)
279367a1092SKalle Valo #define SEC_KEY_2 (1<<1)
280367a1092SKalle Valo #define SEC_KEY_3 (1<<2)
281367a1092SKalle Valo #define SEC_KEY_4 (1<<3)
282367a1092SKalle Valo #define SEC_ACTIVE_KEY (1<<4)
283367a1092SKalle Valo #define SEC_AUTH_MODE (1<<5)
284367a1092SKalle Valo #define SEC_UNICAST_GROUP (1<<6)
285367a1092SKalle Valo #define SEC_LEVEL (1<<7)
286367a1092SKalle Valo #define SEC_ENABLED (1<<8)
287367a1092SKalle Valo #define SEC_ENCRYPT (1<<9)
288367a1092SKalle Valo
289367a1092SKalle Valo #define SEC_LEVEL_0 0 /* None */
290367a1092SKalle Valo #define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */
291367a1092SKalle Valo #define SEC_LEVEL_2 2 /* Level 1 + TKIP */
292367a1092SKalle Valo #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
293367a1092SKalle Valo #define SEC_LEVEL_3 4 /* Level 2 + CCMP */
294367a1092SKalle Valo
295367a1092SKalle Valo #define SEC_ALG_NONE 0
296367a1092SKalle Valo #define SEC_ALG_WEP 1
297367a1092SKalle Valo #define SEC_ALG_TKIP 2
298367a1092SKalle Valo #define SEC_ALG_CCMP 3
299367a1092SKalle Valo
300367a1092SKalle Valo #define WEP_KEYS 4
301367a1092SKalle Valo #define WEP_KEY_LEN 13
302367a1092SKalle Valo #define SCM_KEY_LEN 32
303367a1092SKalle Valo #define SCM_TEMPORAL_KEY_LENGTH 16
304367a1092SKalle Valo
305367a1092SKalle Valo struct libipw_security {
306367a1092SKalle Valo u16 active_key:2, enabled:1, unicast_uses_group:1, encrypt:1;
307367a1092SKalle Valo u8 auth_mode;
308367a1092SKalle Valo u8 encode_alg[WEP_KEYS];
309367a1092SKalle Valo u8 key_sizes[WEP_KEYS];
310367a1092SKalle Valo u8 keys[WEP_KEYS][SCM_KEY_LEN];
311367a1092SKalle Valo u8 level;
312367a1092SKalle Valo u16 flags;
313367a1092SKalle Valo } __packed;
314367a1092SKalle Valo
315367a1092SKalle Valo /*
316367a1092SKalle Valo
317367a1092SKalle Valo 802.11 data frame from AP
318367a1092SKalle Valo
319367a1092SKalle Valo ,-------------------------------------------------------------------.
320367a1092SKalle Valo Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
321367a1092SKalle Valo |------|------|---------|---------|---------|------|---------|------|
322367a1092SKalle Valo Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs |
323367a1092SKalle Valo | | tion | (BSSID) | | | ence | data | |
324367a1092SKalle Valo `-------------------------------------------------------------------'
325367a1092SKalle Valo
326367a1092SKalle Valo Total: 28-2340 bytes
327367a1092SKalle Valo
328367a1092SKalle Valo */
329367a1092SKalle Valo
330367a1092SKalle Valo #define BEACON_PROBE_SSID_ID_POSITION 12
331367a1092SKalle Valo
332367a1092SKalle Valo struct libipw_hdr_1addr {
333367a1092SKalle Valo __le16 frame_ctl;
334367a1092SKalle Valo __le16 duration_id;
335367a1092SKalle Valo u8 addr1[ETH_ALEN];
336e0e05f20SGustavo A. R. Silva u8 payload[];
337367a1092SKalle Valo } __packed;
338367a1092SKalle Valo
339367a1092SKalle Valo struct libipw_hdr_2addr {
340367a1092SKalle Valo __le16 frame_ctl;
341367a1092SKalle Valo __le16 duration_id;
342367a1092SKalle Valo u8 addr1[ETH_ALEN];
343367a1092SKalle Valo u8 addr2[ETH_ALEN];
344e0e05f20SGustavo A. R. Silva u8 payload[];
345367a1092SKalle Valo } __packed;
346367a1092SKalle Valo
347367a1092SKalle Valo struct libipw_hdr_3addr {
348*089332e7SGustavo A. R. Silva /* New members MUST be added within the __struct_group() macro below. */
349*089332e7SGustavo A. R. Silva __struct_group(libipw_hdr_3addr_hdr, hdr, __packed,
350367a1092SKalle Valo __le16 frame_ctl;
351367a1092SKalle Valo __le16 duration_id;
352367a1092SKalle Valo u8 addr1[ETH_ALEN];
353367a1092SKalle Valo u8 addr2[ETH_ALEN];
354367a1092SKalle Valo u8 addr3[ETH_ALEN];
355367a1092SKalle Valo __le16 seq_ctl;
356*089332e7SGustavo A. R. Silva );
357e0e05f20SGustavo A. R. Silva u8 payload[];
358367a1092SKalle Valo } __packed;
359*089332e7SGustavo A. R. Silva static_assert(offsetof(struct libipw_hdr_3addr, payload) == sizeof(struct libipw_hdr_3addr_hdr),
360*089332e7SGustavo A. R. Silva "struct member likely outside of __struct_group()");
361367a1092SKalle Valo
362367a1092SKalle Valo struct libipw_hdr_4addr {
363367a1092SKalle Valo __le16 frame_ctl;
364367a1092SKalle Valo __le16 duration_id;
365367a1092SKalle Valo u8 addr1[ETH_ALEN];
366367a1092SKalle Valo u8 addr2[ETH_ALEN];
367367a1092SKalle Valo u8 addr3[ETH_ALEN];
368367a1092SKalle Valo __le16 seq_ctl;
369367a1092SKalle Valo u8 addr4[ETH_ALEN];
370e0e05f20SGustavo A. R. Silva u8 payload[];
371367a1092SKalle Valo } __packed;
372367a1092SKalle Valo
373367a1092SKalle Valo struct libipw_hdr_3addrqos {
374367a1092SKalle Valo __le16 frame_ctl;
375367a1092SKalle Valo __le16 duration_id;
376367a1092SKalle Valo u8 addr1[ETH_ALEN];
377367a1092SKalle Valo u8 addr2[ETH_ALEN];
378367a1092SKalle Valo u8 addr3[ETH_ALEN];
379367a1092SKalle Valo __le16 seq_ctl;
380367a1092SKalle Valo u8 payload[0];
381367a1092SKalle Valo __le16 qos_ctl;
382367a1092SKalle Valo } __packed;
383367a1092SKalle Valo
384367a1092SKalle Valo struct libipw_info_element {
385367a1092SKalle Valo u8 id;
386367a1092SKalle Valo u8 len;
387e0e05f20SGustavo A. R. Silva u8 data[];
388367a1092SKalle Valo } __packed;
389367a1092SKalle Valo
390367a1092SKalle Valo /*
391367a1092SKalle Valo * These are the data types that can make up management packets
392367a1092SKalle Valo *
393367a1092SKalle Valo u16 auth_algorithm;
394367a1092SKalle Valo u16 auth_sequence;
395367a1092SKalle Valo u16 beacon_interval;
396367a1092SKalle Valo u16 capability;
397367a1092SKalle Valo u8 current_ap[ETH_ALEN];
398367a1092SKalle Valo u16 listen_interval;
399367a1092SKalle Valo struct {
400367a1092SKalle Valo u16 association_id:14, reserved:2;
401367a1092SKalle Valo } __packed;
402367a1092SKalle Valo u32 time_stamp[2];
403367a1092SKalle Valo u16 reason;
404367a1092SKalle Valo u16 status;
405367a1092SKalle Valo */
406367a1092SKalle Valo
407367a1092SKalle Valo struct libipw_auth {
408*089332e7SGustavo A. R. Silva struct libipw_hdr_3addr_hdr header;
409367a1092SKalle Valo __le16 algorithm;
410367a1092SKalle Valo __le16 transaction;
411367a1092SKalle Valo __le16 status;
412367a1092SKalle Valo /* challenge */
41328255dd9SJohannes Berg u8 variable[];
414367a1092SKalle Valo } __packed;
415367a1092SKalle Valo
416367a1092SKalle Valo struct libipw_channel_switch {
417367a1092SKalle Valo u8 id;
418367a1092SKalle Valo u8 len;
419367a1092SKalle Valo u8 mode;
420367a1092SKalle Valo u8 channel;
421367a1092SKalle Valo u8 count;
422367a1092SKalle Valo } __packed;
423367a1092SKalle Valo
424367a1092SKalle Valo struct libipw_action {
425*089332e7SGustavo A. R. Silva struct libipw_hdr_3addr_hdr header;
426367a1092SKalle Valo u8 category;
427367a1092SKalle Valo u8 action;
428367a1092SKalle Valo union {
429367a1092SKalle Valo struct libipw_action_exchange {
430367a1092SKalle Valo u8 token;
431367a1092SKalle Valo } exchange;
432367a1092SKalle Valo struct libipw_channel_switch channel_switch;
433367a1092SKalle Valo
434367a1092SKalle Valo } format;
435367a1092SKalle Valo } __packed;
436367a1092SKalle Valo
437367a1092SKalle Valo struct libipw_disassoc {
438*089332e7SGustavo A. R. Silva struct libipw_hdr_3addr_hdr header;
439367a1092SKalle Valo __le16 reason;
440367a1092SKalle Valo } __packed;
441367a1092SKalle Valo
442367a1092SKalle Valo /* Alias deauth for disassoc */
443367a1092SKalle Valo #define libipw_deauth libipw_disassoc
444367a1092SKalle Valo
445367a1092SKalle Valo struct libipw_probe_request {
446*089332e7SGustavo A. R. Silva struct libipw_hdr_3addr_hdr header;
447367a1092SKalle Valo /* SSID, supported rates */
44828255dd9SJohannes Berg u8 variable[];
449367a1092SKalle Valo } __packed;
450367a1092SKalle Valo
451367a1092SKalle Valo struct libipw_probe_response {
452*089332e7SGustavo A. R. Silva struct libipw_hdr_3addr_hdr header;
453367a1092SKalle Valo __le32 time_stamp[2];
454367a1092SKalle Valo __le16 beacon_interval;
455367a1092SKalle Valo __le16 capability;
456367a1092SKalle Valo /* SSID, supported rates, FH params, DS params,
457367a1092SKalle Valo * CF params, IBSS params, TIM (if beacon), RSN */
45828255dd9SJohannes Berg u8 variable[];
459367a1092SKalle Valo } __packed;
460367a1092SKalle Valo
461367a1092SKalle Valo /* Alias beacon for probe_response */
462367a1092SKalle Valo #define libipw_beacon libipw_probe_response
463367a1092SKalle Valo
464367a1092SKalle Valo struct libipw_reassoc_request {
465*089332e7SGustavo A. R. Silva struct libipw_hdr_3addr_hdr header;
466367a1092SKalle Valo __le16 capability;
467367a1092SKalle Valo __le16 listen_interval;
468367a1092SKalle Valo u8 current_ap[ETH_ALEN];
46928255dd9SJohannes Berg u8 variable[];
470367a1092SKalle Valo } __packed;
471367a1092SKalle Valo
472367a1092SKalle Valo struct libipw_assoc_response {
473*089332e7SGustavo A. R. Silva struct libipw_hdr_3addr_hdr header;
474367a1092SKalle Valo __le16 capability;
475367a1092SKalle Valo __le16 status;
476367a1092SKalle Valo __le16 aid;
477367a1092SKalle Valo /* supported rates */
47828255dd9SJohannes Berg u8 variable[];
479367a1092SKalle Valo } __packed;
480367a1092SKalle Valo
481367a1092SKalle Valo struct libipw_txb {
482367a1092SKalle Valo u8 nr_frags;
483367a1092SKalle Valo u8 encrypted;
484367a1092SKalle Valo u8 rts_included;
485367a1092SKalle Valo u8 reserved;
486367a1092SKalle Valo u16 frag_size;
487367a1092SKalle Valo u16 payload_size;
488357be7ebSKees Cook struct sk_buff *fragments[] __counted_by(nr_frags);
489367a1092SKalle Valo };
490367a1092SKalle Valo
491367a1092SKalle Valo /* SWEEP TABLE ENTRIES NUMBER */
492367a1092SKalle Valo #define MAX_SWEEP_TAB_ENTRIES 42
493367a1092SKalle Valo #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
494367a1092SKalle Valo /* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs
495367a1092SKalle Valo * only use 8, and then use extended rates for the remaining supported
496367a1092SKalle Valo * rates. Other APs, however, stick all of their supported rates on the
497367a1092SKalle Valo * main rates information element... */
498367a1092SKalle Valo #define MAX_RATES_LENGTH ((u8)12)
499367a1092SKalle Valo #define MAX_RATES_EX_LENGTH ((u8)16)
500367a1092SKalle Valo #define MAX_NETWORK_COUNT 128
501367a1092SKalle Valo
502367a1092SKalle Valo #define CRC_LENGTH 4U
503367a1092SKalle Valo
504367a1092SKalle Valo #define MAX_WPA_IE_LEN 64
505367a1092SKalle Valo
506367a1092SKalle Valo #define NETWORK_HAS_OFDM (1<<1)
507367a1092SKalle Valo #define NETWORK_HAS_CCK (1<<2)
508367a1092SKalle Valo
509367a1092SKalle Valo /* QoS structure */
510367a1092SKalle Valo #define NETWORK_HAS_QOS_PARAMETERS (1<<3)
511367a1092SKalle Valo #define NETWORK_HAS_QOS_INFORMATION (1<<4)
512367a1092SKalle Valo #define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \
513367a1092SKalle Valo NETWORK_HAS_QOS_INFORMATION)
514367a1092SKalle Valo
515367a1092SKalle Valo /* 802.11h */
516367a1092SKalle Valo #define NETWORK_HAS_POWER_CONSTRAINT (1<<5)
517367a1092SKalle Valo #define NETWORK_HAS_CSA (1<<6)
518367a1092SKalle Valo #define NETWORK_HAS_QUIET (1<<7)
519367a1092SKalle Valo #define NETWORK_HAS_IBSS_DFS (1<<8)
520367a1092SKalle Valo #define NETWORK_HAS_TPC_REPORT (1<<9)
521367a1092SKalle Valo
522367a1092SKalle Valo #define NETWORK_HAS_ERP_VALUE (1<<10)
523367a1092SKalle Valo
524367a1092SKalle Valo #define QOS_QUEUE_NUM 4
525367a1092SKalle Valo #define QOS_OUI_LEN 3
526367a1092SKalle Valo #define QOS_OUI_TYPE 2
527367a1092SKalle Valo #define QOS_ELEMENT_ID 221
528367a1092SKalle Valo #define QOS_OUI_INFO_SUB_TYPE 0
529367a1092SKalle Valo #define QOS_OUI_PARAM_SUB_TYPE 1
530367a1092SKalle Valo #define QOS_VERSION_1 1
531367a1092SKalle Valo #define QOS_AIFSN_MIN_VALUE 2
532367a1092SKalle Valo
533367a1092SKalle Valo struct libipw_qos_information_element {
534367a1092SKalle Valo u8 elementID;
535367a1092SKalle Valo u8 length;
536367a1092SKalle Valo u8 qui[QOS_OUI_LEN];
537367a1092SKalle Valo u8 qui_type;
538367a1092SKalle Valo u8 qui_subtype;
539367a1092SKalle Valo u8 version;
540367a1092SKalle Valo u8 ac_info;
541367a1092SKalle Valo } __packed;
542367a1092SKalle Valo
543367a1092SKalle Valo struct libipw_qos_ac_parameter {
544367a1092SKalle Valo u8 aci_aifsn;
545367a1092SKalle Valo u8 ecw_min_max;
546367a1092SKalle Valo __le16 tx_op_limit;
547367a1092SKalle Valo } __packed;
548367a1092SKalle Valo
549367a1092SKalle Valo struct libipw_qos_parameter_info {
550367a1092SKalle Valo struct libipw_qos_information_element info_element;
551367a1092SKalle Valo u8 reserved;
552367a1092SKalle Valo struct libipw_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM];
553367a1092SKalle Valo } __packed;
554367a1092SKalle Valo
555367a1092SKalle Valo struct libipw_qos_parameters {
556367a1092SKalle Valo __le16 cw_min[QOS_QUEUE_NUM];
557367a1092SKalle Valo __le16 cw_max[QOS_QUEUE_NUM];
558367a1092SKalle Valo u8 aifs[QOS_QUEUE_NUM];
559367a1092SKalle Valo u8 flag[QOS_QUEUE_NUM];
560367a1092SKalle Valo __le16 tx_op_limit[QOS_QUEUE_NUM];
561367a1092SKalle Valo } __packed;
562367a1092SKalle Valo
563367a1092SKalle Valo struct libipw_qos_data {
564367a1092SKalle Valo struct libipw_qos_parameters parameters;
565367a1092SKalle Valo int active;
566367a1092SKalle Valo int supported;
567367a1092SKalle Valo u8 param_count;
568367a1092SKalle Valo u8 old_param_count;
569367a1092SKalle Valo };
570367a1092SKalle Valo
571367a1092SKalle Valo struct libipw_tim_parameters {
572367a1092SKalle Valo u8 tim_count;
573367a1092SKalle Valo u8 tim_period;
574367a1092SKalle Valo } __packed;
575367a1092SKalle Valo
576367a1092SKalle Valo /*******************************************************/
577367a1092SKalle Valo
578367a1092SKalle Valo struct libipw_tpc_report {
579367a1092SKalle Valo u8 transmit_power;
580367a1092SKalle Valo u8 link_margin;
581367a1092SKalle Valo } __packed;
582367a1092SKalle Valo
583367a1092SKalle Valo struct libipw_channel_map {
584367a1092SKalle Valo u8 channel;
585367a1092SKalle Valo u8 map;
586367a1092SKalle Valo } __packed;
587367a1092SKalle Valo
588367a1092SKalle Valo struct libipw_csa {
589367a1092SKalle Valo u8 mode;
590367a1092SKalle Valo u8 channel;
591367a1092SKalle Valo u8 count;
592367a1092SKalle Valo } __packed;
593367a1092SKalle Valo
594367a1092SKalle Valo struct libipw_quiet {
595367a1092SKalle Valo u8 count;
596367a1092SKalle Valo u8 period;
597367a1092SKalle Valo u8 duration;
598367a1092SKalle Valo u8 offset;
599367a1092SKalle Valo } __packed;
600367a1092SKalle Valo
601367a1092SKalle Valo struct libipw_network {
602367a1092SKalle Valo /* These entries are used to identify a unique network */
603367a1092SKalle Valo u8 bssid[ETH_ALEN];
604367a1092SKalle Valo u8 channel;
605367a1092SKalle Valo /* Ensure null-terminated for any debug msgs */
606367a1092SKalle Valo u8 ssid[IW_ESSID_MAX_SIZE + 1];
607367a1092SKalle Valo u8 ssid_len;
608367a1092SKalle Valo
609367a1092SKalle Valo struct libipw_qos_data qos_data;
610367a1092SKalle Valo
611367a1092SKalle Valo /* These are network statistics */
612367a1092SKalle Valo struct libipw_rx_stats stats;
613367a1092SKalle Valo u16 capability;
614367a1092SKalle Valo u8 rates[MAX_RATES_LENGTH];
615367a1092SKalle Valo u8 rates_len;
616367a1092SKalle Valo u8 rates_ex[MAX_RATES_EX_LENGTH];
617367a1092SKalle Valo u8 rates_ex_len;
618367a1092SKalle Valo unsigned long last_scanned;
619367a1092SKalle Valo u8 mode;
620367a1092SKalle Valo u32 flags;
621367a1092SKalle Valo u32 last_associate;
622367a1092SKalle Valo u32 time_stamp[2];
623367a1092SKalle Valo u16 beacon_interval;
624367a1092SKalle Valo u16 listen_interval;
625367a1092SKalle Valo u16 atim_window;
626367a1092SKalle Valo u8 erp_value;
627367a1092SKalle Valo u8 wpa_ie[MAX_WPA_IE_LEN];
628367a1092SKalle Valo size_t wpa_ie_len;
629367a1092SKalle Valo u8 rsn_ie[MAX_WPA_IE_LEN];
630367a1092SKalle Valo size_t rsn_ie_len;
631367a1092SKalle Valo struct libipw_tim_parameters tim;
632367a1092SKalle Valo
633367a1092SKalle Valo /* 802.11h info */
634367a1092SKalle Valo
635367a1092SKalle Valo /* Power Constraint - mandatory if spctrm mgmt required */
636367a1092SKalle Valo u8 power_constraint;
637367a1092SKalle Valo
638367a1092SKalle Valo /* TPC Report - mandatory if spctrm mgmt required */
639367a1092SKalle Valo struct libipw_tpc_report tpc_report;
640367a1092SKalle Valo
641367a1092SKalle Valo /* Channel Switch Announcement - optional if spctrm mgmt required */
642367a1092SKalle Valo struct libipw_csa csa;
643367a1092SKalle Valo
644367a1092SKalle Valo /* Quiet - optional if spctrm mgmt required */
645367a1092SKalle Valo struct libipw_quiet quiet;
646367a1092SKalle Valo
647367a1092SKalle Valo struct list_head list;
648367a1092SKalle Valo };
649367a1092SKalle Valo
650367a1092SKalle Valo enum libipw_state {
651367a1092SKalle Valo LIBIPW_UNINITIALIZED = 0,
652367a1092SKalle Valo LIBIPW_INITIALIZED,
653367a1092SKalle Valo LIBIPW_ASSOCIATING,
654367a1092SKalle Valo LIBIPW_ASSOCIATED,
655367a1092SKalle Valo LIBIPW_AUTHENTICATING,
656367a1092SKalle Valo LIBIPW_AUTHENTICATED,
657367a1092SKalle Valo LIBIPW_SHUTDOWN
658367a1092SKalle Valo };
659367a1092SKalle Valo
660367a1092SKalle Valo #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
661367a1092SKalle Valo #define DEFAULT_FTS 2346
662367a1092SKalle Valo
663367a1092SKalle Valo #define CFG_LIBIPW_RESERVE_FCS (1<<0)
664367a1092SKalle Valo #define CFG_LIBIPW_COMPUTE_FCS (1<<1)
665367a1092SKalle Valo #define CFG_LIBIPW_RTS (1<<2)
666367a1092SKalle Valo
667367a1092SKalle Valo #define LIBIPW_24GHZ_MIN_CHANNEL 1
668367a1092SKalle Valo #define LIBIPW_24GHZ_MAX_CHANNEL 14
669367a1092SKalle Valo #define LIBIPW_24GHZ_CHANNELS (LIBIPW_24GHZ_MAX_CHANNEL - \
670367a1092SKalle Valo LIBIPW_24GHZ_MIN_CHANNEL + 1)
671367a1092SKalle Valo
672367a1092SKalle Valo #define LIBIPW_52GHZ_MIN_CHANNEL 34
673367a1092SKalle Valo #define LIBIPW_52GHZ_MAX_CHANNEL 165
674367a1092SKalle Valo #define LIBIPW_52GHZ_CHANNELS (LIBIPW_52GHZ_MAX_CHANNEL - \
675367a1092SKalle Valo LIBIPW_52GHZ_MIN_CHANNEL + 1)
676367a1092SKalle Valo
677367a1092SKalle Valo enum {
678367a1092SKalle Valo LIBIPW_CH_PASSIVE_ONLY = (1 << 0),
679367a1092SKalle Valo LIBIPW_CH_80211H_RULES = (1 << 1),
680367a1092SKalle Valo LIBIPW_CH_B_ONLY = (1 << 2),
681367a1092SKalle Valo LIBIPW_CH_NO_IBSS = (1 << 3),
682367a1092SKalle Valo LIBIPW_CH_UNIFORM_SPREADING = (1 << 4),
683367a1092SKalle Valo LIBIPW_CH_RADAR_DETECT = (1 << 5),
684367a1092SKalle Valo LIBIPW_CH_INVALID = (1 << 6),
685367a1092SKalle Valo };
686367a1092SKalle Valo
687367a1092SKalle Valo struct libipw_channel {
688367a1092SKalle Valo u32 freq; /* in MHz */
689367a1092SKalle Valo u8 channel;
690367a1092SKalle Valo u8 flags;
691367a1092SKalle Valo u8 max_power; /* in dBm */
692367a1092SKalle Valo };
693367a1092SKalle Valo
694367a1092SKalle Valo struct libipw_geo {
695367a1092SKalle Valo u8 name[4];
696367a1092SKalle Valo u8 bg_channels;
697367a1092SKalle Valo u8 a_channels;
698367a1092SKalle Valo struct libipw_channel bg[LIBIPW_24GHZ_CHANNELS];
699367a1092SKalle Valo struct libipw_channel a[LIBIPW_52GHZ_CHANNELS];
700367a1092SKalle Valo };
701367a1092SKalle Valo
702367a1092SKalle Valo struct libipw_device {
703367a1092SKalle Valo struct net_device *dev;
704367a1092SKalle Valo struct wireless_dev wdev;
705367a1092SKalle Valo struct libipw_security sec;
706367a1092SKalle Valo
707367a1092SKalle Valo /* Bookkeeping structures */
708367a1092SKalle Valo struct libipw_stats ieee_stats;
709367a1092SKalle Valo
710367a1092SKalle Valo struct libipw_geo geo;
711367a1092SKalle Valo struct ieee80211_supported_band bg_band;
712367a1092SKalle Valo struct ieee80211_supported_band a_band;
713367a1092SKalle Valo
714367a1092SKalle Valo /* Probe / Beacon management */
715367a1092SKalle Valo struct list_head network_free_list;
716367a1092SKalle Valo struct list_head network_list;
717367a1092SKalle Valo struct libipw_network *networks[MAX_NETWORK_COUNT];
718367a1092SKalle Valo int scans;
719367a1092SKalle Valo int scan_age;
720367a1092SKalle Valo
721367a1092SKalle Valo int iw_mode; /* operating mode (IW_MODE_*) */
722367a1092SKalle Valo struct iw_spy_data spy_data; /* iwspy support */
723367a1092SKalle Valo
724367a1092SKalle Valo spinlock_t lock;
725367a1092SKalle Valo
726367a1092SKalle Valo int tx_headroom; /* Set to size of any additional room needed at front
727367a1092SKalle Valo * of allocated Tx SKBs */
728367a1092SKalle Valo u32 config;
729367a1092SKalle Valo
730367a1092SKalle Valo /* WEP and other encryption related settings at the device level */
731367a1092SKalle Valo int open_wep; /* Set to 1 to allow unencrypted frames */
732367a1092SKalle Valo
733367a1092SKalle Valo /* If the host performs {en,de}cryption, then set to 1 */
734367a1092SKalle Valo int host_encrypt;
735367a1092SKalle Valo int host_encrypt_msdu;
736367a1092SKalle Valo int host_decrypt;
737367a1092SKalle Valo /* host performs multicast decryption */
738367a1092SKalle Valo int host_mc_decrypt;
739367a1092SKalle Valo
740367a1092SKalle Valo /* host should strip IV and ICV from protected frames */
741367a1092SKalle Valo /* meaningful only when hardware decryption is being used */
742367a1092SKalle Valo int host_strip_iv_icv;
743367a1092SKalle Valo
744367a1092SKalle Valo int host_open_frag;
745367a1092SKalle Valo int ieee802_1x; /* is IEEE 802.1X used */
746367a1092SKalle Valo
747367a1092SKalle Valo /* WPA data */
748367a1092SKalle Valo int wpa_enabled;
749367a1092SKalle Valo int drop_unencrypted;
750367a1092SKalle Valo int privacy_invoked;
751367a1092SKalle Valo size_t wpa_ie_len;
752367a1092SKalle Valo u8 *wpa_ie;
753367a1092SKalle Valo
754367a1092SKalle Valo struct lib80211_crypt_info crypt_info;
755367a1092SKalle Valo
756367a1092SKalle Valo int bcrx_sta_key; /* use individual keys to override default keys even
757367a1092SKalle Valo * with RX of broad/multicast frames */
758367a1092SKalle Valo
759367a1092SKalle Valo /* Fragmentation structures */
760367a1092SKalle Valo struct libipw_frag_entry frag_cache[LIBIPW_FRAG_CACHE_LEN];
761367a1092SKalle Valo unsigned int frag_next_idx;
762367a1092SKalle Valo u16 fts; /* Fragmentation Threshold */
763367a1092SKalle Valo u16 rts; /* RTS threshold */
764367a1092SKalle Valo
765367a1092SKalle Valo /* Association info */
766367a1092SKalle Valo u8 bssid[ETH_ALEN];
767367a1092SKalle Valo
768367a1092SKalle Valo enum libipw_state state;
769367a1092SKalle Valo
770367a1092SKalle Valo int mode; /* A, B, G */
771367a1092SKalle Valo int modulation; /* CCK, OFDM */
772367a1092SKalle Valo int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */
773367a1092SKalle Valo int abg_true; /* ABG flag */
774367a1092SKalle Valo
775367a1092SKalle Valo int perfect_rssi;
776367a1092SKalle Valo int worst_rssi;
777367a1092SKalle Valo
778367a1092SKalle Valo u16 prev_seq_ctl; /* used to drop duplicate frames */
779367a1092SKalle Valo
780367a1092SKalle Valo /* Callback functions */
781367a1092SKalle Valo void (*set_security) (struct net_device * dev,
782367a1092SKalle Valo struct libipw_security * sec);
783367a1092SKalle Valo netdev_tx_t (*hard_start_xmit) (struct libipw_txb * txb,
784367a1092SKalle Valo struct net_device * dev, int pri);
785367a1092SKalle Valo int (*is_queue_full) (struct net_device * dev, int pri);
786367a1092SKalle Valo
787367a1092SKalle Valo int (*handle_management) (struct net_device * dev,
788367a1092SKalle Valo struct libipw_network * network, u16 type);
789367a1092SKalle Valo int (*is_qos_active) (struct net_device *dev, struct sk_buff *skb);
790367a1092SKalle Valo
791367a1092SKalle Valo /* Typical STA methods */
792367a1092SKalle Valo int (*handle_auth) (struct net_device * dev,
793367a1092SKalle Valo struct libipw_auth * auth);
794367a1092SKalle Valo int (*handle_deauth) (struct net_device * dev,
795367a1092SKalle Valo struct libipw_deauth * auth);
796367a1092SKalle Valo int (*handle_action) (struct net_device * dev,
797367a1092SKalle Valo struct libipw_action * action,
798367a1092SKalle Valo struct libipw_rx_stats * stats);
799367a1092SKalle Valo int (*handle_disassoc) (struct net_device * dev,
800367a1092SKalle Valo struct libipw_disassoc * assoc);
801367a1092SKalle Valo int (*handle_beacon) (struct net_device * dev,
802367a1092SKalle Valo struct libipw_beacon * beacon,
803367a1092SKalle Valo struct libipw_network * network);
804367a1092SKalle Valo int (*handle_probe_response) (struct net_device * dev,
805367a1092SKalle Valo struct libipw_probe_response * resp,
806367a1092SKalle Valo struct libipw_network * network);
807367a1092SKalle Valo int (*handle_probe_request) (struct net_device * dev,
808367a1092SKalle Valo struct libipw_probe_request * req,
809367a1092SKalle Valo struct libipw_rx_stats * stats);
810367a1092SKalle Valo int (*handle_assoc_response) (struct net_device * dev,
811367a1092SKalle Valo struct libipw_assoc_response * resp,
812367a1092SKalle Valo struct libipw_network * network);
813367a1092SKalle Valo
814367a1092SKalle Valo /* Typical AP methods */
815367a1092SKalle Valo int (*handle_assoc_request) (struct net_device * dev);
816367a1092SKalle Valo int (*handle_reassoc_request) (struct net_device * dev,
817367a1092SKalle Valo struct libipw_reassoc_request * req);
818367a1092SKalle Valo
819367a1092SKalle Valo /* This must be the last item so that it points to the data
820367a1092SKalle Valo * allocated beyond this structure by alloc_libipw */
821e0e05f20SGustavo A. R. Silva u8 priv[];
822367a1092SKalle Valo };
823367a1092SKalle Valo
824367a1092SKalle Valo #define IEEE_A (1<<0)
825367a1092SKalle Valo #define IEEE_B (1<<1)
826367a1092SKalle Valo #define IEEE_G (1<<2)
827367a1092SKalle Valo #define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
828367a1092SKalle Valo
libipw_priv(struct net_device * dev)829367a1092SKalle Valo static inline void *libipw_priv(struct net_device *dev)
830367a1092SKalle Valo {
831367a1092SKalle Valo return ((struct libipw_device *)netdev_priv(dev))->priv;
832367a1092SKalle Valo }
833367a1092SKalle Valo
libipw_is_valid_mode(struct libipw_device * ieee,int mode)834367a1092SKalle Valo static inline int libipw_is_valid_mode(struct libipw_device *ieee,
835367a1092SKalle Valo int mode)
836367a1092SKalle Valo {
837367a1092SKalle Valo /*
838367a1092SKalle Valo * It is possible for both access points and our device to support
839367a1092SKalle Valo * combinations of modes, so as long as there is one valid combination
840367a1092SKalle Valo * of ap/device supported modes, then return success
841367a1092SKalle Valo *
842367a1092SKalle Valo */
843367a1092SKalle Valo if ((mode & IEEE_A) &&
844367a1092SKalle Valo (ieee->modulation & LIBIPW_OFDM_MODULATION) &&
845367a1092SKalle Valo (ieee->freq_band & LIBIPW_52GHZ_BAND))
846367a1092SKalle Valo return 1;
847367a1092SKalle Valo
848367a1092SKalle Valo if ((mode & IEEE_G) &&
849367a1092SKalle Valo (ieee->modulation & LIBIPW_OFDM_MODULATION) &&
850367a1092SKalle Valo (ieee->freq_band & LIBIPW_24GHZ_BAND))
851367a1092SKalle Valo return 1;
852367a1092SKalle Valo
853367a1092SKalle Valo if ((mode & IEEE_B) &&
854367a1092SKalle Valo (ieee->modulation & LIBIPW_CCK_MODULATION) &&
855367a1092SKalle Valo (ieee->freq_band & LIBIPW_24GHZ_BAND))
856367a1092SKalle Valo return 1;
857367a1092SKalle Valo
858367a1092SKalle Valo return 0;
859367a1092SKalle Valo }
860367a1092SKalle Valo
libipw_get_hdrlen(u16 fc)861367a1092SKalle Valo static inline int libipw_get_hdrlen(u16 fc)
862367a1092SKalle Valo {
863367a1092SKalle Valo int hdrlen = LIBIPW_3ADDR_LEN;
864367a1092SKalle Valo u16 stype = WLAN_FC_GET_STYPE(fc);
865367a1092SKalle Valo
866367a1092SKalle Valo switch (WLAN_FC_GET_TYPE(fc)) {
867367a1092SKalle Valo case IEEE80211_FTYPE_DATA:
868367a1092SKalle Valo if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
869367a1092SKalle Valo hdrlen = LIBIPW_4ADDR_LEN;
870367a1092SKalle Valo if (stype & IEEE80211_STYPE_QOS_DATA)
871367a1092SKalle Valo hdrlen += 2;
872367a1092SKalle Valo break;
873367a1092SKalle Valo case IEEE80211_FTYPE_CTL:
874367a1092SKalle Valo switch (WLAN_FC_GET_STYPE(fc)) {
875367a1092SKalle Valo case IEEE80211_STYPE_CTS:
876367a1092SKalle Valo case IEEE80211_STYPE_ACK:
877367a1092SKalle Valo hdrlen = LIBIPW_1ADDR_LEN;
878367a1092SKalle Valo break;
879367a1092SKalle Valo default:
880367a1092SKalle Valo hdrlen = LIBIPW_2ADDR_LEN;
881367a1092SKalle Valo break;
882367a1092SKalle Valo }
883367a1092SKalle Valo break;
884367a1092SKalle Valo }
885367a1092SKalle Valo
886367a1092SKalle Valo return hdrlen;
887367a1092SKalle Valo }
888367a1092SKalle Valo
libipw_get_payload(struct ieee80211_hdr * hdr)889367a1092SKalle Valo static inline u8 *libipw_get_payload(struct ieee80211_hdr *hdr)
890367a1092SKalle Valo {
891367a1092SKalle Valo switch (libipw_get_hdrlen(le16_to_cpu(hdr->frame_control))) {
892367a1092SKalle Valo case LIBIPW_1ADDR_LEN:
893367a1092SKalle Valo return ((struct libipw_hdr_1addr *)hdr)->payload;
894367a1092SKalle Valo case LIBIPW_2ADDR_LEN:
895367a1092SKalle Valo return ((struct libipw_hdr_2addr *)hdr)->payload;
896367a1092SKalle Valo case LIBIPW_3ADDR_LEN:
897367a1092SKalle Valo return ((struct libipw_hdr_3addr *)hdr)->payload;
898367a1092SKalle Valo case LIBIPW_4ADDR_LEN:
899367a1092SKalle Valo return ((struct libipw_hdr_4addr *)hdr)->payload;
900367a1092SKalle Valo }
901367a1092SKalle Valo return NULL;
902367a1092SKalle Valo }
903367a1092SKalle Valo
libipw_is_ofdm_rate(u8 rate)904367a1092SKalle Valo static inline int libipw_is_ofdm_rate(u8 rate)
905367a1092SKalle Valo {
906367a1092SKalle Valo switch (rate & ~LIBIPW_BASIC_RATE_MASK) {
907367a1092SKalle Valo case LIBIPW_OFDM_RATE_6MB:
908367a1092SKalle Valo case LIBIPW_OFDM_RATE_9MB:
909367a1092SKalle Valo case LIBIPW_OFDM_RATE_12MB:
910367a1092SKalle Valo case LIBIPW_OFDM_RATE_18MB:
911367a1092SKalle Valo case LIBIPW_OFDM_RATE_24MB:
912367a1092SKalle Valo case LIBIPW_OFDM_RATE_36MB:
913367a1092SKalle Valo case LIBIPW_OFDM_RATE_48MB:
914367a1092SKalle Valo case LIBIPW_OFDM_RATE_54MB:
915367a1092SKalle Valo return 1;
916367a1092SKalle Valo }
917367a1092SKalle Valo return 0;
918367a1092SKalle Valo }
919367a1092SKalle Valo
libipw_is_cck_rate(u8 rate)920367a1092SKalle Valo static inline int libipw_is_cck_rate(u8 rate)
921367a1092SKalle Valo {
922367a1092SKalle Valo switch (rate & ~LIBIPW_BASIC_RATE_MASK) {
923367a1092SKalle Valo case LIBIPW_CCK_RATE_1MB:
924367a1092SKalle Valo case LIBIPW_CCK_RATE_2MB:
925367a1092SKalle Valo case LIBIPW_CCK_RATE_5MB:
926367a1092SKalle Valo case LIBIPW_CCK_RATE_11MB:
927367a1092SKalle Valo return 1;
928367a1092SKalle Valo }
929367a1092SKalle Valo return 0;
930367a1092SKalle Valo }
931367a1092SKalle Valo
932367a1092SKalle Valo /* libipw.c */
933367a1092SKalle Valo void free_libipw(struct net_device *dev, int monitor);
934367a1092SKalle Valo struct net_device *alloc_libipw(int sizeof_priv, int monitor);
935367a1092SKalle Valo
936367a1092SKalle Valo void libipw_networks_age(struct libipw_device *ieee, unsigned long age_secs);
937367a1092SKalle Valo
938367a1092SKalle Valo int libipw_set_encryption(struct libipw_device *ieee);
939367a1092SKalle Valo
940367a1092SKalle Valo /* libipw_tx.c */
941367a1092SKalle Valo netdev_tx_t libipw_xmit(struct sk_buff *skb, struct net_device *dev);
942367a1092SKalle Valo void libipw_txb_free(struct libipw_txb *);
943367a1092SKalle Valo
944367a1092SKalle Valo /* libipw_rx.c */
945367a1092SKalle Valo void libipw_rx_any(struct libipw_device *ieee, struct sk_buff *skb,
946367a1092SKalle Valo struct libipw_rx_stats *stats);
947367a1092SKalle Valo int libipw_rx(struct libipw_device *ieee, struct sk_buff *skb,
948367a1092SKalle Valo struct libipw_rx_stats *rx_stats);
949367a1092SKalle Valo /* make sure to set stats->len */
950367a1092SKalle Valo void libipw_rx_mgt(struct libipw_device *ieee, struct libipw_hdr_4addr *header,
951367a1092SKalle Valo struct libipw_rx_stats *stats);
952367a1092SKalle Valo
953367a1092SKalle Valo /* libipw_geo.c */
954367a1092SKalle Valo const struct libipw_geo *libipw_get_geo(struct libipw_device *ieee);
955367a1092SKalle Valo void libipw_set_geo(struct libipw_device *ieee, const struct libipw_geo *geo);
956367a1092SKalle Valo
957367a1092SKalle Valo int libipw_is_valid_channel(struct libipw_device *ieee, u8 channel);
958367a1092SKalle Valo int libipw_channel_to_index(struct libipw_device *ieee, u8 channel);
959367a1092SKalle Valo u8 libipw_freq_to_channel(struct libipw_device *ieee, u32 freq);
960367a1092SKalle Valo u8 libipw_get_channel_flags(struct libipw_device *ieee, u8 channel);
961367a1092SKalle Valo const struct libipw_channel *libipw_get_channel(struct libipw_device *ieee,
962367a1092SKalle Valo u8 channel);
963367a1092SKalle Valo u32 libipw_channel_to_freq(struct libipw_device *ieee, u8 channel);
964367a1092SKalle Valo
965367a1092SKalle Valo /* libipw_wx.c */
966367a1092SKalle Valo int libipw_wx_get_scan(struct libipw_device *ieee, struct iw_request_info *info,
967367a1092SKalle Valo union iwreq_data *wrqu, char *key);
968367a1092SKalle Valo int libipw_wx_set_encode(struct libipw_device *ieee,
969367a1092SKalle Valo struct iw_request_info *info, union iwreq_data *wrqu,
970367a1092SKalle Valo char *key);
971367a1092SKalle Valo int libipw_wx_get_encode(struct libipw_device *ieee,
972367a1092SKalle Valo struct iw_request_info *info, union iwreq_data *wrqu,
973367a1092SKalle Valo char *key);
974367a1092SKalle Valo int libipw_wx_set_encodeext(struct libipw_device *ieee,
975367a1092SKalle Valo struct iw_request_info *info,
976367a1092SKalle Valo union iwreq_data *wrqu, char *extra);
977367a1092SKalle Valo int libipw_wx_get_encodeext(struct libipw_device *ieee,
978367a1092SKalle Valo struct iw_request_info *info,
979367a1092SKalle Valo union iwreq_data *wrqu, char *extra);
980367a1092SKalle Valo
libipw_increment_scans(struct libipw_device * ieee)981367a1092SKalle Valo static inline void libipw_increment_scans(struct libipw_device *ieee)
982367a1092SKalle Valo {
983367a1092SKalle Valo ieee->scans++;
984367a1092SKalle Valo }
985367a1092SKalle Valo
libipw_get_scans(struct libipw_device * ieee)986367a1092SKalle Valo static inline int libipw_get_scans(struct libipw_device *ieee)
987367a1092SKalle Valo {
988367a1092SKalle Valo return ieee->scans;
989367a1092SKalle Valo }
990367a1092SKalle Valo
991367a1092SKalle Valo #endif /* LIBIPW_H */
992