ieee80211.h 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037
  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 IEEE80211_H
  15. #define IEEE80211_H
  16. #include <linux/types.h>
  17. #include <asm/byteorder.h>
  18. #define FCS_LEN 4
  19. #define IEEE80211_FCTL_VERS 0x0003
  20. #define IEEE80211_FCTL_FTYPE 0x000c
  21. #define IEEE80211_FCTL_STYPE 0x00f0
  22. #define IEEE80211_FCTL_TODS 0x0100
  23. #define IEEE80211_FCTL_FROMDS 0x0200
  24. #define IEEE80211_FCTL_MOREFRAGS 0x0400
  25. #define IEEE80211_FCTL_RETRY 0x0800
  26. #define IEEE80211_FCTL_PM 0x1000
  27. #define IEEE80211_FCTL_MOREDATA 0x2000
  28. #define IEEE80211_FCTL_PROTECTED 0x4000
  29. #define IEEE80211_FCTL_ORDER 0x8000
  30. #define IEEE80211_SCTL_FRAG 0x000F
  31. #define IEEE80211_SCTL_SEQ 0xFFF0
  32. #define IEEE80211_FTYPE_MGMT 0x0000
  33. #define IEEE80211_FTYPE_CTL 0x0004
  34. #define IEEE80211_FTYPE_DATA 0x0008
  35. /* management */
  36. #define IEEE80211_STYPE_ASSOC_REQ 0x0000
  37. #define IEEE80211_STYPE_ASSOC_RESP 0x0010
  38. #define IEEE80211_STYPE_REASSOC_REQ 0x0020
  39. #define IEEE80211_STYPE_REASSOC_RESP 0x0030
  40. #define IEEE80211_STYPE_PROBE_REQ 0x0040
  41. #define IEEE80211_STYPE_PROBE_RESP 0x0050
  42. #define IEEE80211_STYPE_BEACON 0x0080
  43. #define IEEE80211_STYPE_ATIM 0x0090
  44. #define IEEE80211_STYPE_DISASSOC 0x00A0
  45. #define IEEE80211_STYPE_AUTH 0x00B0
  46. #define IEEE80211_STYPE_DEAUTH 0x00C0
  47. #define IEEE80211_STYPE_ACTION 0x00D0
  48. /* control */
  49. #define IEEE80211_STYPE_BACK_REQ 0x0080
  50. #define IEEE80211_STYPE_BACK 0x0090
  51. #define IEEE80211_STYPE_PSPOLL 0x00A0
  52. #define IEEE80211_STYPE_RTS 0x00B0
  53. #define IEEE80211_STYPE_CTS 0x00C0
  54. #define IEEE80211_STYPE_ACK 0x00D0
  55. #define IEEE80211_STYPE_CFEND 0x00E0
  56. #define IEEE80211_STYPE_CFENDACK 0x00F0
  57. /* data */
  58. #define IEEE80211_STYPE_DATA 0x0000
  59. #define IEEE80211_STYPE_DATA_CFACK 0x0010
  60. #define IEEE80211_STYPE_DATA_CFPOLL 0x0020
  61. #define IEEE80211_STYPE_DATA_CFACKPOLL 0x0030
  62. #define IEEE80211_STYPE_NULLFUNC 0x0040
  63. #define IEEE80211_STYPE_CFACK 0x0050
  64. #define IEEE80211_STYPE_CFPOLL 0x0060
  65. #define IEEE80211_STYPE_CFACKPOLL 0x0070
  66. #define IEEE80211_STYPE_QOS_DATA 0x0080
  67. #define IEEE80211_STYPE_QOS_DATA_CFACK 0x0090
  68. #define IEEE80211_STYPE_QOS_DATA_CFPOLL 0x00A0
  69. #define IEEE80211_STYPE_QOS_DATA_CFACKPOLL 0x00B0
  70. #define IEEE80211_STYPE_QOS_NULLFUNC 0x00C0
  71. #define IEEE80211_STYPE_QOS_CFACK 0x00D0
  72. #define IEEE80211_STYPE_QOS_CFPOLL 0x00E0
  73. #define IEEE80211_STYPE_QOS_CFACKPOLL 0x00F0
  74. /* miscellaneous IEEE 802.11 constants */
  75. #define IEEE80211_MAX_FRAG_THRESHOLD 2352
  76. #define IEEE80211_MAX_RTS_THRESHOLD 2353
  77. #define IEEE80211_MAX_AID 2007
  78. #define IEEE80211_MAX_TIM_LEN 251
  79. /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
  80. 6.2.1.1.2.
  81. 802.11e clarifies the figure in section 7.1.2. The frame body is
  82. up to 2304 octets long (maximum MSDU size) plus any crypt overhead. */
  83. #define IEEE80211_MAX_DATA_LEN 2304
  84. /* 30 byte 4 addr hdr, 2 byte QoS, 2304 byte MSDU, 12 byte crypt, 4 byte FCS */
  85. #define IEEE80211_MAX_FRAME_LEN 2352
  86. #define IEEE80211_MAX_SSID_LEN 32
  87. #define IEEE80211_MAX_MESH_ID_LEN 32
  88. #define IEEE80211_QOS_CTL_LEN 2
  89. #define IEEE80211_QOS_CTL_TID_MASK 0x000F
  90. #define IEEE80211_QOS_CTL_TAG1D_MASK 0x0007
  91. struct ieee80211_hdr {
  92. __le16 frame_control;
  93. __le16 duration_id;
  94. u8 addr1[6];
  95. u8 addr2[6];
  96. u8 addr3[6];
  97. __le16 seq_ctrl;
  98. u8 addr4[6];
  99. } __attribute__ ((packed));
  100. /**
  101. * ieee80211_has_tods - check if IEEE80211_FCTL_TODS is set
  102. * @fc: frame control bytes in little-endian byteorder
  103. */
  104. static inline int ieee80211_has_tods(__le16 fc)
  105. {
  106. return (fc & cpu_to_le16(IEEE80211_FCTL_TODS)) != 0;
  107. }
  108. /**
  109. * ieee80211_has_fromds - check if IEEE80211_FCTL_FROMDS is set
  110. * @fc: frame control bytes in little-endian byteorder
  111. */
  112. static inline int ieee80211_has_fromds(__le16 fc)
  113. {
  114. return (fc & cpu_to_le16(IEEE80211_FCTL_FROMDS)) != 0;
  115. }
  116. /**
  117. * ieee80211_has_a4 - check if IEEE80211_FCTL_TODS and IEEE80211_FCTL_FROMDS are set
  118. * @fc: frame control bytes in little-endian byteorder
  119. */
  120. static inline int ieee80211_has_a4(__le16 fc)
  121. {
  122. __le16 tmp = cpu_to_le16(IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS);
  123. return (fc & tmp) == tmp;
  124. }
  125. /**
  126. * ieee80211_has_morefrags - check if IEEE80211_FCTL_MOREFRAGS is set
  127. * @fc: frame control bytes in little-endian byteorder
  128. */
  129. static inline int ieee80211_has_morefrags(__le16 fc)
  130. {
  131. return (fc & cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)) != 0;
  132. }
  133. /**
  134. * ieee80211_has_retry - check if IEEE80211_FCTL_RETRY is set
  135. * @fc: frame control bytes in little-endian byteorder
  136. */
  137. static inline int ieee80211_has_retry(__le16 fc)
  138. {
  139. return (fc & cpu_to_le16(IEEE80211_FCTL_RETRY)) != 0;
  140. }
  141. /**
  142. * ieee80211_has_pm - check if IEEE80211_FCTL_PM is set
  143. * @fc: frame control bytes in little-endian byteorder
  144. */
  145. static inline int ieee80211_has_pm(__le16 fc)
  146. {
  147. return (fc & cpu_to_le16(IEEE80211_FCTL_PM)) != 0;
  148. }
  149. /**
  150. * ieee80211_has_moredata - check if IEEE80211_FCTL_MOREDATA is set
  151. * @fc: frame control bytes in little-endian byteorder
  152. */
  153. static inline int ieee80211_has_moredata(__le16 fc)
  154. {
  155. return (fc & cpu_to_le16(IEEE80211_FCTL_MOREDATA)) != 0;
  156. }
  157. /**
  158. * ieee80211_has_protected - check if IEEE80211_FCTL_PROTECTED is set
  159. * @fc: frame control bytes in little-endian byteorder
  160. */
  161. static inline int ieee80211_has_protected(__le16 fc)
  162. {
  163. return (fc & cpu_to_le16(IEEE80211_FCTL_PROTECTED)) != 0;
  164. }
  165. /**
  166. * ieee80211_has_order - check if IEEE80211_FCTL_ORDER is set
  167. * @fc: frame control bytes in little-endian byteorder
  168. */
  169. static inline int ieee80211_has_order(__le16 fc)
  170. {
  171. return (fc & cpu_to_le16(IEEE80211_FCTL_ORDER)) != 0;
  172. }
  173. /**
  174. * ieee80211_is_mgmt - check if type is IEEE80211_FTYPE_MGMT
  175. * @fc: frame control bytes in little-endian byteorder
  176. */
  177. static inline int ieee80211_is_mgmt(__le16 fc)
  178. {
  179. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
  180. cpu_to_le16(IEEE80211_FTYPE_MGMT);
  181. }
  182. /**
  183. * ieee80211_is_ctl - check if type is IEEE80211_FTYPE_CTL
  184. * @fc: frame control bytes in little-endian byteorder
  185. */
  186. static inline int ieee80211_is_ctl(__le16 fc)
  187. {
  188. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
  189. cpu_to_le16(IEEE80211_FTYPE_CTL);
  190. }
  191. /**
  192. * ieee80211_is_data - check if type is IEEE80211_FTYPE_DATA
  193. * @fc: frame control bytes in little-endian byteorder
  194. */
  195. static inline int ieee80211_is_data(__le16 fc)
  196. {
  197. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
  198. cpu_to_le16(IEEE80211_FTYPE_DATA);
  199. }
  200. /**
  201. * ieee80211_is_data_qos - check if type is IEEE80211_FTYPE_DATA and IEEE80211_STYPE_QOS_DATA is set
  202. * @fc: frame control bytes in little-endian byteorder
  203. */
  204. static inline int ieee80211_is_data_qos(__le16 fc)
  205. {
  206. /*
  207. * mask with QOS_DATA rather than IEEE80211_FCTL_STYPE as we just need
  208. * to check the one bit
  209. */
  210. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_STYPE_QOS_DATA)) ==
  211. cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_QOS_DATA);
  212. }
  213. /**
  214. * ieee80211_is_data_present - check if type is IEEE80211_FTYPE_DATA and has data
  215. * @fc: frame control bytes in little-endian byteorder
  216. */
  217. static inline int ieee80211_is_data_present(__le16 fc)
  218. {
  219. /*
  220. * mask with 0x40 and test that that bit is clear to only return true
  221. * for the data-containing substypes.
  222. */
  223. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | 0x40)) ==
  224. cpu_to_le16(IEEE80211_FTYPE_DATA);
  225. }
  226. /**
  227. * ieee80211_is_assoc_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ASSOC_REQ
  228. * @fc: frame control bytes in little-endian byteorder
  229. */
  230. static inline int ieee80211_is_assoc_req(__le16 fc)
  231. {
  232. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  233. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ASSOC_REQ);
  234. }
  235. /**
  236. * ieee80211_is_assoc_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ASSOC_RESP
  237. * @fc: frame control bytes in little-endian byteorder
  238. */
  239. static inline int ieee80211_is_assoc_resp(__le16 fc)
  240. {
  241. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  242. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ASSOC_RESP);
  243. }
  244. /**
  245. * ieee80211_is_reassoc_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_REASSOC_REQ
  246. * @fc: frame control bytes in little-endian byteorder
  247. */
  248. static inline int ieee80211_is_reassoc_req(__le16 fc)
  249. {
  250. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  251. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_REASSOC_REQ);
  252. }
  253. /**
  254. * ieee80211_is_reassoc_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_REASSOC_RESP
  255. * @fc: frame control bytes in little-endian byteorder
  256. */
  257. static inline int ieee80211_is_reassoc_resp(__le16 fc)
  258. {
  259. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  260. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_REASSOC_RESP);
  261. }
  262. /**
  263. * ieee80211_is_probe_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_PROBE_REQ
  264. * @fc: frame control bytes in little-endian byteorder
  265. */
  266. static inline int ieee80211_is_probe_req(__le16 fc)
  267. {
  268. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  269. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_REQ);
  270. }
  271. /**
  272. * ieee80211_is_probe_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_PROBE_RESP
  273. * @fc: frame control bytes in little-endian byteorder
  274. */
  275. static inline int ieee80211_is_probe_resp(__le16 fc)
  276. {
  277. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  278. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
  279. }
  280. /**
  281. * ieee80211_is_beacon - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_BEACON
  282. * @fc: frame control bytes in little-endian byteorder
  283. */
  284. static inline int ieee80211_is_beacon(__le16 fc)
  285. {
  286. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  287. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
  288. }
  289. /**
  290. * ieee80211_is_atim - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ATIM
  291. * @fc: frame control bytes in little-endian byteorder
  292. */
  293. static inline int ieee80211_is_atim(__le16 fc)
  294. {
  295. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  296. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ATIM);
  297. }
  298. /**
  299. * ieee80211_is_disassoc - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_DISASSOC
  300. * @fc: frame control bytes in little-endian byteorder
  301. */
  302. static inline int ieee80211_is_disassoc(__le16 fc)
  303. {
  304. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  305. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_DISASSOC);
  306. }
  307. /**
  308. * ieee80211_is_auth - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_AUTH
  309. * @fc: frame control bytes in little-endian byteorder
  310. */
  311. static inline int ieee80211_is_auth(__le16 fc)
  312. {
  313. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  314. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH);
  315. }
  316. /**
  317. * ieee80211_is_deauth - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_DEAUTH
  318. * @fc: frame control bytes in little-endian byteorder
  319. */
  320. static inline int ieee80211_is_deauth(__le16 fc)
  321. {
  322. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  323. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_DEAUTH);
  324. }
  325. /**
  326. * ieee80211_is_action - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ACTION
  327. * @fc: frame control bytes in little-endian byteorder
  328. */
  329. static inline int ieee80211_is_action(__le16 fc)
  330. {
  331. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  332. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ACTION);
  333. }
  334. /**
  335. * ieee80211_is_back_req - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_BACK_REQ
  336. * @fc: frame control bytes in little-endian byteorder
  337. */
  338. static inline int ieee80211_is_back_req(__le16 fc)
  339. {
  340. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  341. cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_BACK_REQ);
  342. }
  343. /**
  344. * ieee80211_is_back - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_BACK
  345. * @fc: frame control bytes in little-endian byteorder
  346. */
  347. static inline int ieee80211_is_back(__le16 fc)
  348. {
  349. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  350. cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_BACK);
  351. }
  352. /**
  353. * ieee80211_is_pspoll - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_PSPOLL
  354. * @fc: frame control bytes in little-endian byteorder
  355. */
  356. static inline int ieee80211_is_pspoll(__le16 fc)
  357. {
  358. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  359. cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL);
  360. }
  361. /**
  362. * ieee80211_is_rts - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_RTS
  363. * @fc: frame control bytes in little-endian byteorder
  364. */
  365. static inline int ieee80211_is_rts(__le16 fc)
  366. {
  367. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  368. cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS);
  369. }
  370. /**
  371. * ieee80211_is_cts - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CTS
  372. * @fc: frame control bytes in little-endian byteorder
  373. */
  374. static inline int ieee80211_is_cts(__le16 fc)
  375. {
  376. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  377. cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS);
  378. }
  379. /**
  380. * ieee80211_is_ack - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_ACK
  381. * @fc: frame control bytes in little-endian byteorder
  382. */
  383. static inline int ieee80211_is_ack(__le16 fc)
  384. {
  385. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  386. cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_ACK);
  387. }
  388. /**
  389. * ieee80211_is_cfend - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CFEND
  390. * @fc: frame control bytes in little-endian byteorder
  391. */
  392. static inline int ieee80211_is_cfend(__le16 fc)
  393. {
  394. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  395. cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CFEND);
  396. }
  397. /**
  398. * ieee80211_is_cfendack - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CFENDACK
  399. * @fc: frame control bytes in little-endian byteorder
  400. */
  401. static inline int ieee80211_is_cfendack(__le16 fc)
  402. {
  403. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  404. cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CFENDACK);
  405. }
  406. /**
  407. * ieee80211_is_nullfunc - check if FTYPE=IEEE80211_FTYPE_DATA and STYPE=IEEE80211_STYPE_NULLFUNC
  408. * @fc: frame control bytes in little-endian byteorder
  409. */
  410. static inline int ieee80211_is_nullfunc(__le16 fc)
  411. {
  412. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  413. cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC);
  414. }
  415. struct ieee80211s_hdr {
  416. u8 flags;
  417. u8 ttl;
  418. __le32 seqnum;
  419. u8 eaddr1[6];
  420. u8 eaddr2[6];
  421. u8 eaddr3[6];
  422. } __attribute__ ((packed));
  423. /**
  424. * struct ieee80211_quiet_ie
  425. *
  426. * This structure refers to "Quiet information element"
  427. */
  428. struct ieee80211_quiet_ie {
  429. u8 count;
  430. u8 period;
  431. __le16 duration;
  432. __le16 offset;
  433. } __attribute__ ((packed));
  434. /**
  435. * struct ieee80211_msrment_ie
  436. *
  437. * This structure refers to "Measurement Request/Report information element"
  438. */
  439. struct ieee80211_msrment_ie {
  440. u8 token;
  441. u8 mode;
  442. u8 type;
  443. u8 request[0];
  444. } __attribute__ ((packed));
  445. /**
  446. * struct ieee80211_channel_sw_ie
  447. *
  448. * This structure refers to "Channel Switch Announcement information element"
  449. */
  450. struct ieee80211_channel_sw_ie {
  451. u8 mode;
  452. u8 new_ch_num;
  453. u8 count;
  454. } __attribute__ ((packed));
  455. /**
  456. * struct ieee80211_tim
  457. *
  458. * This structure refers to "Traffic Indication Map information element"
  459. */
  460. struct ieee80211_tim_ie {
  461. u8 dtim_count;
  462. u8 dtim_period;
  463. u8 bitmap_ctrl;
  464. /* variable size: 1 - 251 bytes */
  465. u8 virtual_map[0];
  466. } __attribute__ ((packed));
  467. struct ieee80211_mgmt {
  468. __le16 frame_control;
  469. __le16 duration;
  470. u8 da[6];
  471. u8 sa[6];
  472. u8 bssid[6];
  473. __le16 seq_ctrl;
  474. union {
  475. struct {
  476. __le16 auth_alg;
  477. __le16 auth_transaction;
  478. __le16 status_code;
  479. /* possibly followed by Challenge text */
  480. u8 variable[0];
  481. } __attribute__ ((packed)) auth;
  482. struct {
  483. __le16 reason_code;
  484. } __attribute__ ((packed)) deauth;
  485. struct {
  486. __le16 capab_info;
  487. __le16 listen_interval;
  488. /* followed by SSID and Supported rates */
  489. u8 variable[0];
  490. } __attribute__ ((packed)) assoc_req;
  491. struct {
  492. __le16 capab_info;
  493. __le16 status_code;
  494. __le16 aid;
  495. /* followed by Supported rates */
  496. u8 variable[0];
  497. } __attribute__ ((packed)) assoc_resp, reassoc_resp;
  498. struct {
  499. __le16 capab_info;
  500. __le16 listen_interval;
  501. u8 current_ap[6];
  502. /* followed by SSID and Supported rates */
  503. u8 variable[0];
  504. } __attribute__ ((packed)) reassoc_req;
  505. struct {
  506. __le16 reason_code;
  507. } __attribute__ ((packed)) disassoc;
  508. struct {
  509. __le64 timestamp;
  510. __le16 beacon_int;
  511. __le16 capab_info;
  512. /* followed by some of SSID, Supported rates,
  513. * FH Params, DS Params, CF Params, IBSS Params, TIM */
  514. u8 variable[0];
  515. } __attribute__ ((packed)) beacon;
  516. struct {
  517. /* only variable items: SSID, Supported rates */
  518. u8 variable[0];
  519. } __attribute__ ((packed)) probe_req;
  520. struct {
  521. __le64 timestamp;
  522. __le16 beacon_int;
  523. __le16 capab_info;
  524. /* followed by some of SSID, Supported rates,
  525. * FH Params, DS Params, CF Params, IBSS Params */
  526. u8 variable[0];
  527. } __attribute__ ((packed)) probe_resp;
  528. struct {
  529. u8 category;
  530. union {
  531. struct {
  532. u8 action_code;
  533. u8 dialog_token;
  534. u8 status_code;
  535. u8 variable[0];
  536. } __attribute__ ((packed)) wme_action;
  537. struct{
  538. u8 action_code;
  539. u8 element_id;
  540. u8 length;
  541. struct ieee80211_channel_sw_ie sw_elem;
  542. } __attribute__((packed)) chan_switch;
  543. struct{
  544. u8 action_code;
  545. u8 dialog_token;
  546. u8 element_id;
  547. u8 length;
  548. struct ieee80211_msrment_ie msr_elem;
  549. } __attribute__((packed)) measurement;
  550. struct{
  551. u8 action_code;
  552. u8 dialog_token;
  553. __le16 capab;
  554. __le16 timeout;
  555. __le16 start_seq_num;
  556. } __attribute__((packed)) addba_req;
  557. struct{
  558. u8 action_code;
  559. u8 dialog_token;
  560. __le16 status;
  561. __le16 capab;
  562. __le16 timeout;
  563. } __attribute__((packed)) addba_resp;
  564. struct{
  565. u8 action_code;
  566. __le16 params;
  567. __le16 reason_code;
  568. } __attribute__((packed)) delba;
  569. struct{
  570. u8 action_code;
  571. /* capab_info for open and confirm,
  572. * reason for close
  573. */
  574. __le16 aux;
  575. /* Followed in plink_confirm by status
  576. * code, AID and supported rates,
  577. * and directly by supported rates in
  578. * plink_open and plink_close
  579. */
  580. u8 variable[0];
  581. } __attribute__((packed)) plink_action;
  582. struct{
  583. u8 action_code;
  584. u8 variable[0];
  585. } __attribute__((packed)) mesh_action;
  586. } u;
  587. } __attribute__ ((packed)) action;
  588. } u;
  589. } __attribute__ ((packed));
  590. /* Control frames */
  591. struct ieee80211_rts {
  592. __le16 frame_control;
  593. __le16 duration;
  594. u8 ra[6];
  595. u8 ta[6];
  596. } __attribute__ ((packed));
  597. struct ieee80211_cts {
  598. __le16 frame_control;
  599. __le16 duration;
  600. u8 ra[6];
  601. } __attribute__ ((packed));
  602. /**
  603. * struct ieee80211_bar - HT Block Ack Request
  604. *
  605. * This structure refers to "HT BlockAckReq" as
  606. * described in 802.11n draft section 7.2.1.7.1
  607. */
  608. struct ieee80211_bar {
  609. __le16 frame_control;
  610. __le16 duration;
  611. __u8 ra[6];
  612. __u8 ta[6];
  613. __le16 control;
  614. __le16 start_seq_num;
  615. } __attribute__((packed));
  616. /* 802.11 BAR control masks */
  617. #define IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL 0x0000
  618. #define IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA 0x0004
  619. /**
  620. * struct ieee80211_ht_cap - HT capabilities
  621. *
  622. * This structure refers to "HT capabilities element" as
  623. * described in 802.11n draft section 7.3.2.52
  624. */
  625. struct ieee80211_ht_cap {
  626. __le16 cap_info;
  627. u8 ampdu_params_info;
  628. u8 supp_mcs_set[16];
  629. __le16 extended_ht_cap_info;
  630. __le32 tx_BF_cap_info;
  631. u8 antenna_selection_info;
  632. } __attribute__ ((packed));
  633. /**
  634. * struct ieee80211_ht_cap - HT additional information
  635. *
  636. * This structure refers to "HT information element" as
  637. * described in 802.11n draft section 7.3.2.53
  638. */
  639. struct ieee80211_ht_addt_info {
  640. u8 control_chan;
  641. u8 ht_param;
  642. __le16 operation_mode;
  643. __le16 stbc_param;
  644. u8 basic_set[16];
  645. } __attribute__ ((packed));
  646. /* 802.11n HT capabilities masks */
  647. #define IEEE80211_HT_CAP_SUP_WIDTH 0x0002
  648. #define IEEE80211_HT_CAP_MIMO_PS 0x000C
  649. #define IEEE80211_HT_CAP_GRN_FLD 0x0010
  650. #define IEEE80211_HT_CAP_SGI_20 0x0020
  651. #define IEEE80211_HT_CAP_SGI_40 0x0040
  652. #define IEEE80211_HT_CAP_DELAY_BA 0x0400
  653. #define IEEE80211_HT_CAP_MAX_AMSDU 0x0800
  654. #define IEEE80211_HT_CAP_DSSSCCK40 0x1000
  655. /* 802.11n HT capability AMPDU settings */
  656. #define IEEE80211_HT_CAP_AMPDU_FACTOR 0x03
  657. #define IEEE80211_HT_CAP_AMPDU_DENSITY 0x1C
  658. /* 802.11n HT capability MSC set */
  659. #define IEEE80211_SUPP_MCS_SET_UEQM 4
  660. #define IEEE80211_HT_CAP_MAX_STREAMS 4
  661. #define IEEE80211_SUPP_MCS_SET_LEN 10
  662. /* maximum streams the spec allows */
  663. #define IEEE80211_HT_CAP_MCS_TX_DEFINED 0x01
  664. #define IEEE80211_HT_CAP_MCS_TX_RX_DIFF 0x02
  665. #define IEEE80211_HT_CAP_MCS_TX_STREAMS 0x0C
  666. #define IEEE80211_HT_CAP_MCS_TX_UEQM 0x10
  667. /* 802.11n HT IE masks */
  668. #define IEEE80211_HT_IE_CHA_SEC_OFFSET 0x03
  669. #define IEEE80211_HT_IE_CHA_SEC_NONE 0x00
  670. #define IEEE80211_HT_IE_CHA_SEC_ABOVE 0x01
  671. #define IEEE80211_HT_IE_CHA_SEC_BELOW 0x03
  672. #define IEEE80211_HT_IE_CHA_WIDTH 0x04
  673. #define IEEE80211_HT_IE_HT_PROTECTION 0x0003
  674. #define IEEE80211_HT_IE_NON_GF_STA_PRSNT 0x0004
  675. #define IEEE80211_HT_IE_NON_HT_STA_PRSNT 0x0010
  676. /* MIMO Power Save Modes */
  677. #define WLAN_HT_CAP_MIMO_PS_STATIC 0
  678. #define WLAN_HT_CAP_MIMO_PS_DYNAMIC 1
  679. #define WLAN_HT_CAP_MIMO_PS_INVALID 2
  680. #define WLAN_HT_CAP_MIMO_PS_DISABLED 3
  681. /* Authentication algorithms */
  682. #define WLAN_AUTH_OPEN 0
  683. #define WLAN_AUTH_SHARED_KEY 1
  684. #define WLAN_AUTH_FAST_BSS_TRANSITION 2
  685. #define WLAN_AUTH_LEAP 128
  686. #define WLAN_AUTH_CHALLENGE_LEN 128
  687. #define WLAN_CAPABILITY_ESS (1<<0)
  688. #define WLAN_CAPABILITY_IBSS (1<<1)
  689. #define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
  690. #define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
  691. #define WLAN_CAPABILITY_PRIVACY (1<<4)
  692. #define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
  693. #define WLAN_CAPABILITY_PBCC (1<<6)
  694. #define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
  695. /* 802.11h */
  696. #define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8)
  697. #define WLAN_CAPABILITY_QOS (1<<9)
  698. #define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10)
  699. #define WLAN_CAPABILITY_DSSS_OFDM (1<<13)
  700. /* measurement */
  701. #define IEEE80211_SPCT_MSR_RPRT_MODE_LATE (1<<0)
  702. #define IEEE80211_SPCT_MSR_RPRT_MODE_INCAPABLE (1<<1)
  703. #define IEEE80211_SPCT_MSR_RPRT_MODE_REFUSED (1<<2)
  704. #define IEEE80211_SPCT_MSR_RPRT_TYPE_BASIC 0
  705. #define IEEE80211_SPCT_MSR_RPRT_TYPE_CCA 1
  706. #define IEEE80211_SPCT_MSR_RPRT_TYPE_RPI 2
  707. /* 802.11g ERP information element */
  708. #define WLAN_ERP_NON_ERP_PRESENT (1<<0)
  709. #define WLAN_ERP_USE_PROTECTION (1<<1)
  710. #define WLAN_ERP_BARKER_PREAMBLE (1<<2)
  711. /* WLAN_ERP_BARKER_PREAMBLE values */
  712. enum {
  713. WLAN_ERP_PREAMBLE_SHORT = 0,
  714. WLAN_ERP_PREAMBLE_LONG = 1,
  715. };
  716. /* Status codes */
  717. enum ieee80211_statuscode {
  718. WLAN_STATUS_SUCCESS = 0,
  719. WLAN_STATUS_UNSPECIFIED_FAILURE = 1,
  720. WLAN_STATUS_CAPS_UNSUPPORTED = 10,
  721. WLAN_STATUS_REASSOC_NO_ASSOC = 11,
  722. WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12,
  723. WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13,
  724. WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14,
  725. WLAN_STATUS_CHALLENGE_FAIL = 15,
  726. WLAN_STATUS_AUTH_TIMEOUT = 16,
  727. WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17,
  728. WLAN_STATUS_ASSOC_DENIED_RATES = 18,
  729. /* 802.11b */
  730. WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19,
  731. WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20,
  732. WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21,
  733. /* 802.11h */
  734. WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22,
  735. WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23,
  736. WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24,
  737. /* 802.11g */
  738. WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25,
  739. WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26,
  740. /* 802.11i */
  741. WLAN_STATUS_INVALID_IE = 40,
  742. WLAN_STATUS_INVALID_GROUP_CIPHER = 41,
  743. WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42,
  744. WLAN_STATUS_INVALID_AKMP = 43,
  745. WLAN_STATUS_UNSUPP_RSN_VERSION = 44,
  746. WLAN_STATUS_INVALID_RSN_IE_CAP = 45,
  747. WLAN_STATUS_CIPHER_SUITE_REJECTED = 46,
  748. /* 802.11e */
  749. WLAN_STATUS_UNSPECIFIED_QOS = 32,
  750. WLAN_STATUS_ASSOC_DENIED_NOBANDWIDTH = 33,
  751. WLAN_STATUS_ASSOC_DENIED_LOWACK = 34,
  752. WLAN_STATUS_ASSOC_DENIED_UNSUPP_QOS = 35,
  753. WLAN_STATUS_REQUEST_DECLINED = 37,
  754. WLAN_STATUS_INVALID_QOS_PARAM = 38,
  755. WLAN_STATUS_CHANGE_TSPEC = 39,
  756. WLAN_STATUS_WAIT_TS_DELAY = 47,
  757. WLAN_STATUS_NO_DIRECT_LINK = 48,
  758. WLAN_STATUS_STA_NOT_PRESENT = 49,
  759. WLAN_STATUS_STA_NOT_QSTA = 50,
  760. };
  761. /* Reason codes */
  762. enum ieee80211_reasoncode {
  763. WLAN_REASON_UNSPECIFIED = 1,
  764. WLAN_REASON_PREV_AUTH_NOT_VALID = 2,
  765. WLAN_REASON_DEAUTH_LEAVING = 3,
  766. WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4,
  767. WLAN_REASON_DISASSOC_AP_BUSY = 5,
  768. WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6,
  769. WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7,
  770. WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8,
  771. WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9,
  772. /* 802.11h */
  773. WLAN_REASON_DISASSOC_BAD_POWER = 10,
  774. WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11,
  775. /* 802.11i */
  776. WLAN_REASON_INVALID_IE = 13,
  777. WLAN_REASON_MIC_FAILURE = 14,
  778. WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15,
  779. WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16,
  780. WLAN_REASON_IE_DIFFERENT = 17,
  781. WLAN_REASON_INVALID_GROUP_CIPHER = 18,
  782. WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19,
  783. WLAN_REASON_INVALID_AKMP = 20,
  784. WLAN_REASON_UNSUPP_RSN_VERSION = 21,
  785. WLAN_REASON_INVALID_RSN_IE_CAP = 22,
  786. WLAN_REASON_IEEE8021X_FAILED = 23,
  787. WLAN_REASON_CIPHER_SUITE_REJECTED = 24,
  788. /* 802.11e */
  789. WLAN_REASON_DISASSOC_UNSPECIFIED_QOS = 32,
  790. WLAN_REASON_DISASSOC_QAP_NO_BANDWIDTH = 33,
  791. WLAN_REASON_DISASSOC_LOW_ACK = 34,
  792. WLAN_REASON_DISASSOC_QAP_EXCEED_TXOP = 35,
  793. WLAN_REASON_QSTA_LEAVE_QBSS = 36,
  794. WLAN_REASON_QSTA_NOT_USE = 37,
  795. WLAN_REASON_QSTA_REQUIRE_SETUP = 38,
  796. WLAN_REASON_QSTA_TIMEOUT = 39,
  797. WLAN_REASON_QSTA_CIPHER_NOT_SUPP = 45,
  798. };
  799. /* Information Element IDs */
  800. enum ieee80211_eid {
  801. WLAN_EID_SSID = 0,
  802. WLAN_EID_SUPP_RATES = 1,
  803. WLAN_EID_FH_PARAMS = 2,
  804. WLAN_EID_DS_PARAMS = 3,
  805. WLAN_EID_CF_PARAMS = 4,
  806. WLAN_EID_TIM = 5,
  807. WLAN_EID_IBSS_PARAMS = 6,
  808. WLAN_EID_CHALLENGE = 16,
  809. /* 802.11d */
  810. WLAN_EID_COUNTRY = 7,
  811. WLAN_EID_HP_PARAMS = 8,
  812. WLAN_EID_HP_TABLE = 9,
  813. WLAN_EID_REQUEST = 10,
  814. /* 802.11e */
  815. WLAN_EID_QBSS_LOAD = 11,
  816. WLAN_EID_EDCA_PARAM_SET = 12,
  817. WLAN_EID_TSPEC = 13,
  818. WLAN_EID_TCLAS = 14,
  819. WLAN_EID_SCHEDULE = 15,
  820. WLAN_EID_TS_DELAY = 43,
  821. WLAN_EID_TCLAS_PROCESSING = 44,
  822. WLAN_EID_QOS_CAPA = 46,
  823. /* 802.11s
  824. *
  825. * All mesh EID numbers are pending IEEE 802.11 ANA approval.
  826. * The numbers have been incremented from those suggested in
  827. * 802.11s/D2.0 so that MESH_CONFIG does not conflict with
  828. * EXT_SUPP_RATES.
  829. */
  830. WLAN_EID_MESH_CONFIG = 51,
  831. WLAN_EID_MESH_ID = 52,
  832. WLAN_EID_PEER_LINK = 55,
  833. WLAN_EID_PREQ = 68,
  834. WLAN_EID_PREP = 69,
  835. WLAN_EID_PERR = 70,
  836. /* 802.11h */
  837. WLAN_EID_PWR_CONSTRAINT = 32,
  838. WLAN_EID_PWR_CAPABILITY = 33,
  839. WLAN_EID_TPC_REQUEST = 34,
  840. WLAN_EID_TPC_REPORT = 35,
  841. WLAN_EID_SUPPORTED_CHANNELS = 36,
  842. WLAN_EID_CHANNEL_SWITCH = 37,
  843. WLAN_EID_MEASURE_REQUEST = 38,
  844. WLAN_EID_MEASURE_REPORT = 39,
  845. WLAN_EID_QUIET = 40,
  846. WLAN_EID_IBSS_DFS = 41,
  847. /* 802.11g */
  848. WLAN_EID_ERP_INFO = 42,
  849. WLAN_EID_EXT_SUPP_RATES = 50,
  850. /* 802.11n */
  851. WLAN_EID_HT_CAPABILITY = 45,
  852. WLAN_EID_HT_EXTRA_INFO = 61,
  853. /* 802.11i */
  854. WLAN_EID_RSN = 48,
  855. WLAN_EID_WPA = 221,
  856. WLAN_EID_GENERIC = 221,
  857. WLAN_EID_VENDOR_SPECIFIC = 221,
  858. WLAN_EID_QOS_PARAMETER = 222
  859. };
  860. /* Action category code */
  861. enum ieee80211_category {
  862. WLAN_CATEGORY_SPECTRUM_MGMT = 0,
  863. WLAN_CATEGORY_QOS = 1,
  864. WLAN_CATEGORY_DLS = 2,
  865. WLAN_CATEGORY_BACK = 3,
  866. WLAN_CATEGORY_WMM = 17,
  867. };
  868. /* SPECTRUM_MGMT action code */
  869. enum ieee80211_spectrum_mgmt_actioncode {
  870. WLAN_ACTION_SPCT_MSR_REQ = 0,
  871. WLAN_ACTION_SPCT_MSR_RPRT = 1,
  872. WLAN_ACTION_SPCT_TPC_REQ = 2,
  873. WLAN_ACTION_SPCT_TPC_RPRT = 3,
  874. WLAN_ACTION_SPCT_CHL_SWITCH = 4,
  875. };
  876. /* BACK action code */
  877. enum ieee80211_back_actioncode {
  878. WLAN_ACTION_ADDBA_REQ = 0,
  879. WLAN_ACTION_ADDBA_RESP = 1,
  880. WLAN_ACTION_DELBA = 2,
  881. };
  882. /* BACK (block-ack) parties */
  883. enum ieee80211_back_parties {
  884. WLAN_BACK_RECIPIENT = 0,
  885. WLAN_BACK_INITIATOR = 1,
  886. WLAN_BACK_TIMER = 2,
  887. };
  888. /* A-MSDU 802.11n */
  889. #define IEEE80211_QOS_CONTROL_A_MSDU_PRESENT 0x0080
  890. /* cipher suite selectors */
  891. #define WLAN_CIPHER_SUITE_USE_GROUP 0x000FAC00
  892. #define WLAN_CIPHER_SUITE_WEP40 0x000FAC01
  893. #define WLAN_CIPHER_SUITE_TKIP 0x000FAC02
  894. /* reserved: 0x000FAC03 */
  895. #define WLAN_CIPHER_SUITE_CCMP 0x000FAC04
  896. #define WLAN_CIPHER_SUITE_WEP104 0x000FAC05
  897. #define WLAN_MAX_KEY_LEN 32
  898. /**
  899. * ieee80211_get_qos_ctl - get pointer to qos control bytes
  900. * @hdr: the frame
  901. *
  902. * The qos ctrl bytes come after the frame_control, duration, seq_num
  903. * and 3 or 4 addresses of length ETH_ALEN.
  904. * 3 addr: 2 + 2 + 2 + 3*6 = 24
  905. * 4 addr: 2 + 2 + 2 + 4*6 = 30
  906. */
  907. static inline u8 *ieee80211_get_qos_ctl(struct ieee80211_hdr *hdr)
  908. {
  909. if (ieee80211_has_a4(hdr->frame_control))
  910. return (u8 *)hdr + 30;
  911. else
  912. return (u8 *)hdr + 24;
  913. }
  914. /**
  915. * ieee80211_get_SA - get pointer to SA
  916. * @hdr: the frame
  917. *
  918. * Given an 802.11 frame, this function returns the offset
  919. * to the source address (SA). It does not verify that the
  920. * header is long enough to contain the address, and the
  921. * header must be long enough to contain the frame control
  922. * field.
  923. */
  924. static inline u8 *ieee80211_get_SA(struct ieee80211_hdr *hdr)
  925. {
  926. if (ieee80211_has_a4(hdr->frame_control))
  927. return hdr->addr4;
  928. if (ieee80211_has_fromds(hdr->frame_control))
  929. return hdr->addr3;
  930. return hdr->addr2;
  931. }
  932. /**
  933. * ieee80211_get_DA - get pointer to DA
  934. * @hdr: the frame
  935. *
  936. * Given an 802.11 frame, this function returns the offset
  937. * to the destination address (DA). It does not verify that
  938. * the header is long enough to contain the address, and the
  939. * header must be long enough to contain the frame control
  940. * field.
  941. */
  942. static inline u8 *ieee80211_get_DA(struct ieee80211_hdr *hdr)
  943. {
  944. if (ieee80211_has_tods(hdr->frame_control))
  945. return hdr->addr3;
  946. else
  947. return hdr->addr1;
  948. }
  949. #endif /* IEEE80211_H */