1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * IEEE 802.11 defines 4 * 5 * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen 6 * <jkmaline@cc.hut.fi> 7 * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi> 8 * Copyright (c) 2005, Devicescape Software, Inc. 9 * Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net> 10 * Copyright (c) 2013 - 2014 Intel Mobile Communications GmbH 11 * Copyright (c) 2016 - 2017 Intel Deutschland GmbH 12 * Copyright (c) 2018 - 2026 Intel Corporation 13 */ 14 15 #ifndef LINUX_IEEE80211_H 16 #define LINUX_IEEE80211_H 17 18 #include <linux/types.h> 19 #include <linux/if_ether.h> 20 #include <linux/etherdevice.h> 21 #include <linux/bitfield.h> 22 #include <asm/byteorder.h> 23 #include <linux/unaligned.h> 24 25 /* 26 * DS bit usage 27 * 28 * TA = transmitter address 29 * RA = receiver address 30 * DA = destination address 31 * SA = source address 32 * 33 * ToDS FromDS A1(RA) A2(TA) A3 A4 Use 34 * ----------------------------------------------------------------- 35 * 0 0 DA SA BSSID - IBSS/DLS 36 * 0 1 DA BSSID SA - AP -> STA 37 * 1 0 BSSID SA DA - AP <- STA 38 * 1 1 RA TA DA SA unspecified (WDS) 39 */ 40 41 #define FCS_LEN 4 42 43 #define IEEE80211_FCTL_VERS 0x0003 44 #define IEEE80211_FCTL_FTYPE 0x000c 45 #define IEEE80211_FCTL_STYPE 0x00f0 46 #define IEEE80211_FCTL_TYPE (IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE) 47 #define IEEE80211_FCTL_TODS 0x0100 48 #define IEEE80211_FCTL_FROMDS 0x0200 49 #define IEEE80211_FCTL_MOREFRAGS 0x0400 50 #define IEEE80211_FCTL_RETRY 0x0800 51 #define IEEE80211_FCTL_PM 0x1000 52 #define IEEE80211_FCTL_MOREDATA 0x2000 53 #define IEEE80211_FCTL_PROTECTED 0x4000 54 #define IEEE80211_FCTL_ORDER 0x8000 55 #define IEEE80211_FCTL_CTL_EXT 0x0f00 56 57 #define IEEE80211_SCTL_FRAG 0x000F 58 #define IEEE80211_SCTL_SEQ 0xFFF0 59 60 #define IEEE80211_FTYPE_MGMT 0x0000 61 #define IEEE80211_FTYPE_CTL 0x0004 62 #define IEEE80211_FTYPE_DATA 0x0008 63 #define IEEE80211_FTYPE_EXT 0x000c 64 65 /* management */ 66 #define IEEE80211_STYPE_ASSOC_REQ 0x0000 67 #define IEEE80211_STYPE_ASSOC_RESP 0x0010 68 #define IEEE80211_STYPE_REASSOC_REQ 0x0020 69 #define IEEE80211_STYPE_REASSOC_RESP 0x0030 70 #define IEEE80211_STYPE_PROBE_REQ 0x0040 71 #define IEEE80211_STYPE_PROBE_RESP 0x0050 72 #define IEEE80211_STYPE_BEACON 0x0080 73 #define IEEE80211_STYPE_ATIM 0x0090 74 #define IEEE80211_STYPE_DISASSOC 0x00A0 75 #define IEEE80211_STYPE_AUTH 0x00B0 76 #define IEEE80211_STYPE_DEAUTH 0x00C0 77 #define IEEE80211_STYPE_ACTION 0x00D0 78 79 /* control */ 80 #define IEEE80211_STYPE_TRIGGER 0x0020 81 #define IEEE80211_STYPE_CTL_EXT 0x0060 82 #define IEEE80211_STYPE_BACK_REQ 0x0080 83 #define IEEE80211_STYPE_BACK 0x0090 84 #define IEEE80211_STYPE_PSPOLL 0x00A0 85 #define IEEE80211_STYPE_RTS 0x00B0 86 #define IEEE80211_STYPE_CTS 0x00C0 87 #define IEEE80211_STYPE_ACK 0x00D0 88 #define IEEE80211_STYPE_CFEND 0x00E0 89 #define IEEE80211_STYPE_CFENDACK 0x00F0 90 91 /* data */ 92 #define IEEE80211_STYPE_DATA 0x0000 93 #define IEEE80211_STYPE_DATA_CFACK 0x0010 94 #define IEEE80211_STYPE_DATA_CFPOLL 0x0020 95 #define IEEE80211_STYPE_DATA_CFACKPOLL 0x0030 96 #define IEEE80211_STYPE_NULLFUNC 0x0040 97 #define IEEE80211_STYPE_CFACK 0x0050 98 #define IEEE80211_STYPE_CFPOLL 0x0060 99 #define IEEE80211_STYPE_CFACKPOLL 0x0070 100 #define IEEE80211_STYPE_QOS_DATA 0x0080 101 #define IEEE80211_STYPE_QOS_DATA_CFACK 0x0090 102 #define IEEE80211_STYPE_QOS_DATA_CFPOLL 0x00A0 103 #define IEEE80211_STYPE_QOS_DATA_CFACKPOLL 0x00B0 104 #define IEEE80211_STYPE_QOS_NULLFUNC 0x00C0 105 #define IEEE80211_STYPE_QOS_CFACK 0x00D0 106 #define IEEE80211_STYPE_QOS_CFPOLL 0x00E0 107 #define IEEE80211_STYPE_QOS_CFACKPOLL 0x00F0 108 109 /* extension, added by 802.11ad */ 110 #define IEEE80211_STYPE_DMG_BEACON 0x0000 111 #define IEEE80211_STYPE_S1G_BEACON 0x0010 112 113 #define IEEE80211_NDP_FTYPE_CTS 0 114 #define IEEE80211_NDP_FTYPE_CF_END 0 115 #define IEEE80211_NDP_FTYPE_PS_POLL 1 116 #define IEEE80211_NDP_FTYPE_ACK 2 117 #define IEEE80211_NDP_FTYPE_PS_POLL_ACK 3 118 #define IEEE80211_NDP_FTYPE_BA 4 119 #define IEEE80211_NDP_FTYPE_BF_REPORT_POLL 5 120 #define IEEE80211_NDP_FTYPE_PAGING 6 121 #define IEEE80211_NDP_FTYPE_PREQ 7 122 123 #define SM64(f, v) ((((u64)v) << f##_S) & f) 124 125 /* NDP CMAC frame fields */ 126 #define IEEE80211_NDP_FTYPE 0x0000000000000007 127 #define IEEE80211_NDP_FTYPE_S 0x0000000000000000 128 129 /* 1M Probe Request 11ah 9.9.3.1.1 */ 130 #define IEEE80211_NDP_1M_PREQ_ANO 0x0000000000000008 131 #define IEEE80211_NDP_1M_PREQ_ANO_S 3 132 #define IEEE80211_NDP_1M_PREQ_CSSID 0x00000000000FFFF0 133 #define IEEE80211_NDP_1M_PREQ_CSSID_S 4 134 #define IEEE80211_NDP_1M_PREQ_RTYPE 0x0000000000100000 135 #define IEEE80211_NDP_1M_PREQ_RTYPE_S 20 136 #define IEEE80211_NDP_1M_PREQ_RSV 0x0000000001E00000 137 #define IEEE80211_NDP_1M_PREQ_RSV 0x0000000001E00000 138 /* 2M Probe Request 11ah 9.9.3.1.2 */ 139 #define IEEE80211_NDP_2M_PREQ_ANO 0x0000000000000008 140 #define IEEE80211_NDP_2M_PREQ_ANO_S 3 141 #define IEEE80211_NDP_2M_PREQ_CSSID 0x0000000FFFFFFFF0 142 #define IEEE80211_NDP_2M_PREQ_CSSID_S 4 143 #define IEEE80211_NDP_2M_PREQ_RTYPE 0x0000001000000000 144 #define IEEE80211_NDP_2M_PREQ_RTYPE_S 36 145 146 #define IEEE80211_ANO_NETTYPE_WILD 15 147 148 /* control extension - for IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTL_EXT */ 149 #define IEEE80211_CTL_EXT_POLL 0x2000 150 #define IEEE80211_CTL_EXT_SPR 0x3000 151 #define IEEE80211_CTL_EXT_GRANT 0x4000 152 #define IEEE80211_CTL_EXT_DMG_CTS 0x5000 153 #define IEEE80211_CTL_EXT_DMG_DTS 0x6000 154 #define IEEE80211_CTL_EXT_SSW 0x8000 155 #define IEEE80211_CTL_EXT_SSW_FBACK 0x9000 156 #define IEEE80211_CTL_EXT_SSW_ACK 0xa000 157 158 159 #define IEEE80211_SN_MASK ((IEEE80211_SCTL_SEQ) >> 4) 160 #define IEEE80211_MAX_SN IEEE80211_SN_MASK 161 #define IEEE80211_SN_MODULO (IEEE80211_MAX_SN + 1) 162 163 164 /* PV1 Layout IEEE 802.11-2020 9.8.3.1 */ 165 #define IEEE80211_PV1_FCTL_VERS 0x0003 166 #define IEEE80211_PV1_FCTL_FTYPE 0x001c 167 #define IEEE80211_PV1_FCTL_STYPE 0x00e0 168 #define IEEE80211_PV1_FCTL_FROMDS 0x0100 169 #define IEEE80211_PV1_FCTL_MOREFRAGS 0x0200 170 #define IEEE80211_PV1_FCTL_PM 0x0400 171 #define IEEE80211_PV1_FCTL_MOREDATA 0x0800 172 #define IEEE80211_PV1_FCTL_PROTECTED 0x1000 173 #define IEEE80211_PV1_FCTL_END_SP 0x2000 174 #define IEEE80211_PV1_FCTL_RELAYED 0x4000 175 #define IEEE80211_PV1_FCTL_ACK_POLICY 0x8000 176 #define IEEE80211_PV1_FCTL_CTL_EXT 0x0f00 177 178 static inline bool ieee80211_sn_less(u16 sn1, u16 sn2) 179 { 180 return ((sn1 - sn2) & IEEE80211_SN_MASK) > (IEEE80211_SN_MODULO >> 1); 181 } 182 183 static inline bool ieee80211_sn_less_eq(u16 sn1, u16 sn2) 184 { 185 return ((sn2 - sn1) & IEEE80211_SN_MASK) <= (IEEE80211_SN_MODULO >> 1); 186 } 187 188 static inline u16 ieee80211_sn_add(u16 sn1, u16 sn2) 189 { 190 return (sn1 + sn2) & IEEE80211_SN_MASK; 191 } 192 193 static inline u16 ieee80211_sn_inc(u16 sn) 194 { 195 return ieee80211_sn_add(sn, 1); 196 } 197 198 static inline u16 ieee80211_sn_sub(u16 sn1, u16 sn2) 199 { 200 return (sn1 - sn2) & IEEE80211_SN_MASK; 201 } 202 203 #define IEEE80211_SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4) 204 #define IEEE80211_SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ) 205 206 /* miscellaneous IEEE 802.11 constants */ 207 #define IEEE80211_MAX_FRAG_THRESHOLD 2352 208 #define IEEE80211_MAX_RTS_THRESHOLD 2353 209 #define IEEE80211_MAX_AID 2007 210 #define IEEE80211_MAX_AID_S1G 8191 211 #define IEEE80211_MAX_TIM_LEN 251 212 #define IEEE80211_MAX_MESH_PEERINGS 63 213 214 /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section 215 6.2.1.1.2. 216 217 802.11e clarifies the figure in section 7.1.2. The frame body is 218 up to 2304 octets long (maximum MSDU size) plus any crypt overhead. */ 219 #define IEEE80211_MAX_DATA_LEN 2304 220 /* 802.11ad extends maximum MSDU size for DMG (freq > 40Ghz) networks 221 * to 7920 bytes, see 8.2.3 General frame format 222 */ 223 #define IEEE80211_MAX_DATA_LEN_DMG 7920 224 /* 30 byte 4 addr hdr, 2 byte QoS, 2304 byte MSDU, 12 byte crypt, 4 byte FCS */ 225 #define IEEE80211_MAX_FRAME_LEN 2352 226 227 #define IEEE80211_MAX_SSID_LEN 32 228 229 #define IEEE80211_FIRST_TSPEC_TSID 8 230 #define IEEE80211_NUM_TIDS 16 231 232 /* number of user priorities 802.11 uses */ 233 #define IEEE80211_NUM_UPS 8 234 /* number of ACs */ 235 #define IEEE80211_NUM_ACS 4 236 237 #define IEEE80211_QOS_CTL_LEN 2 238 /* 1d tag mask */ 239 #define IEEE80211_QOS_CTL_TAG1D_MASK 0x0007 240 /* TID mask */ 241 #define IEEE80211_QOS_CTL_TID_MASK 0x000f 242 /* EOSP */ 243 #define IEEE80211_QOS_CTL_EOSP 0x0010 244 /* ACK policy */ 245 #define IEEE80211_QOS_CTL_ACK_POLICY_NORMAL 0x0000 246 #define IEEE80211_QOS_CTL_ACK_POLICY_NOACK 0x0020 247 #define IEEE80211_QOS_CTL_ACK_POLICY_NO_EXPL 0x0040 248 #define IEEE80211_QOS_CTL_ACK_POLICY_BLOCKACK 0x0060 249 #define IEEE80211_QOS_CTL_ACK_POLICY_MASK 0x0060 250 /* A-MSDU 802.11n */ 251 #define IEEE80211_QOS_CTL_A_MSDU_PRESENT 0x0080 252 /* Mesh Control 802.11s */ 253 #define IEEE80211_QOS_CTL_MESH_CONTROL_PRESENT 0x0100 254 255 /* Mesh Power Save Level */ 256 #define IEEE80211_QOS_CTL_MESH_PS_LEVEL 0x0200 257 /* Mesh Receiver Service Period Initiated */ 258 #define IEEE80211_QOS_CTL_RSPI 0x0400 259 260 /* U-APSD queue for WMM IEs sent by AP */ 261 #define IEEE80211_WMM_IE_AP_QOSINFO_UAPSD (1<<7) 262 #define IEEE80211_WMM_IE_AP_QOSINFO_PARAM_SET_CNT_MASK 0x0f 263 264 /* U-APSD queues for WMM IEs sent by STA */ 265 #define IEEE80211_WMM_IE_STA_QOSINFO_AC_VO (1<<0) 266 #define IEEE80211_WMM_IE_STA_QOSINFO_AC_VI (1<<1) 267 #define IEEE80211_WMM_IE_STA_QOSINFO_AC_BK (1<<2) 268 #define IEEE80211_WMM_IE_STA_QOSINFO_AC_BE (1<<3) 269 #define IEEE80211_WMM_IE_STA_QOSINFO_AC_MASK 0x0f 270 271 /* U-APSD max SP length for WMM IEs sent by STA */ 272 #define IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL 0x00 273 #define IEEE80211_WMM_IE_STA_QOSINFO_SP_2 0x01 274 #define IEEE80211_WMM_IE_STA_QOSINFO_SP_4 0x02 275 #define IEEE80211_WMM_IE_STA_QOSINFO_SP_6 0x03 276 #define IEEE80211_WMM_IE_STA_QOSINFO_SP_MASK 0x03 277 #define IEEE80211_WMM_IE_STA_QOSINFO_SP_SHIFT 5 278 279 /* trigger type within common_info of trigger frame */ 280 #define IEEE80211_TRIGGER_TYPE_MASK 0xf 281 #define IEEE80211_TRIGGER_TYPE_BASIC 0x0 282 #define IEEE80211_TRIGGER_TYPE_BFRP 0x1 283 #define IEEE80211_TRIGGER_TYPE_MU_BAR 0x2 284 #define IEEE80211_TRIGGER_TYPE_MU_RTS 0x3 285 #define IEEE80211_TRIGGER_TYPE_BSRP 0x4 286 #define IEEE80211_TRIGGER_TYPE_GCR_MU_BAR 0x5 287 #define IEEE80211_TRIGGER_TYPE_BQRP 0x6 288 #define IEEE80211_TRIGGER_TYPE_NFRP 0x7 289 290 /* UL-bandwidth within common_info of trigger frame */ 291 #define IEEE80211_TRIGGER_ULBW_MASK 0xc0000 292 #define IEEE80211_TRIGGER_ULBW_20MHZ 0x0 293 #define IEEE80211_TRIGGER_ULBW_40MHZ 0x1 294 #define IEEE80211_TRIGGER_ULBW_80MHZ 0x2 295 #define IEEE80211_TRIGGER_ULBW_160_80P80MHZ 0x3 296 297 struct ieee80211_hdr { 298 __le16 frame_control; 299 __le16 duration_id; 300 struct_group(addrs, 301 u8 addr1[ETH_ALEN]; 302 u8 addr2[ETH_ALEN]; 303 u8 addr3[ETH_ALEN]; 304 ); 305 __le16 seq_ctrl; 306 u8 addr4[ETH_ALEN]; 307 } __packed __aligned(2); 308 309 struct ieee80211_hdr_3addr { 310 __le16 frame_control; 311 __le16 duration_id; 312 u8 addr1[ETH_ALEN]; 313 u8 addr2[ETH_ALEN]; 314 u8 addr3[ETH_ALEN]; 315 __le16 seq_ctrl; 316 } __packed __aligned(2); 317 318 struct ieee80211_qos_hdr { 319 __le16 frame_control; 320 __le16 duration_id; 321 u8 addr1[ETH_ALEN]; 322 u8 addr2[ETH_ALEN]; 323 u8 addr3[ETH_ALEN]; 324 __le16 seq_ctrl; 325 __le16 qos_ctrl; 326 } __packed __aligned(2); 327 328 struct ieee80211_qos_hdr_4addr { 329 __le16 frame_control; 330 __le16 duration_id; 331 u8 addr1[ETH_ALEN]; 332 u8 addr2[ETH_ALEN]; 333 u8 addr3[ETH_ALEN]; 334 __le16 seq_ctrl; 335 u8 addr4[ETH_ALEN]; 336 __le16 qos_ctrl; 337 } __packed __aligned(2); 338 339 struct ieee80211_trigger { 340 __le16 frame_control; 341 __le16 duration; 342 u8 ra[ETH_ALEN]; 343 u8 ta[ETH_ALEN]; 344 __le64 common_info; 345 u8 variable[]; 346 } __packed __aligned(2); 347 348 /** 349 * ieee80211_has_tods - check if IEEE80211_FCTL_TODS is set 350 * @fc: frame control bytes in little-endian byteorder 351 * Return: whether or not the frame has to-DS set 352 */ 353 static inline bool ieee80211_has_tods(__le16 fc) 354 { 355 return (fc & cpu_to_le16(IEEE80211_FCTL_TODS)) != 0; 356 } 357 358 /** 359 * ieee80211_has_fromds - check if IEEE80211_FCTL_FROMDS is set 360 * @fc: frame control bytes in little-endian byteorder 361 * Return: whether or not the frame has from-DS set 362 */ 363 static inline bool ieee80211_has_fromds(__le16 fc) 364 { 365 return (fc & cpu_to_le16(IEEE80211_FCTL_FROMDS)) != 0; 366 } 367 368 /** 369 * ieee80211_has_a4 - check if IEEE80211_FCTL_TODS and IEEE80211_FCTL_FROMDS are set 370 * @fc: frame control bytes in little-endian byteorder 371 * Return: whether or not it's a 4-address frame (from-DS and to-DS set) 372 */ 373 static inline bool ieee80211_has_a4(__le16 fc) 374 { 375 __le16 tmp = cpu_to_le16(IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS); 376 return (fc & tmp) == tmp; 377 } 378 379 /** 380 * ieee80211_has_morefrags - check if IEEE80211_FCTL_MOREFRAGS is set 381 * @fc: frame control bytes in little-endian byteorder 382 * Return: whether or not the frame has more fragments (more frags bit set) 383 */ 384 static inline bool ieee80211_has_morefrags(__le16 fc) 385 { 386 return (fc & cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)) != 0; 387 } 388 389 /** 390 * ieee80211_has_retry - check if IEEE80211_FCTL_RETRY is set 391 * @fc: frame control bytes in little-endian byteorder 392 * Return: whether or not the retry flag is set 393 */ 394 static inline bool ieee80211_has_retry(__le16 fc) 395 { 396 return (fc & cpu_to_le16(IEEE80211_FCTL_RETRY)) != 0; 397 } 398 399 /** 400 * ieee80211_has_pm - check if IEEE80211_FCTL_PM is set 401 * @fc: frame control bytes in little-endian byteorder 402 * Return: whether or not the power management flag is set 403 */ 404 static inline bool ieee80211_has_pm(__le16 fc) 405 { 406 return (fc & cpu_to_le16(IEEE80211_FCTL_PM)) != 0; 407 } 408 409 /** 410 * ieee80211_has_moredata - check if IEEE80211_FCTL_MOREDATA is set 411 * @fc: frame control bytes in little-endian byteorder 412 * Return: whether or not the more data flag is set 413 */ 414 static inline bool ieee80211_has_moredata(__le16 fc) 415 { 416 return (fc & cpu_to_le16(IEEE80211_FCTL_MOREDATA)) != 0; 417 } 418 419 /** 420 * ieee80211_has_protected - check if IEEE80211_FCTL_PROTECTED is set 421 * @fc: frame control bytes in little-endian byteorder 422 * Return: whether or not the protected flag is set 423 */ 424 static inline bool ieee80211_has_protected(__le16 fc) 425 { 426 return (fc & cpu_to_le16(IEEE80211_FCTL_PROTECTED)) != 0; 427 } 428 429 /** 430 * ieee80211_has_order - check if IEEE80211_FCTL_ORDER is set 431 * @fc: frame control bytes in little-endian byteorder 432 * Return: whether or not the order flag is set 433 */ 434 static inline bool ieee80211_has_order(__le16 fc) 435 { 436 return (fc & cpu_to_le16(IEEE80211_FCTL_ORDER)) != 0; 437 } 438 439 /** 440 * ieee80211_is_mgmt - check if type is IEEE80211_FTYPE_MGMT 441 * @fc: frame control bytes in little-endian byteorder 442 * Return: whether or not the frame type is management 443 */ 444 static inline bool ieee80211_is_mgmt(__le16 fc) 445 { 446 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) == 447 cpu_to_le16(IEEE80211_FTYPE_MGMT); 448 } 449 450 /** 451 * ieee80211_is_ctl - check if type is IEEE80211_FTYPE_CTL 452 * @fc: frame control bytes in little-endian byteorder 453 * Return: whether or not the frame type is control 454 */ 455 static inline bool ieee80211_is_ctl(__le16 fc) 456 { 457 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) == 458 cpu_to_le16(IEEE80211_FTYPE_CTL); 459 } 460 461 /** 462 * ieee80211_is_data - check if type is IEEE80211_FTYPE_DATA 463 * @fc: frame control bytes in little-endian byteorder 464 * Return: whether or not the frame is a data frame 465 */ 466 static inline bool ieee80211_is_data(__le16 fc) 467 { 468 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) == 469 cpu_to_le16(IEEE80211_FTYPE_DATA); 470 } 471 472 /** 473 * ieee80211_is_ext - check if type is IEEE80211_FTYPE_EXT 474 * @fc: frame control bytes in little-endian byteorder 475 * Return: whether or not the frame type is extended 476 */ 477 static inline bool ieee80211_is_ext(__le16 fc) 478 { 479 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) == 480 cpu_to_le16(IEEE80211_FTYPE_EXT); 481 } 482 483 484 /** 485 * ieee80211_is_data_qos - check if type is IEEE80211_FTYPE_DATA and IEEE80211_STYPE_QOS_DATA is set 486 * @fc: frame control bytes in little-endian byteorder 487 * Return: whether or not the frame is a QoS data frame 488 */ 489 static inline bool ieee80211_is_data_qos(__le16 fc) 490 { 491 /* 492 * mask with QOS_DATA rather than IEEE80211_FCTL_STYPE as we just need 493 * to check the one bit 494 */ 495 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_STYPE_QOS_DATA)) == 496 cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_QOS_DATA); 497 } 498 499 /** 500 * ieee80211_is_data_present - check if type is IEEE80211_FTYPE_DATA and has data 501 * @fc: frame control bytes in little-endian byteorder 502 * Return: whether or not the frame is a QoS data frame that has data 503 * (i.e. is not null data) 504 */ 505 static inline bool ieee80211_is_data_present(__le16 fc) 506 { 507 /* 508 * mask with 0x40 and test that that bit is clear to only return true 509 * for the data-containing substypes. 510 */ 511 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | 0x40)) == 512 cpu_to_le16(IEEE80211_FTYPE_DATA); 513 } 514 515 /** 516 * ieee80211_is_assoc_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ASSOC_REQ 517 * @fc: frame control bytes in little-endian byteorder 518 * Return: whether or not the frame is an association request 519 */ 520 static inline bool ieee80211_is_assoc_req(__le16 fc) 521 { 522 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 523 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ASSOC_REQ); 524 } 525 526 /** 527 * ieee80211_is_assoc_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ASSOC_RESP 528 * @fc: frame control bytes in little-endian byteorder 529 * Return: whether or not the frame is an association response 530 */ 531 static inline bool ieee80211_is_assoc_resp(__le16 fc) 532 { 533 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 534 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ASSOC_RESP); 535 } 536 537 /** 538 * ieee80211_is_reassoc_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_REASSOC_REQ 539 * @fc: frame control bytes in little-endian byteorder 540 * Return: whether or not the frame is a reassociation request 541 */ 542 static inline bool ieee80211_is_reassoc_req(__le16 fc) 543 { 544 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 545 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_REASSOC_REQ); 546 } 547 548 /** 549 * ieee80211_is_reassoc_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_REASSOC_RESP 550 * @fc: frame control bytes in little-endian byteorder 551 * Return: whether or not the frame is a reassociation response 552 */ 553 static inline bool ieee80211_is_reassoc_resp(__le16 fc) 554 { 555 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 556 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_REASSOC_RESP); 557 } 558 559 /** 560 * ieee80211_is_assoc - check if (Re)association request/response frame 561 * @fc: frame control bytes in little-endian byteorder 562 * Return: whether or not the frame is an (re)association request or response 563 */ 564 static inline bool ieee80211_is_assoc(__le16 fc) 565 { 566 return ieee80211_is_assoc_req(fc) || ieee80211_is_reassoc_req(fc) || 567 ieee80211_is_assoc_resp(fc) || ieee80211_is_reassoc_resp(fc); 568 } 569 570 /** 571 * ieee80211_is_probe_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_PROBE_REQ 572 * @fc: frame control bytes in little-endian byteorder 573 * Return: whether or not the frame is a probe request 574 */ 575 static inline bool ieee80211_is_probe_req(__le16 fc) 576 { 577 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 578 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_REQ); 579 } 580 581 /** 582 * ieee80211_is_probe_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_PROBE_RESP 583 * @fc: frame control bytes in little-endian byteorder 584 * Return: whether or not the frame is a probe response 585 */ 586 static inline bool ieee80211_is_probe_resp(__le16 fc) 587 { 588 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 589 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP); 590 } 591 592 /** 593 * ieee80211_is_beacon - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_BEACON 594 * @fc: frame control bytes in little-endian byteorder 595 * Return: whether or not the frame is a (regular, not S1G) beacon 596 */ 597 static inline bool ieee80211_is_beacon(__le16 fc) 598 { 599 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 600 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON); 601 } 602 603 /** 604 * ieee80211_is_atim - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ATIM 605 * @fc: frame control bytes in little-endian byteorder 606 * Return: whether or not the frame is an ATIM frame 607 */ 608 static inline bool ieee80211_is_atim(__le16 fc) 609 { 610 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 611 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ATIM); 612 } 613 614 /** 615 * ieee80211_is_disassoc - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_DISASSOC 616 * @fc: frame control bytes in little-endian byteorder 617 * Return: whether or not the frame is a disassociation frame 618 */ 619 static inline bool ieee80211_is_disassoc(__le16 fc) 620 { 621 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 622 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_DISASSOC); 623 } 624 625 /** 626 * ieee80211_is_auth - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_AUTH 627 * @fc: frame control bytes in little-endian byteorder 628 * Return: whether or not the frame is an authentication frame 629 */ 630 static inline bool ieee80211_is_auth(__le16 fc) 631 { 632 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 633 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH); 634 } 635 636 /** 637 * ieee80211_is_deauth - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_DEAUTH 638 * @fc: frame control bytes in little-endian byteorder 639 * Return: whether or not the frame is a deauthentication frame 640 */ 641 static inline bool ieee80211_is_deauth(__le16 fc) 642 { 643 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 644 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_DEAUTH); 645 } 646 647 /** 648 * ieee80211_is_action - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ACTION 649 * @fc: frame control bytes in little-endian byteorder 650 * Return: whether or not the frame is an action frame 651 */ 652 static inline bool ieee80211_is_action(__le16 fc) 653 { 654 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 655 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ACTION); 656 } 657 658 /** 659 * ieee80211_is_back_req - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_BACK_REQ 660 * @fc: frame control bytes in little-endian byteorder 661 * Return: whether or not the frame is a block-ACK request frame 662 */ 663 static inline bool ieee80211_is_back_req(__le16 fc) 664 { 665 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 666 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_BACK_REQ); 667 } 668 669 /** 670 * ieee80211_is_back - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_BACK 671 * @fc: frame control bytes in little-endian byteorder 672 * Return: whether or not the frame is a block-ACK frame 673 */ 674 static inline bool ieee80211_is_back(__le16 fc) 675 { 676 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 677 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_BACK); 678 } 679 680 /** 681 * ieee80211_is_pspoll - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_PSPOLL 682 * @fc: frame control bytes in little-endian byteorder 683 * Return: whether or not the frame is a PS-poll frame 684 */ 685 static inline bool ieee80211_is_pspoll(__le16 fc) 686 { 687 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 688 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL); 689 } 690 691 /** 692 * ieee80211_is_rts - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_RTS 693 * @fc: frame control bytes in little-endian byteorder 694 * Return: whether or not the frame is an RTS frame 695 */ 696 static inline bool ieee80211_is_rts(__le16 fc) 697 { 698 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 699 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS); 700 } 701 702 /** 703 * ieee80211_is_cts - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CTS 704 * @fc: frame control bytes in little-endian byteorder 705 * Return: whether or not the frame is a CTS frame 706 */ 707 static inline bool ieee80211_is_cts(__le16 fc) 708 { 709 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 710 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS); 711 } 712 713 /** 714 * ieee80211_is_ack - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_ACK 715 * @fc: frame control bytes in little-endian byteorder 716 * Return: whether or not the frame is an ACK frame 717 */ 718 static inline bool ieee80211_is_ack(__le16 fc) 719 { 720 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 721 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_ACK); 722 } 723 724 /** 725 * ieee80211_is_cfend - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CFEND 726 * @fc: frame control bytes in little-endian byteorder 727 * Return: whether or not the frame is a CF-end frame 728 */ 729 static inline bool ieee80211_is_cfend(__le16 fc) 730 { 731 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 732 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CFEND); 733 } 734 735 /** 736 * ieee80211_is_cfendack - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CFENDACK 737 * @fc: frame control bytes in little-endian byteorder 738 * Return: whether or not the frame is a CF-end-ack frame 739 */ 740 static inline bool ieee80211_is_cfendack(__le16 fc) 741 { 742 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 743 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CFENDACK); 744 } 745 746 /** 747 * ieee80211_is_nullfunc - check if frame is a regular (non-QoS) nullfunc frame 748 * @fc: frame control bytes in little-endian byteorder 749 * Return: whether or not the frame is a nullfunc frame 750 */ 751 static inline bool ieee80211_is_nullfunc(__le16 fc) 752 { 753 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 754 cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC); 755 } 756 757 /** 758 * ieee80211_is_qos_nullfunc - check if frame is a QoS nullfunc frame 759 * @fc: frame control bytes in little-endian byteorder 760 * Return: whether or not the frame is a QoS nullfunc frame 761 */ 762 static inline bool ieee80211_is_qos_nullfunc(__le16 fc) 763 { 764 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 765 cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_QOS_NULLFUNC); 766 } 767 768 /** 769 * ieee80211_is_trigger - check if frame is trigger frame 770 * @fc: frame control field in little-endian byteorder 771 * Return: whether or not the frame is a trigger frame 772 */ 773 static inline bool ieee80211_is_trigger(__le16 fc) 774 { 775 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 776 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_TRIGGER); 777 } 778 779 /** 780 * ieee80211_is_any_nullfunc - check if frame is regular or QoS nullfunc frame 781 * @fc: frame control bytes in little-endian byteorder 782 * Return: whether or not the frame is a nullfunc or QoS nullfunc frame 783 */ 784 static inline bool ieee80211_is_any_nullfunc(__le16 fc) 785 { 786 return (ieee80211_is_nullfunc(fc) || ieee80211_is_qos_nullfunc(fc)); 787 } 788 789 /** 790 * ieee80211_is_first_frag - check if IEEE80211_SCTL_FRAG is not set 791 * @seq_ctrl: frame sequence control bytes in little-endian byteorder 792 * Return: whether or not the frame is the first fragment (also true if 793 * it's not fragmented at all) 794 */ 795 static inline bool ieee80211_is_first_frag(__le16 seq_ctrl) 796 { 797 return (seq_ctrl & cpu_to_le16(IEEE80211_SCTL_FRAG)) == 0; 798 } 799 800 /** 801 * ieee80211_is_frag - check if a frame is a fragment 802 * @hdr: 802.11 header of the frame 803 * Return: whether or not the frame is a fragment 804 */ 805 static inline bool ieee80211_is_frag(struct ieee80211_hdr *hdr) 806 { 807 return ieee80211_has_morefrags(hdr->frame_control) || 808 hdr->seq_ctrl & cpu_to_le16(IEEE80211_SCTL_FRAG); 809 } 810 811 static inline u16 ieee80211_get_sn(struct ieee80211_hdr *hdr) 812 { 813 return le16_get_bits(hdr->seq_ctrl, IEEE80211_SCTL_SEQ); 814 } 815 816 /** 817 * struct ieee80211_quiet_ie - Quiet element 818 * @count: Quiet Count 819 * @period: Quiet Period 820 * @duration: Quiet Duration 821 * @offset: Quiet Offset 822 * 823 * This structure represents the payload of the "Quiet element" as 824 * described in IEEE Std 802.11-2020 section 9.4.2.22. 825 */ 826 struct ieee80211_quiet_ie { 827 u8 count; 828 u8 period; 829 __le16 duration; 830 __le16 offset; 831 } __packed; 832 833 /** 834 * struct ieee80211_msrment_ie - Measurement element 835 * @token: Measurement Token 836 * @mode: Measurement Report Mode 837 * @type: Measurement Type 838 * @request: Measurement Request or Measurement Report 839 * 840 * This structure represents the payload of both the "Measurement 841 * Request element" and the "Measurement Report element" as described 842 * in IEEE Std 802.11-2020 sections 9.4.2.20 and 9.4.2.21. 843 */ 844 struct ieee80211_msrment_ie { 845 u8 token; 846 u8 mode; 847 u8 type; 848 u8 request[]; 849 } __packed; 850 851 /** 852 * struct ieee80211_channel_sw_ie - Channel Switch Announcement element 853 * @mode: Channel Switch Mode 854 * @new_ch_num: New Channel Number 855 * @count: Channel Switch Count 856 * 857 * This structure represents the payload of the "Channel Switch 858 * Announcement element" as described in IEEE Std 802.11-2020 section 859 * 9.4.2.18. 860 */ 861 struct ieee80211_channel_sw_ie { 862 u8 mode; 863 u8 new_ch_num; 864 u8 count; 865 } __packed; 866 867 /** 868 * struct ieee80211_ext_chansw_ie - Extended Channel Switch Announcement element 869 * @mode: Channel Switch Mode 870 * @new_operating_class: New Operating Class 871 * @new_ch_num: New Channel Number 872 * @count: Channel Switch Count 873 * 874 * This structure represents the "Extended Channel Switch Announcement 875 * element" as described in IEEE Std 802.11-2020 section 9.4.2.52. 876 */ 877 struct ieee80211_ext_chansw_ie { 878 u8 mode; 879 u8 new_operating_class; 880 u8 new_ch_num; 881 u8 count; 882 } __packed; 883 884 /** 885 * struct ieee80211_sec_chan_offs_ie - secondary channel offset IE 886 * @sec_chan_offs: secondary channel offset, uses IEEE80211_HT_PARAM_CHA_SEC_* 887 * values here 888 * This structure represents the "Secondary Channel Offset element" 889 */ 890 struct ieee80211_sec_chan_offs_ie { 891 u8 sec_chan_offs; 892 } __packed; 893 894 /** 895 * struct ieee80211_wide_bw_chansw_ie - wide bandwidth channel switch IE 896 * @new_channel_width: New Channel Width 897 * @new_center_freq_seg0: New Channel Center Frequency Segment 0 898 * @new_center_freq_seg1: New Channel Center Frequency Segment 1 899 * 900 * This structure represents the payload of the "Wide Bandwidth 901 * Channel Switch element" as described in IEEE Std 802.11-2020 902 * section 9.4.2.160. 903 */ 904 struct ieee80211_wide_bw_chansw_ie { 905 u8 new_channel_width; 906 u8 new_center_freq_seg0, new_center_freq_seg1; 907 } __packed; 908 909 /** 910 * struct ieee80211_tim_ie - Traffic Indication Map information element 911 * @dtim_count: DTIM Count 912 * @dtim_period: DTIM Period 913 * @bitmap_ctrl: Bitmap Control 914 * @required_octet: "Syntatic sugar" to force the struct size to the 915 * minimum valid size when carried in a non-S1G PPDU 916 * @virtual_map: Partial Virtual Bitmap 917 * 918 * This structure represents the payload of the "TIM element" as 919 * described in IEEE Std 802.11-2020 section 9.4.2.5. Note that this 920 * definition is only applicable when the element is carried in a 921 * non-S1G PPDU. When the TIM is carried in an S1G PPDU, the Bitmap 922 * Control and Partial Virtual Bitmap may not be present. 923 */ 924 struct ieee80211_tim_ie { 925 u8 dtim_count; 926 u8 dtim_period; 927 u8 bitmap_ctrl; 928 union { 929 u8 required_octet; 930 DECLARE_FLEX_ARRAY(u8, virtual_map); 931 }; 932 } __packed; 933 934 #define WLAN_SA_QUERY_TR_ID_LEN 2 935 #define WLAN_MEMBERSHIP_LEN 8 936 #define WLAN_USER_POSITION_LEN 16 937 938 /** 939 * struct ieee80211_tpc_report_ie - TPC Report element 940 * @tx_power: Transmit Power 941 * @link_margin: Link Margin 942 * 943 * This structure represents the payload of the "TPC Report element" as 944 * described in IEEE Std 802.11-2020 section 9.4.2.16. 945 */ 946 struct ieee80211_tpc_report_ie { 947 u8 tx_power; 948 u8 link_margin; 949 } __packed; 950 951 #define IEEE80211_ADDBA_EXT_FRAG_LEVEL_MASK GENMASK(2, 1) 952 #define IEEE80211_ADDBA_EXT_FRAG_LEVEL_SHIFT 1 953 #define IEEE80211_ADDBA_EXT_NO_FRAG BIT(0) 954 #define IEEE80211_ADDBA_EXT_BUF_SIZE_MASK GENMASK(7, 5) 955 #define IEEE80211_ADDBA_EXT_BUF_SIZE_SHIFT 10 956 957 struct ieee80211_addba_ext_ie { 958 u8 data; 959 } __packed; 960 961 struct ieee80211_ext { 962 __le16 frame_control; 963 __le16 duration; 964 union { 965 struct { 966 u8 sa[ETH_ALEN]; 967 __le32 timestamp; 968 u8 change_seq; 969 u8 variable[]; 970 } __packed s1g_beacon; 971 } u; 972 } __packed __aligned(2); 973 974 /** 975 * struct ieee80211_bss_load_elem - BSS Load elemen 976 * 977 * Defined in section 9.4.2.26 in IEEE 802.11-REVme D4.1 978 * 979 * @sta_count: total number of STAs currently associated with the AP. 980 * @channel_util: Percentage of time that the access point sensed the channel 981 * was busy. This value is in range [0, 255], the highest value means 982 * 100% busy. 983 * @avail_admission_capa: remaining amount of medium time used for admission 984 * control. 985 */ 986 struct ieee80211_bss_load_elem { 987 __le16 sta_count; 988 u8 channel_util; 989 __le16 avail_admission_capa; 990 } __packed; 991 992 struct ieee80211_mgmt { 993 __le16 frame_control; 994 __le16 duration; 995 u8 da[ETH_ALEN]; 996 u8 sa[ETH_ALEN]; 997 u8 bssid[ETH_ALEN]; 998 __le16 seq_ctrl; 999 union { 1000 struct { 1001 __le16 auth_alg; 1002 __le16 auth_transaction; 1003 __le16 status_code; 1004 /* possibly followed by Challenge text */ 1005 u8 variable[]; 1006 } __packed auth; 1007 struct { 1008 __le16 reason_code; 1009 } __packed deauth; 1010 struct { 1011 __le16 capab_info; 1012 __le16 listen_interval; 1013 /* followed by SSID and Supported rates */ 1014 u8 variable[]; 1015 } __packed assoc_req; 1016 struct { 1017 __le16 capab_info; 1018 __le16 status_code; 1019 __le16 aid; 1020 /* followed by Supported rates */ 1021 u8 variable[]; 1022 } __packed assoc_resp, reassoc_resp; 1023 struct { 1024 __le16 capab_info; 1025 __le16 status_code; 1026 u8 variable[]; 1027 } __packed s1g_assoc_resp, s1g_reassoc_resp; 1028 struct { 1029 __le16 capab_info; 1030 __le16 listen_interval; 1031 u8 current_ap[ETH_ALEN]; 1032 /* followed by SSID and Supported rates */ 1033 u8 variable[]; 1034 } __packed reassoc_req; 1035 struct { 1036 __le16 reason_code; 1037 } __packed disassoc; 1038 struct { 1039 __le64 timestamp; 1040 __le16 beacon_int; 1041 __le16 capab_info; 1042 /* followed by some of SSID, Supported rates, 1043 * FH Params, DS Params, CF Params, IBSS Params, TIM */ 1044 u8 variable[]; 1045 } __packed beacon; 1046 struct { 1047 /* only variable items: SSID, Supported rates */ 1048 DECLARE_FLEX_ARRAY(u8, variable); 1049 } __packed probe_req; 1050 struct { 1051 __le64 timestamp; 1052 __le16 beacon_int; 1053 __le16 capab_info; 1054 /* followed by some of SSID, Supported rates, 1055 * FH Params, DS Params, CF Params, IBSS Params */ 1056 u8 variable[]; 1057 } __packed probe_resp; 1058 struct { 1059 u8 category; 1060 u8 action_code; 1061 union { 1062 struct { 1063 u8 dialog_token; 1064 u8 status_code; 1065 u8 variable[]; 1066 } __packed wme_action; 1067 struct{ 1068 u8 no_fixed_fields[0]; 1069 u8 variable[]; 1070 } __packed chan_switch; 1071 struct{ 1072 struct ieee80211_ext_chansw_ie data; 1073 u8 variable[]; 1074 } __packed ext_chan_switch; 1075 struct{ 1076 u8 dialog_token; 1077 u8 element_id; 1078 u8 length; 1079 struct ieee80211_msrment_ie msr_elem; 1080 } __packed measurement; 1081 struct{ 1082 u8 dialog_token; 1083 __le16 capab; 1084 __le16 timeout; 1085 __le16 start_seq_num; 1086 /* followed by BA Extension */ 1087 u8 variable[]; 1088 } __packed addba_req; 1089 struct{ 1090 u8 dialog_token; 1091 __le16 status; 1092 __le16 capab; 1093 __le16 timeout; 1094 /* followed by BA Extension */ 1095 u8 variable[]; 1096 } __packed addba_resp; 1097 struct{ 1098 __le16 params; 1099 __le16 reason_code; 1100 } __packed delba; 1101 struct { 1102 u8 no_fixed_fields[0]; 1103 u8 variable[]; 1104 } __packed self_prot; 1105 struct{ 1106 u8 no_fixed_fields[0]; 1107 u8 variable[]; 1108 } __packed mesh_action; 1109 struct { 1110 u8 trans_id[WLAN_SA_QUERY_TR_ID_LEN]; 1111 } __packed sa_query; 1112 struct { 1113 u8 smps_control; 1114 } __packed ht_smps; 1115 struct { 1116 u8 chanwidth; 1117 } __packed ht_notify_cw; 1118 struct { 1119 u8 dialog_token; 1120 __le16 capability; 1121 u8 variable[]; 1122 } __packed tdls_discover_resp; 1123 struct { 1124 u8 operating_mode; 1125 } __packed vht_opmode_notif; 1126 struct { 1127 u8 membership[WLAN_MEMBERSHIP_LEN]; 1128 u8 position[WLAN_USER_POSITION_LEN]; 1129 } __packed vht_group_notif; 1130 struct { 1131 u8 dialog_token; 1132 u8 tpc_elem_id; 1133 u8 tpc_elem_length; 1134 struct ieee80211_tpc_report_ie tpc; 1135 } __packed tpc_report; 1136 struct { 1137 u8 dialog_token; 1138 u8 follow_up; 1139 u8 tod[6]; 1140 u8 toa[6]; 1141 __le16 tod_error; 1142 __le16 toa_error; 1143 u8 variable[]; 1144 } __packed ftm; 1145 struct { 1146 u8 no_fixed_fields[0]; 1147 u8 variable[]; 1148 } __packed s1g; 1149 struct { 1150 u8 dialog_token; 1151 u8 follow_up; 1152 u32 tod; 1153 u32 toa; 1154 u8 max_tod_error; 1155 u8 max_toa_error; 1156 } __packed wnm_timing_msr; 1157 struct { 1158 u8 dialog_token; 1159 u8 variable[]; 1160 } __packed ttlm_req; 1161 struct { 1162 u8 dialog_token; 1163 __le16 status_code; 1164 u8 variable[]; 1165 } __packed ttlm_res; 1166 struct { 1167 u8 no_fixed_fields[0]; 1168 /* no variable fields either */ 1169 } __packed ttlm_tear_down; 1170 struct { 1171 u8 dialog_token; 1172 u8 variable[]; 1173 } __packed ml_reconf_req; 1174 struct { 1175 u8 dialog_token; 1176 u8 count; 1177 u8 variable[]; 1178 } __packed ml_reconf_resp; 1179 struct { 1180 u8 no_fixed_fields[0]; 1181 u8 variable[]; 1182 } __packed epcs; 1183 struct { 1184 u8 dialog_token; 1185 u8 control; 1186 u8 variable[]; 1187 } __packed eml_omn; 1188 struct { 1189 u8 dialog_token; 1190 u8 type; 1191 u8 variable[]; 1192 } __packed uhr_link_reconf_req; 1193 struct { 1194 u8 dialog_token; 1195 u8 type; 1196 u8 count; 1197 u8 variable[]; 1198 } __packed uhr_link_reconf_resp; 1199 struct { 1200 u8 dialog_token; 1201 u8 type; 1202 u8 variable[]; 1203 } __packed uhr_link_reconf_notif; 1204 }; 1205 } __packed action; 1206 DECLARE_FLEX_ARRAY(u8, body); /* Generic frame body */ 1207 } u; 1208 } __packed __aligned(2); 1209 1210 /* Supported rates membership selectors */ 1211 #define BSS_MEMBERSHIP_SELECTOR_HT_PHY 127 1212 #define BSS_MEMBERSHIP_SELECTOR_VHT_PHY 126 1213 #define BSS_MEMBERSHIP_SELECTOR_GLK 125 1214 #define BSS_MEMBERSHIP_SELECTOR_EPD 124 1215 #define BSS_MEMBERSHIP_SELECTOR_SAE_H2E 123 1216 #define BSS_MEMBERSHIP_SELECTOR_HE_PHY 122 1217 #define BSS_MEMBERSHIP_SELECTOR_EHT_PHY 121 1218 #define BSS_MEMBERSHIP_SELECTOR_UHR_PHY 120 1219 1220 #define BSS_MEMBERSHIP_SELECTOR_MIN BSS_MEMBERSHIP_SELECTOR_UHR_PHY 1221 1222 #define IEEE80211_MIN_ACTION_SIZE(type) offsetofend(struct ieee80211_mgmt, u.action.type) 1223 1224 /* Link Reconfiguration Status Duple field */ 1225 struct ieee80211_ml_reconf_status { 1226 u8 info; 1227 __le16 status; 1228 } __packed; 1229 1230 #define IEEE80211_ML_RECONF_LINK_ID_MASK 0xf 1231 1232 /* Management MIC information element (IEEE 802.11w) for CMAC */ 1233 struct ieee80211_mmie { 1234 u8 element_id; 1235 u8 length; 1236 __le16 key_id; 1237 u8 sequence_number[6]; 1238 u8 mic[8]; 1239 } __packed; 1240 1241 /* Management MIC information element (IEEE 802.11w) for GMAC and CMAC-256 */ 1242 struct ieee80211_mmie_16 { 1243 u8 element_id; 1244 u8 length; 1245 __le16 key_id; 1246 u8 sequence_number[6]; 1247 u8 mic[16]; 1248 } __packed; 1249 1250 /* Management MIC information element (IEEE 802.11w) for all variants */ 1251 struct ieee80211_mmie_var { 1252 u8 element_id; 1253 u8 length; 1254 __le16 key_id; 1255 u8 sequence_number[6]; 1256 u8 mic[]; /* 8 or 16 bytes */ 1257 } __packed; 1258 1259 struct ieee80211_vendor_ie { 1260 u8 element_id; 1261 u8 len; 1262 u8 oui[3]; 1263 u8 oui_type; 1264 } __packed; 1265 1266 struct ieee80211_wmm_ac_param { 1267 u8 aci_aifsn; /* AIFSN, ACM, ACI */ 1268 u8 cw; /* ECWmin, ECWmax (CW = 2^ECW - 1) */ 1269 __le16 txop_limit; 1270 } __packed; 1271 1272 struct ieee80211_wmm_param_ie { 1273 u8 element_id; /* Element ID: 221 (0xdd); */ 1274 u8 len; /* Length: 24 */ 1275 /* required fields for WMM version 1 */ 1276 u8 oui[3]; /* 00:50:f2 */ 1277 u8 oui_type; /* 2 */ 1278 u8 oui_subtype; /* 1 */ 1279 u8 version; /* 1 for WMM version 1.0 */ 1280 u8 qos_info; /* AP/STA specific QoS info */ 1281 u8 reserved; /* 0 */ 1282 /* AC_BE, AC_BK, AC_VI, AC_VO */ 1283 struct ieee80211_wmm_ac_param ac[4]; 1284 } __packed; 1285 1286 /* Control frames */ 1287 struct ieee80211_rts { 1288 __le16 frame_control; 1289 __le16 duration; 1290 u8 ra[ETH_ALEN]; 1291 u8 ta[ETH_ALEN]; 1292 } __packed __aligned(2); 1293 1294 struct ieee80211_cts { 1295 __le16 frame_control; 1296 __le16 duration; 1297 u8 ra[ETH_ALEN]; 1298 } __packed __aligned(2); 1299 1300 struct ieee80211_pspoll { 1301 __le16 frame_control; 1302 __le16 aid; 1303 u8 bssid[ETH_ALEN]; 1304 u8 ta[ETH_ALEN]; 1305 } __packed __aligned(2); 1306 1307 /* TDLS */ 1308 1309 /* Channel switch timing */ 1310 struct ieee80211_ch_switch_timing { 1311 __le16 switch_time; 1312 __le16 switch_timeout; 1313 } __packed; 1314 1315 /* Link-id information element */ 1316 struct ieee80211_tdls_lnkie { 1317 u8 ie_type; /* Link Identifier IE */ 1318 u8 ie_len; 1319 u8 bssid[ETH_ALEN]; 1320 u8 init_sta[ETH_ALEN]; 1321 u8 resp_sta[ETH_ALEN]; 1322 } __packed; 1323 1324 struct ieee80211_tdls_data { 1325 u8 da[ETH_ALEN]; 1326 u8 sa[ETH_ALEN]; 1327 __be16 ether_type; 1328 u8 payload_type; 1329 u8 category; 1330 u8 action_code; 1331 union { 1332 struct { 1333 u8 dialog_token; 1334 __le16 capability; 1335 u8 variable[]; 1336 } __packed setup_req; 1337 struct { 1338 __le16 status_code; 1339 u8 dialog_token; 1340 __le16 capability; 1341 u8 variable[]; 1342 } __packed setup_resp; 1343 struct { 1344 __le16 status_code; 1345 u8 dialog_token; 1346 u8 variable[]; 1347 } __packed setup_cfm; 1348 struct { 1349 __le16 reason_code; 1350 u8 variable[]; 1351 } __packed teardown; 1352 struct { 1353 u8 dialog_token; 1354 u8 variable[]; 1355 } __packed discover_req; 1356 struct { 1357 u8 target_channel; 1358 u8 oper_class; 1359 u8 variable[]; 1360 } __packed chan_switch_req; 1361 struct { 1362 __le16 status_code; 1363 u8 variable[]; 1364 } __packed chan_switch_resp; 1365 } u; 1366 } __packed; 1367 1368 /* Authentication algorithms */ 1369 #define WLAN_AUTH_OPEN 0 1370 #define WLAN_AUTH_SHARED_KEY 1 1371 #define WLAN_AUTH_FT 2 1372 #define WLAN_AUTH_SAE 3 1373 #define WLAN_AUTH_FILS_SK 4 1374 #define WLAN_AUTH_FILS_SK_PFS 5 1375 #define WLAN_AUTH_FILS_PK 6 1376 #define WLAN_AUTH_IEEE8021X 8 1377 #define WLAN_AUTH_EPPKE 9 1378 #define WLAN_AUTH_LEAP 128 1379 1380 #define WLAN_AUTH_CHALLENGE_LEN 128 1381 1382 #define WLAN_CAPABILITY_ESS (1<<0) 1383 #define WLAN_CAPABILITY_IBSS (1<<1) 1384 1385 /* 1386 * A mesh STA sets the ESS and IBSS capability bits to zero. 1387 * however, this holds true for p2p probe responses (in the p2p_find 1388 * phase) as well. 1389 */ 1390 #define WLAN_CAPABILITY_IS_STA_BSS(cap) \ 1391 (!((cap) & (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS))) 1392 1393 #define WLAN_CAPABILITY_CF_POLLABLE (1<<2) 1394 #define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3) 1395 #define WLAN_CAPABILITY_PRIVACY (1<<4) 1396 #define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5) 1397 #define WLAN_CAPABILITY_PBCC (1<<6) 1398 #define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7) 1399 1400 /* 802.11h */ 1401 #define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8) 1402 #define WLAN_CAPABILITY_QOS (1<<9) 1403 #define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10) 1404 #define WLAN_CAPABILITY_APSD (1<<11) 1405 #define WLAN_CAPABILITY_RADIO_MEASURE (1<<12) 1406 #define WLAN_CAPABILITY_DSSS_OFDM (1<<13) 1407 #define WLAN_CAPABILITY_DEL_BACK (1<<14) 1408 #define WLAN_CAPABILITY_IMM_BACK (1<<15) 1409 1410 /* DMG (60gHz) 802.11ad */ 1411 /* type - bits 0..1 */ 1412 #define WLAN_CAPABILITY_DMG_TYPE_MASK (3<<0) 1413 #define WLAN_CAPABILITY_DMG_TYPE_IBSS (1<<0) /* Tx by: STA */ 1414 #define WLAN_CAPABILITY_DMG_TYPE_PBSS (2<<0) /* Tx by: PCP */ 1415 #define WLAN_CAPABILITY_DMG_TYPE_AP (3<<0) /* Tx by: AP */ 1416 1417 #define WLAN_CAPABILITY_DMG_CBAP_ONLY (1<<2) 1418 #define WLAN_CAPABILITY_DMG_CBAP_SOURCE (1<<3) 1419 #define WLAN_CAPABILITY_DMG_PRIVACY (1<<4) 1420 #define WLAN_CAPABILITY_DMG_ECPAC (1<<5) 1421 1422 #define WLAN_CAPABILITY_DMG_SPECTRUM_MGMT (1<<8) 1423 #define WLAN_CAPABILITY_DMG_RADIO_MEASURE (1<<12) 1424 1425 /* measurement */ 1426 #define IEEE80211_SPCT_MSR_RPRT_MODE_LATE (1<<0) 1427 #define IEEE80211_SPCT_MSR_RPRT_MODE_INCAPABLE (1<<1) 1428 #define IEEE80211_SPCT_MSR_RPRT_MODE_REFUSED (1<<2) 1429 1430 #define IEEE80211_SPCT_MSR_RPRT_TYPE_BASIC 0 1431 #define IEEE80211_SPCT_MSR_RPRT_TYPE_CCA 1 1432 #define IEEE80211_SPCT_MSR_RPRT_TYPE_RPI 2 1433 #define IEEE80211_SPCT_MSR_RPRT_TYPE_LCI 8 1434 #define IEEE80211_SPCT_MSR_RPRT_TYPE_CIVIC 11 1435 1436 /* 802.11g ERP information element */ 1437 #define WLAN_ERP_NON_ERP_PRESENT (1<<0) 1438 #define WLAN_ERP_USE_PROTECTION (1<<1) 1439 #define WLAN_ERP_BARKER_PREAMBLE (1<<2) 1440 1441 /* WLAN_ERP_BARKER_PREAMBLE values */ 1442 enum { 1443 WLAN_ERP_PREAMBLE_SHORT = 0, 1444 WLAN_ERP_PREAMBLE_LONG = 1, 1445 }; 1446 1447 /* Band ID, 802.11ad #8.4.1.45 */ 1448 enum { 1449 IEEE80211_BANDID_TV_WS = 0, /* TV white spaces */ 1450 IEEE80211_BANDID_SUB1 = 1, /* Sub-1 GHz (excluding TV white spaces) */ 1451 IEEE80211_BANDID_2G = 2, /* 2.4 GHz */ 1452 IEEE80211_BANDID_3G = 3, /* 3.6 GHz */ 1453 IEEE80211_BANDID_5G = 4, /* 4.9 and 5 GHz */ 1454 IEEE80211_BANDID_60G = 5, /* 60 GHz */ 1455 }; 1456 1457 /* Status codes */ 1458 enum ieee80211_statuscode { 1459 WLAN_STATUS_SUCCESS = 0, 1460 WLAN_STATUS_UNSPECIFIED_FAILURE = 1, 1461 WLAN_STATUS_CAPS_UNSUPPORTED = 10, 1462 WLAN_STATUS_REASSOC_NO_ASSOC = 11, 1463 WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12, 1464 WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13, 1465 WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14, 1466 WLAN_STATUS_CHALLENGE_FAIL = 15, 1467 WLAN_STATUS_AUTH_TIMEOUT = 16, 1468 WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17, 1469 WLAN_STATUS_ASSOC_DENIED_RATES = 18, 1470 /* 802.11b */ 1471 WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19, 1472 WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20, 1473 WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21, 1474 /* 802.11h */ 1475 WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22, 1476 WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23, 1477 WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24, 1478 /* 802.11g */ 1479 WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25, 1480 WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26, 1481 /* 802.11w */ 1482 WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY = 30, 1483 WLAN_STATUS_ROBUST_MGMT_FRAME_POLICY_VIOLATION = 31, 1484 /* 802.11i */ 1485 WLAN_STATUS_INVALID_IE = 40, 1486 WLAN_STATUS_INVALID_GROUP_CIPHER = 41, 1487 WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42, 1488 WLAN_STATUS_INVALID_AKMP = 43, 1489 WLAN_STATUS_UNSUPP_RSN_VERSION = 44, 1490 WLAN_STATUS_INVALID_RSN_IE_CAP = 45, 1491 WLAN_STATUS_CIPHER_SUITE_REJECTED = 46, 1492 /* 802.11e */ 1493 WLAN_STATUS_UNSPECIFIED_QOS = 32, 1494 WLAN_STATUS_ASSOC_DENIED_NOBANDWIDTH = 33, 1495 WLAN_STATUS_ASSOC_DENIED_LOWACK = 34, 1496 WLAN_STATUS_ASSOC_DENIED_UNSUPP_QOS = 35, 1497 WLAN_STATUS_REQUEST_DECLINED = 37, 1498 WLAN_STATUS_INVALID_QOS_PARAM = 38, 1499 WLAN_STATUS_CHANGE_TSPEC = 39, 1500 WLAN_STATUS_WAIT_TS_DELAY = 47, 1501 WLAN_STATUS_NO_DIRECT_LINK = 48, 1502 WLAN_STATUS_STA_NOT_PRESENT = 49, 1503 WLAN_STATUS_STA_NOT_QSTA = 50, 1504 /* 802.11s */ 1505 WLAN_STATUS_ANTI_CLOG_REQUIRED = 76, 1506 WLAN_STATUS_FCG_NOT_SUPP = 78, 1507 WLAN_STATUS_STA_NO_TBTT = 78, 1508 /* 802.11ad */ 1509 WLAN_STATUS_REJECTED_WITH_SUGGESTED_CHANGES = 39, 1510 WLAN_STATUS_REJECTED_FOR_DELAY_PERIOD = 47, 1511 WLAN_STATUS_REJECT_WITH_SCHEDULE = 83, 1512 WLAN_STATUS_PENDING_ADMITTING_FST_SESSION = 86, 1513 WLAN_STATUS_PERFORMING_FST_NOW = 87, 1514 WLAN_STATUS_PENDING_GAP_IN_BA_WINDOW = 88, 1515 WLAN_STATUS_REJECT_U_PID_SETTING = 89, 1516 WLAN_STATUS_REJECT_DSE_BAND = 96, 1517 WLAN_STATUS_DENIED_WITH_SUGGESTED_BAND_AND_CHANNEL = 99, 1518 WLAN_STATUS_DENIED_DUE_TO_SPECTRUM_MANAGEMENT = 103, 1519 /* 802.11ah */ 1520 WLAN_STATUS_REJECTED_NDP_BLOCK_ACK_SUGGESTED = 109, 1521 /* 802.11ai */ 1522 WLAN_STATUS_FILS_AUTHENTICATION_FAILURE = 112, 1523 WLAN_STATUS_UNKNOWN_AUTHENTICATION_SERVER = 113, 1524 WLAN_STATUS_SAE_HASH_TO_ELEMENT = 126, 1525 WLAN_STATUS_SAE_PK = 127, 1526 WLAN_STATUS_DENIED_TID_TO_LINK_MAPPING = 133, 1527 WLAN_STATUS_PREF_TID_TO_LINK_MAPPING_SUGGESTED = 134, 1528 WLAN_STATUS_8021X_AUTH_SUCCESS = 153, 1529 }; 1530 1531 1532 /* Reason codes */ 1533 enum ieee80211_reasoncode { 1534 WLAN_REASON_UNSPECIFIED = 1, 1535 WLAN_REASON_PREV_AUTH_NOT_VALID = 2, 1536 WLAN_REASON_DEAUTH_LEAVING = 3, 1537 WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4, 1538 WLAN_REASON_DISASSOC_AP_BUSY = 5, 1539 WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6, 1540 WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7, 1541 WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8, 1542 WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9, 1543 /* 802.11h */ 1544 WLAN_REASON_DISASSOC_BAD_POWER = 10, 1545 WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11, 1546 /* 802.11i */ 1547 WLAN_REASON_INVALID_IE = 13, 1548 WLAN_REASON_MIC_FAILURE = 14, 1549 WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15, 1550 WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16, 1551 WLAN_REASON_IE_DIFFERENT = 17, 1552 WLAN_REASON_INVALID_GROUP_CIPHER = 18, 1553 WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19, 1554 WLAN_REASON_INVALID_AKMP = 20, 1555 WLAN_REASON_UNSUPP_RSN_VERSION = 21, 1556 WLAN_REASON_INVALID_RSN_IE_CAP = 22, 1557 WLAN_REASON_IEEE8021X_FAILED = 23, 1558 WLAN_REASON_CIPHER_SUITE_REJECTED = 24, 1559 /* TDLS (802.11z) */ 1560 WLAN_REASON_TDLS_TEARDOWN_UNREACHABLE = 25, 1561 WLAN_REASON_TDLS_TEARDOWN_UNSPECIFIED = 26, 1562 /* 802.11e */ 1563 WLAN_REASON_DISASSOC_UNSPECIFIED_QOS = 32, 1564 WLAN_REASON_DISASSOC_QAP_NO_BANDWIDTH = 33, 1565 WLAN_REASON_DISASSOC_LOW_ACK = 34, 1566 WLAN_REASON_DISASSOC_QAP_EXCEED_TXOP = 35, 1567 WLAN_REASON_QSTA_LEAVE_QBSS = 36, 1568 WLAN_REASON_QSTA_NOT_USE = 37, 1569 WLAN_REASON_QSTA_REQUIRE_SETUP = 38, 1570 WLAN_REASON_QSTA_TIMEOUT = 39, 1571 WLAN_REASON_QSTA_CIPHER_NOT_SUPP = 45, 1572 /* 802.11s */ 1573 WLAN_REASON_MESH_PEER_CANCELED = 52, 1574 WLAN_REASON_MESH_MAX_PEERS = 53, 1575 WLAN_REASON_MESH_CONFIG = 54, 1576 WLAN_REASON_MESH_CLOSE = 55, 1577 WLAN_REASON_MESH_MAX_RETRIES = 56, 1578 WLAN_REASON_MESH_CONFIRM_TIMEOUT = 57, 1579 WLAN_REASON_MESH_INVALID_GTK = 58, 1580 WLAN_REASON_MESH_INCONSISTENT_PARAM = 59, 1581 WLAN_REASON_MESH_INVALID_SECURITY = 60, 1582 WLAN_REASON_MESH_PATH_ERROR = 61, 1583 WLAN_REASON_MESH_PATH_NOFORWARD = 62, 1584 WLAN_REASON_MESH_PATH_DEST_UNREACHABLE = 63, 1585 WLAN_REASON_MAC_EXISTS_IN_MBSS = 64, 1586 WLAN_REASON_MESH_CHAN_REGULATORY = 65, 1587 WLAN_REASON_MESH_CHAN = 66, 1588 }; 1589 1590 1591 /* Information Element IDs */ 1592 enum ieee80211_eid { 1593 WLAN_EID_SSID = 0, 1594 WLAN_EID_SUPP_RATES = 1, 1595 WLAN_EID_FH_PARAMS = 2, /* reserved now */ 1596 WLAN_EID_DS_PARAMS = 3, 1597 WLAN_EID_CF_PARAMS = 4, 1598 WLAN_EID_TIM = 5, 1599 WLAN_EID_IBSS_PARAMS = 6, 1600 WLAN_EID_COUNTRY = 7, 1601 /* 8, 9 reserved */ 1602 WLAN_EID_REQUEST = 10, 1603 WLAN_EID_QBSS_LOAD = 11, 1604 WLAN_EID_EDCA_PARAM_SET = 12, 1605 WLAN_EID_TSPEC = 13, 1606 WLAN_EID_TCLAS = 14, 1607 WLAN_EID_SCHEDULE = 15, 1608 WLAN_EID_CHALLENGE = 16, 1609 /* 17-31 reserved for challenge text extension */ 1610 WLAN_EID_PWR_CONSTRAINT = 32, 1611 WLAN_EID_PWR_CAPABILITY = 33, 1612 WLAN_EID_TPC_REQUEST = 34, 1613 WLAN_EID_TPC_REPORT = 35, 1614 WLAN_EID_SUPPORTED_CHANNELS = 36, 1615 WLAN_EID_CHANNEL_SWITCH = 37, 1616 WLAN_EID_MEASURE_REQUEST = 38, 1617 WLAN_EID_MEASURE_REPORT = 39, 1618 WLAN_EID_QUIET = 40, 1619 WLAN_EID_IBSS_DFS = 41, 1620 WLAN_EID_ERP_INFO = 42, 1621 WLAN_EID_TS_DELAY = 43, 1622 WLAN_EID_TCLAS_PROCESSING = 44, 1623 WLAN_EID_HT_CAPABILITY = 45, 1624 WLAN_EID_QOS_CAPA = 46, 1625 /* 47 reserved for Broadcom */ 1626 WLAN_EID_RSN = 48, 1627 WLAN_EID_802_15_COEX = 49, 1628 WLAN_EID_EXT_SUPP_RATES = 50, 1629 WLAN_EID_AP_CHAN_REPORT = 51, 1630 WLAN_EID_NEIGHBOR_REPORT = 52, 1631 WLAN_EID_RCPI = 53, 1632 WLAN_EID_MOBILITY_DOMAIN = 54, 1633 WLAN_EID_FAST_BSS_TRANSITION = 55, 1634 WLAN_EID_TIMEOUT_INTERVAL = 56, 1635 WLAN_EID_RIC_DATA = 57, 1636 WLAN_EID_DSE_REGISTERED_LOCATION = 58, 1637 WLAN_EID_SUPPORTED_REGULATORY_CLASSES = 59, 1638 WLAN_EID_EXT_CHANSWITCH_ANN = 60, 1639 WLAN_EID_HT_OPERATION = 61, 1640 WLAN_EID_SECONDARY_CHANNEL_OFFSET = 62, 1641 WLAN_EID_BSS_AVG_ACCESS_DELAY = 63, 1642 WLAN_EID_ANTENNA_INFO = 64, 1643 WLAN_EID_RSNI = 65, 1644 WLAN_EID_MEASUREMENT_PILOT_TX_INFO = 66, 1645 WLAN_EID_BSS_AVAILABLE_CAPACITY = 67, 1646 WLAN_EID_BSS_AC_ACCESS_DELAY = 68, 1647 WLAN_EID_TIME_ADVERTISEMENT = 69, 1648 WLAN_EID_RRM_ENABLED_CAPABILITIES = 70, 1649 WLAN_EID_MULTIPLE_BSSID = 71, 1650 WLAN_EID_BSS_COEX_2040 = 72, 1651 WLAN_EID_BSS_INTOLERANT_CHL_REPORT = 73, 1652 WLAN_EID_OVERLAP_BSS_SCAN_PARAM = 74, 1653 WLAN_EID_RIC_DESCRIPTOR = 75, 1654 WLAN_EID_MMIE = 76, 1655 WLAN_EID_ASSOC_COMEBACK_TIME = 77, 1656 WLAN_EID_EVENT_REQUEST = 78, 1657 WLAN_EID_EVENT_REPORT = 79, 1658 WLAN_EID_DIAGNOSTIC_REQUEST = 80, 1659 WLAN_EID_DIAGNOSTIC_REPORT = 81, 1660 WLAN_EID_LOCATION_PARAMS = 82, 1661 WLAN_EID_NON_TX_BSSID_CAP = 83, 1662 WLAN_EID_SSID_LIST = 84, 1663 WLAN_EID_MULTI_BSSID_IDX = 85, 1664 WLAN_EID_FMS_DESCRIPTOR = 86, 1665 WLAN_EID_FMS_REQUEST = 87, 1666 WLAN_EID_FMS_RESPONSE = 88, 1667 WLAN_EID_QOS_TRAFFIC_CAPA = 89, 1668 WLAN_EID_BSS_MAX_IDLE_PERIOD = 90, 1669 WLAN_EID_TSF_REQUEST = 91, 1670 WLAN_EID_TSF_RESPOSNE = 92, 1671 WLAN_EID_WNM_SLEEP_MODE = 93, 1672 WLAN_EID_TIM_BCAST_REQ = 94, 1673 WLAN_EID_TIM_BCAST_RESP = 95, 1674 WLAN_EID_COLL_IF_REPORT = 96, 1675 WLAN_EID_CHANNEL_USAGE = 97, 1676 WLAN_EID_TIME_ZONE = 98, 1677 WLAN_EID_DMS_REQUEST = 99, 1678 WLAN_EID_DMS_RESPONSE = 100, 1679 WLAN_EID_LINK_ID = 101, 1680 WLAN_EID_WAKEUP_SCHEDUL = 102, 1681 /* 103 reserved */ 1682 WLAN_EID_CHAN_SWITCH_TIMING = 104, 1683 WLAN_EID_PTI_CONTROL = 105, 1684 WLAN_EID_PU_BUFFER_STATUS = 106, 1685 WLAN_EID_INTERWORKING = 107, 1686 WLAN_EID_ADVERTISEMENT_PROTOCOL = 108, 1687 WLAN_EID_EXPEDITED_BW_REQ = 109, 1688 WLAN_EID_QOS_MAP_SET = 110, 1689 WLAN_EID_ROAMING_CONSORTIUM = 111, 1690 WLAN_EID_EMERGENCY_ALERT = 112, 1691 WLAN_EID_MESH_CONFIG = 113, 1692 WLAN_EID_MESH_ID = 114, 1693 WLAN_EID_LINK_METRIC_REPORT = 115, 1694 WLAN_EID_CONGESTION_NOTIFICATION = 116, 1695 WLAN_EID_PEER_MGMT = 117, 1696 WLAN_EID_CHAN_SWITCH_PARAM = 118, 1697 WLAN_EID_MESH_AWAKE_WINDOW = 119, 1698 WLAN_EID_BEACON_TIMING = 120, 1699 WLAN_EID_MCCAOP_SETUP_REQ = 121, 1700 WLAN_EID_MCCAOP_SETUP_RESP = 122, 1701 WLAN_EID_MCCAOP_ADVERT = 123, 1702 WLAN_EID_MCCAOP_TEARDOWN = 124, 1703 WLAN_EID_GANN = 125, 1704 WLAN_EID_RANN = 126, 1705 WLAN_EID_EXT_CAPABILITY = 127, 1706 /* 128, 129 reserved for Agere */ 1707 WLAN_EID_PREQ = 130, 1708 WLAN_EID_PREP = 131, 1709 WLAN_EID_PERR = 132, 1710 /* 133-136 reserved for Cisco */ 1711 WLAN_EID_PXU = 137, 1712 WLAN_EID_PXUC = 138, 1713 WLAN_EID_AUTH_MESH_PEER_EXCH = 139, 1714 WLAN_EID_MIC = 140, 1715 WLAN_EID_DESTINATION_URI = 141, 1716 WLAN_EID_UAPSD_COEX = 142, 1717 WLAN_EID_WAKEUP_SCHEDULE = 143, 1718 WLAN_EID_EXT_SCHEDULE = 144, 1719 WLAN_EID_STA_AVAILABILITY = 145, 1720 WLAN_EID_DMG_TSPEC = 146, 1721 WLAN_EID_DMG_AT = 147, 1722 WLAN_EID_DMG_CAP = 148, 1723 /* 149 reserved for Cisco */ 1724 WLAN_EID_CISCO_VENDOR_SPECIFIC = 150, 1725 WLAN_EID_DMG_OPERATION = 151, 1726 WLAN_EID_DMG_BSS_PARAM_CHANGE = 152, 1727 WLAN_EID_DMG_BEAM_REFINEMENT = 153, 1728 WLAN_EID_CHANNEL_MEASURE_FEEDBACK = 154, 1729 /* 155-156 reserved for Cisco */ 1730 WLAN_EID_AWAKE_WINDOW = 157, 1731 WLAN_EID_MULTI_BAND = 158, 1732 WLAN_EID_ADDBA_EXT = 159, 1733 WLAN_EID_NEXT_PCP_LIST = 160, 1734 WLAN_EID_PCP_HANDOVER = 161, 1735 WLAN_EID_DMG_LINK_MARGIN = 162, 1736 WLAN_EID_SWITCHING_STREAM = 163, 1737 WLAN_EID_SESSION_TRANSITION = 164, 1738 WLAN_EID_DYN_TONE_PAIRING_REPORT = 165, 1739 WLAN_EID_CLUSTER_REPORT = 166, 1740 WLAN_EID_RELAY_CAP = 167, 1741 WLAN_EID_RELAY_XFER_PARAM_SET = 168, 1742 WLAN_EID_BEAM_LINK_MAINT = 169, 1743 WLAN_EID_MULTIPLE_MAC_ADDR = 170, 1744 WLAN_EID_U_PID = 171, 1745 WLAN_EID_DMG_LINK_ADAPT_ACK = 172, 1746 /* 173 reserved for Symbol */ 1747 WLAN_EID_MCCAOP_ADV_OVERVIEW = 174, 1748 WLAN_EID_QUIET_PERIOD_REQ = 175, 1749 /* 176 reserved for Symbol */ 1750 WLAN_EID_QUIET_PERIOD_RESP = 177, 1751 /* 178-179 reserved for Symbol */ 1752 /* 180 reserved for ISO/IEC 20011 */ 1753 WLAN_EID_EPAC_POLICY = 182, 1754 WLAN_EID_CLISTER_TIME_OFF = 183, 1755 WLAN_EID_INTER_AC_PRIO = 184, 1756 WLAN_EID_SCS_DESCRIPTOR = 185, 1757 WLAN_EID_QLOAD_REPORT = 186, 1758 WLAN_EID_HCCA_TXOP_UPDATE_COUNT = 187, 1759 WLAN_EID_HL_STREAM_ID = 188, 1760 WLAN_EID_GCR_GROUP_ADDR = 189, 1761 WLAN_EID_ANTENNA_SECTOR_ID_PATTERN = 190, 1762 WLAN_EID_VHT_CAPABILITY = 191, 1763 WLAN_EID_VHT_OPERATION = 192, 1764 WLAN_EID_EXTENDED_BSS_LOAD = 193, 1765 WLAN_EID_WIDE_BW_CHANNEL_SWITCH = 194, 1766 WLAN_EID_TX_POWER_ENVELOPE = 195, 1767 WLAN_EID_CHANNEL_SWITCH_WRAPPER = 196, 1768 WLAN_EID_AID = 197, 1769 WLAN_EID_QUIET_CHANNEL = 198, 1770 WLAN_EID_OPMODE_NOTIF = 199, 1771 1772 WLAN_EID_REDUCED_NEIGHBOR_REPORT = 201, 1773 1774 WLAN_EID_AID_REQUEST = 210, 1775 WLAN_EID_AID_RESPONSE = 211, 1776 WLAN_EID_S1G_BCN_COMPAT = 213, 1777 WLAN_EID_S1G_SHORT_BCN_INTERVAL = 214, 1778 WLAN_EID_S1G_TWT = 216, 1779 WLAN_EID_S1G_CAPABILITIES = 217, 1780 WLAN_EID_VENDOR_SPECIFIC = 221, 1781 WLAN_EID_QOS_PARAMETER = 222, 1782 WLAN_EID_S1G_OPERATION = 232, 1783 WLAN_EID_CAG_NUMBER = 237, 1784 WLAN_EID_AP_CSN = 239, 1785 WLAN_EID_FILS_INDICATION = 240, 1786 WLAN_EID_DILS = 241, 1787 WLAN_EID_FRAGMENT = 242, 1788 WLAN_EID_RSNX = 244, 1789 WLAN_EID_EXTENSION = 255 1790 }; 1791 1792 /* Element ID Extensions for Element ID 255 */ 1793 enum ieee80211_eid_ext { 1794 WLAN_EID_EXT_ASSOC_DELAY_INFO = 1, 1795 WLAN_EID_EXT_FILS_REQ_PARAMS = 2, 1796 WLAN_EID_EXT_FILS_KEY_CONFIRM = 3, 1797 WLAN_EID_EXT_FILS_SESSION = 4, 1798 WLAN_EID_EXT_FILS_HLP_CONTAINER = 5, 1799 WLAN_EID_EXT_FILS_IP_ADDR_ASSIGN = 6, 1800 WLAN_EID_EXT_KEY_DELIVERY = 7, 1801 WLAN_EID_EXT_FILS_WRAPPED_DATA = 8, 1802 WLAN_EID_EXT_FILS_PUBLIC_KEY = 12, 1803 WLAN_EID_EXT_FILS_NONCE = 13, 1804 WLAN_EID_EXT_FUTURE_CHAN_GUIDANCE = 14, 1805 WLAN_EID_EXT_DH_PARAMETER = 32, 1806 WLAN_EID_EXT_HE_CAPABILITY = 35, 1807 WLAN_EID_EXT_HE_OPERATION = 36, 1808 WLAN_EID_EXT_UORA = 37, 1809 WLAN_EID_EXT_HE_MU_EDCA = 38, 1810 WLAN_EID_EXT_HE_SPR = 39, 1811 WLAN_EID_EXT_NDP_FEEDBACK_REPORT_PARAMSET = 41, 1812 WLAN_EID_EXT_BSS_COLOR_CHG_ANN = 42, 1813 WLAN_EID_EXT_QUIET_TIME_PERIOD_SETUP = 43, 1814 WLAN_EID_EXT_ESS_REPORT = 45, 1815 WLAN_EID_EXT_OPS = 46, 1816 WLAN_EID_EXT_HE_BSS_LOAD = 47, 1817 WLAN_EID_EXT_MAX_CHANNEL_SWITCH_TIME = 52, 1818 WLAN_EID_EXT_MULTIPLE_BSSID_CONFIGURATION = 55, 1819 WLAN_EID_EXT_NON_INHERITANCE = 56, 1820 WLAN_EID_EXT_KNOWN_BSSID = 57, 1821 WLAN_EID_EXT_SHORT_SSID_LIST = 58, 1822 WLAN_EID_EXT_HE_6GHZ_CAPA = 59, 1823 WLAN_EID_EXT_UL_MU_POWER_CAPA = 60, 1824 WLAN_EID_EXT_EHT_OPERATION = 106, 1825 WLAN_EID_EXT_EHT_MULTI_LINK = 107, 1826 WLAN_EID_EXT_EHT_CAPABILITY = 108, 1827 WLAN_EID_EXT_TID_TO_LINK_MAPPING = 109, 1828 WLAN_EID_EXT_BANDWIDTH_INDICATION = 135, 1829 WLAN_EID_EXT_KNOWN_STA_IDENTIFCATION = 136, 1830 WLAN_EID_EXT_NON_AP_STA_REG_CON = 137, 1831 WLAN_EID_EXT_CIP_CAPA = 150, 1832 WLAN_EID_EXT_UHR_OPER = 151, 1833 WLAN_EID_EXT_UHR_CAPA = 152, 1834 WLAN_EID_EXT_MACP = 153, 1835 WLAN_EID_EXT_SMD = 154, 1836 WLAN_EID_EXT_BSS_SMD_TRANS_PARAMS = 155, 1837 WLAN_EID_EXT_CHAN_USAGE = 156, 1838 WLAN_EID_EXT_UHR_MODE_CHG = 157, 1839 WLAN_EID_EXT_UHR_PARAM_UPD = 158, 1840 WLAN_EID_EXT_TXPI = 159, 1841 }; 1842 1843 /* Action category code */ 1844 enum ieee80211_category { 1845 WLAN_CATEGORY_SPECTRUM_MGMT = 0, 1846 WLAN_CATEGORY_QOS = 1, 1847 WLAN_CATEGORY_DLS = 2, 1848 WLAN_CATEGORY_BACK = 3, 1849 WLAN_CATEGORY_PUBLIC = 4, 1850 WLAN_CATEGORY_RADIO_MEASUREMENT = 5, 1851 WLAN_CATEGORY_FAST_BBS_TRANSITION = 6, 1852 WLAN_CATEGORY_HT = 7, 1853 WLAN_CATEGORY_SA_QUERY = 8, 1854 WLAN_CATEGORY_PROTECTED_DUAL_OF_ACTION = 9, 1855 WLAN_CATEGORY_WNM = 10, 1856 WLAN_CATEGORY_WNM_UNPROTECTED = 11, 1857 WLAN_CATEGORY_TDLS = 12, 1858 WLAN_CATEGORY_MESH_ACTION = 13, 1859 WLAN_CATEGORY_MULTIHOP_ACTION = 14, 1860 WLAN_CATEGORY_SELF_PROTECTED = 15, 1861 WLAN_CATEGORY_DMG = 16, 1862 WLAN_CATEGORY_WMM = 17, 1863 WLAN_CATEGORY_FST = 18, 1864 WLAN_CATEGORY_UNPROT_DMG = 20, 1865 WLAN_CATEGORY_VHT = 21, 1866 WLAN_CATEGORY_S1G = 22, 1867 WLAN_CATEGORY_PROTECTED_EHT = 37, 1868 WLAN_CATEGORY_PROTECTED_UHR = 43, 1869 WLAN_CATEGORY_VENDOR_SPECIFIC_PROTECTED = 126, 1870 WLAN_CATEGORY_VENDOR_SPECIFIC = 127, 1871 }; 1872 1873 /* SPECTRUM_MGMT action code */ 1874 enum ieee80211_spectrum_mgmt_actioncode { 1875 WLAN_ACTION_SPCT_MSR_REQ = 0, 1876 WLAN_ACTION_SPCT_MSR_RPRT = 1, 1877 WLAN_ACTION_SPCT_TPC_REQ = 2, 1878 WLAN_ACTION_SPCT_TPC_RPRT = 3, 1879 WLAN_ACTION_SPCT_CHL_SWITCH = 4, 1880 }; 1881 1882 /* Self Protected Action codes */ 1883 enum ieee80211_self_protected_actioncode { 1884 WLAN_SP_RESERVED = 0, 1885 WLAN_SP_MESH_PEERING_OPEN = 1, 1886 WLAN_SP_MESH_PEERING_CONFIRM = 2, 1887 WLAN_SP_MESH_PEERING_CLOSE = 3, 1888 WLAN_SP_MGK_INFORM = 4, 1889 WLAN_SP_MGK_ACK = 5, 1890 }; 1891 1892 /* Unprotected WNM action codes */ 1893 enum ieee80211_unprotected_wnm_actioncode { 1894 WLAN_UNPROTECTED_WNM_ACTION_TIM = 0, 1895 WLAN_UNPROTECTED_WNM_ACTION_TIMING_MEASUREMENT_RESPONSE = 1, 1896 }; 1897 1898 /* Security key length */ 1899 enum ieee80211_key_len { 1900 WLAN_KEY_LEN_WEP40 = 5, 1901 WLAN_KEY_LEN_WEP104 = 13, 1902 WLAN_KEY_LEN_CCMP = 16, 1903 WLAN_KEY_LEN_CCMP_256 = 32, 1904 WLAN_KEY_LEN_TKIP = 32, 1905 WLAN_KEY_LEN_AES_CMAC = 16, 1906 WLAN_KEY_LEN_SMS4 = 32, 1907 WLAN_KEY_LEN_GCMP = 16, 1908 WLAN_KEY_LEN_GCMP_256 = 32, 1909 WLAN_KEY_LEN_BIP_CMAC_256 = 32, 1910 WLAN_KEY_LEN_BIP_GMAC_128 = 16, 1911 WLAN_KEY_LEN_BIP_GMAC_256 = 32, 1912 }; 1913 1914 /* Radio measurement action codes as defined in IEEE 802.11-2024 - Table 9-470 */ 1915 enum ieee80211_radio_measurement_actioncode { 1916 WLAN_RM_ACTION_RADIO_MEASUREMENT_REQUEST = 0, 1917 WLAN_RM_ACTION_RADIO_MEASUREMENT_REPORT = 1, 1918 WLAN_RM_ACTION_LINK_MEASUREMENT_REQUEST = 2, 1919 WLAN_RM_ACTION_LINK_MEASUREMENT_REPORT = 3, 1920 WLAN_RM_ACTION_NEIGHBOR_REPORT_REQUEST = 4, 1921 WLAN_RM_ACTION_NEIGHBOR_REPORT_RESPONSE = 5, 1922 }; 1923 1924 #define IEEE80211_WEP_IV_LEN 4 1925 #define IEEE80211_WEP_ICV_LEN 4 1926 #define IEEE80211_CCMP_HDR_LEN 8 1927 #define IEEE80211_CCMP_MIC_LEN 8 1928 #define IEEE80211_CCMP_PN_LEN 6 1929 #define IEEE80211_CCMP_256_HDR_LEN 8 1930 #define IEEE80211_CCMP_256_MIC_LEN 16 1931 #define IEEE80211_CCMP_256_PN_LEN 6 1932 #define IEEE80211_TKIP_IV_LEN 8 1933 #define IEEE80211_TKIP_ICV_LEN 4 1934 #define IEEE80211_CMAC_PN_LEN 6 1935 #define IEEE80211_GMAC_PN_LEN 6 1936 #define IEEE80211_GCMP_HDR_LEN 8 1937 #define IEEE80211_GCMP_MIC_LEN 16 1938 #define IEEE80211_GCMP_PN_LEN 6 1939 #define IEEE80211_CMAC_128_MIC_LEN 8 1940 #define IEEE80211_CMAC_256_MIC_LEN 16 1941 #define IEEE80211_GMAC_MIC_LEN 16 1942 1943 #define FILS_NONCE_LEN 16 1944 #define FILS_MAX_KEK_LEN 64 1945 1946 #define FILS_ERP_MAX_USERNAME_LEN 16 1947 #define FILS_ERP_MAX_REALM_LEN 253 1948 #define FILS_ERP_MAX_RRK_LEN 64 1949 1950 #define PMK_MAX_LEN 64 1951 #define SAE_PASSWORD_MAX_LEN 128 1952 1953 #define MICHAEL_MIC_LEN 8 1954 1955 void michael_mic(const u8 *key, struct ieee80211_hdr *hdr, 1956 const u8 *data, size_t data_len, u8 *mic); 1957 1958 /* Public action codes (IEEE Std 802.11-2016, 9.6.8.1, Table 9-307) */ 1959 enum ieee80211_pub_actioncode { 1960 WLAN_PUB_ACTION_20_40_BSS_COEX = 0, 1961 WLAN_PUB_ACTION_DSE_ENABLEMENT = 1, 1962 WLAN_PUB_ACTION_DSE_DEENABLEMENT = 2, 1963 WLAN_PUB_ACTION_DSE_REG_LOC_ANN = 3, 1964 WLAN_PUB_ACTION_EXT_CHANSW_ANN = 4, 1965 WLAN_PUB_ACTION_DSE_MSMT_REQ = 5, 1966 WLAN_PUB_ACTION_DSE_MSMT_RESP = 6, 1967 WLAN_PUB_ACTION_MSMT_PILOT = 7, 1968 WLAN_PUB_ACTION_DSE_PC = 8, 1969 WLAN_PUB_ACTION_VENDOR_SPECIFIC = 9, 1970 WLAN_PUB_ACTION_GAS_INITIAL_REQ = 10, 1971 WLAN_PUB_ACTION_GAS_INITIAL_RESP = 11, 1972 WLAN_PUB_ACTION_GAS_COMEBACK_REQ = 12, 1973 WLAN_PUB_ACTION_GAS_COMEBACK_RESP = 13, 1974 WLAN_PUB_ACTION_TDLS_DISCOVER_RES = 14, 1975 WLAN_PUB_ACTION_LOC_TRACK_NOTI = 15, 1976 WLAN_PUB_ACTION_QAB_REQUEST_FRAME = 16, 1977 WLAN_PUB_ACTION_QAB_RESPONSE_FRAME = 17, 1978 WLAN_PUB_ACTION_QMF_POLICY = 18, 1979 WLAN_PUB_ACTION_QMF_POLICY_CHANGE = 19, 1980 WLAN_PUB_ACTION_QLOAD_REQUEST = 20, 1981 WLAN_PUB_ACTION_QLOAD_REPORT = 21, 1982 WLAN_PUB_ACTION_HCCA_TXOP_ADVERT = 22, 1983 WLAN_PUB_ACTION_HCCA_TXOP_RESPONSE = 23, 1984 WLAN_PUB_ACTION_PUBLIC_KEY = 24, 1985 WLAN_PUB_ACTION_CHANNEL_AVAIL_QUERY = 25, 1986 WLAN_PUB_ACTION_CHANNEL_SCHEDULE_MGMT = 26, 1987 WLAN_PUB_ACTION_CONTACT_VERI_SIGNAL = 27, 1988 WLAN_PUB_ACTION_GDD_ENABLEMENT_REQ = 28, 1989 WLAN_PUB_ACTION_GDD_ENABLEMENT_RESP = 29, 1990 WLAN_PUB_ACTION_NETWORK_CHANNEL_CONTROL = 30, 1991 WLAN_PUB_ACTION_WHITE_SPACE_MAP_ANN = 31, 1992 WLAN_PUB_ACTION_FTM_REQUEST = 32, 1993 WLAN_PUB_ACTION_FTM_RESPONSE = 33, 1994 WLAN_PUB_ACTION_FILS_DISCOVERY = 34, 1995 }; 1996 1997 /* TDLS action codes */ 1998 enum ieee80211_tdls_actioncode { 1999 WLAN_TDLS_SETUP_REQUEST = 0, 2000 WLAN_TDLS_SETUP_RESPONSE = 1, 2001 WLAN_TDLS_SETUP_CONFIRM = 2, 2002 WLAN_TDLS_TEARDOWN = 3, 2003 WLAN_TDLS_PEER_TRAFFIC_INDICATION = 4, 2004 WLAN_TDLS_CHANNEL_SWITCH_REQUEST = 5, 2005 WLAN_TDLS_CHANNEL_SWITCH_RESPONSE = 6, 2006 WLAN_TDLS_PEER_PSM_REQUEST = 7, 2007 WLAN_TDLS_PEER_PSM_RESPONSE = 8, 2008 WLAN_TDLS_PEER_TRAFFIC_RESPONSE = 9, 2009 WLAN_TDLS_DISCOVERY_REQUEST = 10, 2010 }; 2011 2012 /* Extended Channel Switching capability to be set in the 1st byte of 2013 * the @WLAN_EID_EXT_CAPABILITY information element 2014 */ 2015 #define WLAN_EXT_CAPA1_EXT_CHANNEL_SWITCHING BIT(2) 2016 2017 /* Multiple BSSID capability is set in the 6th bit of 3rd byte of the 2018 * @WLAN_EID_EXT_CAPABILITY information element 2019 */ 2020 #define WLAN_EXT_CAPA3_MULTI_BSSID_SUPPORT BIT(6) 2021 2022 /* Timing Measurement protocol for time sync is set in the 7th bit of 3rd byte 2023 * of the @WLAN_EID_EXT_CAPABILITY information element 2024 */ 2025 #define WLAN_EXT_CAPA3_TIMING_MEASUREMENT_SUPPORT BIT(7) 2026 2027 /* TDLS capabilities in the 4th byte of @WLAN_EID_EXT_CAPABILITY */ 2028 #define WLAN_EXT_CAPA4_TDLS_BUFFER_STA BIT(4) 2029 #define WLAN_EXT_CAPA4_TDLS_PEER_PSM BIT(5) 2030 #define WLAN_EXT_CAPA4_TDLS_CHAN_SWITCH BIT(6) 2031 2032 /* Interworking capabilities are set in 7th bit of 4th byte of the 2033 * @WLAN_EID_EXT_CAPABILITY information element 2034 */ 2035 #define WLAN_EXT_CAPA4_INTERWORKING_ENABLED BIT(7) 2036 2037 /* 2038 * TDLS capabililites to be enabled in the 5th byte of the 2039 * @WLAN_EID_EXT_CAPABILITY information element 2040 */ 2041 #define WLAN_EXT_CAPA5_TDLS_ENABLED BIT(5) 2042 #define WLAN_EXT_CAPA5_TDLS_PROHIBITED BIT(6) 2043 #define WLAN_EXT_CAPA5_TDLS_CH_SW_PROHIBITED BIT(7) 2044 2045 #define WLAN_EXT_CAPA8_TDLS_WIDE_BW_ENABLED BIT(5) 2046 #define WLAN_EXT_CAPA8_OPMODE_NOTIF BIT(6) 2047 2048 /* Defines the maximal number of MSDUs in an A-MSDU. */ 2049 #define WLAN_EXT_CAPA8_MAX_MSDU_IN_AMSDU_LSB BIT(7) 2050 #define WLAN_EXT_CAPA9_MAX_MSDU_IN_AMSDU_MSB BIT(0) 2051 2052 /* 2053 * Fine Timing Measurement Initiator - bit 71 of @WLAN_EID_EXT_CAPABILITY 2054 * information element 2055 */ 2056 #define WLAN_EXT_CAPA9_FTM_INITIATOR BIT(7) 2057 2058 /* Defines support for TWT Requester and TWT Responder */ 2059 #define WLAN_EXT_CAPA10_TWT_REQUESTER_SUPPORT BIT(5) 2060 #define WLAN_EXT_CAPA10_TWT_RESPONDER_SUPPORT BIT(6) 2061 2062 /* 2063 * When set, indicates that the AP is able to tolerate 26-tone RU UL 2064 * OFDMA transmissions using HE TB PPDU from OBSS (not falsely classify the 2065 * 26-tone RU UL OFDMA transmissions as radar pulses). 2066 */ 2067 #define WLAN_EXT_CAPA10_OBSS_NARROW_BW_RU_TOLERANCE_SUPPORT BIT(7) 2068 2069 /* Defines support for enhanced multi-bssid advertisement*/ 2070 #define WLAN_EXT_CAPA11_EMA_SUPPORT BIT(3) 2071 2072 /* Enable Beacon Protection */ 2073 #define WLAN_EXT_CAPA11_BCN_PROTECT BIT(4) 2074 2075 /* TDLS specific payload type in the LLC/SNAP header */ 2076 #define WLAN_TDLS_SNAP_RFTYPE 0x2 2077 2078 /* BSS Coex IE information field bits */ 2079 #define WLAN_BSS_COEX_INFORMATION_REQUEST BIT(0) 2080 2081 /* 2082 * IEEE 802.11-2007 7.3.2.9 Country information element 2083 * 2084 * Minimum length is 8 octets, ie len must be evenly 2085 * divisible by 2 2086 */ 2087 2088 /* Although the spec says 8 I'm seeing 6 in practice */ 2089 #define IEEE80211_COUNTRY_IE_MIN_LEN 6 2090 2091 /* The Country String field of the element shall be 3 octets in length */ 2092 #define IEEE80211_COUNTRY_STRING_LEN 3 2093 2094 /* 2095 * For regulatory extension stuff see IEEE 802.11-2007 2096 * Annex I (page 1141) and Annex J (page 1147). Also 2097 * review 7.3.2.9. 2098 * 2099 * When dot11RegulatoryClassesRequired is true and the 2100 * first_channel/reg_extension_id is >= 201 then the IE 2101 * compromises of the 'ext' struct represented below: 2102 * 2103 * - Regulatory extension ID - when generating IE this just needs 2104 * to be monotonically increasing for each triplet passed in 2105 * the IE 2106 * - Regulatory class - index into set of rules 2107 * - Coverage class - index into air propagation time (Table 7-27), 2108 * in microseconds, you can compute the air propagation time from 2109 * the index by multiplying by 3, so index 10 yields a propagation 2110 * of 10 us. Valid values are 0-31, values 32-255 are not defined 2111 * yet. A value of 0 inicates air propagation of <= 1 us. 2112 * 2113 * See also Table I.2 for Emission limit sets and table 2114 * I.3 for Behavior limit sets. Table J.1 indicates how to map 2115 * a reg_class to an emission limit set and behavior limit set. 2116 */ 2117 #define IEEE80211_COUNTRY_EXTENSION_ID 201 2118 2119 /* 2120 * Channels numbers in the IE must be monotonically increasing 2121 * if dot11RegulatoryClassesRequired is not true. 2122 * 2123 * If dot11RegulatoryClassesRequired is true consecutive 2124 * subband triplets following a regulatory triplet shall 2125 * have monotonically increasing first_channel number fields. 2126 * 2127 * Channel numbers shall not overlap. 2128 * 2129 * Note that max_power is signed. 2130 */ 2131 struct ieee80211_country_ie_triplet { 2132 union { 2133 struct { 2134 u8 first_channel; 2135 u8 num_channels; 2136 s8 max_power; 2137 } __packed chans; 2138 struct { 2139 u8 reg_extension_id; 2140 u8 reg_class; 2141 u8 coverage_class; 2142 } __packed ext; 2143 }; 2144 } __packed; 2145 2146 enum ieee80211_timeout_interval_type { 2147 WLAN_TIMEOUT_REASSOC_DEADLINE = 1 /* 802.11r */, 2148 WLAN_TIMEOUT_KEY_LIFETIME = 2 /* 802.11r */, 2149 WLAN_TIMEOUT_ASSOC_COMEBACK = 3 /* 802.11w */, 2150 }; 2151 2152 /** 2153 * struct ieee80211_timeout_interval_ie - Timeout Interval element 2154 * @type: type, see &enum ieee80211_timeout_interval_type 2155 * @value: timeout interval value 2156 */ 2157 struct ieee80211_timeout_interval_ie { 2158 u8 type; 2159 __le32 value; 2160 } __packed; 2161 2162 /** 2163 * enum ieee80211_idle_options - BSS idle options 2164 * @WLAN_IDLE_OPTIONS_PROTECTED_KEEP_ALIVE: the station should send an RSN 2165 * protected frame to the AP to reset the idle timer at the AP for 2166 * the station. 2167 */ 2168 enum ieee80211_idle_options { 2169 WLAN_IDLE_OPTIONS_PROTECTED_KEEP_ALIVE = BIT(0), 2170 }; 2171 2172 /** 2173 * struct ieee80211_bss_max_idle_period_ie - BSS max idle period element struct 2174 * 2175 * This structure refers to "BSS Max idle period element" 2176 * 2177 * @max_idle_period: indicates the time period during which a station can 2178 * refrain from transmitting frames to its associated AP without being 2179 * disassociated. In units of 1000 TUs. 2180 * @idle_options: indicates the options associated with the BSS idle capability 2181 * as specified in &enum ieee80211_idle_options. 2182 */ 2183 struct ieee80211_bss_max_idle_period_ie { 2184 __le16 max_idle_period; 2185 u8 idle_options; 2186 } __packed; 2187 2188 /* SA Query action */ 2189 enum ieee80211_sa_query_action { 2190 WLAN_ACTION_SA_QUERY_REQUEST = 0, 2191 WLAN_ACTION_SA_QUERY_RESPONSE = 1, 2192 }; 2193 2194 /** 2195 * struct ieee80211_bssid_index - multiple BSSID index element structure 2196 * 2197 * This structure refers to "Multiple BSSID-index element" 2198 * 2199 * @bssid_index: BSSID index 2200 * @dtim_period: optional, overrides transmitted BSS dtim period 2201 * @dtim_count: optional, overrides transmitted BSS dtim count 2202 */ 2203 struct ieee80211_bssid_index { 2204 u8 bssid_index; 2205 u8 dtim_period; 2206 u8 dtim_count; 2207 }; 2208 2209 /** 2210 * struct ieee80211_multiple_bssid_configuration - multiple BSSID configuration 2211 * element structure 2212 * 2213 * This structure refers to "Multiple BSSID Configuration element" 2214 * 2215 * @bssid_count: total number of active BSSIDs in the set 2216 * @profile_periodicity: the least number of beacon frames need to be received 2217 * in order to discover all the nontransmitted BSSIDs in the set. 2218 */ 2219 struct ieee80211_multiple_bssid_configuration { 2220 u8 bssid_count; 2221 u8 profile_periodicity; 2222 }; 2223 2224 #define SUITE(oui, id) (((oui) << 8) | (id)) 2225 2226 /* cipher suite selectors */ 2227 #define WLAN_CIPHER_SUITE_USE_GROUP SUITE(0x000FAC, 0) 2228 #define WLAN_CIPHER_SUITE_WEP40 SUITE(0x000FAC, 1) 2229 #define WLAN_CIPHER_SUITE_TKIP SUITE(0x000FAC, 2) 2230 /* reserved: SUITE(0x000FAC, 3) */ 2231 #define WLAN_CIPHER_SUITE_CCMP SUITE(0x000FAC, 4) 2232 #define WLAN_CIPHER_SUITE_WEP104 SUITE(0x000FAC, 5) 2233 #define WLAN_CIPHER_SUITE_AES_CMAC SUITE(0x000FAC, 6) 2234 #define WLAN_CIPHER_SUITE_GCMP SUITE(0x000FAC, 8) 2235 #define WLAN_CIPHER_SUITE_GCMP_256 SUITE(0x000FAC, 9) 2236 #define WLAN_CIPHER_SUITE_CCMP_256 SUITE(0x000FAC, 10) 2237 #define WLAN_CIPHER_SUITE_BIP_GMAC_128 SUITE(0x000FAC, 11) 2238 #define WLAN_CIPHER_SUITE_BIP_GMAC_256 SUITE(0x000FAC, 12) 2239 #define WLAN_CIPHER_SUITE_BIP_CMAC_256 SUITE(0x000FAC, 13) 2240 2241 #define WLAN_CIPHER_SUITE_SMS4 SUITE(0x001472, 1) 2242 2243 /* AKM suite selectors */ 2244 #define WLAN_AKM_SUITE_8021X SUITE(0x000FAC, 1) 2245 #define WLAN_AKM_SUITE_PSK SUITE(0x000FAC, 2) 2246 #define WLAN_AKM_SUITE_FT_8021X SUITE(0x000FAC, 3) 2247 #define WLAN_AKM_SUITE_FT_PSK SUITE(0x000FAC, 4) 2248 #define WLAN_AKM_SUITE_8021X_SHA256 SUITE(0x000FAC, 5) 2249 #define WLAN_AKM_SUITE_PSK_SHA256 SUITE(0x000FAC, 6) 2250 #define WLAN_AKM_SUITE_TDLS SUITE(0x000FAC, 7) 2251 #define WLAN_AKM_SUITE_SAE SUITE(0x000FAC, 8) 2252 #define WLAN_AKM_SUITE_FT_OVER_SAE SUITE(0x000FAC, 9) 2253 #define WLAN_AKM_SUITE_AP_PEER_KEY SUITE(0x000FAC, 10) 2254 #define WLAN_AKM_SUITE_8021X_SUITE_B SUITE(0x000FAC, 11) 2255 #define WLAN_AKM_SUITE_8021X_SUITE_B_192 SUITE(0x000FAC, 12) 2256 #define WLAN_AKM_SUITE_FT_8021X_SHA384 SUITE(0x000FAC, 13) 2257 #define WLAN_AKM_SUITE_FILS_SHA256 SUITE(0x000FAC, 14) 2258 #define WLAN_AKM_SUITE_FILS_SHA384 SUITE(0x000FAC, 15) 2259 #define WLAN_AKM_SUITE_FT_FILS_SHA256 SUITE(0x000FAC, 16) 2260 #define WLAN_AKM_SUITE_FT_FILS_SHA384 SUITE(0x000FAC, 17) 2261 #define WLAN_AKM_SUITE_OWE SUITE(0x000FAC, 18) 2262 #define WLAN_AKM_SUITE_FT_PSK_SHA384 SUITE(0x000FAC, 19) 2263 #define WLAN_AKM_SUITE_PSK_SHA384 SUITE(0x000FAC, 20) 2264 2265 #define WLAN_AKM_SUITE_WFA_DPP SUITE(WLAN_OUI_WFA, 2) 2266 2267 #define WLAN_MAX_KEY_LEN 32 2268 #define WLAN_MAX_SECURE_LTF_KEYSEED_LEN 48 2269 2270 #define WLAN_PMK_NAME_LEN 16 2271 #define WLAN_PMKID_LEN 16 2272 #define WLAN_PMK_LEN_EAP_LEAP 16 2273 #define WLAN_PMK_LEN 32 2274 #define WLAN_PMK_LEN_SUITE_B_192 48 2275 2276 #define WLAN_OUI_WFA 0x506f9a 2277 #define WLAN_OUI_TYPE_WFA_P2P 9 2278 #define WLAN_OUI_TYPE_WFA_NAN 0x13 2279 #define WLAN_OUI_TYPE_WFA_DPP 0x1A 2280 #define WLAN_OUI_MICROSOFT 0x0050f2 2281 #define WLAN_OUI_TYPE_MICROSOFT_WPA 1 2282 #define WLAN_OUI_TYPE_MICROSOFT_WMM 2 2283 #define WLAN_OUI_TYPE_MICROSOFT_WPS 4 2284 #define WLAN_OUI_TYPE_MICROSOFT_TPC 8 2285 2286 /* 2287 * WMM/802.11e Tspec Element 2288 */ 2289 #define IEEE80211_WMM_IE_TSPEC_TID_MASK 0x0F 2290 #define IEEE80211_WMM_IE_TSPEC_TID_SHIFT 1 2291 2292 enum ieee80211_tspec_status_code { 2293 IEEE80211_TSPEC_STATUS_ADMISS_ACCEPTED = 0, 2294 IEEE80211_TSPEC_STATUS_ADDTS_INVAL_PARAMS = 0x1, 2295 }; 2296 2297 struct ieee80211_tspec_ie { 2298 u8 element_id; 2299 u8 len; 2300 u8 oui[3]; 2301 u8 oui_type; 2302 u8 oui_subtype; 2303 u8 version; 2304 __le16 tsinfo; 2305 u8 tsinfo_resvd; 2306 __le16 nominal_msdu; 2307 __le16 max_msdu; 2308 __le32 min_service_int; 2309 __le32 max_service_int; 2310 __le32 inactivity_int; 2311 __le32 suspension_int; 2312 __le32 service_start_time; 2313 __le32 min_data_rate; 2314 __le32 mean_data_rate; 2315 __le32 peak_data_rate; 2316 __le32 max_burst_size; 2317 __le32 delay_bound; 2318 __le32 min_phy_rate; 2319 __le16 sba; 2320 __le16 medium_time; 2321 } __packed; 2322 2323 /** 2324 * ieee80211_get_qos_ctl - get pointer to qos control bytes 2325 * @hdr: the frame 2326 * Return: a pointer to the QoS control field in the frame header 2327 * 2328 * The qos ctrl bytes come after the frame_control, duration, seq_num 2329 * and 3 or 4 addresses of length ETH_ALEN. Checks frame_control to choose 2330 * between struct ieee80211_qos_hdr_4addr and struct ieee80211_qos_hdr. 2331 */ 2332 static inline u8 *ieee80211_get_qos_ctl(struct ieee80211_hdr *hdr) 2333 { 2334 union { 2335 struct ieee80211_qos_hdr addr3; 2336 struct ieee80211_qos_hdr_4addr addr4; 2337 } *qos; 2338 2339 qos = (void *)hdr; 2340 if (ieee80211_has_a4(qos->addr3.frame_control)) 2341 return (u8 *)&qos->addr4.qos_ctrl; 2342 else 2343 return (u8 *)&qos->addr3.qos_ctrl; 2344 } 2345 2346 /** 2347 * ieee80211_get_tid - get qos TID 2348 * @hdr: the frame 2349 * Return: the TID from the QoS control field 2350 */ 2351 static inline u8 ieee80211_get_tid(struct ieee80211_hdr *hdr) 2352 { 2353 u8 *qc = ieee80211_get_qos_ctl(hdr); 2354 2355 return qc[0] & IEEE80211_QOS_CTL_TID_MASK; 2356 } 2357 2358 /** 2359 * ieee80211_get_SA - get pointer to SA 2360 * @hdr: the frame 2361 * Return: a pointer to the source address (SA) 2362 * 2363 * Given an 802.11 frame, this function returns the offset 2364 * to the source address (SA). It does not verify that the 2365 * header is long enough to contain the address, and the 2366 * header must be long enough to contain the frame control 2367 * field. 2368 */ 2369 static inline u8 *ieee80211_get_SA(struct ieee80211_hdr *hdr) 2370 { 2371 if (ieee80211_has_a4(hdr->frame_control)) 2372 return hdr->addr4; 2373 if (ieee80211_has_fromds(hdr->frame_control)) 2374 return hdr->addr3; 2375 return hdr->addr2; 2376 } 2377 2378 /** 2379 * ieee80211_get_DA - get pointer to DA 2380 * @hdr: the frame 2381 * Return: a pointer to the destination address (DA) 2382 * 2383 * Given an 802.11 frame, this function returns the offset 2384 * to the destination address (DA). It does not verify that 2385 * the header is long enough to contain the address, and the 2386 * header must be long enough to contain the frame control 2387 * field. 2388 */ 2389 static inline u8 *ieee80211_get_DA(struct ieee80211_hdr *hdr) 2390 { 2391 if (ieee80211_has_tods(hdr->frame_control)) 2392 return hdr->addr3; 2393 else 2394 return hdr->addr1; 2395 } 2396 2397 /** 2398 * ieee80211_is_bufferable_mmpdu - check if frame is bufferable MMPDU 2399 * @skb: the skb to check, starting with the 802.11 header 2400 * Return: whether or not the MMPDU is bufferable 2401 */ 2402 static inline bool ieee80211_is_bufferable_mmpdu(struct sk_buff *skb) 2403 { 2404 struct ieee80211_mgmt *mgmt = (void *)skb->data; 2405 __le16 fc = mgmt->frame_control; 2406 2407 /* 2408 * IEEE 802.11 REVme D2.0 definition of bufferable MMPDU; 2409 * note that this ignores the IBSS special case. 2410 */ 2411 if (!ieee80211_is_mgmt(fc)) 2412 return false; 2413 2414 if (ieee80211_is_disassoc(fc) || ieee80211_is_deauth(fc)) 2415 return true; 2416 2417 if (!ieee80211_is_action(fc)) 2418 return false; 2419 2420 if (skb->len < IEEE80211_MIN_ACTION_SIZE(action_code)) 2421 return true; 2422 2423 /* action frame - additionally check for non-bufferable FTM */ 2424 2425 if (mgmt->u.action.category != WLAN_CATEGORY_PUBLIC) 2426 return true; 2427 2428 if (mgmt->u.action.action_code == WLAN_PUB_ACTION_FTM_REQUEST || 2429 mgmt->u.action.action_code == WLAN_PUB_ACTION_FTM_RESPONSE) 2430 return false; 2431 2432 return true; 2433 } 2434 2435 /** 2436 * _ieee80211_is_robust_mgmt_frame - check if frame is a robust management frame 2437 * @hdr: the frame (buffer must include at least the first octet of payload) 2438 * Return: whether or not the frame is a robust management frame 2439 */ 2440 static inline bool _ieee80211_is_robust_mgmt_frame(struct ieee80211_hdr *hdr) 2441 { 2442 if (ieee80211_is_disassoc(hdr->frame_control) || 2443 ieee80211_is_deauth(hdr->frame_control)) 2444 return true; 2445 2446 if (ieee80211_is_action(hdr->frame_control)) { 2447 u8 *category; 2448 2449 /* 2450 * Action frames, excluding Public Action frames, are Robust 2451 * Management Frames. However, if we are looking at a Protected 2452 * frame, skip the check since the data may be encrypted and 2453 * the frame has already been found to be a Robust Management 2454 * Frame (by the other end). 2455 */ 2456 if (ieee80211_has_protected(hdr->frame_control)) 2457 return true; 2458 category = ((u8 *) hdr) + 24; 2459 return *category != WLAN_CATEGORY_PUBLIC && 2460 *category != WLAN_CATEGORY_HT && 2461 *category != WLAN_CATEGORY_WNM_UNPROTECTED && 2462 *category != WLAN_CATEGORY_SELF_PROTECTED && 2463 *category != WLAN_CATEGORY_UNPROT_DMG && 2464 *category != WLAN_CATEGORY_VHT && 2465 *category != WLAN_CATEGORY_S1G && 2466 *category != WLAN_CATEGORY_VENDOR_SPECIFIC; 2467 } 2468 2469 return false; 2470 } 2471 2472 /** 2473 * ieee80211_is_robust_mgmt_frame - check if skb contains a robust mgmt frame 2474 * @skb: the skb containing the frame, length will be checked 2475 * Return: whether or not the frame is a robust management frame 2476 */ 2477 static inline bool ieee80211_is_robust_mgmt_frame(struct sk_buff *skb) 2478 { 2479 if (skb->len < IEEE80211_MIN_ACTION_SIZE(category)) 2480 return false; 2481 return _ieee80211_is_robust_mgmt_frame((void *)skb->data); 2482 } 2483 2484 /** 2485 * ieee80211_is_public_action - check if frame is a public action frame 2486 * @hdr: the frame 2487 * @len: length of the frame 2488 * Return: whether or not the frame is a public action frame 2489 */ 2490 static inline bool ieee80211_is_public_action(struct ieee80211_hdr *hdr, 2491 size_t len) 2492 { 2493 struct ieee80211_mgmt *mgmt = (void *)hdr; 2494 2495 if (len < IEEE80211_MIN_ACTION_SIZE(category)) 2496 return false; 2497 if (!ieee80211_is_action(hdr->frame_control)) 2498 return false; 2499 return mgmt->u.action.category == WLAN_CATEGORY_PUBLIC; 2500 } 2501 2502 /** 2503 * ieee80211_is_protected_dual_of_public_action - check if skb contains a 2504 * protected dual of public action management frame 2505 * @skb: the skb containing the frame, length will be checked 2506 * 2507 * Return: true if the skb contains a protected dual of public action 2508 * management frame, false otherwise. 2509 */ 2510 static inline bool 2511 ieee80211_is_protected_dual_of_public_action(struct sk_buff *skb) 2512 { 2513 struct ieee80211_mgmt *mgmt = (void *)skb->data; 2514 u8 action; 2515 2516 if (!ieee80211_is_public_action((void *)skb->data, skb->len) || 2517 skb->len < IEEE80211_MIN_ACTION_SIZE(action_code)) 2518 return false; 2519 2520 action = mgmt->u.action.action_code; 2521 2522 return action != WLAN_PUB_ACTION_20_40_BSS_COEX && 2523 action != WLAN_PUB_ACTION_DSE_REG_LOC_ANN && 2524 action != WLAN_PUB_ACTION_MSMT_PILOT && 2525 action != WLAN_PUB_ACTION_TDLS_DISCOVER_RES && 2526 action != WLAN_PUB_ACTION_LOC_TRACK_NOTI && 2527 action != WLAN_PUB_ACTION_FTM_REQUEST && 2528 action != WLAN_PUB_ACTION_FTM_RESPONSE && 2529 action != WLAN_PUB_ACTION_FILS_DISCOVERY && 2530 action != WLAN_PUB_ACTION_VENDOR_SPECIFIC; 2531 } 2532 2533 /** 2534 * _ieee80211_is_group_privacy_action - check if frame is a group addressed 2535 * privacy action frame 2536 * @hdr: the frame 2537 * Return: whether or not the frame is a group addressed privacy action frame 2538 */ 2539 static inline bool _ieee80211_is_group_privacy_action(struct ieee80211_hdr *hdr) 2540 { 2541 struct ieee80211_mgmt *mgmt = (void *)hdr; 2542 2543 if (!ieee80211_is_action(hdr->frame_control) || 2544 !is_multicast_ether_addr(hdr->addr1)) 2545 return false; 2546 2547 return mgmt->u.action.category == WLAN_CATEGORY_MESH_ACTION || 2548 mgmt->u.action.category == WLAN_CATEGORY_MULTIHOP_ACTION; 2549 } 2550 2551 /** 2552 * ieee80211_is_group_privacy_action - check if frame is a group addressed 2553 * privacy action frame 2554 * @skb: the skb containing the frame, length will be checked 2555 * Return: whether or not the frame is a group addressed privacy action frame 2556 */ 2557 static inline bool ieee80211_is_group_privacy_action(struct sk_buff *skb) 2558 { 2559 if (skb->len < IEEE80211_MIN_ACTION_SIZE(category)) 2560 return false; 2561 return _ieee80211_is_group_privacy_action((void *)skb->data); 2562 } 2563 2564 /** 2565 * ieee80211_tu_to_usec - convert time units (TU) to microseconds 2566 * @tu: the TUs 2567 * Return: the time value converted to microseconds 2568 */ 2569 static inline unsigned long ieee80211_tu_to_usec(unsigned long tu) 2570 { 2571 return 1024 * tu; 2572 } 2573 2574 static inline bool __ieee80211_check_tim(const struct ieee80211_tim_ie *tim, 2575 u8 tim_len, u16 aid) 2576 { 2577 u8 mask; 2578 u8 index, indexn1, indexn2; 2579 2580 if (unlikely(!tim || tim_len < sizeof(*tim))) 2581 return false; 2582 2583 aid &= 0x3fff; 2584 index = aid / 8; 2585 mask = 1 << (aid & 7); 2586 2587 indexn1 = tim->bitmap_ctrl & 0xfe; 2588 indexn2 = tim_len + indexn1 - 4; 2589 2590 if (index < indexn1 || index > indexn2) 2591 return false; 2592 2593 index -= indexn1; 2594 2595 return !!(tim->virtual_map[index] & mask); 2596 } 2597 2598 /** 2599 * ieee80211_get_tdls_action - get TDLS action code 2600 * @skb: the skb containing the frame, length will not be checked 2601 * Return: the TDLS action code, or -1 if it's not an encapsulated TDLS action 2602 * frame 2603 * 2604 * This function assumes the frame is a data frame, and that the network header 2605 * is in the correct place. 2606 */ 2607 static inline int ieee80211_get_tdls_action(struct sk_buff *skb) 2608 { 2609 if (!skb_is_nonlinear(skb) && 2610 skb->len > (skb_network_offset(skb) + 2)) { 2611 /* Point to where the indication of TDLS should start */ 2612 const u8 *tdls_data = skb_network_header(skb) - 2; 2613 2614 if (get_unaligned_be16(tdls_data) == ETH_P_TDLS && 2615 tdls_data[2] == WLAN_TDLS_SNAP_RFTYPE && 2616 tdls_data[3] == WLAN_CATEGORY_TDLS) 2617 return tdls_data[4]; 2618 } 2619 2620 return -1; 2621 } 2622 2623 /* convert time units */ 2624 #define TU_TO_JIFFIES(x) (usecs_to_jiffies((x) * 1024)) 2625 #define TU_TO_EXP_TIME(x) (jiffies + TU_TO_JIFFIES(x)) 2626 2627 /* convert frequencies */ 2628 #define MHZ_TO_KHZ(freq) ((freq) * 1000) 2629 #define KHZ_TO_MHZ(freq) ((freq) / 1000) 2630 #define KHZ_TO_HZ(x) ((x) * 1000) 2631 #define PR_KHZ(f) KHZ_TO_MHZ(f), f % 1000 2632 #define KHZ_F "%d.%03d" 2633 2634 /* convert powers */ 2635 #define DBI_TO_MBI(gain) ((gain) * 100) 2636 #define MBI_TO_DBI(gain) ((gain) / 100) 2637 #define DBM_TO_MBM(gain) ((gain) * 100) 2638 #define MBM_TO_DBM(gain) ((gain) / 100) 2639 2640 /** 2641 * ieee80211_action_contains_tpc - checks if the frame contains TPC element 2642 * @skb: the skb containing the frame, length will be checked 2643 * Return: %true if the frame contains a TPC element, %false otherwise 2644 * 2645 * This function checks if it's either TPC report action frame or Link 2646 * Measurement report action frame as defined in IEEE Std. 802.11-2012 8.5.2.5 2647 * and 8.5.7.5 accordingly. 2648 */ 2649 static inline bool ieee80211_action_contains_tpc(struct sk_buff *skb) 2650 { 2651 struct ieee80211_mgmt *mgmt = (void *)skb->data; 2652 2653 if (!ieee80211_is_action(mgmt->frame_control)) 2654 return false; 2655 2656 if (skb->len < IEEE80211_MIN_ACTION_SIZE(tpc_report)) 2657 return false; 2658 2659 /* 2660 * TPC report - check that: 2661 * category = 0 (Spectrum Management) or 5 (Radio Measurement) 2662 * spectrum management action = 3 (TPC/Link Measurement report) 2663 * TPC report EID = 35 2664 * TPC report element length = 2 2665 * 2666 * The spectrum management's tpc_report struct is used here both for 2667 * parsing tpc_report and radio measurement's link measurement report 2668 * frame, since the relevant part is identical in both frames. 2669 */ 2670 if (mgmt->u.action.category != WLAN_CATEGORY_SPECTRUM_MGMT && 2671 mgmt->u.action.category != WLAN_CATEGORY_RADIO_MEASUREMENT) 2672 return false; 2673 2674 /* both spectrum mgmt and link measurement have same action code */ 2675 if (mgmt->u.action.action_code != WLAN_ACTION_SPCT_TPC_RPRT) 2676 return false; 2677 2678 if (mgmt->u.action.tpc_report.tpc_elem_id != WLAN_EID_TPC_REPORT || 2679 mgmt->u.action.tpc_report.tpc_elem_length != 2680 sizeof(struct ieee80211_tpc_report_ie)) 2681 return false; 2682 2683 return true; 2684 } 2685 2686 /** 2687 * ieee80211_is_timing_measurement - check if frame is timing measurement response 2688 * @skb: the SKB to check 2689 * Return: whether or not the frame is a valid timing measurement response 2690 */ 2691 static inline bool ieee80211_is_timing_measurement(struct sk_buff *skb) 2692 { 2693 struct ieee80211_mgmt *mgmt = (void *)skb->data; 2694 2695 if (skb->len < IEEE80211_MIN_ACTION_SIZE(wnm_timing_msr)) 2696 return false; 2697 2698 if (!ieee80211_is_action(mgmt->frame_control)) 2699 return false; 2700 2701 if (mgmt->u.action.category == WLAN_CATEGORY_WNM_UNPROTECTED && 2702 mgmt->u.action.action_code == 2703 WLAN_UNPROTECTED_WNM_ACTION_TIMING_MEASUREMENT_RESPONSE) 2704 return true; 2705 2706 return false; 2707 } 2708 2709 /** 2710 * ieee80211_is_ftm - check if frame is FTM response 2711 * @skb: the SKB to check 2712 * Return: whether or not the frame is a valid FTM response action frame 2713 */ 2714 static inline bool ieee80211_is_ftm(struct sk_buff *skb) 2715 { 2716 struct ieee80211_mgmt *mgmt = (void *)skb->data; 2717 2718 if (skb->len < IEEE80211_MIN_ACTION_SIZE(ftm)) 2719 return false; 2720 2721 if (!ieee80211_is_public_action((void *)mgmt, skb->len)) 2722 return false; 2723 2724 return mgmt->u.action.action_code == WLAN_PUB_ACTION_FTM_RESPONSE; 2725 } 2726 2727 struct element { 2728 u8 id; 2729 u8 datalen; 2730 u8 data[]; 2731 } __packed; 2732 2733 /* trigger enum comparison warnings if applicable (constant id) */ 2734 #define element_iteration_typecheck(type, id) \ 2735 (((type)0 == (id)) || true) 2736 2737 /* element iteration helpers */ 2738 #define for_each_element(_elem, _data, _datalen) \ 2739 for (_elem = (const struct element *)(_data); \ 2740 (const u8 *)(_data) + (_datalen) - (const u8 *)_elem >= \ 2741 (int)sizeof(*_elem) && \ 2742 (const u8 *)(_data) + (_datalen) - (const u8 *)_elem >= \ 2743 (int)sizeof(*_elem) + _elem->datalen; \ 2744 _elem = (const struct element *)(_elem->data + _elem->datalen)) 2745 2746 #define for_each_element_id(element, _id, data, datalen) \ 2747 for_each_element(element, data, datalen) \ 2748 if (element_iteration_typecheck(enum ieee80211_eid, \ 2749 _id) && \ 2750 element->id == (_id)) 2751 2752 #define for_each_element_extid(element, extid, _data, _datalen) \ 2753 for_each_element(element, _data, _datalen) \ 2754 if (element_iteration_typecheck(enum ieee80211_eid_ext, \ 2755 extid) && \ 2756 element->id == WLAN_EID_EXTENSION && \ 2757 element->datalen > 0 && \ 2758 element->data[0] == (extid)) 2759 2760 #define for_each_subelement(sub, element) \ 2761 for_each_element(sub, (element)->data, (element)->datalen) 2762 2763 #define for_each_subelement_id(sub, id, element) \ 2764 for_each_element_id(sub, (u8)id, (element)->data, (element)->datalen) 2765 2766 #define for_each_subelement_extid(sub, extid, element) \ 2767 for_each_element_extid(sub, (u8)extid, (element)->data, \ 2768 (element)->datalen) 2769 2770 /** 2771 * for_each_element_completed - determine if element parsing consumed all data 2772 * @element: element pointer after for_each_element() or friends 2773 * @data: same data pointer as passed to for_each_element() or friends 2774 * @datalen: same data length as passed to for_each_element() or friends 2775 * Return: %true if all elements were iterated, %false otherwise; see notes 2776 * 2777 * This function returns %true if all the data was parsed or considered 2778 * while walking the elements. Only use this if your for_each_element() 2779 * loop cannot be broken out of, otherwise it always returns %false. 2780 * 2781 * If some data was malformed, this returns %false since the last parsed 2782 * element will not fill the whole remaining data. 2783 */ 2784 static inline bool for_each_element_completed(const struct element *element, 2785 const void *data, size_t datalen) 2786 { 2787 return (const u8 *)element == (const u8 *)data + datalen; 2788 } 2789 2790 /* 2791 * RSNX Capabilities: 2792 * bits 0-3: Field length (n-1) 2793 */ 2794 #define WLAN_RSNX_CAPA_PROTECTED_TWT BIT(4) 2795 #define WLAN_RSNX_CAPA_SAE_H2E BIT(5) 2796 2797 /* EBPCC = Enhanced BSS Parameter Change Count */ 2798 #define IEEE80211_ENH_CRIT_UPD_EBPCC 0x0F 2799 #define IEEE80211_ENH_CRIT_UPD_TYPE 0x70 2800 #define IEEE80211_ENH_CRIT_UPD_TYPE_NO_UHR 0 2801 #define IEEE80211_ENH_CRIT_UPD_TYPE_UHR 1 2802 #define IEEE80211_ENH_CRIT_UPD_ALL 0x80 2803 2804 /** 2805 * struct ieee80211_enh_crit_upd - enhanced critical update (UHR) 2806 * @v: value of the enhanced critical update data, 2807 * see %IEEE80211_ENH_CRIT_UPD_* to parse the bits 2808 */ 2809 struct ieee80211_enh_crit_upd { 2810 u8 v; 2811 } __packed; 2812 2813 /* 2814 * reduced neighbor report, based on Draft P802.11ax_D6.1, 2815 * section 9.4.2.170 and accepted contributions. 2816 */ 2817 #define IEEE80211_AP_INFO_TBTT_HDR_TYPE 0x03 2818 #define IEEE80211_AP_INFO_TBTT_HDR_FILTERED 0x04 2819 #define IEEE80211_AP_INFO_TBTT_HDR_COLOC 0x08 2820 #define IEEE80211_AP_INFO_TBTT_HDR_COUNT 0xF0 2821 #define IEEE80211_TBTT_INFO_TYPE_TBTT 0 2822 #define IEEE80211_TBTT_INFO_TYPE_MLD 1 2823 2824 #define IEEE80211_RNR_TBTT_PARAMS_OCT_RECOMMENDED 0x01 2825 #define IEEE80211_RNR_TBTT_PARAMS_SAME_SSID 0x02 2826 #define IEEE80211_RNR_TBTT_PARAMS_MULTI_BSSID 0x04 2827 #define IEEE80211_RNR_TBTT_PARAMS_TRANSMITTED_BSSID 0x08 2828 #define IEEE80211_RNR_TBTT_PARAMS_COLOC_ESS 0x10 2829 #define IEEE80211_RNR_TBTT_PARAMS_PROBE_ACTIVE 0x20 2830 #define IEEE80211_RNR_TBTT_PARAMS_COLOC_AP 0x40 2831 #define IEEE80211_RNR_TBTT_PARAMS_SAME_SMD 0x80 2832 2833 #define IEEE80211_RNR_TBTT_PARAMS_PSD_NO_LIMIT 127 2834 #define IEEE80211_RNR_TBTT_PARAMS_PSD_RESERVED -128 2835 2836 struct ieee80211_neighbor_ap_info { 2837 u8 tbtt_info_hdr; 2838 u8 tbtt_info_len; 2839 u8 op_class; 2840 u8 channel; 2841 } __packed; 2842 2843 enum ieee80211_range_params_max_total_ltf { 2844 IEEE80211_RANGE_PARAMS_MAX_TOTAL_LTF_4 = 0, 2845 IEEE80211_RANGE_PARAMS_MAX_TOTAL_LTF_8, 2846 IEEE80211_RANGE_PARAMS_MAX_TOTAL_LTF_16, 2847 IEEE80211_RANGE_PARAMS_MAX_TOTAL_LTF_UNSPECIFIED, 2848 }; 2849 2850 /* 2851 * reduced neighbor report, based on Draft P802.11be_D3.0, 2852 * section 9.4.2.170.2. 2853 */ 2854 struct ieee80211_rnr_mld_params { 2855 u8 mld_id; 2856 __le16 params; 2857 } __packed; 2858 2859 #define IEEE80211_RNR_MLD_PARAMS_LINK_ID 0x000F 2860 #define IEEE80211_RNR_MLD_PARAMS_BSS_CHANGE_COUNT 0x0FF0 2861 #define IEEE80211_RNR_MLD_PARAMS_UPDATES_INCLUDED 0x1000 2862 #define IEEE80211_RNR_MLD_PARAMS_DISABLED_LINK 0x2000 2863 2864 /* Format of the TBTT information element if it has 7, 8 or 9 bytes */ 2865 struct ieee80211_tbtt_info_7_8_9 { 2866 u8 tbtt_offset; 2867 u8 bssid[ETH_ALEN]; 2868 2869 /* The following element is optional, structure may not grow */ 2870 u8 bss_params; 2871 s8 psd_20; 2872 } __packed; 2873 2874 /* Format of the TBTT information element if it has >= 11 bytes */ 2875 struct ieee80211_tbtt_info_ge_11 { 2876 u8 tbtt_offset; 2877 u8 bssid[ETH_ALEN]; 2878 __le32 short_ssid; 2879 2880 /* The following elements are optional, structure may grow */ 2881 u8 bss_params; 2882 s8 psd_20; 2883 struct ieee80211_rnr_mld_params mld_params; 2884 struct ieee80211_enh_crit_upd enh_crit_upd; 2885 } __packed; 2886 2887 #include "ieee80211-ht.h" 2888 #include "ieee80211-vht.h" 2889 #include "ieee80211-he.h" 2890 #include "ieee80211-eht.h" 2891 #include "ieee80211-uhr.h" 2892 #include "ieee80211-mesh.h" 2893 #include "ieee80211-s1g.h" 2894 #include "ieee80211-p2p.h" 2895 #include "ieee80211-nan.h" 2896 2897 /** 2898 * ieee80211_check_tim - check if AID bit is set in TIM 2899 * @tim: the TIM IE 2900 * @tim_len: length of the TIM IE 2901 * @aid: the AID to look for 2902 * @s1g: whether the TIM is from an S1G PPDU 2903 * Return: whether or not traffic is indicated in the TIM for the given AID 2904 */ 2905 static inline bool ieee80211_check_tim(const struct ieee80211_tim_ie *tim, 2906 u8 tim_len, u16 aid, bool s1g) 2907 { 2908 return s1g ? ieee80211_s1g_check_tim(tim, tim_len, aid) : 2909 __ieee80211_check_tim(tim, tim_len, aid); 2910 } 2911 2912 /** 2913 * enum ieee80211_cip_cap_fields - CIP Capabilities element fields 2914 * @IEEE80211_CIP_CAP_MIC_PADDING: The MIC padding subfield in the CIP 2915 * capabilities 2916 * @IEEE80211_CIP_CAP_PROTECTED_CTRL_FRAME_ONLY: The MIC Padding For Protected 2917 * Control Frames Only bit in CIP capabilities 2918 */ 2919 enum ieee80211_cip_cap_fields { 2920 IEEE80211_CIP_CAP_MIC_PADDING = 0x0F, 2921 IEEE80211_CIP_CAP_PROTECTED_CTRL_FRAME_ONLY = 0x10, 2922 }; 2923 2924 /** 2925 * struct ieee80211_cip_cap - CIP Capabilities element 2926 * 2927 * @v: The value of the Control Integrity Protocol Capability element 2928 */ 2929 struct ieee80211_cip_cap { 2930 u8 v; 2931 } __packed; 2932 2933 #endif /* LINUX_IEEE80211_H */ 2934