This source file includes following definitions.
- is_multicast_mac_addr
- is_broadcast_mac_addr
- is_zero_mac_addr
1
2
3
4
5
6
7 #ifndef __IEEE80211_H
8 #define __IEEE80211_H
9
10 #include <linux/ieee80211.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 #define RTL_IOCTL_HOSTAPD (SIOCIWFIRSTPRIV + 28)
19
20
21 enum {
22 RTL871X_HOSTAPD_FLUSH = 1,
23 RTL871X_HOSTAPD_ADD_STA = 2,
24 RTL871X_HOSTAPD_REMOVE_STA = 3,
25 RTL871X_HOSTAPD_GET_INFO_STA = 4,
26
27 RTL871X_HOSTAPD_GET_WPAIE_STA = 5,
28 RTL871X_SET_ENCRYPTION = 6,
29 RTL871X_GET_ENCRYPTION = 7,
30 RTL871X_HOSTAPD_SET_FLAGS_STA = 8,
31 RTL871X_HOSTAPD_GET_RID = 9,
32 RTL871X_HOSTAPD_SET_RID = 10,
33 RTL871X_HOSTAPD_SET_ASSOC_AP_ADDR = 11,
34 RTL871X_HOSTAPD_SET_GENERIC_ELEMENT = 12,
35 RTL871X_HOSTAPD_MLME = 13,
36 RTL871X_HOSTAPD_SCAN_REQ = 14,
37 RTL871X_HOSTAPD_STA_CLEAR_STATS = 15,
38 RTL871X_HOSTAPD_SET_BEACON = 16,
39 RTL871X_HOSTAPD_SET_WPS_BEACON = 17,
40 RTL871X_HOSTAPD_SET_WPS_PROBE_RESP = 18,
41 RTL871X_HOSTAPD_SET_WPS_ASSOC_RESP = 19,
42 RTL871X_HOSTAPD_SET_HIDDEN_SSID = 20,
43 RTL871X_HOSTAPD_SET_MACADDR_ACL = 21,
44 RTL871X_HOSTAPD_ACL_ADD_STA = 22,
45 RTL871X_HOSTAPD_ACL_REMOVE_STA = 23,
46 };
47
48
49 #define WLAN_STA_AUTH BIT(0)
50 #define WLAN_STA_ASSOC BIT(1)
51 #define WLAN_STA_PS BIT(2)
52 #define WLAN_STA_TIM BIT(3)
53 #define WLAN_STA_PERM BIT(4)
54 #define WLAN_STA_AUTHORIZED BIT(5)
55 #define WLAN_STA_PENDING_POLL BIT(6)
56 #define WLAN_STA_SHORT_PREAMBLE BIT(7)
57 #define WLAN_STA_PREAUTH BIT(8)
58 #define WLAN_STA_WME BIT(9)
59 #define WLAN_STA_MFP BIT(10)
60 #define WLAN_STA_HT BIT(11)
61 #define WLAN_STA_WPS BIT(12)
62 #define WLAN_STA_MAYBE_WPS BIT(13)
63 #define WLAN_STA_VHT BIT(14)
64 #define WLAN_STA_NONERP BIT(31)
65
66 #define IEEE_CMD_SET_WPA_PARAM 1
67 #define IEEE_CMD_SET_WPA_IE 2
68 #define IEEE_CMD_SET_ENCRYPTION 3
69 #define IEEE_CMD_MLME 4
70
71 #define IEEE_PARAM_WPA_ENABLED 1
72 #define IEEE_PARAM_TKIP_COUNTERMEASURES 2
73 #define IEEE_PARAM_DROP_UNENCRYPTED 3
74 #define IEEE_PARAM_PRIVACY_INVOKED 4
75 #define IEEE_PARAM_AUTH_ALGS 5
76 #define IEEE_PARAM_IEEE_802_1X 6
77 #define IEEE_PARAM_WPAX_SELECT 7
78
79 #define IEEE_MLME_STA_DEAUTH 1
80 #define IEEE_MLME_STA_DISASSOC 2
81
82 #define IEEE_CRYPT_ERR_UNKNOWN_ALG 2
83 #define IEEE_CRYPT_ERR_UNKNOWN_ADDR 3
84 #define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED 4
85 #define IEEE_CRYPT_ERR_KEY_SET_FAILED 5
86 #define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED 6
87 #define IEEE_CRYPT_ERR_CARD_CONF_FAILED 7
88
89
90 #define IEEE_CRYPT_ALG_NAME_LEN 16
91
92 #define WPA_CIPHER_NONE BIT(0)
93 #define WPA_CIPHER_WEP40 BIT(1)
94 #define WPA_CIPHER_WEP104 BIT(2)
95 #define WPA_CIPHER_TKIP BIT(3)
96 #define WPA_CIPHER_CCMP BIT(4)
97
98
99
100 #define WPA_SELECTOR_LEN 4
101 extern u8 RTW_WPA_OUI_TYPE[] ;
102 extern u16 RTW_WPA_VERSION ;
103 extern u8 WPA_AUTH_KEY_MGMT_NONE[];
104 extern u8 WPA_AUTH_KEY_MGMT_UNSPEC_802_1X[];
105 extern u8 WPA_AUTH_KEY_MGMT_PSK_OVER_802_1X[];
106 extern u8 WPA_CIPHER_SUITE_NONE[];
107 extern u8 WPA_CIPHER_SUITE_WEP40[];
108 extern u8 WPA_CIPHER_SUITE_TKIP[];
109 extern u8 WPA_CIPHER_SUITE_WRAP[];
110 extern u8 WPA_CIPHER_SUITE_CCMP[];
111 extern u8 WPA_CIPHER_SUITE_WEP104[];
112
113
114 #define RSN_HEADER_LEN 4
115 #define RSN_SELECTOR_LEN 4
116
117 extern u16 RSN_VERSION_BSD;
118 extern u8 RSN_AUTH_KEY_MGMT_UNSPEC_802_1X[];
119 extern u8 RSN_AUTH_KEY_MGMT_PSK_OVER_802_1X[];
120 extern u8 RSN_CIPHER_SUITE_NONE[];
121 extern u8 RSN_CIPHER_SUITE_WEP40[];
122 extern u8 RSN_CIPHER_SUITE_TKIP[];
123 extern u8 RSN_CIPHER_SUITE_WRAP[];
124 extern u8 RSN_CIPHER_SUITE_CCMP[];
125 extern u8 RSN_CIPHER_SUITE_WEP104[];
126
127
128 typedef enum _RATEID_IDX_ {
129 RATEID_IDX_BGN_40M_2SS = 0,
130 RATEID_IDX_BGN_40M_1SS = 1,
131 RATEID_IDX_BGN_20M_2SS_BN = 2,
132 RATEID_IDX_BGN_20M_1SS_BN = 3,
133 RATEID_IDX_GN_N2SS = 4,
134 RATEID_IDX_GN_N1SS = 5,
135 RATEID_IDX_BG = 6,
136 RATEID_IDX_G = 7,
137 RATEID_IDX_B = 8,
138 RATEID_IDX_VHT_2SS = 9,
139 RATEID_IDX_VHT_1SS = 10,
140 } RATEID_IDX, *PRATEID_IDX;
141
142 typedef enum _RATR_TABLE_MODE{
143 RATR_INX_WIRELESS_NGB = 0,
144 RATR_INX_WIRELESS_NG = 1,
145 RATR_INX_WIRELESS_NB = 2,
146 RATR_INX_WIRELESS_N = 3,
147 RATR_INX_WIRELESS_GB = 4,
148 RATR_INX_WIRELESS_G = 5,
149 RATR_INX_WIRELESS_B = 6,
150 RATR_INX_WIRELESS_MC = 7,
151 RATR_INX_WIRELESS_AC_N = 8,
152 }RATR_TABLE_MODE, *PRATR_TABLE_MODE;
153
154
155 enum NETWORK_TYPE
156 {
157 WIRELESS_INVALID = 0,
158
159 WIRELESS_11B = BIT(0),
160 WIRELESS_11G = BIT(1),
161 WIRELESS_11A = BIT(2),
162 WIRELESS_11_24N = BIT(3),
163 WIRELESS_11_5N = BIT(4),
164 WIRELESS_AUTO = BIT(5),
165 WIRELESS_11AC = BIT(6),
166
167
168
169 WIRELESS_11BG = (WIRELESS_11B|WIRELESS_11G),
170 WIRELESS_11G_24N = (WIRELESS_11G|WIRELESS_11_24N),
171 WIRELESS_11A_5N = (WIRELESS_11A|WIRELESS_11_5N),
172 WIRELESS_11B_24N = (WIRELESS_11B|WIRELESS_11_24N),
173 WIRELESS_11BG_24N = (WIRELESS_11B|WIRELESS_11G|WIRELESS_11_24N),
174 WIRELESS_11_24AC = (WIRELESS_11G|WIRELESS_11AC),
175 WIRELESS_11_5AC = (WIRELESS_11A|WIRELESS_11AC),
176
177
178
179 WIRELESS_11AGN = (WIRELESS_11A|WIRELESS_11G|WIRELESS_11_24N|WIRELESS_11_5N),
180 WIRELESS_11ABGN = (WIRELESS_11A|WIRELESS_11B|WIRELESS_11G|WIRELESS_11_24N|WIRELESS_11_5N),
181 WIRELESS_MODE_24G = (WIRELESS_11B|WIRELESS_11G|WIRELESS_11_24N|WIRELESS_11AC),
182 WIRELESS_MODE_MAX = (WIRELESS_11A|WIRELESS_11B|WIRELESS_11G|WIRELESS_11_24N|WIRELESS_11_5N|WIRELESS_11AC),
183 };
184
185 #define SUPPORTED_24G_NETTYPE_MSK (WIRELESS_11B | WIRELESS_11G | WIRELESS_11_24N)
186
187 #define IsLegacyOnly(NetType) ((NetType) == ((NetType) & (WIRELESS_11BG|WIRELESS_11A)))
188
189 #define IsSupported24G(NetType) ((NetType) & SUPPORTED_24G_NETTYPE_MSK ? true : false)
190
191 #define IsEnableHWCCK(NetType) IsSupported24G(NetType)
192 #define IsEnableHWOFDM(NetType) (((NetType) & (WIRELESS_11G|WIRELESS_11_24N)) ? true : false)
193
194 #define IsSupportedRxCCK(NetType) IsEnableHWCCK(NetType)
195 #define IsSupportedRxOFDM(NetType) IsEnableHWOFDM(NetType)
196 #define IsSupportedRxHT(NetType) IsEnableHWOFDM(NetType)
197
198 #define IsSupportedTxCCK(NetType) (((NetType) & (WIRELESS_11B)) ? true : false)
199 #define IsSupportedTxOFDM(NetType) (((NetType) & (WIRELESS_11G|WIRELESS_11A)) ? true : false)
200 #define IsSupportedHT(NetType) (((NetType) & (WIRELESS_11_24N|WIRELESS_11_5N)) ? true : false)
201
202 #define IsSupportedVHT(NetType) (((NetType) & (WIRELESS_11AC)) ? true : false)
203
204
205 struct ieee_param {
206 u32 cmd;
207 u8 sta_addr[ETH_ALEN];
208 union {
209 struct {
210 u8 name;
211 u32 value;
212 } wpa_param;
213 struct {
214 u32 len;
215 u8 reserved[32];
216 u8 data[0];
217 } wpa_ie;
218 struct{
219 int command;
220 int reason_code;
221 } mlme;
222 struct {
223 u8 alg[IEEE_CRYPT_ALG_NAME_LEN];
224 u8 set_tx;
225 u32 err;
226 u8 idx;
227 u8 seq[8];
228 u16 key_len;
229 u8 key[0];
230 } crypt;
231 struct {
232 u16 aid;
233 u16 capability;
234 int flags;
235 u8 tx_supp_rates[16];
236 struct rtw_ieee80211_ht_cap ht_cap;
237 } add_sta;
238 struct {
239 u8 reserved[2];
240 u8 buf[0];
241 } bcn_ie;
242 } u;
243 };
244
245 struct ieee_param_ex {
246 u32 cmd;
247 u8 sta_addr[ETH_ALEN];
248 u8 data[0];
249 };
250
251 struct sta_data{
252 u16 aid;
253 u16 capability;
254 int flags;
255 u32 sta_set;
256 u8 tx_supp_rates[16];
257 u32 tx_supp_rates_len;
258 struct rtw_ieee80211_ht_cap ht_cap;
259 u64 rx_pkts;
260 u64 rx_bytes;
261 u64 rx_drops;
262 u64 tx_pkts;
263 u64 tx_bytes;
264 u64 tx_drops;
265 };
266
267
268 #define IEEE_IBSS_MAC_HASH_SIZE 31
269
270 struct ieee_ibss_seq {
271 u8 mac[ETH_ALEN];
272 u16 seq_num;
273 u16 frag_num;
274 unsigned long packet_time;
275 struct list_head list;
276 };
277
278 struct eapol {
279 u8 snap[6];
280 u16 ethertype;
281 u8 version;
282 u8 type;
283 u16 length;
284 } __attribute__ ((packed));
285
286 enum eap_type {
287 EAP_PACKET = 0,
288 EAPOL_START,
289 EAPOL_LOGOFF,
290 EAPOL_KEY,
291 EAPOL_ENCAP_ASF_ALERT
292 };
293
294 #define IEEE80211_FCS_LEN 4
295
296 #define MIN_FRAG_THRESHOLD 256U
297 #define MAX_FRAG_THRESHOLD 2346U
298
299
300 #define RTW_IEEE80211_SCTL_FRAG 0x000F
301 #define RTW_IEEE80211_SCTL_SEQ 0xFFF0
302
303
304 #define RTW_ERP_INFO_NON_ERP_PRESENT BIT(0)
305 #define RTW_ERP_INFO_USE_PROTECTION BIT(1)
306 #define RTW_ERP_INFO_BARKER_PREAMBLE_MODE BIT(2)
307
308
309 #define NORMAL_ACK 0
310 #define NO_ACK 1
311 #define NON_EXPLICIT_ACK 2
312 #define BLOCK_ACK 3
313
314 #ifndef ETH_P_PAE
315 #define ETH_P_PAE 0x888E
316 #endif
317
318 #define ETH_P_PREAUTH 0x88C7
319
320 #define ETH_P_ECONET 0x0018
321
322 #ifndef ETH_P_80211_RAW
323 #define ETH_P_80211_RAW (ETH_P_ECONET + 1)
324 #endif
325
326
327
328 #define P80211_OUI_LEN 3
329
330 struct ieee80211_snap_hdr {
331 u8 dsap;
332 u8 ssap;
333 u8 ctrl;
334 u8 oui[P80211_OUI_LEN];
335 } __attribute__ ((packed));
336
337 #define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
338
339 #define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE)
340 #define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE)
341
342 #define WLAN_QC_GET_TID(qc) ((qc) & 0x0f)
343
344 #define WLAN_GET_SEQ_FRAG(seq) ((seq) & RTW_IEEE80211_SCTL_FRAG)
345 #define WLAN_GET_SEQ_SEQ(seq) ((seq) & RTW_IEEE80211_SCTL_SEQ)
346
347
348 #define WLAN_CAPABILITY_BSS (1<<0)
349 #define WLAN_CAPABILITY_SHORT_SLOT (1<<10)
350
351
352 #define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19
353
354
355 #define WLAN_REASON_ACTIVE_ROAM 65533
356 #define WLAN_REASON_JOIN_WRONG_CHANNEL 65534
357 #define WLAN_REASON_EXPIRATION_CHK 65535
358
359
360 #define WLAN_EID_HT_CAP 45
361 #define WLAN_EID_20_40_BSS_COEXISTENCE 72
362 #define WLAN_EID_20_40_BSS_INTOLERANT 73
363 #define WLAN_EID_OVERLAPPING_BSS_SCAN_PARAMS 74
364 #define WLAN_EID_GENERIC (WLAN_EID_VENDOR_SPECIFIC)
365 #define WLAN_EID_VHT_OP_MODE_NOTIFY 199
366
367 #define IEEE80211_MGMT_HDR_LEN 24
368 #define IEEE80211_DATA_HDR3_LEN 24
369 #define IEEE80211_DATA_HDR4_LEN 30
370
371
372 #define IEEE80211_STATMASK_SIGNAL (1<<0)
373 #define IEEE80211_STATMASK_RSSI (1<<1)
374 #define IEEE80211_STATMASK_NOISE (1<<2)
375 #define IEEE80211_STATMASK_RATE (1<<3)
376 #define IEEE80211_STATMASK_WEMASK 0x7
377
378
379 #define IEEE80211_CCK_MODULATION (1<<0)
380 #define IEEE80211_OFDM_MODULATION (1<<1)
381
382 #define IEEE80211_24GHZ_BAND (1<<0)
383 #define IEEE80211_52GHZ_BAND (1<<1)
384
385 #define IEEE80211_CCK_RATE_LEN 4
386 #define IEEE80211_NUM_OFDM_RATESLEN 8
387
388
389 #define IEEE80211_CCK_RATE_1MB 0x02
390 #define IEEE80211_CCK_RATE_2MB 0x04
391 #define IEEE80211_CCK_RATE_5MB 0x0B
392 #define IEEE80211_CCK_RATE_11MB 0x16
393 #define IEEE80211_OFDM_RATE_LEN 8
394 #define IEEE80211_OFDM_RATE_6MB 0x0C
395 #define IEEE80211_OFDM_RATE_9MB 0x12
396 #define IEEE80211_OFDM_RATE_12MB 0x18
397 #define IEEE80211_OFDM_RATE_18MB 0x24
398 #define IEEE80211_OFDM_RATE_24MB 0x30
399 #define IEEE80211_OFDM_RATE_36MB 0x48
400 #define IEEE80211_OFDM_RATE_48MB 0x60
401 #define IEEE80211_OFDM_RATE_54MB 0x6C
402 #define IEEE80211_BASIC_RATE_MASK 0x80
403
404 #define IEEE80211_CCK_RATE_1MB_MASK (1<<0)
405 #define IEEE80211_CCK_RATE_2MB_MASK (1<<1)
406 #define IEEE80211_CCK_RATE_5MB_MASK (1<<2)
407 #define IEEE80211_CCK_RATE_11MB_MASK (1<<3)
408 #define IEEE80211_OFDM_RATE_6MB_MASK (1<<4)
409 #define IEEE80211_OFDM_RATE_9MB_MASK (1<<5)
410 #define IEEE80211_OFDM_RATE_12MB_MASK (1<<6)
411 #define IEEE80211_OFDM_RATE_18MB_MASK (1<<7)
412 #define IEEE80211_OFDM_RATE_24MB_MASK (1<<8)
413 #define IEEE80211_OFDM_RATE_36MB_MASK (1<<9)
414 #define IEEE80211_OFDM_RATE_48MB_MASK (1<<10)
415 #define IEEE80211_OFDM_RATE_54MB_MASK (1<<11)
416
417 #define IEEE80211_CCK_RATES_MASK 0x0000000F
418 #define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \
419 IEEE80211_CCK_RATE_2MB_MASK)
420 #define IEEE80211_CCK_DEFAULT_RATES_MASK (IEEE80211_CCK_BASIC_RATES_MASK | \
421 IEEE80211_CCK_RATE_5MB_MASK | \
422 IEEE80211_CCK_RATE_11MB_MASK)
423
424 #define IEEE80211_OFDM_RATES_MASK 0x00000FF0
425 #define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \
426 IEEE80211_OFDM_RATE_12MB_MASK | \
427 IEEE80211_OFDM_RATE_24MB_MASK)
428 #define IEEE80211_OFDM_DEFAULT_RATES_MASK (IEEE80211_OFDM_BASIC_RATES_MASK | \
429 IEEE80211_OFDM_RATE_9MB_MASK | \
430 IEEE80211_OFDM_RATE_18MB_MASK | \
431 IEEE80211_OFDM_RATE_36MB_MASK | \
432 IEEE80211_OFDM_RATE_48MB_MASK | \
433 IEEE80211_OFDM_RATE_54MB_MASK)
434 #define IEEE80211_DEFAULT_RATES_MASK (IEEE80211_OFDM_DEFAULT_RATES_MASK | \
435 IEEE80211_CCK_DEFAULT_RATES_MASK)
436
437 #define IEEE80211_NUM_OFDM_RATES 8
438 #define IEEE80211_NUM_CCK_RATES 4
439 #define IEEE80211_OFDM_SHIFT_MASK_A 4
440
441
442 enum MGN_RATE{
443 MGN_1M = 0x02,
444 MGN_2M = 0x04,
445 MGN_5_5M = 0x0B,
446 MGN_6M = 0x0C,
447 MGN_9M = 0x12,
448 MGN_11M = 0x16,
449 MGN_12M = 0x18,
450 MGN_18M = 0x24,
451 MGN_24M = 0x30,
452 MGN_36M = 0x48,
453 MGN_48M = 0x60,
454 MGN_54M = 0x6C,
455 MGN_MCS32 = 0x7F,
456 MGN_MCS0,
457 MGN_MCS1,
458 MGN_MCS2,
459 MGN_MCS3,
460 MGN_MCS4,
461 MGN_MCS5,
462 MGN_MCS6,
463 MGN_MCS7,
464 MGN_MCS8,
465 MGN_MCS9,
466 MGN_MCS10,
467 MGN_MCS11,
468 MGN_MCS12,
469 MGN_MCS13,
470 MGN_MCS14,
471 MGN_MCS15,
472 MGN_MCS16,
473 MGN_MCS17,
474 MGN_MCS18,
475 MGN_MCS19,
476 MGN_MCS20,
477 MGN_MCS21,
478 MGN_MCS22,
479 MGN_MCS23,
480 MGN_MCS24,
481 MGN_MCS25,
482 MGN_MCS26,
483 MGN_MCS27,
484 MGN_MCS28,
485 MGN_MCS29,
486 MGN_MCS30,
487 MGN_MCS31,
488 MGN_VHT1SS_MCS0,
489 MGN_VHT1SS_MCS1,
490 MGN_VHT1SS_MCS2,
491 MGN_VHT1SS_MCS3,
492 MGN_VHT1SS_MCS4,
493 MGN_VHT1SS_MCS5,
494 MGN_VHT1SS_MCS6,
495 MGN_VHT1SS_MCS7,
496 MGN_VHT1SS_MCS8,
497 MGN_VHT1SS_MCS9,
498 MGN_VHT2SS_MCS0,
499 MGN_VHT2SS_MCS1,
500 MGN_VHT2SS_MCS2,
501 MGN_VHT2SS_MCS3,
502 MGN_VHT2SS_MCS4,
503 MGN_VHT2SS_MCS5,
504 MGN_VHT2SS_MCS6,
505 MGN_VHT2SS_MCS7,
506 MGN_VHT2SS_MCS8,
507 MGN_VHT2SS_MCS9,
508 MGN_VHT3SS_MCS0,
509 MGN_VHT3SS_MCS1,
510 MGN_VHT3SS_MCS2,
511 MGN_VHT3SS_MCS3,
512 MGN_VHT3SS_MCS4,
513 MGN_VHT3SS_MCS5,
514 MGN_VHT3SS_MCS6,
515 MGN_VHT3SS_MCS7,
516 MGN_VHT3SS_MCS8,
517 MGN_VHT3SS_MCS9,
518 MGN_VHT4SS_MCS0,
519 MGN_VHT4SS_MCS1,
520 MGN_VHT4SS_MCS2,
521 MGN_VHT4SS_MCS3,
522 MGN_VHT4SS_MCS4,
523 MGN_VHT4SS_MCS5,
524 MGN_VHT4SS_MCS6,
525 MGN_VHT4SS_MCS7,
526 MGN_VHT4SS_MCS8,
527 MGN_VHT4SS_MCS9,
528 MGN_UNKNOWN
529 };
530
531 #define IS_HT_RATE(_rate) (_rate >= MGN_MCS0 && _rate <= MGN_MCS31)
532 #define IS_VHT_RATE(_rate) (_rate >= MGN_VHT1SS_MCS0 && _rate <= MGN_VHT4SS_MCS9)
533 #define IS_CCK_RATE(_rate) (MGN_1M == _rate || _rate == MGN_2M || _rate == MGN_5_5M || _rate == MGN_11M)
534 #define IS_OFDM_RATE(_rate) (MGN_6M <= _rate && _rate <= MGN_54M && _rate != MGN_11M)
535
536
537
538
539
540 struct ieee80211_rx_stats {
541 s8 rssi;
542 u8 signal;
543 u8 noise;
544 u8 received_channel;
545 u16 rate;
546 u8 mask;
547 u8 freq;
548 u16 len;
549 };
550
551
552
553
554
555 #define IEEE80211_FRAG_CACHE_LEN 4
556
557 struct ieee80211_frag_entry {
558 u32 first_frag_time;
559 uint seq;
560 uint last_frag;
561 uint qos;
562 uint tid;
563 struct sk_buff *skb;
564 u8 src_addr[ETH_ALEN];
565 u8 dst_addr[ETH_ALEN];
566 };
567
568 struct ieee80211_stats {
569 uint tx_unicast_frames;
570 uint tx_multicast_frames;
571 uint tx_fragments;
572 uint tx_unicast_octets;
573 uint tx_multicast_octets;
574 uint tx_deferred_transmissions;
575 uint tx_single_retry_frames;
576 uint tx_multiple_retry_frames;
577 uint tx_retry_limit_exceeded;
578 uint tx_discards;
579 uint rx_unicast_frames;
580 uint rx_multicast_frames;
581 uint rx_fragments;
582 uint rx_unicast_octets;
583 uint rx_multicast_octets;
584 uint rx_fcs_errors;
585 uint rx_discards_no_buffer;
586 uint tx_discards_wrong_sa;
587 uint rx_discards_undecryptable;
588 uint rx_message_in_msg_fragments;
589 uint rx_message_in_bad_msg_fragments;
590 };
591
592 struct ieee80211_softmac_stats {
593 uint rx_ass_ok;
594 uint rx_ass_err;
595 uint rx_probe_rq;
596 uint tx_probe_rs;
597 uint tx_beacons;
598 uint rx_auth_rq;
599 uint rx_auth_rs_ok;
600 uint rx_auth_rs_err;
601 uint tx_auth_rq;
602 uint no_auth_rs;
603 uint no_ass_rs;
604 uint tx_ass_rq;
605 uint rx_ass_rq;
606 uint tx_probe_rq;
607 uint reassoc;
608 uint swtxstop;
609 uint swtxawake;
610 };
611
612 #define SEC_KEY_1 (1<<0)
613 #define SEC_KEY_2 (1<<1)
614 #define SEC_KEY_3 (1<<2)
615 #define SEC_KEY_4 (1<<3)
616 #define SEC_ACTIVE_KEY (1<<4)
617 #define SEC_AUTH_MODE (1<<5)
618 #define SEC_UNICAST_GROUP (1<<6)
619 #define SEC_LEVEL (1<<7)
620 #define SEC_ENABLED (1<<8)
621
622 #define SEC_LEVEL_0 0
623 #define SEC_LEVEL_1 1
624 #define SEC_LEVEL_2 2
625 #define SEC_LEVEL_2_CKIP 3
626 #define SEC_LEVEL_3 4
627
628 #define WEP_KEYS 4
629 #define WEP_KEY_LEN 13
630
631 #define BIP_MAX_KEYID 5
632 #define BIP_AAD_SIZE 20
633
634 struct ieee80211_security {
635 u16 active_key:2,
636 enabled:1,
637 auth_mode:2,
638 auth_algo:4,
639 unicast_uses_group:1;
640 u8 key_sizes[WEP_KEYS];
641 u8 keys[WEP_KEYS][WEP_KEY_LEN];
642 u8 level;
643 u16 flags;
644 } __attribute__ ((packed));
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661 struct ieee80211_header_data {
662 u16 frame_ctl;
663 u16 duration_id;
664 u8 addr1[6];
665 u8 addr2[6];
666 u8 addr3[6];
667 u16 seq_ctrl;
668 };
669
670 #define BEACON_PROBE_SSID_ID_POSITION 12
671
672
673 #define MFIE_TYPE_SSID 0
674 #define MFIE_TYPE_RATES 1
675 #define MFIE_TYPE_FH_SET 2
676 #define MFIE_TYPE_DS_SET 3
677 #define MFIE_TYPE_CF_SET 4
678 #define MFIE_TYPE_TIM 5
679 #define MFIE_TYPE_IBSS_SET 6
680 #define MFIE_TYPE_CHALLENGE 16
681 #define MFIE_TYPE_ERP 42
682 #define MFIE_TYPE_RSN 48
683 #define MFIE_TYPE_RATES_EX 50
684 #define MFIE_TYPE_GENERIC 221
685
686 struct ieee80211_info_element_hdr {
687 u8 id;
688 u8 len;
689 } __attribute__ ((packed));
690
691 struct ieee80211_info_element {
692 u8 id;
693 u8 len;
694 u8 data[0];
695 } __attribute__ ((packed));
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714 #define IEEE80211_DEFAULT_TX_ESSID "Penguin"
715 #define IEEE80211_DEFAULT_BASIC_RATE 10
716
717
718 struct ieee80211_authentication {
719 struct ieee80211_header_data header;
720 u16 algorithm;
721 u16 transaction;
722 u16 status;
723
724 } __attribute__ ((packed));
725
726
727 struct ieee80211_probe_response {
728 struct ieee80211_header_data header;
729 u32 time_stamp[2];
730 u16 beacon_interval;
731 u16 capability;
732 struct ieee80211_info_element info_element;
733 } __attribute__ ((packed));
734
735 struct ieee80211_probe_request {
736 struct ieee80211_header_data header;
737
738 } __attribute__ ((packed));
739
740 struct ieee80211_assoc_request_frame {
741 struct ieee80211_hdr_3addr header;
742 u16 capability;
743 u16 listen_interval;
744
745 struct ieee80211_info_element_hdr info_element;
746 } __attribute__ ((packed));
747
748 struct ieee80211_assoc_response_frame {
749 struct ieee80211_hdr_3addr header;
750 u16 capability;
751 u16 status;
752 u16 aid;
753 } __attribute__ ((packed));
754
755 struct ieee80211_txb {
756 u8 nr_frags;
757 u8 encrypted;
758 u16 reserved;
759 u16 frag_size;
760 u16 payload_size;
761 struct sk_buff *fragments[0];
762 };
763
764
765
766 #define MAX_SWEEP_TAB_ENTRIES 42
767 #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
768
769
770
771
772 #define MAX_RATES_LENGTH ((u8)12)
773 #define MAX_RATES_EX_LENGTH ((u8)16)
774 #define MAX_NETWORK_COUNT 128
775 #define MAX_CHANNEL_NUMBER 161
776 #define IEEE80211_SOFTMAC_SCAN_TIME 400
777
778 #define IEEE80211_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2)
779
780 #define CRC_LENGTH 4U
781
782 #define MAX_WPA_IE_LEN (256)
783 #define MAX_WPS_IE_LEN (512)
784 #define MAX_P2P_IE_LEN (256)
785 #define MAX_WFD_IE_LEN (128)
786
787 #define NETWORK_EMPTY_ESSID (1<<0)
788 #define NETWORK_HAS_OFDM (1<<1)
789 #define NETWORK_HAS_CCK (1<<2)
790
791 #define IEEE80211_DTIM_MBCAST 4
792 #define IEEE80211_DTIM_UCAST 2
793 #define IEEE80211_DTIM_VALID 1
794 #define IEEE80211_DTIM_INVALID 0
795
796 #define IEEE80211_PS_DISABLED 0
797 #define IEEE80211_PS_UNICAST IEEE80211_DTIM_UCAST
798 #define IEEE80211_PS_MBCAST IEEE80211_DTIM_MBCAST
799 #define IW_ESSID_MAX_SIZE 32
800
801
802
803
804
805
806
807 enum ieee80211_state {
808
809
810 IEEE80211_NOLINK = 0,
811
812
813
814
815
816
817
818
819
820
821 IEEE80211_ASSOCIATING,
822 IEEE80211_ASSOCIATING_RETRY,
823
824
825 IEEE80211_ASSOCIATING_AUTHENTICATING,
826
827
828
829
830 IEEE80211_ASSOCIATING_AUTHENTICATED,
831
832
833
834
835 IEEE80211_LINKED,
836
837
838
839
840
841
842 IEEE80211_LINKED_SCANNING,
843
844 };
845
846 #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
847 #define DEFAULT_FTS 2346
848 #define MAC_FMT "%pM"
849 #define MAC_ARG(x) (x)
850 #define IP_FMT "%pI4"
851 #define IP_ARG(x) (x)
852
853 static inline int is_multicast_mac_addr(const u8 *addr)
854 {
855 return ((addr[0] != 0xff) && (0x01 & addr[0]));
856 }
857
858 static inline int is_broadcast_mac_addr(const u8 *addr)
859 {
860 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \
861 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
862 }
863
864 static inline int is_zero_mac_addr(const u8 *addr)
865 {
866 return ((addr[0] == 0x00) && (addr[1] == 0x00) && (addr[2] == 0x00) && \
867 (addr[3] == 0x00) && (addr[4] == 0x00) && (addr[5] == 0x00));
868 }
869
870 #define CFG_IEEE80211_RESERVE_FCS (1<<0)
871 #define CFG_IEEE80211_COMPUTE_FCS (1<<1)
872
873 #define MAXTID 16
874
875 #define IEEE_A (1<<0)
876 #define IEEE_B (1<<1)
877 #define IEEE_G (1<<2)
878 #define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
879
880
881 enum rtw_ieee80211_category {
882 RTW_WLAN_CATEGORY_SPECTRUM_MGMT = 0,
883 RTW_WLAN_CATEGORY_QOS = 1,
884 RTW_WLAN_CATEGORY_DLS = 2,
885 RTW_WLAN_CATEGORY_BACK = 3,
886 RTW_WLAN_CATEGORY_PUBLIC = 4,
887 RTW_WLAN_CATEGORY_RADIO_MEASUREMENT = 5,
888 RTW_WLAN_CATEGORY_FT = 6,
889 RTW_WLAN_CATEGORY_HT = 7,
890 RTW_WLAN_CATEGORY_SA_QUERY = 8,
891 RTW_WLAN_CATEGORY_UNPROTECTED_WNM = 11,
892 RTW_WLAN_CATEGORY_TDLS = 12,
893 RTW_WLAN_CATEGORY_SELF_PROTECTED = 15,
894 RTW_WLAN_CATEGORY_WMM = 17,
895 RTW_WLAN_CATEGORY_VHT = 21,
896 RTW_WLAN_CATEGORY_P2P = 0x7f,
897 };
898
899
900 enum rtw_ieee80211_spectrum_mgmt_actioncode {
901 RTW_WLAN_ACTION_SPCT_MSR_REQ = 0,
902 RTW_WLAN_ACTION_SPCT_MSR_RPRT = 1,
903 RTW_WLAN_ACTION_SPCT_TPC_REQ = 2,
904 RTW_WLAN_ACTION_SPCT_TPC_RPRT = 3,
905 RTW_WLAN_ACTION_SPCT_CHL_SWITCH = 4,
906 RTW_WLAN_ACTION_SPCT_EXT_CHL_SWITCH = 5,
907 };
908
909 enum _PUBLIC_ACTION{
910 ACT_PUBLIC_BSSCOEXIST = 0,
911 ACT_PUBLIC_DSE_ENABLE = 1,
912 ACT_PUBLIC_DSE_DEENABLE = 2,
913 ACT_PUBLIC_DSE_REG_LOCATION = 3,
914 ACT_PUBLIC_EXT_CHL_SWITCH = 4,
915 ACT_PUBLIC_DSE_MSR_REQ = 5,
916 ACT_PUBLIC_DSE_MSR_RPRT = 6,
917 ACT_PUBLIC_MP = 7,
918 ACT_PUBLIC_DSE_PWR_CONSTRAINT = 8,
919 ACT_PUBLIC_VENDOR = 9,
920 ACT_PUBLIC_GAS_INITIAL_REQ = 10,
921 ACT_PUBLIC_GAS_INITIAL_RSP = 11,
922 ACT_PUBLIC_GAS_COMEBACK_REQ = 12,
923 ACT_PUBLIC_GAS_COMEBACK_RSP = 13,
924 ACT_PUBLIC_TDLS_DISCOVERY_RSP = 14,
925 ACT_PUBLIC_LOCATION_TRACK = 15,
926 ACT_PUBLIC_MAX
927 };
928
929
930 enum rtw_ieee80211_back_actioncode {
931 RTW_WLAN_ACTION_ADDBA_REQ = 0,
932 RTW_WLAN_ACTION_ADDBA_RESP = 1,
933 RTW_WLAN_ACTION_DELBA = 2,
934 };
935
936
937 enum rtw_ieee80211_ht_actioncode {
938 RTW_WLAN_ACTION_HT_NOTI_CHNL_WIDTH = 0,
939 RTW_WLAN_ACTION_HT_SM_PS = 1,
940 RTW_WLAN_ACTION_HT_PSMP = 2,
941 RTW_WLAN_ACTION_HT_SET_PCO_PHASE = 3,
942 RTW_WLAN_ACTION_HT_CSI = 4,
943 RTW_WLAN_ACTION_HT_NON_COMPRESS_BEAMFORMING = 5,
944 RTW_WLAN_ACTION_HT_COMPRESS_BEAMFORMING = 6,
945 RTW_WLAN_ACTION_HT_ASEL_FEEDBACK = 7,
946 };
947
948
949 enum rtw_ieee80211_back_parties {
950 RTW_WLAN_BACK_RECIPIENT = 0,
951 RTW_WLAN_BACK_INITIATOR = 1,
952 RTW_WLAN_BACK_TIMER = 2,
953 };
954
955
956 enum rtw_ieee80211_vht_actioncode{
957 RTW_WLAN_ACTION_VHT_COMPRESSED_BEAMFORMING = 0,
958 RTW_WLAN_ACTION_VHT_GROUPID_MANAGEMENT = 1,
959 RTW_WLAN_ACTION_VHT_OPMODE_NOTIFICATION = 2,
960 };
961
962
963 #define OUI_MICROSOFT 0x0050f2
964
965 #define WME_OUI_TYPE 2
966 #define WME_OUI_SUBTYPE_INFORMATION_ELEMENT 0
967 #define WME_OUI_SUBTYPE_PARAMETER_ELEMENT 1
968 #define WME_OUI_SUBTYPE_TSPEC_ELEMENT 2
969 #define WME_VERSION 1
970
971 #define WME_ACTION_CODE_SETUP_REQUEST 0
972 #define WME_ACTION_CODE_SETUP_RESPONSE 1
973 #define WME_ACTION_CODE_TEARDOWN 2
974
975 #define WME_SETUP_RESPONSE_STATUS_ADMISSION_ACCEPTED 0
976 #define WME_SETUP_RESPONSE_STATUS_INVALID_PARAMETERS 1
977 #define WME_SETUP_RESPONSE_STATUS_REFUSED 3
978
979 #define WME_TSPEC_DIRECTION_UPLINK 0
980 #define WME_TSPEC_DIRECTION_DOWNLINK 1
981 #define WME_TSPEC_DIRECTION_BI_DIRECTIONAL 3
982
983
984 #define OUI_BROADCOM 0x00904c
985
986 #define VENDOR_HT_CAPAB_OUI_TYPE 0x33
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003 enum rtw_ieee80211_channel_flags {
1004 RTW_IEEE80211_CHAN_DISABLED = 1<<0,
1005 RTW_IEEE80211_CHAN_PASSIVE_SCAN = 1<<1,
1006 RTW_IEEE80211_CHAN_NO_IBSS = 1<<2,
1007 RTW_IEEE80211_CHAN_RADAR = 1<<3,
1008 RTW_IEEE80211_CHAN_NO_HT40PLUS = 1<<4,
1009 RTW_IEEE80211_CHAN_NO_HT40MINUS = 1<<5,
1010 };
1011
1012 #define RTW_IEEE80211_CHAN_NO_HT40 \
1013 (RTW_IEEE80211_CHAN_NO_HT40PLUS | RTW_IEEE80211_CHAN_NO_HT40MINUS)
1014
1015
1016 struct rtw_ieee80211_channel {
1017
1018
1019 u16 hw_value;
1020 u32 flags;
1021
1022
1023
1024
1025
1026
1027
1028 };
1029
1030 #define CHAN_FMT \
1031 \
1032 \
1033 "hw_value:%u, " \
1034 "flags:0x%08x" \
1035 \
1036 \
1037 \
1038 \
1039 \
1040 \
1041
1042
1043 #define CHAN_ARG(channel) \
1044 \
1045 \
1046 (channel)->hw_value \
1047 , (channel)->flags \
1048 \
1049 \
1050 \
1051 \
1052 \
1053 \
1054 \
1055
1056
1057 struct rtw_ieee802_11_elems {
1058 u8 *ssid;
1059 u8 ssid_len;
1060 u8 *supp_rates;
1061 u8 supp_rates_len;
1062 u8 *fh_params;
1063 u8 fh_params_len;
1064 u8 *ds_params;
1065 u8 ds_params_len;
1066 u8 *cf_params;
1067 u8 cf_params_len;
1068 u8 *tim;
1069 u8 tim_len;
1070 u8 *ibss_params;
1071 u8 ibss_params_len;
1072 u8 *challenge;
1073 u8 challenge_len;
1074 u8 *erp_info;
1075 u8 erp_info_len;
1076 u8 *ext_supp_rates;
1077 u8 ext_supp_rates_len;
1078 u8 *wpa_ie;
1079 u8 wpa_ie_len;
1080 u8 *rsn_ie;
1081 u8 rsn_ie_len;
1082 u8 *wme;
1083 u8 wme_len;
1084 u8 *wme_tspec;
1085 u8 wme_tspec_len;
1086 u8 *wps_ie;
1087 u8 wps_ie_len;
1088 u8 *power_cap;
1089 u8 power_cap_len;
1090 u8 *supp_channels;
1091 u8 supp_channels_len;
1092 u8 *mdie;
1093 u8 mdie_len;
1094 u8 *ftie;
1095 u8 ftie_len;
1096 u8 *timeout_int;
1097 u8 timeout_int_len;
1098 u8 *ht_capabilities;
1099 u8 ht_capabilities_len;
1100 u8 *ht_operation;
1101 u8 ht_operation_len;
1102 u8 *vendor_ht_cap;
1103 u8 vendor_ht_cap_len;
1104 u8 *vht_capabilities;
1105 u8 vht_capabilities_len;
1106 u8 *vht_operation;
1107 u8 vht_operation_len;
1108 u8 *vht_op_mode_notify;
1109 u8 vht_op_mode_notify_len;
1110 };
1111
1112 typedef enum { ParseOK = 0, ParseUnknown = 1, ParseFailed = -1 } ParseRes;
1113
1114 ParseRes rtw_ieee802_11_parse_elems(u8 *start, uint len,
1115 struct rtw_ieee802_11_elems *elems,
1116 int show_errors);
1117
1118 u8 *rtw_set_fixed_ie(unsigned char *pbuf, unsigned int len, unsigned char *source, unsigned int *frlen);
1119 u8 *rtw_set_ie(u8 *pbuf, sint index, uint len, u8 *source, uint *frlen);
1120
1121 enum secondary_ch_offset {
1122 SCN = 0,
1123 SCA = 1,
1124 SCB = 3,
1125 };
1126
1127 u8 *rtw_get_ie(u8*pbuf, sint index, sint *len, sint limit);
1128 u8 *rtw_get_ie_ex(u8 *in_ie, uint in_len, u8 eid, u8 *oui, u8 oui_len, u8 *ie, uint *ielen);
1129 int rtw_ies_remove_ie(u8 *ies, uint *ies_len, uint offset, u8 eid, u8 *oui, u8 oui_len);
1130
1131 void rtw_set_supported_rate(u8 *SupportedRates, uint mode) ;
1132
1133 unsigned char *rtw_get_wpa_ie(unsigned char *pie, int *wpa_ie_len, int limit);
1134 unsigned char *rtw_get_wpa2_ie(unsigned char *pie, int *rsn_ie_len, int limit);
1135 int rtw_get_wpa_cipher_suite(u8 *s);
1136 int rtw_get_wpa2_cipher_suite(u8 *s);
1137 int rtw_get_wapi_ie(u8 *in_ie, uint in_len, u8 *wapi_ie, u16 *wapi_len);
1138 int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x);
1139 int rtw_parse_wpa2_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x);
1140
1141 void rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, u16 *wpa_len);
1142
1143 u8 rtw_is_wps_ie(u8 *ie_ptr, uint *wps_ielen);
1144 u8 *rtw_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen);
1145 u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id , u8 *buf_attr, u32 *len_attr);
1146 u8 *rtw_get_wps_attr_content(u8 *wps_ie, uint wps_ielen, u16 target_attr_id , u8 *buf_content, uint *len_content);
1147
1148
1149
1150
1151
1152
1153
1154 #define for_each_ie(ie, buf, buf_len) \
1155 for (ie = (void*)buf; (((u8 *)ie) - ((u8 *)buf) + 1) < buf_len; ie = (void*)(((u8 *)ie) + *(((u8 *)ie)+1) + 2))
1156
1157 uint rtw_get_rateset_len(u8 *rateset);
1158
1159 struct registry_priv;
1160 int rtw_generate_ie(struct registry_priv *pregistrypriv);
1161
1162
1163 int rtw_get_bit_value_from_ieee_value(u8 val);
1164
1165 bool rtw_is_cckrates_included(u8 *rate);
1166
1167 bool rtw_is_cckratesonly_included(u8 *rate);
1168
1169 int rtw_check_network_type(unsigned char *rate, int ratelen, int channel);
1170
1171 void rtw_get_bcn_info(struct wlan_network *pnetwork);
1172
1173 void rtw_macaddr_cfg(struct device *dev, u8 *mac_addr);
1174
1175 u16 rtw_mcs_rate(u8 rf_type, u8 bw_40MHz, u8 short_GI, unsigned char * MCS_rate);
1176
1177 int rtw_action_frame_parse(const u8 *frame, u32 frame_len, u8 *category, u8 *action);
1178 const char *action_public_str(u8 action);
1179
1180 #endif