| 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_NONERP BIT(31) |
| 64 |
|
| 65 |
#define IEEE_CMD_SET_WPA_PARAM 1 |
| 66 |
#define IEEE_CMD_SET_WPA_IE 2 |
| 67 |
#define IEEE_CMD_SET_ENCRYPTION 3 |
| 68 |
#define IEEE_CMD_MLME 4 |
| 69 |
|
| 70 |
#define IEEE_PARAM_WPA_ENABLED 1 |
| 71 |
#define IEEE_PARAM_TKIP_COUNTERMEASURES 2 |
| 72 |
#define IEEE_PARAM_DROP_UNENCRYPTED 3 |
| 73 |
#define IEEE_PARAM_PRIVACY_INVOKED 4 |
| 74 |
#define IEEE_PARAM_AUTH_ALGS 5 |
| 75 |
#define IEEE_PARAM_IEEE_802_1X 6 |
| 76 |
#define IEEE_PARAM_WPAX_SELECT 7 |
| 77 |
|
| 78 |
#define IEEE_MLME_STA_DEAUTH 1 |
| 79 |
#define IEEE_MLME_STA_DISASSOC 2 |
| 80 |
|
| 81 |
#define IEEE_CRYPT_ERR_UNKNOWN_ALG 2 |
| 82 |
#define IEEE_CRYPT_ERR_UNKNOWN_ADDR 3 |
| 83 |
#define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED 4 |
| 84 |
#define IEEE_CRYPT_ERR_KEY_SET_FAILED 5 |
| 85 |
#define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED 6 |
| 86 |
#define IEEE_CRYPT_ERR_CARD_CONF_FAILED 7 |
| 87 |
|
| 88 |
|
| 89 |
#define IEEE_CRYPT_ALG_NAME_LEN 16 |
| 90 |
|
| 91 |
#define WPA_CIPHER_NONE BIT(0) |
| 92 |
#define WPA_CIPHER_WEP40 BIT(1) |
| 93 |
#define WPA_CIPHER_WEP104 BIT(2) |
| 94 |
#define WPA_CIPHER_TKIP BIT(3) |
| 95 |
#define WPA_CIPHER_CCMP BIT(4) |
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
#define WPA_SELECTOR_LEN 4 |
| 100 |
extern u8 RTW_WPA_OUI_TYPE[]; |
| 101 |
extern u16 RTW_WPA_VERSION; |
| 102 |
extern u8 WPA_AUTH_KEY_MGMT_NONE[]; |
| 103 |
extern u8 WPA_AUTH_KEY_MGMT_UNSPEC_802_1X[]; |
| 104 |
extern u8 WPA_AUTH_KEY_MGMT_PSK_OVER_802_1X[]; |
| 105 |
extern u8 WPA_CIPHER_SUITE_NONE[]; |
| 106 |
extern u8 WPA_CIPHER_SUITE_WEP40[]; |
| 107 |
extern u8 WPA_CIPHER_SUITE_TKIP[]; |
| 108 |
extern u8 WPA_CIPHER_SUITE_WRAP[]; |
| 109 |
extern u8 WPA_CIPHER_SUITE_CCMP[]; |
| 110 |
extern u8 WPA_CIPHER_SUITE_WEP104[]; |
| 111 |
|
| 112 |
|
| 113 |
#define RSN_HEADER_LEN 4 |
| 114 |
#define RSN_SELECTOR_LEN 4 |
| 115 |
|
| 116 |
extern u16 RSN_VERSION_BSD; |
| 117 |
extern u8 RSN_AUTH_KEY_MGMT_UNSPEC_802_1X[]; |
| 118 |
extern u8 RSN_AUTH_KEY_MGMT_PSK_OVER_802_1X[]; |
| 119 |
extern u8 RSN_CIPHER_SUITE_NONE[]; |
| 120 |
extern u8 RSN_CIPHER_SUITE_WEP40[]; |
| 121 |
extern u8 RSN_CIPHER_SUITE_TKIP[]; |
| 122 |
extern u8 RSN_CIPHER_SUITE_WRAP[]; |
| 123 |
extern u8 RSN_CIPHER_SUITE_CCMP[]; |
| 124 |
extern u8 RSN_CIPHER_SUITE_WEP104[]; |
| 125 |
|
| 126 |
|
| 127 |
enum { |
| 128 |
RATEID_IDX_BGN_40M_2SS = 0, |
| 129 |
RATEID_IDX_BGN_40M_1SS = 1, |
| 130 |
RATEID_IDX_BGN_20M_2SS_BN = 2, |
| 131 |
RATEID_IDX_BGN_20M_1SS_BN = 3, |
| 132 |
RATEID_IDX_GN_N2SS = 4, |
| 133 |
RATEID_IDX_GN_N1SS = 5, |
| 134 |
RATEID_IDX_BG = 6, |
| 135 |
RATEID_IDX_G = 7, |
| 136 |
RATEID_IDX_B = 8, |
| 137 |
}; |
| 138 |
|
| 139 |
enum network_type { |
| 140 |
WIRELESS_INVALID = 0, |
| 141 |
/* Sub-Element */ |
| 142 |
WIRELESS_11B = BIT(0), /* tx: cck only , rx: cck only, hw: cck */ |
| 143 |
WIRELESS_11G = BIT(1), /* tx: ofdm only, rx: ofdm & cck, hw: cck & ofdm */ |
| 144 |
WIRELESS_11_24N = BIT(3), /* tx: MCS only, rx: MCS & cck, hw: MCS & cck */ |
| 145 |
WIRELESS_AUTO = BIT(5), |
| 146 |
|
| 147 |
/* Combination */ |
| 148 |
/* Type for current wireless mode */ |
| 149 |
WIRELESS_11BG = (WIRELESS_11B|WIRELESS_11G), /* tx: cck & ofdm, rx: cck & ofdm & MCS, hw: cck & ofdm */ |
| 150 |
WIRELESS_11G_24N = (WIRELESS_11G|WIRELESS_11_24N), /* tx: ofdm & MCS, rx: ofdm & cck & MCS, hw: cck & ofdm */ |
| 151 |
WIRELESS_11B_24N = (WIRELESS_11B|WIRELESS_11_24N), /* tx: ofdm & cck & MCS, rx: ofdm & cck & MCS, hw: ofdm & cck */ |
| 152 |
WIRELESS_11BG_24N = (WIRELESS_11B|WIRELESS_11G|WIRELESS_11_24N), /* tx: ofdm & cck & MCS, rx: ofdm & cck & MCS, hw: ofdm & cck */ |
| 153 |
}; |
| 154 |
|
| 155 |
#define SUPPORTED_24G_NETTYPE_MSK (WIRELESS_11B | WIRELESS_11G | WIRELESS_11_24N) |
| 156 |
|
| 157 |
#define is_legacy_only(net_type) ((net_type) == ((net_type) & (WIRELESS_11BG))) |
| 158 |
|
| 159 |
#define is_supported_24g(net_type) ((net_type) & SUPPORTED_24G_NETTYPE_MSK ? true : false) |
| 160 |
|
| 161 |
#define is_supported_tx_cck(net_type) (((net_type) & (WIRELESS_11B)) ? true : false) |
| 162 |
#define is_supported_ht(net_type) (((net_type) & (WIRELESS_11_24N)) ? true : false) |
| 163 |
|
| 164 |
struct ieee_param { |
| 165 |
u32 cmd; |
| 166 |
u8 sta_addr[ETH_ALEN]; |
| 167 |
union { |
| 168 |
struct { |
| 169 |
u8 name; |
| 170 |
u32 value; |
| 171 |
} wpa_param; |
| 172 |
struct { |
| 173 |
u32 len; |
| 174 |
u8 reserved[32]; |
| 175 |
u8 data[]; |
| 176 |
} wpa_ie; |
| 177 |
struct{ |
| 178 |
int command; |
| 179 |
int reason_code; |
| 180 |
} mlme; |
| 181 |
struct { |
| 182 |
u8 alg[IEEE_CRYPT_ALG_NAME_LEN]; |
| 183 |
u8 set_tx; |
| 184 |
u32 err; |
| 185 |
u8 idx; |
| 186 |
u8 seq[8]; /* sequence counter (set: RX, get: TX) */ |
| 187 |
u16 key_len; |
| 188 |
u8 key[]; |
| 189 |
} crypt; |
| 190 |
struct { |
| 191 |
u16 aid; |
| 192 |
u16 capability; |
| 193 |
int flags; |
| 194 |
u8 tx_supp_rates[16]; |
| 195 |
struct ieee80211_ht_cap ht_cap; |
| 196 |
} add_sta; |
| 197 |
struct { |
| 198 |
u8 reserved[2];/* for set max_num_sta */ |
| 199 |
u8 buf[]; |
| 200 |
} bcn_ie; |
| 201 |
} u; |
| 202 |
}; |
| 203 |
|
| 204 |
struct ieee_param_ex { |
| 205 |
u32 cmd; |
| 206 |
u8 sta_addr[ETH_ALEN]; |
| 207 |
u8 data[]; |
| 208 |
}; |
| 209 |
|
| 210 |
struct sta_data { |
| 211 |
u16 aid; |
| 212 |
u16 capability; |
| 213 |
int flags; |
| 214 |
u32 sta_set; |
| 215 |
u8 tx_supp_rates[16]; |
| 216 |
u32 tx_supp_rates_len; |
| 217 |
struct ieee80211_ht_cap ht_cap; |
| 218 |
u64 rx_pkts; |
| 219 |
u64 rx_bytes; |
| 220 |
u64 rx_drops; |
| 221 |
u64 tx_pkts; |
| 222 |
u64 tx_bytes; |
| 223 |
u64 tx_drops; |
| 224 |
}; |
| 225 |
|
| 226 |
/* this is stolen from ipw2200 driver */ |
| 227 |
#define IEEE_IBSS_MAC_HASH_SIZE 31 |
| 228 |
|
| 229 |
struct eapol { |
| 230 |
u8 snap[6]; |
| 231 |
u16 ethertype; |
| 232 |
u8 version; |
| 233 |
u8 type; |
| 234 |
u16 length; |
| 235 |
} __attribute__ ((packed)); |
| 236 |
|
| 237 |
#define IEEE80211_FCS_LEN 4 |
| 238 |
|
| 239 |
#define MIN_FRAG_THRESHOLD 256U |
| 240 |
#define MAX_FRAG_THRESHOLD 2346U |
| 241 |
|
| 242 |
/* sequence control field */ |
| 243 |
#define RTW_IEEE80211_SCTL_FRAG 0x000F |
| 244 |
#define RTW_IEEE80211_SCTL_SEQ 0xFFF0 |
| 245 |
|
| 246 |
|
| 247 |
#define RTW_ERP_INFO_NON_ERP_PRESENT BIT(0) |
| 248 |
#define RTW_ERP_INFO_USE_PROTECTION BIT(1) |
| 249 |
#define RTW_ERP_INFO_BARKER_PREAMBLE_MODE BIT(2) |
| 250 |
|
| 251 |
/* QoS, QOS */ |
| 252 |
#define NORMAL_ACK 0 |
| 253 |
#define NO_ACK 1 |
| 254 |
#define NON_EXPLICIT_ACK 2 |
| 255 |
#define BLOCK_ACK 3 |
| 256 |
|
| 257 |
#ifndef ETH_P_PAE |
| 258 |
#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */ |
| 259 |
#endif /* ETH_P_PAE */ |
| 260 |
|
| 261 |
#define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */ |
| 262 |
|
| 263 |
#define ETH_P_ECONET 0x0018 |
| 264 |
|
| 265 |
#ifndef ETH_P_80211_RAW |
| 266 |
#define ETH_P_80211_RAW (ETH_P_ECONET + 1) |
| 267 |
#endif |
| 268 |
|
| 269 |
/* IEEE 802.11 defines */ |
| 270 |
|
| 271 |
#define P80211_OUI_LEN 3 |
| 272 |
|
| 273 |
struct ieee80211_snap_hdr { |
| 274 |
u8 dsap; /* always 0xAA */ |
| 275 |
u8 ssap; /* always 0xAA */ |
| 276 |
u8 ctrl; /* always 0x03 */ |
| 277 |
u8 oui[P80211_OUI_LEN]; /* organizational universal id */ |
| 278 |
} __attribute__ ((packed)); |
| 279 |
|
| 280 |
#define SNAP_SIZE sizeof(struct ieee80211_snap_hdr) |
| 281 |
|
| 282 |
#define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE) |
| 283 |
#define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE) |
| 284 |
|
| 285 |
#define WLAN_QC_GET_TID(qc) ((qc) & 0x0f) |
| 286 |
|
| 287 |
#define WLAN_GET_SEQ_FRAG(seq) ((seq) & RTW_IEEE80211_SCTL_FRAG) |
| 288 |
#define WLAN_GET_SEQ_SEQ(seq) ((seq) & RTW_IEEE80211_SCTL_SEQ) |
| 289 |
|
| 290 |
/* Reason codes */ |
| 291 |
#define WLAN_REASON_ACTIVE_ROAM 65533 |
| 292 |
#define WLAN_REASON_JOIN_WRONG_CHANNEL 65534 |
| 293 |
#define WLAN_REASON_EXPIRATION_CHK 65535 |
| 294 |
|
| 295 |
#define IEEE80211_MGMT_HDR_LEN 24 |
| 296 |
#define IEEE80211_DATA_HDR3_LEN 24 |
| 297 |
#define IEEE80211_DATA_HDR4_LEN 30 |
| 298 |
|
| 299 |
|
| 300 |
#define IEEE80211_STATMASK_SIGNAL (1<<0) |
| 301 |
#define IEEE80211_STATMASK_RSSI (1<<1) |
| 302 |
#define IEEE80211_STATMASK_NOISE (1<<2) |
| 303 |
#define IEEE80211_STATMASK_RATE (1<<3) |
| 304 |
#define IEEE80211_STATMASK_WEMASK 0x7 |
| 305 |
|
| 306 |
|
| 307 |
#define IEEE80211_CCK_MODULATION (1<<0) |
| 308 |
#define IEEE80211_OFDM_MODULATION (1<<1) |
| 309 |
|
| 310 |
#define IEEE80211_24GHZ_BAND (1<<0) |
| 311 |
#define IEEE80211_52GHZ_BAND (1<<1) |
| 312 |
|
| 313 |
#define IEEE80211_CCK_RATE_LEN 4 |
| 314 |
#define IEEE80211_NUM_OFDM_RATESLEN 8 |
| 315 |
|
| 316 |
|
| 317 |
#define IEEE80211_CCK_RATE_1MB 0x02 |
| 318 |
#define IEEE80211_CCK_RATE_2MB 0x04 |
| 319 |
#define IEEE80211_CCK_RATE_5MB 0x0B |
| 320 |
#define IEEE80211_CCK_RATE_11MB 0x16 |
| 321 |
#define IEEE80211_OFDM_RATE_LEN 8 |
| 322 |
#define IEEE80211_OFDM_RATE_6MB 0x0C |
| 323 |
#define IEEE80211_OFDM_RATE_9MB 0x12 |
| 324 |
#define IEEE80211_OFDM_RATE_12MB 0x18 |
| 325 |
#define IEEE80211_OFDM_RATE_18MB 0x24 |
| 326 |
#define IEEE80211_OFDM_RATE_24MB 0x30 |
| 327 |
#define IEEE80211_OFDM_RATE_36MB 0x48 |
| 328 |
#define IEEE80211_OFDM_RATE_48MB 0x60 |
| 329 |
#define IEEE80211_OFDM_RATE_54MB 0x6C |
| 330 |
#define IEEE80211_BASIC_RATE_MASK 0x80 |
| 331 |
|
| 332 |
#define IEEE80211_CCK_RATE_1MB_MASK (1<<0) |
| 333 |
#define IEEE80211_CCK_RATE_2MB_MASK (1<<1) |
| 334 |
#define IEEE80211_CCK_RATE_5MB_MASK (1<<2) |
| 335 |
#define IEEE80211_CCK_RATE_11MB_MASK (1<<3) |
| 336 |
#define IEEE80211_OFDM_RATE_6MB_MASK (1<<4) |
| 337 |
#define IEEE80211_OFDM_RATE_9MB_MASK (1<<5) |
| 338 |
#define IEEE80211_OFDM_RATE_12MB_MASK (1<<6) |
| 339 |
#define IEEE80211_OFDM_RATE_18MB_MASK (1<<7) |
| 340 |
#define IEEE80211_OFDM_RATE_24MB_MASK (1<<8) |
| 341 |
#define IEEE80211_OFDM_RATE_36MB_MASK (1<<9) |
| 342 |
#define IEEE80211_OFDM_RATE_48MB_MASK (1<<10) |
| 343 |
#define IEEE80211_OFDM_RATE_54MB_MASK (1<<11) |
| 344 |
|
| 345 |
#define IEEE80211_CCK_RATES_MASK 0x0000000F |
| 346 |
#define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \ |
| 347 |
IEEE80211_CCK_RATE_2MB_MASK) |
| 348 |
#define IEEE80211_CCK_DEFAULT_RATES_MASK \ |
| 349 |
(IEEE80211_CCK_BASIC_RATES_MASK | \ |
| 350 |
IEEE80211_CCK_RATE_5MB_MASK | \ |
| 351 |
IEEE80211_CCK_RATE_11MB_MASK) |
| 352 |
|
| 353 |
#define IEEE80211_OFDM_RATES_MASK 0x00000FF0 |
| 354 |
#define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \ |
| 355 |
IEEE80211_OFDM_RATE_12MB_MASK | \ |
| 356 |
IEEE80211_OFDM_RATE_24MB_MASK) |
| 357 |
#define IEEE80211_OFDM_DEFAULT_RATES_MASK (IEEE80211_OFDM_BASIC_RATES_MASK | \ |
| 358 |
IEEE80211_OFDM_RATE_9MB_MASK | \ |
| 359 |
IEEE80211_OFDM_RATE_18MB_MASK | \ |
| 360 |
IEEE80211_OFDM_RATE_36MB_MASK | \ |
| 361 |
IEEE80211_OFDM_RATE_48MB_MASK | \ |
| 362 |
IEEE80211_OFDM_RATE_54MB_MASK) |
| 363 |
#define IEEE80211_DEFAULT_RATES_MASK \ |
| 364 |
(IEEE80211_OFDM_DEFAULT_RATES_MASK | \ |
| 365 |
IEEE80211_CCK_DEFAULT_RATES_MASK) |
| 366 |
|
| 367 |
#define IEEE80211_NUM_OFDM_RATES 8 |
| 368 |
#define IEEE80211_NUM_CCK_RATES 4 |
| 369 |
#define IEEE80211_OFDM_SHIFT_MASK_A 4 |
| 370 |
|
| 371 |
|
| 372 |
enum { |
| 373 |
MGN_1M = 0x02, |
| 374 |
MGN_2M = 0x04, |
| 375 |
MGN_5_5M = 0x0B, |
| 376 |
MGN_6M = 0x0C, |
| 377 |
MGN_9M = 0x12, |
| 378 |
MGN_11M = 0x16, |
| 379 |
MGN_12M = 0x18, |
| 380 |
MGN_18M = 0x24, |
| 381 |
MGN_24M = 0x30, |
| 382 |
MGN_36M = 0x48, |
| 383 |
MGN_48M = 0x60, |
| 384 |
MGN_54M = 0x6C, |
| 385 |
MGN_MCS32 = 0x7F, |
| 386 |
MGN_MCS0, |
| 387 |
MGN_MCS1, |
| 388 |
MGN_MCS2, |
| 389 |
MGN_MCS3, |
| 390 |
MGN_MCS4, |
| 391 |
MGN_MCS5, |
| 392 |
MGN_MCS6, |
| 393 |
MGN_MCS7, |
| 394 |
MGN_UNKNOWN |
| 395 |
}; |
| 396 |
|
| 397 |
#define IS_HT_RATE(_rate) (_rate >= MGN_MCS0 && _rate <= MGN_MCS31) |
| 398 |
#define IS_CCK_RATE(_rate) (MGN_1M == _rate || _rate == MGN_2M || _rate == MGN_5_5M || _rate == MGN_11M) |
| 399 |
#define IS_OFDM_RATE(_rate) (MGN_6M <= _rate && _rate <= MGN_54M && _rate != MGN_11M) |
| 400 |
|
| 401 |
|
| 402 |
/* NOTE: This data is for statistical purposes; not all hardware provides this |
| 403 |
* information for frames received. Not setting these will not cause |
| 404 |
* any adverse affects. */ |
| 405 |
|
| 406 |
/* IEEE 802.11 requires that STA supports concurrent reception of at least |
| 407 |
* three fragmented frames. This define can be increased to support more |
| 408 |
* concurrent frames, but it should be noted that each entry can consume about |
| 409 |
* 2 kB of RAM and increasing cache size will slow down frame reassembly. */ |
| 410 |
#define IEEE80211_FRAG_CACHE_LEN 4 |
| 411 |
|
| 412 |
#define SEC_KEY_1 (1<<0) |
| 413 |
#define SEC_KEY_2 (1<<1) |
| 414 |
#define SEC_KEY_3 (1<<2) |
| 415 |
#define SEC_KEY_4 (1<<3) |
| 416 |
#define SEC_ACTIVE_KEY (1<<4) |
| 417 |
#define SEC_AUTH_MODE (1<<5) |
| 418 |
#define SEC_UNICAST_GROUP (1<<6) |
| 419 |
#define SEC_LEVEL (1<<7) |
| 420 |
#define SEC_ENABLED (1<<8) |
| 421 |
|
| 422 |
#define SEC_LEVEL_0 0 /* None */ |
| 423 |
#define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */ |
| 424 |
#define SEC_LEVEL_2 2 /* Level 1 + TKIP */ |
| 425 |
#define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */ |
| 426 |
#define SEC_LEVEL_3 4 /* Level 2 + CCMP */ |
| 427 |
|
| 428 |
#define WEP_KEYS 4 |
| 429 |
#define WEP_KEY_LEN 13 |
| 430 |
|
| 431 |
#define BIP_MAX_KEYID 5 |
| 432 |
#define BIP_AAD_SIZE 20 |
| 433 |
|
| 434 |
/* |
| 435 |
|
| 436 |
802.11 data frame from AP |
| 437 |
|
| 438 |
,-------------------------------------------------------------------. |
| 439 |
Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 | |
| 440 |
|------|------|---------|---------|---------|------|---------|------| |
| 441 |
Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs | |
| 442 |
| | tion | (BSSID) | | | ence | data | | |
| 443 |
`-------------------------------------------------------------------' |
| 444 |
|
| 445 |
Total: 28-2340 bytes |
| 446 |
|
| 447 |
*/ |
| 448 |
|
| 449 |
#define BEACON_PROBE_SSID_ID_POSITION 12 |
| 450 |
|
| 451 |
/* Management Frame Information Element Types */ |
| 452 |
#define MFIE_TYPE_SSID 0 |
| 453 |
#define MFIE_TYPE_RATES 1 |
| 454 |
#define MFIE_TYPE_FH_SET 2 |
| 455 |
#define MFIE_TYPE_DS_SET 3 |
| 456 |
#define MFIE_TYPE_CF_SET 4 |
| 457 |
#define MFIE_TYPE_TIM 5 |
| 458 |
#define MFIE_TYPE_IBSS_SET 6 |
| 459 |
#define MFIE_TYPE_CHALLENGE 16 |
| 460 |
#define MFIE_TYPE_ERP 42 |
| 461 |
#define MFIE_TYPE_RSN 48 |
| 462 |
#define MFIE_TYPE_RATES_EX 50 |
| 463 |
#define MFIE_TYPE_GENERIC 221 |
| 464 |
|
| 465 |
/* SWEEP TABLE ENTRIES NUMBER*/ |
| 466 |
#define MAX_SWEEP_TAB_ENTRIES 42 |
| 467 |
#define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7 |
| 468 |
/* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs |
| 469 |
* only use 8, and then use extended rates for the remaining supported |
| 470 |
* rates. Other APs, however, stick all of their supported rates on the |
| 471 |
* main rates information element... */ |
| 472 |
#define MAX_RATES_LENGTH ((u8)12) |
| 473 |
#define MAX_RATES_EX_LENGTH ((u8)16) |
| 474 |
#define MAX_NETWORK_COUNT 128 |
| 475 |
#define MAX_CHANNEL_NUMBER 161 |
| 476 |
#define IEEE80211_SOFTMAC_SCAN_TIME 400 |
| 477 |
/* HZ / 2) */ |
| 478 |
#define IEEE80211_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2) |
| 479 |
|
| 480 |
#define CRC_LENGTH 4U |
| 481 |
|
| 482 |
#define MAX_WPA_IE_LEN (256) |
| 483 |
#define MAX_WPS_IE_LEN (512) |
| 484 |
#define MAX_P2P_IE_LEN (256) |
| 485 |
#define MAX_WFD_IE_LEN (128) |
| 486 |
|
| 487 |
#define NETWORK_EMPTY_ESSID (1<<0) |
| 488 |
#define NETWORK_HAS_OFDM (1<<1) |
| 489 |
#define NETWORK_HAS_CCK (1<<2) |
| 490 |
|
| 491 |
#define IEEE80211_DTIM_MBCAST 4 |
| 492 |
#define IEEE80211_DTIM_UCAST 2 |
| 493 |
#define IEEE80211_DTIM_VALID 1 |
| 494 |
#define IEEE80211_DTIM_INVALID 0 |
| 495 |
|
| 496 |
#define IEEE80211_PS_DISABLED 0 |
| 497 |
#define IEEE80211_PS_UNICAST IEEE80211_DTIM_UCAST |
| 498 |
#define IEEE80211_PS_MBCAST IEEE80211_DTIM_MBCAST |
| 499 |
#define IW_ESSID_MAX_SIZE 32 |
| 500 |
/* |
| 501 |
join_res: |
| 502 |
-1: authentication fail |
| 503 |
-2: association fail |
| 504 |
> 0: TID |
| 505 |
*/ |
| 506 |
|
| 507 |
#define DEFAULT_MAX_SCAN_AGE (15 * HZ) |
| 508 |
#define DEFAULT_FTS 2346 |
| 509 |
#define IP_ARG(x) (x) |
| 510 |
|
| 511 |
static inline int is_multicast_mac_addr(const u8 *addr) |
| 512 |
{ |
| 513 |
return ((addr[0] != 0xff) && (0x01 & addr[0])); |
| 514 |
} |
| 515 |
|
| 516 |
static inline int is_broadcast_mac_addr(const u8 *addr) |
| 517 |
{ |
| 518 |
return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \ |
| 519 |
(addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); |
| 520 |
} |
| 521 |
|
| 522 |
static inline int is_zero_mac_addr(const u8 *addr) |
| 523 |
{ |
| 524 |
return ((addr[0] == 0x00) && (addr[1] == 0x00) && (addr[2] == 0x00) && \ |
| 525 |
(addr[3] == 0x00) && (addr[4] == 0x00) && (addr[5] == 0x00)); |
| 526 |
} |
| 527 |
|
| 528 |
#define CFG_IEEE80211_RESERVE_FCS (1<<0) |
| 529 |
#define CFG_IEEE80211_COMPUTE_FCS (1<<1) |
| 530 |
|
| 531 |
#define MAXTID 16 |
| 532 |
|
| 533 |
#define IEEE_A (1<<0) |
| 534 |
#define IEEE_B (1<<1) |
| 535 |
#define IEEE_G (1<<2) |
| 536 |
#define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G) |
| 537 |
|
| 538 |
/* Action category code */ |
| 539 |
enum { |
| 540 |
RTW_WLAN_CATEGORY_SPECTRUM_MGMT = 0, |
| 541 |
RTW_WLAN_CATEGORY_QOS = 1, |
| 542 |
RTW_WLAN_CATEGORY_DLS = 2, |
| 543 |
RTW_WLAN_CATEGORY_BACK = 3, |
| 544 |
RTW_WLAN_CATEGORY_PUBLIC = 4, /* IEEE 802.11 public action frames */ |
| 545 |
RTW_WLAN_CATEGORY_RADIO_MEASUREMENT = 5, |
| 546 |
RTW_WLAN_CATEGORY_FT = 6, |
| 547 |
RTW_WLAN_CATEGORY_HT = 7, |
| 548 |
RTW_WLAN_CATEGORY_SA_QUERY = 8, |
| 549 |
RTW_WLAN_CATEGORY_UNPROTECTED_WNM = 11, /* add for CONFIG_IEEE80211W, none 11w also can use */ |
| 550 |
RTW_WLAN_CATEGORY_TDLS = 12, |
| 551 |
RTW_WLAN_CATEGORY_SELF_PROTECTED = 15, /* add for CONFIG_IEEE80211W, none 11w also can use */ |
| 552 |
RTW_WLAN_CATEGORY_WMM = 17, |
| 553 |
RTW_WLAN_CATEGORY_P2P = 0x7f,/* P2P action frames */ |
| 554 |
}; |
| 555 |
|
| 556 |
enum { |
| 557 |
ACT_PUBLIC_BSSCOEXIST = 0, /* 20/40 BSS Coexistence */ |
| 558 |
ACT_PUBLIC_DSE_ENABLE = 1, |
| 559 |
ACT_PUBLIC_DSE_DEENABLE = 2, |
| 560 |
ACT_PUBLIC_DSE_REG_LOCATION = 3, |
| 561 |
ACT_PUBLIC_EXT_CHL_SWITCH = 4, |
| 562 |
ACT_PUBLIC_DSE_MSR_REQ = 5, |
| 563 |
ACT_PUBLIC_DSE_MSR_RPRT = 6, |
| 564 |
ACT_PUBLIC_MP = 7, /* Measurement Pilot */ |
| 565 |
ACT_PUBLIC_DSE_PWR_CONSTRAINT = 8, |
| 566 |
ACT_PUBLIC_VENDOR = 9, /* for WIFI_DIRECT */ |
| 567 |
ACT_PUBLIC_GAS_INITIAL_REQ = 10, |
| 568 |
ACT_PUBLIC_GAS_INITIAL_RSP = 11, |
| 569 |
ACT_PUBLIC_GAS_COMEBACK_REQ = 12, |
| 570 |
ACT_PUBLIC_GAS_COMEBACK_RSP = 13, |
| 571 |
ACT_PUBLIC_TDLS_DISCOVERY_RSP = 14, |
| 572 |
ACT_PUBLIC_LOCATION_TRACK = 15, |
| 573 |
ACT_PUBLIC_MAX |
| 574 |
}; |
| 575 |
|
| 576 |
#define OUI_MICROSOFT 0x0050f2 /* Microsoft (also used in Wi-Fi specs) |
| 577 |
* 00:50:F2 */ |
| 578 |
#define WME_OUI_TYPE 2 |
| 579 |
#define WME_OUI_SUBTYPE_INFORMATION_ELEMENT 0 |
| 580 |
#define WME_OUI_SUBTYPE_PARAMETER_ELEMENT 1 |
| 581 |
#define WME_OUI_SUBTYPE_TSPEC_ELEMENT 2 |
| 582 |
#define WME_VERSION 1 |
| 583 |
|
| 584 |
#define WME_ACTION_CODE_SETUP_REQUEST 0 |
| 585 |
#define WME_ACTION_CODE_SETUP_RESPONSE 1 |
| 586 |
#define WME_ACTION_CODE_TEARDOWN 2 |
| 587 |
|
| 588 |
#define WME_SETUP_RESPONSE_STATUS_ADMISSION_ACCEPTED 0 |
| 589 |
#define WME_SETUP_RESPONSE_STATUS_INVALID_PARAMETERS 1 |
| 590 |
#define WME_SETUP_RESPONSE_STATUS_REFUSED 3 |
| 591 |
|
| 592 |
#define WME_TSPEC_DIRECTION_UPLINK 0 |
| 593 |
#define WME_TSPEC_DIRECTION_DOWNLINK 1 |
| 594 |
#define WME_TSPEC_DIRECTION_BI_DIRECTIONAL 3 |
| 595 |
|
| 596 |
|
| 597 |
#define OUI_BROADCOM 0x00904c /* Broadcom (Epigram) */ |
| 598 |
|
| 599 |
#define VENDOR_HT_CAPAB_OUI_TYPE 0x33 /* 00-90-4c:0x33 */ |
| 600 |
|
| 601 |
/** |
| 602 |
* enum rtw_ieee80211_channel_flags - channel flags |
| 603 |
* |
| 604 |
* Channel flags set by the regulatory control code. |
| 605 |
* |
| 606 |
* @RTW_IEEE80211_CHAN_DISABLED: This channel is disabled. |
| 607 |
* @RTW_IEEE80211_CHAN_PASSIVE_SCAN: Only passive scanning is permitted |
| 608 |
* on this channel. |
| 609 |
* @RTW_IEEE80211_CHAN_NO_IBSS: IBSS is not allowed on this channel. |
| 610 |
* @RTW_IEEE80211_CHAN_RADAR: Radar detection is required on this channel. |
| 611 |
* @RTW_IEEE80211_CHAN_NO_HT40PLUS: extension channel above this channel |
| 612 |
* is not permitted. |
| 613 |
* @RTW_IEEE80211_CHAN_NO_HT40MINUS: extension channel below this channel |
| 614 |
* is not permitted. |
| 615 |
*/ |
| 616 |
enum rtw_ieee80211_channel_flags { |
| 617 |
RTW_IEEE80211_CHAN_DISABLED = 1<<0, |
| 618 |
RTW_IEEE80211_CHAN_PASSIVE_SCAN = 1<<1, |
| 619 |
RTW_IEEE80211_CHAN_NO_IBSS = 1<<2, |
| 620 |
RTW_IEEE80211_CHAN_RADAR = 1<<3, |
| 621 |
RTW_IEEE80211_CHAN_NO_HT40PLUS = 1<<4, |
| 622 |
RTW_IEEE80211_CHAN_NO_HT40MINUS = 1<<5, |
| 623 |
}; |
| 624 |
|
| 625 |
#define RTW_IEEE80211_CHAN_NO_HT40 \ |
| 626 |
(RTW_IEEE80211_CHAN_NO_HT40PLUS | \ |
| 627 |
RTW_IEEE80211_CHAN_NO_HT40MINUS) |
| 628 |
|
| 629 |
/* Represent channel details, subset of ieee80211_channel */ |
| 630 |
struct rtw_ieee80211_channel { |
| 631 |
/* enum nl80211_band band; */ |
| 632 |
/* u16 center_freq; */ |
| 633 |
u16 hw_value; |
| 634 |
u32 flags; |
| 635 |
/* int max_antenna_gain; */ |
| 636 |
/* int max_power; */ |
| 637 |
/* int max_reg_power; */ |
| 638 |
/* bool beacon_found; */ |
| 639 |
/* u32 orig_flags; */ |
| 640 |
/* int orig_mag; */ |
| 641 |
/* int orig_mpwr; */ |
| 642 |
}; |
| 643 |
|
| 644 |
#define CHAN_FMT \ |
| 645 |
/*"band:%d, "*/ \ |
| 646 |
/*"center_freq:%u, "*/ \ |
| 647 |
"hw_value:%u, " \ |
| 648 |
"flags:0x%08x" \ |
| 649 |
/*"max_antenna_gain:%d\n"*/ \ |
| 650 |
/*"max_power:%d\n"*/ \ |
| 651 |
/*"max_reg_power:%d\n"*/ \ |
| 652 |
/*"beacon_found:%u\n"*/ \ |
| 653 |
/*"orig_flags:0x%08x\n"*/ \ |
| 654 |
/*"orig_mag:%d\n"*/ \ |
| 655 |
/*"orig_mpwr:%d\n"*/ |
| 656 |
|
| 657 |
#define CHAN_ARG(channel) \ |
| 658 |
/*(channel)->band*/ \ |
| 659 |
/*, (channel)->center_freq*/ \ |
| 660 |
(channel)->hw_value \ |
| 661 |
, (channel)->flags \ |
| 662 |
/*, (channel)->max_antenna_gain*/ \ |
| 663 |
/*, (channel)->max_power*/ \ |
| 664 |
/*, (channel)->max_reg_power*/ \ |
| 665 |
/*, (channel)->beacon_found*/ \ |
| 666 |
/*, (channel)->orig_flags*/ \ |
| 667 |
/*, (channel)->orig_mag*/ \ |
| 668 |
/*, (channel)->orig_mpwr*/ \ |
| 669 |
|
| 670 |
/* Parsed Information Elements */ |
| 671 |
struct rtw_ieee802_11_elems { |
| 672 |
u8 *ssid; |
| 673 |
u8 ssid_len; |
| 674 |
u8 *supp_rates; |
| 675 |
u8 supp_rates_len; |
| 676 |
u8 *fh_params; |
| 677 |
u8 fh_params_len; |
| 678 |
u8 *ds_params; |
| 679 |
u8 ds_params_len; |
| 680 |
u8 *cf_params; |
| 681 |
u8 cf_params_len; |
| 682 |
u8 *tim; |
| 683 |
u8 tim_len; |
| 684 |
u8 *ibss_params; |
| 685 |
u8 ibss_params_len; |
| 686 |
u8 *challenge; |
| 687 |
u8 challenge_len; |
| 688 |
u8 *erp_info; |
| 689 |
u8 erp_info_len; |
| 690 |
u8 *ext_supp_rates; |
| 691 |
u8 ext_supp_rates_len; |
| 692 |
u8 *wpa_ie; |
| 693 |
u8 wpa_ie_len; |
| 694 |
u8 *rsn_ie; |
| 695 |
u8 rsn_ie_len; |
| 696 |
u8 *wme; |
| 697 |
u8 wme_len; |
| 698 |
u8 *wme_tspec; |
| 699 |
u8 wme_tspec_len; |
| 700 |
u8 *wps_ie; |
| 701 |
u8 wps_ie_len; |
| 702 |
u8 *power_cap; |
| 703 |
u8 power_cap_len; |
| 704 |
u8 *supp_channels; |
| 705 |
u8 supp_channels_len; |
| 706 |
u8 *mdie; |
| 707 |
u8 mdie_len; |
| 708 |
u8 *ftie; |
| 709 |
u8 ftie_len; |
| 710 |
u8 *timeout_int; |
| 711 |
u8 timeout_int_len; |
| 712 |
u8 *ht_capabilities; |
| 713 |
u8 ht_capabilities_len; |
| 714 |
u8 *ht_operation; |
| 715 |
u8 ht_operation_len; |
| 716 |
u8 *vendor_ht_cap; |
| 717 |
u8 vendor_ht_cap_len; |
| 718 |
u8 *vht_capabilities; |
| 719 |
u8 vht_capabilities_len; |
| 720 |
u8 *vht_operation; |
| 721 |
u8 vht_operation_len; |
| 722 |
u8 *vht_op_mode_notify; |
| 723 |
u8 vht_op_mode_notify_len; |
| 724 |
}; |
| 725 |
|
| 726 |
enum ParseRes { ParseOK = 0, ParseUnknown = 1, ParseFailed = -1 }; |
| 727 |
|
| 728 |
enum ParseRes rtw_ieee802_11_parse_elems(u8 *start, uint len, |
| 729 |
struct rtw_ieee802_11_elems *elems, |
| 730 |
int show_errors); |
| 731 |
|
| 732 |
u8 *rtw_set_fixed_ie(unsigned char *pbuf, unsigned int len, unsigned char *source, unsigned int *frlen); |
| 733 |
u8 *rtw_set_ie(u8 *pbuf, signed int index, uint len, u8 *source, uint *frlen); |
| 734 |
|
| 735 |
u8 *rtw_get_ie(u8 *pbuf, signed int index, signed int *len, signed int limit); |
| 736 |
u8 *rtw_get_ie_ex(u8 *in_ie, uint in_len, u8 eid, u8 *oui, u8 oui_len, u8 *ie, uint *ielen); |
| 737 |
int rtw_ies_remove_ie(u8 *ies, uint *ies_len, uint offset, u8 eid, u8 *oui, u8 oui_len); |
| 738 |
|
| 739 |
void rtw_set_supported_rate(u8 *SupportedRates, uint mode); |
| 740 |
|
| 741 |
unsigned char *rtw_get_wpa_ie(unsigned char *pie, int *wpa_ie_len, int limit); |
| 742 |
unsigned char *rtw_get_wpa2_ie(unsigned char *pie, int *rsn_ie_len, int limit); |
| 743 |
int rtw_get_wpa_cipher_suite(u8 *s); |
| 744 |
int rtw_get_wpa2_cipher_suite(u8 *s); |
| 745 |
int rtw_get_wapi_ie(u8 *in_ie, uint in_len, u8 *wapi_ie, u16 *wapi_len); |
| 746 |
int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x); |
| 747 |
int rtw_parse_wpa2_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x); |
| 748 |
|
| 749 |
void rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, u16 *wpa_len); |
| 750 |
|
| 751 |
u8 *rtw_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen); |
| 752 |
u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, u8 *buf_attr, u32 *len_attr); |
| 753 |
u8 *rtw_get_wps_attr_content(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, u8 *buf_content, uint *len_content); |
| 754 |
|
| 755 |
/** |
| 756 |
* for_each_ie - iterate over continuous IEs |
| 757 |
* @ie: |
| 758 |
* @buf: |
| 759 |
* @buf_len: |
| 760 |
*/ |
| 761 |
#define for_each_ie(ie, buf, buf_len) \ |
| 762 |
for (ie = (void *)buf; (((u8 *)ie) - ((u8 *)buf) + 1) < buf_len; \ |
| 763 |
ie = (void *)(((u8 *)ie) + *(((u8 *)ie) + 1) + 2)) |
| 764 |
|
| 765 |
uint rtw_get_rateset_len(u8 *rateset); |
| 766 |
|
| 767 |
struct registry_priv; |
| 768 |
int rtw_generate_ie(struct registry_priv *pregistrypriv); |
| 769 |
|
| 770 |
|
| 771 |
int rtw_get_bit_value_from_ieee_value(u8 val); |
| 772 |
|
| 773 |
bool rtw_is_cckrates_included(u8 *rate); |
| 774 |
|
| 775 |
bool rtw_is_cckratesonly_included(u8 *rate); |
| 776 |
|
| 777 |
int rtw_check_network_type(unsigned char *rate, int ratelen, int channel); |
| 778 |
|
| 779 |
void rtw_get_bcn_info(struct wlan_network *pnetwork); |
| 780 |
|
| 781 |
void rtw_macaddr_cfg(struct device *dev, u8 *mac_addr); |
| 782 |
|
| 783 |
u16 rtw_mcs_rate(u8 bw_40MHz, u8 short_GI, unsigned char *MCS_rate); |
| 784 |
|
| 785 |
int rtw_action_frame_parse(const u8 *frame, u32 frame_len, u8 *category, u8 *action); |
| 786 |
const char *action_public_str(u8 action); |
| 787 |
|
| 788 |
#endif /* IEEE80211_H */ |