1 /******************************************************************************
2 *
3 * Copyright(c) 2007 - 2011 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 *
19 ******************************************************************************/
20 #ifndef __IEEE80211_H
21 #define __IEEE80211_H
22
23 #include <osdep_service.h>
24 #include <drv_types.h>
25 #include "wifi.h"
26 #include <linux/wireless.h>
27
28 #define MGMT_QUEUE_NUM 5
29
30 #define ETH_ALEN 6
31 #define ETH_TYPE_LEN 2
32 #define PAYLOAD_TYPE_LEN 1
33
34 #ifdef CONFIG_88EU_AP_MODE
35
36 #define RTL_IOCTL_HOSTAPD (SIOCIWFIRSTPRIV + 28)
37
38 /* RTL871X_IOCTL_HOSTAPD ioctl() cmd: */
39 enum {
40 RTL871X_HOSTAPD_FLUSH = 1,
41 RTL871X_HOSTAPD_ADD_STA = 2,
42 RTL871X_HOSTAPD_REMOVE_STA = 3,
43 RTL871X_HOSTAPD_GET_INFO_STA = 4,
44 /* REMOVED: PRISM2_HOSTAPD_RESET_TXEXC_STA = 5, */
45 RTL871X_HOSTAPD_GET_WPAIE_STA = 5,
46 RTL871X_SET_ENCRYPTION = 6,
47 RTL871X_GET_ENCRYPTION = 7,
48 RTL871X_HOSTAPD_SET_FLAGS_STA = 8,
49 RTL871X_HOSTAPD_GET_RID = 9,
50 RTL871X_HOSTAPD_SET_RID = 10,
51 RTL871X_HOSTAPD_SET_ASSOC_AP_ADDR = 11,
52 RTL871X_HOSTAPD_SET_GENERIC_ELEMENT = 12,
53 RTL871X_HOSTAPD_MLME = 13,
54 RTL871X_HOSTAPD_SCAN_REQ = 14,
55 RTL871X_HOSTAPD_STA_CLEAR_STATS = 15,
56 RTL871X_HOSTAPD_SET_BEACON = 16,
57 RTL871X_HOSTAPD_SET_WPS_BEACON = 17,
58 RTL871X_HOSTAPD_SET_WPS_PROBE_RESP = 18,
59 RTL871X_HOSTAPD_SET_WPS_ASSOC_RESP = 19,
60 RTL871X_HOSTAPD_SET_HIDDEN_SSID = 20,
61 RTL871X_HOSTAPD_SET_MACADDR_ACL = 21,
62 RTL871X_HOSTAPD_ACL_ADD_STA = 22,
63 RTL871X_HOSTAPD_ACL_REMOVE_STA = 23,
64 };
65
66 /* STA flags */
67 #define WLAN_STA_AUTH BIT(0)
68 #define WLAN_STA_ASSOC BIT(1)
69 #define WLAN_STA_PS BIT(2)
70 #define WLAN_STA_TIM BIT(3)
71 #define WLAN_STA_PERM BIT(4)
72 #define WLAN_STA_AUTHORIZED BIT(5)
73 #define WLAN_STA_PENDING_POLL BIT(6) /* pending activity poll not ACKed */
74 #define WLAN_STA_SHORT_PREAMBLE BIT(7)
75 #define WLAN_STA_PREAUTH BIT(8)
76 #define WLAN_STA_WME BIT(9)
77 #define WLAN_STA_MFP BIT(10)
78 #define WLAN_STA_HT BIT(11)
79 #define WLAN_STA_WPS BIT(12)
80 #define WLAN_STA_MAYBE_WPS BIT(13)
81 #define WLAN_STA_NONERP BIT(31)
82
83 #endif
84
85 #define IEEE_CMD_SET_WPA_PARAM 1
86 #define IEEE_CMD_SET_WPA_IE 2
87 #define IEEE_CMD_SET_ENCRYPTION 3
88 #define IEEE_CMD_MLME 4
89
90 #define IEEE_PARAM_WPA_ENABLED 1
91 #define IEEE_PARAM_TKIP_COUNTERMEASURES 2
92 #define IEEE_PARAM_DROP_UNENCRYPTED 3
93 #define IEEE_PARAM_PRIVACY_INVOKED 4
94 #define IEEE_PARAM_AUTH_ALGS 5
95 #define IEEE_PARAM_IEEE_802_1X 6
96 #define IEEE_PARAM_WPAX_SELECT 7
97
98 #define AUTH_ALG_OPEN_SYSTEM 0x1
99 #define AUTH_ALG_SHARED_KEY 0x2
100 #define AUTH_ALG_LEAP 0x00000004
101
102 #define IEEE_MLME_STA_DEAUTH 1
103 #define IEEE_MLME_STA_DISASSOC 2
104
105 #define IEEE_CRYPT_ERR_UNKNOWN_ALG 2
106 #define IEEE_CRYPT_ERR_UNKNOWN_ADDR 3
107 #define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED 4
108 #define IEEE_CRYPT_ERR_KEY_SET_FAILED 5
109 #define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED 6
110 #define IEEE_CRYPT_ERR_CARD_CONF_FAILED 7
111
112
113 #define IEEE_CRYPT_ALG_NAME_LEN 16
114
115 #define WPA_CIPHER_NONE BIT(0)
116 #define WPA_CIPHER_WEP40 BIT(1)
117 #define WPA_CIPHER_WEP104 BIT(2)
118 #define WPA_CIPHER_TKIP BIT(3)
119 #define WPA_CIPHER_CCMP BIT(4)
120
121
122
123 #define WPA_SELECTOR_LEN 4
124 extern u8 RTW_WPA_OUI_TYPE[];
125 extern u16 RTW_WPA_VERSION;
126 extern u8 WPA_AUTH_KEY_MGMT_NONE[];
127 extern u8 WPA_AUTH_KEY_MGMT_UNSPEC_802_1X[];
128 extern u8 WPA_AUTH_KEY_MGMT_PSK_OVER_802_1X[];
129 extern u8 WPA_CIPHER_SUITE_NONE[];
130 extern u8 WPA_CIPHER_SUITE_WEP40[];
131 extern u8 WPA_CIPHER_SUITE_TKIP[];
132 extern u8 WPA_CIPHER_SUITE_WRAP[];
133 extern u8 WPA_CIPHER_SUITE_CCMP[];
134 extern u8 WPA_CIPHER_SUITE_WEP104[];
135
136
137 #define RSN_HEADER_LEN 4
138 #define RSN_SELECTOR_LEN 4
139
140 extern u16 RSN_VERSION_BSD;
141 extern u8 RSN_AUTH_KEY_MGMT_UNSPEC_802_1X[];
142 extern u8 RSN_AUTH_KEY_MGMT_PSK_OVER_802_1X[];
143 extern u8 RSN_CIPHER_SUITE_NONE[];
144 extern u8 RSN_CIPHER_SUITE_WEP40[];
145 extern u8 RSN_CIPHER_SUITE_TKIP[];
146 extern u8 RSN_CIPHER_SUITE_WRAP[];
147 extern u8 RSN_CIPHER_SUITE_CCMP[];
148 extern u8 RSN_CIPHER_SUITE_WEP104[];
149
150 enum ratr_table_mode {
151 RATR_INX_WIRELESS_NGB = 0, /* BGN 40 Mhz 2SS 1SS */
152 RATR_INX_WIRELESS_NG = 1, /* GN or N */
153 RATR_INX_WIRELESS_NB = 2, /* BGN 20 Mhz 2SS 1SS or BN */
154 RATR_INX_WIRELESS_N = 3,
155 RATR_INX_WIRELESS_GB = 4,
156 RATR_INX_WIRELESS_G = 5,
157 RATR_INX_WIRELESS_B = 6,
158 RATR_INX_WIRELESS_MC = 7,
159 RATR_INX_WIRELESS_AC_N = 8,
160 };
161
162 enum NETWORK_TYPE {
163 WIRELESS_INVALID = 0,
164 /* Sub-Element */
165 WIRELESS_11B = BIT(0), /* tx:cck only, rx:cck only, hw: cck */
166 WIRELESS_11G = BIT(1), /* tx:ofdm only, rx:ofdm & cck, hw:cck & ofdm*/
167 WIRELESS_11A = BIT(2), /* tx:ofdm only, rx: ofdm only, hw:ofdm only */
168 WIRELESS_11_24N = BIT(3), /* tx:MCS only, rx:MCS & cck, hw:MCS & cck */
169 WIRELESS_11_5N = BIT(4), /* tx:MCS only, rx:MCS & ofdm, hw:ofdm only */
170 WIRELESS_AC = BIT(6),
171
172 /* Combination */
173 /* tx: cck & ofdm, rx: cck & ofdm & MCS, hw: cck & ofdm */
174 WIRELESS_11BG = (WIRELESS_11B | WIRELESS_11G),
175 /* tx: ofdm & MCS, rx: ofdm & cck & MCS, hw: cck & ofdm */
176 WIRELESS_11G_24N = (WIRELESS_11G | WIRELESS_11_24N),
177 /* tx: ofdm & MCS, rx: ofdm & MCS, hw: ofdm only */
178 WIRELESS_11A_5N = (WIRELESS_11A | WIRELESS_11_5N),
179 /* tx: ofdm & cck & MCS, rx: ofdm & cck & MCS, hw: ofdm & cck */
180 WIRELESS_11BG_24N = (WIRELESS_11B | WIRELESS_11G | WIRELESS_11_24N),
181 /* tx: ofdm & MCS, rx: ofdm & MCS, hw: ofdm only */
182 WIRELESS_11AGN = (WIRELESS_11A | WIRELESS_11G | WIRELESS_11_24N |
183 WIRELESS_11_5N),
184 WIRELESS_11ABGN = (WIRELESS_11A | WIRELESS_11B | WIRELESS_11G |
185 WIRELESS_11_24N | WIRELESS_11_5N),
186 };
187
188 #define SUPPORTED_24G_NETTYPE_MSK \
189 (WIRELESS_11B | WIRELESS_11G | WIRELESS_11_24N)
190 #define SUPPORTED_5G_NETTYPE_MSK \
191 (WIRELESS_11A | WIRELESS_11_5N)
192
193 #define IsSupported24G(NetType) \
194 ((NetType) & SUPPORTED_24G_NETTYPE_MSK ? true : false)
195 #define IsSupported5G(NetType) \
196 ((NetType) & SUPPORTED_5G_NETTYPE_MSK ? true : false)
197
198 #define IsEnableHWCCK(NetType) \
199 IsSupported24G(NetType)
200 #define IsEnableHWOFDM(NetType) \
201 ((NetType) & (WIRELESS_11G | WIRELESS_11_24N | \
202 SUPPORTED_5G_NETTYPE_MSK) ? true : false)
203
204 #define IsSupportedRxCCK(NetType) IsEnableHWCCK(NetType)
205 #define IsSupportedRxOFDM(NetType) IsEnableHWOFDM(NetType)
206 #define IsSupportedRxMCS(NetType) IsEnableHWOFDM(NetType)
207
208 #define IsSupportedTxCCK(NetType) \
209 ((NetType) & (WIRELESS_11B) ? true : false)
210 #define IsSupportedTxOFDM(NetType) \
211 ((NetType) & (WIRELESS_11G|WIRELESS_11A) ? true : false)
212 #define IsSupportedTxMCS(NetType) \
213 ((NetType) & (WIRELESS_11_24N|WIRELESS_11_5N) ? true : false)
214
215
216 struct ieee_param {
217 u32 cmd;
218 u8 sta_addr[ETH_ALEN];
219 union {
220 struct {
221 u8 name;
222 u32 value;
223 } wpa_param;
224 struct {
225 u32 len;
226 u8 reserved[32];
227 u8 data[0];
228 } wpa_ie;
229 struct {
230 int command;
231 int reason_code;
232 } mlme;
233 struct {
234 u8 alg[IEEE_CRYPT_ALG_NAME_LEN];
235 u8 set_tx;
236 u32 err;
237 u8 idx;
238 u8 seq[8]; /* sequence counter (set: RX, get: TX) */
239 u16 key_len;
240 u8 key[0];
241 } crypt;
242 #ifdef CONFIG_88EU_AP_MODE
243 struct {
244 u16 aid;
245 u16 capability;
246 int flags;
247 u8 tx_supp_rates[16];
248 struct rtw_ieee80211_ht_cap ht_cap;
249 } add_sta;
250 struct {
251 u8 reserved[2];/* for set max_num_sta */
252 u8 buf[0];
253 } bcn_ie;
254 #endif
255
256 } u;
257 };
258
259 #ifdef CONFIG_88EU_AP_MODE
260 struct ieee_param_ex {
261 u32 cmd;
262 u8 sta_addr[ETH_ALEN];
263 u8 data[0];
264 };
265
266 struct sta_data {
267 u16 aid;
268 u16 capability;
269 int flags;
270 u32 sta_set;
271 u8 tx_supp_rates[16];
272 u32 tx_supp_rates_len;
273 struct rtw_ieee80211_ht_cap ht_cap;
274 u64 rx_pkts;
275 u64 rx_bytes;
276 u64 rx_drops;
277 u64 tx_pkts;
278 u64 tx_bytes;
279 u64 tx_drops;
280 };
281 #endif
282
283 #define IEEE80211_DATA_LEN 2304
284 /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
285 6.2.1.1.2.
286
287 The figure in section 7.1.2 suggests a body size of up to 2312
288 bytes is allowed, which is a bit confusing, I suspect this
289 represents the 2304 bytes of real data, plus a possible 8 bytes of
290 WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
291
292
293 #define IEEE80211_HLEN 30
294 #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
295
296
297 /* this is stolen from ipw2200 driver */
298 #define IEEE_IBSS_MAC_HASH_SIZE 31
299
300 struct ieee_ibss_seq {
301 u8 mac[ETH_ALEN];
302 u16 seq_num;
303 u16 frag_num;
304 unsigned long packet_time;
305 struct list_head list;
306 };
307
308 struct rtw_ieee80211_hdr {
309 __le16 frame_ctl;
310 __le16 duration_id;
311 u8 addr1[ETH_ALEN];
312 u8 addr2[ETH_ALEN];
313 u8 addr3[ETH_ALEN];
314 u16 seq_ctl;
315 u8 addr4[ETH_ALEN];
316 } __packed;
317
318 struct rtw_ieee80211_hdr_3addr {
319 __le16 frame_ctl;
320 __le16 duration_id;
321 u8 addr1[ETH_ALEN];
322 u8 addr2[ETH_ALEN];
323 u8 addr3[ETH_ALEN];
324 u16 seq_ctl;
325 } __packed;
326
327 struct rtw_ieee80211_hdr_qos {
328 __le16 frame_ctl;
329 __le16 duration_id;
330 u8 addr1[ETH_ALEN];
331 u8 addr2[ETH_ALEN];
332 u8 addr3[ETH_ALEN];
333 u16 seq_ctl;
334 u8 addr4[ETH_ALEN];
335 u16 qc;
336 } __packed;
337
338 struct rtw_ieee80211_hdr_3addr_qos {
339 __le16 frame_ctl;
340 __le16 duration_id;
341 u8 addr1[ETH_ALEN];
342 u8 addr2[ETH_ALEN];
343 u8 addr3[ETH_ALEN];
344 u16 seq_ctl;
345 u16 qc;
346 } __packed;
347
348 struct eapol {
349 u8 snap[6];
350 u16 ethertype;
351 u8 version;
352 u8 type;
353 u16 length;
354 } __packed;
355
356 enum eap_type {
357 EAP_PACKET = 0,
358 EAPOL_START,
359 EAPOL_LOGOFF,
360 EAPOL_KEY,
361 EAPOL_ENCAP_ASF_ALERT
362 };
363
364 #define IEEE80211_3ADDR_LEN 24
365 #define IEEE80211_4ADDR_LEN 30
366 #define IEEE80211_FCS_LEN 4
367
368 #define MIN_FRAG_THRESHOLD 256U
369 #define MAX_FRAG_THRESHOLD 2346U
370
371 /* Frame control field constants */
372 #define RTW_IEEE80211_FCTL_VERS 0x0003
373 #define RTW_IEEE80211_FCTL_FTYPE 0x000c
374 #define RTW_IEEE80211_FCTL_STYPE 0x00f0
375 #define RTW_IEEE80211_FCTL_TODS 0x0100
376 #define RTW_IEEE80211_FCTL_FROMDS 0x0200
377 #define RTW_IEEE80211_FCTL_MOREFRAGS 0x0400
378 #define RTW_IEEE80211_FCTL_RETRY 0x0800
379 #define RTW_IEEE80211_FCTL_PM 0x1000
380 #define RTW_IEEE80211_FCTL_MOREDATA 0x2000
381 #define RTW_IEEE80211_FCTL_PROTECTED 0x4000
382 #define RTW_IEEE80211_FCTL_ORDER 0x8000
383 #define RTW_IEEE80211_FCTL_CTL_EXT 0x0f00
384
385 #define RTW_IEEE80211_FTYPE_MGMT 0x0000
386 #define RTW_IEEE80211_FTYPE_CTL 0x0004
387 #define RTW_IEEE80211_FTYPE_DATA 0x0008
388 #define RTW_IEEE80211_FTYPE_EXT 0x000c
389
390 /* management */
391 #define RTW_IEEE80211_STYPE_ASSOC_REQ 0x0000
392 #define RTW_IEEE80211_STYPE_ASSOC_RESP 0x0010
393 #define RTW_IEEE80211_STYPE_REASSOC_REQ 0x0020
394 #define RTW_IEEE80211_STYPE_REASSOC_RESP 0x0030
395 #define RTW_IEEE80211_STYPE_PROBE_REQ 0x0040
396 #define RTW_IEEE80211_STYPE_PROBE_RESP 0x0050
397 #define RTW_IEEE80211_STYPE_BEACON 0x0080
398 #define RTW_IEEE80211_STYPE_ATIM 0x0090
399 #define RTW_IEEE80211_STYPE_DISASSOC 0x00A0
400 #define RTW_IEEE80211_STYPE_AUTH 0x00B0
401 #define RTW_IEEE80211_STYPE_DEAUTH 0x00C0
402 #define RTW_IEEE80211_STYPE_ACTION 0x00D0
403
404 /* control */
405 #define RTW_IEEE80211_STYPE_CTL_EXT 0x0060
406 #define RTW_IEEE80211_STYPE_BACK_REQ 0x0080
407 #define RTW_IEEE80211_STYPE_BACK 0x0090
408 #define RTW_IEEE80211_STYPE_PSPOLL 0x00A0
409 #define RTW_IEEE80211_STYPE_RTS 0x00B0
410 #define RTW_IEEE80211_STYPE_CTS 0x00C0
411 #define RTW_IEEE80211_STYPE_ACK 0x00D0
412 #define RTW_IEEE80211_STYPE_CFEND 0x00E0
413 #define RTW_IEEE80211_STYPE_CFENDACK 0x00F0
414
415 /* data */
416 #define RTW_IEEE80211_STYPE_DATA 0x0000
417 #define RTW_IEEE80211_STYPE_DATA_CFACK 0x0010
418 #define RTW_IEEE80211_STYPE_DATA_CFPOLL 0x0020
419 #define RTW_IEEE80211_STYPE_DATA_CFACKPOLL 0x0030
420 #define RTW_IEEE80211_STYPE_NULLFUNC 0x0040
421 #define RTW_IEEE80211_STYPE_CFACK 0x0050
422 #define RTW_IEEE80211_STYPE_CFPOLL 0x0060
423 #define RTW_IEEE80211_STYPE_CFACKPOLL 0x0070
424 #define RTW_IEEE80211_STYPE_QOS_DATA 0x0080
425 #define RTW_IEEE80211_STYPE_QOS_DATA_CFACK 0x0090
426 #define RTW_IEEE80211_STYPE_QOS_DATA_CFPOLL 0x00A0
427 #define RTW_IEEE80211_STYPE_QOS_DATA_CFACKPOLL 0x00B0
428 #define RTW_IEEE80211_STYPE_QOS_NULLFUNC 0x00C0
429 #define RTW_IEEE80211_STYPE_QOS_CFACK 0x00D0
430 #define RTW_IEEE80211_STYPE_QOS_CFPOLL 0x00E0
431 #define RTW_IEEE80211_STYPE_QOS_CFACKPOLL 0x00F0
432
433 /* sequence control field */
434 #define RTW_IEEE80211_SCTL_FRAG 0x000F
435 #define RTW_IEEE80211_SCTL_SEQ 0xFFF0
436
437
438 #define RTW_ERP_INFO_NON_ERP_PRESENT BIT(0)
439 #define RTW_ERP_INFO_USE_PROTECTION BIT(1)
440 #define RTW_ERP_INFO_BARKER_PREAMBLE_MODE BIT(2)
441
442 /* QoS, QOS */
443 #define NORMAL_ACK 0
444 #define NO_ACK 1
445 #define NON_EXPLICIT_ACK 2
446 #define BLOCK_ACK 3
447
448 #ifndef ETH_P_PAE
449 #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
450 #endif /* ETH_P_PAE */
451
452 #define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
453
454 #define ETH_P_ECONET 0x0018
455
456 #ifndef ETH_P_80211_RAW
457 #define ETH_P_80211_RAW (ETH_P_ECONET + 1)
458 #endif
459
460 /* IEEE 802.11 defines */
461
462 #define P80211_OUI_LEN 3
463
464 struct ieee80211_snap_hdr {
465 u8 dsap; /* always 0xAA */
466 u8 ssap; /* always 0xAA */
467 u8 ctrl; /* always 0x03 */
468 u8 oui[P80211_OUI_LEN]; /* organizational universal id */
469 } __packed;
470
471 #define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
472
473 #define WLAN_FC_GET_TYPE(fc) ((fc) & RTW_IEEE80211_FCTL_FTYPE)
474 #define WLAN_FC_GET_STYPE(fc) ((fc) & RTW_IEEE80211_FCTL_STYPE)
475
476 #define WLAN_QC_GET_TID(qc) ((qc) & 0x0f)
477
478 #define WLAN_GET_SEQ_FRAG(seq) ((seq) & RTW_IEEE80211_SCTL_FRAG)
479 #define WLAN_GET_SEQ_SEQ(seq) ((seq) & RTW_IEEE80211_SCTL_SEQ)
480
481 /* Authentication algorithms */
482 #define WLAN_AUTH_OPEN 0
483 #define WLAN_AUTH_SHARED_KEY 1
484
485 #define WLAN_AUTH_CHALLENGE_LEN 128
486
487 #define WLAN_CAPABILITY_BSS (1<<0)
488 #define WLAN_CAPABILITY_IBSS (1<<1)
489 #define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
490 #define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
491 #define WLAN_CAPABILITY_PRIVACY (1<<4)
492 #define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
493 #define WLAN_CAPABILITY_PBCC (1<<6)
494 #define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
495 #define WLAN_CAPABILITY_SHORT_SLOT (1<<10)
496
497 /* Status codes */
498 #define WLAN_STATUS_SUCCESS 0
499 #define WLAN_STATUS_UNSPECIFIED_FAILURE 1
500 #define WLAN_STATUS_CAPS_UNSUPPORTED 10
501 #define WLAN_STATUS_REASSOC_NO_ASSOC 11
502 #define WLAN_STATUS_ASSOC_DENIED_UNSPEC 12
503 #define WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG 13
504 #define WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION 14
505 #define WLAN_STATUS_CHALLENGE_FAIL 15
506 #define WLAN_STATUS_AUTH_TIMEOUT 16
507 #define WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA 17
508 #define WLAN_STATUS_ASSOC_DENIED_RATES 18
509 /* 802.11b */
510 #define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19
511 #define WLAN_STATUS_ASSOC_DENIED_NOPBCC 20
512 #define WLAN_STATUS_ASSOC_DENIED_NOAGILITY 21
513
514 /* Reason codes */
515 #define WLAN_REASON_UNSPECIFIED 1
516 #define WLAN_REASON_PREV_AUTH_NOT_VALID 2
517 #define WLAN_REASON_DEAUTH_LEAVING 3
518 #define WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY 4
519 #define WLAN_REASON_DISASSOC_AP_BUSY 5
520 #define WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA 6
521 #define WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA 7
522 #define WLAN_REASON_DISASSOC_STA_HAS_LEFT 8
523 #define WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH 9
524 #define WLAN_REASON_JOIN_WRONG_CHANNEL 65534
525 #define WLAN_REASON_EXPIRATION_CHK 65535
526
527 /* Information Element IDs */
528 #define WLAN_EID_SSID 0
529 #define WLAN_EID_SUPP_RATES 1
530 #define WLAN_EID_FH_PARAMS 2
531 #define WLAN_EID_DS_PARAMS 3
532 #define WLAN_EID_CF_PARAMS 4
533 #define WLAN_EID_TIM 5
534 #define WLAN_EID_IBSS_PARAMS 6
535 #define WLAN_EID_CHALLENGE 16
536 /* EIDs defined by IEEE 802.11h - START */
537 #define WLAN_EID_PWR_CONSTRAINT 32
538 #define WLAN_EID_PWR_CAPABILITY 33
539 #define WLAN_EID_TPC_REQUEST 34
540 #define WLAN_EID_TPC_REPORT 35
541 #define WLAN_EID_SUPPORTED_CHANNELS 36
542 #define WLAN_EID_CHANNEL_SWITCH 37
543 #define WLAN_EID_MEASURE_REQUEST 38
544 #define WLAN_EID_MEASURE_REPORT 39
545 #define WLAN_EID_QUITE 40
546 #define WLAN_EID_IBSS_DFS 41
547 /* EIDs defined by IEEE 802.11h - END */
548 #define WLAN_EID_ERP_INFO 42
549 #define WLAN_EID_HT_CAP 45
550 #define WLAN_EID_RSN 48
551 #define WLAN_EID_EXT_SUPP_RATES 50
552 #define WLAN_EID_MOBILITY_DOMAIN 54
553 #define WLAN_EID_FAST_BSS_TRANSITION 55
554 #define WLAN_EID_TIMEOUT_INTERVAL 56
555 #define WLAN_EID_RIC_DATA 57
556 #define WLAN_EID_HT_OPERATION 61
557 #define WLAN_EID_SECONDARY_CHANNEL_OFFSET 62
558 #define WLAN_EID_20_40_BSS_COEXISTENCE 72
559 #define WLAN_EID_20_40_BSS_INTOLERANT 73
560 #define WLAN_EID_OVERLAPPING_BSS_SCAN_PARAMS 74
561 #define WLAN_EID_MMIE 76
562 #define WLAN_EID_VENDOR_SPECIFIC 221
563 #define WLAN_EID_GENERIC (WLAN_EID_VENDOR_SPECIFIC)
564
565 #define IEEE80211_MGMT_HDR_LEN 24
566 #define IEEE80211_DATA_HDR3_LEN 24
567 #define IEEE80211_DATA_HDR4_LEN 30
568
569
570 #define IEEE80211_STATMASK_SIGNAL (1<<0)
571 #define IEEE80211_STATMASK_RSSI (1<<1)
572 #define IEEE80211_STATMASK_NOISE (1<<2)
573 #define IEEE80211_STATMASK_RATE (1<<3)
574 #define IEEE80211_STATMASK_WEMASK 0x7
575
576
577 #define IEEE80211_CCK_MODULATION (1<<0)
578 #define IEEE80211_OFDM_MODULATION (1<<1)
579
580 #define IEEE80211_24GHZ_BAND (1<<0)
581 #define IEEE80211_52GHZ_BAND (1<<1)
582
583 #define IEEE80211_CCK_RATE_LEN 4
584 #define IEEE80211_NUM_OFDM_RATESLEN 8
585
586
587 #define IEEE80211_CCK_RATE_1MB 0x02
588 #define IEEE80211_CCK_RATE_2MB 0x04
589 #define IEEE80211_CCK_RATE_5MB 0x0B
590 #define IEEE80211_CCK_RATE_11MB 0x16
591 #define IEEE80211_OFDM_RATE_LEN 8
592 #define IEEE80211_OFDM_RATE_6MB 0x0C
593 #define IEEE80211_OFDM_RATE_9MB 0x12
594 #define IEEE80211_OFDM_RATE_12MB 0x18
595 #define IEEE80211_OFDM_RATE_18MB 0x24
596 #define IEEE80211_OFDM_RATE_24MB 0x30
597 #define IEEE80211_OFDM_RATE_36MB 0x48
598 #define IEEE80211_OFDM_RATE_48MB 0x60
599 #define IEEE80211_OFDM_RATE_54MB 0x6C
600 #define IEEE80211_BASIC_RATE_MASK 0x80
601
602 #define IEEE80211_CCK_RATE_1MB_MASK (1<<0)
603 #define IEEE80211_CCK_RATE_2MB_MASK (1<<1)
604 #define IEEE80211_CCK_RATE_5MB_MASK (1<<2)
605 #define IEEE80211_CCK_RATE_11MB_MASK (1<<3)
606 #define IEEE80211_OFDM_RATE_6MB_MASK (1<<4)
607 #define IEEE80211_OFDM_RATE_9MB_MASK (1<<5)
608 #define IEEE80211_OFDM_RATE_12MB_MASK (1<<6)
609 #define IEEE80211_OFDM_RATE_18MB_MASK (1<<7)
610 #define IEEE80211_OFDM_RATE_24MB_MASK (1<<8)
611 #define IEEE80211_OFDM_RATE_36MB_MASK (1<<9)
612 #define IEEE80211_OFDM_RATE_48MB_MASK (1<<10)
613 #define IEEE80211_OFDM_RATE_54MB_MASK (1<<11)
614
615 #define IEEE80211_CCK_RATES_MASK 0x0000000F
616 #define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \
617 IEEE80211_CCK_RATE_2MB_MASK)
618 #define IEEE80211_CCK_DEFAULT_RATES_MASK \
619 (IEEE80211_CCK_BASIC_RATES_MASK | \
620 IEEE80211_CCK_RATE_5MB_MASK | \
621 IEEE80211_CCK_RATE_11MB_MASK)
622
623 #define IEEE80211_OFDM_RATES_MASK 0x00000FF0
624 #define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \
625 IEEE80211_OFDM_RATE_12MB_MASK | \
626 IEEE80211_OFDM_RATE_24MB_MASK)
627 #define IEEE80211_OFDM_DEFAULT_RATES_MASK \
628 (IEEE80211_OFDM_BASIC_RATES_MASK | \
629 IEEE80211_OFDM_RATE_9MB_MASK | \
630 IEEE80211_OFDM_RATE_18MB_MASK | \
631 IEEE80211_OFDM_RATE_36MB_MASK | \
632 IEEE80211_OFDM_RATE_48MB_MASK | \
633 IEEE80211_OFDM_RATE_54MB_MASK)
634 #define IEEE80211_DEFAULT_RATES_MASK \
635 (IEEE80211_OFDM_DEFAULT_RATES_MASK | \
636 IEEE80211_CCK_DEFAULT_RATES_MASK)
637
638 #define IEEE80211_NUM_OFDM_RATES 8
639 #define IEEE80211_NUM_CCK_RATES 4
640 #define IEEE80211_OFDM_SHIFT_MASK_A 4
641
642 /* NOTE: This data is for statistical purposes; not all hardware provides this
643 * information for frames received. Not setting these will not cause
644 * any adverse affects. */
645 struct ieee80211_rx_stats {
646 /* u32 mac_time[2]; */
647 s8 rssi;
648 u8 signal;
649 u8 noise;
650 u8 received_channel;
651 u16 rate; /* in 100 kbps */
652 /* u8 control; */
653 u8 mask;
654 u8 freq;
655 u16 len;
656 };
657
658 /* IEEE 802.11 requires that STA supports concurrent reception of at least
659 * three fragmented frames. This define can be increased to support more
660 * concurrent frames, but it should be noted that each entry can consume about
661 * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
662 #define IEEE80211_FRAG_CACHE_LEN 4
663
664 struct ieee80211_frag_entry {
665 u32 first_frag_time;
666 uint seq;
667 uint last_frag;
668 uint qos; /* jackson */
669 uint tid; /* jackson */
670 struct sk_buff *skb;
671 u8 src_addr[ETH_ALEN];
672 u8 dst_addr[ETH_ALEN];
673 };
674
675 struct ieee80211_stats {
676 uint tx_unicast_frames;
677 uint tx_multicast_frames;
678 uint tx_fragments;
679 uint tx_unicast_octets;
680 uint tx_multicast_octets;
681 uint tx_deferred_transmissions;
682 uint tx_single_retry_frames;
683 uint tx_multiple_retry_frames;
684 uint tx_retry_limit_exceeded;
685 uint tx_discards;
686 uint rx_unicast_frames;
687 uint rx_multicast_frames;
688 uint rx_fragments;
689 uint rx_unicast_octets;
690 uint rx_multicast_octets;
691 uint rx_fcs_errors;
692 uint rx_discards_no_buffer;
693 uint tx_discards_wrong_sa;
694 uint rx_discards_undecryptable;
695 uint rx_message_in_msg_fragments;
696 uint rx_message_in_bad_msg_fragments;
697 };
698
699 struct ieee80211_softmac_stats {
700 uint rx_ass_ok;
701 uint rx_ass_err;
702 uint rx_probe_rq;
703 uint tx_probe_rs;
704 uint tx_beacons;
705 uint rx_auth_rq;
706 uint rx_auth_rs_ok;
707 uint rx_auth_rs_err;
708 uint tx_auth_rq;
709 uint no_auth_rs;
710 uint no_ass_rs;
711 uint tx_ass_rq;
712 uint rx_ass_rq;
713 uint tx_probe_rq;
714 uint reassoc;
715 uint swtxstop;
716 uint swtxawake;
717 };
718
719 #define SEC_KEY_1 (1<<0)
720 #define SEC_KEY_2 (1<<1)
721 #define SEC_KEY_3 (1<<2)
722 #define SEC_KEY_4 (1<<3)
723 #define SEC_ACTIVE_KEY (1<<4)
724 #define SEC_AUTH_MODE (1<<5)
725 #define SEC_UNICAST_GROUP (1<<6)
726 #define SEC_LEVEL (1<<7)
727 #define SEC_ENABLED (1<<8)
728
729 #define SEC_LEVEL_0 0 /* None */
730 #define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */
731 #define SEC_LEVEL_2 2 /* Level 1 + TKIP */
732 #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
733 #define SEC_LEVEL_3 4 /* Level 2 + CCMP */
734
735 #define WEP_KEYS 4
736 #define WEP_KEY_LEN 13
737
738 struct ieee80211_security {
739 u16 active_key:2,
740 enabled:1,
741 auth_mode:2,
742 auth_algo:4,
743 unicast_uses_group:1;
744 u8 key_sizes[WEP_KEYS];
745 u8 keys[WEP_KEYS][WEP_KEY_LEN];
746 u8 level;
747 u16 flags;
748 } __packed;
749
750 /*
751
752 802.11 data frame from AP
753
754 ,-------------------------------------------------------------------.
755 Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
756 |------|------|---------|---------|---------|------|---------|------|
757 Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs |
758 | | tion | (BSSID) | | | ence | data | |
759 `-------------------------------------------------------------------'
760
761 Total: 28-2340 bytes
762
763 */
764
765 struct ieee80211_header_data {
766 u16 frame_ctl;
767 u16 duration_id;
768 u8 addr1[6];
769 u8 addr2[6];
770 u8 addr3[6];
771 u16 seq_ctrl;
772 };
773
774 #define BEACON_PROBE_SSID_ID_POSITION 12
775
776 /* Management Frame Information Element Types */
777 #define MFIE_TYPE_SSID 0
778 #define MFIE_TYPE_RATES 1
779 #define MFIE_TYPE_FH_SET 2
780 #define MFIE_TYPE_DS_SET 3
781 #define MFIE_TYPE_CF_SET 4
782 #define MFIE_TYPE_TIM 5
783 #define MFIE_TYPE_IBSS_SET 6
784 #define MFIE_TYPE_CHALLENGE 16
785 #define MFIE_TYPE_ERP 42
786 #define MFIE_TYPE_RSN 48
787 #define MFIE_TYPE_RATES_EX 50
788 #define MFIE_TYPE_GENERIC 221
789
790 struct ieee80211_info_element_hdr {
791 u8 id;
792 u8 len;
793 } __packed;
794
795 struct ieee80211_info_element {
796 u8 id;
797 u8 len;
798 u8 data[0];
799 } __packed;
800
801 /*
802 * These are the data types that can make up management packets
803 *
804 u16 auth_algorithm;
805 u16 auth_sequence;
806 u16 beacon_interval;
807 u16 capability;
808 u8 current_ap[ETH_ALEN];
809 u16 listen_interval;
810 struct {
811 u16 association_id:14, reserved:2;
812 } __packed;
813 u32 time_stamp[2];
814 u16 reason;
815 u16 status;
816 */
817
818 #define IEEE80211_DEFAULT_TX_ESSID "Penguin"
819 #define IEEE80211_DEFAULT_BASIC_RATE 10
820
821 struct ieee80211_authentication {
822 struct ieee80211_header_data header;
823 u16 algorithm;
824 u16 transaction;
825 u16 status;
826 /* struct ieee80211_info_element_hdr info_element; */
827 } __packed;
828
829 struct ieee80211_probe_response {
830 struct ieee80211_header_data header;
831 u32 time_stamp[2];
832 u16 beacon_interval;
833 u16 capability;
834 struct ieee80211_info_element info_element;
835 } __packed;
836
837 struct ieee80211_probe_request {
838 struct ieee80211_header_data header;
839 } __packed;
840
841 struct ieee80211_assoc_request_frame {
842 struct rtw_ieee80211_hdr_3addr header;
843 u16 capability;
844 u16 listen_interval;
845 struct ieee80211_info_element_hdr info_element;
846 } __packed;
847
848 struct ieee80211_assoc_response_frame {
849 struct rtw_ieee80211_hdr_3addr header;
850 u16 capability;
851 u16 status;
852 u16 aid;
853 } __packed;
854
855 struct ieee80211_txb {
856 u8 nr_frags;
857 u8 encrypted;
858 u16 reserved;
859 u16 frag_size;
860 u16 payload_size;
861 struct sk_buff *fragments[0];
862 };
863
864
865 /* SWEEP TABLE ENTRIES NUMBER*/
866 #define MAX_SWEEP_TAB_ENTRIES 42
867 #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
868 /* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs
869 * only use 8, and then use extended rates for the remaining supported
870 * rates. Other APs, however, stick all of their supported rates on the
871 * main rates information element... */
872 #define MAX_RATES_LENGTH ((u8)12)
873 #define MAX_RATES_EX_LENGTH ((u8)16)
874 #define MAX_NETWORK_COUNT 128
875 #define MAX_CHANNEL_NUMBER 161
876 #define IEEE80211_SOFTMAC_SCAN_TIME 400
877 /* HZ / 2) */
878 #define IEEE80211_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2)
879
880 #define CRC_LENGTH 4U
881
882 #define MAX_WPA_IE_LEN (256)
883 #define MAX_WPS_IE_LEN (512)
884 #define MAX_P2P_IE_LEN (256)
885 #define MAX_WFD_IE_LEN (128)
886
887 #define NETWORK_EMPTY_ESSID (1<<0)
888 #define NETWORK_HAS_OFDM (1<<1)
889 #define NETWORK_HAS_CCK (1<<2)
890
891 #define IEEE80211_DTIM_MBCAST 4
892 #define IEEE80211_DTIM_UCAST 2
893 #define IEEE80211_DTIM_VALID 1
894 #define IEEE80211_DTIM_INVALID 0
895
896 #define IEEE80211_PS_DISABLED 0
897 #define IEEE80211_PS_UNICAST IEEE80211_DTIM_UCAST
898 #define IEEE80211_PS_MBCAST IEEE80211_DTIM_MBCAST
899 #define IW_ESSID_MAX_SIZE 32
900 /*
901 join_res:
902 -1: authentication fail
903 -2: association fail
904 > 0: TID
905 */
906
907 enum ieee80211_state {
908 /* the card is not linked at all */
909 IEEE80211_NOLINK = 0,
910
911 /* IEEE80211_ASSOCIATING* are for BSS client mode
912 * the driver shall not perform RX filtering unless
913 * the state is LINKED.
914 * The driver shall just check for the state LINKED and
915 * defaults to NOLINK for ALL the other states (including
916 * LINKED_SCANNING)
917 */
918
919 /* the association procedure will start (wq scheduling)*/
920 IEEE80211_ASSOCIATING,
921 IEEE80211_ASSOCIATING_RETRY,
922
923 /* the association procedure is sending AUTH request*/
924 IEEE80211_ASSOCIATING_AUTHENTICATING,
925
926 /* the association procedure has successfully authentcated
927 * and is sending association request
928 */
929 IEEE80211_ASSOCIATING_AUTHENTICATED,
930
931 /* the link is ok. the card associated to a BSS or linked
932 * to a ibss cell or acting as an AP and creating the bss
933 */
934 IEEE80211_LINKED,
935
936 /* same as LINKED, but the driver shall apply RX filter
937 * rules as we are in NO_LINK mode. As the card is still
938 * logically linked, but it is doing a syncro site survey
939 * then it will be back to LINKED state.
940 */
941 IEEE80211_LINKED_SCANNING,
942
943 };
944
945 #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
946 #define DEFAULT_FTS 2346
947
is_multicast_mac_addr(const u8 * addr)948 static inline int is_multicast_mac_addr(const u8 *addr)
949 {
950 return ((addr[0] != 0xff) && (0x01 & addr[0]));
951 }
952
is_broadcast_mac_addr(const u8 * addr)953 static inline int is_broadcast_mac_addr(const u8 *addr)
954 {
955 return (addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&
956 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff);
957 }
958
959 #define CFG_IEEE80211_RESERVE_FCS (1<<0)
960 #define CFG_IEEE80211_COMPUTE_FCS (1<<1)
961
962 struct tx_pending {
963 int frag;
964 struct ieee80211_txb *txb;
965 };
966
967 #define MAXTID 16
968
969 #define IEEE_A (1<<0)
970 #define IEEE_B (1<<1)
971 #define IEEE_G (1<<2)
972 #define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
973
974 /* Baron move to ieee80211.c */
975 int ieee80211_is_empty_essid(const char *essid, int essid_len);
976 int ieee80211_get_hdrlen(u16 fc);
977
978 /* Action category code */
979 enum rtw_ieee80211_category {
980 RTW_WLAN_CATEGORY_SPECTRUM_MGMT = 0,
981 RTW_WLAN_CATEGORY_QOS = 1,
982 RTW_WLAN_CATEGORY_DLS = 2,
983 RTW_WLAN_CATEGORY_BACK = 3,
984 RTW_WLAN_CATEGORY_PUBLIC = 4, /* IEEE 802.11 public action frames */
985 RTW_WLAN_CATEGORY_RADIO_MEASUREMENT = 5,
986 RTW_WLAN_CATEGORY_FT = 6,
987 RTW_WLAN_CATEGORY_HT = 7,
988 RTW_WLAN_CATEGORY_SA_QUERY = 8,
989 RTW_WLAN_CATEGORY_TDLS = 12,
990 RTW_WLAN_CATEGORY_WMM = 17,
991 RTW_WLAN_CATEGORY_P2P = 0x7f,/* P2P action frames */
992 };
993
994 /* SPECTRUM_MGMT action code */
995 enum rtw_ieee80211_spectrum_mgmt_actioncode {
996 RTW_WLAN_ACTION_SPCT_MSR_REQ = 0,
997 RTW_WLAN_ACTION_SPCT_MSR_RPRT = 1,
998 RTW_WLAN_ACTION_SPCT_TPC_REQ = 2,
999 RTW_WLAN_ACTION_SPCT_TPC_RPRT = 3,
1000 RTW_WLAN_ACTION_SPCT_CHL_SWITCH = 4,
1001 RTW_WLAN_ACTION_SPCT_EXT_CHL_SWITCH = 5,
1002 };
1003
1004 enum _PUBLIC_ACTION {
1005 ACT_PUBLIC_BSSCOEXIST = 0, /* 20/40 BSS Coexistence */
1006 ACT_PUBLIC_DSE_ENABLE = 1,
1007 ACT_PUBLIC_DSE_DEENABLE = 2,
1008 ACT_PUBLIC_DSE_REG_LOCATION = 3,
1009 ACT_PUBLIC_EXT_CHL_SWITCH = 4,
1010 ACT_PUBLIC_DSE_MSR_REQ = 5,
1011 ACT_PUBLIC_DSE_MSR_RPRT = 6,
1012 ACT_PUBLIC_MP = 7, /* Measurement Pilot */
1013 ACT_PUBLIC_DSE_PWR_CONSTRAINT = 8,
1014 ACT_PUBLIC_VENDOR = 9, /* for WIFI_DIRECT */
1015 ACT_PUBLIC_GAS_INITIAL_REQ = 10,
1016 ACT_PUBLIC_GAS_INITIAL_RSP = 11,
1017 ACT_PUBLIC_GAS_COMEBACK_REQ = 12,
1018 ACT_PUBLIC_GAS_COMEBACK_RSP = 13,
1019 ACT_PUBLIC_TDLS_DISCOVERY_RSP = 14,
1020 ACT_PUBLIC_LOCATION_TRACK = 15,
1021 ACT_PUBLIC_MAX
1022 };
1023
1024 /* BACK action code */
1025 enum rtw_ieee80211_back_actioncode {
1026 RTW_WLAN_ACTION_ADDBA_REQ = 0,
1027 RTW_WLAN_ACTION_ADDBA_RESP = 1,
1028 RTW_WLAN_ACTION_DELBA = 2,
1029 };
1030
1031 /* HT features action code */
1032 enum rtw_ieee80211_ht_actioncode {
1033 RTW_WLAN_ACTION_NOTIFY_CH_WIDTH = 0,
1034 RTW_WLAN_ACTION_SM_PS = 1,
1035 RTW_WLAN_ACTION_PSPM = 2,
1036 RTW_WLAN_ACTION_PCO_PHASE = 3,
1037 RTW_WLAN_ACTION_MIMO_CSI_MX = 4,
1038 RTW_WLAN_ACTION_MIMO_NONCP_BF = 5,
1039 RTW_WLAN_ACTION_MIMP_CP_BF = 6,
1040 RTW_WLAN_ACTION_ASEL_INDICATES_FB = 7,
1041 RTW_WLAN_ACTION_HI_INFO_EXCHG = 8,
1042 };
1043
1044 /* BACK (block-ack) parties */
1045 enum rtw_ieee80211_back_parties {
1046 RTW_WLAN_BACK_RECIPIENT = 0,
1047 RTW_WLAN_BACK_INITIATOR = 1,
1048 RTW_WLAN_BACK_TIMER = 2,
1049 };
1050
1051 #define OUI_MICROSOFT 0x0050f2 /* Microsoft (also used in Wi-Fi specs)
1052 * 00:50:F2 */
1053 #define WME_OUI_TYPE 2
1054 #define WME_OUI_SUBTYPE_INFORMATION_ELEMENT 0
1055 #define WME_OUI_SUBTYPE_PARAMETER_ELEMENT 1
1056 #define WME_OUI_SUBTYPE_TSPEC_ELEMENT 2
1057 #define WME_VERSION 1
1058
1059 #define WME_ACTION_CODE_SETUP_REQUEST 0
1060 #define WME_ACTION_CODE_SETUP_RESPONSE 1
1061 #define WME_ACTION_CODE_TEARDOWN 2
1062
1063 #define WME_SETUP_RESPONSE_STATUS_ADMISSION_ACCEPTED 0
1064 #define WME_SETUP_RESPONSE_STATUS_INVALID_PARAMETERS 1
1065 #define WME_SETUP_RESPONSE_STATUS_REFUSED 3
1066
1067 #define WME_TSPEC_DIRECTION_UPLINK 0
1068 #define WME_TSPEC_DIRECTION_DOWNLINK 1
1069 #define WME_TSPEC_DIRECTION_BI_DIRECTIONAL 3
1070
1071
1072 #define OUI_BROADCOM 0x00904c /* Broadcom (Epigram) */
1073
1074 #define VENDOR_HT_CAPAB_OUI_TYPE 0x33 /* 00-90-4c:0x33 */
1075
1076 /**
1077 * enum rtw_ieee80211_channel_flags - channel flags
1078 *
1079 * Channel flags set by the regulatory control code.
1080 *
1081 * @RTW_IEEE80211_CHAN_DISABLED: This channel is disabled.
1082 * @RTW_IEEE80211_CHAN_PASSIVE_SCAN: Only passive scanning is permitted
1083 * on this channel.
1084 * @RTW_IEEE80211_CHAN_NO_IBSS: IBSS is not allowed on this channel.
1085 * @RTW_IEEE80211_CHAN_RADAR: Radar detection is required on this channel.
1086 * @RTW_IEEE80211_CHAN_NO_HT40PLUS: extension channel above this channel
1087 * is not permitted.
1088 * @RTW_IEEE80211_CHAN_NO_HT40MINUS: extension channel below this channel
1089 * is not permitted.
1090 */
1091 enum rtw_ieee80211_channel_flags {
1092 RTW_IEEE80211_CHAN_DISABLED = 1<<0,
1093 RTW_IEEE80211_CHAN_PASSIVE_SCAN = 1<<1,
1094 RTW_IEEE80211_CHAN_NO_IBSS = 1<<2,
1095 RTW_IEEE80211_CHAN_RADAR = 1<<3,
1096 RTW_IEEE80211_CHAN_NO_HT40PLUS = 1<<4,
1097 RTW_IEEE80211_CHAN_NO_HT40MINUS = 1<<5,
1098 };
1099
1100 #define RTW_IEEE80211_CHAN_NO_HT40 \
1101 (RTW_IEEE80211_CHAN_NO_HT40PLUS | RTW_IEEE80211_CHAN_NO_HT40MINUS)
1102
1103 /* Represent channel details, subset of ieee80211_channel */
1104 struct rtw_ieee80211_channel {
1105 u16 hw_value;
1106 u32 flags;
1107 };
1108
1109 #define CHAN_FMT \
1110 "hw_value:%u, " \
1111 "flags:0x%08x" \
1112
1113 #define CHAN_ARG(channel) \
1114 (channel)->hw_value \
1115 , (channel)->flags \
1116
1117 /* Parsed Information Elements */
1118 struct rtw_ieee802_11_elems {
1119 u8 *ssid;
1120 u8 ssid_len;
1121 u8 *supp_rates;
1122 u8 supp_rates_len;
1123 u8 *fh_params;
1124 u8 fh_params_len;
1125 u8 *ds_params;
1126 u8 ds_params_len;
1127 u8 *cf_params;
1128 u8 cf_params_len;
1129 u8 *tim;
1130 u8 tim_len;
1131 u8 *ibss_params;
1132 u8 ibss_params_len;
1133 u8 *challenge;
1134 u8 challenge_len;
1135 u8 *erp_info;
1136 u8 erp_info_len;
1137 u8 *ext_supp_rates;
1138 u8 ext_supp_rates_len;
1139 u8 *wpa_ie;
1140 u8 wpa_ie_len;
1141 u8 *rsn_ie;
1142 u8 rsn_ie_len;
1143 u8 *wme;
1144 u8 wme_len;
1145 u8 *wme_tspec;
1146 u8 wme_tspec_len;
1147 u8 *wps_ie;
1148 u8 wps_ie_len;
1149 u8 *power_cap;
1150 u8 power_cap_len;
1151 u8 *supp_channels;
1152 u8 supp_channels_len;
1153 u8 *mdie;
1154 u8 mdie_len;
1155 u8 *ftie;
1156 u8 ftie_len;
1157 u8 *timeout_int;
1158 u8 timeout_int_len;
1159 u8 *ht_capabilities;
1160 u8 ht_capabilities_len;
1161 u8 *ht_operation;
1162 u8 ht_operation_len;
1163 u8 *vendor_ht_cap;
1164 u8 vendor_ht_cap_len;
1165 };
1166
1167 enum parse_res {
1168 ParseOK = 0,
1169 ParseUnknown = 1,
1170 ParseFailed = -1
1171 };
1172
1173 enum parse_res rtw_ieee802_11_parse_elems(u8 *start, uint len,
1174 struct rtw_ieee802_11_elems *elems,
1175 int show_errors);
1176
1177 u8 *rtw_set_fixed_ie(unsigned char *pbuf, unsigned int len,
1178 unsigned char *source, unsigned int *frlen);
1179 u8 *rtw_set_ie(u8 *pbuf, int index, uint len, u8 *source, uint *frlen);
1180
1181 enum secondary_ch_offset {
1182 SCN = 0, /* no secondary channel */
1183 SCA = 1, /* secondary channel above */
1184 SCB = 3, /* secondary channel below */
1185 };
1186 u8 secondary_ch_offset_to_hal_ch_offset(u8 ch_offset);
1187 u8 hal_ch_offset_to_secondary_ch_offset(u8 ch_offset);
1188 u8 *rtw_set_ie_ch_switch(u8 *buf, u32 *buf_len, u8 ch_switch_mode,
1189 u8 new_ch, u8 ch_switch_cnt);
1190 u8 *rtw_set_ie_secondary_ch_offset(u8 *buf, u32 *buf_len,
1191 u8 secondary_ch_offset);
1192 u8 *rtw_set_ie_mesh_ch_switch_parm(u8 *buf, u32 *buf_len, u8 ttl,
1193 u8 flags, u16 reason, u16 precedence);
1194
1195 u8 *rtw_get_ie(u8 *pbuf, int index, int *len, int limit);
1196 u8 *rtw_get_ie_ex(u8 *in_ie, uint in_len, u8 eid, u8 *oui,
1197 u8 oui_len, u8 *ie, uint *ielen);
1198 int rtw_ies_remove_ie(u8 *ies, uint *ies_len, uint offset,
1199 u8 eid, u8 *oui, u8 oui_len);
1200
1201 void rtw_set_supported_rate(u8 *SupportedRates, uint mode);
1202
1203 unsigned char *rtw_get_wpa_ie(unsigned char *pie, int *wpa_ie_len, int limit);
1204 unsigned char *rtw_get_wpa2_ie(unsigned char *pie, int *rsn_ie_len, int limit);
1205 int rtw_get_wpa_cipher_suite(u8 *s);
1206 int rtw_get_wpa2_cipher_suite(u8 *s);
1207 int rtw_get_wapi_ie(u8 *in_ie, uint in_len, u8 *wapi_ie, u16 *wapi_len);
1208 int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher,
1209 int *pairwise_cipher, int *is_8021x);
1210 int rtw_parse_wpa2_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher,
1211 int *pairwise_cipher, int *is_8021x);
1212
1213 int rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len,
1214 u8 *wpa_ie, u16 *wpa_len);
1215
1216 u8 rtw_is_wps_ie(u8 *ie_ptr, uint *wps_ielen);
1217 u8 *rtw_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen);
1218 u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id,
1219 u8 *buf_attr, u32 *len_attr);
1220 u8 *rtw_get_wps_attr_content(u8 *wps_ie, uint wps_ielen, u16 target_attr_id,
1221 u8 *buf_content, uint *len_content);
1222
1223 /**
1224 * for_each_ie - iterate over continuous IEs
1225 * @ie:
1226 * @buf:
1227 * @buf_len:
1228 */
1229 #define for_each_ie(ie, buf, buf_len) \
1230 for (ie = (void *)buf; (((u8 *)ie) - ((u8 *)buf) + 1) < buf_len; \
1231 ie = (void *)(((u8 *)ie) + *(((u8 *)ie)+1) + 2))
1232
1233 void dump_ies(u8 *buf, u32 buf_len);
1234 void dump_wps_ie(u8 *ie, u32 ie_len);
1235
1236 uint rtw_get_rateset_len(u8 *rateset);
1237
1238 struct registry_priv;
1239 int rtw_generate_ie(struct registry_priv *pregistrypriv);
1240
1241
1242 int rtw_get_bit_value_from_ieee_value(u8 val);
1243
1244 uint rtw_is_cckrates_included(u8 *rate);
1245
1246 uint rtw_is_cckratesonly_included(u8 *rate);
1247
1248 int rtw_check_network_type(unsigned char *rate, int ratelen, int channel);
1249
1250 void rtw_get_bcn_info(struct wlan_network *pnetwork);
1251
1252 void rtw_macaddr_cfg(u8 *mac_addr);
1253
1254 u16 rtw_mcs_rate(u8 rf_type, u8 bw_40MHz, u8 short_GI_20, u8 short_GI_40,
1255 unsigned char *MCS_rate);
1256
1257 int rtw_action_frame_parse(const u8 *frame, u32 frame_len, u8 *category,
1258 u8 *action);
1259 const char *action_public_str(u8 action);
1260
1261 #endif /* IEEE80211_H */
1262