ieee80211.h 32 KB

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