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