ieee80211.h 29 KB

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