Commit | Line | Data |
---|---|---|
cf3e6881 AB |
1 | /****************************************************************************** |
2 | * | |
3 | * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or modify it | |
6 | * under the terms of version 2 of the GNU General Public License as | |
7 | * published by the Free Software Foundation. | |
8 | * | |
9 | * This program is distributed in the hope that it will be useful, but WITHOUT | |
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
12 | * more details. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License along with | |
15 | * this program; if not, write to the Free Software Foundation, Inc., | |
16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA | |
17 | * | |
18 | * Modifications for inclusion into the Linux staging tree are | |
19 | * Copyright(c) 2010 Larry Finger. All rights reserved. | |
20 | * | |
21 | * Contact information: | |
22 | * WLAN FAE <wlanfae@realtek.com> | |
23 | * Larry Finger <Larry.Finger@lwfinger.net> | |
24 | * | |
25 | ******************************************************************************/ | |
2865d42c LF |
26 | #ifndef __IEEE80211_H |
27 | #define __IEEE80211_H | |
28 | ||
29 | #include "osdep_service.h" | |
30 | #include "drv_types.h" | |
31 | #include "wifi.h" | |
40878364 | 32 | #include <linux/compiler.h> |
2865d42c LF |
33 | #include <linux/wireless.h> |
34 | ||
35 | #define MGMT_QUEUE_NUM 5 | |
36 | #define ETH_ALEN 6 | |
37 | #define IEEE_CMD_SET_WPA_PARAM 1 | |
38 | #define IEEE_CMD_SET_WPA_IE 2 | |
39 | #define IEEE_CMD_SET_ENCRYPTION 3 | |
40 | #define IEEE_CMD_MLME 4 | |
41 | ||
42 | #define IEEE_PARAM_WPA_ENABLED 1 | |
43 | #define IEEE_PARAM_TKIP_COUNTERMEASURES 2 | |
44 | #define IEEE_PARAM_DROP_UNENCRYPTED 3 | |
45 | #define IEEE_PARAM_PRIVACY_INVOKED 4 | |
46 | #define IEEE_PARAM_AUTH_ALGS 5 | |
47 | #define IEEE_PARAM_IEEE_802_1X 6 | |
48 | #define IEEE_PARAM_WPAX_SELECT 7 | |
49 | ||
50 | #define AUTH_ALG_OPEN_SYSTEM 0x1 | |
51 | #define AUTH_ALG_SHARED_KEY 0x2 | |
52 | #define AUTH_ALG_LEAP 0x00000004 | |
53 | ||
54 | #define IEEE_MLME_STA_DEAUTH 1 | |
55 | #define IEEE_MLME_STA_DISASSOC 2 | |
56 | ||
57 | #define IEEE_CRYPT_ERR_UNKNOWN_ALG 2 | |
58 | #define IEEE_CRYPT_ERR_UNKNOWN_ADDR 3 | |
59 | #define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED 4 | |
60 | #define IEEE_CRYPT_ERR_KEY_SET_FAILED 5 | |
61 | #define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED 6 | |
62 | #define IEEE_CRYPT_ERR_CARD_CONF_FAILED 7 | |
63 | ||
64 | ||
65 | #define IEEE_CRYPT_ALG_NAME_LEN 16 | |
66 | ||
67 | #define WPA_CIPHER_NONE BIT(0) | |
68 | #define WPA_CIPHER_WEP40 BIT(1) | |
69 | #define WPA_CIPHER_WEP104 BIT(2) | |
70 | #define WPA_CIPHER_TKIP BIT(3) | |
71 | #define WPA_CIPHER_CCMP BIT(4) | |
72 | ||
73 | ||
74 | ||
75 | #define WPA_SELECTOR_LEN 4 | |
76 | #define RSN_HEADER_LEN 4 | |
77 | ||
78 | #define RSN_SELECTOR_LEN 4 | |
79 | ||
80 | enum NETWORK_TYPE { | |
81 | WIRELESS_INVALID = 0, | |
82 | WIRELESS_11B = 1, | |
83 | WIRELESS_11G = 2, | |
84 | WIRELESS_11BG = (WIRELESS_11B | WIRELESS_11G), | |
85 | WIRELESS_11A = 4, | |
86 | WIRELESS_11N = 8, | |
87 | WIRELESS_11GN = (WIRELESS_11G | WIRELESS_11N), | |
88 | WIRELESS_11BGN = (WIRELESS_11B | WIRELESS_11G | WIRELESS_11N), | |
89 | }; | |
90 | ||
91 | ||
92 | struct ieee_param { | |
93 | u32 cmd; | |
94 | u8 sta_addr[ETH_ALEN]; | |
95 | union { | |
96 | struct { | |
97 | u8 name; | |
98 | u32 value; | |
99 | } wpa_param; | |
100 | struct { | |
101 | u32 len; | |
102 | u8 reserved[32]; | |
103 | u8 data[0]; | |
104 | } wpa_ie; | |
0593758e | 105 | struct { |
2865d42c LF |
106 | int command; |
107 | int reason_code; | |
108 | } mlme; | |
109 | struct { | |
110 | u8 alg[IEEE_CRYPT_ALG_NAME_LEN]; | |
111 | u8 set_tx; | |
112 | u32 err; | |
113 | u8 idx; | |
114 | u8 seq[8]; /* sequence counter (set: RX, get: TX) */ | |
115 | u16 key_len; | |
116 | u8 key[0]; | |
117 | } crypt; | |
118 | } u; | |
119 | }; | |
120 | ||
121 | #define IEEE80211_DATA_LEN 2304 | |
122 | /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section | |
123 | 6.2.1.1.2. | |
124 | ||
125 | The figure in section 7.1.2 suggests a body size of up to 2312 | |
126 | bytes is allowed, which is a bit confusing, I suspect this | |
127 | represents the 2304 bytes of real data, plus a possible 8 bytes of | |
128 | WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */ | |
129 | ||
130 | #define IEEE80211_HLEN 30 | |
131 | #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN) | |
132 | ||
133 | /* this is stolen from ipw2200 driver */ | |
134 | #define IEEE_IBSS_MAC_HASH_SIZE 31 | |
135 | ||
136 | struct ieee_ibss_seq { | |
137 | u8 mac[ETH_ALEN]; | |
138 | u16 seq_num; | |
139 | u16 frag_num; | |
ee5b1aad | 140 | unsigned long packet_time; |
2865d42c LF |
141 | struct list_head list; |
142 | }; | |
143 | ||
144 | struct ieee80211_hdr { | |
145 | u16 frame_ctl; | |
146 | u16 duration_id; | |
147 | u8 addr1[ETH_ALEN]; | |
148 | u8 addr2[ETH_ALEN]; | |
149 | u8 addr3[ETH_ALEN]; | |
150 | u16 seq_ctl; | |
151 | u8 addr4[ETH_ALEN]; | |
40878364 | 152 | } __packed; |
2865d42c LF |
153 | |
154 | struct ieee80211_hdr_3addr { | |
155 | u16 frame_ctl; | |
156 | u16 duration_id; | |
157 | u8 addr1[ETH_ALEN]; | |
158 | u8 addr2[ETH_ALEN]; | |
159 | u8 addr3[ETH_ALEN]; | |
160 | u16 seq_ctl; | |
40878364 | 161 | } __packed; |
2865d42c LF |
162 | |
163 | ||
164 | struct ieee80211_hdr_qos { | |
165 | u16 frame_ctl; | |
166 | u16 duration_id; | |
167 | u8 addr1[ETH_ALEN]; | |
168 | u8 addr2[ETH_ALEN]; | |
169 | u8 addr3[ETH_ALEN]; | |
170 | u16 seq_ctl; | |
171 | u8 addr4[ETH_ALEN]; | |
172 | u16 qc; | |
40878364 | 173 | } __packed; |
2865d42c LF |
174 | |
175 | struct ieee80211_hdr_3addr_qos { | |
176 | u16 frame_ctl; | |
177 | u16 duration_id; | |
0593758e JM |
178 | u8 addr1[ETH_ALEN]; |
179 | u8 addr2[ETH_ALEN]; | |
180 | u8 addr3[ETH_ALEN]; | |
2865d42c | 181 | u16 seq_ctl; |
0593758e | 182 | u16 qc; |
40878364 | 183 | } __packed; |
2865d42c LF |
184 | |
185 | struct eapol { | |
186 | u8 snap[6]; | |
187 | u16 ethertype; | |
188 | u8 version; | |
189 | u8 type; | |
190 | u16 length; | |
40878364 | 191 | } __packed; |
2865d42c LF |
192 | |
193 | ||
194 | enum eap_type { | |
195 | EAP_PACKET = 0, | |
196 | EAPOL_START, | |
197 | EAPOL_LOGOFF, | |
198 | EAPOL_KEY, | |
199 | EAPOL_ENCAP_ASF_ALERT | |
200 | }; | |
201 | ||
202 | #define IEEE80211_3ADDR_LEN 24 | |
203 | #define IEEE80211_4ADDR_LEN 30 | |
204 | #define IEEE80211_FCS_LEN 4 | |
205 | ||
206 | #define MIN_FRAG_THRESHOLD 256U | |
207 | #define MAX_FRAG_THRESHOLD 2346U | |
208 | ||
209 | /* Frame control field constants */ | |
210 | #define IEEE80211_FCTL_VERS 0x0002 | |
211 | #define IEEE80211_FCTL_FTYPE 0x000c | |
212 | #define IEEE80211_FCTL_STYPE 0x00f0 | |
213 | #define IEEE80211_FCTL_TODS 0x0100 | |
214 | #define IEEE80211_FCTL_FROMDS 0x0200 | |
215 | #define IEEE80211_FCTL_MOREFRAGS 0x0400 | |
216 | #define IEEE80211_FCTL_RETRY 0x0800 | |
217 | #define IEEE80211_FCTL_PM 0x1000 | |
218 | #define IEEE80211_FCTL_MOREDATA 0x2000 | |
219 | #define IEEE80211_FCTL_WEP 0x4000 | |
220 | #define IEEE80211_FCTL_ORDER 0x8000 | |
221 | ||
222 | #define IEEE80211_FTYPE_MGMT 0x0000 | |
223 | #define IEEE80211_FTYPE_CTL 0x0004 | |
224 | #define IEEE80211_FTYPE_DATA 0x0008 | |
225 | ||
226 | /* management */ | |
227 | #define IEEE80211_STYPE_ASSOC_REQ 0x0000 | |
228 | #define IEEE80211_STYPE_ASSOC_RESP 0x0010 | |
229 | #define IEEE80211_STYPE_REASSOC_REQ 0x0020 | |
230 | #define IEEE80211_STYPE_REASSOC_RESP 0x0030 | |
231 | #define IEEE80211_STYPE_PROBE_REQ 0x0040 | |
232 | #define IEEE80211_STYPE_PROBE_RESP 0x0050 | |
233 | #define IEEE80211_STYPE_BEACON 0x0080 | |
234 | #define IEEE80211_STYPE_ATIM 0x0090 | |
235 | #define IEEE80211_STYPE_DISASSOC 0x00A0 | |
236 | #define IEEE80211_STYPE_AUTH 0x00B0 | |
237 | #define IEEE80211_STYPE_DEAUTH 0x00C0 | |
238 | ||
239 | /* control */ | |
240 | #define IEEE80211_STYPE_PSPOLL 0x00A0 | |
241 | #define IEEE80211_STYPE_RTS 0x00B0 | |
242 | #define IEEE80211_STYPE_CTS 0x00C0 | |
243 | #define IEEE80211_STYPE_ACK 0x00D0 | |
244 | #define IEEE80211_STYPE_CFEND 0x00E0 | |
245 | #define IEEE80211_STYPE_CFENDACK 0x00F0 | |
246 | ||
247 | /* data */ | |
248 | #define IEEE80211_STYPE_DATA 0x0000 | |
249 | #define IEEE80211_STYPE_DATA_CFACK 0x0010 | |
250 | #define IEEE80211_STYPE_DATA_CFPOLL 0x0020 | |
251 | #define IEEE80211_STYPE_DATA_CFACKPOLL 0x0030 | |
252 | #define IEEE80211_STYPE_NULLFUNC 0x0040 | |
253 | #define IEEE80211_STYPE_CFACK 0x0050 | |
254 | #define IEEE80211_STYPE_CFPOLL 0x0060 | |
255 | #define IEEE80211_STYPE_CFACKPOLL 0x0070 | |
256 | #define IEEE80211_QOS_DATAGRP 0x0080 | |
257 | #define IEEE80211_QoS_DATAGRP IEEE80211_QOS_DATAGRP | |
258 | ||
259 | #define IEEE80211_SCTL_FRAG 0x000F | |
260 | #define IEEE80211_SCTL_SEQ 0xFFF0 | |
261 | ||
262 | /* QoS,QOS */ | |
263 | #define NORMAL_ACK 0 | |
264 | #define NO_ACK 1 | |
265 | #define NON_EXPLICIT_ACK 2 | |
266 | #define BLOCK_ACK 3 | |
267 | ||
268 | #ifndef ETH_P_PAE | |
269 | #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */ | |
270 | #endif /* ETH_P_PAE */ | |
271 | ||
272 | #define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */ | |
273 | ||
274 | #define ETH_P_ECONET 0x0018 | |
275 | ||
276 | #ifndef ETH_P_80211_RAW | |
277 | #define ETH_P_80211_RAW (ETH_P_ECONET + 1) | |
278 | #endif | |
279 | ||
280 | /* IEEE 802.11 defines */ | |
281 | ||
282 | #define P80211_OUI_LEN 3 | |
283 | ||
284 | struct ieee80211_snap_hdr { | |
285 | u8 dsap; /* always 0xAA */ | |
286 | u8 ssap; /* always 0xAA */ | |
287 | u8 ctrl; /* always 0x03 */ | |
288 | u8 oui[P80211_OUI_LEN]; /* organizational universal id */ | |
40878364 | 289 | } __packed; |
2865d42c LF |
290 | |
291 | #define SNAP_SIZE sizeof(struct ieee80211_snap_hdr) | |
292 | ||
293 | #define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE) | |
294 | #define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE) | |
295 | ||
296 | #define WLAN_QC_GET_TID(qc) ((qc) & 0x0f) | |
297 | ||
298 | #define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG) | |
299 | #define WLAN_GET_SEQ_SEQ(seq) ((seq) & IEEE80211_SCTL_SEQ) | |
300 | ||
301 | /* Authentication algorithms */ | |
302 | #define WLAN_AUTH_OPEN 0 | |
303 | #define WLAN_AUTH_SHARED_KEY 1 | |
304 | ||
305 | #define WLAN_AUTH_CHALLENGE_LEN 128 | |
306 | ||
307 | #define WLAN_CAPABILITY_BSS (1<<0) | |
308 | #define WLAN_CAPABILITY_IBSS (1<<1) | |
309 | #define WLAN_CAPABILITY_CF_POLLABLE (1<<2) | |
310 | #define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3) | |
311 | #define WLAN_CAPABILITY_PRIVACY (1<<4) | |
312 | #define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5) | |
313 | #define WLAN_CAPABILITY_PBCC (1<<6) | |
314 | #define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7) | |
315 | #define WLAN_CAPABILITY_SHORT_SLOT (1<<10) | |
316 | ||
317 | /* Status codes */ | |
318 | #define WLAN_STATUS_SUCCESS 0 | |
319 | #define WLAN_STATUS_UNSPECIFIED_FAILURE 1 | |
320 | #define WLAN_STATUS_CAPS_UNSUPPORTED 10 | |
321 | #define WLAN_STATUS_REASSOC_NO_ASSOC 11 | |
322 | #define WLAN_STATUS_ASSOC_DENIED_UNSPEC 12 | |
323 | #define WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG 13 | |
324 | #define WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION 14 | |
325 | #define WLAN_STATUS_CHALLENGE_FAIL 15 | |
326 | #define WLAN_STATUS_AUTH_TIMEOUT 16 | |
327 | #define WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA 17 | |
328 | #define WLAN_STATUS_ASSOC_DENIED_RATES 18 | |
329 | /* 802.11b */ | |
330 | #define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19 | |
331 | #define WLAN_STATUS_ASSOC_DENIED_NOPBCC 20 | |
332 | #define WLAN_STATUS_ASSOC_DENIED_NOAGILITY 21 | |
333 | ||
334 | /* Reason codes */ | |
335 | #define WLAN_REASON_UNSPECIFIED 1 | |
336 | #define WLAN_REASON_PREV_AUTH_NOT_VALID 2 | |
337 | #define WLAN_REASON_DEAUTH_LEAVING 3 | |
338 | #define WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY 4 | |
339 | #define WLAN_REASON_DISASSOC_AP_BUSY 5 | |
340 | #define WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA 6 | |
341 | #define WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA 7 | |
342 | #define WLAN_REASON_DISASSOC_STA_HAS_LEFT 8 | |
343 | #define WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH 9 | |
344 | ||
345 | ||
346 | /* Information Element IDs */ | |
347 | #define WLAN_EID_SSID 0 | |
348 | #define WLAN_EID_SUPP_RATES 1 | |
349 | #define WLAN_EID_FH_PARAMS 2 | |
350 | #define WLAN_EID_DS_PARAMS 3 | |
351 | #define WLAN_EID_CF_PARAMS 4 | |
352 | #define WLAN_EID_TIM 5 | |
353 | #define WLAN_EID_IBSS_PARAMS 6 | |
354 | #define WLAN_EID_CHALLENGE 16 | |
355 | #define WLAN_EID_RSN 48 | |
356 | #define WLAN_EID_GENERIC 221 | |
357 | ||
358 | #define IEEE80211_MGMT_HDR_LEN 24 | |
359 | #define IEEE80211_DATA_HDR3_LEN 24 | |
360 | #define IEEE80211_DATA_HDR4_LEN 30 | |
361 | ||
362 | ||
363 | #define IEEE80211_STATMASK_SIGNAL (1<<0) | |
364 | #define IEEE80211_STATMASK_RSSI (1<<1) | |
365 | #define IEEE80211_STATMASK_NOISE (1<<2) | |
366 | #define IEEE80211_STATMASK_RATE (1<<3) | |
367 | #define IEEE80211_STATMASK_WEMASK 0x7 | |
368 | ||
369 | ||
370 | #define IEEE80211_CCK_MODULATION (1<<0) | |
371 | #define IEEE80211_OFDM_MODULATION (1<<1) | |
372 | ||
373 | #define IEEE80211_24GHZ_BAND (1<<0) | |
374 | #define IEEE80211_52GHZ_BAND (1<<1) | |
375 | ||
376 | #define IEEE80211_CCK_RATE_LEN 4 | |
377 | #define IEEE80211_NUM_OFDM_RATESLEN 8 | |
378 | ||
379 | ||
380 | #define IEEE80211_CCK_RATE_1MB 0x02 | |
381 | #define IEEE80211_CCK_RATE_2MB 0x04 | |
382 | #define IEEE80211_CCK_RATE_5MB 0x0B | |
383 | #define IEEE80211_CCK_RATE_11MB 0x16 | |
384 | #define IEEE80211_OFDM_RATE_LEN 8 | |
385 | #define IEEE80211_OFDM_RATE_6MB 0x0C | |
386 | #define IEEE80211_OFDM_RATE_9MB 0x12 | |
387 | #define IEEE80211_OFDM_RATE_12MB 0x18 | |
388 | #define IEEE80211_OFDM_RATE_18MB 0x24 | |
389 | #define IEEE80211_OFDM_RATE_24MB 0x30 | |
390 | #define IEEE80211_OFDM_RATE_36MB 0x48 | |
391 | #define IEEE80211_OFDM_RATE_48MB 0x60 | |
392 | #define IEEE80211_OFDM_RATE_54MB 0x6C | |
393 | #define IEEE80211_BASIC_RATE_MASK 0x80 | |
394 | ||
395 | #define IEEE80211_CCK_RATE_1MB_MASK (1<<0) | |
396 | #define IEEE80211_CCK_RATE_2MB_MASK (1<<1) | |
397 | #define IEEE80211_CCK_RATE_5MB_MASK (1<<2) | |
398 | #define IEEE80211_CCK_RATE_11MB_MASK (1<<3) | |
399 | #define IEEE80211_OFDM_RATE_6MB_MASK (1<<4) | |
400 | #define IEEE80211_OFDM_RATE_9MB_MASK (1<<5) | |
401 | #define IEEE80211_OFDM_RATE_12MB_MASK (1<<6) | |
402 | #define IEEE80211_OFDM_RATE_18MB_MASK (1<<7) | |
403 | #define IEEE80211_OFDM_RATE_24MB_MASK (1<<8) | |
404 | #define IEEE80211_OFDM_RATE_36MB_MASK (1<<9) | |
405 | #define IEEE80211_OFDM_RATE_48MB_MASK (1<<10) | |
406 | #define IEEE80211_OFDM_RATE_54MB_MASK (1<<11) | |
407 | ||
408 | #define IEEE80211_CCK_RATES_MASK 0x0000000F | |
409 | #define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \ | |
410 | IEEE80211_CCK_RATE_2MB_MASK) | |
411 | #define IEEE80211_CCK_DEFAULT_RATES_MASK (IEEE80211_CCK_BASIC_RATES_MASK | \ | |
412 | IEEE80211_CCK_RATE_5MB_MASK | \ | |
413 | IEEE80211_CCK_RATE_11MB_MASK) | |
414 | ||
415 | #define IEEE80211_OFDM_RATES_MASK 0x00000FF0 | |
416 | #define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \ | |
417 | IEEE80211_OFDM_RATE_12MB_MASK | \ | |
418 | IEEE80211_OFDM_RATE_24MB_MASK) | |
419 | #define IEEE80211_OFDM_DEFAULT_RATES_MASK (IEEE80211_OFDM_BASIC_RATES_MASK | \ | |
420 | IEEE80211_OFDM_RATE_9MB_MASK | \ | |
421 | IEEE80211_OFDM_RATE_18MB_MASK | \ | |
422 | IEEE80211_OFDM_RATE_36MB_MASK | \ | |
423 | IEEE80211_OFDM_RATE_48MB_MASK | \ | |
424 | IEEE80211_OFDM_RATE_54MB_MASK) | |
425 | #define IEEE80211_DEFAULT_RATES_MASK (IEEE80211_OFDM_DEFAULT_RATES_MASK | \ | |
426 | IEEE80211_CCK_DEFAULT_RATES_MASK) | |
427 | ||
428 | #define IEEE80211_NUM_OFDM_RATES 8 | |
429 | #define IEEE80211_NUM_CCK_RATES 4 | |
430 | #define IEEE80211_OFDM_SHIFT_MASK_A 4 | |
431 | ||
432 | ||
433 | ||
434 | ||
435 | /* NOTE: This data is for statistical purposes; not all hardware provides this | |
436 | * information for frames received. Not setting these will not cause | |
437 | * any adverse affects. */ | |
438 | struct ieee80211_rx_stats { | |
439 | s8 rssi; | |
440 | u8 signal; | |
441 | u8 noise; | |
442 | u8 received_channel; | |
443 | u16 rate; /* in 100 kbps */ | |
444 | u8 mask; | |
445 | u8 freq; | |
446 | u16 len; | |
447 | }; | |
448 | ||
449 | /* IEEE 802.11 requires that STA supports concurrent reception of at least | |
450 | * three fragmented frames. This define can be increased to support more | |
451 | * concurrent frames, but it should be noted that each entry can consume about | |
452 | * 2 kB of RAM and increasing cache size will slow down frame reassembly. */ | |
453 | #define IEEE80211_FRAG_CACHE_LEN 4 | |
454 | ||
455 | struct ieee80211_frag_entry { | |
456 | u32 first_frag_time; | |
457 | uint seq; | |
458 | uint last_frag; | |
459 | uint qos; /*jackson*/ | |
460 | uint tid; /*jackson*/ | |
461 | struct sk_buff *skb; | |
462 | u8 src_addr[ETH_ALEN]; | |
463 | u8 dst_addr[ETH_ALEN]; | |
464 | }; | |
465 | ||
466 | struct ieee80211_stats { | |
467 | uint tx_unicast_frames; | |
468 | uint tx_multicast_frames; | |
469 | uint tx_fragments; | |
470 | uint tx_unicast_octets; | |
471 | uint tx_multicast_octets; | |
472 | uint tx_deferred_transmissions; | |
473 | uint tx_single_retry_frames; | |
474 | uint tx_multiple_retry_frames; | |
475 | uint tx_retry_limit_exceeded; | |
476 | uint tx_discards; | |
477 | uint rx_unicast_frames; | |
478 | uint rx_multicast_frames; | |
479 | uint rx_fragments; | |
480 | uint rx_unicast_octets; | |
481 | uint rx_multicast_octets; | |
482 | uint rx_fcs_errors; | |
483 | uint rx_discards_no_buffer; | |
484 | uint tx_discards_wrong_sa; | |
485 | uint rx_discards_undecryptable; | |
486 | uint rx_message_in_msg_fragments; | |
487 | uint rx_message_in_bad_msg_fragments; | |
488 | }; | |
489 | ||
0593758e | 490 | struct ieee80211_softmac_stats { |
2865d42c LF |
491 | uint rx_ass_ok; |
492 | uint rx_ass_err; | |
493 | uint rx_probe_rq; | |
494 | uint tx_probe_rs; | |
495 | uint tx_beacons; | |
496 | uint rx_auth_rq; | |
497 | uint rx_auth_rs_ok; | |
498 | uint rx_auth_rs_err; | |
499 | uint tx_auth_rq; | |
500 | uint no_auth_rs; | |
501 | uint no_ass_rs; | |
502 | uint tx_ass_rq; | |
503 | uint rx_ass_rq; | |
504 | uint tx_probe_rq; | |
505 | uint reassoc; | |
506 | uint swtxstop; | |
507 | uint swtxawake; | |
508 | }; | |
509 | ||
510 | #define SEC_KEY_1 (1<<0) | |
511 | #define SEC_KEY_2 (1<<1) | |
512 | #define SEC_KEY_3 (1<<2) | |
513 | #define SEC_KEY_4 (1<<3) | |
514 | #define SEC_ACTIVE_KEY (1<<4) | |
515 | #define SEC_AUTH_MODE (1<<5) | |
516 | #define SEC_UNICAST_GROUP (1<<6) | |
517 | #define SEC_LEVEL (1<<7) | |
518 | #define SEC_ENABLED (1<<8) | |
519 | ||
520 | #define SEC_LEVEL_0 0 /* None */ | |
521 | #define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */ | |
522 | #define SEC_LEVEL_2 2 /* Level 1 + TKIP */ | |
523 | #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */ | |
524 | #define SEC_LEVEL_3 4 /* Level 2 + CCMP */ | |
525 | ||
526 | #define WEP_KEYS 4 | |
527 | #define WEP_KEY_LEN 13 | |
528 | ||
529 | struct ieee80211_security { | |
530 | u16 active_key:2, | |
531 | enabled:1, | |
532 | auth_mode:2, | |
533 | auth_algo:4, | |
534 | unicast_uses_group:1; | |
535 | u8 key_sizes[WEP_KEYS]; | |
536 | u8 keys[WEP_KEYS][WEP_KEY_LEN]; | |
537 | u8 level; | |
538 | u16 flags; | |
40878364 | 539 | } __packed; |
2865d42c LF |
540 | |
541 | /* | |
542 | ||
543 | 802.11 data frame from AP | |
544 | ||
545 | ,-------------------------------------------------------------------. | |
546 | Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 | | |
547 | |------|------|---------|---------|---------|------|---------|------| | |
548 | Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs | | |
549 | | | tion | (BSSID) | | | ence | data | | | |
550 | `-------------------------------------------------------------------' | |
551 | ||
552 | Total: 28-2340 bytes | |
553 | ||
554 | */ | |
555 | ||
556 | struct ieee80211_header_data { | |
557 | u16 frame_ctl; | |
558 | u16 duration_id; | |
559 | u8 addr1[6]; | |
560 | u8 addr2[6]; | |
561 | u8 addr3[6]; | |
562 | u16 seq_ctrl; | |
563 | }; | |
564 | ||
565 | #define BEACON_PROBE_SSID_ID_POSITION 12 | |
566 | ||
567 | /* Management Frame Information Element Types */ | |
568 | #define MFIE_TYPE_SSID 0 | |
569 | #define MFIE_TYPE_RATES 1 | |
570 | #define MFIE_TYPE_FH_SET 2 | |
571 | #define MFIE_TYPE_DS_SET 3 | |
572 | #define MFIE_TYPE_CF_SET 4 | |
573 | #define MFIE_TYPE_TIM 5 | |
574 | #define MFIE_TYPE_IBSS_SET 6 | |
575 | #define MFIE_TYPE_CHALLENGE 16 | |
576 | #define MFIE_TYPE_ERP 42 | |
577 | #define MFIE_TYPE_RSN 48 | |
578 | #define MFIE_TYPE_RATES_EX 50 | |
579 | #define MFIE_TYPE_GENERIC 221 | |
580 | ||
581 | struct ieee80211_info_element_hdr { | |
582 | u8 id; | |
583 | u8 len; | |
40878364 | 584 | } __packed; |
2865d42c LF |
585 | |
586 | struct ieee80211_info_element { | |
587 | u8 id; | |
588 | u8 len; | |
589 | u8 data[0]; | |
40878364 | 590 | } __packed; |
2865d42c LF |
591 | |
592 | /* | |
593 | * These are the data types that can make up management packets | |
594 | * | |
595 | u16 auth_algorithm; | |
596 | u16 auth_sequence; | |
597 | u16 beacon_interval; | |
598 | u16 capability; | |
599 | u8 current_ap[ETH_ALEN]; | |
600 | u16 listen_interval; | |
601 | struct { | |
602 | u16 association_id:14, reserved:2; | |
40878364 | 603 | } __packed; |
2865d42c LF |
604 | u32 time_stamp[2]; |
605 | u16 reason; | |
606 | u16 status; | |
607 | */ | |
608 | ||
609 | #define IEEE80211_DEFAULT_TX_ESSID "Penguin" | |
610 | #define IEEE80211_DEFAULT_BASIC_RATE 10 | |
611 | ||
612 | struct ieee80211_authentication { | |
613 | struct ieee80211_header_data header; | |
614 | u16 algorithm; | |
615 | u16 transaction; | |
616 | u16 status; | |
40878364 | 617 | } __packed; |
2865d42c LF |
618 | |
619 | struct ieee80211_probe_response { | |
620 | struct ieee80211_header_data header; | |
621 | u32 time_stamp[2]; | |
622 | u16 beacon_interval; | |
623 | u16 capability; | |
624 | struct ieee80211_info_element info_element; | |
40878364 | 625 | } __packed; |
2865d42c LF |
626 | |
627 | struct ieee80211_probe_request { | |
628 | struct ieee80211_header_data header; | |
40878364 | 629 | } __packed; |
2865d42c LF |
630 | |
631 | struct ieee80211_assoc_request_frame { | |
632 | struct ieee80211_hdr_3addr header; | |
633 | u16 capability; | |
634 | u16 listen_interval; | |
635 | struct ieee80211_info_element_hdr info_element; | |
40878364 | 636 | } __packed; |
2865d42c LF |
637 | |
638 | struct ieee80211_assoc_response_frame { | |
639 | struct ieee80211_hdr_3addr header; | |
640 | u16 capability; | |
641 | u16 status; | |
642 | u16 aid; | |
40878364 | 643 | } __packed; |
2865d42c LF |
644 | |
645 | struct ieee80211_txb { | |
646 | u8 nr_frags; | |
647 | u8 encrypted; | |
648 | u16 reserved; | |
649 | u16 frag_size; | |
650 | u16 payload_size; | |
651 | struct sk_buff *fragments[0]; | |
652 | }; | |
653 | ||
654 | /* SWEEP TABLE ENTRIES NUMBER*/ | |
655 | #define MAX_SWEEP_TAB_ENTRIES 42 | |
656 | #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7 | |
657 | /* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs | |
658 | * only use 8, and then use extended rates for the remaining supported | |
659 | * rates. Other APs, however, stick all of their supported rates on the | |
660 | * main rates information element... */ | |
661 | #define MAX_RATES_LENGTH ((u8)12) | |
662 | #define MAX_RATES_EX_LENGTH ((u8)16) | |
663 | #define MAX_NETWORK_COUNT 128 | |
664 | #define MAX_CHANNEL_NUMBER 161 | |
665 | #define IEEE80211_SOFTMAC_SCAN_TIME 400 | |
666 | /*(HZ / 2)*/ | |
667 | #define IEEE80211_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2) | |
668 | ||
669 | #define CRC_LENGTH 4U | |
670 | ||
671 | #define MAX_WPA_IE_LEN 128 | |
2865d42c LF |
672 | |
673 | #define NETWORK_EMPTY_ESSID (1<<0) | |
674 | #define NETWORK_HAS_OFDM (1<<1) | |
675 | #define NETWORK_HAS_CCK (1<<2) | |
676 | ||
677 | #define IEEE80211_DTIM_MBCAST 4 | |
678 | #define IEEE80211_DTIM_UCAST 2 | |
679 | #define IEEE80211_DTIM_VALID 1 | |
680 | #define IEEE80211_DTIM_INVALID 0 | |
681 | ||
682 | #define IEEE80211_PS_DISABLED 0 | |
683 | #define IEEE80211_PS_UNICAST IEEE80211_DTIM_UCAST | |
684 | #define IEEE80211_PS_MBCAST IEEE80211_DTIM_MBCAST | |
685 | #define IW_ESSID_MAX_SIZE 32 | |
686 | /* | |
687 | * join_res: | |
688 | * -1: authentication fail | |
689 | * -2: association fail | |
690 | * > 0: TID | |
691 | */ | |
692 | ||
693 | enum ieee80211_state { | |
694 | /* the card is not linked at all */ | |
695 | IEEE80211_NOLINK = 0, | |
696 | /* IEEE80211_ASSOCIATING* are for BSS client mode | |
697 | * the driver shall not perform RX filtering unless | |
698 | * the state is LINKED. | |
699 | * The driver shall just check for the state LINKED and | |
700 | * defaults to NOLINK for ALL the other states (including | |
701 | * LINKED_SCANNING) | |
702 | */ | |
703 | /* the association procedure will start (wq scheduling)*/ | |
704 | IEEE80211_ASSOCIATING, | |
705 | IEEE80211_ASSOCIATING_RETRY, | |
706 | /* the association procedure is sending AUTH request*/ | |
707 | IEEE80211_ASSOCIATING_AUTHENTICATING, | |
be10ac2b | 708 | /* the association procedure has successfully authenticated |
2865d42c LF |
709 | * and is sending association request |
710 | */ | |
711 | IEEE80211_ASSOCIATING_AUTHENTICATED, | |
712 | /* the link is ok. the card associated to a BSS or linked | |
713 | * to a ibss cell or acting as an AP and creating the bss | |
714 | */ | |
715 | IEEE80211_LINKED, | |
716 | /* same as LINKED, but the driver shall apply RX filter | |
717 | * rules as we are in NO_LINK mode. As the card is still | |
718 | * logically linked, but it is doing a syncro site survey | |
719 | * then it will be back to LINKED state. | |
720 | */ | |
721 | IEEE80211_LINKED_SCANNING, | |
722 | }; | |
723 | ||
724 | #define DEFAULT_MAX_SCAN_AGE (15 * HZ) | |
725 | #define DEFAULT_FTS 2346 | |
726 | ||
727 | #define CFG_IEEE80211_RESERVE_FCS (1<<0) | |
728 | #define CFG_IEEE80211_COMPUTE_FCS (1<<1) | |
729 | ||
730 | #define MAXTID 16 | |
731 | ||
732 | #define IEEE_A (1<<0) | |
733 | #define IEEE_B (1<<1) | |
734 | #define IEEE_G (1<<2) | |
735 | #define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G) | |
736 | ||
737 | extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len) | |
738 | { | |
739 | /* Single white space is for Linksys APs */ | |
740 | if (essid_len == 1 && essid[0] == ' ') | |
741 | return 1; | |
742 | /* Otherwise, if the entire essid is 0, we assume it is hidden */ | |
743 | while (essid_len) { | |
744 | essid_len--; | |
745 | if (essid[essid_len] != '\0') | |
746 | return 0; | |
747 | } | |
748 | return 1; | |
749 | } | |
750 | ||
751 | extern inline int ieee80211_get_hdrlen(u16 fc) | |
752 | { | |
753 | int hdrlen = 24; | |
754 | ||
755 | switch (WLAN_FC_GET_TYPE(fc)) { | |
756 | case IEEE80211_FTYPE_DATA: | |
757 | if (fc & IEEE80211_QOS_DATAGRP) | |
758 | hdrlen += 2; | |
759 | if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS)) | |
760 | hdrlen += 6; /* Addr4 */ | |
761 | break; | |
762 | case IEEE80211_FTYPE_CTL: | |
763 | switch (WLAN_FC_GET_STYPE(fc)) { | |
764 | case IEEE80211_STYPE_CTS: | |
765 | case IEEE80211_STYPE_ACK: | |
766 | hdrlen = 10; | |
767 | break; | |
768 | default: | |
769 | hdrlen = 16; | |
770 | break; | |
771 | } | |
772 | break; | |
773 | } | |
774 | return hdrlen; | |
775 | } | |
776 | ||
777 | struct registry_priv; | |
778 | ||
779 | u8 *r8712_set_ie(u8 *pbuf, sint index, uint len, u8 *source, uint *frlen); | |
c07f9721 | 780 | u8 *r8712_get_ie(u8 *pbuf, sint index, sint *len, sint limit); |
2865d42c | 781 | unsigned char *r8712_get_wpa_ie(unsigned char *pie, int *rsn_ie_len, int limit); |
0593758e JM |
782 | unsigned char *r8712_get_wpa2_ie(unsigned char *pie, int *rsn_ie_len, |
783 | int limit); | |
2865d42c | 784 | int r8712_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, |
0593758e | 785 | int *pairwise_cipher); |
2865d42c | 786 | int r8712_parse_wpa2_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, |
0593758e JM |
787 | int *pairwise_cipher); |
788 | int r8712_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, | |
789 | u8 *wpa_ie, u16 *wpa_len); | |
2865d42c | 790 | int r8712_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen); |
ee5b1aad | 791 | int r8712_generate_ie(struct registry_priv *pregistrypriv); |
2865d42c LF |
792 | uint r8712_is_cckrates_included(u8 *rate); |
793 | uint r8712_is_cckratesonly_included(u8 *rate); | |
794 | ||
795 | #endif /* IEEE80211_H */ | |
796 |