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