ieee80211.h 69 KB

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