1 /****************************************************************************** 2 * 3 * Copyright(c) 2007 - 2017 Realtek Corporation. 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 *****************************************************************************/ 15 #ifndef __IEEE80211_H 16 #define __IEEE80211_H 17 18 #define MGMT_QUEUE_NUM 5 19 20 #define ETH_ALEN 6 21 #define ETH_TYPE_LEN 2 22 #define PAYLOAD_TYPE_LEN 1 23 24 #define NET80211_TU_TO_US 1024 /* unit:us */ 25 #define DEFAULT_BCN_INTERVAL 100 /* 100 ms */ 26 27 #ifdef CONFIG_AP_MODE 28 29 #define RTL_IOCTL_HOSTAPD (SIOCDEVPRIVATE + 2) 30 31 /* RTL871X_IOCTL_HOSTAPD ioctl() cmd: */ 32 enum { 33 RTL871X_HOSTAPD_FLUSH = 1, 34 RTL871X_HOSTAPD_ADD_STA = 2, 35 RTL871X_HOSTAPD_REMOVE_STA = 3, 36 RTL871X_HOSTAPD_GET_INFO_STA = 4, 37 /* REMOVED: PRISM2_HOSTAPD_RESET_TXEXC_STA = 5, */ 38 RTL871X_HOSTAPD_GET_WPAIE_STA = 5, 39 RTL871X_SET_ENCRYPTION = 6, 40 RTL871X_GET_ENCRYPTION = 7, 41 RTL871X_HOSTAPD_SET_FLAGS_STA = 8, 42 RTL871X_HOSTAPD_GET_RID = 9, 43 RTL871X_HOSTAPD_SET_RID = 10, 44 RTL871X_HOSTAPD_SET_ASSOC_AP_ADDR = 11, 45 RTL871X_HOSTAPD_SET_GENERIC_ELEMENT = 12, 46 RTL871X_HOSTAPD_MLME = 13, 47 RTL871X_HOSTAPD_SCAN_REQ = 14, 48 RTL871X_HOSTAPD_STA_CLEAR_STATS = 15, 49 RTL871X_HOSTAPD_SET_BEACON = 16, 50 RTL871X_HOSTAPD_SET_WPS_BEACON = 17, 51 RTL871X_HOSTAPD_SET_WPS_PROBE_RESP = 18, 52 RTL871X_HOSTAPD_SET_WPS_ASSOC_RESP = 19, 53 RTL871X_HOSTAPD_SET_HIDDEN_SSID = 20, 54 RTL871X_HOSTAPD_SET_MACADDR_ACL = 21, 55 RTL871X_HOSTAPD_ACL_ADD_STA = 22, 56 RTL871X_HOSTAPD_ACL_REMOVE_STA = 23, 57 }; 58 #endif /* CONFIG_AP_MODE */ 59 60 /* STA flags */ 61 #define WLAN_STA_AUTH BIT(0) 62 #define WLAN_STA_ASSOC BIT(1) 63 #define WLAN_STA_PS BIT(2) 64 #define WLAN_STA_TIM BIT(3) 65 #define WLAN_STA_PERM BIT(4) 66 #define WLAN_STA_AUTHORIZED BIT(5) 67 #define WLAN_STA_PENDING_POLL BIT(6) /* pending activity poll not ACKed */ 68 #define WLAN_STA_SHORT_PREAMBLE BIT(7) 69 #define WLAN_STA_PREAUTH BIT(8) 70 #define WLAN_STA_WME BIT(9) 71 #define WLAN_STA_MFP BIT(10) 72 #define WLAN_STA_HT BIT(11) 73 #define WLAN_STA_WPS BIT(12) 74 #define WLAN_STA_MAYBE_WPS BIT(13) 75 #define WLAN_STA_VHT BIT(14) 76 #define WLAN_STA_WDS BIT(15) 77 #define WLAN_STA_MULTI_AP BIT(16) 78 #define WLAN_STA_AMSDU_DISABLE BIT(17) 79 #define WLAN_STA_NONERP BIT(31) 80 81 #define IEEE_CMD_SET_WPA_PARAM 1 82 #define IEEE_CMD_SET_WPA_IE 2 83 #define IEEE_CMD_SET_ENCRYPTION 3 84 #define IEEE_CMD_MLME 4 85 86 #define IEEE_PARAM_WPA_ENABLED 1 87 #define IEEE_PARAM_TKIP_COUNTERMEASURES 2 88 #define IEEE_PARAM_DROP_UNENCRYPTED 3 89 #define IEEE_PARAM_PRIVACY_INVOKED 4 90 #define IEEE_PARAM_AUTH_ALGS 5 91 #define IEEE_PARAM_IEEE_802_1X 6 92 #define IEEE_PARAM_WPAX_SELECT 7 93 94 #define AUTH_ALG_OPEN_SYSTEM 0x1 95 #define AUTH_ALG_SHARED_KEY 0x2 96 #define AUTH_ALG_LEAP 0x00000004 97 98 #define IEEE_MLME_STA_DEAUTH 1 99 #define IEEE_MLME_STA_DISASSOC 2 100 101 #define IEEE_CRYPT_ERR_UNKNOWN_ALG 2 102 #define IEEE_CRYPT_ERR_UNKNOWN_ADDR 3 103 #define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED 4 104 #define IEEE_CRYPT_ERR_KEY_SET_FAILED 5 105 #define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED 6 106 #define IEEE_CRYPT_ERR_CARD_CONF_FAILED 7 107 108 109 #define IEEE_CRYPT_ALG_NAME_LEN 16 110 111 #define WPA_CIPHER_NONE BIT(0) 112 #define WPA_CIPHER_WEP40 BIT(1) 113 #define WPA_CIPHER_WEP104 BIT(2) 114 #define WPA_CIPHER_TKIP BIT(3) 115 #define WPA_CIPHER_CCMP BIT(4) 116 #define WPA_CIPHER_GCMP BIT(5) 117 #define WPA_CIPHER_GCMP_256 BIT(6) 118 #define WPA_CIPHER_CCMP_256 BIT(7) 119 #define WPA_CIPHER_BIP_CMAC_128 BIT(8) 120 #define WPA_CIPHER_BIP_GMAC_128 BIT(9) 121 #define WPA_CIPHER_BIP_GMAC_256 BIT(10) 122 #define WPA_CIPHER_BIP_CMAC_256 BIT(11) 123 124 125 #define WPA_SELECTOR_LEN 4 126 extern u8 RTW_WPA_OUI_TYPE[] ; 127 extern u16 RTW_WPA_VERSION ; 128 extern u8 WPA_AUTH_KEY_MGMT_NONE[]; 129 extern u8 WPA_AUTH_KEY_MGMT_UNSPEC_802_1X[]; 130 extern u8 WPA_AUTH_KEY_MGMT_PSK_OVER_802_1X[]; 131 extern u8 WPA_CIPHER_SUITE_NONE[]; 132 extern u8 WPA_CIPHER_SUITE_WEP40[]; 133 extern u8 WPA_CIPHER_SUITE_TKIP[]; 134 extern u8 WPA_CIPHER_SUITE_WRAP[]; 135 extern u8 WPA_CIPHER_SUITE_CCMP[]; 136 extern u8 RSN_CIPHER_SUITE_GCMP[]; 137 extern u8 RSN_CIPHER_SUITE_GCMP_256[]; 138 extern u8 RSN_CIPHER_SUITE_CCMP_256[]; 139 extern u8 WPA_CIPHER_SUITE_WEP104[]; 140 141 142 #define RSN_HEADER_LEN 4 143 #define RSN_SELECTOR_LEN 4 144 145 extern u16 RSN_VERSION_BSD; 146 extern u8 RSN_CIPHER_SUITE_NONE[]; 147 extern u8 RSN_CIPHER_SUITE_WEP40[]; 148 extern u8 RSN_CIPHER_SUITE_TKIP[]; 149 extern u8 RSN_CIPHER_SUITE_WRAP[]; 150 extern u8 RSN_CIPHER_SUITE_CCMP[]; 151 extern u8 RSN_CIPHER_SUITE_WEP104[]; 152 153 /* AKM suite type */ 154 extern u8 WLAN_AKM_8021X[]; 155 extern u8 WLAN_AKM_PSK[]; 156 extern u8 WLAN_AKM_FT_8021X[]; 157 extern u8 WLAN_AKM_FT_PSK[]; 158 extern u8 WLAN_AKM_8021X_SHA256[]; 159 extern u8 WLAN_AKM_PSK_SHA256[]; 160 extern u8 WLAN_AKM_TDLS[]; 161 extern u8 WLAN_AKM_SAE[]; 162 extern u8 WLAN_AKM_FT_OVER_SAE[]; 163 extern u8 WLAN_AKM_8021X_SUITE_B[]; 164 extern u8 WLAN_AKM_8021X_SUITE_B_192[]; 165 extern u8 WLAN_AKM_FILS_SHA256[]; 166 extern u8 WLAN_AKM_FILS_SHA384[]; 167 extern u8 WLAN_AKM_FT_FILS_SHA256[]; 168 extern u8 WLAN_AKM_FT_FILS_SHA384[]; 169 170 #define WLAN_AKM_TYPE_8021X BIT(0) 171 #define WLAN_AKM_TYPE_PSK BIT(1) 172 #define WLAN_AKM_TYPE_FT_8021X BIT(2) 173 #define WLAN_AKM_TYPE_FT_PSK BIT(3) 174 #define WLAN_AKM_TYPE_8021X_SHA256 BIT(4) 175 #define WLAN_AKM_TYPE_PSK_SHA256 BIT(5) 176 #define WLAN_AKM_TYPE_TDLS BIT(6) 177 #define WLAN_AKM_TYPE_SAE BIT(7) 178 #define WLAN_AKM_TYPE_FT_OVER_SAE BIT(8) 179 #define WLAN_AKM_TYPE_8021X_SUITE_B BIT(9) 180 #define WLAN_AKM_TYPE_8021X_SUITE_B_192 BIT(10) 181 #define WLAN_AKM_TYPE_FILS_SHA256 BIT(11) 182 #define WLAN_AKM_TYPE_FILS_SHA384 BIT(12) 183 #define WLAN_AKM_TYPE_FT_FILS_SHA256 BIT(13) 184 #define WLAN_AKM_TYPE_FT_FILS_SHA384 BIT(14) 185 186 /* IEEE 802.11i */ 187 #define PMKID_LEN 16 188 #define PMK_LEN 32 189 #define PMK_LEN_SUITE_B_192 48 190 #define PMK_LEN_MAX 48 191 #define WPA_REPLAY_COUNTER_LEN 8 192 #define WPA_NONCE_LEN 32 193 #define WPA_KEY_RSC_LEN 8 194 #define WPA_GMK_LEN 32 195 #define WPA_GTK_MAX_LEN 32 196 197 /* IEEE 802.11, 8.5.2 EAPOL-Key frames */ 198 #define WPA_KEY_INFO_TYPE_MASK ((u16) (BIT(0) | BIT(1) | BIT(2))) 199 #define WPA_KEY_INFO_TYPE_AKM_DEFINED 0 200 #define WPA_KEY_INFO_TYPE_HMAC_MD5_RC4 BIT(0) 201 #define WPA_KEY_INFO_TYPE_HMAC_SHA1_AES BIT(1) 202 #define WPA_KEY_INFO_TYPE_AES_128_CMAC 3 203 #define WPA_KEY_INFO_KEY_TYPE BIT(3) /* 1 = Pairwise, 0 = Group key */ 204 /* bit4..5 is used in WPA, but is reserved in IEEE 802.11i/RSN */ 205 #define WPA_KEY_INFO_KEY_INDEX_MASK (BIT(4) | BIT(5)) 206 #define WPA_KEY_INFO_KEY_INDEX_SHIFT 4 207 #define WPA_KEY_INFO_INSTALL BIT(6) /* pairwise */ 208 #define WPA_KEY_INFO_TXRX BIT(6) /* group */ 209 #define WPA_KEY_INFO_ACK BIT(7) 210 #define WPA_KEY_INFO_MIC BIT(8) 211 #define WPA_KEY_INFO_SECURE BIT(9) 212 #define WPA_KEY_INFO_ERROR BIT(10) 213 #define WPA_KEY_INFO_REQUEST BIT(11) 214 #define WPA_KEY_INFO_ENCR_KEY_DATA BIT(12) /* IEEE 802.11i/RSN only */ 215 #define WPA_KEY_INFO_SMK_MESSAGE BIT(13) 216 217 struct ieee802_1x_hdr { 218 u8 version; 219 u8 type; 220 u16 length; 221 /* followed by length octets of data */ 222 }; 223 224 struct wpa_eapol_key { 225 u8 type; 226 /* Note: key_info, key_length, and key_data_length are unaligned */ 227 u8 key_info[2]; /* big endian */ 228 u8 key_length[2]; /* big endian */ 229 u8 replay_counter[WPA_REPLAY_COUNTER_LEN]; 230 u8 key_nonce[WPA_NONCE_LEN]; 231 u8 key_iv[16]; 232 u8 key_rsc[WPA_KEY_RSC_LEN]; 233 u8 key_id[8]; /* Reserved in IEEE 802.11i/RSN */ 234 u8 key_mic[16]; 235 u8 key_data_length[2]; /* big endian */ 236 /* followed by key_data_length bytes of key_data */ 237 }; 238 239 typedef enum _RATEID_IDX_ { 240 RATEID_IDX_BGN_40M_2SS = 0, 241 RATEID_IDX_BGN_40M_1SS = 1, 242 RATEID_IDX_BGN_20M_2SS_BN = 2, 243 RATEID_IDX_BGN_20M_1SS_BN = 3, 244 RATEID_IDX_GN_N2SS = 4, 245 RATEID_IDX_GN_N1SS = 5, 246 RATEID_IDX_BG = 6, 247 RATEID_IDX_G = 7, 248 RATEID_IDX_B = 8, 249 RATEID_IDX_VHT_2SS = 9, 250 RATEID_IDX_VHT_1SS = 10, 251 RATEID_IDX_MIX1 = 11, 252 RATEID_IDX_MIX2 = 12, 253 RATEID_IDX_VHT_3SS = 13, 254 RATEID_IDX_BGN_3SS = 14, 255 RATEID_IDX_BGN_4SS = 15, 256 RATEID_IDX_VHT_4SS = 16, 257 } RATEID_IDX, *PRATEID_IDX; 258 259 typedef enum _RATR_TABLE_MODE { 260 RATR_INX_WIRELESS_NGB = 0, /* BGN 40 Mhz 2SS 1SS */ 261 RATR_INX_WIRELESS_NG = 1, /* GN or N */ 262 RATR_INX_WIRELESS_NB = 2, /* BGN 20 Mhz 2SS 1SS or BN */ 263 RATR_INX_WIRELESS_N = 3, 264 RATR_INX_WIRELESS_GB = 4, 265 RATR_INX_WIRELESS_G = 5, 266 RATR_INX_WIRELESS_B = 6, 267 RATR_INX_WIRELESS_MC = 7, 268 RATR_INX_WIRELESS_AC_N = 8, 269 } RATR_TABLE_MODE, *PRATR_TABLE_MODE; 270 271 272 enum NETWORK_TYPE { 273 WIRELESS_INVALID = 0, 274 /* Sub-Element */ 275 WIRELESS_11B = BIT(0), /* tx: cck only , rx: cck only, hw: cck */ 276 WIRELESS_11G = BIT(1), /* tx: ofdm only, rx: ofdm & cck, hw: cck & ofdm */ 277 WIRELESS_11A = BIT(2), /* tx: ofdm only, rx: ofdm only, hw: ofdm only */ 278 WIRELESS_11_24N = BIT(3), /* tx: MCS only, rx: MCS & cck, hw: MCS & cck */ 279 WIRELESS_11_5N = BIT(4), /* tx: MCS only, rx: MCS & ofdm, hw: ofdm only */ 280 WIRELESS_AUTO = BIT(5), 281 WIRELESS_11AC = BIT(6), 282 283 /* Combination */ 284 /* Type for current wireless mode */ 285 WIRELESS_11BG = (WIRELESS_11B | WIRELESS_11G), /* tx: cck & ofdm, rx: cck & ofdm & MCS, hw: cck & ofdm */ 286 WIRELESS_11G_24N = (WIRELESS_11G | WIRELESS_11_24N), /* tx: ofdm & MCS, rx: ofdm & cck & MCS, hw: cck & ofdm */ 287 WIRELESS_11A_5N = (WIRELESS_11A | WIRELESS_11_5N), /* tx: ofdm & MCS, rx: ofdm & MCS, hw: ofdm only */ 288 WIRELESS_11B_24N = (WIRELESS_11B | WIRELESS_11_24N), /* tx: ofdm & cck & MCS, rx: ofdm & cck & MCS, hw: ofdm & cck */ 289 WIRELESS_11BG_24N = (WIRELESS_11B | WIRELESS_11G | WIRELESS_11_24N), /* tx: ofdm & cck & MCS, rx: ofdm & cck & MCS, hw: ofdm & cck */ 290 WIRELESS_11_24AC = (WIRELESS_11B | WIRELESS_11G | WIRELESS_11AC), 291 WIRELESS_11_5AC = (WIRELESS_11A | WIRELESS_11AC), 292 293 294 /* Type for registry default wireless mode */ 295 WIRELESS_11AGN = (WIRELESS_11A | WIRELESS_11G | WIRELESS_11_24N | WIRELESS_11_5N), /* tx: ofdm & MCS, rx: ofdm & MCS, hw: ofdm only */ 296 WIRELESS_11ABGN = (WIRELESS_11A | WIRELESS_11B | WIRELESS_11G | WIRELESS_11_24N | WIRELESS_11_5N), 297 WIRELESS_MODE_24G = (WIRELESS_11B | WIRELESS_11G | WIRELESS_11_24N), 298 WIRELESS_MODE_5G = (WIRELESS_11A | WIRELESS_11_5N | WIRELESS_11AC), 299 WIRELESS_MODE_MAX = (WIRELESS_11A | WIRELESS_11B | WIRELESS_11G | WIRELESS_11_24N | WIRELESS_11_5N | WIRELESS_11AC), 300 }; 301 302 #define SUPPORTED_24G_NETTYPE_MSK WIRELESS_MODE_24G 303 #define SUPPORTED_5G_NETTYPE_MSK WIRELESS_MODE_5G 304 305 #define IsLegacyOnly(NetType) ((NetType) == ((NetType) & (WIRELESS_11BG | WIRELESS_11A))) 306 307 #define IsSupported24G(NetType) ((NetType) & SUPPORTED_24G_NETTYPE_MSK ? _TRUE : _FALSE) 308 #define is_supported_5g(NetType) ((NetType) & SUPPORTED_5G_NETTYPE_MSK ? _TRUE : _FALSE) 309 310 #define IsEnableHWCCK(NetType) IsSupported24G(NetType) 311 #define IsEnableHWOFDM(NetType) ((NetType) & (WIRELESS_11G | WIRELESS_11_24N | SUPPORTED_5G_NETTYPE_MSK) ? _TRUE : _FALSE) 312 313 #define IsSupportedRxCCK(NetType) IsEnableHWCCK(NetType) 314 #define IsSupportedRxOFDM(NetType) IsEnableHWOFDM(NetType) 315 #define IsSupportedRxHT(NetType) IsEnableHWOFDM(NetType) 316 317 #define IsSupportedTxCCK(NetType) ((NetType) & (WIRELESS_11B) ? _TRUE : _FALSE) 318 #define IsSupportedTxOFDM(NetType) ((NetType) & (WIRELESS_11G | WIRELESS_11A) ? _TRUE : _FALSE) 319 #define is_supported_ht(NetType) ((NetType) & (WIRELESS_11_24N | WIRELESS_11_5N) ? _TRUE : _FALSE) 320 321 #define is_supported_vht(NetType) ((NetType) & (WIRELESS_11AC) ? _TRUE : _FALSE) 322 323 324 325 326 327 typedef struct ieee_param { 328 u32 cmd; 329 u8 sta_addr[ETH_ALEN]; 330 union { 331 struct { 332 u8 name; 333 u32 value; 334 } wpa_param; 335 struct { 336 u32 len; 337 u8 reserved[32]; 338 u8 data[0]; 339 } wpa_ie; 340 struct { 341 int command; 342 int reason_code; 343 } mlme; 344 struct { 345 u8 alg[IEEE_CRYPT_ALG_NAME_LEN]; 346 u8 set_tx; 347 u32 err; 348 u8 idx; 349 u8 seq[8]; /* sequence counter (set: RX, get: TX) */ 350 u16 key_len; 351 u8 key[0]; 352 } crypt; 353 #ifdef CONFIG_AP_MODE 354 struct { 355 u16 aid; 356 u16 capability; 357 int flags; 358 u8 tx_supp_rates[16]; 359 struct rtw_ieee80211_ht_cap ht_cap; 360 } add_sta; 361 struct { 362 u8 reserved[2];/* for set max_num_sta */ 363 u8 buf[0]; 364 } bcn_ie; 365 #endif 366 367 } u; 368 } ieee_param; 369 370 #ifdef CONFIG_AP_MODE 371 typedef struct ieee_param_ex { 372 u32 cmd; 373 u8 sta_addr[ETH_ALEN]; 374 u8 data[0]; 375 } ieee_param_ex; 376 377 struct sta_data { 378 u16 aid; 379 u16 capability; 380 int flags; 381 u32 sta_set; 382 u8 tx_supp_rates[16]; 383 u32 tx_supp_rates_len; 384 struct rtw_ieee80211_ht_cap ht_cap; 385 u64 rx_pkts; 386 u64 rx_bytes; 387 u64 rx_drops; 388 u64 tx_pkts; 389 u64 tx_bytes; 390 u64 tx_drops; 391 }; 392 #endif 393 394 395 #if WIRELESS_EXT < 17 396 #define IW_QUAL_QUAL_INVALID 0x10 397 #define IW_QUAL_LEVEL_INVALID 0x20 398 #define IW_QUAL_NOISE_INVALID 0x40 399 #define IW_QUAL_QUAL_UPDATED 0x1 400 #define IW_QUAL_LEVEL_UPDATED 0x2 401 #define IW_QUAL_NOISE_UPDATED 0x4 402 #endif 403 404 #define IEEE80211_DATA_LEN 2304 405 /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section 406 6.2.1.1.2. 407 408 The figure in section 7.1.2 suggests a body size of up to 2312 409 bytes is allowed, which is a bit confusing, I suspect this 410 represents the 2304 bytes of real data, plus a possible 8 bytes of 411 WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */ 412 413 414 #define IEEE80211_HLEN 30 415 #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN) 416 417 418 /* this is stolen from ipw2200 driver */ 419 #define IEEE_IBSS_MAC_HASH_SIZE 31 420 421 struct ieee_ibss_seq { 422 u8 mac[ETH_ALEN]; 423 u16 seq_num; 424 u16 frag_num; 425 unsigned long packet_time; 426 _list list; 427 }; 428 429 #if defined(PLATFORM_LINUX) || defined(PLATFORM_FREEBSD) 430 431 struct rtw_ieee80211_hdr { 432 u16 frame_ctl; 433 u16 duration_id; 434 u8 addr1[ETH_ALEN]; 435 u8 addr2[ETH_ALEN]; 436 u8 addr3[ETH_ALEN]; 437 u16 seq_ctl; 438 u8 addr4[ETH_ALEN]; 439 } __attribute__((packed)); 440 441 struct rtw_ieee80211_hdr_3addr { 442 u16 frame_ctl; 443 u16 duration_id; 444 u8 addr1[ETH_ALEN]; 445 u8 addr2[ETH_ALEN]; 446 u8 addr3[ETH_ALEN]; 447 u16 seq_ctl; 448 } __attribute__((packed)); 449 450 451 struct rtw_ieee80211_hdr_qos { 452 u16 frame_ctl; 453 u16 duration_id; 454 u8 addr1[ETH_ALEN]; 455 u8 addr2[ETH_ALEN]; 456 u8 addr3[ETH_ALEN]; 457 u16 seq_ctl; 458 u8 addr4[ETH_ALEN]; 459 u16 qc; 460 } __attribute__((packed)); 461 462 struct rtw_ieee80211_hdr_3addr_qos { 463 u16 frame_ctl; 464 u16 duration_id; 465 u8 addr1[ETH_ALEN]; 466 u8 addr2[ETH_ALEN]; 467 u8 addr3[ETH_ALEN]; 468 u16 seq_ctl; 469 u16 qc; 470 } __attribute__((packed)); 471 472 struct eapol { 473 u8 snap[6]; 474 u16 ethertype; 475 u8 version; 476 u8 type; 477 u16 length; 478 } __attribute__((packed)); 479 480 struct rtw_ieee80211s_hdr { 481 u8 flags; 482 u8 ttl; 483 u32 seqnum; 484 u8 eaddr1[ETH_ALEN]; 485 u8 eaddr2[ETH_ALEN]; 486 } __attribute__((packed)); 487 488 /** 489 * struct rtw_ieee80211_rann_ie 490 * 491 * This structure refers to "Root Announcement information element" 492 */ 493 struct rtw_ieee80211_rann_ie { 494 u8 rann_flags; 495 u8 rann_hopcount; 496 u8 rann_ttl; 497 u8 rann_addr[ETH_ALEN]; 498 u32 rann_seq; 499 u32 rann_interval; 500 u32 rann_metric; 501 } __attribute__((packed)); 502 #endif 503 504 /* Some IEEE 802.11x packet types are corresponding to parsing_eapol_packet() */ 505 enum eap_type { 506 EAP_PACKET = 0, 507 NON_EAPOL, 508 EAPOL_START, 509 EAPOL_LOGOFF, 510 EAPOL_KEY, 511 EAPOL_ENCAP_ASF_ALERT, 512 EAPOL_PACKET, 513 EAPOL_WPA_GROUP_KEY_1_2, 514 EAPOL_WPA_GROUP_KEY_2_2, 515 EAPOL_1_4, 516 EAPOL_2_4, 517 EAPOL_3_4, 518 EAPOL_4_4, 519 }; 520 521 #define IEEE80211_3ADDR_LEN 24 522 #define IEEE80211_4ADDR_LEN 30 523 #define IEEE80211_FCS_LEN 4 524 525 #define MIN_FRAG_THRESHOLD 256U 526 #define MAX_FRAG_THRESHOLD 2346U 527 528 /* Frame control field constants */ 529 #define RTW_IEEE80211_FCTL_VERS 0x0003 530 #define RTW_IEEE80211_FCTL_FTYPE 0x000c 531 #define RTW_IEEE80211_FCTL_STYPE 0x00f0 532 #define RTW_IEEE80211_FCTL_TODS 0x0100 533 #define RTW_IEEE80211_FCTL_FROMDS 0x0200 534 #define RTW_IEEE80211_FCTL_MOREFRAGS 0x0400 535 #define RTW_IEEE80211_FCTL_RETRY 0x0800 536 #define RTW_IEEE80211_FCTL_PM 0x1000 537 #define RTW_IEEE80211_FCTL_MOREDATA 0x2000 538 #define RTW_IEEE80211_FCTL_PROTECTED 0x4000 539 #define RTW_IEEE80211_FCTL_ORDER 0x8000 540 #define RTW_IEEE80211_FCTL_CTL_EXT 0x0f00 541 542 #define RTW_IEEE80211_FTYPE_MGMT 0x0000 543 #define RTW_IEEE80211_FTYPE_CTL 0x0004 544 #define RTW_IEEE80211_FTYPE_DATA 0x0008 545 #define RTW_IEEE80211_FTYPE_EXT 0x000c 546 547 /* management */ 548 #define RTW_IEEE80211_STYPE_ASSOC_REQ 0x0000 549 #define RTW_IEEE80211_STYPE_ASSOC_RESP 0x0010 550 #define RTW_IEEE80211_STYPE_REASSOC_REQ 0x0020 551 #define RTW_IEEE80211_STYPE_REASSOC_RESP 0x0030 552 #define RTW_IEEE80211_STYPE_PROBE_REQ 0x0040 553 #define RTW_IEEE80211_STYPE_PROBE_RESP 0x0050 554 #define RTW_IEEE80211_STYPE_BEACON 0x0080 555 #define RTW_IEEE80211_STYPE_ATIM 0x0090 556 #define RTW_IEEE80211_STYPE_DISASSOC 0x00A0 557 #define RTW_IEEE80211_STYPE_AUTH 0x00B0 558 #define RTW_IEEE80211_STYPE_DEAUTH 0x00C0 559 #define RTW_IEEE80211_STYPE_ACTION 0x00D0 560 561 /* control */ 562 #define RTW_IEEE80211_STYPE_CTL_EXT 0x0060 563 #define RTW_IEEE80211_STYPE_BACK_REQ 0x0080 564 #define RTW_IEEE80211_STYPE_BACK 0x0090 565 #define RTW_IEEE80211_STYPE_PSPOLL 0x00A0 566 #define RTW_IEEE80211_STYPE_RTS 0x00B0 567 #define RTW_IEEE80211_STYPE_CTS 0x00C0 568 #define RTW_IEEE80211_STYPE_ACK 0x00D0 569 #define RTW_IEEE80211_STYPE_CFEND 0x00E0 570 #define RTW_IEEE80211_STYPE_CFENDACK 0x00F0 571 572 /* data */ 573 #define RTW_IEEE80211_STYPE_DATA 0x0000 574 #define RTW_IEEE80211_STYPE_DATA_CFACK 0x0010 575 #define RTW_IEEE80211_STYPE_DATA_CFPOLL 0x0020 576 #define RTW_IEEE80211_STYPE_DATA_CFACKPOLL 0x0030 577 #define RTW_IEEE80211_STYPE_NULLFUNC 0x0040 578 #define RTW_IEEE80211_STYPE_CFACK 0x0050 579 #define RTW_IEEE80211_STYPE_CFPOLL 0x0060 580 #define RTW_IEEE80211_STYPE_CFACKPOLL 0x0070 581 #define RTW_IEEE80211_STYPE_QOS_DATA 0x0080 582 #define RTW_IEEE80211_STYPE_QOS_DATA_CFACK 0x0090 583 #define RTW_IEEE80211_STYPE_QOS_DATA_CFPOLL 0x00A0 584 #define RTW_IEEE80211_STYPE_QOS_DATA_CFACKPOLL 0x00B0 585 #define RTW_IEEE80211_STYPE_QOS_NULLFUNC 0x00C0 586 #define RTW_IEEE80211_STYPE_QOS_CFACK 0x00D0 587 #define RTW_IEEE80211_STYPE_QOS_CFPOLL 0x00E0 588 #define RTW_IEEE80211_STYPE_QOS_CFACKPOLL 0x00F0 589 590 /* sequence control field */ 591 #define RTW_IEEE80211_SCTL_FRAG 0x000F 592 #define RTW_IEEE80211_SCTL_SEQ 0xFFF0 593 594 595 #define RTW_ERP_INFO_NON_ERP_PRESENT BIT(0) 596 #define RTW_ERP_INFO_USE_PROTECTION BIT(1) 597 #define RTW_ERP_INFO_BARKER_PREAMBLE_MODE BIT(2) 598 599 /* QoS,QOS */ 600 #define NORMAL_ACK 0 601 #define NO_ACK 1 602 #define NON_EXPLICIT_ACK 2 603 #define BLOCK_ACK 3 604 605 #ifndef ETH_P_PAE 606 #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */ 607 #endif /* ETH_P_PAE */ 608 609 #define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */ 610 611 #define ETH_P_ECONET 0x0018 612 613 #ifndef ETH_P_80211_RAW 614 #define ETH_P_80211_RAW (ETH_P_ECONET + 1) 615 #endif 616 617 /* IEEE 802.11 defines */ 618 619 #define P80211_OUI_LEN 3 620 621 #if defined(PLATFORM_LINUX) || defined(PLATFORM_FREEBSD) 622 623 struct ieee80211_snap_hdr { 624 625 u8 dsap; /* always 0xAA */ 626 u8 ssap; /* always 0xAA */ 627 u8 ctrl; /* always 0x03 */ 628 u8 oui[P80211_OUI_LEN]; /* organizational universal id */ 629 630 } __attribute__((packed)); 631 632 #endif 633 634 #define SNAP_SIZE sizeof(struct ieee80211_snap_hdr) 635 636 #define WLAN_FC_GET_TYPE(fc) ((fc) & RTW_IEEE80211_FCTL_FTYPE) 637 #define WLAN_FC_GET_STYPE(fc) ((fc) & RTW_IEEE80211_FCTL_STYPE) 638 639 #define WLAN_QC_GET_TID(qc) ((qc) & 0x0f) 640 641 #define WLAN_GET_SEQ_FRAG(seq) ((seq) & RTW_IEEE80211_SCTL_FRAG) 642 #define WLAN_GET_SEQ_SEQ(seq) ((seq) & RTW_IEEE80211_SCTL_SEQ) 643 644 /* Authentication algorithms */ 645 #define WLAN_AUTH_OPEN 0 646 #define WLAN_AUTH_SHARED_KEY 1 647 #define WLAN_AUTH_SAE 3 648 649 #define WLAN_AUTH_CHALLENGE_LEN 128 650 651 #define WLAN_CAPABILITY_BSS (1<<0) 652 #define WLAN_CAPABILITY_IBSS (1<<1) 653 #define WLAN_CAPABILITY_CF_POLLABLE (1<<2) 654 #define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3) 655 #define WLAN_CAPABILITY_PRIVACY (1<<4) 656 #define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5) 657 #define WLAN_CAPABILITY_PBCC (1<<6) 658 #define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7) 659 #define WLAN_CAPABILITY_SHORT_SLOT (1<<10) 660 661 /* Status codes */ 662 #define WLAN_STATUS_SUCCESS 0 663 #define WLAN_STATUS_UNSPECIFIED_FAILURE 1 664 #define WLAN_STATUS_CAPS_UNSUPPORTED 10 665 #define WLAN_STATUS_REASSOC_NO_ASSOC 11 666 #define WLAN_STATUS_ASSOC_DENIED_UNSPEC 12 667 #define WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG 13 668 #define WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION 14 669 #define WLAN_STATUS_CHALLENGE_FAIL 15 670 #define WLAN_STATUS_AUTH_TIMEOUT 16 671 #define WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA 17 672 #define WLAN_STATUS_ASSOC_DENIED_RATES 18 673 /* 802.11b */ 674 #define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19 675 #define WLAN_STATUS_ASSOC_DENIED_NOPBCC 20 676 #define WLAN_STATUS_ASSOC_DENIED_NOAGILITY 21 677 678 /* Reason codes */ 679 #define WLAN_REASON_UNSPECIFIED 1 680 #define WLAN_REASON_PREV_AUTH_NOT_VALID 2 681 #define WLAN_REASON_DEAUTH_LEAVING 3 682 #define WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY 4 683 #define WLAN_REASON_DISASSOC_AP_BUSY 5 684 #define WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA 6 685 #define WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA 7 686 #define WLAN_REASON_DISASSOC_STA_HAS_LEFT 8 687 #define WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH 9 688 #define WLAN_REASON_IEEE_802_1X_AUTH_FAILED 23 689 #define WLAN_REASON_MESH_PEER_CANCELED 52 690 #define WLAN_REASON_MESH_MAX_PEERS 53 691 #define WLAN_REASON_MESH_CONFIG 54 692 #define WLAN_REASON_MESH_CLOSE 55 693 #define WLAN_REASON_MESH_MAX_RETRIES 56 694 #define WLAN_REASON_MESH_CONFIRM_TIMEOUT 57 695 #define WLAN_REASON_MESH_INVALID_GTK 58 696 #define WLAN_REASON_MESH_INCONSISTENT_PARAM 59 697 #define WLAN_REASON_MESH_INVALID_SECURITY 60 698 #define WLAN_REASON_MESH_PATH_NOPROXY 61 699 #define WLAN_REASON_MESH_PATH_NOFORWARD 62 700 #define WLAN_REASON_MESH_PATH_DEST_UNREACHABLE 63 701 #define WLAN_REASON_MAC_EXISTS_IN_MBSS 64 702 #define WLAN_REASON_MESH_CHAN_REGULATORY 65 703 #define WLAN_REASON_MESH_CHAN 66 704 #define WLAN_REASON_SA_QUERY_TIMEOUT 65532 705 #define WLAN_REASON_ACTIVE_ROAM 65533 706 #define WLAN_REASON_JOIN_WRONG_CHANNEL 65534 707 #define WLAN_REASON_EXPIRATION_CHK 65535 708 709 #define WLAN_REASON_IS_PRIVATE(reason) ( \ 710 reason == WLAN_REASON_EXPIRATION_CHK \ 711 || reason == WLAN_REASON_JOIN_WRONG_CHANNEL \ 712 || reason == WLAN_REASON_ACTIVE_ROAM \ 713 || reason == WLAN_REASON_SA_QUERY_TIMEOUT \ 714 ) 715 716 /* Information Element IDs */ 717 #define WLAN_EID_SSID 0 718 #define WLAN_EID_SUPP_RATES 1 719 #define WLAN_EID_FH_PARAMS 2 720 #define WLAN_EID_DS_PARAMS 3 721 #define WLAN_EID_CF_PARAMS 4 722 #define WLAN_EID_TIM 5 723 #define WLAN_EID_IBSS_PARAMS 6 724 #define WLAN_EID_CHALLENGE 16 725 /* EIDs defined by IEEE 802.11h - START */ 726 #define WLAN_EID_PWR_CONSTRAINT 32 727 #define WLAN_EID_PWR_CAPABILITY 33 728 #define WLAN_EID_TPC_REQUEST 34 729 #define WLAN_EID_TPC_REPORT 35 730 #define WLAN_EID_SUPPORTED_CHANNELS 36 731 #define WLAN_EID_CHANNEL_SWITCH 37 732 #define WLAN_EID_MEASURE_REQUEST 38 733 #define WLAN_EID_MEASURE_REPORT 39 734 #define WLAN_EID_QUITE 40 735 #define WLAN_EID_IBSS_DFS 41 736 /* EIDs defined by IEEE 802.11h - END */ 737 #define WLAN_EID_ERP_INFO 42 738 #define WLAN_EID_HT_CAP 45 739 #define WLAN_EID_RSN 48 740 #define WLAN_EID_EXT_SUPP_RATES 50 741 #define WLAN_EID_MOBILITY_DOMAIN 54 742 #define WLAN_EID_FAST_BSS_TRANSITION 55 743 #define WLAN_EID_TIMEOUT_INTERVAL 56 744 #define WLAN_EID_RIC_DATA 57 745 #define WLAN_EID_HT_OPERATION 61 746 #define WLAN_EID_SECONDARY_CHANNEL_OFFSET 62 747 #define WLAN_EID_20_40_BSS_COEXISTENCE 72 748 #define WLAN_EID_20_40_BSS_INTOLERANT 73 749 #define WLAN_EID_OVERLAPPING_BSS_SCAN_PARAMS 74 750 #define WLAN_EID_MMIE 76 751 #define WLAN_EID_MESH_CONFIG 113 752 #define WLAN_EID_MESH_ID 114 753 #define WLAN_EID_MPM 117 754 #define WLAN_EID_RANN 126 755 #define WLAN_EID_PREQ 130 756 #define WLAN_EID_PREP 131 757 #define WLAN_EID_PERR 132 758 #define WLAN_EID_AMPE 139 759 #define WLAN_EID_MIC 140 760 #define WLAN_EID_VENDOR_SPECIFIC 221 761 #define WLAN_EID_GENERIC (WLAN_EID_VENDOR_SPECIFIC) 762 #define WLAN_EID_VHT_CAPABILITY 191 763 #define WLAN_EID_VHT_OPERATION 192 764 #define WLAN_EID_WIDE_BANDWIDTH_CHANNEL_SWITCH 194 765 #define WLAN_EID_CHANNEL_SWITCH_WRAPPER 196 766 #define WLAN_EID_VHT_OP_MODE_NOTIFY 199 767 #define WLAN_EID_RSNX 244 768 #define WLAN_EID_EXTENSION 255 769 #define WLAN_EID_EXT_OWE_DH_PARAM 32 770 771 #define IEEE80211_MGMT_HDR_LEN 24 772 #define IEEE80211_DATA_HDR3_LEN 24 773 #define IEEE80211_DATA_HDR4_LEN 30 774 775 776 #define IEEE80211_STATMASK_SIGNAL (1<<0) 777 #define IEEE80211_STATMASK_RSSI (1<<1) 778 #define IEEE80211_STATMASK_NOISE (1<<2) 779 #define IEEE80211_STATMASK_RATE (1<<3) 780 #define IEEE80211_STATMASK_WEMASK 0x7 781 782 783 #define IEEE80211_CCK_MODULATION (1<<0) 784 #define IEEE80211_OFDM_MODULATION (1<<1) 785 786 #define IEEE80211_24GHZ_BAND (1<<0) 787 #define IEEE80211_52GHZ_BAND (1<<1) 788 789 #define IEEE80211_CCK_RATE_LEN 4 790 #define IEEE80211_NUM_OFDM_RATESLEN 8 791 792 793 794 #define IEEE80211_CCK_RATE_1MB 0x02 795 #define IEEE80211_CCK_RATE_2MB 0x04 796 #define IEEE80211_CCK_RATE_5MB 0x0B 797 #define IEEE80211_CCK_RATE_11MB 0x16 798 #define IEEE80211_OFDM_RATE_LEN 8 799 #define IEEE80211_OFDM_RATE_6MB 0x0C 800 #define IEEE80211_OFDM_RATE_9MB 0x12 801 #define IEEE80211_OFDM_RATE_12MB 0x18 802 #define IEEE80211_OFDM_RATE_18MB 0x24 803 #define IEEE80211_OFDM_RATE_24MB 0x30 804 #define IEEE80211_PBCC_RATE_22MB 0x2C 805 #define IEEE80211_FREAK_RATE_22_5MB 0x2D 806 #define IEEE80211_OFDM_RATE_36MB 0x48 807 #define IEEE80211_OFDM_RATE_48MB 0x60 808 #define IEEE80211_OFDM_RATE_54MB 0x6C 809 #define IEEE80211_BASIC_RATE_MASK 0x80 810 811 #define IEEE80211_CCK_RATE_1MB_MASK (1<<0) 812 #define IEEE80211_CCK_RATE_2MB_MASK (1<<1) 813 #define IEEE80211_CCK_RATE_5MB_MASK (1<<2) 814 #define IEEE80211_CCK_RATE_11MB_MASK (1<<3) 815 #define IEEE80211_OFDM_RATE_6MB_MASK (1<<4) 816 #define IEEE80211_OFDM_RATE_9MB_MASK (1<<5) 817 #define IEEE80211_OFDM_RATE_12MB_MASK (1<<6) 818 #define IEEE80211_OFDM_RATE_18MB_MASK (1<<7) 819 #define IEEE80211_OFDM_RATE_24MB_MASK (1<<8) 820 #define IEEE80211_OFDM_RATE_36MB_MASK (1<<9) 821 #define IEEE80211_OFDM_RATE_48MB_MASK (1<<10) 822 #define IEEE80211_OFDM_RATE_54MB_MASK (1<<11) 823 824 #define IEEE80211_CCK_RATES_MASK 0x0000000F 825 #define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \ 826 IEEE80211_CCK_RATE_2MB_MASK) 827 #define IEEE80211_CCK_DEFAULT_RATES_MASK (IEEE80211_CCK_BASIC_RATES_MASK | \ 828 IEEE80211_CCK_RATE_5MB_MASK | \ 829 IEEE80211_CCK_RATE_11MB_MASK) 830 831 #define IEEE80211_OFDM_RATES_MASK 0x00000FF0 832 #define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \ 833 IEEE80211_OFDM_RATE_12MB_MASK | \ 834 IEEE80211_OFDM_RATE_24MB_MASK) 835 #define IEEE80211_OFDM_DEFAULT_RATES_MASK (IEEE80211_OFDM_BASIC_RATES_MASK | \ 836 IEEE80211_OFDM_RATE_9MB_MASK | \ 837 IEEE80211_OFDM_RATE_18MB_MASK | \ 838 IEEE80211_OFDM_RATE_36MB_MASK | \ 839 IEEE80211_OFDM_RATE_48MB_MASK | \ 840 IEEE80211_OFDM_RATE_54MB_MASK) 841 #define IEEE80211_DEFAULT_RATES_MASK (IEEE80211_OFDM_DEFAULT_RATES_MASK | \ 842 IEEE80211_CCK_DEFAULT_RATES_MASK) 843 844 #define IEEE80211_NUM_OFDM_RATES 8 845 #define IEEE80211_NUM_CCK_RATES 4 846 #define IEEE80211_OFDM_SHIFT_MASK_A 4 847 848 849 enum MGN_RATE { 850 MGN_1M = 0x02, 851 MGN_2M = 0x04, 852 MGN_5_5M = 0x0B, 853 MGN_6M = 0x0C, 854 MGN_9M = 0x12, 855 MGN_11M = 0x16, 856 MGN_12M = 0x18, 857 MGN_18M = 0x24, 858 MGN_24M = 0x30, 859 MGN_36M = 0x48, 860 MGN_48M = 0x60, 861 MGN_54M = 0x6C, 862 MGN_MCS32 = 0x7F, 863 MGN_MCS0, 864 MGN_MCS1, 865 MGN_MCS2, 866 MGN_MCS3, 867 MGN_MCS4, 868 MGN_MCS5, 869 MGN_MCS6, 870 MGN_MCS7, 871 MGN_MCS8, 872 MGN_MCS9, 873 MGN_MCS10, 874 MGN_MCS11, 875 MGN_MCS12, 876 MGN_MCS13, 877 MGN_MCS14, 878 MGN_MCS15, 879 MGN_MCS16, 880 MGN_MCS17, 881 MGN_MCS18, 882 MGN_MCS19, 883 MGN_MCS20, 884 MGN_MCS21, 885 MGN_MCS22, 886 MGN_MCS23, 887 MGN_MCS24, 888 MGN_MCS25, 889 MGN_MCS26, 890 MGN_MCS27, 891 MGN_MCS28, 892 MGN_MCS29, 893 MGN_MCS30, 894 MGN_MCS31, 895 MGN_VHT1SS_MCS0, 896 MGN_VHT1SS_MCS1, 897 MGN_VHT1SS_MCS2, 898 MGN_VHT1SS_MCS3, 899 MGN_VHT1SS_MCS4, 900 MGN_VHT1SS_MCS5, 901 MGN_VHT1SS_MCS6, 902 MGN_VHT1SS_MCS7, 903 MGN_VHT1SS_MCS8, 904 MGN_VHT1SS_MCS9, 905 MGN_VHT2SS_MCS0, 906 MGN_VHT2SS_MCS1, 907 MGN_VHT2SS_MCS2, 908 MGN_VHT2SS_MCS3, 909 MGN_VHT2SS_MCS4, 910 MGN_VHT2SS_MCS5, 911 MGN_VHT2SS_MCS6, 912 MGN_VHT2SS_MCS7, 913 MGN_VHT2SS_MCS8, 914 MGN_VHT2SS_MCS9, 915 MGN_VHT3SS_MCS0, 916 MGN_VHT3SS_MCS1, 917 MGN_VHT3SS_MCS2, 918 MGN_VHT3SS_MCS3, 919 MGN_VHT3SS_MCS4, 920 MGN_VHT3SS_MCS5, 921 MGN_VHT3SS_MCS6, 922 MGN_VHT3SS_MCS7, 923 MGN_VHT3SS_MCS8, 924 MGN_VHT3SS_MCS9, 925 MGN_VHT4SS_MCS0, 926 MGN_VHT4SS_MCS1, 927 MGN_VHT4SS_MCS2, 928 MGN_VHT4SS_MCS3, 929 MGN_VHT4SS_MCS4, 930 MGN_VHT4SS_MCS5, 931 MGN_VHT4SS_MCS6, 932 MGN_VHT4SS_MCS7, 933 MGN_VHT4SS_MCS8, 934 MGN_VHT4SS_MCS9, 935 MGN_UNKNOWN 936 }; 937 938 #define IS_HT_RATE(_rate) ((_rate) >= MGN_MCS0 && (_rate) <= MGN_MCS31) 939 #define IS_VHT_RATE(_rate) ((_rate) >= MGN_VHT1SS_MCS0 && (_rate) <= MGN_VHT4SS_MCS9) 940 #define IS_CCK_RATE(_rate) ((_rate) == MGN_1M || (_rate) == MGN_2M || (_rate) == MGN_5_5M || (_rate) == MGN_11M) 941 #define IS_OFDM_RATE(_rate) ((_rate) >= MGN_6M && (_rate) <= MGN_54M && (_rate) != MGN_11M) 942 943 #define IS_HT1SS_RATE(_rate) ((_rate) >= MGN_MCS0 && (_rate) <= MGN_MCS7) 944 #define IS_HT2SS_RATE(_rate) ((_rate) >= MGN_MCS8 && (_rate) <= MGN_MCS15) 945 #define IS_HT3SS_RATE(_rate) ((_rate) >= MGN_MCS16 && (_rate) <= MGN_MCS23) 946 #define IS_HT4SS_RATE(_rate) ((_rate) >= MGN_MCS24 && (_rate) <= MGN_MCS31) 947 948 #define IS_VHT1SS_RATE(_rate) ((_rate) >= MGN_VHT1SS_MCS0 && (_rate) <= MGN_VHT1SS_MCS9) 949 #define IS_VHT2SS_RATE(_rate) ((_rate) >= MGN_VHT2SS_MCS0 && (_rate) <= MGN_VHT2SS_MCS9) 950 #define IS_VHT3SS_RATE(_rate) ((_rate) >= MGN_VHT3SS_MCS0 && (_rate) <= MGN_VHT3SS_MCS9) 951 #define IS_VHT4SS_RATE(_rate) ((_rate) >= MGN_VHT4SS_MCS0 && (_rate) <= MGN_VHT4SS_MCS9) 952 953 #define IS_1T_RATE(_rate) (IS_CCK_RATE((_rate)) || IS_OFDM_RATE((_rate)) || IS_HT1SS_RATE((_rate)) || IS_VHT1SS_RATE((_rate))) 954 #define IS_2T_RATE(_rate) (IS_HT2SS_RATE((_rate)) || IS_VHT2SS_RATE((_rate))) 955 #define IS_3T_RATE(_rate) (IS_HT3SS_RATE((_rate)) || IS_VHT3SS_RATE((_rate))) 956 #define IS_4T_RATE(_rate) (IS_HT4SS_RATE((_rate)) || IS_VHT4SS_RATE((_rate))) 957 958 #define MGN_RATE_STR(_rate) \ 959 (_rate == MGN_1M) ? "CCK_1M" : \ 960 (_rate == MGN_2M) ? "CCK_2M" : \ 961 (_rate == MGN_5_5M) ? "CCK_5.5M" : \ 962 (_rate == MGN_11M) ? "CCK_11M" : \ 963 (_rate == MGN_6M) ? "OFDM_6M" : \ 964 (_rate == MGN_9M) ? "OFDM_9M" : \ 965 (_rate == MGN_12M) ? "OFDM_12M" : \ 966 (_rate == MGN_18M) ? "OFDM_18M" : \ 967 (_rate == MGN_24M) ? "OFDM_24M" : \ 968 (_rate == MGN_36M) ? "OFDM_36M" : \ 969 (_rate == MGN_48M) ? "OFDM_48M" : \ 970 (_rate == MGN_54M) ? "OFDM_54M" : \ 971 (_rate == MGN_MCS32) ? "MCS32" : \ 972 (_rate == MGN_MCS0) ? "MCS0" : \ 973 (_rate == MGN_MCS1) ? "MCS1" : \ 974 (_rate == MGN_MCS2) ? "MCS2" : \ 975 (_rate == MGN_MCS3) ? "MCS3" : \ 976 (_rate == MGN_MCS4) ? "MCS4" : \ 977 (_rate == MGN_MCS5) ? "MCS5" : \ 978 (_rate == MGN_MCS6) ? "MCS6" : \ 979 (_rate == MGN_MCS7) ? "MCS7" : \ 980 (_rate == MGN_MCS8) ? "MCS8" : \ 981 (_rate == MGN_MCS9) ? "MCS9" : \ 982 (_rate == MGN_MCS10) ? "MCS10" : \ 983 (_rate == MGN_MCS11) ? "MCS11" : \ 984 (_rate == MGN_MCS12) ? "MCS12" : \ 985 (_rate == MGN_MCS13) ? "MCS13" : \ 986 (_rate == MGN_MCS14) ? "MCS14" : \ 987 (_rate == MGN_MCS15) ? "MCS15" : \ 988 (_rate == MGN_MCS16) ? "MCS16" : \ 989 (_rate == MGN_MCS17) ? "MCS17" : \ 990 (_rate == MGN_MCS18) ? "MCS18" : \ 991 (_rate == MGN_MCS19) ? "MCS19" : \ 992 (_rate == MGN_MCS20) ? "MCS20" : \ 993 (_rate == MGN_MCS21) ? "MCS21" : \ 994 (_rate == MGN_MCS22) ? "MCS22" : \ 995 (_rate == MGN_MCS23) ? "MCS23" : \ 996 (_rate == MGN_MCS24) ? "MCS24" : \ 997 (_rate == MGN_MCS25) ? "MCS25" : \ 998 (_rate == MGN_MCS26) ? "MCS26" : \ 999 (_rate == MGN_MCS27) ? "MCS27" : \ 1000 (_rate == MGN_MCS28) ? "MCS28" : \ 1001 (_rate == MGN_MCS29) ? "MCS29" : \ 1002 (_rate == MGN_MCS30) ? "MCS30" : \ 1003 (_rate == MGN_MCS31) ? "MCS31" : \ 1004 (_rate == MGN_VHT1SS_MCS0) ? "VHT1SMCS0" : \ 1005 (_rate == MGN_VHT1SS_MCS1) ? "VHT1SMCS1" : \ 1006 (_rate == MGN_VHT1SS_MCS2) ? "VHT1SMCS2" : \ 1007 (_rate == MGN_VHT1SS_MCS3) ? "VHT1SMCS3" : \ 1008 (_rate == MGN_VHT1SS_MCS4) ? "VHT1SMCS4" : \ 1009 (_rate == MGN_VHT1SS_MCS5) ? "VHT1SMCS5" : \ 1010 (_rate == MGN_VHT1SS_MCS6) ? "VHT1SMCS6" : \ 1011 (_rate == MGN_VHT1SS_MCS7) ? "VHT1SMCS7" : \ 1012 (_rate == MGN_VHT1SS_MCS8) ? "VHT1SMCS8" : \ 1013 (_rate == MGN_VHT1SS_MCS9) ? "VHT1SMCS9" : \ 1014 (_rate == MGN_VHT2SS_MCS0) ? "VHT2SMCS0" : \ 1015 (_rate == MGN_VHT2SS_MCS1) ? "VHT2SMCS1" : \ 1016 (_rate == MGN_VHT2SS_MCS2) ? "VHT2SMCS2" : \ 1017 (_rate == MGN_VHT2SS_MCS3) ? "VHT2SMCS3" : \ 1018 (_rate == MGN_VHT2SS_MCS4) ? "VHT2SMCS4" : \ 1019 (_rate == MGN_VHT2SS_MCS5) ? "VHT2SMCS5" : \ 1020 (_rate == MGN_VHT2SS_MCS6) ? "VHT2SMCS6" : \ 1021 (_rate == MGN_VHT2SS_MCS7) ? "VHT2SMCS7" : \ 1022 (_rate == MGN_VHT2SS_MCS8) ? "VHT2SMCS8" : \ 1023 (_rate == MGN_VHT2SS_MCS9) ? "VHT2SMCS9" : \ 1024 (_rate == MGN_VHT3SS_MCS0) ? "VHT3SMCS0" : \ 1025 (_rate == MGN_VHT3SS_MCS1) ? "VHT3SMCS1" : \ 1026 (_rate == MGN_VHT3SS_MCS2) ? "VHT3SMCS2" : \ 1027 (_rate == MGN_VHT3SS_MCS3) ? "VHT3SMCS3" : \ 1028 (_rate == MGN_VHT3SS_MCS4) ? "VHT3SMCS4" : \ 1029 (_rate == MGN_VHT3SS_MCS5) ? "VHT3SMCS5" : \ 1030 (_rate == MGN_VHT3SS_MCS6) ? "VHT3SMCS6" : \ 1031 (_rate == MGN_VHT3SS_MCS7) ? "VHT3SMCS7" : \ 1032 (_rate == MGN_VHT3SS_MCS8) ? "VHT3SMCS8" : \ 1033 (_rate == MGN_VHT3SS_MCS9) ? "VHT3SMCS9" : \ 1034 (_rate == MGN_VHT4SS_MCS0) ? "VHT4SMCS0" : \ 1035 (_rate == MGN_VHT4SS_MCS1) ? "VHT4SMCS1" : \ 1036 (_rate == MGN_VHT4SS_MCS2) ? "VHT4SMCS2" : \ 1037 (_rate == MGN_VHT4SS_MCS3) ? "VHT4SMCS3" : \ 1038 (_rate == MGN_VHT4SS_MCS4) ? "VHT4SMCS4" : \ 1039 (_rate == MGN_VHT4SS_MCS5) ? "VHT4SMCS5" : \ 1040 (_rate == MGN_VHT4SS_MCS6) ? "VHT4SMCS6" : \ 1041 (_rate == MGN_VHT4SS_MCS7) ? "VHT4SMCS7" : \ 1042 (_rate == MGN_VHT4SS_MCS8) ? "VHT4SMCS8" : \ 1043 (_rate == MGN_VHT4SS_MCS9) ? "VHT4SMCS9" : "UNKNOWN" 1044 1045 typedef enum _RATE_SECTION { 1046 CCK = 0, 1047 OFDM = 1, 1048 HT_MCS0_MCS7 = 2, 1049 HT_MCS8_MCS15 = 3, 1050 HT_MCS16_MCS23 = 4, 1051 HT_MCS24_MCS31 = 5, 1052 HT_1SS = HT_MCS0_MCS7, 1053 HT_2SS = HT_MCS8_MCS15, 1054 HT_3SS = HT_MCS16_MCS23, 1055 HT_4SS = HT_MCS24_MCS31, 1056 VHT_1SSMCS0_1SSMCS9 = 6, 1057 VHT_2SSMCS0_2SSMCS9 = 7, 1058 VHT_3SSMCS0_3SSMCS9 = 8, 1059 VHT_4SSMCS0_4SSMCS9 = 9, 1060 VHT_1SS = VHT_1SSMCS0_1SSMCS9, 1061 VHT_2SS = VHT_2SSMCS0_2SSMCS9, 1062 VHT_3SS = VHT_3SSMCS0_3SSMCS9, 1063 VHT_4SS = VHT_4SSMCS0_4SSMCS9, 1064 RATE_SECTION_NUM, 1065 } RATE_SECTION; 1066 1067 RATE_SECTION mgn_rate_to_rs(enum MGN_RATE rate); 1068 1069 const char *rate_section_str(u8 section); 1070 1071 #define IS_CCK_RATE_SECTION(section) ((section) == CCK) 1072 #define IS_OFDM_RATE_SECTION(section) ((section) == OFDM) 1073 #define IS_HT_RATE_SECTION(section) ((section) >= HT_1SS && (section) <= HT_4SS) 1074 #define IS_VHT_RATE_SECTION(section) ((section) >= VHT_1SS && (section) <= VHT_4SS) 1075 1076 #define IS_1T_RATE_SECTION(section) ((section) == CCK || (section) == OFDM || (section) == HT_1SS || (section) == VHT_1SS) 1077 #define IS_2T_RATE_SECTION(section) ((section) == HT_2SS || (section) == VHT_2SS) 1078 #define IS_3T_RATE_SECTION(section) ((section) == HT_3SS || (section) == VHT_3SS) 1079 #define IS_4T_RATE_SECTION(section) ((section) == HT_4SS || (section) == VHT_4SS) 1080 1081 extern u8 mgn_rates_cck[]; 1082 extern u8 mgn_rates_ofdm[]; 1083 extern u8 mgn_rates_mcs0_7[]; 1084 extern u8 mgn_rates_mcs8_15[]; 1085 extern u8 mgn_rates_mcs16_23[]; 1086 extern u8 mgn_rates_mcs24_31[]; 1087 extern u8 mgn_rates_vht1ss[]; 1088 extern u8 mgn_rates_vht2ss[]; 1089 extern u8 mgn_rates_vht3ss[]; 1090 extern u8 mgn_rates_vht4ss[]; 1091 1092 struct rate_section_ent { 1093 u8 tx_num; /* value of RF_TX_NUM */ 1094 u8 rate_num; 1095 u8 *rates; 1096 }; 1097 1098 extern struct rate_section_ent rates_by_sections[]; 1099 1100 #define rate_section_to_tx_num(section) (rates_by_sections[(section)].tx_num) 1101 #define rate_section_rate_num(section) (rates_by_sections[(section)].rate_num) 1102 1103 /* NOTE: This data is for statistical purposes; not all hardware provides this 1104 * information for frames received. Not setting these will not cause 1105 * any adverse affects. */ 1106 struct ieee80211_rx_stats { 1107 /* u32 mac_time[2]; */ 1108 s8 rssi; 1109 u8 signal; 1110 u8 noise; 1111 u8 received_channel; 1112 u16 rate; /* in 100 kbps */ 1113 /* u8 control; */ 1114 u8 mask; 1115 u8 freq; 1116 u16 len; 1117 }; 1118 1119 /* IEEE 802.11 requires that STA supports concurrent reception of at least 1120 * three fragmented frames. This define can be increased to support more 1121 * concurrent frames, but it should be noted that each entry can consume about 1122 * 2 kB of RAM and increasing cache size will slow down frame reassembly. */ 1123 #define IEEE80211_FRAG_CACHE_LEN 4 1124 1125 struct ieee80211_frag_entry { 1126 u32 first_frag_time; 1127 uint seq; 1128 uint last_frag; 1129 uint qos; /* jackson */ 1130 uint tid; /* jackson */ 1131 struct sk_buff *skb; 1132 u8 src_addr[ETH_ALEN]; 1133 u8 dst_addr[ETH_ALEN]; 1134 }; 1135 1136 #ifndef PLATFORM_FREEBSD /* Baron BSD has already defined */ 1137 struct ieee80211_stats { 1138 uint tx_unicast_frames; 1139 uint tx_multicast_frames; 1140 uint tx_fragments; 1141 uint tx_unicast_octets; 1142 uint tx_multicast_octets; 1143 uint tx_deferred_transmissions; 1144 uint tx_single_retry_frames; 1145 uint tx_multiple_retry_frames; 1146 uint tx_retry_limit_exceeded; 1147 uint tx_discards; 1148 uint rx_unicast_frames; 1149 uint rx_multicast_frames; 1150 uint rx_fragments; 1151 uint rx_unicast_octets; 1152 uint rx_multicast_octets; 1153 uint rx_fcs_errors; 1154 uint rx_discards_no_buffer; 1155 uint tx_discards_wrong_sa; 1156 uint rx_discards_undecryptable; 1157 uint rx_message_in_msg_fragments; 1158 uint rx_message_in_bad_msg_fragments; 1159 }; 1160 #endif /* PLATFORM_FREEBSD */ 1161 struct ieee80211_softmac_stats { 1162 uint rx_ass_ok; 1163 uint rx_ass_err; 1164 uint rx_probe_rq; 1165 uint tx_probe_rs; 1166 uint tx_beacons; 1167 uint rx_auth_rq; 1168 uint rx_auth_rs_ok; 1169 uint rx_auth_rs_err; 1170 uint tx_auth_rq; 1171 uint no_auth_rs; 1172 uint no_ass_rs; 1173 uint tx_ass_rq; 1174 uint rx_ass_rq; 1175 uint tx_probe_rq; 1176 uint reassoc; 1177 uint swtxstop; 1178 uint swtxawake; 1179 }; 1180 1181 #define SEC_KEY_1 (1<<0) 1182 #define SEC_KEY_2 (1<<1) 1183 #define SEC_KEY_3 (1<<2) 1184 #define SEC_KEY_4 (1<<3) 1185 #define SEC_ACTIVE_KEY (1<<4) 1186 #define SEC_AUTH_MODE (1<<5) 1187 #define SEC_UNICAST_GROUP (1<<6) 1188 #define SEC_LEVEL (1<<7) 1189 #define SEC_ENABLED (1<<8) 1190 1191 #define SEC_LEVEL_0 0 /* None */ 1192 #define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */ 1193 #define SEC_LEVEL_2 2 /* Level 1 + TKIP */ 1194 #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */ 1195 #define SEC_LEVEL_3 4 /* Level 2 + CCMP */ 1196 1197 #define WEP_KEYS 4 1198 #define WEP_KEY_LEN 13 1199 #define BIP_MAX_KEYID 5 1200 #define BIP_AAD_SIZE 20 1201 1202 #if defined(PLATFORM_LINUX) 1203 struct ieee80211_security { 1204 u16 active_key:2, 1205 enabled:1, 1206 auth_mode:2, 1207 auth_algo:4, 1208 unicast_uses_group:1; 1209 u8 key_sizes[WEP_KEYS]; 1210 u8 keys[WEP_KEYS][WEP_KEY_LEN]; 1211 u8 level; 1212 u16 flags; 1213 } __attribute__((packed)); 1214 1215 #endif 1216 1217 /* 1218 1219 802.11 data frame from AP 1220 1221 ,-------------------------------------------------------------------. 1222 Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 | 1223 |------|------|---------|---------|---------|------|---------|------| 1224 Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs | 1225 | | tion | (BSSID) | | | ence | data | | 1226 `-------------------------------------------------------------------' 1227 1228 Total: 28-2340 bytes 1229 1230 */ 1231 1232 struct ieee80211_header_data { 1233 u16 frame_ctl; 1234 u16 duration_id; 1235 u8 addr1[6]; 1236 u8 addr2[6]; 1237 u8 addr3[6]; 1238 u16 seq_ctrl; 1239 }; 1240 1241 #define BEACON_PROBE_SSID_ID_POSITION 12 1242 1243 /* Management Frame Information Element Types */ 1244 #define MFIE_TYPE_SSID 0 1245 #define MFIE_TYPE_RATES 1 1246 #define MFIE_TYPE_FH_SET 2 1247 #define MFIE_TYPE_DS_SET 3 1248 #define MFIE_TYPE_CF_SET 4 1249 #define MFIE_TYPE_TIM 5 1250 #define MFIE_TYPE_IBSS_SET 6 1251 #define MFIE_TYPE_CHALLENGE 16 1252 #define MFIE_TYPE_ERP 42 1253 #define MFIE_TYPE_RSN 48 1254 #define MFIE_TYPE_RATES_EX 50 1255 #define MFIE_TYPE_GENERIC 221 1256 1257 #if defined(PLATFORM_LINUX) 1258 struct ieee80211_info_element_hdr { 1259 u8 id; 1260 u8 len; 1261 } __attribute__((packed)); 1262 1263 struct ieee80211_info_element { 1264 u8 id; 1265 u8 len; 1266 u8 data[0]; 1267 } __attribute__((packed)); 1268 #endif 1269 1270 1271 /* 1272 * These are the data types that can make up management packets 1273 * 1274 u16 auth_algorithm; 1275 u16 auth_sequence; 1276 u16 beacon_interval; 1277 u16 capability; 1278 u8 current_ap[ETH_ALEN]; 1279 u16 listen_interval; 1280 struct { 1281 u16 association_id:14, reserved:2; 1282 } __attribute__ ((packed)); 1283 u32 time_stamp[2]; 1284 u16 reason; 1285 u16 status; 1286 */ 1287 1288 #define IEEE80211_DEFAULT_TX_ESSID "Penguin" 1289 #define IEEE80211_DEFAULT_BASIC_RATE 10 1290 1291 1292 #if defined(PLATFORM_LINUX) 1293 struct ieee80211_authentication { 1294 struct ieee80211_header_data header; 1295 u16 algorithm; 1296 u16 transaction; 1297 u16 status; 1298 /* struct ieee80211_info_element_hdr info_element; */ 1299 } __attribute__((packed)); 1300 1301 1302 struct ieee80211_probe_response { 1303 struct ieee80211_header_data header; 1304 u32 time_stamp[2]; 1305 u16 beacon_interval; 1306 u16 capability; 1307 struct ieee80211_info_element info_element; 1308 } __attribute__((packed)); 1309 1310 struct ieee80211_probe_request { 1311 struct ieee80211_header_data header; 1312 /*struct ieee80211_info_element info_element;*/ 1313 } __attribute__((packed)); 1314 1315 struct ieee80211_assoc_request_frame { 1316 struct rtw_ieee80211_hdr_3addr header; 1317 u16 capability; 1318 u16 listen_interval; 1319 /* u8 current_ap[ETH_ALEN]; */ 1320 struct ieee80211_info_element_hdr info_element; 1321 } __attribute__((packed)); 1322 1323 struct ieee80211_assoc_response_frame { 1324 struct rtw_ieee80211_hdr_3addr header; 1325 u16 capability; 1326 u16 status; 1327 u16 aid; 1328 /* struct ieee80211_info_element info_element; supported rates */ 1329 } __attribute__((packed)); 1330 #endif 1331 1332 struct ieee80211_txb { 1333 u8 nr_frags; 1334 u8 encrypted; 1335 u16 reserved; 1336 u16 frag_size; 1337 u16 payload_size; 1338 struct sk_buff *fragments[0]; 1339 }; 1340 1341 1342 /* SWEEP TABLE ENTRIES NUMBER*/ 1343 #define MAX_SWEEP_TAB_ENTRIES 42 1344 #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7 1345 /* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs 1346 * only use 8, and then use extended rates for the remaining supported 1347 * rates. Other APs, however, stick all of their supported rates on the 1348 * main rates information element... */ 1349 #define MAX_RATES_LENGTH ((u8)12) 1350 #define MAX_RATES_EX_LENGTH ((u8)16) 1351 #define MAX_NETWORK_COUNT 128 1352 #define IEEE80211_SOFTMAC_SCAN_TIME 400 1353 /* (HZ / 2) */ 1354 #define IEEE80211_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2) 1355 1356 #define CRC_LENGTH 4U 1357 1358 #define MAX_WPA_IE_LEN (256) 1359 #define MAX_WPS_IE_LEN (512) 1360 #define MAX_OWE_IE_LEN (128) 1361 #define MAX_P2P_IE_LEN (256) 1362 #define MAX_WFD_IE_LEN (128) 1363 #define MAX_RSNX_IE_LEN (16) 1364 1365 #define NETWORK_EMPTY_ESSID (1<<0) 1366 #define NETWORK_HAS_OFDM (1<<1) 1367 #define NETWORK_HAS_CCK (1<<2) 1368 1369 #define IEEE80211_DTIM_MBCAST 4 1370 #define IEEE80211_DTIM_UCAST 2 1371 #define IEEE80211_DTIM_VALID 1 1372 #define IEEE80211_DTIM_INVALID 0 1373 1374 #define IEEE80211_PS_DISABLED 0 1375 #define IEEE80211_PS_UNICAST IEEE80211_DTIM_UCAST 1376 #define IEEE80211_PS_MBCAST IEEE80211_DTIM_MBCAST 1377 #define IW_ESSID_MAX_SIZE 32 1378 #if 0 1379 struct ieee80211_network { 1380 /* These entries are used to identify a unique network */ 1381 u8 bssid[ETH_ALEN]; 1382 u8 channel; 1383 /* Ensure null-terminated for any debug msgs */ 1384 u8 ssid[IW_ESSID_MAX_SIZE + 1]; 1385 u8 ssid_len; 1386 u8 rssi; /* relative signal strength */ 1387 u8 sq; /* signal quality */ 1388 1389 /* These are network statistics */ 1390 /* struct ieee80211_rx_stats stats; */ 1391 u16 capability; 1392 u16 aid; 1393 u8 rates[MAX_RATES_LENGTH]; 1394 u8 rates_len; 1395 u8 rates_ex[MAX_RATES_EX_LENGTH]; 1396 u8 rates_ex_len; 1397 1398 u8 edca_parmsets[18]; 1399 1400 u8 mode; 1401 u8 flags; 1402 u8 time_stamp[8]; 1403 u16 beacon_interval; 1404 u16 listen_interval; 1405 u16 atim_window; 1406 u8 wpa_ie[MAX_WPA_IE_LEN]; 1407 size_t wpa_ie_len; 1408 u8 rsn_ie[MAX_WPA_IE_LEN]; 1409 size_t rsn_ie_len; 1410 u8 country[6]; 1411 u8 dtim_period; 1412 u8 dtim_data; 1413 u8 power_constraint; 1414 u8 qosinfo; 1415 u8 qbssload[5]; 1416 u8 network_type; 1417 int join_res; 1418 unsigned long last_scanned; 1419 }; 1420 #endif 1421 /* 1422 join_res: 1423 -1: authentication fail 1424 -2: association fail 1425 > 0: TID 1426 */ 1427 1428 #ifndef PLATFORM_FREEBSD /* Baron BSD has already defined */ 1429 1430 enum ieee80211_state { 1431 1432 /* the card is not linked at all */ 1433 IEEE80211_NOLINK = 0, 1434 1435 /* IEEE80211_ASSOCIATING* are for BSS client mode 1436 * the driver shall not perform RX filtering unless 1437 * the state is LINKED. 1438 * The driver shall just check for the state LINKED and 1439 * defaults to NOLINK for ALL the other states (including 1440 * LINKED_SCANNING) 1441 */ 1442 1443 /* the association procedure will start (wq scheduling)*/ 1444 IEEE80211_ASSOCIATING, 1445 IEEE80211_ASSOCIATING_RETRY, 1446 1447 /* the association procedure is sending AUTH request*/ 1448 IEEE80211_ASSOCIATING_AUTHENTICATING, 1449 1450 /* the association procedure has successfully authentcated 1451 * and is sending association request 1452 */ 1453 IEEE80211_ASSOCIATING_AUTHENTICATED, 1454 1455 /* the link is ok. the card associated to a BSS or linked 1456 * to a ibss cell or acting as an AP and creating the bss 1457 */ 1458 IEEE80211_LINKED, 1459 1460 /* same as LINKED, but the driver shall apply RX filter 1461 * rules as we are in NO_LINK mode. As the card is still 1462 * logically linked, but it is doing a syncro site survey 1463 * then it will be back to LINKED state. 1464 */ 1465 IEEE80211_LINKED_SCANNING, 1466 1467 }; 1468 #endif /* PLATFORM_FREEBSD */ 1469 1470 #define DEFAULT_MAX_SCAN_AGE (15 * HZ) 1471 #define DEFAULT_FTS 2346 1472 #define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x" 1473 #define MAC_ARG(x) ((u8 *)(x))[0], ((u8 *)(x))[1], ((u8 *)(x))[2], ((u8 *)(x))[3], ((u8 *)(x))[4], ((u8 *)(x))[5] 1474 #define MAC_SFMT "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx" 1475 #define MAC_SARG(x) ((u8*)(x)),((u8*)(x)) + 1,((u8*)(x)) + 2,((u8*)(x)) + 3,((u8*)(x)) + 4,((u8*)(x)) + 5 1476 #define IP_FMT "%d.%d.%d.%d" 1477 #define IP_ARG(x) ((u8 *)(x))[0], ((u8 *)(x))[1], ((u8 *)(x))[2], ((u8 *)(x))[3] 1478 #define PORT_FMT "%u" 1479 #define PORT_ARG(x) ntohs(*((u16 *)(x))) 1480 1481 #define is_multicast_mac_addr(Addr) ((((Addr[0]) & 0x01) == 0x01) && ((Addr[0]) != 0xff)) 1482 #define is_broadcast_mac_addr(Addr) ((((Addr[0]) & 0xff) == 0xff) && (((Addr[1]) & 0xff) == 0xff) && \ 1483 (((Addr[2]) & 0xff) == 0xff) && (((Addr[3]) & 0xff) == 0xff) && (((Addr[4]) & 0xff) == 0xff) && \ 1484 (((Addr[5]) & 0xff) == 0xff)) 1485 #define is_zero_mac_addr(Addr) ((Addr[0] == 0x00) && (Addr[1] == 0x00) && (Addr[2] == 0x00) && \ 1486 (Addr[3] == 0x00) && (Addr[4] == 0x00) && (Addr[5] == 0x00)) 1487 1488 1489 #define CFG_IEEE80211_RESERVE_FCS (1<<0) 1490 #define CFG_IEEE80211_COMPUTE_FCS (1<<1) 1491 1492 typedef struct tx_pending_t { 1493 int frag; 1494 struct ieee80211_txb *txb; 1495 } tx_pending_t; 1496 1497 1498 1499 #define TID_NUM 16 1500 1501 #define IEEE_A (1<<0) 1502 #define IEEE_B (1<<1) 1503 #define IEEE_G (1<<2) 1504 #define IEEE_MODE_MASK (IEEE_A | IEEE_B | IEEE_G) 1505 1506 /* Baron move to ieee80211.c */ 1507 int ieee80211_is_empty_essid(const char *essid, int essid_len); 1508 int ieee80211_get_hdrlen(u16 fc); 1509 1510 #if 0 1511 /* Action frame categories (IEEE 802.11-2007, 7.3.1.11, Table 7-24) */ 1512 #define WLAN_ACTION_SPECTRUM_MGMT 0 1513 #define WLAN_ACTION_QOS 1 1514 #define WLAN_ACTION_DLS 2 1515 #define WLAN_ACTION_BLOCK_ACK 3 1516 #define WLAN_ACTION_RADIO_MEASUREMENT 5 1517 #define WLAN_ACTION_FT 6 1518 #define WLAN_ACTION_SA_QUERY 8 1519 #define WLAN_ACTION_WMM 17 1520 #endif 1521 1522 1523 /* Action category code */ 1524 enum rtw_ieee80211_category { 1525 RTW_WLAN_CATEGORY_SPECTRUM_MGMT = 0, 1526 RTW_WLAN_CATEGORY_QOS = 1, 1527 RTW_WLAN_CATEGORY_DLS = 2, 1528 RTW_WLAN_CATEGORY_BACK = 3, 1529 RTW_WLAN_CATEGORY_PUBLIC = 4, /* IEEE 802.11 public action frames */ 1530 RTW_WLAN_CATEGORY_RADIO_MEAS = 5, 1531 RTW_WLAN_CATEGORY_FT = 6, 1532 RTW_WLAN_CATEGORY_HT = 7, 1533 RTW_WLAN_CATEGORY_SA_QUERY = 8, 1534 RTW_WLAN_CATEGORY_WNM = 10, 1535 RTW_WLAN_CATEGORY_UNPROTECTED_WNM = 11, /* add for CONFIG_IEEE80211W, none 11w also can use */ 1536 RTW_WLAN_CATEGORY_TDLS = 12, 1537 RTW_WLAN_CATEGORY_MESH = 13, 1538 RTW_WLAN_CATEGORY_MULTIHOP = 14, 1539 RTW_WLAN_CATEGORY_SELF_PROTECTED = 15, 1540 RTW_WLAN_CATEGORY_WMM = 17, 1541 RTW_WLAN_CATEGORY_VHT = 21, 1542 #ifdef CONFIG_RTW_TOKEN_BASED_XMIT 1543 RTW_WLAN_CATEGORY_TBTX = 25, 1544 #endif 1545 RTW_WLAN_CATEGORY_P2P = 0x7f,/* P2P action frames */ 1546 }; 1547 1548 #define CATEGORY_IS_GROUP_PRIVACY(cat) \ 1549 (cat == RTW_WLAN_CATEGORY_MESH || cat == RTW_WLAN_CATEGORY_MULTIHOP) 1550 1551 #define CATEGORY_IS_NON_ROBUST(cat) \ 1552 (cat == RTW_WLAN_CATEGORY_PUBLIC \ 1553 || cat == RTW_WLAN_CATEGORY_HT \ 1554 || cat == RTW_WLAN_CATEGORY_UNPROTECTED_WNM \ 1555 || cat == RTW_WLAN_CATEGORY_SELF_PROTECTED \ 1556 || cat == RTW_WLAN_CATEGORY_VHT \ 1557 || cat == RTW_WLAN_CATEGORY_P2P) 1558 1559 #define CATEGORY_IS_ROBUST(cat) !CATEGORY_IS_NON_ROBUST(cat) 1560 1561 /* SPECTRUM_MGMT action code */ 1562 enum rtw_ieee80211_spectrum_mgmt_actioncode { 1563 RTW_WLAN_ACTION_SPCT_MSR_REQ = 0, 1564 RTW_WLAN_ACTION_SPCT_MSR_RPRT = 1, 1565 RTW_WLAN_ACTION_SPCT_TPC_REQ = 2, 1566 RTW_WLAN_ACTION_SPCT_TPC_RPRT = 3, 1567 RTW_WLAN_ACTION_SPCT_CHL_SWITCH = 4, 1568 RTW_WLAN_ACTION_SPCT_EXT_CHL_SWITCH = 5, 1569 }; 1570 1571 /* SELF_PROTECTED action code */ 1572 enum rtw_ieee80211_self_protected_actioncode { 1573 RTW_ACT_SELF_PROTECTED_RSVD = 0, 1574 RTW_ACT_SELF_PROTECTED_MESH_OPEN = 1, 1575 RTW_ACT_SELF_PROTECTED_MESH_CONF = 2, 1576 RTW_ACT_SELF_PROTECTED_MESH_CLOSE = 3, 1577 RTW_ACT_SELF_PROTECTED_MESH_GK_INFORM = 4, 1578 RTW_ACT_SELF_PROTECTED_MESH_GK_ACK = 5, 1579 RTW_ACT_SELF_PROTECTED_NUM, 1580 }; 1581 1582 /* MESH action code */ 1583 enum rtw_ieee80211_mesh_actioncode { 1584 RTW_ACT_MESH_LINK_METRIC_REPORT, 1585 RTW_ACT_MESH_HWMP_PATH_SELECTION, 1586 RTW_ACT_MESH_GATE_ANNOUNCEMENT, 1587 RTW_ACT_MESH_CONGESTION_CONTROL_NOTIFICATION, 1588 RTW_ACT_MESH_MCCA_SETUP_REQUEST, 1589 RTW_ACT_MESH_MCCA_SETUP_REPLY, 1590 RTW_ACT_MESH_MCCA_ADVERTISEMENT_REQUEST, 1591 RTW_ACT_MESH_MCCA_ADVERTISEMENT, 1592 RTW_ACT_MESH_MCCA_TEARDOWN, 1593 RTW_ACT_MESH_TBTT_ADJUSTMENT_REQUEST, 1594 RTW_ACT_MESH_TBTT_ADJUSTMENT_RESPONSE, 1595 }; 1596 1597 enum _PUBLIC_ACTION { 1598 ACT_PUBLIC_BSSCOEXIST = 0, /* 20/40 BSS Coexistence */ 1599 ACT_PUBLIC_DSE_ENABLE = 1, 1600 ACT_PUBLIC_DSE_DEENABLE = 2, 1601 ACT_PUBLIC_DSE_REG_LOCATION = 3, 1602 ACT_PUBLIC_EXT_CHL_SWITCH = 4, 1603 ACT_PUBLIC_DSE_MSR_REQ = 5, 1604 ACT_PUBLIC_DSE_MSR_RPRT = 6, 1605 ACT_PUBLIC_MP = 7, /* Measurement Pilot */ 1606 ACT_PUBLIC_DSE_PWR_CONSTRAINT = 8, 1607 ACT_PUBLIC_VENDOR = 9, /* for WIFI_DIRECT */ 1608 ACT_PUBLIC_GAS_INITIAL_REQ = 10, 1609 ACT_PUBLIC_GAS_INITIAL_RSP = 11, 1610 ACT_PUBLIC_GAS_COMEBACK_REQ = 12, 1611 ACT_PUBLIC_GAS_COMEBACK_RSP = 13, 1612 ACT_PUBLIC_TDLS_DISCOVERY_RSP = 14, 1613 ACT_PUBLIC_LOCATION_TRACK = 15, 1614 ACT_PUBLIC_MAX 1615 }; 1616 1617 #ifdef CONFIG_TDLS 1618 enum TDLS_ACTION_FIELD { 1619 TDLS_SETUP_REQUEST = 0, 1620 TDLS_SETUP_RESPONSE = 1, 1621 TDLS_SETUP_CONFIRM = 2, 1622 TDLS_TEARDOWN = 3, 1623 TDLS_PEER_TRAFFIC_INDICATION = 4, 1624 TDLS_CHANNEL_SWITCH_REQUEST = 5, 1625 TDLS_CHANNEL_SWITCH_RESPONSE = 6, 1626 TDLS_PEER_PSM_REQUEST = 7, 1627 TDLS_PEER_PSM_RESPONSE = 8, 1628 TDLS_PEER_TRAFFIC_RESPONSE = 9, 1629 TDLS_DISCOVERY_REQUEST = 10, 1630 TDLS_DISCOVERY_RESPONSE = 14, /* it's used in public action frame */ 1631 }; 1632 1633 #define TUNNELED_PROBE_REQ 15 1634 #define TUNNELED_PROBE_RSP 16 1635 #endif /* CONFIG_TDLS */ 1636 1637 /* BACK action code */ 1638 enum rtw_ieee80211_back_actioncode { 1639 RTW_WLAN_ACTION_ADDBA_REQ = 0, 1640 RTW_WLAN_ACTION_ADDBA_RESP = 1, 1641 RTW_WLAN_ACTION_DELBA = 2, 1642 }; 1643 1644 /* HT features action code */ 1645 enum rtw_ieee80211_ht_actioncode { 1646 RTW_WLAN_ACTION_HT_NOTI_CHNL_WIDTH = 0, 1647 RTW_WLAN_ACTION_HT_SM_PS = 1, 1648 RTW_WLAN_ACTION_HT_PSMP = 2, 1649 RTW_WLAN_ACTION_HT_SET_PCO_PHASE = 3, 1650 RTW_WLAN_ACTION_HT_CSI = 4, 1651 RTW_WLAN_ACTION_HT_NON_COMPRESS_BEAMFORMING = 5, 1652 RTW_WLAN_ACTION_HT_COMPRESS_BEAMFORMING = 6, 1653 RTW_WLAN_ACTION_HT_ASEL_FEEDBACK = 7, 1654 }; 1655 1656 /* BACK (block-ack) parties */ 1657 enum rtw_ieee80211_back_parties { 1658 RTW_WLAN_BACK_RECIPIENT = 0, 1659 RTW_WLAN_BACK_INITIATOR = 1, 1660 RTW_WLAN_BACK_TIMER = 2, 1661 }; 1662 1663 /*20/40 BSS Coexistence element */ 1664 #define RTW_WLAN_20_40_BSS_COEX_INFO_REQ BIT(0) 1665 #define RTW_WLAN_20_40_BSS_COEX_40MHZ_INTOL BIT(1) 1666 #define RTW_WLAN_20_40_BSS_COEX_20MHZ_WIDTH_REQ BIT(2) 1667 #define RTW_WLAN_20_40_BSS_COEX_OBSS_EXEMPT_REQ BIT(3) 1668 #define RTW_WLAN_20_40_BSS_COEX_OBSS_EXEMPT_GRNT BIT(4) 1669 1670 /* VHT features action code */ 1671 enum rtw_ieee80211_vht_actioncode { 1672 RTW_WLAN_ACTION_VHT_COMPRESSED_BEAMFORMING = 0, 1673 RTW_WLAN_ACTION_VHT_GROUPID_MANAGEMENT = 1, 1674 RTW_WLAN_ACTION_VHT_OPMODE_NOTIFICATION = 2, 1675 }; 1676 1677 #define OUI_MICROSOFT 0x0050f2 /* Microsoft (also used in Wi-Fi specs) 1678 * 00:50:F2 */ 1679 #ifndef PLATFORM_FREEBSD /* Baron BSD has defined */ 1680 #define WME_OUI_TYPE 2 1681 #endif /* PLATFORM_FREEBSD */ 1682 #define WME_OUI_SUBTYPE_INFORMATION_ELEMENT 0 1683 #define WME_OUI_SUBTYPE_PARAMETER_ELEMENT 1 1684 #define WME_OUI_SUBTYPE_TSPEC_ELEMENT 2 1685 #define WME_VERSION 1 1686 1687 #define WME_ACTION_CODE_SETUP_REQUEST 0 1688 #define WME_ACTION_CODE_SETUP_RESPONSE 1 1689 #define WME_ACTION_CODE_TEARDOWN 2 1690 1691 #define WME_SETUP_RESPONSE_STATUS_ADMISSION_ACCEPTED 0 1692 #define WME_SETUP_RESPONSE_STATUS_INVALID_PARAMETERS 1 1693 #define WME_SETUP_RESPONSE_STATUS_REFUSED 3 1694 1695 #define WME_TSPEC_DIRECTION_UPLINK 0 1696 #define WME_TSPEC_DIRECTION_DOWNLINK 1 1697 #define WME_TSPEC_DIRECTION_BI_DIRECTIONAL 3 1698 1699 1700 #define OUI_BROADCOM 0x00904c /* Broadcom (Epigram) */ 1701 1702 #ifdef CONFIG_RTW_TOKEN_BASED_XMIT 1703 #define OUI_REALTEK 0x00e04c /* Realtek */ 1704 #endif 1705 #define VENDOR_HT_CAPAB_OUI_TYPE 0x33 /* 00-90-4c:0x33 */ 1706 1707 enum rtw_ieee80211_rann_flags { 1708 RTW_RANN_FLAG_IS_GATE = 1 << 0, 1709 }; 1710 1711 /** 1712 * enum rtw_ieee80211_preq_flags - mesh PREQ element flags 1713 * 1714 * @RTW_IEEE80211_PREQ_IS_GATE_FLAG: Gate Announcement subfield 1715 * @RTW_IEEE80211_PREQ_PROACTIVE_PREP_FLAG: proactive PREP subfield 1716 */ 1717 enum rtw_ieee80211_preq_flags { 1718 RTW_IEEE80211_PREQ_IS_GATE_FLAG = 1 << 0, 1719 RTW_IEEE80211_PREQ_PROACTIVE_PREP_FLAG = 1 << 2, 1720 }; 1721 1722 /** 1723 * enum rtw_ieee80211_preq_target_flags - mesh PREQ element per target flags 1724 * 1725 * @RTW_IEEE80211_PREQ_TO_FLAG: target only subfield 1726 * @RTW_IEEE80211_PREQ_USN_FLAG: unknown target HWMP sequence number subfield 1727 */ 1728 enum rtw_ieee80211_preq_target_flags { 1729 RTW_IEEE80211_PREQ_TO_FLAG = 1<<0, 1730 RTW_IEEE80211_PREQ_USN_FLAG = 1<<2, 1731 }; 1732 1733 /** 1734 * enum rtw_ieee80211_root_mode_identifier - root mesh STA mode identifier 1735 * 1736 * These attribute are used by dot11MeshHWMPRootMode to set root mesh STA mode 1737 * 1738 * @RTW_IEEE80211_ROOTMODE_NO_ROOT: the mesh STA is not a root mesh STA (default) 1739 * @RTW_IEEE80211_ROOTMODE_ROOT: the mesh STA is a root mesh STA if greater than 1740 * this value 1741 * @RTW_IEEE80211_PROACTIVE_PREQ_NO_PREP: the mesh STA is a root mesh STA supports 1742 * the proactive PREQ with proactive PREP subfield set to 0 1743 * @RTW_IEEE80211_PROACTIVE_PREQ_WITH_PREP: the mesh STA is a root mesh STA 1744 * supports the proactive PREQ with proactive PREP subfield set to 1 1745 * @RTW_IEEE80211_PROACTIVE_RANN: the mesh STA is a root mesh STA supports 1746 * the proactive RANN 1747 */ 1748 enum rtw_ieee80211_root_mode_identifier { 1749 RTW_IEEE80211_ROOTMODE_NO_ROOT = 0, 1750 RTW_IEEE80211_ROOTMODE_ROOT = 1, 1751 RTW_IEEE80211_PROACTIVE_PREQ_NO_PREP = 2, 1752 RTW_IEEE80211_PROACTIVE_PREQ_WITH_PREP = 3, 1753 RTW_IEEE80211_PROACTIVE_RANN = 4, 1754 }; 1755 1756 /** 1757 * enum rtw_ieee80211_channel_flags - channel flags 1758 * 1759 * Channel flags set by the regulatory control code. 1760 * 1761 * @RTW_IEEE80211_CHAN_DISABLED: This channel is disabled. 1762 * @RTW_IEEE80211_CHAN_PASSIVE_SCAN: Only passive scanning is permitted 1763 * on this channel. 1764 * @RTW_IEEE80211_CHAN_NO_IBSS: IBSS is not allowed on this channel. 1765 * @RTW_IEEE80211_CHAN_RADAR: Radar detection is required on this channel. 1766 * @RTW_IEEE80211_CHAN_NO_HT40PLUS: extension channel above this channel 1767 * is not permitted. 1768 * @RTW_IEEE80211_CHAN_NO_HT40MINUS: extension channel below this channel 1769 * is not permitted. 1770 */ 1771 enum rtw_ieee80211_channel_flags { 1772 RTW_IEEE80211_CHAN_DISABLED = 1 << 0, 1773 RTW_IEEE80211_CHAN_PASSIVE_SCAN = 1 << 1, 1774 RTW_IEEE80211_CHAN_NO_IBSS = 1 << 2, 1775 RTW_IEEE80211_CHAN_RADAR = 1 << 3, 1776 RTW_IEEE80211_CHAN_NO_HT40PLUS = 1 << 4, 1777 RTW_IEEE80211_CHAN_NO_HT40MINUS = 1 << 5, 1778 }; 1779 1780 #define RTW_IEEE80211_CHAN_NO_HT40 \ 1781 (RTW_IEEE80211_CHAN_NO_HT40PLUS | RTW_IEEE80211_CHAN_NO_HT40MINUS) 1782 1783 /* Represent channel details, subset of ieee80211_channel */ 1784 struct rtw_ieee80211_channel { 1785 /* enum ieee80211_band band; */ 1786 /* u16 center_freq; */ 1787 u16 hw_value; 1788 u32 flags; 1789 /* int max_antenna_gain; */ 1790 /* int max_power; */ 1791 /* int max_reg_power; */ 1792 /* bool beacon_found; */ 1793 /* u32 orig_flags; */ 1794 /* int orig_mag; */ 1795 /* int orig_mpwr; */ 1796 }; 1797 1798 #define CHAN_FMT \ 1799 /*"band:%d, "*/ \ 1800 /*"center_freq:%u, "*/ \ 1801 "hw_value:%u, " \ 1802 "flags:0x%08x" \ 1803 /*"max_antenna_gain:%d\n"*/ \ 1804 /*"max_power:%d\n"*/ \ 1805 /*"max_reg_power:%d\n"*/ \ 1806 /*"beacon_found:%u\n"*/ \ 1807 /*"orig_flags:0x%08x\n"*/ \ 1808 /*"orig_mag:%d\n"*/ \ 1809 /*"orig_mpwr:%d\n"*/ 1810 1811 #define CHAN_ARG(channel) \ 1812 /*(channel)->band*/ \ 1813 /*, (channel)->center_freq*/ \ 1814 (channel)->hw_value \ 1815 , (channel)->flags \ 1816 /*, (channel)->max_antenna_gain*/ \ 1817 /*, (channel)->max_power*/ \ 1818 /*, (channel)->max_reg_power*/ \ 1819 /*, (channel)->beacon_found*/ \ 1820 /*, (channel)->orig_flags*/ \ 1821 /*, (channel)->orig_mag*/ \ 1822 /*, (channel)->orig_mpwr*/ \ 1823 1824 /* Parsed Information Elements */ 1825 struct rtw_ieee802_11_elems { 1826 u8 *ssid; 1827 u8 ssid_len; 1828 u8 *supp_rates; 1829 u8 supp_rates_len; 1830 u8 *fh_params; 1831 u8 fh_params_len; 1832 u8 *ds_params; 1833 u8 ds_params_len; 1834 u8 *cf_params; 1835 u8 cf_params_len; 1836 u8 *tim; 1837 u8 tim_len; 1838 u8 *ibss_params; 1839 u8 ibss_params_len; 1840 u8 *challenge; 1841 u8 challenge_len; 1842 u8 *erp_info; 1843 u8 erp_info_len; 1844 u8 *ext_supp_rates; 1845 u8 ext_supp_rates_len; 1846 u8 *wpa_ie; 1847 u8 wpa_ie_len; 1848 u8 *rsn_ie; 1849 u8 rsn_ie_len; 1850 u8 *wme; 1851 u8 wme_len; 1852 u8 *wme_tspec; 1853 u8 wme_tspec_len; 1854 u8 *wps_ie; 1855 u8 wps_ie_len; 1856 u8 *power_cap; 1857 u8 power_cap_len; 1858 u8 *supp_channels; 1859 u8 supp_channels_len; 1860 u8 *mdie; 1861 u8 mdie_len; 1862 u8 *ftie; 1863 u8 ftie_len; 1864 u8 *timeout_int; 1865 u8 timeout_int_len; 1866 u8 *ht_capabilities; 1867 u8 ht_capabilities_len; 1868 u8 *ht_operation; 1869 u8 ht_operation_len; 1870 u8 *vendor_ht_cap; 1871 u8 vendor_ht_cap_len; 1872 u8 *vht_capabilities; 1873 u8 vht_capabilities_len; 1874 u8 *vht_operation; 1875 u8 vht_operation_len; 1876 u8 *vht_op_mode_notify; 1877 u8 vht_op_mode_notify_len; 1878 u8 *rm_en_cap; 1879 u8 rm_en_cap_len; 1880 #ifdef CONFIG_RTW_MESH 1881 u8 *preq; 1882 u8 preq_len; 1883 u8 *prep; 1884 u8 prep_len; 1885 u8 *perr; 1886 u8 perr_len; 1887 u8 *rann; 1888 u8 rann_len; 1889 #endif 1890 #ifdef CONFIG_RTW_TOKEN_BASED_XMIT 1891 u8 *tbtx_cap; 1892 u8 tbtx_cap_len; 1893 #endif 1894 }; 1895 1896 typedef enum { ParseOK = 0, ParseUnknown = 1, ParseFailed = -1 } ParseRes; 1897 1898 ParseRes rtw_ieee802_11_parse_elems(u8 *start, uint len, 1899 struct rtw_ieee802_11_elems *elems, 1900 int show_errors); 1901 1902 u8 *rtw_set_fixed_ie(unsigned char *pbuf, unsigned int len, unsigned char *source, unsigned int *frlen); 1903 u8 *rtw_set_ie(u8 *pbuf, sint index, uint len, const u8 *source, uint *frlen); 1904 1905 enum secondary_ch_offset { 1906 SCN = 0, /* no secondary channel */ 1907 SCA = 1, /* secondary channel above */ 1908 SCB = 3, /* secondary channel below */ 1909 }; 1910 u8 secondary_ch_offset_to_hal_ch_offset(u8 ch_offset); 1911 u8 hal_ch_offset_to_secondary_ch_offset(u8 ch_offset); 1912 u8 *rtw_set_ie_ch_switch(u8 *buf, u32 *buf_len, u8 ch_switch_mode, u8 new_ch, u8 ch_switch_cnt); 1913 u8 *rtw_set_ie_secondary_ch_offset(u8 *buf, u32 *buf_len, u8 secondary_ch_offset); 1914 u8 *rtw_set_ie_mesh_ch_switch_parm(u8 *buf, u32 *buf_len, u8 ttl, u8 flags, u16 reason, u16 precedence); 1915 1916 u8 *rtw_get_ie(const u8 *pbuf, sint index, sint *len, sint limit); 1917 u8 rtw_update_rate_bymode(WLAN_BSSID_EX *pbss_network, u32 mode); 1918 1919 u8 *rtw_get_ie_ex(const u8 *in_ie, uint in_len, u8 eid, const u8 *oui, u8 oui_len, u8 *ie, uint *ielen); 1920 int rtw_ies_remove_ie(u8 *ies, uint *ies_len, uint offset, u8 eid, u8 *oui, u8 oui_len); 1921 1922 void rtw_set_supported_rate(u8 *SupportedRates, uint mode) ; 1923 1924 #define GET_RSN_CAP_MFP_OPTION(cap) LE_BITS_TO_2BYTE(((u8 *)(cap)), 6, 2) 1925 1926 #define MFP_NO 0 1927 #define MFP_INVALID 1 1928 #define MFP_OPTIONAL 2 1929 #define MFP_REQUIRED 3 1930 1931 /*For amsdu mode */ 1932 #define GET_RSN_CAP_SPP_OPT(cap) LE_BITS_TO_2BYTE(((u8 *)(cap)), 10, 2) 1933 #define SET_RSN_CAP_SPP(cap, spp) SET_BITS_TO_LE_2BYTE(((u8 *)(cap)), 10, 2, spp) 1934 #define SPP_CAP BIT(0) 1935 #define SPP_REQ BIT(1) 1936 1937 enum rtw_amsdu_mode { 1938 RTW_AMSDU_MODE_NON_SPP = 0, 1939 RTW_AMSDU_MODE_SPP = 1, 1940 RTW_AMSDU_MODE_ALL_DROP = 2, 1941 }; 1942 1943 struct rsne_info { 1944 u8 *gcs; 1945 u16 pcs_cnt; 1946 u8 *pcs_list; 1947 u16 akm_cnt; 1948 u8 *akm_list; 1949 u8 *cap; 1950 u16 pmkid_cnt; 1951 u8 *pmkid_list; 1952 u8 *gmcs; 1953 1954 u8 err; 1955 }; 1956 int rtw_rsne_info_parse(const u8 *ie, uint ie_len, struct rsne_info *info); 1957 1958 unsigned char *rtw_get_wpa_ie(unsigned char *pie, int *wpa_ie_len, int limit); 1959 unsigned char *rtw_get_wpa2_ie(unsigned char *pie, int *rsn_ie_len, int limit); 1960 int rtw_get_wpa_cipher_suite(u8 *s); 1961 int rtw_get_rsn_cipher_suite(u8 *s); 1962 int rtw_get_wapi_ie(u8 *in_ie, uint in_len, u8 *wapi_ie, u16 *wapi_len); 1963 int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, u32 *akm); 1964 int rtw_parse_wpa2_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *gmcs, u32 *akm, u8 *mfp_opt, u8* spp_opt); 1965 1966 int rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, u16 *wpa_len); 1967 1968 u8 rtw_is_wps_ie(u8 *ie_ptr, uint *wps_ielen); 1969 u8 *rtw_get_wps_ie_from_scan_queue(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen, enum bss_type frame_type); 1970 u8 *rtw_get_wps_ie(const u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen); 1971 u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id , u8 *buf_attr, u32 *len_attr); 1972 u8 *rtw_get_wps_attr_content(u8 *wps_ie, uint wps_ielen, u16 target_attr_id , u8 *buf_content, uint *len_content); 1973 1974 u8 *rtw_get_owe_ie(const u8 *in_ie, uint in_len, u8 *owe_ie, uint *owe_ielen); 1975 1976 /** 1977 * for_each_ie - iterate over continuous IEs 1978 * @ie: 1979 * @buf: 1980 * @buf_len: 1981 */ 1982 #define for_each_ie(ie, buf, buf_len) \ 1983 for (ie = (void *)buf; (((u8 *)ie) - ((u8 *)buf) + 1) < buf_len; ie = (void *)(((u8 *)ie) + *(((u8 *)ie)+1) + 2)) 1984 1985 void dump_ies(void *sel, const u8 *buf, u32 buf_len); 1986 #ifdef CONFIG_RTW_DEBUG 1987 1988 #ifdef CONFIG_80211N_HT 1989 #define HT_SC_OFFSET_MAX 4 1990 extern const char *const _ht_sc_offset_str[]; 1991 #define ht_sc_offset_str(sc) (((sc) >= HT_SC_OFFSET_MAX) ? _ht_sc_offset_str[2] : _ht_sc_offset_str[(sc)]) 1992 1993 void dump_ht_cap_ie_content(void *sel, const u8 *buf, u32 buf_len); 1994 #endif 1995 1996 void dump_wps_ie(void *sel, const u8 *ie, u32 ie_len); 1997 #endif /* CONFIG_RTW_DEBUG */ 1998 1999 void rtw_ies_get_chbw(u8 *ies, int ies_len, u8 *ch, u8 *bw, u8 *offset, u8 ht, u8 vht); 2000 2001 void rtw_bss_get_chbw(WLAN_BSSID_EX *bss, u8 *ch, u8 *bw, u8 *offset, u8 ht, u8 vht); 2002 2003 bool rtw_is_chbw_grouped(u8 ch_a, u8 bw_a, u8 offset_a 2004 , u8 ch_b, u8 bw_b, u8 offset_b); 2005 void rtw_sync_chbw(u8 *req_ch, u8 *req_bw, u8 *req_offset 2006 , u8 *g_ch, u8 *g_bw, u8 *g_offset); 2007 2008 #ifdef CONFIG_P2P 2009 u32 rtw_get_p2p_merged_ies_len(u8 *in_ie, u32 in_len); 2010 int rtw_p2p_merge_ies(u8 *in_ie, u32 in_len, u8 *merge_ie); 2011 #ifdef CONFIG_RTW_DEBUG 2012 void dump_p2p_ie(void *sel, const u8 *ie, u32 ie_len); 2013 #endif 2014 u8 *rtw_get_p2p_ie(const u8 *in_ie, int in_len, u8 *p2p_ie, uint *p2p_ielen); 2015 u8 *rtw_get_p2p_attr(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id, u8 *buf_attr, u32 *len_attr); 2016 u8 *rtw_get_p2p_attr_content(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id, u8 *buf_content, uint *len_content); 2017 u32 rtw_set_p2p_attr_content(u8 *pbuf, u8 attr_id, u16 attr_len, u8 *pdata_attr); 2018 uint rtw_del_p2p_ie(u8 *ies, uint ies_len_ori, const char *msg); 2019 uint rtw_del_p2p_attr(u8 *ie, uint ielen_ori, u8 attr_id); 2020 u8 *rtw_bss_ex_get_p2p_ie(WLAN_BSSID_EX *bss_ex, u8 *p2p_ie, uint *p2p_ielen); 2021 void rtw_bss_ex_del_p2p_ie(WLAN_BSSID_EX *bss_ex); 2022 void rtw_bss_ex_del_p2p_attr(WLAN_BSSID_EX *bss_ex, u8 attr_id); 2023 #endif /* CONFIG_P2P */ 2024 2025 uint rtw_del_wfd_ie(u8 *ies, uint ies_len_ori, const char *msg); 2026 void rtw_bss_ex_del_wfd_ie(WLAN_BSSID_EX *bss_ex); 2027 #ifdef CONFIG_WFD 2028 #ifdef CONFIG_RTW_DEBUG 2029 void dump_wfd_ie(void *sel, const u8 *ie, u32 ie_len); 2030 #endif 2031 u8 *rtw_get_wfd_ie(const u8 *in_ie, int in_len, u8 *wfd_ie, uint *wfd_ielen); 2032 u8 *rtw_get_wfd_attr(u8 *wfd_ie, uint wfd_ielen, u8 target_attr_id, u8 *buf_attr, u32 *len_attr); 2033 u8 *rtw_get_wfd_attr_content(u8 *wfd_ie, uint wfd_ielen, u8 target_attr_id, u8 *buf_content, uint *len_content); 2034 uint rtw_del_wfd_attr(u8 *ie, uint ielen_ori, u8 attr_id); 2035 u8 *rtw_bss_ex_get_wfd_ie(WLAN_BSSID_EX *bss_ex, u8 *wfd_ie, uint *wfd_ielen); 2036 void rtw_bss_ex_del_wfd_attr(WLAN_BSSID_EX *bss_ex, u8 attr_id); 2037 #endif 2038 2039 #define MULTI_AP_SUB_ELEM_TYPE 0x06 2040 #define MULTI_AP_TEAR_DOWN BIT(4) 2041 #define MULTI_AP_FRONTHAUL_BSS BIT(5) 2042 #define MULTI_AP_BACKHAUL_BSS BIT(6) 2043 #define MULTI_AP_BACKHAUL_STA BIT(7) 2044 #ifdef CONFIG_RTW_MULTI_AP 2045 void dump_multi_ap_ie(void *sel, const u8 *ie, u32 ie_len); 2046 u8 rtw_get_multi_ap_ie_ext(const u8 *ies, int ies_len); 2047 u8 *rtw_set_multi_ap_ie_ext(u8 *pbuf, uint *frlen, u8 val); 2048 #endif 2049 2050 uint rtw_get_rateset_len(u8 *rateset); 2051 2052 struct registry_priv; 2053 int rtw_generate_ie(struct registry_priv *pregistrypriv); 2054 2055 int rtw_get_bit_value_from_ieee_value(u8 val); 2056 2057 uint rtw_is_cckrates_included(u8 *rate); 2058 2059 uint rtw_is_cckratesonly_included(u8 *rate); 2060 uint rtw_get_cckrate_size(u8 *rate,u32 rate_length); 2061 int rtw_check_network_type(unsigned char *rate, int ratelen, int channel); 2062 2063 u8 rtw_check_invalid_mac_address(u8 *mac_addr, u8 check_local_bit); 2064 void rtw_macaddr_cfg(u8 *out, const u8 *hw_mac_addr); 2065 2066 u16 rtw_ht_mcs_rate(u8 bw_40MHz, u8 short_GI, unsigned char *MCS_rate); 2067 u8 rtw_ht_mcsset_to_nss(u8 *supp_mcs_set); 2068 u32 rtw_ht_mcs_set_to_bitmap(u8 *mcs_set, u8 nss); 2069 2070 int rtw_action_frame_parse(const u8 *frame, u32 frame_len, u8 *category, u8 *action); 2071 const char *action_public_str(u8 action); 2072 2073 u8 key_2char2num(u8 hch, u8 lch); 2074 u8 str_2char2num(u8 hch, u8 lch); 2075 void macstr2num(u8 *dst, u8 *src); 2076 u8 convert_ip_addr(u8 hch, u8 mch, u8 lch); 2077 int wifirate2_ratetbl_inx(unsigned char rate); 2078 2079 /* For amsdu mode. */ 2080 /*void rtw_set_spp_amsdu_mode(u8 mode, u8 *rsn_ie, int rsn_ie_len); */ 2081 u8 rtw_check_amsdu_disable(u8 mode, u8 spp_opt); 2082 2083 #endif /* IEEE80211_H */ 2084