ieee80211.h 58 KB

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