1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /****************************************************************************** 3 * 4 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. 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 /* RTL871X_IOCTL_HOSTAPD ioctl() cmd: */ 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 /* REMOVED: PRISM2_HOSTAPD_RESET_TXEXC_STA = 5, */ 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 /* STA flags */ 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) /* pending activity poll not ACKed */ 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, /* BGN 40 Mhz 2SS 1SS */ 144 RATR_INX_WIRELESS_NG = 1, /* GN or N */ 145 RATR_INX_WIRELESS_NB = 2, /* BGN 20 Mhz 2SS 1SS or BN */ 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 WIRELESS_INVALID = 0, 157 /* Sub-Element */ 158 WIRELESS_11B = BIT(0), /* tx: cck only , rx: cck only, hw: cck */ 159 WIRELESS_11G = BIT(1), /* tx: ofdm only, rx: ofdm & cck, hw: cck & ofdm */ 160 WIRELESS_11A = BIT(2), /* tx: ofdm only, rx: ofdm only, hw: ofdm only */ 161 WIRELESS_11_24N = BIT(3), /* tx: MCS only, rx: MCS & cck, hw: MCS & cck */ 162 WIRELESS_11_5N = BIT(4), /* tx: MCS only, rx: MCS & ofdm, hw: ofdm only */ 163 WIRELESS_AUTO = BIT(5), 164 WIRELESS_11AC = BIT(6), 165 166 /* Combination */ 167 /* Type for current wireless mode */ 168 WIRELESS_11BG = (WIRELESS_11B|WIRELESS_11G), /* tx: cck & ofdm, rx: cck & ofdm & MCS, hw: cck & ofdm */ 169 WIRELESS_11G_24N = (WIRELESS_11G|WIRELESS_11_24N), /* tx: ofdm & MCS, rx: ofdm & cck & MCS, hw: cck & ofdm */ 170 WIRELESS_11A_5N = (WIRELESS_11A|WIRELESS_11_5N), /* tx: ofdm & MCS, rx: ofdm & MCS, hw: ofdm only */ 171 WIRELESS_11B_24N = (WIRELESS_11B|WIRELESS_11_24N), /* tx: ofdm & cck & MCS, rx: ofdm & cck & MCS, hw: ofdm & cck */ 172 WIRELESS_11BG_24N = (WIRELESS_11B|WIRELESS_11G|WIRELESS_11_24N), /* tx: ofdm & cck & MCS, rx: ofdm & cck & MCS, hw: ofdm & cck */ 173 WIRELESS_11_24AC = (WIRELESS_11G|WIRELESS_11AC), 174 WIRELESS_11_5AC = (WIRELESS_11A|WIRELESS_11AC), 175 176 177 /* Type for registry default wireless mode */ 178 WIRELESS_11AGN = (WIRELESS_11A|WIRELESS_11G|WIRELESS_11_24N|WIRELESS_11_5N), /* tx: ofdm & MCS, rx: ofdm & MCS, hw: ofdm only */ 179 WIRELESS_11ABGN = (WIRELESS_11A|WIRELESS_11B|WIRELESS_11G|WIRELESS_11_24N|WIRELESS_11_5N), 180 WIRELESS_MODE_24G = (WIRELESS_11B|WIRELESS_11G|WIRELESS_11_24N|WIRELESS_11AC), 181 WIRELESS_MODE_MAX = (WIRELESS_11A|WIRELESS_11B|WIRELESS_11G|WIRELESS_11_24N|WIRELESS_11_5N|WIRELESS_11AC), 182 }; 183 184 #define SUPPORTED_24G_NETTYPE_MSK (WIRELESS_11B | WIRELESS_11G | WIRELESS_11_24N) 185 186 #define IsLegacyOnly(NetType) ((NetType) == ((NetType) & (WIRELESS_11BG|WIRELESS_11A))) 187 188 #define IsSupported24G(NetType) ((NetType) & SUPPORTED_24G_NETTYPE_MSK ? true : false) 189 190 #define IsEnableHWCCK(NetType) IsSupported24G(NetType) 191 #define IsEnableHWOFDM(NetType) (((NetType) & (WIRELESS_11G|WIRELESS_11_24N)) ? true : false) 192 193 #define IsSupportedRxCCK(NetType) IsEnableHWCCK(NetType) 194 #define IsSupportedRxOFDM(NetType) IsEnableHWOFDM(NetType) 195 #define IsSupportedRxHT(NetType) IsEnableHWOFDM(NetType) 196 197 #define IsSupportedTxCCK(NetType) (((NetType) & (WIRELESS_11B)) ? true : false) 198 #define IsSupportedTxOFDM(NetType) (((NetType) & (WIRELESS_11G|WIRELESS_11A)) ? true : false) 199 #define IsSupportedHT(NetType) (((NetType) & (WIRELESS_11_24N|WIRELESS_11_5N)) ? true : false) 200 201 #define IsSupportedVHT(NetType) (((NetType) & (WIRELESS_11AC)) ? true : false) 202 203 204 struct ieee_param { 205 u32 cmd; 206 u8 sta_addr[ETH_ALEN]; 207 union { 208 struct { 209 u8 name; 210 u32 value; 211 } wpa_param; 212 struct { 213 u32 len; 214 u8 reserved[32]; 215 u8 data[0]; 216 } wpa_ie; 217 struct{ 218 int command; 219 int reason_code; 220 } mlme; 221 struct { 222 u8 alg[IEEE_CRYPT_ALG_NAME_LEN]; 223 u8 set_tx; 224 u32 err; 225 u8 idx; 226 u8 seq[8]; /* sequence counter (set: RX, get: TX) */ 227 u16 key_len; 228 u8 key[0]; 229 } crypt; 230 struct { 231 u16 aid; 232 u16 capability; 233 int flags; 234 u8 tx_supp_rates[16]; 235 struct rtw_ieee80211_ht_cap ht_cap; 236 } add_sta; 237 struct { 238 u8 reserved[2];/* for set max_num_sta */ 239 u8 buf[0]; 240 } bcn_ie; 241 } u; 242 }; 243 244 struct ieee_param_ex { 245 u32 cmd; 246 u8 sta_addr[ETH_ALEN]; 247 u8 data[0]; 248 }; 249 250 struct sta_data { 251 u16 aid; 252 u16 capability; 253 int flags; 254 u32 sta_set; 255 u8 tx_supp_rates[16]; 256 u32 tx_supp_rates_len; 257 struct rtw_ieee80211_ht_cap ht_cap; 258 u64 rx_pkts; 259 u64 rx_bytes; 260 u64 rx_drops; 261 u64 tx_pkts; 262 u64 tx_bytes; 263 u64 tx_drops; 264 }; 265 266 /* this is stolen from ipw2200 driver */ 267 #define IEEE_IBSS_MAC_HASH_SIZE 31 268 269 struct ieee_ibss_seq { 270 u8 mac[ETH_ALEN]; 271 u16 seq_num; 272 u16 frag_num; 273 unsigned long packet_time; 274 struct list_head list; 275 }; 276 277 struct eapol { 278 u8 snap[6]; 279 u16 ethertype; 280 u8 version; 281 u8 type; 282 u16 length; 283 } __attribute__ ((packed)); 284 285 enum eap_type { 286 EAP_PACKET = 0, 287 EAPOL_START, 288 EAPOL_LOGOFF, 289 EAPOL_KEY, 290 EAPOL_ENCAP_ASF_ALERT 291 }; 292 293 #define IEEE80211_FCS_LEN 4 294 295 #define MIN_FRAG_THRESHOLD 256U 296 #define MAX_FRAG_THRESHOLD 2346U 297 298 /* sequence control field */ 299 #define RTW_IEEE80211_SCTL_FRAG 0x000F 300 #define RTW_IEEE80211_SCTL_SEQ 0xFFF0 301 302 303 #define RTW_ERP_INFO_NON_ERP_PRESENT BIT(0) 304 #define RTW_ERP_INFO_USE_PROTECTION BIT(1) 305 #define RTW_ERP_INFO_BARKER_PREAMBLE_MODE BIT(2) 306 307 /* QoS, QOS */ 308 #define NORMAL_ACK 0 309 #define NO_ACK 1 310 #define NON_EXPLICIT_ACK 2 311 #define BLOCK_ACK 3 312 313 #ifndef ETH_P_PAE 314 #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */ 315 #endif /* ETH_P_PAE */ 316 317 #define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */ 318 319 #define ETH_P_ECONET 0x0018 320 321 #ifndef ETH_P_80211_RAW 322 #define ETH_P_80211_RAW (ETH_P_ECONET + 1) 323 #endif 324 325 /* IEEE 802.11 defines */ 326 327 #define P80211_OUI_LEN 3 328 329 struct ieee80211_snap_hdr { 330 u8 dsap; /* always 0xAA */ 331 u8 ssap; /* always 0xAA */ 332 u8 ctrl; /* always 0x03 */ 333 u8 oui[P80211_OUI_LEN]; /* organizational universal id */ 334 } __attribute__ ((packed)); 335 336 #define SNAP_SIZE sizeof(struct ieee80211_snap_hdr) 337 338 #define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE) 339 #define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE) 340 341 #define WLAN_QC_GET_TID(qc) ((qc) & 0x0f) 342 343 #define WLAN_GET_SEQ_FRAG(seq) ((seq) & RTW_IEEE80211_SCTL_FRAG) 344 #define WLAN_GET_SEQ_SEQ(seq) ((seq) & RTW_IEEE80211_SCTL_SEQ) 345 346 /* Authentication algorithms */ 347 #define WLAN_CAPABILITY_BSS (1<<0) 348 #define WLAN_CAPABILITY_SHORT_SLOT (1<<10) 349 350 /* 802.11b */ 351 #define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19 352 353 /* Reason codes */ 354 #define WLAN_REASON_ACTIVE_ROAM 65533 355 #define WLAN_REASON_JOIN_WRONG_CHANNEL 65534 356 #define WLAN_REASON_EXPIRATION_CHK 65535 357 358 /* EIDs defined by IEEE 802.11h - END */ 359 #define WLAN_EID_HT_CAP 45 360 #define WLAN_EID_20_40_BSS_COEXISTENCE 72 361 #define WLAN_EID_20_40_BSS_INTOLERANT 73 362 #define WLAN_EID_OVERLAPPING_BSS_SCAN_PARAMS 74 363 #define WLAN_EID_GENERIC (WLAN_EID_VENDOR_SPECIFIC) 364 #define WLAN_EID_VHT_OP_MODE_NOTIFY 199 365 366 #define IEEE80211_MGMT_HDR_LEN 24 367 #define IEEE80211_DATA_HDR3_LEN 24 368 #define IEEE80211_DATA_HDR4_LEN 30 369 370 371 #define IEEE80211_STATMASK_SIGNAL (1<<0) 372 #define IEEE80211_STATMASK_RSSI (1<<1) 373 #define IEEE80211_STATMASK_NOISE (1<<2) 374 #define IEEE80211_STATMASK_RATE (1<<3) 375 #define IEEE80211_STATMASK_WEMASK 0x7 376 377 378 #define IEEE80211_CCK_MODULATION (1<<0) 379 #define IEEE80211_OFDM_MODULATION (1<<1) 380 381 #define IEEE80211_24GHZ_BAND (1<<0) 382 #define IEEE80211_52GHZ_BAND (1<<1) 383 384 #define IEEE80211_CCK_RATE_LEN 4 385 #define IEEE80211_NUM_OFDM_RATESLEN 8 386 387 388 #define IEEE80211_CCK_RATE_1MB 0x02 389 #define IEEE80211_CCK_RATE_2MB 0x04 390 #define IEEE80211_CCK_RATE_5MB 0x0B 391 #define IEEE80211_CCK_RATE_11MB 0x16 392 #define IEEE80211_OFDM_RATE_LEN 8 393 #define IEEE80211_OFDM_RATE_6MB 0x0C 394 #define IEEE80211_OFDM_RATE_9MB 0x12 395 #define IEEE80211_OFDM_RATE_12MB 0x18 396 #define IEEE80211_OFDM_RATE_18MB 0x24 397 #define IEEE80211_OFDM_RATE_24MB 0x30 398 #define IEEE80211_OFDM_RATE_36MB 0x48 399 #define IEEE80211_OFDM_RATE_48MB 0x60 400 #define IEEE80211_OFDM_RATE_54MB 0x6C 401 #define IEEE80211_BASIC_RATE_MASK 0x80 402 403 #define IEEE80211_CCK_RATE_1MB_MASK (1<<0) 404 #define IEEE80211_CCK_RATE_2MB_MASK (1<<1) 405 #define IEEE80211_CCK_RATE_5MB_MASK (1<<2) 406 #define IEEE80211_CCK_RATE_11MB_MASK (1<<3) 407 #define IEEE80211_OFDM_RATE_6MB_MASK (1<<4) 408 #define IEEE80211_OFDM_RATE_9MB_MASK (1<<5) 409 #define IEEE80211_OFDM_RATE_12MB_MASK (1<<6) 410 #define IEEE80211_OFDM_RATE_18MB_MASK (1<<7) 411 #define IEEE80211_OFDM_RATE_24MB_MASK (1<<8) 412 #define IEEE80211_OFDM_RATE_36MB_MASK (1<<9) 413 #define IEEE80211_OFDM_RATE_48MB_MASK (1<<10) 414 #define IEEE80211_OFDM_RATE_54MB_MASK (1<<11) 415 416 #define IEEE80211_CCK_RATES_MASK 0x0000000F 417 #define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \ 418 IEEE80211_CCK_RATE_2MB_MASK) 419 #define IEEE80211_CCK_DEFAULT_RATES_MASK (IEEE80211_CCK_BASIC_RATES_MASK | \ 420 IEEE80211_CCK_RATE_5MB_MASK | \ 421 IEEE80211_CCK_RATE_11MB_MASK) 422 423 #define IEEE80211_OFDM_RATES_MASK 0x00000FF0 424 #define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \ 425 IEEE80211_OFDM_RATE_12MB_MASK | \ 426 IEEE80211_OFDM_RATE_24MB_MASK) 427 #define IEEE80211_OFDM_DEFAULT_RATES_MASK (IEEE80211_OFDM_BASIC_RATES_MASK | \ 428 IEEE80211_OFDM_RATE_9MB_MASK | \ 429 IEEE80211_OFDM_RATE_18MB_MASK | \ 430 IEEE80211_OFDM_RATE_36MB_MASK | \ 431 IEEE80211_OFDM_RATE_48MB_MASK | \ 432 IEEE80211_OFDM_RATE_54MB_MASK) 433 #define IEEE80211_DEFAULT_RATES_MASK (IEEE80211_OFDM_DEFAULT_RATES_MASK | \ 434 IEEE80211_CCK_DEFAULT_RATES_MASK) 435 436 #define IEEE80211_NUM_OFDM_RATES 8 437 #define IEEE80211_NUM_CCK_RATES 4 438 #define IEEE80211_OFDM_SHIFT_MASK_A 4 439 440 441 enum MGN_RATE { 442 MGN_1M = 0x02, 443 MGN_2M = 0x04, 444 MGN_5_5M = 0x0B, 445 MGN_6M = 0x0C, 446 MGN_9M = 0x12, 447 MGN_11M = 0x16, 448 MGN_12M = 0x18, 449 MGN_18M = 0x24, 450 MGN_24M = 0x30, 451 MGN_36M = 0x48, 452 MGN_48M = 0x60, 453 MGN_54M = 0x6C, 454 MGN_MCS32 = 0x7F, 455 MGN_MCS0, 456 MGN_MCS1, 457 MGN_MCS2, 458 MGN_MCS3, 459 MGN_MCS4, 460 MGN_MCS5, 461 MGN_MCS6, 462 MGN_MCS7, 463 MGN_MCS8, 464 MGN_MCS9, 465 MGN_MCS10, 466 MGN_MCS11, 467 MGN_MCS12, 468 MGN_MCS13, 469 MGN_MCS14, 470 MGN_MCS15, 471 MGN_MCS16, 472 MGN_MCS17, 473 MGN_MCS18, 474 MGN_MCS19, 475 MGN_MCS20, 476 MGN_MCS21, 477 MGN_MCS22, 478 MGN_MCS23, 479 MGN_MCS24, 480 MGN_MCS25, 481 MGN_MCS26, 482 MGN_MCS27, 483 MGN_MCS28, 484 MGN_MCS29, 485 MGN_MCS30, 486 MGN_MCS31, 487 MGN_VHT1SS_MCS0, 488 MGN_VHT1SS_MCS1, 489 MGN_VHT1SS_MCS2, 490 MGN_VHT1SS_MCS3, 491 MGN_VHT1SS_MCS4, 492 MGN_VHT1SS_MCS5, 493 MGN_VHT1SS_MCS6, 494 MGN_VHT1SS_MCS7, 495 MGN_VHT1SS_MCS8, 496 MGN_VHT1SS_MCS9, 497 MGN_VHT2SS_MCS0, 498 MGN_VHT2SS_MCS1, 499 MGN_VHT2SS_MCS2, 500 MGN_VHT2SS_MCS3, 501 MGN_VHT2SS_MCS4, 502 MGN_VHT2SS_MCS5, 503 MGN_VHT2SS_MCS6, 504 MGN_VHT2SS_MCS7, 505 MGN_VHT2SS_MCS8, 506 MGN_VHT2SS_MCS9, 507 MGN_VHT3SS_MCS0, 508 MGN_VHT3SS_MCS1, 509 MGN_VHT3SS_MCS2, 510 MGN_VHT3SS_MCS3, 511 MGN_VHT3SS_MCS4, 512 MGN_VHT3SS_MCS5, 513 MGN_VHT3SS_MCS6, 514 MGN_VHT3SS_MCS7, 515 MGN_VHT3SS_MCS8, 516 MGN_VHT3SS_MCS9, 517 MGN_VHT4SS_MCS0, 518 MGN_VHT4SS_MCS1, 519 MGN_VHT4SS_MCS2, 520 MGN_VHT4SS_MCS3, 521 MGN_VHT4SS_MCS4, 522 MGN_VHT4SS_MCS5, 523 MGN_VHT4SS_MCS6, 524 MGN_VHT4SS_MCS7, 525 MGN_VHT4SS_MCS8, 526 MGN_VHT4SS_MCS9, 527 MGN_UNKNOWN 528 }; 529 530 #define IS_HT_RATE(_rate) (_rate >= MGN_MCS0 && _rate <= MGN_MCS31) 531 #define IS_VHT_RATE(_rate) (_rate >= MGN_VHT1SS_MCS0 && _rate <= MGN_VHT4SS_MCS9) 532 #define IS_CCK_RATE(_rate) (MGN_1M == _rate || _rate == MGN_2M || _rate == MGN_5_5M || _rate == MGN_11M) 533 #define IS_OFDM_RATE(_rate) (MGN_6M <= _rate && _rate <= MGN_54M && _rate != MGN_11M) 534 535 536 /* NOTE: This data is for statistical purposes; not all hardware provides this 537 * information for frames received. Not setting these will not cause 538 * any adverse affects. */ 539 struct ieee80211_rx_stats { 540 s8 rssi; 541 u8 signal; 542 u8 noise; 543 u8 received_channel; 544 u16 rate; /* in 100 kbps */ 545 u8 mask; 546 u8 freq; 547 u16 len; 548 }; 549 550 /* IEEE 802.11 requires that STA supports concurrent reception of at least 551 * three fragmented frames. This define can be increased to support more 552 * concurrent frames, but it should be noted that each entry can consume about 553 * 2 kB of RAM and increasing cache size will slow down frame reassembly. */ 554 #define IEEE80211_FRAG_CACHE_LEN 4 555 556 struct ieee80211_frag_entry { 557 u32 first_frag_time; 558 uint seq; 559 uint last_frag; 560 uint qos; /* jackson */ 561 uint tid; /* jackson */ 562 struct sk_buff *skb; 563 u8 src_addr[ETH_ALEN]; 564 u8 dst_addr[ETH_ALEN]; 565 }; 566 567 struct ieee80211_stats { 568 uint tx_unicast_frames; 569 uint tx_multicast_frames; 570 uint tx_fragments; 571 uint tx_unicast_octets; 572 uint tx_multicast_octets; 573 uint tx_deferred_transmissions; 574 uint tx_single_retry_frames; 575 uint tx_multiple_retry_frames; 576 uint tx_retry_limit_exceeded; 577 uint tx_discards; 578 uint rx_unicast_frames; 579 uint rx_multicast_frames; 580 uint rx_fragments; 581 uint rx_unicast_octets; 582 uint rx_multicast_octets; 583 uint rx_fcs_errors; 584 uint rx_discards_no_buffer; 585 uint tx_discards_wrong_sa; 586 uint rx_discards_undecryptable; 587 uint rx_message_in_msg_fragments; 588 uint rx_message_in_bad_msg_fragments; 589 }; 590 591 struct ieee80211_softmac_stats { 592 uint rx_ass_ok; 593 uint rx_ass_err; 594 uint rx_probe_rq; 595 uint tx_probe_rs; 596 uint tx_beacons; 597 uint rx_auth_rq; 598 uint rx_auth_rs_ok; 599 uint rx_auth_rs_err; 600 uint tx_auth_rq; 601 uint no_auth_rs; 602 uint no_ass_rs; 603 uint tx_ass_rq; 604 uint rx_ass_rq; 605 uint tx_probe_rq; 606 uint reassoc; 607 uint swtxstop; 608 uint swtxawake; 609 }; 610 611 #define SEC_KEY_1 (1<<0) 612 #define SEC_KEY_2 (1<<1) 613 #define SEC_KEY_3 (1<<2) 614 #define SEC_KEY_4 (1<<3) 615 #define SEC_ACTIVE_KEY (1<<4) 616 #define SEC_AUTH_MODE (1<<5) 617 #define SEC_UNICAST_GROUP (1<<6) 618 #define SEC_LEVEL (1<<7) 619 #define SEC_ENABLED (1<<8) 620 621 #define SEC_LEVEL_0 0 /* None */ 622 #define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */ 623 #define SEC_LEVEL_2 2 /* Level 1 + TKIP */ 624 #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */ 625 #define SEC_LEVEL_3 4 /* Level 2 + CCMP */ 626 627 #define WEP_KEYS 4 628 #define WEP_KEY_LEN 13 629 630 #define BIP_MAX_KEYID 5 631 #define BIP_AAD_SIZE 20 632 633 struct ieee80211_security { 634 u16 active_key:2, 635 enabled:1, 636 auth_mode:2, 637 auth_algo:4, 638 unicast_uses_group:1; 639 u8 key_sizes[WEP_KEYS]; 640 u8 keys[WEP_KEYS][WEP_KEY_LEN]; 641 u8 level; 642 u16 flags; 643 } __attribute__ ((packed)); 644 645 /* 646 647 802.11 data frame from AP 648 649 ,-------------------------------------------------------------------. 650 Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 | 651 |------|------|---------|---------|---------|------|---------|------| 652 Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs | 653 | | tion | (BSSID) | | | ence | data | | 654 `-------------------------------------------------------------------' 655 656 Total: 28-2340 bytes 657 658 */ 659 660 struct ieee80211_header_data { 661 u16 frame_ctl; 662 u16 duration_id; 663 u8 addr1[6]; 664 u8 addr2[6]; 665 u8 addr3[6]; 666 u16 seq_ctrl; 667 }; 668 669 #define BEACON_PROBE_SSID_ID_POSITION 12 670 671 /* Management Frame Information Element Types */ 672 #define MFIE_TYPE_SSID 0 673 #define MFIE_TYPE_RATES 1 674 #define MFIE_TYPE_FH_SET 2 675 #define MFIE_TYPE_DS_SET 3 676 #define MFIE_TYPE_CF_SET 4 677 #define MFIE_TYPE_TIM 5 678 #define MFIE_TYPE_IBSS_SET 6 679 #define MFIE_TYPE_CHALLENGE 16 680 #define MFIE_TYPE_ERP 42 681 #define MFIE_TYPE_RSN 48 682 #define MFIE_TYPE_RATES_EX 50 683 #define MFIE_TYPE_GENERIC 221 684 685 struct ieee80211_info_element_hdr { 686 u8 id; 687 u8 len; 688 } __attribute__ ((packed)); 689 690 struct ieee80211_info_element { 691 u8 id; 692 u8 len; 693 u8 data[0]; 694 } __attribute__ ((packed)); 695 696 /* 697 * These are the data types that can make up management packets 698 * 699 u16 auth_algorithm; 700 u16 auth_sequence; 701 u16 beacon_interval; 702 u16 capability; 703 u8 current_ap[ETH_ALEN]; 704 u16 listen_interval; 705 struct { 706 u16 association_id:14, reserved:2; 707 } __attribute__ ((packed)); 708 u32 time_stamp[2]; 709 u16 reason; 710 u16 status; 711 */ 712 713 #define IEEE80211_DEFAULT_TX_ESSID "Penguin" 714 #define IEEE80211_DEFAULT_BASIC_RATE 10 715 716 717 struct ieee80211_authentication { 718 struct ieee80211_header_data header; 719 u16 algorithm; 720 u16 transaction; 721 u16 status; 722 /* struct ieee80211_info_element_hdr info_element; */ 723 } __attribute__ ((packed)); 724 725 726 struct ieee80211_probe_response { 727 struct ieee80211_header_data header; 728 u32 time_stamp[2]; 729 u16 beacon_interval; 730 u16 capability; 731 struct ieee80211_info_element info_element; 732 } __attribute__ ((packed)); 733 734 struct ieee80211_probe_request { 735 struct ieee80211_header_data header; 736 /*struct ieee80211_info_element info_element;*/ 737 } __attribute__ ((packed)); 738 739 struct ieee80211_assoc_request_frame { 740 struct ieee80211_hdr_3addr header; 741 u16 capability; 742 u16 listen_interval; 743 /* u8 current_ap[ETH_ALEN]; */ 744 struct ieee80211_info_element_hdr info_element; 745 } __attribute__ ((packed)); 746 747 struct ieee80211_assoc_response_frame { 748 struct ieee80211_hdr_3addr header; 749 u16 capability; 750 u16 status; 751 u16 aid; 752 } __attribute__ ((packed)); 753 754 struct ieee80211_txb { 755 u8 nr_frags; 756 u8 encrypted; 757 u16 reserved; 758 u16 frag_size; 759 u16 payload_size; 760 struct sk_buff *fragments[0]; 761 }; 762 763 764 /* SWEEP TABLE ENTRIES NUMBER*/ 765 #define MAX_SWEEP_TAB_ENTRIES 42 766 #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7 767 /* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs 768 * only use 8, and then use extended rates for the remaining supported 769 * rates. Other APs, however, stick all of their supported rates on the 770 * main rates information element... */ 771 #define MAX_RATES_LENGTH ((u8)12) 772 #define MAX_RATES_EX_LENGTH ((u8)16) 773 #define MAX_NETWORK_COUNT 128 774 #define MAX_CHANNEL_NUMBER 161 775 #define IEEE80211_SOFTMAC_SCAN_TIME 400 776 /* HZ / 2) */ 777 #define IEEE80211_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2) 778 779 #define CRC_LENGTH 4U 780 781 #define MAX_WPA_IE_LEN (256) 782 #define MAX_WPS_IE_LEN (512) 783 #define MAX_P2P_IE_LEN (256) 784 #define MAX_WFD_IE_LEN (128) 785 786 #define NETWORK_EMPTY_ESSID (1<<0) 787 #define NETWORK_HAS_OFDM (1<<1) 788 #define NETWORK_HAS_CCK (1<<2) 789 790 #define IEEE80211_DTIM_MBCAST 4 791 #define IEEE80211_DTIM_UCAST 2 792 #define IEEE80211_DTIM_VALID 1 793 #define IEEE80211_DTIM_INVALID 0 794 795 #define IEEE80211_PS_DISABLED 0 796 #define IEEE80211_PS_UNICAST IEEE80211_DTIM_UCAST 797 #define IEEE80211_PS_MBCAST IEEE80211_DTIM_MBCAST 798 #define IW_ESSID_MAX_SIZE 32 799 /* 800 join_res: 801 -1: authentication fail 802 -2: association fail 803 > 0: TID 804 */ 805 806 enum ieee80211_state { 807 808 /* the card is not linked at all */ 809 IEEE80211_NOLINK = 0, 810 811 /* IEEE80211_ASSOCIATING* are for BSS client mode 812 * the driver shall not perform RX filtering unless 813 * the state is LINKED. 814 * The driver shall just check for the state LINKED and 815 * defaults to NOLINK for ALL the other states (including 816 * LINKED_SCANNING) 817 */ 818 819 /* the association procedure will start (wq scheduling)*/ 820 IEEE80211_ASSOCIATING, 821 IEEE80211_ASSOCIATING_RETRY, 822 823 /* the association procedure is sending AUTH request*/ 824 IEEE80211_ASSOCIATING_AUTHENTICATING, 825 826 /* the association procedure has successfully authentcated 827 * and is sending association request 828 */ 829 IEEE80211_ASSOCIATING_AUTHENTICATED, 830 831 /* the link is ok. the card associated to a BSS or linked 832 * to a ibss cell or acting as an AP and creating the bss 833 */ 834 IEEE80211_LINKED, 835 836 /* same as LINKED, but the driver shall apply RX filter 837 * rules as we are in NO_LINK mode. As the card is still 838 * logically linked, but it is doing a syncro site survey 839 * then it will be back to LINKED state. 840 */ 841 IEEE80211_LINKED_SCANNING, 842 843 }; 844 845 #define DEFAULT_MAX_SCAN_AGE (15 * HZ) 846 #define DEFAULT_FTS 2346 847 #define MAC_FMT "%pM" 848 #define MAC_ARG(x) (x) 849 #define IP_FMT "%pI4" 850 #define IP_ARG(x) (x) 851 852 static inline int is_multicast_mac_addr(const u8 *addr) 853 { 854 return ((addr[0] != 0xff) && (0x01 & addr[0])); 855 } 856 857 static inline int is_broadcast_mac_addr(const u8 *addr) 858 { 859 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \ 860 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); 861 } 862 863 static inline int is_zero_mac_addr(const u8 *addr) 864 { 865 return ((addr[0] == 0x00) && (addr[1] == 0x00) && (addr[2] == 0x00) && \ 866 (addr[3] == 0x00) && (addr[4] == 0x00) && (addr[5] == 0x00)); 867 } 868 869 #define CFG_IEEE80211_RESERVE_FCS (1<<0) 870 #define CFG_IEEE80211_COMPUTE_FCS (1<<1) 871 872 #define MAXTID 16 873 874 #define IEEE_A (1<<0) 875 #define IEEE_B (1<<1) 876 #define IEEE_G (1<<2) 877 #define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G) 878 879 /* Action category code */ 880 enum rtw_ieee80211_category { 881 RTW_WLAN_CATEGORY_SPECTRUM_MGMT = 0, 882 RTW_WLAN_CATEGORY_QOS = 1, 883 RTW_WLAN_CATEGORY_DLS = 2, 884 RTW_WLAN_CATEGORY_BACK = 3, 885 RTW_WLAN_CATEGORY_PUBLIC = 4, /* IEEE 802.11 public action frames */ 886 RTW_WLAN_CATEGORY_RADIO_MEASUREMENT = 5, 887 RTW_WLAN_CATEGORY_FT = 6, 888 RTW_WLAN_CATEGORY_HT = 7, 889 RTW_WLAN_CATEGORY_SA_QUERY = 8, 890 RTW_WLAN_CATEGORY_UNPROTECTED_WNM = 11, /* add for CONFIG_IEEE80211W, none 11w also can use */ 891 RTW_WLAN_CATEGORY_TDLS = 12, 892 RTW_WLAN_CATEGORY_SELF_PROTECTED = 15, /* add for CONFIG_IEEE80211W, none 11w also can use */ 893 RTW_WLAN_CATEGORY_WMM = 17, 894 RTW_WLAN_CATEGORY_VHT = 21, 895 RTW_WLAN_CATEGORY_P2P = 0x7f,/* P2P action frames */ 896 }; 897 898 /* SPECTRUM_MGMT action code */ 899 enum rtw_ieee80211_spectrum_mgmt_actioncode { 900 RTW_WLAN_ACTION_SPCT_MSR_REQ = 0, 901 RTW_WLAN_ACTION_SPCT_MSR_RPRT = 1, 902 RTW_WLAN_ACTION_SPCT_TPC_REQ = 2, 903 RTW_WLAN_ACTION_SPCT_TPC_RPRT = 3, 904 RTW_WLAN_ACTION_SPCT_CHL_SWITCH = 4, 905 RTW_WLAN_ACTION_SPCT_EXT_CHL_SWITCH = 5, 906 }; 907 908 enum _PUBLIC_ACTION { 909 ACT_PUBLIC_BSSCOEXIST = 0, /* 20/40 BSS Coexistence */ 910 ACT_PUBLIC_DSE_ENABLE = 1, 911 ACT_PUBLIC_DSE_DEENABLE = 2, 912 ACT_PUBLIC_DSE_REG_LOCATION = 3, 913 ACT_PUBLIC_EXT_CHL_SWITCH = 4, 914 ACT_PUBLIC_DSE_MSR_REQ = 5, 915 ACT_PUBLIC_DSE_MSR_RPRT = 6, 916 ACT_PUBLIC_MP = 7, /* Measurement Pilot */ 917 ACT_PUBLIC_DSE_PWR_CONSTRAINT = 8, 918 ACT_PUBLIC_VENDOR = 9, /* for WIFI_DIRECT */ 919 ACT_PUBLIC_GAS_INITIAL_REQ = 10, 920 ACT_PUBLIC_GAS_INITIAL_RSP = 11, 921 ACT_PUBLIC_GAS_COMEBACK_REQ = 12, 922 ACT_PUBLIC_GAS_COMEBACK_RSP = 13, 923 ACT_PUBLIC_TDLS_DISCOVERY_RSP = 14, 924 ACT_PUBLIC_LOCATION_TRACK = 15, 925 ACT_PUBLIC_MAX 926 }; 927 928 /* BACK action code */ 929 enum rtw_ieee80211_back_actioncode { 930 RTW_WLAN_ACTION_ADDBA_REQ = 0, 931 RTW_WLAN_ACTION_ADDBA_RESP = 1, 932 RTW_WLAN_ACTION_DELBA = 2, 933 }; 934 935 /* HT features action code */ 936 enum rtw_ieee80211_ht_actioncode { 937 RTW_WLAN_ACTION_HT_NOTI_CHNL_WIDTH = 0, 938 RTW_WLAN_ACTION_HT_SM_PS = 1, 939 RTW_WLAN_ACTION_HT_PSMP = 2, 940 RTW_WLAN_ACTION_HT_SET_PCO_PHASE = 3, 941 RTW_WLAN_ACTION_HT_CSI = 4, 942 RTW_WLAN_ACTION_HT_NON_COMPRESS_BEAMFORMING = 5, 943 RTW_WLAN_ACTION_HT_COMPRESS_BEAMFORMING = 6, 944 RTW_WLAN_ACTION_HT_ASEL_FEEDBACK = 7, 945 }; 946 947 /* BACK (block-ack) parties */ 948 enum rtw_ieee80211_back_parties { 949 RTW_WLAN_BACK_RECIPIENT = 0, 950 RTW_WLAN_BACK_INITIATOR = 1, 951 RTW_WLAN_BACK_TIMER = 2, 952 }; 953 954 /* VHT features action code */ 955 enum rtw_ieee80211_vht_actioncode { 956 RTW_WLAN_ACTION_VHT_COMPRESSED_BEAMFORMING = 0, 957 RTW_WLAN_ACTION_VHT_GROUPID_MANAGEMENT = 1, 958 RTW_WLAN_ACTION_VHT_OPMODE_NOTIFICATION = 2, 959 }; 960 961 962 #define OUI_MICROSOFT 0x0050f2 /* Microsoft (also used in Wi-Fi specs) 963 * 00:50:F2 */ 964 #define WME_OUI_TYPE 2 965 #define WME_OUI_SUBTYPE_INFORMATION_ELEMENT 0 966 #define WME_OUI_SUBTYPE_PARAMETER_ELEMENT 1 967 #define WME_OUI_SUBTYPE_TSPEC_ELEMENT 2 968 #define WME_VERSION 1 969 970 #define WME_ACTION_CODE_SETUP_REQUEST 0 971 #define WME_ACTION_CODE_SETUP_RESPONSE 1 972 #define WME_ACTION_CODE_TEARDOWN 2 973 974 #define WME_SETUP_RESPONSE_STATUS_ADMISSION_ACCEPTED 0 975 #define WME_SETUP_RESPONSE_STATUS_INVALID_PARAMETERS 1 976 #define WME_SETUP_RESPONSE_STATUS_REFUSED 3 977 978 #define WME_TSPEC_DIRECTION_UPLINK 0 979 #define WME_TSPEC_DIRECTION_DOWNLINK 1 980 #define WME_TSPEC_DIRECTION_BI_DIRECTIONAL 3 981 982 983 #define OUI_BROADCOM 0x00904c /* Broadcom (Epigram) */ 984 985 #define VENDOR_HT_CAPAB_OUI_TYPE 0x33 /* 00-90-4c:0x33 */ 986 987 /** 988 * enum rtw_ieee80211_channel_flags - channel flags 989 * 990 * Channel flags set by the regulatory control code. 991 * 992 * @RTW_IEEE80211_CHAN_DISABLED: This channel is disabled. 993 * @RTW_IEEE80211_CHAN_PASSIVE_SCAN: Only passive scanning is permitted 994 * on this channel. 995 * @RTW_IEEE80211_CHAN_NO_IBSS: IBSS is not allowed on this channel. 996 * @RTW_IEEE80211_CHAN_RADAR: Radar detection is required on this channel. 997 * @RTW_IEEE80211_CHAN_NO_HT40PLUS: extension channel above this channel 998 * is not permitted. 999 * @RTW_IEEE80211_CHAN_NO_HT40MINUS: extension channel below this channel 1000 * is not permitted. 1001 */ 1002 enum rtw_ieee80211_channel_flags { 1003 RTW_IEEE80211_CHAN_DISABLED = 1<<0, 1004 RTW_IEEE80211_CHAN_PASSIVE_SCAN = 1<<1, 1005 RTW_IEEE80211_CHAN_NO_IBSS = 1<<2, 1006 RTW_IEEE80211_CHAN_RADAR = 1<<3, 1007 RTW_IEEE80211_CHAN_NO_HT40PLUS = 1<<4, 1008 RTW_IEEE80211_CHAN_NO_HT40MINUS = 1<<5, 1009 }; 1010 1011 #define RTW_IEEE80211_CHAN_NO_HT40 \ 1012 (RTW_IEEE80211_CHAN_NO_HT40PLUS | RTW_IEEE80211_CHAN_NO_HT40MINUS) 1013 1014 /* Represent channel details, subset of ieee80211_channel */ 1015 struct rtw_ieee80211_channel { 1016 /* enum nl80211_band band; */ 1017 /* u16 center_freq; */ 1018 u16 hw_value; 1019 u32 flags; 1020 /* int max_antenna_gain; */ 1021 /* int max_power; */ 1022 /* int max_reg_power; */ 1023 /* bool beacon_found; */ 1024 /* u32 orig_flags; */ 1025 /* int orig_mag; */ 1026 /* int orig_mpwr; */ 1027 }; 1028 1029 #define CHAN_FMT \ 1030 /*"band:%d, "*/ \ 1031 /*"center_freq:%u, "*/ \ 1032 "hw_value:%u, " \ 1033 "flags:0x%08x" \ 1034 /*"max_antenna_gain:%d\n"*/ \ 1035 /*"max_power:%d\n"*/ \ 1036 /*"max_reg_power:%d\n"*/ \ 1037 /*"beacon_found:%u\n"*/ \ 1038 /*"orig_flags:0x%08x\n"*/ \ 1039 /*"orig_mag:%d\n"*/ \ 1040 /*"orig_mpwr:%d\n"*/ 1041 1042 #define CHAN_ARG(channel) \ 1043 /*(channel)->band*/ \ 1044 /*, (channel)->center_freq*/ \ 1045 (channel)->hw_value \ 1046 , (channel)->flags \ 1047 /*, (channel)->max_antenna_gain*/ \ 1048 /*, (channel)->max_power*/ \ 1049 /*, (channel)->max_reg_power*/ \ 1050 /*, (channel)->beacon_found*/ \ 1051 /*, (channel)->orig_flags*/ \ 1052 /*, (channel)->orig_mag*/ \ 1053 /*, (channel)->orig_mpwr*/ \ 1054 1055 /* Parsed Information Elements */ 1056 struct rtw_ieee802_11_elems { 1057 u8 *ssid; 1058 u8 ssid_len; 1059 u8 *supp_rates; 1060 u8 supp_rates_len; 1061 u8 *fh_params; 1062 u8 fh_params_len; 1063 u8 *ds_params; 1064 u8 ds_params_len; 1065 u8 *cf_params; 1066 u8 cf_params_len; 1067 u8 *tim; 1068 u8 tim_len; 1069 u8 *ibss_params; 1070 u8 ibss_params_len; 1071 u8 *challenge; 1072 u8 challenge_len; 1073 u8 *erp_info; 1074 u8 erp_info_len; 1075 u8 *ext_supp_rates; 1076 u8 ext_supp_rates_len; 1077 u8 *wpa_ie; 1078 u8 wpa_ie_len; 1079 u8 *rsn_ie; 1080 u8 rsn_ie_len; 1081 u8 *wme; 1082 u8 wme_len; 1083 u8 *wme_tspec; 1084 u8 wme_tspec_len; 1085 u8 *wps_ie; 1086 u8 wps_ie_len; 1087 u8 *power_cap; 1088 u8 power_cap_len; 1089 u8 *supp_channels; 1090 u8 supp_channels_len; 1091 u8 *mdie; 1092 u8 mdie_len; 1093 u8 *ftie; 1094 u8 ftie_len; 1095 u8 *timeout_int; 1096 u8 timeout_int_len; 1097 u8 *ht_capabilities; 1098 u8 ht_capabilities_len; 1099 u8 *ht_operation; 1100 u8 ht_operation_len; 1101 u8 *vendor_ht_cap; 1102 u8 vendor_ht_cap_len; 1103 u8 *vht_capabilities; 1104 u8 vht_capabilities_len; 1105 u8 *vht_operation; 1106 u8 vht_operation_len; 1107 u8 *vht_op_mode_notify; 1108 u8 vht_op_mode_notify_len; 1109 }; 1110 1111 typedef enum { ParseOK = 0, ParseUnknown = 1, ParseFailed = -1 } ParseRes; 1112 1113 ParseRes rtw_ieee802_11_parse_elems(u8 *start, uint len, 1114 struct rtw_ieee802_11_elems *elems, 1115 int show_errors); 1116 1117 u8 *rtw_set_fixed_ie(unsigned char *pbuf, unsigned int len, unsigned char *source, unsigned int *frlen); 1118 u8 *rtw_set_ie(u8 *pbuf, sint index, uint len, u8 *source, uint *frlen); 1119 1120 enum secondary_ch_offset { 1121 SCN = 0, /* no secondary channel */ 1122 SCA = 1, /* secondary channel above */ 1123 SCB = 3, /* secondary channel below */ 1124 }; 1125 1126 u8 *rtw_get_ie(u8*pbuf, sint index, sint *len, sint limit); 1127 u8 *rtw_get_ie_ex(u8 *in_ie, uint in_len, u8 eid, u8 *oui, u8 oui_len, u8 *ie, uint *ielen); 1128 int rtw_ies_remove_ie(u8 *ies, uint *ies_len, uint offset, u8 eid, u8 *oui, u8 oui_len); 1129 1130 void rtw_set_supported_rate(u8 *SupportedRates, uint mode); 1131 1132 unsigned char *rtw_get_wpa_ie(unsigned char *pie, int *wpa_ie_len, int limit); 1133 unsigned char *rtw_get_wpa2_ie(unsigned char *pie, int *rsn_ie_len, int limit); 1134 int rtw_get_wpa_cipher_suite(u8 *s); 1135 int rtw_get_wpa2_cipher_suite(u8 *s); 1136 int rtw_get_wapi_ie(u8 *in_ie, uint in_len, u8 *wapi_ie, u16 *wapi_len); 1137 int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x); 1138 int rtw_parse_wpa2_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x); 1139 1140 void rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, u16 *wpa_len); 1141 1142 u8 rtw_is_wps_ie(u8 *ie_ptr, uint *wps_ielen); 1143 u8 *rtw_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen); 1144 u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, u8 *buf_attr, u32 *len_attr); 1145 u8 *rtw_get_wps_attr_content(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, u8 *buf_content, uint *len_content); 1146 1147 /** 1148 * for_each_ie - iterate over continuous IEs 1149 * @ie: 1150 * @buf: 1151 * @buf_len: 1152 */ 1153 #define for_each_ie(ie, buf, buf_len) \ 1154 for (ie = (void*)buf; (((u8 *)ie) - ((u8 *)buf) + 1) < buf_len; ie = (void*)(((u8 *)ie) + *(((u8 *)ie)+1) + 2)) 1155 1156 uint rtw_get_rateset_len(u8 *rateset); 1157 1158 struct registry_priv; 1159 int rtw_generate_ie(struct registry_priv *pregistrypriv); 1160 1161 1162 int rtw_get_bit_value_from_ieee_value(u8 val); 1163 1164 bool rtw_is_cckrates_included(u8 *rate); 1165 1166 bool rtw_is_cckratesonly_included(u8 *rate); 1167 1168 int rtw_check_network_type(unsigned char *rate, int ratelen, int channel); 1169 1170 void rtw_get_bcn_info(struct wlan_network *pnetwork); 1171 1172 void rtw_macaddr_cfg(struct device *dev, u8 *mac_addr); 1173 1174 u16 rtw_mcs_rate(u8 rf_type, u8 bw_40MHz, u8 short_GI, unsigned char * MCS_rate); 1175 1176 int rtw_action_frame_parse(const u8 *frame, u32 frame_len, u8 *category, u8 *action); 1177 const char *action_public_str(u8 action); 1178 1179 #endif /* IEEE80211_H */ 1180