ieee80211.h 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511
  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_SCTL_FRAG 0x000F
  46. #define IEEE80211_SCTL_SEQ 0xFFF0
  47. #define IEEE80211_FTYPE_MGMT 0x0000
  48. #define IEEE80211_FTYPE_CTL 0x0004
  49. #define IEEE80211_FTYPE_DATA 0x0008
  50. /* management */
  51. #define IEEE80211_STYPE_ASSOC_REQ 0x0000
  52. #define IEEE80211_STYPE_ASSOC_RESP 0x0010
  53. #define IEEE80211_STYPE_REASSOC_REQ 0x0020
  54. #define IEEE80211_STYPE_REASSOC_RESP 0x0030
  55. #define IEEE80211_STYPE_PROBE_REQ 0x0040
  56. #define IEEE80211_STYPE_PROBE_RESP 0x0050
  57. #define IEEE80211_STYPE_BEACON 0x0080
  58. #define IEEE80211_STYPE_ATIM 0x0090
  59. #define IEEE80211_STYPE_DISASSOC 0x00A0
  60. #define IEEE80211_STYPE_AUTH 0x00B0
  61. #define IEEE80211_STYPE_DEAUTH 0x00C0
  62. #define IEEE80211_STYPE_ACTION 0x00D0
  63. /* control */
  64. #define IEEE80211_STYPE_BACK_REQ 0x0080
  65. #define IEEE80211_STYPE_BACK 0x0090
  66. #define IEEE80211_STYPE_PSPOLL 0x00A0
  67. #define IEEE80211_STYPE_RTS 0x00B0
  68. #define IEEE80211_STYPE_CTS 0x00C0
  69. #define IEEE80211_STYPE_ACK 0x00D0
  70. #define IEEE80211_STYPE_CFEND 0x00E0
  71. #define IEEE80211_STYPE_CFENDACK 0x00F0
  72. /* data */
  73. #define IEEE80211_STYPE_DATA 0x0000
  74. #define IEEE80211_STYPE_DATA_CFACK 0x0010
  75. #define IEEE80211_STYPE_DATA_CFPOLL 0x0020
  76. #define IEEE80211_STYPE_DATA_CFACKPOLL 0x0030
  77. #define IEEE80211_STYPE_NULLFUNC 0x0040
  78. #define IEEE80211_STYPE_CFACK 0x0050
  79. #define IEEE80211_STYPE_CFPOLL 0x0060
  80. #define IEEE80211_STYPE_CFACKPOLL 0x0070
  81. #define IEEE80211_STYPE_QOS_DATA 0x0080
  82. #define IEEE80211_STYPE_QOS_DATA_CFACK 0x0090
  83. #define IEEE80211_STYPE_QOS_DATA_CFPOLL 0x00A0
  84. #define IEEE80211_STYPE_QOS_DATA_CFACKPOLL 0x00B0
  85. #define IEEE80211_STYPE_QOS_NULLFUNC 0x00C0
  86. #define IEEE80211_STYPE_QOS_CFACK 0x00D0
  87. #define IEEE80211_STYPE_QOS_CFPOLL 0x00E0
  88. #define IEEE80211_STYPE_QOS_CFACKPOLL 0x00F0
  89. /* miscellaneous IEEE 802.11 constants */
  90. #define IEEE80211_MAX_FRAG_THRESHOLD 2352
  91. #define IEEE80211_MAX_RTS_THRESHOLD 2353
  92. #define IEEE80211_MAX_AID 2007
  93. #define IEEE80211_MAX_TIM_LEN 251
  94. /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
  95. 6.2.1.1.2.
  96. 802.11e clarifies the figure in section 7.1.2. The frame body is
  97. up to 2304 octets long (maximum MSDU size) plus any crypt overhead. */
  98. #define IEEE80211_MAX_DATA_LEN 2304
  99. /* 30 byte 4 addr hdr, 2 byte QoS, 2304 byte MSDU, 12 byte crypt, 4 byte FCS */
  100. #define IEEE80211_MAX_FRAME_LEN 2352
  101. #define IEEE80211_MAX_SSID_LEN 32
  102. #define IEEE80211_MAX_MESH_ID_LEN 32
  103. #define IEEE80211_QOS_CTL_LEN 2
  104. #define IEEE80211_QOS_CTL_TID_MASK 0x000F
  105. #define IEEE80211_QOS_CTL_TAG1D_MASK 0x0007
  106. struct ieee80211_hdr {
  107. __le16 frame_control;
  108. __le16 duration_id;
  109. u8 addr1[6];
  110. u8 addr2[6];
  111. u8 addr3[6];
  112. __le16 seq_ctrl;
  113. u8 addr4[6];
  114. } __attribute__ ((packed));
  115. /**
  116. * ieee80211_has_tods - check if IEEE80211_FCTL_TODS is set
  117. * @fc: frame control bytes in little-endian byteorder
  118. */
  119. static inline int ieee80211_has_tods(__le16 fc)
  120. {
  121. return (fc & cpu_to_le16(IEEE80211_FCTL_TODS)) != 0;
  122. }
  123. /**
  124. * ieee80211_has_fromds - check if IEEE80211_FCTL_FROMDS is set
  125. * @fc: frame control bytes in little-endian byteorder
  126. */
  127. static inline int ieee80211_has_fromds(__le16 fc)
  128. {
  129. return (fc & cpu_to_le16(IEEE80211_FCTL_FROMDS)) != 0;
  130. }
  131. /**
  132. * ieee80211_has_a4 - check if IEEE80211_FCTL_TODS and IEEE80211_FCTL_FROMDS are set
  133. * @fc: frame control bytes in little-endian byteorder
  134. */
  135. static inline int ieee80211_has_a4(__le16 fc)
  136. {
  137. __le16 tmp = cpu_to_le16(IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS);
  138. return (fc & tmp) == tmp;
  139. }
  140. /**
  141. * ieee80211_has_morefrags - check if IEEE80211_FCTL_MOREFRAGS is set
  142. * @fc: frame control bytes in little-endian byteorder
  143. */
  144. static inline int ieee80211_has_morefrags(__le16 fc)
  145. {
  146. return (fc & cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)) != 0;
  147. }
  148. /**
  149. * ieee80211_has_retry - check if IEEE80211_FCTL_RETRY is set
  150. * @fc: frame control bytes in little-endian byteorder
  151. */
  152. static inline int ieee80211_has_retry(__le16 fc)
  153. {
  154. return (fc & cpu_to_le16(IEEE80211_FCTL_RETRY)) != 0;
  155. }
  156. /**
  157. * ieee80211_has_pm - check if IEEE80211_FCTL_PM is set
  158. * @fc: frame control bytes in little-endian byteorder
  159. */
  160. static inline int ieee80211_has_pm(__le16 fc)
  161. {
  162. return (fc & cpu_to_le16(IEEE80211_FCTL_PM)) != 0;
  163. }
  164. /**
  165. * ieee80211_has_moredata - check if IEEE80211_FCTL_MOREDATA is set
  166. * @fc: frame control bytes in little-endian byteorder
  167. */
  168. static inline int ieee80211_has_moredata(__le16 fc)
  169. {
  170. return (fc & cpu_to_le16(IEEE80211_FCTL_MOREDATA)) != 0;
  171. }
  172. /**
  173. * ieee80211_has_protected - check if IEEE80211_FCTL_PROTECTED is set
  174. * @fc: frame control bytes in little-endian byteorder
  175. */
  176. static inline int ieee80211_has_protected(__le16 fc)
  177. {
  178. return (fc & cpu_to_le16(IEEE80211_FCTL_PROTECTED)) != 0;
  179. }
  180. /**
  181. * ieee80211_has_order - check if IEEE80211_FCTL_ORDER is set
  182. * @fc: frame control bytes in little-endian byteorder
  183. */
  184. static inline int ieee80211_has_order(__le16 fc)
  185. {
  186. return (fc & cpu_to_le16(IEEE80211_FCTL_ORDER)) != 0;
  187. }
  188. /**
  189. * ieee80211_is_mgmt - check if type is IEEE80211_FTYPE_MGMT
  190. * @fc: frame control bytes in little-endian byteorder
  191. */
  192. static inline int ieee80211_is_mgmt(__le16 fc)
  193. {
  194. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
  195. cpu_to_le16(IEEE80211_FTYPE_MGMT);
  196. }
  197. /**
  198. * ieee80211_is_ctl - check if type is IEEE80211_FTYPE_CTL
  199. * @fc: frame control bytes in little-endian byteorder
  200. */
  201. static inline int ieee80211_is_ctl(__le16 fc)
  202. {
  203. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
  204. cpu_to_le16(IEEE80211_FTYPE_CTL);
  205. }
  206. /**
  207. * ieee80211_is_data - check if type is IEEE80211_FTYPE_DATA
  208. * @fc: frame control bytes in little-endian byteorder
  209. */
  210. static inline int ieee80211_is_data(__le16 fc)
  211. {
  212. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
  213. cpu_to_le16(IEEE80211_FTYPE_DATA);
  214. }
  215. /**
  216. * ieee80211_is_data_qos - check if type is IEEE80211_FTYPE_DATA and IEEE80211_STYPE_QOS_DATA is set
  217. * @fc: frame control bytes in little-endian byteorder
  218. */
  219. static inline int ieee80211_is_data_qos(__le16 fc)
  220. {
  221. /*
  222. * mask with QOS_DATA rather than IEEE80211_FCTL_STYPE as we just need
  223. * to check the one bit
  224. */
  225. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_STYPE_QOS_DATA)) ==
  226. cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_QOS_DATA);
  227. }
  228. /**
  229. * ieee80211_is_data_present - check if type is IEEE80211_FTYPE_DATA and has data
  230. * @fc: frame control bytes in little-endian byteorder
  231. */
  232. static inline int ieee80211_is_data_present(__le16 fc)
  233. {
  234. /*
  235. * mask with 0x40 and test that that bit is clear to only return true
  236. * for the data-containing substypes.
  237. */
  238. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | 0x40)) ==
  239. cpu_to_le16(IEEE80211_FTYPE_DATA);
  240. }
  241. /**
  242. * ieee80211_is_assoc_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ASSOC_REQ
  243. * @fc: frame control bytes in little-endian byteorder
  244. */
  245. static inline int ieee80211_is_assoc_req(__le16 fc)
  246. {
  247. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  248. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ASSOC_REQ);
  249. }
  250. /**
  251. * ieee80211_is_assoc_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ASSOC_RESP
  252. * @fc: frame control bytes in little-endian byteorder
  253. */
  254. static inline int ieee80211_is_assoc_resp(__le16 fc)
  255. {
  256. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  257. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ASSOC_RESP);
  258. }
  259. /**
  260. * ieee80211_is_reassoc_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_REASSOC_REQ
  261. * @fc: frame control bytes in little-endian byteorder
  262. */
  263. static inline int ieee80211_is_reassoc_req(__le16 fc)
  264. {
  265. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  266. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_REASSOC_REQ);
  267. }
  268. /**
  269. * ieee80211_is_reassoc_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_REASSOC_RESP
  270. * @fc: frame control bytes in little-endian byteorder
  271. */
  272. static inline int ieee80211_is_reassoc_resp(__le16 fc)
  273. {
  274. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  275. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_REASSOC_RESP);
  276. }
  277. /**
  278. * ieee80211_is_probe_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_PROBE_REQ
  279. * @fc: frame control bytes in little-endian byteorder
  280. */
  281. static inline int ieee80211_is_probe_req(__le16 fc)
  282. {
  283. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  284. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_REQ);
  285. }
  286. /**
  287. * ieee80211_is_probe_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_PROBE_RESP
  288. * @fc: frame control bytes in little-endian byteorder
  289. */
  290. static inline int ieee80211_is_probe_resp(__le16 fc)
  291. {
  292. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  293. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
  294. }
  295. /**
  296. * ieee80211_is_beacon - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_BEACON
  297. * @fc: frame control bytes in little-endian byteorder
  298. */
  299. static inline int ieee80211_is_beacon(__le16 fc)
  300. {
  301. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  302. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
  303. }
  304. /**
  305. * ieee80211_is_atim - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ATIM
  306. * @fc: frame control bytes in little-endian byteorder
  307. */
  308. static inline int ieee80211_is_atim(__le16 fc)
  309. {
  310. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  311. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ATIM);
  312. }
  313. /**
  314. * ieee80211_is_disassoc - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_DISASSOC
  315. * @fc: frame control bytes in little-endian byteorder
  316. */
  317. static inline int ieee80211_is_disassoc(__le16 fc)
  318. {
  319. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  320. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_DISASSOC);
  321. }
  322. /**
  323. * ieee80211_is_auth - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_AUTH
  324. * @fc: frame control bytes in little-endian byteorder
  325. */
  326. static inline int ieee80211_is_auth(__le16 fc)
  327. {
  328. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  329. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH);
  330. }
  331. /**
  332. * ieee80211_is_deauth - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_DEAUTH
  333. * @fc: frame control bytes in little-endian byteorder
  334. */
  335. static inline int ieee80211_is_deauth(__le16 fc)
  336. {
  337. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  338. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_DEAUTH);
  339. }
  340. /**
  341. * ieee80211_is_action - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ACTION
  342. * @fc: frame control bytes in little-endian byteorder
  343. */
  344. static inline int ieee80211_is_action(__le16 fc)
  345. {
  346. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  347. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ACTION);
  348. }
  349. /**
  350. * ieee80211_is_back_req - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_BACK_REQ
  351. * @fc: frame control bytes in little-endian byteorder
  352. */
  353. static inline int ieee80211_is_back_req(__le16 fc)
  354. {
  355. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  356. cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_BACK_REQ);
  357. }
  358. /**
  359. * ieee80211_is_back - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_BACK
  360. * @fc: frame control bytes in little-endian byteorder
  361. */
  362. static inline int ieee80211_is_back(__le16 fc)
  363. {
  364. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  365. cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_BACK);
  366. }
  367. /**
  368. * ieee80211_is_pspoll - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_PSPOLL
  369. * @fc: frame control bytes in little-endian byteorder
  370. */
  371. static inline int ieee80211_is_pspoll(__le16 fc)
  372. {
  373. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  374. cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL);
  375. }
  376. /**
  377. * ieee80211_is_rts - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_RTS
  378. * @fc: frame control bytes in little-endian byteorder
  379. */
  380. static inline int ieee80211_is_rts(__le16 fc)
  381. {
  382. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  383. cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS);
  384. }
  385. /**
  386. * ieee80211_is_cts - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CTS
  387. * @fc: frame control bytes in little-endian byteorder
  388. */
  389. static inline int ieee80211_is_cts(__le16 fc)
  390. {
  391. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  392. cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS);
  393. }
  394. /**
  395. * ieee80211_is_ack - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_ACK
  396. * @fc: frame control bytes in little-endian byteorder
  397. */
  398. static inline int ieee80211_is_ack(__le16 fc)
  399. {
  400. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  401. cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_ACK);
  402. }
  403. /**
  404. * ieee80211_is_cfend - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CFEND
  405. * @fc: frame control bytes in little-endian byteorder
  406. */
  407. static inline int ieee80211_is_cfend(__le16 fc)
  408. {
  409. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  410. cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CFEND);
  411. }
  412. /**
  413. * ieee80211_is_cfendack - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CFENDACK
  414. * @fc: frame control bytes in little-endian byteorder
  415. */
  416. static inline int ieee80211_is_cfendack(__le16 fc)
  417. {
  418. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  419. cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CFENDACK);
  420. }
  421. /**
  422. * ieee80211_is_nullfunc - check if frame is a regular (non-QoS) nullfunc frame
  423. * @fc: frame control bytes in little-endian byteorder
  424. */
  425. static inline int ieee80211_is_nullfunc(__le16 fc)
  426. {
  427. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  428. cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC);
  429. }
  430. /**
  431. * ieee80211_is_qos_nullfunc - check if frame is a QoS nullfunc frame
  432. * @fc: frame control bytes in little-endian byteorder
  433. */
  434. static inline int ieee80211_is_qos_nullfunc(__le16 fc)
  435. {
  436. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  437. cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_QOS_NULLFUNC);
  438. }
  439. struct ieee80211s_hdr {
  440. u8 flags;
  441. u8 ttl;
  442. __le32 seqnum;
  443. u8 eaddr1[6];
  444. u8 eaddr2[6];
  445. u8 eaddr3[6];
  446. } __attribute__ ((packed));
  447. /* Mesh flags */
  448. #define MESH_FLAGS_AE_A4 0x1
  449. #define MESH_FLAGS_AE_A5_A6 0x2
  450. #define MESH_FLAGS_AE 0x3
  451. #define MESH_FLAGS_PS_DEEP 0x4
  452. /**
  453. * struct ieee80211_quiet_ie
  454. *
  455. * This structure refers to "Quiet information element"
  456. */
  457. struct ieee80211_quiet_ie {
  458. u8 count;
  459. u8 period;
  460. __le16 duration;
  461. __le16 offset;
  462. } __attribute__ ((packed));
  463. /**
  464. * struct ieee80211_msrment_ie
  465. *
  466. * This structure refers to "Measurement Request/Report information element"
  467. */
  468. struct ieee80211_msrment_ie {
  469. u8 token;
  470. u8 mode;
  471. u8 type;
  472. u8 request[0];
  473. } __attribute__ ((packed));
  474. /**
  475. * struct ieee80211_channel_sw_ie
  476. *
  477. * This structure refers to "Channel Switch Announcement information element"
  478. */
  479. struct ieee80211_channel_sw_ie {
  480. u8 mode;
  481. u8 new_ch_num;
  482. u8 count;
  483. } __attribute__ ((packed));
  484. /**
  485. * struct ieee80211_tim
  486. *
  487. * This structure refers to "Traffic Indication Map information element"
  488. */
  489. struct ieee80211_tim_ie {
  490. u8 dtim_count;
  491. u8 dtim_period;
  492. u8 bitmap_ctrl;
  493. /* variable size: 1 - 251 bytes */
  494. u8 virtual_map[1];
  495. } __attribute__ ((packed));
  496. /**
  497. * struct ieee80211_meshconf_ie
  498. *
  499. * This structure refers to "Mesh Configuration information element"
  500. */
  501. struct ieee80211_meshconf_ie {
  502. u8 meshconf_psel;
  503. u8 meshconf_pmetric;
  504. u8 meshconf_congest;
  505. u8 meshconf_synch;
  506. u8 meshconf_auth;
  507. u8 meshconf_form;
  508. u8 meshconf_cap;
  509. } __attribute__ ((packed));
  510. /**
  511. * struct ieee80211_rann_ie
  512. *
  513. * This structure refers to "Root Announcement information element"
  514. */
  515. struct ieee80211_rann_ie {
  516. u8 rann_flags;
  517. u8 rann_hopcount;
  518. u8 rann_ttl;
  519. u8 rann_addr[6];
  520. u32 rann_seq;
  521. u32 rann_metric;
  522. } __attribute__ ((packed));
  523. #define WLAN_SA_QUERY_TR_ID_LEN 2
  524. struct ieee80211_mgmt {
  525. __le16 frame_control;
  526. __le16 duration;
  527. u8 da[6];
  528. u8 sa[6];
  529. u8 bssid[6];
  530. __le16 seq_ctrl;
  531. union {
  532. struct {
  533. __le16 auth_alg;
  534. __le16 auth_transaction;
  535. __le16 status_code;
  536. /* possibly followed by Challenge text */
  537. u8 variable[0];
  538. } __attribute__ ((packed)) auth;
  539. struct {
  540. __le16 reason_code;
  541. } __attribute__ ((packed)) deauth;
  542. struct {
  543. __le16 capab_info;
  544. __le16 listen_interval;
  545. /* followed by SSID and Supported rates */
  546. u8 variable[0];
  547. } __attribute__ ((packed)) assoc_req;
  548. struct {
  549. __le16 capab_info;
  550. __le16 status_code;
  551. __le16 aid;
  552. /* followed by Supported rates */
  553. u8 variable[0];
  554. } __attribute__ ((packed)) assoc_resp, reassoc_resp;
  555. struct {
  556. __le16 capab_info;
  557. __le16 listen_interval;
  558. u8 current_ap[6];
  559. /* followed by SSID and Supported rates */
  560. u8 variable[0];
  561. } __attribute__ ((packed)) reassoc_req;
  562. struct {
  563. __le16 reason_code;
  564. } __attribute__ ((packed)) disassoc;
  565. struct {
  566. __le64 timestamp;
  567. __le16 beacon_int;
  568. __le16 capab_info;
  569. /* followed by some of SSID, Supported rates,
  570. * FH Params, DS Params, CF Params, IBSS Params, TIM */
  571. u8 variable[0];
  572. } __attribute__ ((packed)) beacon;
  573. struct {
  574. /* only variable items: SSID, Supported rates */
  575. u8 variable[0];
  576. } __attribute__ ((packed)) probe_req;
  577. struct {
  578. __le64 timestamp;
  579. __le16 beacon_int;
  580. __le16 capab_info;
  581. /* followed by some of SSID, Supported rates,
  582. * FH Params, DS Params, CF Params, IBSS Params */
  583. u8 variable[0];
  584. } __attribute__ ((packed)) probe_resp;
  585. struct {
  586. u8 category;
  587. union {
  588. struct {
  589. u8 action_code;
  590. u8 dialog_token;
  591. u8 status_code;
  592. u8 variable[0];
  593. } __attribute__ ((packed)) wme_action;
  594. struct{
  595. u8 action_code;
  596. u8 element_id;
  597. u8 length;
  598. struct ieee80211_channel_sw_ie sw_elem;
  599. } __attribute__((packed)) chan_switch;
  600. struct{
  601. u8 action_code;
  602. u8 dialog_token;
  603. u8 element_id;
  604. u8 length;
  605. struct ieee80211_msrment_ie msr_elem;
  606. } __attribute__((packed)) measurement;
  607. struct{
  608. u8 action_code;
  609. u8 dialog_token;
  610. __le16 capab;
  611. __le16 timeout;
  612. __le16 start_seq_num;
  613. } __attribute__((packed)) addba_req;
  614. struct{
  615. u8 action_code;
  616. u8 dialog_token;
  617. __le16 status;
  618. __le16 capab;
  619. __le16 timeout;
  620. } __attribute__((packed)) addba_resp;
  621. struct{
  622. u8 action_code;
  623. __le16 params;
  624. __le16 reason_code;
  625. } __attribute__((packed)) delba;
  626. struct{
  627. u8 action_code;
  628. /* capab_info for open and confirm,
  629. * reason for close
  630. */
  631. __le16 aux;
  632. /* Followed in plink_confirm by status
  633. * code, AID and supported rates,
  634. * and directly by supported rates in
  635. * plink_open and plink_close
  636. */
  637. u8 variable[0];
  638. } __attribute__((packed)) plink_action;
  639. struct{
  640. u8 action_code;
  641. u8 variable[0];
  642. } __attribute__((packed)) mesh_action;
  643. struct {
  644. u8 action;
  645. u8 trans_id[WLAN_SA_QUERY_TR_ID_LEN];
  646. } __attribute__ ((packed)) sa_query;
  647. } u;
  648. } __attribute__ ((packed)) action;
  649. } u;
  650. } __attribute__ ((packed));
  651. /* mgmt header + 1 byte category code */
  652. #define IEEE80211_MIN_ACTION_SIZE offsetof(struct ieee80211_mgmt, u.action.u)
  653. /* Management MIC information element (IEEE 802.11w) */
  654. struct ieee80211_mmie {
  655. u8 element_id;
  656. u8 length;
  657. __le16 key_id;
  658. u8 sequence_number[6];
  659. u8 mic[8];
  660. } __attribute__ ((packed));
  661. /* Control frames */
  662. struct ieee80211_rts {
  663. __le16 frame_control;
  664. __le16 duration;
  665. u8 ra[6];
  666. u8 ta[6];
  667. } __attribute__ ((packed));
  668. struct ieee80211_cts {
  669. __le16 frame_control;
  670. __le16 duration;
  671. u8 ra[6];
  672. } __attribute__ ((packed));
  673. struct ieee80211_pspoll {
  674. __le16 frame_control;
  675. __le16 aid;
  676. u8 bssid[6];
  677. u8 ta[6];
  678. } __attribute__ ((packed));
  679. /**
  680. * struct ieee80211_bar - HT Block Ack Request
  681. *
  682. * This structure refers to "HT BlockAckReq" as
  683. * described in 802.11n draft section 7.2.1.7.1
  684. */
  685. struct ieee80211_bar {
  686. __le16 frame_control;
  687. __le16 duration;
  688. __u8 ra[6];
  689. __u8 ta[6];
  690. __le16 control;
  691. __le16 start_seq_num;
  692. } __attribute__((packed));
  693. /* 802.11 BAR control masks */
  694. #define IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL 0x0000
  695. #define IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA 0x0004
  696. #define IEEE80211_HT_MCS_MASK_LEN 10
  697. /**
  698. * struct ieee80211_mcs_info - MCS information
  699. * @rx_mask: RX mask
  700. * @rx_highest: highest supported RX rate
  701. * @tx_params: TX parameters
  702. */
  703. struct ieee80211_mcs_info {
  704. u8 rx_mask[IEEE80211_HT_MCS_MASK_LEN];
  705. __le16 rx_highest;
  706. u8 tx_params;
  707. u8 reserved[3];
  708. } __attribute__((packed));
  709. /* 802.11n HT capability MSC set */
  710. #define IEEE80211_HT_MCS_RX_HIGHEST_MASK 0x3ff
  711. #define IEEE80211_HT_MCS_TX_DEFINED 0x01
  712. #define IEEE80211_HT_MCS_TX_RX_DIFF 0x02
  713. /* value 0 == 1 stream etc */
  714. #define IEEE80211_HT_MCS_TX_MAX_STREAMS_MASK 0x0C
  715. #define IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT 2
  716. #define IEEE80211_HT_MCS_TX_MAX_STREAMS 4
  717. #define IEEE80211_HT_MCS_TX_UNEQUAL_MODULATION 0x10
  718. /*
  719. * 802.11n D5.0 20.3.5 / 20.6 says:
  720. * - indices 0 to 7 and 32 are single spatial stream
  721. * - 8 to 31 are multiple spatial streams using equal modulation
  722. * [8..15 for two streams, 16..23 for three and 24..31 for four]
  723. * - remainder are multiple spatial streams using unequal modulation
  724. */
  725. #define IEEE80211_HT_MCS_UNEQUAL_MODULATION_START 33
  726. #define IEEE80211_HT_MCS_UNEQUAL_MODULATION_START_BYTE \
  727. (IEEE80211_HT_MCS_UNEQUAL_MODULATION_START / 8)
  728. /**
  729. * struct ieee80211_ht_cap - HT capabilities
  730. *
  731. * This structure is the "HT capabilities element" as
  732. * described in 802.11n D5.0 7.3.2.57
  733. */
  734. struct ieee80211_ht_cap {
  735. __le16 cap_info;
  736. u8 ampdu_params_info;
  737. /* 16 bytes MCS information */
  738. struct ieee80211_mcs_info mcs;
  739. __le16 extended_ht_cap_info;
  740. __le32 tx_BF_cap_info;
  741. u8 antenna_selection_info;
  742. } __attribute__ ((packed));
  743. /* 802.11n HT capabilities masks (for cap_info) */
  744. #define IEEE80211_HT_CAP_LDPC_CODING 0x0001
  745. #define IEEE80211_HT_CAP_SUP_WIDTH_20_40 0x0002
  746. #define IEEE80211_HT_CAP_SM_PS 0x000C
  747. #define IEEE80211_HT_CAP_GRN_FLD 0x0010
  748. #define IEEE80211_HT_CAP_SGI_20 0x0020
  749. #define IEEE80211_HT_CAP_SGI_40 0x0040
  750. #define IEEE80211_HT_CAP_TX_STBC 0x0080
  751. #define IEEE80211_HT_CAP_RX_STBC 0x0300
  752. #define IEEE80211_HT_CAP_DELAY_BA 0x0400
  753. #define IEEE80211_HT_CAP_MAX_AMSDU 0x0800
  754. #define IEEE80211_HT_CAP_DSSSCCK40 0x1000
  755. #define IEEE80211_HT_CAP_RESERVED 0x2000
  756. #define IEEE80211_HT_CAP_40MHZ_INTOLERANT 0x4000
  757. #define IEEE80211_HT_CAP_LSIG_TXOP_PROT 0x8000
  758. /* 802.11n HT capability AMPDU settings (for ampdu_params_info) */
  759. #define IEEE80211_HT_AMPDU_PARM_FACTOR 0x03
  760. #define IEEE80211_HT_AMPDU_PARM_DENSITY 0x1C
  761. /*
  762. * Maximum length of AMPDU that the STA can receive.
  763. * Length = 2 ^ (13 + max_ampdu_length_exp) - 1 (octets)
  764. */
  765. enum ieee80211_max_ampdu_length_exp {
  766. IEEE80211_HT_MAX_AMPDU_8K = 0,
  767. IEEE80211_HT_MAX_AMPDU_16K = 1,
  768. IEEE80211_HT_MAX_AMPDU_32K = 2,
  769. IEEE80211_HT_MAX_AMPDU_64K = 3
  770. };
  771. #define IEEE80211_HT_MAX_AMPDU_FACTOR 13
  772. /* Minimum MPDU start spacing */
  773. enum ieee80211_min_mpdu_spacing {
  774. IEEE80211_HT_MPDU_DENSITY_NONE = 0, /* No restriction */
  775. IEEE80211_HT_MPDU_DENSITY_0_25 = 1, /* 1/4 usec */
  776. IEEE80211_HT_MPDU_DENSITY_0_5 = 2, /* 1/2 usec */
  777. IEEE80211_HT_MPDU_DENSITY_1 = 3, /* 1 usec */
  778. IEEE80211_HT_MPDU_DENSITY_2 = 4, /* 2 usec */
  779. IEEE80211_HT_MPDU_DENSITY_4 = 5, /* 4 usec */
  780. IEEE80211_HT_MPDU_DENSITY_8 = 6, /* 8 usec */
  781. IEEE80211_HT_MPDU_DENSITY_16 = 7 /* 16 usec */
  782. };
  783. /**
  784. * struct ieee80211_ht_info - HT information
  785. *
  786. * This structure is the "HT information element" as
  787. * described in 802.11n D5.0 7.3.2.58
  788. */
  789. struct ieee80211_ht_info {
  790. u8 control_chan;
  791. u8 ht_param;
  792. __le16 operation_mode;
  793. __le16 stbc_param;
  794. u8 basic_set[16];
  795. } __attribute__ ((packed));
  796. /* for ht_param */
  797. #define IEEE80211_HT_PARAM_CHA_SEC_OFFSET 0x03
  798. #define IEEE80211_HT_PARAM_CHA_SEC_NONE 0x00
  799. #define IEEE80211_HT_PARAM_CHA_SEC_ABOVE 0x01
  800. #define IEEE80211_HT_PARAM_CHA_SEC_BELOW 0x03
  801. #define IEEE80211_HT_PARAM_CHAN_WIDTH_ANY 0x04
  802. #define IEEE80211_HT_PARAM_RIFS_MODE 0x08
  803. #define IEEE80211_HT_PARAM_SPSMP_SUPPORT 0x10
  804. #define IEEE80211_HT_PARAM_SERV_INTERVAL_GRAN 0xE0
  805. /* for operation_mode */
  806. #define IEEE80211_HT_OP_MODE_PROTECTION 0x0003
  807. #define IEEE80211_HT_OP_MODE_PROTECTION_NONE 0
  808. #define IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER 1
  809. #define IEEE80211_HT_OP_MODE_PROTECTION_20MHZ 2
  810. #define IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED 3
  811. #define IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT 0x0004
  812. #define IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT 0x0010
  813. /* for stbc_param */
  814. #define IEEE80211_HT_STBC_PARAM_DUAL_BEACON 0x0040
  815. #define IEEE80211_HT_STBC_PARAM_DUAL_CTS_PROT 0x0080
  816. #define IEEE80211_HT_STBC_PARAM_STBC_BEACON 0x0100
  817. #define IEEE80211_HT_STBC_PARAM_LSIG_TXOP_FULLPROT 0x0200
  818. #define IEEE80211_HT_STBC_PARAM_PCO_ACTIVE 0x0400
  819. #define IEEE80211_HT_STBC_PARAM_PCO_PHASE 0x0800
  820. /* block-ack parameters */
  821. #define IEEE80211_ADDBA_PARAM_POLICY_MASK 0x0002
  822. #define IEEE80211_ADDBA_PARAM_TID_MASK 0x003C
  823. #define IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK 0xFFA0
  824. #define IEEE80211_DELBA_PARAM_TID_MASK 0xF000
  825. #define IEEE80211_DELBA_PARAM_INITIATOR_MASK 0x0800
  826. /*
  827. * A-PMDU buffer sizes
  828. * According to IEEE802.11n spec size varies from 8K to 64K (in powers of 2)
  829. */
  830. #define IEEE80211_MIN_AMPDU_BUF 0x8
  831. #define IEEE80211_MAX_AMPDU_BUF 0x40
  832. /* Spatial Multiplexing Power Save Modes */
  833. #define WLAN_HT_CAP_SM_PS_STATIC 0
  834. #define WLAN_HT_CAP_SM_PS_DYNAMIC 1
  835. #define WLAN_HT_CAP_SM_PS_INVALID 2
  836. #define WLAN_HT_CAP_SM_PS_DISABLED 3
  837. /* Authentication algorithms */
  838. #define WLAN_AUTH_OPEN 0
  839. #define WLAN_AUTH_SHARED_KEY 1
  840. #define WLAN_AUTH_FT 2
  841. #define WLAN_AUTH_LEAP 128
  842. #define WLAN_AUTH_CHALLENGE_LEN 128
  843. #define WLAN_CAPABILITY_ESS (1<<0)
  844. #define WLAN_CAPABILITY_IBSS (1<<1)
  845. #define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
  846. #define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
  847. #define WLAN_CAPABILITY_PRIVACY (1<<4)
  848. #define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
  849. #define WLAN_CAPABILITY_PBCC (1<<6)
  850. #define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
  851. /* 802.11h */
  852. #define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8)
  853. #define WLAN_CAPABILITY_QOS (1<<9)
  854. #define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10)
  855. #define WLAN_CAPABILITY_DSSS_OFDM (1<<13)
  856. /* measurement */
  857. #define IEEE80211_SPCT_MSR_RPRT_MODE_LATE (1<<0)
  858. #define IEEE80211_SPCT_MSR_RPRT_MODE_INCAPABLE (1<<1)
  859. #define IEEE80211_SPCT_MSR_RPRT_MODE_REFUSED (1<<2)
  860. #define IEEE80211_SPCT_MSR_RPRT_TYPE_BASIC 0
  861. #define IEEE80211_SPCT_MSR_RPRT_TYPE_CCA 1
  862. #define IEEE80211_SPCT_MSR_RPRT_TYPE_RPI 2
  863. /* 802.11g ERP information element */
  864. #define WLAN_ERP_NON_ERP_PRESENT (1<<0)
  865. #define WLAN_ERP_USE_PROTECTION (1<<1)
  866. #define WLAN_ERP_BARKER_PREAMBLE (1<<2)
  867. /* WLAN_ERP_BARKER_PREAMBLE values */
  868. enum {
  869. WLAN_ERP_PREAMBLE_SHORT = 0,
  870. WLAN_ERP_PREAMBLE_LONG = 1,
  871. };
  872. /* Status codes */
  873. enum ieee80211_statuscode {
  874. WLAN_STATUS_SUCCESS = 0,
  875. WLAN_STATUS_UNSPECIFIED_FAILURE = 1,
  876. WLAN_STATUS_CAPS_UNSUPPORTED = 10,
  877. WLAN_STATUS_REASSOC_NO_ASSOC = 11,
  878. WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12,
  879. WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13,
  880. WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14,
  881. WLAN_STATUS_CHALLENGE_FAIL = 15,
  882. WLAN_STATUS_AUTH_TIMEOUT = 16,
  883. WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17,
  884. WLAN_STATUS_ASSOC_DENIED_RATES = 18,
  885. /* 802.11b */
  886. WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19,
  887. WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20,
  888. WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21,
  889. /* 802.11h */
  890. WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22,
  891. WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23,
  892. WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24,
  893. /* 802.11g */
  894. WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25,
  895. WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26,
  896. /* 802.11w */
  897. WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY = 30,
  898. WLAN_STATUS_ROBUST_MGMT_FRAME_POLICY_VIOLATION = 31,
  899. /* 802.11i */
  900. WLAN_STATUS_INVALID_IE = 40,
  901. WLAN_STATUS_INVALID_GROUP_CIPHER = 41,
  902. WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42,
  903. WLAN_STATUS_INVALID_AKMP = 43,
  904. WLAN_STATUS_UNSUPP_RSN_VERSION = 44,
  905. WLAN_STATUS_INVALID_RSN_IE_CAP = 45,
  906. WLAN_STATUS_CIPHER_SUITE_REJECTED = 46,
  907. /* 802.11e */
  908. WLAN_STATUS_UNSPECIFIED_QOS = 32,
  909. WLAN_STATUS_ASSOC_DENIED_NOBANDWIDTH = 33,
  910. WLAN_STATUS_ASSOC_DENIED_LOWACK = 34,
  911. WLAN_STATUS_ASSOC_DENIED_UNSUPP_QOS = 35,
  912. WLAN_STATUS_REQUEST_DECLINED = 37,
  913. WLAN_STATUS_INVALID_QOS_PARAM = 38,
  914. WLAN_STATUS_CHANGE_TSPEC = 39,
  915. WLAN_STATUS_WAIT_TS_DELAY = 47,
  916. WLAN_STATUS_NO_DIRECT_LINK = 48,
  917. WLAN_STATUS_STA_NOT_PRESENT = 49,
  918. WLAN_STATUS_STA_NOT_QSTA = 50,
  919. };
  920. /* Reason codes */
  921. enum ieee80211_reasoncode {
  922. WLAN_REASON_UNSPECIFIED = 1,
  923. WLAN_REASON_PREV_AUTH_NOT_VALID = 2,
  924. WLAN_REASON_DEAUTH_LEAVING = 3,
  925. WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4,
  926. WLAN_REASON_DISASSOC_AP_BUSY = 5,
  927. WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6,
  928. WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7,
  929. WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8,
  930. WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9,
  931. /* 802.11h */
  932. WLAN_REASON_DISASSOC_BAD_POWER = 10,
  933. WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11,
  934. /* 802.11i */
  935. WLAN_REASON_INVALID_IE = 13,
  936. WLAN_REASON_MIC_FAILURE = 14,
  937. WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15,
  938. WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16,
  939. WLAN_REASON_IE_DIFFERENT = 17,
  940. WLAN_REASON_INVALID_GROUP_CIPHER = 18,
  941. WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19,
  942. WLAN_REASON_INVALID_AKMP = 20,
  943. WLAN_REASON_UNSUPP_RSN_VERSION = 21,
  944. WLAN_REASON_INVALID_RSN_IE_CAP = 22,
  945. WLAN_REASON_IEEE8021X_FAILED = 23,
  946. WLAN_REASON_CIPHER_SUITE_REJECTED = 24,
  947. /* 802.11e */
  948. WLAN_REASON_DISASSOC_UNSPECIFIED_QOS = 32,
  949. WLAN_REASON_DISASSOC_QAP_NO_BANDWIDTH = 33,
  950. WLAN_REASON_DISASSOC_LOW_ACK = 34,
  951. WLAN_REASON_DISASSOC_QAP_EXCEED_TXOP = 35,
  952. WLAN_REASON_QSTA_LEAVE_QBSS = 36,
  953. WLAN_REASON_QSTA_NOT_USE = 37,
  954. WLAN_REASON_QSTA_REQUIRE_SETUP = 38,
  955. WLAN_REASON_QSTA_TIMEOUT = 39,
  956. WLAN_REASON_QSTA_CIPHER_NOT_SUPP = 45,
  957. };
  958. /* Information Element IDs */
  959. enum ieee80211_eid {
  960. WLAN_EID_SSID = 0,
  961. WLAN_EID_SUPP_RATES = 1,
  962. WLAN_EID_FH_PARAMS = 2,
  963. WLAN_EID_DS_PARAMS = 3,
  964. WLAN_EID_CF_PARAMS = 4,
  965. WLAN_EID_TIM = 5,
  966. WLAN_EID_IBSS_PARAMS = 6,
  967. WLAN_EID_CHALLENGE = 16,
  968. /* 802.11d */
  969. WLAN_EID_COUNTRY = 7,
  970. WLAN_EID_HP_PARAMS = 8,
  971. WLAN_EID_HP_TABLE = 9,
  972. WLAN_EID_REQUEST = 10,
  973. /* 802.11e */
  974. WLAN_EID_QBSS_LOAD = 11,
  975. WLAN_EID_EDCA_PARAM_SET = 12,
  976. WLAN_EID_TSPEC = 13,
  977. WLAN_EID_TCLAS = 14,
  978. WLAN_EID_SCHEDULE = 15,
  979. WLAN_EID_TS_DELAY = 43,
  980. WLAN_EID_TCLAS_PROCESSING = 44,
  981. WLAN_EID_QOS_CAPA = 46,
  982. /* 802.11s
  983. *
  984. * All mesh EID numbers are pending IEEE 802.11 ANA approval.
  985. * The numbers have been incremented from those suggested in
  986. * 802.11s/D2.0 so that MESH_CONFIG does not conflict with
  987. * EXT_SUPP_RATES.
  988. */
  989. WLAN_EID_MESH_CONFIG = 51,
  990. WLAN_EID_MESH_ID = 52,
  991. WLAN_EID_PEER_LINK = 55,
  992. WLAN_EID_PREQ = 68,
  993. WLAN_EID_PREP = 69,
  994. WLAN_EID_PERR = 70,
  995. WLAN_EID_RANN = 49, /* compatible with FreeBSD */
  996. /* 802.11h */
  997. WLAN_EID_PWR_CONSTRAINT = 32,
  998. WLAN_EID_PWR_CAPABILITY = 33,
  999. WLAN_EID_TPC_REQUEST = 34,
  1000. WLAN_EID_TPC_REPORT = 35,
  1001. WLAN_EID_SUPPORTED_CHANNELS = 36,
  1002. WLAN_EID_CHANNEL_SWITCH = 37,
  1003. WLAN_EID_MEASURE_REQUEST = 38,
  1004. WLAN_EID_MEASURE_REPORT = 39,
  1005. WLAN_EID_QUIET = 40,
  1006. WLAN_EID_IBSS_DFS = 41,
  1007. /* 802.11g */
  1008. WLAN_EID_ERP_INFO = 42,
  1009. WLAN_EID_EXT_SUPP_RATES = 50,
  1010. /* 802.11n */
  1011. WLAN_EID_HT_CAPABILITY = 45,
  1012. WLAN_EID_HT_INFORMATION = 61,
  1013. /* 802.11i */
  1014. WLAN_EID_RSN = 48,
  1015. WLAN_EID_TIMEOUT_INTERVAL = 56,
  1016. WLAN_EID_MMIE = 76 /* 802.11w */,
  1017. WLAN_EID_WPA = 221,
  1018. WLAN_EID_GENERIC = 221,
  1019. WLAN_EID_VENDOR_SPECIFIC = 221,
  1020. WLAN_EID_QOS_PARAMETER = 222
  1021. };
  1022. /* Action category code */
  1023. enum ieee80211_category {
  1024. WLAN_CATEGORY_SPECTRUM_MGMT = 0,
  1025. WLAN_CATEGORY_QOS = 1,
  1026. WLAN_CATEGORY_DLS = 2,
  1027. WLAN_CATEGORY_BACK = 3,
  1028. WLAN_CATEGORY_PUBLIC = 4,
  1029. WLAN_CATEGORY_HT = 7,
  1030. WLAN_CATEGORY_SA_QUERY = 8,
  1031. WLAN_CATEGORY_PROTECTED_DUAL_OF_ACTION = 9,
  1032. WLAN_CATEGORY_WMM = 17,
  1033. WLAN_CATEGORY_VENDOR_SPECIFIC_PROTECTED = 126,
  1034. WLAN_CATEGORY_VENDOR_SPECIFIC = 127,
  1035. };
  1036. /* SPECTRUM_MGMT action code */
  1037. enum ieee80211_spectrum_mgmt_actioncode {
  1038. WLAN_ACTION_SPCT_MSR_REQ = 0,
  1039. WLAN_ACTION_SPCT_MSR_RPRT = 1,
  1040. WLAN_ACTION_SPCT_TPC_REQ = 2,
  1041. WLAN_ACTION_SPCT_TPC_RPRT = 3,
  1042. WLAN_ACTION_SPCT_CHL_SWITCH = 4,
  1043. };
  1044. /* Security key length */
  1045. enum ieee80211_key_len {
  1046. WLAN_KEY_LEN_WEP40 = 5,
  1047. WLAN_KEY_LEN_WEP104 = 13,
  1048. WLAN_KEY_LEN_CCMP = 16,
  1049. WLAN_KEY_LEN_TKIP = 32,
  1050. WLAN_KEY_LEN_AES_CMAC = 16,
  1051. };
  1052. /*
  1053. * IEEE 802.11-2007 7.3.2.9 Country information element
  1054. *
  1055. * Minimum length is 8 octets, ie len must be evenly
  1056. * divisible by 2
  1057. */
  1058. /* Although the spec says 8 I'm seeing 6 in practice */
  1059. #define IEEE80211_COUNTRY_IE_MIN_LEN 6
  1060. /*
  1061. * For regulatory extension stuff see IEEE 802.11-2007
  1062. * Annex I (page 1141) and Annex J (page 1147). Also
  1063. * review 7.3.2.9.
  1064. *
  1065. * When dot11RegulatoryClassesRequired is true and the
  1066. * first_channel/reg_extension_id is >= 201 then the IE
  1067. * compromises of the 'ext' struct represented below:
  1068. *
  1069. * - Regulatory extension ID - when generating IE this just needs
  1070. * to be monotonically increasing for each triplet passed in
  1071. * the IE
  1072. * - Regulatory class - index into set of rules
  1073. * - Coverage class - index into air propagation time (Table 7-27),
  1074. * in microseconds, you can compute the air propagation time from
  1075. * the index by multiplying by 3, so index 10 yields a propagation
  1076. * of 10 us. Valid values are 0-31, values 32-255 are not defined
  1077. * yet. A value of 0 inicates air propagation of <= 1 us.
  1078. *
  1079. * See also Table I.2 for Emission limit sets and table
  1080. * I.3 for Behavior limit sets. Table J.1 indicates how to map
  1081. * a reg_class to an emission limit set and behavior limit set.
  1082. */
  1083. #define IEEE80211_COUNTRY_EXTENSION_ID 201
  1084. /*
  1085. * Channels numbers in the IE must be monotonically increasing
  1086. * if dot11RegulatoryClassesRequired is not true.
  1087. *
  1088. * If dot11RegulatoryClassesRequired is true consecutive
  1089. * subband triplets following a regulatory triplet shall
  1090. * have monotonically increasing first_channel number fields.
  1091. *
  1092. * Channel numbers shall not overlap.
  1093. *
  1094. * Note that max_power is signed.
  1095. */
  1096. struct ieee80211_country_ie_triplet {
  1097. union {
  1098. struct {
  1099. u8 first_channel;
  1100. u8 num_channels;
  1101. s8 max_power;
  1102. } __attribute__ ((packed)) chans;
  1103. struct {
  1104. u8 reg_extension_id;
  1105. u8 reg_class;
  1106. u8 coverage_class;
  1107. } __attribute__ ((packed)) ext;
  1108. };
  1109. } __attribute__ ((packed));
  1110. enum ieee80211_timeout_interval_type {
  1111. WLAN_TIMEOUT_REASSOC_DEADLINE = 1 /* 802.11r */,
  1112. WLAN_TIMEOUT_KEY_LIFETIME = 2 /* 802.11r */,
  1113. WLAN_TIMEOUT_ASSOC_COMEBACK = 3 /* 802.11w */,
  1114. };
  1115. /* BACK action code */
  1116. enum ieee80211_back_actioncode {
  1117. WLAN_ACTION_ADDBA_REQ = 0,
  1118. WLAN_ACTION_ADDBA_RESP = 1,
  1119. WLAN_ACTION_DELBA = 2,
  1120. };
  1121. /* BACK (block-ack) parties */
  1122. enum ieee80211_back_parties {
  1123. WLAN_BACK_RECIPIENT = 0,
  1124. WLAN_BACK_INITIATOR = 1,
  1125. WLAN_BACK_TIMER = 2,
  1126. };
  1127. /* SA Query action */
  1128. enum ieee80211_sa_query_action {
  1129. WLAN_ACTION_SA_QUERY_REQUEST = 0,
  1130. WLAN_ACTION_SA_QUERY_RESPONSE = 1,
  1131. };
  1132. /* A-MSDU 802.11n */
  1133. #define IEEE80211_QOS_CONTROL_A_MSDU_PRESENT 0x0080
  1134. /* cipher suite selectors */
  1135. #define WLAN_CIPHER_SUITE_USE_GROUP 0x000FAC00
  1136. #define WLAN_CIPHER_SUITE_WEP40 0x000FAC01
  1137. #define WLAN_CIPHER_SUITE_TKIP 0x000FAC02
  1138. /* reserved: 0x000FAC03 */
  1139. #define WLAN_CIPHER_SUITE_CCMP 0x000FAC04
  1140. #define WLAN_CIPHER_SUITE_WEP104 0x000FAC05
  1141. #define WLAN_CIPHER_SUITE_AES_CMAC 0x000FAC06
  1142. /* AKM suite selectors */
  1143. #define WLAN_AKM_SUITE_8021X 0x000FAC01
  1144. #define WLAN_AKM_SUITE_PSK 0x000FAC02
  1145. #define WLAN_MAX_KEY_LEN 32
  1146. #define WLAN_PMKID_LEN 16
  1147. /**
  1148. * ieee80211_get_qos_ctl - get pointer to qos control bytes
  1149. * @hdr: the frame
  1150. *
  1151. * The qos ctrl bytes come after the frame_control, duration, seq_num
  1152. * and 3 or 4 addresses of length ETH_ALEN.
  1153. * 3 addr: 2 + 2 + 2 + 3*6 = 24
  1154. * 4 addr: 2 + 2 + 2 + 4*6 = 30
  1155. */
  1156. static inline u8 *ieee80211_get_qos_ctl(struct ieee80211_hdr *hdr)
  1157. {
  1158. if (ieee80211_has_a4(hdr->frame_control))
  1159. return (u8 *)hdr + 30;
  1160. else
  1161. return (u8 *)hdr + 24;
  1162. }
  1163. /**
  1164. * ieee80211_get_SA - get pointer to SA
  1165. * @hdr: the frame
  1166. *
  1167. * Given an 802.11 frame, this function returns the offset
  1168. * to the source address (SA). It does not verify that the
  1169. * header is long enough to contain the address, and the
  1170. * header must be long enough to contain the frame control
  1171. * field.
  1172. */
  1173. static inline u8 *ieee80211_get_SA(struct ieee80211_hdr *hdr)
  1174. {
  1175. if (ieee80211_has_a4(hdr->frame_control))
  1176. return hdr->addr4;
  1177. if (ieee80211_has_fromds(hdr->frame_control))
  1178. return hdr->addr3;
  1179. return hdr->addr2;
  1180. }
  1181. /**
  1182. * ieee80211_get_DA - get pointer to DA
  1183. * @hdr: the frame
  1184. *
  1185. * Given an 802.11 frame, this function returns the offset
  1186. * to the destination address (DA). It does not verify that
  1187. * the header is long enough to contain the address, and the
  1188. * header must be long enough to contain the frame control
  1189. * field.
  1190. */
  1191. static inline u8 *ieee80211_get_DA(struct ieee80211_hdr *hdr)
  1192. {
  1193. if (ieee80211_has_tods(hdr->frame_control))
  1194. return hdr->addr3;
  1195. else
  1196. return hdr->addr1;
  1197. }
  1198. /**
  1199. * ieee80211_is_robust_mgmt_frame - check if frame is a robust management frame
  1200. * @hdr: the frame (buffer must include at least the first octet of payload)
  1201. */
  1202. static inline bool ieee80211_is_robust_mgmt_frame(struct ieee80211_hdr *hdr)
  1203. {
  1204. if (ieee80211_is_disassoc(hdr->frame_control) ||
  1205. ieee80211_is_deauth(hdr->frame_control))
  1206. return true;
  1207. if (ieee80211_is_action(hdr->frame_control)) {
  1208. u8 *category;
  1209. /*
  1210. * Action frames, excluding Public Action frames, are Robust
  1211. * Management Frames. However, if we are looking at a Protected
  1212. * frame, skip the check since the data may be encrypted and
  1213. * the frame has already been found to be a Robust Management
  1214. * Frame (by the other end).
  1215. */
  1216. if (ieee80211_has_protected(hdr->frame_control))
  1217. return true;
  1218. category = ((u8 *) hdr) + 24;
  1219. return *category != WLAN_CATEGORY_PUBLIC &&
  1220. *category != WLAN_CATEGORY_HT &&
  1221. *category != WLAN_CATEGORY_VENDOR_SPECIFIC;
  1222. }
  1223. return false;
  1224. }
  1225. /**
  1226. * ieee80211_fhss_chan_to_freq - get channel frequency
  1227. * @channel: the FHSS channel
  1228. *
  1229. * Convert IEEE802.11 FHSS channel to frequency (MHz)
  1230. * Ref IEEE 802.11-2007 section 14.6
  1231. */
  1232. static inline int ieee80211_fhss_chan_to_freq(int channel)
  1233. {
  1234. if ((channel > 1) && (channel < 96))
  1235. return channel + 2400;
  1236. else
  1237. return -1;
  1238. }
  1239. /**
  1240. * ieee80211_freq_to_fhss_chan - get channel
  1241. * @freq: the channels frequency
  1242. *
  1243. * Convert frequency (MHz) to IEEE802.11 FHSS channel
  1244. * Ref IEEE 802.11-2007 section 14.6
  1245. */
  1246. static inline int ieee80211_freq_to_fhss_chan(int freq)
  1247. {
  1248. if ((freq > 2401) && (freq < 2496))
  1249. return freq - 2400;
  1250. else
  1251. return -1;
  1252. }
  1253. /**
  1254. * ieee80211_dsss_chan_to_freq - get channel center frequency
  1255. * @channel: the DSSS channel
  1256. *
  1257. * Convert IEEE802.11 DSSS channel to the center frequency (MHz).
  1258. * Ref IEEE 802.11-2007 section 15.6
  1259. */
  1260. static inline int ieee80211_dsss_chan_to_freq(int channel)
  1261. {
  1262. if ((channel > 0) && (channel < 14))
  1263. return 2407 + (channel * 5);
  1264. else if (channel == 14)
  1265. return 2484;
  1266. else
  1267. return -1;
  1268. }
  1269. /**
  1270. * ieee80211_freq_to_dsss_chan - get channel
  1271. * @freq: the frequency
  1272. *
  1273. * Convert frequency (MHz) to IEEE802.11 DSSS channel
  1274. * Ref IEEE 802.11-2007 section 15.6
  1275. *
  1276. * This routine selects the channel with the closest center frequency.
  1277. */
  1278. static inline int ieee80211_freq_to_dsss_chan(int freq)
  1279. {
  1280. if ((freq >= 2410) && (freq < 2475))
  1281. return (freq - 2405) / 5;
  1282. else if ((freq >= 2482) && (freq < 2487))
  1283. return 14;
  1284. else
  1285. return -1;
  1286. }
  1287. /* Convert IEEE802.11 HR DSSS channel to frequency (MHz) and back
  1288. * Ref IEEE 802.11-2007 section 18.4.6.2
  1289. *
  1290. * The channels and frequencies are the same as those defined for DSSS
  1291. */
  1292. #define ieee80211_hr_chan_to_freq(chan) ieee80211_dsss_chan_to_freq(chan)
  1293. #define ieee80211_freq_to_hr_chan(freq) ieee80211_freq_to_dsss_chan(freq)
  1294. /* Convert IEEE802.11 ERP channel to frequency (MHz) and back
  1295. * Ref IEEE 802.11-2007 section 19.4.2
  1296. */
  1297. #define ieee80211_erp_chan_to_freq(chan) ieee80211_hr_chan_to_freq(chan)
  1298. #define ieee80211_freq_to_erp_chan(freq) ieee80211_freq_to_hr_chan(freq)
  1299. /**
  1300. * ieee80211_ofdm_chan_to_freq - get channel center frequency
  1301. * @s_freq: starting frequency == (dotChannelStartingFactor/2) MHz
  1302. * @channel: the OFDM channel
  1303. *
  1304. * Convert IEEE802.11 OFDM channel to center frequency (MHz)
  1305. * Ref IEEE 802.11-2007 section 17.3.8.3.2
  1306. */
  1307. static inline int ieee80211_ofdm_chan_to_freq(int s_freq, int channel)
  1308. {
  1309. if ((channel > 0) && (channel <= 200) &&
  1310. (s_freq >= 4000))
  1311. return s_freq + (channel * 5);
  1312. else
  1313. return -1;
  1314. }
  1315. /**
  1316. * ieee80211_freq_to_ofdm_channel - get channel
  1317. * @s_freq: starting frequency == (dotChannelStartingFactor/2) MHz
  1318. * @freq: the frequency
  1319. *
  1320. * Convert frequency (MHz) to IEEE802.11 OFDM channel
  1321. * Ref IEEE 802.11-2007 section 17.3.8.3.2
  1322. *
  1323. * This routine selects the channel with the closest center frequency.
  1324. */
  1325. static inline int ieee80211_freq_to_ofdm_chan(int s_freq, int freq)
  1326. {
  1327. if ((freq > (s_freq + 2)) && (freq <= (s_freq + 1202)) &&
  1328. (s_freq >= 4000))
  1329. return (freq + 2 - s_freq) / 5;
  1330. else
  1331. return -1;
  1332. }
  1333. /**
  1334. * ieee80211_tu_to_usec - convert time units (TU) to microseconds
  1335. * @tu: the TUs
  1336. */
  1337. static inline unsigned long ieee80211_tu_to_usec(unsigned long tu)
  1338. {
  1339. return 1024 * tu;
  1340. }
  1341. /**
  1342. * ieee80211_check_tim - check if AID bit is set in TIM
  1343. * @tim: the TIM IE
  1344. * @tim_len: length of the TIM IE
  1345. * @aid: the AID to look for
  1346. */
  1347. static inline bool ieee80211_check_tim(struct ieee80211_tim_ie *tim,
  1348. u8 tim_len, u16 aid)
  1349. {
  1350. u8 mask;
  1351. u8 index, indexn1, indexn2;
  1352. if (unlikely(!tim || tim_len < sizeof(*tim)))
  1353. return false;
  1354. aid &= 0x3fff;
  1355. index = aid / 8;
  1356. mask = 1 << (aid & 7);
  1357. indexn1 = tim->bitmap_ctrl & 0xfe;
  1358. indexn2 = tim_len + indexn1 - 4;
  1359. if (index < indexn1 || index > indexn2)
  1360. return false;
  1361. index -= indexn1;
  1362. return !!(tim->virtual_map[index] & mask);
  1363. }
  1364. #endif /* LINUX_IEEE80211_H */