ieee80211.h 68 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353
  1. /*
  2. * IEEE 802.11 defines
  3. *
  4. * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
  5. * <jkmaline@cc.hut.fi>
  6. * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
  7. * Copyright (c) 2005, Devicescape Software, Inc.
  8. * Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #ifndef LINUX_IEEE80211_H
  15. #define LINUX_IEEE80211_H
  16. #include <linux/types.h>
  17. #include <linux/if_ether.h>
  18. #include <asm/byteorder.h>
  19. /*
  20. * DS bit usage
  21. *
  22. * TA = transmitter address
  23. * RA = receiver address
  24. * DA = destination address
  25. * SA = source address
  26. *
  27. * ToDS FromDS A1(RA) A2(TA) A3 A4 Use
  28. * -----------------------------------------------------------------
  29. * 0 0 DA SA BSSID - IBSS/DLS
  30. * 0 1 DA BSSID SA - AP -> STA
  31. * 1 0 BSSID SA DA - AP <- STA
  32. * 1 1 RA TA DA SA unspecified (WDS)
  33. */
  34. #define FCS_LEN 4
  35. #define IEEE80211_FCTL_VERS 0x0003
  36. #define IEEE80211_FCTL_FTYPE 0x000c
  37. #define IEEE80211_FCTL_STYPE 0x00f0
  38. #define IEEE80211_FCTL_TODS 0x0100
  39. #define IEEE80211_FCTL_FROMDS 0x0200
  40. #define IEEE80211_FCTL_MOREFRAGS 0x0400
  41. #define IEEE80211_FCTL_RETRY 0x0800
  42. #define IEEE80211_FCTL_PM 0x1000
  43. #define IEEE80211_FCTL_MOREDATA 0x2000
  44. #define IEEE80211_FCTL_PROTECTED 0x4000
  45. #define IEEE80211_FCTL_ORDER 0x8000
  46. #define IEEE80211_FCTL_CTL_EXT 0x0f00
  47. #define IEEE80211_SCTL_FRAG 0x000F
  48. #define IEEE80211_SCTL_SEQ 0xFFF0
  49. #define IEEE80211_FTYPE_MGMT 0x0000
  50. #define IEEE80211_FTYPE_CTL 0x0004
  51. #define IEEE80211_FTYPE_DATA 0x0008
  52. #define IEEE80211_FTYPE_EXT 0x000c
  53. /* management */
  54. #define IEEE80211_STYPE_ASSOC_REQ 0x0000
  55. #define IEEE80211_STYPE_ASSOC_RESP 0x0010
  56. #define IEEE80211_STYPE_REASSOC_REQ 0x0020
  57. #define IEEE80211_STYPE_REASSOC_RESP 0x0030
  58. #define IEEE80211_STYPE_PROBE_REQ 0x0040
  59. #define IEEE80211_STYPE_PROBE_RESP 0x0050
  60. #define IEEE80211_STYPE_BEACON 0x0080
  61. #define IEEE80211_STYPE_ATIM 0x0090
  62. #define IEEE80211_STYPE_DISASSOC 0x00A0
  63. #define IEEE80211_STYPE_AUTH 0x00B0
  64. #define IEEE80211_STYPE_DEAUTH 0x00C0
  65. #define IEEE80211_STYPE_ACTION 0x00D0
  66. /* control */
  67. #define IEEE80211_STYPE_CTL_EXT 0x0060
  68. #define IEEE80211_STYPE_BACK_REQ 0x0080
  69. #define IEEE80211_STYPE_BACK 0x0090
  70. #define IEEE80211_STYPE_PSPOLL 0x00A0
  71. #define IEEE80211_STYPE_RTS 0x00B0
  72. #define IEEE80211_STYPE_CTS 0x00C0
  73. #define IEEE80211_STYPE_ACK 0x00D0
  74. #define IEEE80211_STYPE_CFEND 0x00E0
  75. #define IEEE80211_STYPE_CFENDACK 0x00F0
  76. /* data */
  77. #define IEEE80211_STYPE_DATA 0x0000
  78. #define IEEE80211_STYPE_DATA_CFACK 0x0010
  79. #define IEEE80211_STYPE_DATA_CFPOLL 0x0020
  80. #define IEEE80211_STYPE_DATA_CFACKPOLL 0x0030
  81. #define IEEE80211_STYPE_NULLFUNC 0x0040
  82. #define IEEE80211_STYPE_CFACK 0x0050
  83. #define IEEE80211_STYPE_CFPOLL 0x0060
  84. #define IEEE80211_STYPE_CFACKPOLL 0x0070
  85. #define IEEE80211_STYPE_QOS_DATA 0x0080
  86. #define IEEE80211_STYPE_QOS_DATA_CFACK 0x0090
  87. #define IEEE80211_STYPE_QOS_DATA_CFPOLL 0x00A0
  88. #define IEEE80211_STYPE_QOS_DATA_CFACKPOLL 0x00B0
  89. #define IEEE80211_STYPE_QOS_NULLFUNC 0x00C0
  90. #define IEEE80211_STYPE_QOS_CFACK 0x00D0
  91. #define IEEE80211_STYPE_QOS_CFPOLL 0x00E0
  92. #define IEEE80211_STYPE_QOS_CFACKPOLL 0x00F0
  93. /* extension, added by 802.11ad */
  94. #define IEEE80211_STYPE_DMG_BEACON 0x0000
  95. /* control extension - for IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTL_EXT */
  96. #define IEEE80211_CTL_EXT_POLL 0x2000
  97. #define IEEE80211_CTL_EXT_SPR 0x3000
  98. #define IEEE80211_CTL_EXT_GRANT 0x4000
  99. #define IEEE80211_CTL_EXT_DMG_CTS 0x5000
  100. #define IEEE80211_CTL_EXT_DMG_DTS 0x6000
  101. #define IEEE80211_CTL_EXT_SSW 0x8000
  102. #define IEEE80211_CTL_EXT_SSW_FBACK 0x9000
  103. #define IEEE80211_CTL_EXT_SSW_ACK 0xa000
  104. #define IEEE80211_SN_MASK ((IEEE80211_SCTL_SEQ) >> 4)
  105. #define IEEE80211_MAX_SN IEEE80211_SN_MASK
  106. #define IEEE80211_SN_MODULO (IEEE80211_MAX_SN + 1)
  107. static inline int ieee80211_sn_less(u16 sn1, u16 sn2)
  108. {
  109. return ((sn1 - sn2) & IEEE80211_SN_MASK) > (IEEE80211_SN_MODULO >> 1);
  110. }
  111. static inline u16 ieee80211_sn_add(u16 sn1, u16 sn2)
  112. {
  113. return (sn1 + sn2) & IEEE80211_SN_MASK;
  114. }
  115. static inline u16 ieee80211_sn_inc(u16 sn)
  116. {
  117. return ieee80211_sn_add(sn, 1);
  118. }
  119. static inline u16 ieee80211_sn_sub(u16 sn1, u16 sn2)
  120. {
  121. return (sn1 - sn2) & IEEE80211_SN_MASK;
  122. }
  123. #define IEEE80211_SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
  124. #define IEEE80211_SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ)
  125. /* miscellaneous IEEE 802.11 constants */
  126. #define IEEE80211_MAX_FRAG_THRESHOLD 2352
  127. #define IEEE80211_MAX_RTS_THRESHOLD 2353
  128. #define IEEE80211_MAX_AID 2007
  129. #define IEEE80211_MAX_TIM_LEN 251
  130. #define IEEE80211_MAX_MESH_PEERINGS 63
  131. /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
  132. 6.2.1.1.2.
  133. 802.11e clarifies the figure in section 7.1.2. The frame body is
  134. up to 2304 octets long (maximum MSDU size) plus any crypt overhead. */
  135. #define IEEE80211_MAX_DATA_LEN 2304
  136. /* 30 byte 4 addr hdr, 2 byte QoS, 2304 byte MSDU, 12 byte crypt, 4 byte FCS */
  137. #define IEEE80211_MAX_FRAME_LEN 2352
  138. #define IEEE80211_MAX_SSID_LEN 32
  139. #define IEEE80211_MAX_MESH_ID_LEN 32
  140. #define IEEE80211_NUM_TIDS 16
  141. #define IEEE80211_QOS_CTL_LEN 2
  142. /* 1d tag mask */
  143. #define IEEE80211_QOS_CTL_TAG1D_MASK 0x0007
  144. /* TID mask */
  145. #define IEEE80211_QOS_CTL_TID_MASK 0x000f
  146. /* EOSP */
  147. #define IEEE80211_QOS_CTL_EOSP 0x0010
  148. /* ACK policy */
  149. #define IEEE80211_QOS_CTL_ACK_POLICY_NORMAL 0x0000
  150. #define IEEE80211_QOS_CTL_ACK_POLICY_NOACK 0x0020
  151. #define IEEE80211_QOS_CTL_ACK_POLICY_NO_EXPL 0x0040
  152. #define IEEE80211_QOS_CTL_ACK_POLICY_BLOCKACK 0x0060
  153. #define IEEE80211_QOS_CTL_ACK_POLICY_MASK 0x0060
  154. /* A-MSDU 802.11n */
  155. #define IEEE80211_QOS_CTL_A_MSDU_PRESENT 0x0080
  156. /* Mesh Control 802.11s */
  157. #define IEEE80211_QOS_CTL_MESH_CONTROL_PRESENT 0x0100
  158. /* Mesh Power Save Level */
  159. #define IEEE80211_QOS_CTL_MESH_PS_LEVEL 0x0200
  160. /* Mesh Receiver Service Period Initiated */
  161. #define IEEE80211_QOS_CTL_RSPI 0x0400
  162. /* U-APSD queue for WMM IEs sent by AP */
  163. #define IEEE80211_WMM_IE_AP_QOSINFO_UAPSD (1<<7)
  164. #define IEEE80211_WMM_IE_AP_QOSINFO_PARAM_SET_CNT_MASK 0x0f
  165. /* U-APSD queues for WMM IEs sent by STA */
  166. #define IEEE80211_WMM_IE_STA_QOSINFO_AC_VO (1<<0)
  167. #define IEEE80211_WMM_IE_STA_QOSINFO_AC_VI (1<<1)
  168. #define IEEE80211_WMM_IE_STA_QOSINFO_AC_BK (1<<2)
  169. #define IEEE80211_WMM_IE_STA_QOSINFO_AC_BE (1<<3)
  170. #define IEEE80211_WMM_IE_STA_QOSINFO_AC_MASK 0x0f
  171. /* U-APSD max SP length for WMM IEs sent by STA */
  172. #define IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL 0x00
  173. #define IEEE80211_WMM_IE_STA_QOSINFO_SP_2 0x01
  174. #define IEEE80211_WMM_IE_STA_QOSINFO_SP_4 0x02
  175. #define IEEE80211_WMM_IE_STA_QOSINFO_SP_6 0x03
  176. #define IEEE80211_WMM_IE_STA_QOSINFO_SP_MASK 0x03
  177. #define IEEE80211_WMM_IE_STA_QOSINFO_SP_SHIFT 5
  178. #define IEEE80211_HT_CTL_LEN 4
  179. struct ieee80211_hdr {
  180. __le16 frame_control;
  181. __le16 duration_id;
  182. u8 addr1[ETH_ALEN];
  183. u8 addr2[ETH_ALEN];
  184. u8 addr3[ETH_ALEN];
  185. __le16 seq_ctrl;
  186. u8 addr4[ETH_ALEN];
  187. } __packed __aligned(2);
  188. struct ieee80211_hdr_3addr {
  189. __le16 frame_control;
  190. __le16 duration_id;
  191. u8 addr1[ETH_ALEN];
  192. u8 addr2[ETH_ALEN];
  193. u8 addr3[ETH_ALEN];
  194. __le16 seq_ctrl;
  195. } __packed __aligned(2);
  196. struct ieee80211_qos_hdr {
  197. __le16 frame_control;
  198. __le16 duration_id;
  199. u8 addr1[ETH_ALEN];
  200. u8 addr2[ETH_ALEN];
  201. u8 addr3[ETH_ALEN];
  202. __le16 seq_ctrl;
  203. __le16 qos_ctrl;
  204. } __packed __aligned(2);
  205. /**
  206. * ieee80211_has_tods - check if IEEE80211_FCTL_TODS is set
  207. * @fc: frame control bytes in little-endian byteorder
  208. */
  209. static inline int ieee80211_has_tods(__le16 fc)
  210. {
  211. return (fc & cpu_to_le16(IEEE80211_FCTL_TODS)) != 0;
  212. }
  213. /**
  214. * ieee80211_has_fromds - check if IEEE80211_FCTL_FROMDS is set
  215. * @fc: frame control bytes in little-endian byteorder
  216. */
  217. static inline int ieee80211_has_fromds(__le16 fc)
  218. {
  219. return (fc & cpu_to_le16(IEEE80211_FCTL_FROMDS)) != 0;
  220. }
  221. /**
  222. * ieee80211_has_a4 - check if IEEE80211_FCTL_TODS and IEEE80211_FCTL_FROMDS are set
  223. * @fc: frame control bytes in little-endian byteorder
  224. */
  225. static inline int ieee80211_has_a4(__le16 fc)
  226. {
  227. __le16 tmp = cpu_to_le16(IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS);
  228. return (fc & tmp) == tmp;
  229. }
  230. /**
  231. * ieee80211_has_morefrags - check if IEEE80211_FCTL_MOREFRAGS is set
  232. * @fc: frame control bytes in little-endian byteorder
  233. */
  234. static inline int ieee80211_has_morefrags(__le16 fc)
  235. {
  236. return (fc & cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)) != 0;
  237. }
  238. /**
  239. * ieee80211_has_retry - check if IEEE80211_FCTL_RETRY is set
  240. * @fc: frame control bytes in little-endian byteorder
  241. */
  242. static inline int ieee80211_has_retry(__le16 fc)
  243. {
  244. return (fc & cpu_to_le16(IEEE80211_FCTL_RETRY)) != 0;
  245. }
  246. /**
  247. * ieee80211_has_pm - check if IEEE80211_FCTL_PM is set
  248. * @fc: frame control bytes in little-endian byteorder
  249. */
  250. static inline int ieee80211_has_pm(__le16 fc)
  251. {
  252. return (fc & cpu_to_le16(IEEE80211_FCTL_PM)) != 0;
  253. }
  254. /**
  255. * ieee80211_has_moredata - check if IEEE80211_FCTL_MOREDATA is set
  256. * @fc: frame control bytes in little-endian byteorder
  257. */
  258. static inline int ieee80211_has_moredata(__le16 fc)
  259. {
  260. return (fc & cpu_to_le16(IEEE80211_FCTL_MOREDATA)) != 0;
  261. }
  262. /**
  263. * ieee80211_has_protected - check if IEEE80211_FCTL_PROTECTED is set
  264. * @fc: frame control bytes in little-endian byteorder
  265. */
  266. static inline int ieee80211_has_protected(__le16 fc)
  267. {
  268. return (fc & cpu_to_le16(IEEE80211_FCTL_PROTECTED)) != 0;
  269. }
  270. /**
  271. * ieee80211_has_order - check if IEEE80211_FCTL_ORDER is set
  272. * @fc: frame control bytes in little-endian byteorder
  273. */
  274. static inline int ieee80211_has_order(__le16 fc)
  275. {
  276. return (fc & cpu_to_le16(IEEE80211_FCTL_ORDER)) != 0;
  277. }
  278. /**
  279. * ieee80211_is_mgmt - check if type is IEEE80211_FTYPE_MGMT
  280. * @fc: frame control bytes in little-endian byteorder
  281. */
  282. static inline int ieee80211_is_mgmt(__le16 fc)
  283. {
  284. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
  285. cpu_to_le16(IEEE80211_FTYPE_MGMT);
  286. }
  287. /**
  288. * ieee80211_is_ctl - check if type is IEEE80211_FTYPE_CTL
  289. * @fc: frame control bytes in little-endian byteorder
  290. */
  291. static inline int ieee80211_is_ctl(__le16 fc)
  292. {
  293. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
  294. cpu_to_le16(IEEE80211_FTYPE_CTL);
  295. }
  296. /**
  297. * ieee80211_is_data - check if type is IEEE80211_FTYPE_DATA
  298. * @fc: frame control bytes in little-endian byteorder
  299. */
  300. static inline int ieee80211_is_data(__le16 fc)
  301. {
  302. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
  303. cpu_to_le16(IEEE80211_FTYPE_DATA);
  304. }
  305. /**
  306. * ieee80211_is_data_qos - check if type is IEEE80211_FTYPE_DATA and IEEE80211_STYPE_QOS_DATA is set
  307. * @fc: frame control bytes in little-endian byteorder
  308. */
  309. static inline int ieee80211_is_data_qos(__le16 fc)
  310. {
  311. /*
  312. * mask with QOS_DATA rather than IEEE80211_FCTL_STYPE as we just need
  313. * to check the one bit
  314. */
  315. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_STYPE_QOS_DATA)) ==
  316. cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_QOS_DATA);
  317. }
  318. /**
  319. * ieee80211_is_data_present - check if type is IEEE80211_FTYPE_DATA and has data
  320. * @fc: frame control bytes in little-endian byteorder
  321. */
  322. static inline int ieee80211_is_data_present(__le16 fc)
  323. {
  324. /*
  325. * mask with 0x40 and test that that bit is clear to only return true
  326. * for the data-containing substypes.
  327. */
  328. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | 0x40)) ==
  329. cpu_to_le16(IEEE80211_FTYPE_DATA);
  330. }
  331. /**
  332. * ieee80211_is_assoc_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ASSOC_REQ
  333. * @fc: frame control bytes in little-endian byteorder
  334. */
  335. static inline int ieee80211_is_assoc_req(__le16 fc)
  336. {
  337. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  338. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ASSOC_REQ);
  339. }
  340. /**
  341. * ieee80211_is_assoc_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ASSOC_RESP
  342. * @fc: frame control bytes in little-endian byteorder
  343. */
  344. static inline int ieee80211_is_assoc_resp(__le16 fc)
  345. {
  346. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  347. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ASSOC_RESP);
  348. }
  349. /**
  350. * ieee80211_is_reassoc_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_REASSOC_REQ
  351. * @fc: frame control bytes in little-endian byteorder
  352. */
  353. static inline int ieee80211_is_reassoc_req(__le16 fc)
  354. {
  355. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  356. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_REASSOC_REQ);
  357. }
  358. /**
  359. * ieee80211_is_reassoc_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_REASSOC_RESP
  360. * @fc: frame control bytes in little-endian byteorder
  361. */
  362. static inline int ieee80211_is_reassoc_resp(__le16 fc)
  363. {
  364. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  365. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_REASSOC_RESP);
  366. }
  367. /**
  368. * ieee80211_is_probe_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_PROBE_REQ
  369. * @fc: frame control bytes in little-endian byteorder
  370. */
  371. static inline int ieee80211_is_probe_req(__le16 fc)
  372. {
  373. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  374. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_REQ);
  375. }
  376. /**
  377. * ieee80211_is_probe_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_PROBE_RESP
  378. * @fc: frame control bytes in little-endian byteorder
  379. */
  380. static inline int ieee80211_is_probe_resp(__le16 fc)
  381. {
  382. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  383. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
  384. }
  385. /**
  386. * ieee80211_is_beacon - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_BEACON
  387. * @fc: frame control bytes in little-endian byteorder
  388. */
  389. static inline int ieee80211_is_beacon(__le16 fc)
  390. {
  391. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  392. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
  393. }
  394. /**
  395. * ieee80211_is_atim - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ATIM
  396. * @fc: frame control bytes in little-endian byteorder
  397. */
  398. static inline int ieee80211_is_atim(__le16 fc)
  399. {
  400. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  401. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ATIM);
  402. }
  403. /**
  404. * ieee80211_is_disassoc - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_DISASSOC
  405. * @fc: frame control bytes in little-endian byteorder
  406. */
  407. static inline int ieee80211_is_disassoc(__le16 fc)
  408. {
  409. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  410. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_DISASSOC);
  411. }
  412. /**
  413. * ieee80211_is_auth - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_AUTH
  414. * @fc: frame control bytes in little-endian byteorder
  415. */
  416. static inline int ieee80211_is_auth(__le16 fc)
  417. {
  418. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  419. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH);
  420. }
  421. /**
  422. * ieee80211_is_deauth - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_DEAUTH
  423. * @fc: frame control bytes in little-endian byteorder
  424. */
  425. static inline int ieee80211_is_deauth(__le16 fc)
  426. {
  427. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  428. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_DEAUTH);
  429. }
  430. /**
  431. * ieee80211_is_action - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ACTION
  432. * @fc: frame control bytes in little-endian byteorder
  433. */
  434. static inline int ieee80211_is_action(__le16 fc)
  435. {
  436. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  437. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ACTION);
  438. }
  439. /**
  440. * ieee80211_is_back_req - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_BACK_REQ
  441. * @fc: frame control bytes in little-endian byteorder
  442. */
  443. static inline int ieee80211_is_back_req(__le16 fc)
  444. {
  445. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  446. cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_BACK_REQ);
  447. }
  448. /**
  449. * ieee80211_is_back - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_BACK
  450. * @fc: frame control bytes in little-endian byteorder
  451. */
  452. static inline int ieee80211_is_back(__le16 fc)
  453. {
  454. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  455. cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_BACK);
  456. }
  457. /**
  458. * ieee80211_is_pspoll - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_PSPOLL
  459. * @fc: frame control bytes in little-endian byteorder
  460. */
  461. static inline int ieee80211_is_pspoll(__le16 fc)
  462. {
  463. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  464. cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL);
  465. }
  466. /**
  467. * ieee80211_is_rts - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_RTS
  468. * @fc: frame control bytes in little-endian byteorder
  469. */
  470. static inline int ieee80211_is_rts(__le16 fc)
  471. {
  472. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  473. cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS);
  474. }
  475. /**
  476. * ieee80211_is_cts - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CTS
  477. * @fc: frame control bytes in little-endian byteorder
  478. */
  479. static inline int ieee80211_is_cts(__le16 fc)
  480. {
  481. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  482. cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS);
  483. }
  484. /**
  485. * ieee80211_is_ack - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_ACK
  486. * @fc: frame control bytes in little-endian byteorder
  487. */
  488. static inline int ieee80211_is_ack(__le16 fc)
  489. {
  490. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  491. cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_ACK);
  492. }
  493. /**
  494. * ieee80211_is_cfend - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CFEND
  495. * @fc: frame control bytes in little-endian byteorder
  496. */
  497. static inline int ieee80211_is_cfend(__le16 fc)
  498. {
  499. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  500. cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CFEND);
  501. }
  502. /**
  503. * ieee80211_is_cfendack - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CFENDACK
  504. * @fc: frame control bytes in little-endian byteorder
  505. */
  506. static inline int ieee80211_is_cfendack(__le16 fc)
  507. {
  508. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  509. cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CFENDACK);
  510. }
  511. /**
  512. * ieee80211_is_nullfunc - check if frame is a regular (non-QoS) nullfunc frame
  513. * @fc: frame control bytes in little-endian byteorder
  514. */
  515. static inline int ieee80211_is_nullfunc(__le16 fc)
  516. {
  517. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  518. cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC);
  519. }
  520. /**
  521. * ieee80211_is_qos_nullfunc - check if frame is a QoS nullfunc frame
  522. * @fc: frame control bytes in little-endian byteorder
  523. */
  524. static inline int ieee80211_is_qos_nullfunc(__le16 fc)
  525. {
  526. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  527. cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_QOS_NULLFUNC);
  528. }
  529. /**
  530. * ieee80211_is_bufferable_mmpdu - check if frame is bufferable MMPDU
  531. * @fc: frame control field in little-endian byteorder
  532. */
  533. static inline bool ieee80211_is_bufferable_mmpdu(__le16 fc)
  534. {
  535. /* IEEE 802.11-2012, definition of "bufferable management frame";
  536. * note that this ignores the IBSS special case. */
  537. return ieee80211_is_mgmt(fc) &&
  538. (ieee80211_is_action(fc) ||
  539. ieee80211_is_disassoc(fc) ||
  540. ieee80211_is_deauth(fc));
  541. }
  542. /**
  543. * ieee80211_is_first_frag - check if IEEE80211_SCTL_FRAG is not set
  544. * @seq_ctrl: frame sequence control bytes in little-endian byteorder
  545. */
  546. static inline int ieee80211_is_first_frag(__le16 seq_ctrl)
  547. {
  548. return (seq_ctrl & cpu_to_le16(IEEE80211_SCTL_FRAG)) == 0;
  549. }
  550. struct ieee80211s_hdr {
  551. u8 flags;
  552. u8 ttl;
  553. __le32 seqnum;
  554. u8 eaddr1[ETH_ALEN];
  555. u8 eaddr2[ETH_ALEN];
  556. } __packed __aligned(2);
  557. /* Mesh flags */
  558. #define MESH_FLAGS_AE_A4 0x1
  559. #define MESH_FLAGS_AE_A5_A6 0x2
  560. #define MESH_FLAGS_AE 0x3
  561. #define MESH_FLAGS_PS_DEEP 0x4
  562. /**
  563. * enum ieee80211_preq_flags - mesh PREQ element flags
  564. *
  565. * @IEEE80211_PREQ_PROACTIVE_PREP_FLAG: proactive PREP subfield
  566. */
  567. enum ieee80211_preq_flags {
  568. IEEE80211_PREQ_PROACTIVE_PREP_FLAG = 1<<2,
  569. };
  570. /**
  571. * enum ieee80211_preq_target_flags - mesh PREQ element per target flags
  572. *
  573. * @IEEE80211_PREQ_TO_FLAG: target only subfield
  574. * @IEEE80211_PREQ_USN_FLAG: unknown target HWMP sequence number subfield
  575. */
  576. enum ieee80211_preq_target_flags {
  577. IEEE80211_PREQ_TO_FLAG = 1<<0,
  578. IEEE80211_PREQ_USN_FLAG = 1<<2,
  579. };
  580. /**
  581. * struct ieee80211_quiet_ie
  582. *
  583. * This structure refers to "Quiet information element"
  584. */
  585. struct ieee80211_quiet_ie {
  586. u8 count;
  587. u8 period;
  588. __le16 duration;
  589. __le16 offset;
  590. } __packed;
  591. /**
  592. * struct ieee80211_msrment_ie
  593. *
  594. * This structure refers to "Measurement Request/Report information element"
  595. */
  596. struct ieee80211_msrment_ie {
  597. u8 token;
  598. u8 mode;
  599. u8 type;
  600. u8 request[0];
  601. } __packed;
  602. /**
  603. * struct ieee80211_channel_sw_ie
  604. *
  605. * This structure refers to "Channel Switch Announcement information element"
  606. */
  607. struct ieee80211_channel_sw_ie {
  608. u8 mode;
  609. u8 new_ch_num;
  610. u8 count;
  611. } __packed;
  612. /**
  613. * struct ieee80211_ext_chansw_ie
  614. *
  615. * This structure represents the "Extended Channel Switch Announcement element"
  616. */
  617. struct ieee80211_ext_chansw_ie {
  618. u8 mode;
  619. u8 new_operating_class;
  620. u8 new_ch_num;
  621. u8 count;
  622. } __packed;
  623. /**
  624. * struct ieee80211_sec_chan_offs_ie - secondary channel offset IE
  625. * @sec_chan_offs: secondary channel offset, uses IEEE80211_HT_PARAM_CHA_SEC_*
  626. * values here
  627. * This structure represents the "Secondary Channel Offset element"
  628. */
  629. struct ieee80211_sec_chan_offs_ie {
  630. u8 sec_chan_offs;
  631. } __packed;
  632. /**
  633. * struct ieee80211_mesh_chansw_params_ie - mesh channel switch parameters IE
  634. *
  635. * This structure represents the "Mesh Channel Switch Paramters element"
  636. */
  637. struct ieee80211_mesh_chansw_params_ie {
  638. u8 mesh_ttl;
  639. u8 mesh_flags;
  640. __le16 mesh_reason;
  641. __le16 mesh_pre_value;
  642. } __packed;
  643. /**
  644. * struct ieee80211_wide_bw_chansw_ie - wide bandwidth channel switch IE
  645. */
  646. struct ieee80211_wide_bw_chansw_ie {
  647. u8 new_channel_width;
  648. u8 new_center_freq_seg0, new_center_freq_seg1;
  649. } __packed;
  650. /**
  651. * struct ieee80211_tim
  652. *
  653. * This structure refers to "Traffic Indication Map information element"
  654. */
  655. struct ieee80211_tim_ie {
  656. u8 dtim_count;
  657. u8 dtim_period;
  658. u8 bitmap_ctrl;
  659. /* variable size: 1 - 251 bytes */
  660. u8 virtual_map[1];
  661. } __packed;
  662. /**
  663. * struct ieee80211_meshconf_ie
  664. *
  665. * This structure refers to "Mesh Configuration information element"
  666. */
  667. struct ieee80211_meshconf_ie {
  668. u8 meshconf_psel;
  669. u8 meshconf_pmetric;
  670. u8 meshconf_congest;
  671. u8 meshconf_synch;
  672. u8 meshconf_auth;
  673. u8 meshconf_form;
  674. u8 meshconf_cap;
  675. } __packed;
  676. /**
  677. * enum mesh_config_capab_flags - Mesh Configuration IE capability field flags
  678. *
  679. * @IEEE80211_MESHCONF_CAPAB_ACCEPT_PLINKS: STA is willing to establish
  680. * additional mesh peerings with other mesh STAs
  681. * @IEEE80211_MESHCONF_CAPAB_FORWARDING: the STA forwards MSDUs
  682. * @IEEE80211_MESHCONF_CAPAB_TBTT_ADJUSTING: TBTT adjustment procedure
  683. * is ongoing
  684. * @IEEE80211_MESHCONF_CAPAB_POWER_SAVE_LEVEL: STA is in deep sleep mode or has
  685. * neighbors in deep sleep mode
  686. */
  687. enum mesh_config_capab_flags {
  688. IEEE80211_MESHCONF_CAPAB_ACCEPT_PLINKS = 0x01,
  689. IEEE80211_MESHCONF_CAPAB_FORWARDING = 0x08,
  690. IEEE80211_MESHCONF_CAPAB_TBTT_ADJUSTING = 0x20,
  691. IEEE80211_MESHCONF_CAPAB_POWER_SAVE_LEVEL = 0x40,
  692. };
  693. /**
  694. * mesh channel switch parameters element's flag indicator
  695. *
  696. */
  697. #define WLAN_EID_CHAN_SWITCH_PARAM_TX_RESTRICT BIT(0)
  698. #define WLAN_EID_CHAN_SWITCH_PARAM_INITIATOR BIT(1)
  699. #define WLAN_EID_CHAN_SWITCH_PARAM_REASON BIT(2)
  700. /**
  701. * struct ieee80211_rann_ie
  702. *
  703. * This structure refers to "Root Announcement information element"
  704. */
  705. struct ieee80211_rann_ie {
  706. u8 rann_flags;
  707. u8 rann_hopcount;
  708. u8 rann_ttl;
  709. u8 rann_addr[ETH_ALEN];
  710. __le32 rann_seq;
  711. __le32 rann_interval;
  712. __le32 rann_metric;
  713. } __packed;
  714. enum ieee80211_rann_flags {
  715. RANN_FLAG_IS_GATE = 1 << 0,
  716. };
  717. enum ieee80211_ht_chanwidth_values {
  718. IEEE80211_HT_CHANWIDTH_20MHZ = 0,
  719. IEEE80211_HT_CHANWIDTH_ANY = 1,
  720. };
  721. /**
  722. * enum ieee80211_opmode_bits - VHT operating mode field bits
  723. * @IEEE80211_OPMODE_NOTIF_CHANWIDTH_MASK: channel width mask
  724. * @IEEE80211_OPMODE_NOTIF_CHANWIDTH_20MHZ: 20 MHz channel width
  725. * @IEEE80211_OPMODE_NOTIF_CHANWIDTH_40MHZ: 40 MHz channel width
  726. * @IEEE80211_OPMODE_NOTIF_CHANWIDTH_80MHZ: 80 MHz channel width
  727. * @IEEE80211_OPMODE_NOTIF_CHANWIDTH_160MHZ: 160 MHz or 80+80 MHz channel width
  728. * @IEEE80211_OPMODE_NOTIF_RX_NSS_MASK: number of spatial streams mask
  729. * (the NSS value is the value of this field + 1)
  730. * @IEEE80211_OPMODE_NOTIF_RX_NSS_SHIFT: number of spatial streams shift
  731. * @IEEE80211_OPMODE_NOTIF_RX_NSS_TYPE_BF: indicates streams in SU-MIMO PPDU
  732. * using a beamforming steering matrix
  733. */
  734. enum ieee80211_vht_opmode_bits {
  735. IEEE80211_OPMODE_NOTIF_CHANWIDTH_MASK = 3,
  736. IEEE80211_OPMODE_NOTIF_CHANWIDTH_20MHZ = 0,
  737. IEEE80211_OPMODE_NOTIF_CHANWIDTH_40MHZ = 1,
  738. IEEE80211_OPMODE_NOTIF_CHANWIDTH_80MHZ = 2,
  739. IEEE80211_OPMODE_NOTIF_CHANWIDTH_160MHZ = 3,
  740. IEEE80211_OPMODE_NOTIF_RX_NSS_MASK = 0x70,
  741. IEEE80211_OPMODE_NOTIF_RX_NSS_SHIFT = 4,
  742. IEEE80211_OPMODE_NOTIF_RX_NSS_TYPE_BF = 0x80,
  743. };
  744. #define WLAN_SA_QUERY_TR_ID_LEN 2
  745. struct ieee80211_mgmt {
  746. __le16 frame_control;
  747. __le16 duration;
  748. u8 da[ETH_ALEN];
  749. u8 sa[ETH_ALEN];
  750. u8 bssid[ETH_ALEN];
  751. __le16 seq_ctrl;
  752. union {
  753. struct {
  754. __le16 auth_alg;
  755. __le16 auth_transaction;
  756. __le16 status_code;
  757. /* possibly followed by Challenge text */
  758. u8 variable[0];
  759. } __packed auth;
  760. struct {
  761. __le16 reason_code;
  762. } __packed deauth;
  763. struct {
  764. __le16 capab_info;
  765. __le16 listen_interval;
  766. /* followed by SSID and Supported rates */
  767. u8 variable[0];
  768. } __packed assoc_req;
  769. struct {
  770. __le16 capab_info;
  771. __le16 status_code;
  772. __le16 aid;
  773. /* followed by Supported rates */
  774. u8 variable[0];
  775. } __packed assoc_resp, reassoc_resp;
  776. struct {
  777. __le16 capab_info;
  778. __le16 listen_interval;
  779. u8 current_ap[ETH_ALEN];
  780. /* followed by SSID and Supported rates */
  781. u8 variable[0];
  782. } __packed reassoc_req;
  783. struct {
  784. __le16 reason_code;
  785. } __packed disassoc;
  786. struct {
  787. __le64 timestamp;
  788. __le16 beacon_int;
  789. __le16 capab_info;
  790. /* followed by some of SSID, Supported rates,
  791. * FH Params, DS Params, CF Params, IBSS Params, TIM */
  792. u8 variable[0];
  793. } __packed beacon;
  794. struct {
  795. /* only variable items: SSID, Supported rates */
  796. u8 variable[0];
  797. } __packed probe_req;
  798. struct {
  799. __le64 timestamp;
  800. __le16 beacon_int;
  801. __le16 capab_info;
  802. /* followed by some of SSID, Supported rates,
  803. * FH Params, DS Params, CF Params, IBSS Params */
  804. u8 variable[0];
  805. } __packed probe_resp;
  806. struct {
  807. u8 category;
  808. union {
  809. struct {
  810. u8 action_code;
  811. u8 dialog_token;
  812. u8 status_code;
  813. u8 variable[0];
  814. } __packed wme_action;
  815. struct{
  816. u8 action_code;
  817. u8 variable[0];
  818. } __packed chan_switch;
  819. struct{
  820. u8 action_code;
  821. struct ieee80211_ext_chansw_ie data;
  822. u8 variable[0];
  823. } __packed ext_chan_switch;
  824. struct{
  825. u8 action_code;
  826. u8 dialog_token;
  827. u8 element_id;
  828. u8 length;
  829. struct ieee80211_msrment_ie msr_elem;
  830. } __packed measurement;
  831. struct{
  832. u8 action_code;
  833. u8 dialog_token;
  834. __le16 capab;
  835. __le16 timeout;
  836. __le16 start_seq_num;
  837. } __packed addba_req;
  838. struct{
  839. u8 action_code;
  840. u8 dialog_token;
  841. __le16 status;
  842. __le16 capab;
  843. __le16 timeout;
  844. } __packed addba_resp;
  845. struct{
  846. u8 action_code;
  847. __le16 params;
  848. __le16 reason_code;
  849. } __packed delba;
  850. struct {
  851. u8 action_code;
  852. u8 variable[0];
  853. } __packed self_prot;
  854. struct{
  855. u8 action_code;
  856. u8 variable[0];
  857. } __packed mesh_action;
  858. struct {
  859. u8 action;
  860. u8 trans_id[WLAN_SA_QUERY_TR_ID_LEN];
  861. } __packed sa_query;
  862. struct {
  863. u8 action;
  864. u8 smps_control;
  865. } __packed ht_smps;
  866. struct {
  867. u8 action_code;
  868. u8 chanwidth;
  869. } __packed ht_notify_cw;
  870. struct {
  871. u8 action_code;
  872. u8 dialog_token;
  873. __le16 capability;
  874. u8 variable[0];
  875. } __packed tdls_discover_resp;
  876. struct {
  877. u8 action_code;
  878. u8 operating_mode;
  879. } __packed vht_opmode_notif;
  880. } u;
  881. } __packed action;
  882. } u;
  883. } __packed __aligned(2);
  884. /* Supported Rates value encodings in 802.11n-2009 7.3.2.2 */
  885. #define BSS_MEMBERSHIP_SELECTOR_HT_PHY 127
  886. /* mgmt header + 1 byte category code */
  887. #define IEEE80211_MIN_ACTION_SIZE offsetof(struct ieee80211_mgmt, u.action.u)
  888. /* Management MIC information element (IEEE 802.11w) */
  889. struct ieee80211_mmie {
  890. u8 element_id;
  891. u8 length;
  892. __le16 key_id;
  893. u8 sequence_number[6];
  894. u8 mic[8];
  895. } __packed;
  896. struct ieee80211_vendor_ie {
  897. u8 element_id;
  898. u8 len;
  899. u8 oui[3];
  900. u8 oui_type;
  901. } __packed;
  902. /* Control frames */
  903. struct ieee80211_rts {
  904. __le16 frame_control;
  905. __le16 duration;
  906. u8 ra[ETH_ALEN];
  907. u8 ta[ETH_ALEN];
  908. } __packed __aligned(2);
  909. struct ieee80211_cts {
  910. __le16 frame_control;
  911. __le16 duration;
  912. u8 ra[ETH_ALEN];
  913. } __packed __aligned(2);
  914. struct ieee80211_pspoll {
  915. __le16 frame_control;
  916. __le16 aid;
  917. u8 bssid[ETH_ALEN];
  918. u8 ta[ETH_ALEN];
  919. } __packed __aligned(2);
  920. /* TDLS */
  921. /* Link-id information element */
  922. struct ieee80211_tdls_lnkie {
  923. u8 ie_type; /* Link Identifier IE */
  924. u8 ie_len;
  925. u8 bssid[ETH_ALEN];
  926. u8 init_sta[ETH_ALEN];
  927. u8 resp_sta[ETH_ALEN];
  928. } __packed;
  929. struct ieee80211_tdls_data {
  930. u8 da[ETH_ALEN];
  931. u8 sa[ETH_ALEN];
  932. __be16 ether_type;
  933. u8 payload_type;
  934. u8 category;
  935. u8 action_code;
  936. union {
  937. struct {
  938. u8 dialog_token;
  939. __le16 capability;
  940. u8 variable[0];
  941. } __packed setup_req;
  942. struct {
  943. __le16 status_code;
  944. u8 dialog_token;
  945. __le16 capability;
  946. u8 variable[0];
  947. } __packed setup_resp;
  948. struct {
  949. __le16 status_code;
  950. u8 dialog_token;
  951. u8 variable[0];
  952. } __packed setup_cfm;
  953. struct {
  954. __le16 reason_code;
  955. u8 variable[0];
  956. } __packed teardown;
  957. struct {
  958. u8 dialog_token;
  959. u8 variable[0];
  960. } __packed discover_req;
  961. } u;
  962. } __packed;
  963. /*
  964. * Peer-to-Peer IE attribute related definitions.
  965. */
  966. /**
  967. * enum ieee80211_p2p_attr_id - identifies type of peer-to-peer attribute.
  968. */
  969. enum ieee80211_p2p_attr_id {
  970. IEEE80211_P2P_ATTR_STATUS = 0,
  971. IEEE80211_P2P_ATTR_MINOR_REASON,
  972. IEEE80211_P2P_ATTR_CAPABILITY,
  973. IEEE80211_P2P_ATTR_DEVICE_ID,
  974. IEEE80211_P2P_ATTR_GO_INTENT,
  975. IEEE80211_P2P_ATTR_GO_CONFIG_TIMEOUT,
  976. IEEE80211_P2P_ATTR_LISTEN_CHANNEL,
  977. IEEE80211_P2P_ATTR_GROUP_BSSID,
  978. IEEE80211_P2P_ATTR_EXT_LISTEN_TIMING,
  979. IEEE80211_P2P_ATTR_INTENDED_IFACE_ADDR,
  980. IEEE80211_P2P_ATTR_MANAGABILITY,
  981. IEEE80211_P2P_ATTR_CHANNEL_LIST,
  982. IEEE80211_P2P_ATTR_ABSENCE_NOTICE,
  983. IEEE80211_P2P_ATTR_DEVICE_INFO,
  984. IEEE80211_P2P_ATTR_GROUP_INFO,
  985. IEEE80211_P2P_ATTR_GROUP_ID,
  986. IEEE80211_P2P_ATTR_INTERFACE,
  987. IEEE80211_P2P_ATTR_OPER_CHANNEL,
  988. IEEE80211_P2P_ATTR_INVITE_FLAGS,
  989. /* 19 - 220: Reserved */
  990. IEEE80211_P2P_ATTR_VENDOR_SPECIFIC = 221,
  991. IEEE80211_P2P_ATTR_MAX
  992. };
  993. /* Notice of Absence attribute - described in P2P spec 4.1.14 */
  994. /* Typical max value used here */
  995. #define IEEE80211_P2P_NOA_DESC_MAX 4
  996. struct ieee80211_p2p_noa_desc {
  997. u8 count;
  998. __le32 duration;
  999. __le32 interval;
  1000. __le32 start_time;
  1001. } __packed;
  1002. struct ieee80211_p2p_noa_attr {
  1003. u8 index;
  1004. u8 oppps_ctwindow;
  1005. struct ieee80211_p2p_noa_desc desc[IEEE80211_P2P_NOA_DESC_MAX];
  1006. } __packed;
  1007. #define IEEE80211_P2P_OPPPS_ENABLE_BIT BIT(7)
  1008. #define IEEE80211_P2P_OPPPS_CTWINDOW_MASK 0x7F
  1009. /**
  1010. * struct ieee80211_bar - HT Block Ack Request
  1011. *
  1012. * This structure refers to "HT BlockAckReq" as
  1013. * described in 802.11n draft section 7.2.1.7.1
  1014. */
  1015. struct ieee80211_bar {
  1016. __le16 frame_control;
  1017. __le16 duration;
  1018. __u8 ra[ETH_ALEN];
  1019. __u8 ta[ETH_ALEN];
  1020. __le16 control;
  1021. __le16 start_seq_num;
  1022. } __packed;
  1023. /* 802.11 BAR control masks */
  1024. #define IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL 0x0000
  1025. #define IEEE80211_BAR_CTRL_MULTI_TID 0x0002
  1026. #define IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA 0x0004
  1027. #define IEEE80211_BAR_CTRL_TID_INFO_MASK 0xf000
  1028. #define IEEE80211_BAR_CTRL_TID_INFO_SHIFT 12
  1029. #define IEEE80211_HT_MCS_MASK_LEN 10
  1030. /**
  1031. * struct ieee80211_mcs_info - MCS information
  1032. * @rx_mask: RX mask
  1033. * @rx_highest: highest supported RX rate. If set represents
  1034. * the highest supported RX data rate in units of 1 Mbps.
  1035. * If this field is 0 this value should not be used to
  1036. * consider the highest RX data rate supported.
  1037. * @tx_params: TX parameters
  1038. */
  1039. struct ieee80211_mcs_info {
  1040. u8 rx_mask[IEEE80211_HT_MCS_MASK_LEN];
  1041. __le16 rx_highest;
  1042. u8 tx_params;
  1043. u8 reserved[3];
  1044. } __packed;
  1045. /* 802.11n HT capability MSC set */
  1046. #define IEEE80211_HT_MCS_RX_HIGHEST_MASK 0x3ff
  1047. #define IEEE80211_HT_MCS_TX_DEFINED 0x01
  1048. #define IEEE80211_HT_MCS_TX_RX_DIFF 0x02
  1049. /* value 0 == 1 stream etc */
  1050. #define IEEE80211_HT_MCS_TX_MAX_STREAMS_MASK 0x0C
  1051. #define IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT 2
  1052. #define IEEE80211_HT_MCS_TX_MAX_STREAMS 4
  1053. #define IEEE80211_HT_MCS_TX_UNEQUAL_MODULATION 0x10
  1054. /*
  1055. * 802.11n D5.0 20.3.5 / 20.6 says:
  1056. * - indices 0 to 7 and 32 are single spatial stream
  1057. * - 8 to 31 are multiple spatial streams using equal modulation
  1058. * [8..15 for two streams, 16..23 for three and 24..31 for four]
  1059. * - remainder are multiple spatial streams using unequal modulation
  1060. */
  1061. #define IEEE80211_HT_MCS_UNEQUAL_MODULATION_START 33
  1062. #define IEEE80211_HT_MCS_UNEQUAL_MODULATION_START_BYTE \
  1063. (IEEE80211_HT_MCS_UNEQUAL_MODULATION_START / 8)
  1064. /**
  1065. * struct ieee80211_ht_cap - HT capabilities
  1066. *
  1067. * This structure is the "HT capabilities element" as
  1068. * described in 802.11n D5.0 7.3.2.57
  1069. */
  1070. struct ieee80211_ht_cap {
  1071. __le16 cap_info;
  1072. u8 ampdu_params_info;
  1073. /* 16 bytes MCS information */
  1074. struct ieee80211_mcs_info mcs;
  1075. __le16 extended_ht_cap_info;
  1076. __le32 tx_BF_cap_info;
  1077. u8 antenna_selection_info;
  1078. } __packed;
  1079. /* 802.11n HT capabilities masks (for cap_info) */
  1080. #define IEEE80211_HT_CAP_LDPC_CODING 0x0001
  1081. #define IEEE80211_HT_CAP_SUP_WIDTH_20_40 0x0002
  1082. #define IEEE80211_HT_CAP_SM_PS 0x000C
  1083. #define IEEE80211_HT_CAP_SM_PS_SHIFT 2
  1084. #define IEEE80211_HT_CAP_GRN_FLD 0x0010
  1085. #define IEEE80211_HT_CAP_SGI_20 0x0020
  1086. #define IEEE80211_HT_CAP_SGI_40 0x0040
  1087. #define IEEE80211_HT_CAP_TX_STBC 0x0080
  1088. #define IEEE80211_HT_CAP_RX_STBC 0x0300
  1089. #define IEEE80211_HT_CAP_RX_STBC_SHIFT 8
  1090. #define IEEE80211_HT_CAP_DELAY_BA 0x0400
  1091. #define IEEE80211_HT_CAP_MAX_AMSDU 0x0800
  1092. #define IEEE80211_HT_CAP_DSSSCCK40 0x1000
  1093. #define IEEE80211_HT_CAP_RESERVED 0x2000
  1094. #define IEEE80211_HT_CAP_40MHZ_INTOLERANT 0x4000
  1095. #define IEEE80211_HT_CAP_LSIG_TXOP_PROT 0x8000
  1096. /* 802.11n HT extended capabilities masks (for extended_ht_cap_info) */
  1097. #define IEEE80211_HT_EXT_CAP_PCO 0x0001
  1098. #define IEEE80211_HT_EXT_CAP_PCO_TIME 0x0006
  1099. #define IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT 1
  1100. #define IEEE80211_HT_EXT_CAP_MCS_FB 0x0300
  1101. #define IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT 8
  1102. #define IEEE80211_HT_EXT_CAP_HTC_SUP 0x0400
  1103. #define IEEE80211_HT_EXT_CAP_RD_RESPONDER 0x0800
  1104. /* 802.11n HT capability AMPDU settings (for ampdu_params_info) */
  1105. #define IEEE80211_HT_AMPDU_PARM_FACTOR 0x03
  1106. #define IEEE80211_HT_AMPDU_PARM_DENSITY 0x1C
  1107. #define IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT 2
  1108. /*
  1109. * Maximum length of AMPDU that the STA can receive.
  1110. * Length = 2 ^ (13 + max_ampdu_length_exp) - 1 (octets)
  1111. */
  1112. enum ieee80211_max_ampdu_length_exp {
  1113. IEEE80211_HT_MAX_AMPDU_8K = 0,
  1114. IEEE80211_HT_MAX_AMPDU_16K = 1,
  1115. IEEE80211_HT_MAX_AMPDU_32K = 2,
  1116. IEEE80211_HT_MAX_AMPDU_64K = 3
  1117. };
  1118. #define IEEE80211_HT_MAX_AMPDU_FACTOR 13
  1119. /* Minimum MPDU start spacing */
  1120. enum ieee80211_min_mpdu_spacing {
  1121. IEEE80211_HT_MPDU_DENSITY_NONE = 0, /* No restriction */
  1122. IEEE80211_HT_MPDU_DENSITY_0_25 = 1, /* 1/4 usec */
  1123. IEEE80211_HT_MPDU_DENSITY_0_5 = 2, /* 1/2 usec */
  1124. IEEE80211_HT_MPDU_DENSITY_1 = 3, /* 1 usec */
  1125. IEEE80211_HT_MPDU_DENSITY_2 = 4, /* 2 usec */
  1126. IEEE80211_HT_MPDU_DENSITY_4 = 5, /* 4 usec */
  1127. IEEE80211_HT_MPDU_DENSITY_8 = 6, /* 8 usec */
  1128. IEEE80211_HT_MPDU_DENSITY_16 = 7 /* 16 usec */
  1129. };
  1130. /**
  1131. * struct ieee80211_ht_operation - HT operation IE
  1132. *
  1133. * This structure is the "HT operation element" as
  1134. * described in 802.11n-2009 7.3.2.57
  1135. */
  1136. struct ieee80211_ht_operation {
  1137. u8 primary_chan;
  1138. u8 ht_param;
  1139. __le16 operation_mode;
  1140. __le16 stbc_param;
  1141. u8 basic_set[16];
  1142. } __packed;
  1143. /* for ht_param */
  1144. #define IEEE80211_HT_PARAM_CHA_SEC_OFFSET 0x03
  1145. #define IEEE80211_HT_PARAM_CHA_SEC_NONE 0x00
  1146. #define IEEE80211_HT_PARAM_CHA_SEC_ABOVE 0x01
  1147. #define IEEE80211_HT_PARAM_CHA_SEC_BELOW 0x03
  1148. #define IEEE80211_HT_PARAM_CHAN_WIDTH_ANY 0x04
  1149. #define IEEE80211_HT_PARAM_RIFS_MODE 0x08
  1150. /* for operation_mode */
  1151. #define IEEE80211_HT_OP_MODE_PROTECTION 0x0003
  1152. #define IEEE80211_HT_OP_MODE_PROTECTION_NONE 0
  1153. #define IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER 1
  1154. #define IEEE80211_HT_OP_MODE_PROTECTION_20MHZ 2
  1155. #define IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED 3
  1156. #define IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT 0x0004
  1157. #define IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT 0x0010
  1158. /* for stbc_param */
  1159. #define IEEE80211_HT_STBC_PARAM_DUAL_BEACON 0x0040
  1160. #define IEEE80211_HT_STBC_PARAM_DUAL_CTS_PROT 0x0080
  1161. #define IEEE80211_HT_STBC_PARAM_STBC_BEACON 0x0100
  1162. #define IEEE80211_HT_STBC_PARAM_LSIG_TXOP_FULLPROT 0x0200
  1163. #define IEEE80211_HT_STBC_PARAM_PCO_ACTIVE 0x0400
  1164. #define IEEE80211_HT_STBC_PARAM_PCO_PHASE 0x0800
  1165. /* block-ack parameters */
  1166. #define IEEE80211_ADDBA_PARAM_POLICY_MASK 0x0002
  1167. #define IEEE80211_ADDBA_PARAM_TID_MASK 0x003C
  1168. #define IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK 0xFFC0
  1169. #define IEEE80211_DELBA_PARAM_TID_MASK 0xF000
  1170. #define IEEE80211_DELBA_PARAM_INITIATOR_MASK 0x0800
  1171. /*
  1172. * A-PMDU buffer sizes
  1173. * According to IEEE802.11n spec size varies from 8K to 64K (in powers of 2)
  1174. */
  1175. #define IEEE80211_MIN_AMPDU_BUF 0x8
  1176. #define IEEE80211_MAX_AMPDU_BUF 0x40
  1177. /* Spatial Multiplexing Power Save Modes (for capability) */
  1178. #define WLAN_HT_CAP_SM_PS_STATIC 0
  1179. #define WLAN_HT_CAP_SM_PS_DYNAMIC 1
  1180. #define WLAN_HT_CAP_SM_PS_INVALID 2
  1181. #define WLAN_HT_CAP_SM_PS_DISABLED 3
  1182. /* for SM power control field lower two bits */
  1183. #define WLAN_HT_SMPS_CONTROL_DISABLED 0
  1184. #define WLAN_HT_SMPS_CONTROL_STATIC 1
  1185. #define WLAN_HT_SMPS_CONTROL_DYNAMIC 3
  1186. /**
  1187. * struct ieee80211_vht_mcs_info - VHT MCS information
  1188. * @rx_mcs_map: RX MCS map 2 bits for each stream, total 8 streams
  1189. * @rx_highest: Indicates highest long GI VHT PPDU data rate
  1190. * STA can receive. Rate expressed in units of 1 Mbps.
  1191. * If this field is 0 this value should not be used to
  1192. * consider the highest RX data rate supported.
  1193. * The top 3 bits of this field are reserved.
  1194. * @tx_mcs_map: TX MCS map 2 bits for each stream, total 8 streams
  1195. * @tx_highest: Indicates highest long GI VHT PPDU data rate
  1196. * STA can transmit. Rate expressed in units of 1 Mbps.
  1197. * If this field is 0 this value should not be used to
  1198. * consider the highest TX data rate supported.
  1199. * The top 3 bits of this field are reserved.
  1200. */
  1201. struct ieee80211_vht_mcs_info {
  1202. __le16 rx_mcs_map;
  1203. __le16 rx_highest;
  1204. __le16 tx_mcs_map;
  1205. __le16 tx_highest;
  1206. } __packed;
  1207. /**
  1208. * enum ieee80211_vht_mcs_support - VHT MCS support definitions
  1209. * @IEEE80211_VHT_MCS_SUPPORT_0_7: MCSes 0-7 are supported for the
  1210. * number of streams
  1211. * @IEEE80211_VHT_MCS_SUPPORT_0_8: MCSes 0-8 are supported
  1212. * @IEEE80211_VHT_MCS_SUPPORT_0_9: MCSes 0-9 are supported
  1213. * @IEEE80211_VHT_MCS_NOT_SUPPORTED: This number of streams isn't supported
  1214. *
  1215. * These definitions are used in each 2-bit subfield of the @rx_mcs_map
  1216. * and @tx_mcs_map fields of &struct ieee80211_vht_mcs_info, which are
  1217. * both split into 8 subfields by number of streams. These values indicate
  1218. * which MCSes are supported for the number of streams the value appears
  1219. * for.
  1220. */
  1221. enum ieee80211_vht_mcs_support {
  1222. IEEE80211_VHT_MCS_SUPPORT_0_7 = 0,
  1223. IEEE80211_VHT_MCS_SUPPORT_0_8 = 1,
  1224. IEEE80211_VHT_MCS_SUPPORT_0_9 = 2,
  1225. IEEE80211_VHT_MCS_NOT_SUPPORTED = 3,
  1226. };
  1227. /**
  1228. * struct ieee80211_vht_cap - VHT capabilities
  1229. *
  1230. * This structure is the "VHT capabilities element" as
  1231. * described in 802.11ac D3.0 8.4.2.160
  1232. * @vht_cap_info: VHT capability info
  1233. * @supp_mcs: VHT MCS supported rates
  1234. */
  1235. struct ieee80211_vht_cap {
  1236. __le32 vht_cap_info;
  1237. struct ieee80211_vht_mcs_info supp_mcs;
  1238. } __packed;
  1239. /**
  1240. * enum ieee80211_vht_chanwidth - VHT channel width
  1241. * @IEEE80211_VHT_CHANWIDTH_USE_HT: use the HT operation IE to
  1242. * determine the channel width (20 or 40 MHz)
  1243. * @IEEE80211_VHT_CHANWIDTH_80MHZ: 80 MHz bandwidth
  1244. * @IEEE80211_VHT_CHANWIDTH_160MHZ: 160 MHz bandwidth
  1245. * @IEEE80211_VHT_CHANWIDTH_80P80MHZ: 80+80 MHz bandwidth
  1246. */
  1247. enum ieee80211_vht_chanwidth {
  1248. IEEE80211_VHT_CHANWIDTH_USE_HT = 0,
  1249. IEEE80211_VHT_CHANWIDTH_80MHZ = 1,
  1250. IEEE80211_VHT_CHANWIDTH_160MHZ = 2,
  1251. IEEE80211_VHT_CHANWIDTH_80P80MHZ = 3,
  1252. };
  1253. /**
  1254. * struct ieee80211_vht_operation - VHT operation IE
  1255. *
  1256. * This structure is the "VHT operation element" as
  1257. * described in 802.11ac D3.0 8.4.2.161
  1258. * @chan_width: Operating channel width
  1259. * @center_freq_seg1_idx: center freq segment 1 index
  1260. * @center_freq_seg2_idx: center freq segment 2 index
  1261. * @basic_mcs_set: VHT Basic MCS rate set
  1262. */
  1263. struct ieee80211_vht_operation {
  1264. u8 chan_width;
  1265. u8 center_freq_seg1_idx;
  1266. u8 center_freq_seg2_idx;
  1267. __le16 basic_mcs_set;
  1268. } __packed;
  1269. /* 802.11ac VHT Capabilities */
  1270. #define IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895 0x00000000
  1271. #define IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991 0x00000001
  1272. #define IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454 0x00000002
  1273. #define IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ 0x00000004
  1274. #define IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ 0x00000008
  1275. #define IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK 0x0000000C
  1276. #define IEEE80211_VHT_CAP_RXLDPC 0x00000010
  1277. #define IEEE80211_VHT_CAP_SHORT_GI_80 0x00000020
  1278. #define IEEE80211_VHT_CAP_SHORT_GI_160 0x00000040
  1279. #define IEEE80211_VHT_CAP_TXSTBC 0x00000080
  1280. #define IEEE80211_VHT_CAP_RXSTBC_1 0x00000100
  1281. #define IEEE80211_VHT_CAP_RXSTBC_2 0x00000200
  1282. #define IEEE80211_VHT_CAP_RXSTBC_3 0x00000300
  1283. #define IEEE80211_VHT_CAP_RXSTBC_4 0x00000400
  1284. #define IEEE80211_VHT_CAP_RXSTBC_MASK 0x00000700
  1285. #define IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE 0x00000800
  1286. #define IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE 0x00001000
  1287. #define IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT 13
  1288. #define IEEE80211_VHT_CAP_BEAMFORMEE_STS_MASK \
  1289. (7 << IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT)
  1290. #define IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT 16
  1291. #define IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_MASK \
  1292. (7 << IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT)
  1293. #define IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE 0x00080000
  1294. #define IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE 0x00100000
  1295. #define IEEE80211_VHT_CAP_VHT_TXOP_PS 0x00200000
  1296. #define IEEE80211_VHT_CAP_HTC_VHT 0x00400000
  1297. #define IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT 23
  1298. #define IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK \
  1299. (7 << IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT)
  1300. #define IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_UNSOL_MFB 0x08000000
  1301. #define IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB 0x0c000000
  1302. #define IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN 0x10000000
  1303. #define IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN 0x20000000
  1304. /* Authentication algorithms */
  1305. #define WLAN_AUTH_OPEN 0
  1306. #define WLAN_AUTH_SHARED_KEY 1
  1307. #define WLAN_AUTH_FT 2
  1308. #define WLAN_AUTH_SAE 3
  1309. #define WLAN_AUTH_LEAP 128
  1310. #define WLAN_AUTH_CHALLENGE_LEN 128
  1311. #define WLAN_CAPABILITY_ESS (1<<0)
  1312. #define WLAN_CAPABILITY_IBSS (1<<1)
  1313. /*
  1314. * A mesh STA sets the ESS and IBSS capability bits to zero.
  1315. * however, this holds true for p2p probe responses (in the p2p_find
  1316. * phase) as well.
  1317. */
  1318. #define WLAN_CAPABILITY_IS_STA_BSS(cap) \
  1319. (!((cap) & (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS)))
  1320. #define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
  1321. #define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
  1322. #define WLAN_CAPABILITY_PRIVACY (1<<4)
  1323. #define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
  1324. #define WLAN_CAPABILITY_PBCC (1<<6)
  1325. #define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
  1326. /* 802.11h */
  1327. #define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8)
  1328. #define WLAN_CAPABILITY_QOS (1<<9)
  1329. #define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10)
  1330. #define WLAN_CAPABILITY_APSD (1<<11)
  1331. #define WLAN_CAPABILITY_RADIO_MEASURE (1<<12)
  1332. #define WLAN_CAPABILITY_DSSS_OFDM (1<<13)
  1333. #define WLAN_CAPABILITY_DEL_BACK (1<<14)
  1334. #define WLAN_CAPABILITY_IMM_BACK (1<<15)
  1335. /* DMG (60gHz) 802.11ad */
  1336. /* type - bits 0..1 */
  1337. #define WLAN_CAPABILITY_DMG_TYPE_MASK (3<<0)
  1338. #define WLAN_CAPABILITY_DMG_TYPE_IBSS (1<<0) /* Tx by: STA */
  1339. #define WLAN_CAPABILITY_DMG_TYPE_PBSS (2<<0) /* Tx by: PCP */
  1340. #define WLAN_CAPABILITY_DMG_TYPE_AP (3<<0) /* Tx by: AP */
  1341. #define WLAN_CAPABILITY_DMG_CBAP_ONLY (1<<2)
  1342. #define WLAN_CAPABILITY_DMG_CBAP_SOURCE (1<<3)
  1343. #define WLAN_CAPABILITY_DMG_PRIVACY (1<<4)
  1344. #define WLAN_CAPABILITY_DMG_ECPAC (1<<5)
  1345. #define WLAN_CAPABILITY_DMG_SPECTRUM_MGMT (1<<8)
  1346. #define WLAN_CAPABILITY_DMG_RADIO_MEASURE (1<<12)
  1347. /* measurement */
  1348. #define IEEE80211_SPCT_MSR_RPRT_MODE_LATE (1<<0)
  1349. #define IEEE80211_SPCT_MSR_RPRT_MODE_INCAPABLE (1<<1)
  1350. #define IEEE80211_SPCT_MSR_RPRT_MODE_REFUSED (1<<2)
  1351. #define IEEE80211_SPCT_MSR_RPRT_TYPE_BASIC 0
  1352. #define IEEE80211_SPCT_MSR_RPRT_TYPE_CCA 1
  1353. #define IEEE80211_SPCT_MSR_RPRT_TYPE_RPI 2
  1354. /* 802.11g ERP information element */
  1355. #define WLAN_ERP_NON_ERP_PRESENT (1<<0)
  1356. #define WLAN_ERP_USE_PROTECTION (1<<1)
  1357. #define WLAN_ERP_BARKER_PREAMBLE (1<<2)
  1358. /* WLAN_ERP_BARKER_PREAMBLE values */
  1359. enum {
  1360. WLAN_ERP_PREAMBLE_SHORT = 0,
  1361. WLAN_ERP_PREAMBLE_LONG = 1,
  1362. };
  1363. /* Band ID, 802.11ad #8.4.1.45 */
  1364. enum {
  1365. IEEE80211_BANDID_TV_WS = 0, /* TV white spaces */
  1366. IEEE80211_BANDID_SUB1 = 1, /* Sub-1 GHz (excluding TV white spaces) */
  1367. IEEE80211_BANDID_2G = 2, /* 2.4 GHz */
  1368. IEEE80211_BANDID_3G = 3, /* 3.6 GHz */
  1369. IEEE80211_BANDID_5G = 4, /* 4.9 and 5 GHz */
  1370. IEEE80211_BANDID_60G = 5, /* 60 GHz */
  1371. };
  1372. /* Status codes */
  1373. enum ieee80211_statuscode {
  1374. WLAN_STATUS_SUCCESS = 0,
  1375. WLAN_STATUS_UNSPECIFIED_FAILURE = 1,
  1376. WLAN_STATUS_CAPS_UNSUPPORTED = 10,
  1377. WLAN_STATUS_REASSOC_NO_ASSOC = 11,
  1378. WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12,
  1379. WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13,
  1380. WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14,
  1381. WLAN_STATUS_CHALLENGE_FAIL = 15,
  1382. WLAN_STATUS_AUTH_TIMEOUT = 16,
  1383. WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17,
  1384. WLAN_STATUS_ASSOC_DENIED_RATES = 18,
  1385. /* 802.11b */
  1386. WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19,
  1387. WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20,
  1388. WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21,
  1389. /* 802.11h */
  1390. WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22,
  1391. WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23,
  1392. WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24,
  1393. /* 802.11g */
  1394. WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25,
  1395. WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26,
  1396. /* 802.11w */
  1397. WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY = 30,
  1398. WLAN_STATUS_ROBUST_MGMT_FRAME_POLICY_VIOLATION = 31,
  1399. /* 802.11i */
  1400. WLAN_STATUS_INVALID_IE = 40,
  1401. WLAN_STATUS_INVALID_GROUP_CIPHER = 41,
  1402. WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42,
  1403. WLAN_STATUS_INVALID_AKMP = 43,
  1404. WLAN_STATUS_UNSUPP_RSN_VERSION = 44,
  1405. WLAN_STATUS_INVALID_RSN_IE_CAP = 45,
  1406. WLAN_STATUS_CIPHER_SUITE_REJECTED = 46,
  1407. /* 802.11e */
  1408. WLAN_STATUS_UNSPECIFIED_QOS = 32,
  1409. WLAN_STATUS_ASSOC_DENIED_NOBANDWIDTH = 33,
  1410. WLAN_STATUS_ASSOC_DENIED_LOWACK = 34,
  1411. WLAN_STATUS_ASSOC_DENIED_UNSUPP_QOS = 35,
  1412. WLAN_STATUS_REQUEST_DECLINED = 37,
  1413. WLAN_STATUS_INVALID_QOS_PARAM = 38,
  1414. WLAN_STATUS_CHANGE_TSPEC = 39,
  1415. WLAN_STATUS_WAIT_TS_DELAY = 47,
  1416. WLAN_STATUS_NO_DIRECT_LINK = 48,
  1417. WLAN_STATUS_STA_NOT_PRESENT = 49,
  1418. WLAN_STATUS_STA_NOT_QSTA = 50,
  1419. /* 802.11s */
  1420. WLAN_STATUS_ANTI_CLOG_REQUIRED = 76,
  1421. WLAN_STATUS_FCG_NOT_SUPP = 78,
  1422. WLAN_STATUS_STA_NO_TBTT = 78,
  1423. /* 802.11ad */
  1424. WLAN_STATUS_REJECTED_WITH_SUGGESTED_CHANGES = 39,
  1425. WLAN_STATUS_REJECTED_FOR_DELAY_PERIOD = 47,
  1426. WLAN_STATUS_REJECT_WITH_SCHEDULE = 83,
  1427. WLAN_STATUS_PENDING_ADMITTING_FST_SESSION = 86,
  1428. WLAN_STATUS_PERFORMING_FST_NOW = 87,
  1429. WLAN_STATUS_PENDING_GAP_IN_BA_WINDOW = 88,
  1430. WLAN_STATUS_REJECT_U_PID_SETTING = 89,
  1431. WLAN_STATUS_REJECT_DSE_BAND = 96,
  1432. WLAN_STATUS_DENIED_WITH_SUGGESTED_BAND_AND_CHANNEL = 99,
  1433. WLAN_STATUS_DENIED_DUE_TO_SPECTRUM_MANAGEMENT = 103,
  1434. };
  1435. /* Reason codes */
  1436. enum ieee80211_reasoncode {
  1437. WLAN_REASON_UNSPECIFIED = 1,
  1438. WLAN_REASON_PREV_AUTH_NOT_VALID = 2,
  1439. WLAN_REASON_DEAUTH_LEAVING = 3,
  1440. WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4,
  1441. WLAN_REASON_DISASSOC_AP_BUSY = 5,
  1442. WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6,
  1443. WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7,
  1444. WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8,
  1445. WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9,
  1446. /* 802.11h */
  1447. WLAN_REASON_DISASSOC_BAD_POWER = 10,
  1448. WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11,
  1449. /* 802.11i */
  1450. WLAN_REASON_INVALID_IE = 13,
  1451. WLAN_REASON_MIC_FAILURE = 14,
  1452. WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15,
  1453. WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16,
  1454. WLAN_REASON_IE_DIFFERENT = 17,
  1455. WLAN_REASON_INVALID_GROUP_CIPHER = 18,
  1456. WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19,
  1457. WLAN_REASON_INVALID_AKMP = 20,
  1458. WLAN_REASON_UNSUPP_RSN_VERSION = 21,
  1459. WLAN_REASON_INVALID_RSN_IE_CAP = 22,
  1460. WLAN_REASON_IEEE8021X_FAILED = 23,
  1461. WLAN_REASON_CIPHER_SUITE_REJECTED = 24,
  1462. /* 802.11e */
  1463. WLAN_REASON_DISASSOC_UNSPECIFIED_QOS = 32,
  1464. WLAN_REASON_DISASSOC_QAP_NO_BANDWIDTH = 33,
  1465. WLAN_REASON_DISASSOC_LOW_ACK = 34,
  1466. WLAN_REASON_DISASSOC_QAP_EXCEED_TXOP = 35,
  1467. WLAN_REASON_QSTA_LEAVE_QBSS = 36,
  1468. WLAN_REASON_QSTA_NOT_USE = 37,
  1469. WLAN_REASON_QSTA_REQUIRE_SETUP = 38,
  1470. WLAN_REASON_QSTA_TIMEOUT = 39,
  1471. WLAN_REASON_QSTA_CIPHER_NOT_SUPP = 45,
  1472. /* 802.11s */
  1473. WLAN_REASON_MESH_PEER_CANCELED = 52,
  1474. WLAN_REASON_MESH_MAX_PEERS = 53,
  1475. WLAN_REASON_MESH_CONFIG = 54,
  1476. WLAN_REASON_MESH_CLOSE = 55,
  1477. WLAN_REASON_MESH_MAX_RETRIES = 56,
  1478. WLAN_REASON_MESH_CONFIRM_TIMEOUT = 57,
  1479. WLAN_REASON_MESH_INVALID_GTK = 58,
  1480. WLAN_REASON_MESH_INCONSISTENT_PARAM = 59,
  1481. WLAN_REASON_MESH_INVALID_SECURITY = 60,
  1482. WLAN_REASON_MESH_PATH_ERROR = 61,
  1483. WLAN_REASON_MESH_PATH_NOFORWARD = 62,
  1484. WLAN_REASON_MESH_PATH_DEST_UNREACHABLE = 63,
  1485. WLAN_REASON_MAC_EXISTS_IN_MBSS = 64,
  1486. WLAN_REASON_MESH_CHAN_REGULATORY = 65,
  1487. WLAN_REASON_MESH_CHAN = 66,
  1488. };
  1489. /* Information Element IDs */
  1490. enum ieee80211_eid {
  1491. WLAN_EID_SSID = 0,
  1492. WLAN_EID_SUPP_RATES = 1,
  1493. WLAN_EID_FH_PARAMS = 2, /* reserved now */
  1494. WLAN_EID_DS_PARAMS = 3,
  1495. WLAN_EID_CF_PARAMS = 4,
  1496. WLAN_EID_TIM = 5,
  1497. WLAN_EID_IBSS_PARAMS = 6,
  1498. WLAN_EID_COUNTRY = 7,
  1499. WLAN_EID_HP_PARAMS = 8,
  1500. WLAN_EID_HP_TABLE = 9,
  1501. WLAN_EID_REQUEST = 10,
  1502. WLAN_EID_QBSS_LOAD = 11,
  1503. WLAN_EID_EDCA_PARAM_SET = 12,
  1504. WLAN_EID_TSPEC = 13,
  1505. WLAN_EID_TCLAS = 14,
  1506. WLAN_EID_SCHEDULE = 15,
  1507. WLAN_EID_CHALLENGE = 16,
  1508. /* 17-31 reserved for challenge text extension */
  1509. WLAN_EID_PWR_CONSTRAINT = 32,
  1510. WLAN_EID_PWR_CAPABILITY = 33,
  1511. WLAN_EID_TPC_REQUEST = 34,
  1512. WLAN_EID_TPC_REPORT = 35,
  1513. WLAN_EID_SUPPORTED_CHANNELS = 36,
  1514. WLAN_EID_CHANNEL_SWITCH = 37,
  1515. WLAN_EID_MEASURE_REQUEST = 38,
  1516. WLAN_EID_MEASURE_REPORT = 39,
  1517. WLAN_EID_QUIET = 40,
  1518. WLAN_EID_IBSS_DFS = 41,
  1519. WLAN_EID_ERP_INFO = 42,
  1520. WLAN_EID_TS_DELAY = 43,
  1521. WLAN_EID_TCLAS_PROCESSING = 44,
  1522. WLAN_EID_HT_CAPABILITY = 45,
  1523. WLAN_EID_QOS_CAPA = 46,
  1524. /* 47 reserved for Broadcom */
  1525. WLAN_EID_RSN = 48,
  1526. WLAN_EID_802_15_COEX = 49,
  1527. WLAN_EID_EXT_SUPP_RATES = 50,
  1528. WLAN_EID_AP_CHAN_REPORT = 51,
  1529. WLAN_EID_NEIGHBOR_REPORT = 52,
  1530. WLAN_EID_RCPI = 53,
  1531. WLAN_EID_MOBILITY_DOMAIN = 54,
  1532. WLAN_EID_FAST_BSS_TRANSITION = 55,
  1533. WLAN_EID_TIMEOUT_INTERVAL = 56,
  1534. WLAN_EID_RIC_DATA = 57,
  1535. WLAN_EID_DSE_REGISTERED_LOCATION = 58,
  1536. WLAN_EID_SUPPORTED_REGULATORY_CLASSES = 59,
  1537. WLAN_EID_EXT_CHANSWITCH_ANN = 60,
  1538. WLAN_EID_HT_OPERATION = 61,
  1539. WLAN_EID_SECONDARY_CHANNEL_OFFSET = 62,
  1540. WLAN_EID_BSS_AVG_ACCESS_DELAY = 63,
  1541. WLAN_EID_ANTENNA_INFO = 64,
  1542. WLAN_EID_RSNI = 65,
  1543. WLAN_EID_MEASUREMENT_PILOT_TX_INFO = 66,
  1544. WLAN_EID_BSS_AVAILABLE_CAPACITY = 67,
  1545. WLAN_EID_BSS_AC_ACCESS_DELAY = 68,
  1546. WLAN_EID_TIME_ADVERTISEMENT = 69,
  1547. WLAN_EID_RRM_ENABLED_CAPABILITIES = 70,
  1548. WLAN_EID_MULTIPLE_BSSID = 71,
  1549. WLAN_EID_BSS_COEX_2040 = 72,
  1550. WLAN_EID_OVERLAP_BSS_SCAN_PARAM = 74,
  1551. WLAN_EID_RIC_DESCRIPTOR = 75,
  1552. WLAN_EID_MMIE = 76,
  1553. WLAN_EID_ASSOC_COMEBACK_TIME = 77,
  1554. WLAN_EID_EVENT_REQUEST = 78,
  1555. WLAN_EID_EVENT_REPORT = 79,
  1556. WLAN_EID_DIAGNOSTIC_REQUEST = 80,
  1557. WLAN_EID_DIAGNOSTIC_REPORT = 81,
  1558. WLAN_EID_LOCATION_PARAMS = 82,
  1559. WLAN_EID_NON_TX_BSSID_CAP = 83,
  1560. WLAN_EID_SSID_LIST = 84,
  1561. WLAN_EID_MULTI_BSSID_IDX = 85,
  1562. WLAN_EID_FMS_DESCRIPTOR = 86,
  1563. WLAN_EID_FMS_REQUEST = 87,
  1564. WLAN_EID_FMS_RESPONSE = 88,
  1565. WLAN_EID_QOS_TRAFFIC_CAPA = 89,
  1566. WLAN_EID_BSS_MAX_IDLE_PERIOD = 90,
  1567. WLAN_EID_TSF_REQUEST = 91,
  1568. WLAN_EID_TSF_RESPOSNE = 92,
  1569. WLAN_EID_WNM_SLEEP_MODE = 93,
  1570. WLAN_EID_TIM_BCAST_REQ = 94,
  1571. WLAN_EID_TIM_BCAST_RESP = 95,
  1572. WLAN_EID_COLL_IF_REPORT = 96,
  1573. WLAN_EID_CHANNEL_USAGE = 97,
  1574. WLAN_EID_TIME_ZONE = 98,
  1575. WLAN_EID_DMS_REQUEST = 99,
  1576. WLAN_EID_DMS_RESPONSE = 100,
  1577. WLAN_EID_LINK_ID = 101,
  1578. WLAN_EID_WAKEUP_SCHEDUL = 102,
  1579. /* 103 reserved */
  1580. WLAN_EID_CHAN_SWITCH_TIMING = 104,
  1581. WLAN_EID_PTI_CONTROL = 105,
  1582. WLAN_EID_PU_BUFFER_STATUS = 106,
  1583. WLAN_EID_INTERWORKING = 107,
  1584. WLAN_EID_ADVERTISEMENT_PROTOCOL = 108,
  1585. WLAN_EID_EXPEDITED_BW_REQ = 109,
  1586. WLAN_EID_QOS_MAP_SET = 110,
  1587. WLAN_EID_ROAMING_CONSORTIUM = 111,
  1588. WLAN_EID_EMERGENCY_ALERT = 112,
  1589. WLAN_EID_MESH_CONFIG = 113,
  1590. WLAN_EID_MESH_ID = 114,
  1591. WLAN_EID_LINK_METRIC_REPORT = 115,
  1592. WLAN_EID_CONGESTION_NOTIFICATION = 116,
  1593. WLAN_EID_PEER_MGMT = 117,
  1594. WLAN_EID_CHAN_SWITCH_PARAM = 118,
  1595. WLAN_EID_MESH_AWAKE_WINDOW = 119,
  1596. WLAN_EID_BEACON_TIMING = 120,
  1597. WLAN_EID_MCCAOP_SETUP_REQ = 121,
  1598. WLAN_EID_MCCAOP_SETUP_RESP = 122,
  1599. WLAN_EID_MCCAOP_ADVERT = 123,
  1600. WLAN_EID_MCCAOP_TEARDOWN = 124,
  1601. WLAN_EID_GANN = 125,
  1602. WLAN_EID_RANN = 126,
  1603. WLAN_EID_EXT_CAPABILITY = 127,
  1604. /* 128, 129 reserved for Agere */
  1605. WLAN_EID_PREQ = 130,
  1606. WLAN_EID_PREP = 131,
  1607. WLAN_EID_PERR = 132,
  1608. /* 133-136 reserved for Cisco */
  1609. WLAN_EID_PXU = 137,
  1610. WLAN_EID_PXUC = 138,
  1611. WLAN_EID_AUTH_MESH_PEER_EXCH = 139,
  1612. WLAN_EID_MIC = 140,
  1613. WLAN_EID_DESTINATION_URI = 141,
  1614. WLAN_EID_UAPSD_COEX = 142,
  1615. WLAN_EID_WAKEUP_SCHEDULE = 143,
  1616. WLAN_EID_EXT_SCHEDULE = 144,
  1617. WLAN_EID_STA_AVAILABILITY = 145,
  1618. WLAN_EID_DMG_TSPEC = 146,
  1619. WLAN_EID_DMG_AT = 147,
  1620. WLAN_EID_DMG_CAP = 148,
  1621. /* 149-150 reserved for Cisco */
  1622. WLAN_EID_DMG_OPERATION = 151,
  1623. WLAN_EID_DMG_BSS_PARAM_CHANGE = 152,
  1624. WLAN_EID_DMG_BEAM_REFINEMENT = 153,
  1625. WLAN_EID_CHANNEL_MEASURE_FEEDBACK = 154,
  1626. /* 155-156 reserved for Cisco */
  1627. WLAN_EID_AWAKE_WINDOW = 157,
  1628. WLAN_EID_MULTI_BAND = 158,
  1629. WLAN_EID_ADDBA_EXT = 159,
  1630. WLAN_EID_NEXT_PCP_LIST = 160,
  1631. WLAN_EID_PCP_HANDOVER = 161,
  1632. WLAN_EID_DMG_LINK_MARGIN = 162,
  1633. WLAN_EID_SWITCHING_STREAM = 163,
  1634. WLAN_EID_SESSION_TRANSITION = 164,
  1635. WLAN_EID_DYN_TONE_PAIRING_REPORT = 165,
  1636. WLAN_EID_CLUSTER_REPORT = 166,
  1637. WLAN_EID_RELAY_CAP = 167,
  1638. WLAN_EID_RELAY_XFER_PARAM_SET = 168,
  1639. WLAN_EID_BEAM_LINK_MAINT = 169,
  1640. WLAN_EID_MULTIPLE_MAC_ADDR = 170,
  1641. WLAN_EID_U_PID = 171,
  1642. WLAN_EID_DMG_LINK_ADAPT_ACK = 172,
  1643. /* 173 reserved for Symbol */
  1644. WLAN_EID_MCCAOP_ADV_OVERVIEW = 174,
  1645. WLAN_EID_QUIET_PERIOD_REQ = 175,
  1646. /* 176 reserved for Symbol */
  1647. WLAN_EID_QUIET_PERIOD_RESP = 177,
  1648. /* 178-179 reserved for Symbol */
  1649. /* 180 reserved for ISO/IEC 20011 */
  1650. WLAN_EID_EPAC_POLICY = 182,
  1651. WLAN_EID_CLISTER_TIME_OFF = 183,
  1652. WLAN_EID_INTER_AC_PRIO = 184,
  1653. WLAN_EID_SCS_DESCRIPTOR = 185,
  1654. WLAN_EID_QLOAD_REPORT = 186,
  1655. WLAN_EID_HCCA_TXOP_UPDATE_COUNT = 187,
  1656. WLAN_EID_HL_STREAM_ID = 188,
  1657. WLAN_EID_GCR_GROUP_ADDR = 189,
  1658. WLAN_EID_ANTENNA_SECTOR_ID_PATTERN = 190,
  1659. WLAN_EID_VHT_CAPABILITY = 191,
  1660. WLAN_EID_VHT_OPERATION = 192,
  1661. WLAN_EID_EXTENDED_BSS_LOAD = 193,
  1662. WLAN_EID_WIDE_BW_CHANNEL_SWITCH = 194,
  1663. WLAN_EID_VHT_TX_POWER_ENVELOPE = 195,
  1664. WLAN_EID_CHANNEL_SWITCH_WRAPPER = 196,
  1665. WLAN_EID_AID = 197,
  1666. WLAN_EID_QUIET_CHANNEL = 198,
  1667. WLAN_EID_OPMODE_NOTIF = 199,
  1668. WLAN_EID_VENDOR_SPECIFIC = 221,
  1669. WLAN_EID_QOS_PARAMETER = 222,
  1670. };
  1671. /* Action category code */
  1672. enum ieee80211_category {
  1673. WLAN_CATEGORY_SPECTRUM_MGMT = 0,
  1674. WLAN_CATEGORY_QOS = 1,
  1675. WLAN_CATEGORY_DLS = 2,
  1676. WLAN_CATEGORY_BACK = 3,
  1677. WLAN_CATEGORY_PUBLIC = 4,
  1678. WLAN_CATEGORY_HT = 7,
  1679. WLAN_CATEGORY_SA_QUERY = 8,
  1680. WLAN_CATEGORY_PROTECTED_DUAL_OF_ACTION = 9,
  1681. WLAN_CATEGORY_TDLS = 12,
  1682. WLAN_CATEGORY_MESH_ACTION = 13,
  1683. WLAN_CATEGORY_MULTIHOP_ACTION = 14,
  1684. WLAN_CATEGORY_SELF_PROTECTED = 15,
  1685. WLAN_CATEGORY_DMG = 16,
  1686. WLAN_CATEGORY_WMM = 17,
  1687. WLAN_CATEGORY_FST = 18,
  1688. WLAN_CATEGORY_UNPROT_DMG = 20,
  1689. WLAN_CATEGORY_VHT = 21,
  1690. WLAN_CATEGORY_VENDOR_SPECIFIC_PROTECTED = 126,
  1691. WLAN_CATEGORY_VENDOR_SPECIFIC = 127,
  1692. };
  1693. /* SPECTRUM_MGMT action code */
  1694. enum ieee80211_spectrum_mgmt_actioncode {
  1695. WLAN_ACTION_SPCT_MSR_REQ = 0,
  1696. WLAN_ACTION_SPCT_MSR_RPRT = 1,
  1697. WLAN_ACTION_SPCT_TPC_REQ = 2,
  1698. WLAN_ACTION_SPCT_TPC_RPRT = 3,
  1699. WLAN_ACTION_SPCT_CHL_SWITCH = 4,
  1700. };
  1701. /* HT action codes */
  1702. enum ieee80211_ht_actioncode {
  1703. WLAN_HT_ACTION_NOTIFY_CHANWIDTH = 0,
  1704. WLAN_HT_ACTION_SMPS = 1,
  1705. WLAN_HT_ACTION_PSMP = 2,
  1706. WLAN_HT_ACTION_PCO_PHASE = 3,
  1707. WLAN_HT_ACTION_CSI = 4,
  1708. WLAN_HT_ACTION_NONCOMPRESSED_BF = 5,
  1709. WLAN_HT_ACTION_COMPRESSED_BF = 6,
  1710. WLAN_HT_ACTION_ASEL_IDX_FEEDBACK = 7,
  1711. };
  1712. /* VHT action codes */
  1713. enum ieee80211_vht_actioncode {
  1714. WLAN_VHT_ACTION_COMPRESSED_BF = 0,
  1715. WLAN_VHT_ACTION_GROUPID_MGMT = 1,
  1716. WLAN_VHT_ACTION_OPMODE_NOTIF = 2,
  1717. };
  1718. /* Self Protected Action codes */
  1719. enum ieee80211_self_protected_actioncode {
  1720. WLAN_SP_RESERVED = 0,
  1721. WLAN_SP_MESH_PEERING_OPEN = 1,
  1722. WLAN_SP_MESH_PEERING_CONFIRM = 2,
  1723. WLAN_SP_MESH_PEERING_CLOSE = 3,
  1724. WLAN_SP_MGK_INFORM = 4,
  1725. WLAN_SP_MGK_ACK = 5,
  1726. };
  1727. /* Mesh action codes */
  1728. enum ieee80211_mesh_actioncode {
  1729. WLAN_MESH_ACTION_LINK_METRIC_REPORT,
  1730. WLAN_MESH_ACTION_HWMP_PATH_SELECTION,
  1731. WLAN_MESH_ACTION_GATE_ANNOUNCEMENT,
  1732. WLAN_MESH_ACTION_CONGESTION_CONTROL_NOTIFICATION,
  1733. WLAN_MESH_ACTION_MCCA_SETUP_REQUEST,
  1734. WLAN_MESH_ACTION_MCCA_SETUP_REPLY,
  1735. WLAN_MESH_ACTION_MCCA_ADVERTISEMENT_REQUEST,
  1736. WLAN_MESH_ACTION_MCCA_ADVERTISEMENT,
  1737. WLAN_MESH_ACTION_MCCA_TEARDOWN,
  1738. WLAN_MESH_ACTION_TBTT_ADJUSTMENT_REQUEST,
  1739. WLAN_MESH_ACTION_TBTT_ADJUSTMENT_RESPONSE,
  1740. };
  1741. /* Security key length */
  1742. enum ieee80211_key_len {
  1743. WLAN_KEY_LEN_WEP40 = 5,
  1744. WLAN_KEY_LEN_WEP104 = 13,
  1745. WLAN_KEY_LEN_CCMP = 16,
  1746. WLAN_KEY_LEN_TKIP = 32,
  1747. WLAN_KEY_LEN_AES_CMAC = 16,
  1748. WLAN_KEY_LEN_SMS4 = 32,
  1749. };
  1750. #define IEEE80211_WEP_IV_LEN 4
  1751. #define IEEE80211_WEP_ICV_LEN 4
  1752. #define IEEE80211_CCMP_HDR_LEN 8
  1753. #define IEEE80211_CCMP_MIC_LEN 8
  1754. #define IEEE80211_CCMP_PN_LEN 6
  1755. #define IEEE80211_TKIP_IV_LEN 8
  1756. #define IEEE80211_TKIP_ICV_LEN 4
  1757. #define IEEE80211_CMAC_PN_LEN 6
  1758. /* Public action codes */
  1759. enum ieee80211_pub_actioncode {
  1760. WLAN_PUB_ACTION_EXT_CHANSW_ANN = 4,
  1761. WLAN_PUB_ACTION_TDLS_DISCOVER_RES = 14,
  1762. };
  1763. /* TDLS action codes */
  1764. enum ieee80211_tdls_actioncode {
  1765. WLAN_TDLS_SETUP_REQUEST = 0,
  1766. WLAN_TDLS_SETUP_RESPONSE = 1,
  1767. WLAN_TDLS_SETUP_CONFIRM = 2,
  1768. WLAN_TDLS_TEARDOWN = 3,
  1769. WLAN_TDLS_PEER_TRAFFIC_INDICATION = 4,
  1770. WLAN_TDLS_CHANNEL_SWITCH_REQUEST = 5,
  1771. WLAN_TDLS_CHANNEL_SWITCH_RESPONSE = 6,
  1772. WLAN_TDLS_PEER_PSM_REQUEST = 7,
  1773. WLAN_TDLS_PEER_PSM_RESPONSE = 8,
  1774. WLAN_TDLS_PEER_TRAFFIC_RESPONSE = 9,
  1775. WLAN_TDLS_DISCOVERY_REQUEST = 10,
  1776. };
  1777. /* Interworking capabilities are set in 7th bit of 4th byte of the
  1778. * @WLAN_EID_EXT_CAPABILITY information element
  1779. */
  1780. #define WLAN_EXT_CAPA4_INTERWORKING_ENABLED BIT(7)
  1781. /*
  1782. * TDLS capabililites to be enabled in the 5th byte of the
  1783. * @WLAN_EID_EXT_CAPABILITY information element
  1784. */
  1785. #define WLAN_EXT_CAPA5_TDLS_ENABLED BIT(5)
  1786. #define WLAN_EXT_CAPA5_TDLS_PROHIBITED BIT(6)
  1787. #define WLAN_EXT_CAPA8_OPMODE_NOTIF BIT(6)
  1788. #define WLAN_EXT_CAPA8_TDLS_WIDE_BW_ENABLED BIT(7)
  1789. /* TDLS specific payload type in the LLC/SNAP header */
  1790. #define WLAN_TDLS_SNAP_RFTYPE 0x2
  1791. /**
  1792. * enum - mesh synchronization method identifier
  1793. *
  1794. * @IEEE80211_SYNC_METHOD_NEIGHBOR_OFFSET: the default synchronization method
  1795. * @IEEE80211_SYNC_METHOD_VENDOR: a vendor specific synchronization method
  1796. * that will be specified in a vendor specific information element
  1797. */
  1798. enum {
  1799. IEEE80211_SYNC_METHOD_NEIGHBOR_OFFSET = 1,
  1800. IEEE80211_SYNC_METHOD_VENDOR = 255,
  1801. };
  1802. /**
  1803. * enum - mesh path selection protocol identifier
  1804. *
  1805. * @IEEE80211_PATH_PROTOCOL_HWMP: the default path selection protocol
  1806. * @IEEE80211_PATH_PROTOCOL_VENDOR: a vendor specific protocol that will
  1807. * be specified in a vendor specific information element
  1808. */
  1809. enum {
  1810. IEEE80211_PATH_PROTOCOL_HWMP = 1,
  1811. IEEE80211_PATH_PROTOCOL_VENDOR = 255,
  1812. };
  1813. /**
  1814. * enum - mesh path selection metric identifier
  1815. *
  1816. * @IEEE80211_PATH_METRIC_AIRTIME: the default path selection metric
  1817. * @IEEE80211_PATH_METRIC_VENDOR: a vendor specific metric that will be
  1818. * specified in a vendor specific information element
  1819. */
  1820. enum {
  1821. IEEE80211_PATH_METRIC_AIRTIME = 1,
  1822. IEEE80211_PATH_METRIC_VENDOR = 255,
  1823. };
  1824. /**
  1825. * enum ieee80211_root_mode_identifier - root mesh STA mode identifier
  1826. *
  1827. * These attribute are used by dot11MeshHWMPRootMode to set root mesh STA mode
  1828. *
  1829. * @IEEE80211_ROOTMODE_NO_ROOT: the mesh STA is not a root mesh STA (default)
  1830. * @IEEE80211_ROOTMODE_ROOT: the mesh STA is a root mesh STA if greater than
  1831. * this value
  1832. * @IEEE80211_PROACTIVE_PREQ_NO_PREP: the mesh STA is a root mesh STA supports
  1833. * the proactive PREQ with proactive PREP subfield set to 0
  1834. * @IEEE80211_PROACTIVE_PREQ_WITH_PREP: the mesh STA is a root mesh STA
  1835. * supports the proactive PREQ with proactive PREP subfield set to 1
  1836. * @IEEE80211_PROACTIVE_RANN: the mesh STA is a root mesh STA supports
  1837. * the proactive RANN
  1838. */
  1839. enum ieee80211_root_mode_identifier {
  1840. IEEE80211_ROOTMODE_NO_ROOT = 0,
  1841. IEEE80211_ROOTMODE_ROOT = 1,
  1842. IEEE80211_PROACTIVE_PREQ_NO_PREP = 2,
  1843. IEEE80211_PROACTIVE_PREQ_WITH_PREP = 3,
  1844. IEEE80211_PROACTIVE_RANN = 4,
  1845. };
  1846. /*
  1847. * IEEE 802.11-2007 7.3.2.9 Country information element
  1848. *
  1849. * Minimum length is 8 octets, ie len must be evenly
  1850. * divisible by 2
  1851. */
  1852. /* Although the spec says 8 I'm seeing 6 in practice */
  1853. #define IEEE80211_COUNTRY_IE_MIN_LEN 6
  1854. /* The Country String field of the element shall be 3 octets in length */
  1855. #define IEEE80211_COUNTRY_STRING_LEN 3
  1856. /*
  1857. * For regulatory extension stuff see IEEE 802.11-2007
  1858. * Annex I (page 1141) and Annex J (page 1147). Also
  1859. * review 7.3.2.9.
  1860. *
  1861. * When dot11RegulatoryClassesRequired is true and the
  1862. * first_channel/reg_extension_id is >= 201 then the IE
  1863. * compromises of the 'ext' struct represented below:
  1864. *
  1865. * - Regulatory extension ID - when generating IE this just needs
  1866. * to be monotonically increasing for each triplet passed in
  1867. * the IE
  1868. * - Regulatory class - index into set of rules
  1869. * - Coverage class - index into air propagation time (Table 7-27),
  1870. * in microseconds, you can compute the air propagation time from
  1871. * the index by multiplying by 3, so index 10 yields a propagation
  1872. * of 10 us. Valid values are 0-31, values 32-255 are not defined
  1873. * yet. A value of 0 inicates air propagation of <= 1 us.
  1874. *
  1875. * See also Table I.2 for Emission limit sets and table
  1876. * I.3 for Behavior limit sets. Table J.1 indicates how to map
  1877. * a reg_class to an emission limit set and behavior limit set.
  1878. */
  1879. #define IEEE80211_COUNTRY_EXTENSION_ID 201
  1880. /*
  1881. * Channels numbers in the IE must be monotonically increasing
  1882. * if dot11RegulatoryClassesRequired is not true.
  1883. *
  1884. * If dot11RegulatoryClassesRequired is true consecutive
  1885. * subband triplets following a regulatory triplet shall
  1886. * have monotonically increasing first_channel number fields.
  1887. *
  1888. * Channel numbers shall not overlap.
  1889. *
  1890. * Note that max_power is signed.
  1891. */
  1892. struct ieee80211_country_ie_triplet {
  1893. union {
  1894. struct {
  1895. u8 first_channel;
  1896. u8 num_channels;
  1897. s8 max_power;
  1898. } __packed chans;
  1899. struct {
  1900. u8 reg_extension_id;
  1901. u8 reg_class;
  1902. u8 coverage_class;
  1903. } __packed ext;
  1904. };
  1905. } __packed;
  1906. enum ieee80211_timeout_interval_type {
  1907. WLAN_TIMEOUT_REASSOC_DEADLINE = 1 /* 802.11r */,
  1908. WLAN_TIMEOUT_KEY_LIFETIME = 2 /* 802.11r */,
  1909. WLAN_TIMEOUT_ASSOC_COMEBACK = 3 /* 802.11w */,
  1910. };
  1911. /**
  1912. * struct ieee80211_timeout_interval_ie - Timeout Interval element
  1913. * @type: type, see &enum ieee80211_timeout_interval_type
  1914. * @value: timeout interval value
  1915. */
  1916. struct ieee80211_timeout_interval_ie {
  1917. u8 type;
  1918. __le32 value;
  1919. } __packed;
  1920. /* BACK action code */
  1921. enum ieee80211_back_actioncode {
  1922. WLAN_ACTION_ADDBA_REQ = 0,
  1923. WLAN_ACTION_ADDBA_RESP = 1,
  1924. WLAN_ACTION_DELBA = 2,
  1925. };
  1926. /* BACK (block-ack) parties */
  1927. enum ieee80211_back_parties {
  1928. WLAN_BACK_RECIPIENT = 0,
  1929. WLAN_BACK_INITIATOR = 1,
  1930. };
  1931. /* SA Query action */
  1932. enum ieee80211_sa_query_action {
  1933. WLAN_ACTION_SA_QUERY_REQUEST = 0,
  1934. WLAN_ACTION_SA_QUERY_RESPONSE = 1,
  1935. };
  1936. /* cipher suite selectors */
  1937. #define WLAN_CIPHER_SUITE_USE_GROUP 0x000FAC00
  1938. #define WLAN_CIPHER_SUITE_WEP40 0x000FAC01
  1939. #define WLAN_CIPHER_SUITE_TKIP 0x000FAC02
  1940. /* reserved: 0x000FAC03 */
  1941. #define WLAN_CIPHER_SUITE_CCMP 0x000FAC04
  1942. #define WLAN_CIPHER_SUITE_WEP104 0x000FAC05
  1943. #define WLAN_CIPHER_SUITE_AES_CMAC 0x000FAC06
  1944. #define WLAN_CIPHER_SUITE_GCMP 0x000FAC08
  1945. #define WLAN_CIPHER_SUITE_SMS4 0x00147201
  1946. /* AKM suite selectors */
  1947. #define WLAN_AKM_SUITE_8021X 0x000FAC01
  1948. #define WLAN_AKM_SUITE_PSK 0x000FAC02
  1949. #define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05
  1950. #define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06
  1951. #define WLAN_AKM_SUITE_TDLS 0x000FAC07
  1952. #define WLAN_AKM_SUITE_SAE 0x000FAC08
  1953. #define WLAN_AKM_SUITE_FT_OVER_SAE 0x000FAC09
  1954. #define WLAN_MAX_KEY_LEN 32
  1955. #define WLAN_PMKID_LEN 16
  1956. #define WLAN_OUI_WFA 0x506f9a
  1957. #define WLAN_OUI_TYPE_WFA_P2P 9
  1958. #define WLAN_OUI_MICROSOFT 0x0050f2
  1959. #define WLAN_OUI_TYPE_MICROSOFT_WPA 1
  1960. #define WLAN_OUI_TYPE_MICROSOFT_WMM 2
  1961. #define WLAN_OUI_TYPE_MICROSOFT_WPS 4
  1962. /*
  1963. * WMM/802.11e Tspec Element
  1964. */
  1965. #define IEEE80211_WMM_IE_TSPEC_TID_MASK 0x0F
  1966. #define IEEE80211_WMM_IE_TSPEC_TID_SHIFT 1
  1967. enum ieee80211_tspec_status_code {
  1968. IEEE80211_TSPEC_STATUS_ADMISS_ACCEPTED = 0,
  1969. IEEE80211_TSPEC_STATUS_ADDTS_INVAL_PARAMS = 0x1,
  1970. };
  1971. struct ieee80211_tspec_ie {
  1972. u8 element_id;
  1973. u8 len;
  1974. u8 oui[3];
  1975. u8 oui_type;
  1976. u8 oui_subtype;
  1977. u8 version;
  1978. __le16 tsinfo;
  1979. u8 tsinfo_resvd;
  1980. __le16 nominal_msdu;
  1981. __le16 max_msdu;
  1982. __le32 min_service_int;
  1983. __le32 max_service_int;
  1984. __le32 inactivity_int;
  1985. __le32 suspension_int;
  1986. __le32 service_start_time;
  1987. __le32 min_data_rate;
  1988. __le32 mean_data_rate;
  1989. __le32 peak_data_rate;
  1990. __le32 max_burst_size;
  1991. __le32 delay_bound;
  1992. __le32 min_phy_rate;
  1993. __le16 sba;
  1994. __le16 medium_time;
  1995. } __packed;
  1996. /**
  1997. * ieee80211_get_qos_ctl - get pointer to qos control bytes
  1998. * @hdr: the frame
  1999. *
  2000. * The qos ctrl bytes come after the frame_control, duration, seq_num
  2001. * and 3 or 4 addresses of length ETH_ALEN.
  2002. * 3 addr: 2 + 2 + 2 + 3*6 = 24
  2003. * 4 addr: 2 + 2 + 2 + 4*6 = 30
  2004. */
  2005. static inline u8 *ieee80211_get_qos_ctl(struct ieee80211_hdr *hdr)
  2006. {
  2007. if (ieee80211_has_a4(hdr->frame_control))
  2008. return (u8 *)hdr + 30;
  2009. else
  2010. return (u8 *)hdr + 24;
  2011. }
  2012. /**
  2013. * ieee80211_get_SA - get pointer to SA
  2014. * @hdr: the frame
  2015. *
  2016. * Given an 802.11 frame, this function returns the offset
  2017. * to the source address (SA). It does not verify that the
  2018. * header is long enough to contain the address, and the
  2019. * header must be long enough to contain the frame control
  2020. * field.
  2021. */
  2022. static inline u8 *ieee80211_get_SA(struct ieee80211_hdr *hdr)
  2023. {
  2024. if (ieee80211_has_a4(hdr->frame_control))
  2025. return hdr->addr4;
  2026. if (ieee80211_has_fromds(hdr->frame_control))
  2027. return hdr->addr3;
  2028. return hdr->addr2;
  2029. }
  2030. /**
  2031. * ieee80211_get_DA - get pointer to DA
  2032. * @hdr: the frame
  2033. *
  2034. * Given an 802.11 frame, this function returns the offset
  2035. * to the destination address (DA). It does not verify that
  2036. * the header is long enough to contain the address, and the
  2037. * header must be long enough to contain the frame control
  2038. * field.
  2039. */
  2040. static inline u8 *ieee80211_get_DA(struct ieee80211_hdr *hdr)
  2041. {
  2042. if (ieee80211_has_tods(hdr->frame_control))
  2043. return hdr->addr3;
  2044. else
  2045. return hdr->addr1;
  2046. }
  2047. /**
  2048. * _ieee80211_is_robust_mgmt_frame - check if frame is a robust management frame
  2049. * @hdr: the frame (buffer must include at least the first octet of payload)
  2050. */
  2051. static inline bool _ieee80211_is_robust_mgmt_frame(struct ieee80211_hdr *hdr)
  2052. {
  2053. if (ieee80211_is_disassoc(hdr->frame_control) ||
  2054. ieee80211_is_deauth(hdr->frame_control))
  2055. return true;
  2056. if (ieee80211_is_action(hdr->frame_control)) {
  2057. u8 *category;
  2058. /*
  2059. * Action frames, excluding Public Action frames, are Robust
  2060. * Management Frames. However, if we are looking at a Protected
  2061. * frame, skip the check since the data may be encrypted and
  2062. * the frame has already been found to be a Robust Management
  2063. * Frame (by the other end).
  2064. */
  2065. if (ieee80211_has_protected(hdr->frame_control))
  2066. return true;
  2067. category = ((u8 *) hdr) + 24;
  2068. return *category != WLAN_CATEGORY_PUBLIC &&
  2069. *category != WLAN_CATEGORY_HT &&
  2070. *category != WLAN_CATEGORY_SELF_PROTECTED &&
  2071. *category != WLAN_CATEGORY_VENDOR_SPECIFIC;
  2072. }
  2073. return false;
  2074. }
  2075. /**
  2076. * ieee80211_is_robust_mgmt_frame - check if skb contains a robust mgmt frame
  2077. * @skb: the skb containing the frame, length will be checked
  2078. */
  2079. static inline bool ieee80211_is_robust_mgmt_frame(struct sk_buff *skb)
  2080. {
  2081. if (skb->len < 25)
  2082. return false;
  2083. return _ieee80211_is_robust_mgmt_frame((void *)skb->data);
  2084. }
  2085. /**
  2086. * ieee80211_is_public_action - check if frame is a public action frame
  2087. * @hdr: the frame
  2088. * @len: length of the frame
  2089. */
  2090. static inline bool ieee80211_is_public_action(struct ieee80211_hdr *hdr,
  2091. size_t len)
  2092. {
  2093. struct ieee80211_mgmt *mgmt = (void *)hdr;
  2094. if (len < IEEE80211_MIN_ACTION_SIZE)
  2095. return false;
  2096. if (!ieee80211_is_action(hdr->frame_control))
  2097. return false;
  2098. return mgmt->u.action.category == WLAN_CATEGORY_PUBLIC;
  2099. }
  2100. /**
  2101. * ieee80211_tu_to_usec - convert time units (TU) to microseconds
  2102. * @tu: the TUs
  2103. */
  2104. static inline unsigned long ieee80211_tu_to_usec(unsigned long tu)
  2105. {
  2106. return 1024 * tu;
  2107. }
  2108. /**
  2109. * ieee80211_check_tim - check if AID bit is set in TIM
  2110. * @tim: the TIM IE
  2111. * @tim_len: length of the TIM IE
  2112. * @aid: the AID to look for
  2113. */
  2114. static inline bool ieee80211_check_tim(const struct ieee80211_tim_ie *tim,
  2115. u8 tim_len, u16 aid)
  2116. {
  2117. u8 mask;
  2118. u8 index, indexn1, indexn2;
  2119. if (unlikely(!tim || tim_len < sizeof(*tim)))
  2120. return false;
  2121. aid &= 0x3fff;
  2122. index = aid / 8;
  2123. mask = 1 << (aid & 7);
  2124. indexn1 = tim->bitmap_ctrl & 0xfe;
  2125. indexn2 = tim_len + indexn1 - 4;
  2126. if (index < indexn1 || index > indexn2)
  2127. return false;
  2128. index -= indexn1;
  2129. return !!(tim->virtual_map[index] & mask);
  2130. }
  2131. /* convert time units */
  2132. #define TU_TO_JIFFIES(x) (usecs_to_jiffies((x) * 1024))
  2133. #define TU_TO_EXP_TIME(x) (jiffies + TU_TO_JIFFIES(x))
  2134. #endif /* LINUX_IEEE80211_H */