p80211mgmt.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  1. /* p80211mgmt.h
  2. *
  3. * Macros, types, and functions to handle 802.11 mgmt frames
  4. *
  5. * Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
  6. * --------------------------------------------------------------------
  7. *
  8. * linux-wlan
  9. *
  10. * The contents of this file are subject to the Mozilla Public
  11. * License Version 1.1 (the "License"); you may not use this file
  12. * except in compliance with the License. You may obtain a copy of
  13. * the License at http://www.mozilla.org/MPL/
  14. *
  15. * Software distributed under the License is distributed on an "AS
  16. * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  17. * implied. See the License for the specific language governing
  18. * rights and limitations under the License.
  19. *
  20. * Alternatively, the contents of this file may be used under the
  21. * terms of the GNU Public License version 2 (the "GPL"), in which
  22. * case the provisions of the GPL are applicable instead of the
  23. * above. If you wish to allow the use of your version of this file
  24. * only under the terms of the GPL and not to allow others to use
  25. * your version of this file under the MPL, indicate your decision
  26. * by deleting the provisions above and replace them with the notice
  27. * and other provisions required by the GPL. If you do not delete
  28. * the provisions above, a recipient may use your version of this
  29. * file under either the MPL or the GPL.
  30. *
  31. * --------------------------------------------------------------------
  32. *
  33. * Inquiries regarding the linux-wlan Open Source project can be
  34. * made directly to:
  35. *
  36. * AbsoluteValue Systems Inc.
  37. * info@linux-wlan.com
  38. * http://www.linux-wlan.com
  39. *
  40. * --------------------------------------------------------------------
  41. *
  42. * Portions of the development of this software were funded by
  43. * Intersil Corporation as part of PRISM(R) chipset product development.
  44. *
  45. * --------------------------------------------------------------------
  46. *
  47. * This file declares the constants and types used in the interface
  48. * between a wlan driver and the user mode utilities.
  49. *
  50. * Notes:
  51. * - Constant values are always in HOST byte order. To assign
  52. * values to multi-byte fields they _must_ be converted to
  53. * ieee byte order. To retrieve multi-byte values from incoming
  54. * frames, they must be converted to host order.
  55. *
  56. * - The len member of the frame structure does NOT!!! include
  57. * the MAC CRC. Therefore, the len field on rx'd frames should
  58. * have 4 subtracted from it.
  59. *
  60. * All functions declared here are implemented in p80211.c
  61. *
  62. * The types, macros, and functions defined here are primarily
  63. * used for encoding and decoding management frames. They are
  64. * designed to follow these patterns of use:
  65. *
  66. * DECODE:
  67. * 1) a frame of length len is received into buffer b
  68. * 2) using the hdr structure and macros, we determine the type
  69. * 3) an appropriate mgmt frame structure, mf, is allocated and zeroed
  70. * 4) mf.hdr = b
  71. * mf.buf = b
  72. * mf.len = len
  73. * 5) call mgmt_decode( mf )
  74. * 6) the frame field pointers in mf are now set. Note that any
  75. * multi-byte frame field values accessed using the frame field
  76. * pointers are in ieee byte order and will have to be converted
  77. * to host order.
  78. *
  79. * ENCODE:
  80. * 1) Library client allocates buffer space for maximum length
  81. * frame of the desired type
  82. * 2) Library client allocates a mgmt frame structure, called mf,
  83. * of the desired type
  84. * 3) Set the following:
  85. * mf.type = <desired type>
  86. * mf.buf = <allocated buffer address>
  87. * 4) call mgmt_encode( mf )
  88. * 5) all of the fixed field pointers and fixed length information element
  89. * pointers in mf are now set to their respective locations in the
  90. * allocated space (fortunately, all variable length information elements
  91. * fall at the end of their respective frames).
  92. * 5a) The length field is set to include the last of the fixed and fixed
  93. * length fields. It may have to be updated for optional or variable
  94. * length information elements.
  95. * 6) Optional and variable length information elements are special cases
  96. * and must be handled individually by the client code.
  97. * --------------------------------------------------------------------
  98. */
  99. #ifndef _P80211MGMT_H
  100. #define _P80211MGMT_H
  101. #ifndef _P80211HDR_H
  102. #include "p80211hdr.h"
  103. #endif
  104. /*-- Information Element IDs --------------------*/
  105. #define WLAN_EID_SSID 0
  106. #define WLAN_EID_SUPP_RATES 1
  107. #define WLAN_EID_FH_PARMS 2
  108. #define WLAN_EID_DS_PARMS 3
  109. #define WLAN_EID_CF_PARMS 4
  110. #define WLAN_EID_TIM 5
  111. #define WLAN_EID_IBSS_PARMS 6
  112. /*-- values 7-15 reserved --*/
  113. #define WLAN_EID_CHALLENGE 16
  114. /*-- values 17-31 reserved for challenge text extension --*/
  115. /*-- values 32-255 reserved --*/
  116. /*-- Reason Codes -------------------------------*/
  117. #define WLAN_MGMT_REASON_RSVD 0
  118. #define WLAN_MGMT_REASON_UNSPEC 1
  119. #define WLAN_MGMT_REASON_PRIOR_AUTH_INVALID 2
  120. #define WLAN_MGMT_REASON_DEAUTH_LEAVING 3
  121. #define WLAN_MGMT_REASON_DISASSOC_INACTIVE 4
  122. #define WLAN_MGMT_REASON_DISASSOC_AP_BUSY 5
  123. #define WLAN_MGMT_REASON_CLASS2_NONAUTH 6
  124. #define WLAN_MGMT_REASON_CLASS3_NONASSOC 7
  125. #define WLAN_MGMT_REASON_DISASSOC_STA_HASLEFT 8
  126. #define WLAN_MGMT_REASON_CANT_ASSOC_NONAUTH 9
  127. /*-- Status Codes -------------------------------*/
  128. #define WLAN_MGMT_STATUS_SUCCESS 0
  129. #define WLAN_MGMT_STATUS_UNSPEC_FAILURE 1
  130. #define WLAN_MGMT_STATUS_CAPS_UNSUPPORTED 10
  131. #define WLAN_MGMT_STATUS_REASSOC_NO_ASSOC 11
  132. #define WLAN_MGMT_STATUS_ASSOC_DENIED_UNSPEC 12
  133. #define WLAN_MGMT_STATUS_UNSUPPORTED_AUTHALG 13
  134. #define WLAN_MGMT_STATUS_RX_AUTH_NOSEQ 14
  135. #define WLAN_MGMT_STATUS_CHALLENGE_FAIL 15
  136. #define WLAN_MGMT_STATUS_AUTH_TIMEOUT 16
  137. #define WLAN_MGMT_STATUS_ASSOC_DENIED_BUSY 17
  138. #define WLAN_MGMT_STATUS_ASSOC_DENIED_RATES 18
  139. /* p80211b additions */
  140. #define WLAN_MGMT_STATUS_ASSOC_DENIED_NOSHORT 19
  141. #define WLAN_MGMT_STATUS_ASSOC_DENIED_NOPBCC 20
  142. #define WLAN_MGMT_STATUS_ASSOC_DENIED_NOAGILITY 21
  143. /*-- Auth Algorithm Field ---------------------------*/
  144. #define WLAN_AUTH_ALG_OPENSYSTEM 0
  145. #define WLAN_AUTH_ALG_SHAREDKEY 1
  146. /*-- Management Frame Field Offsets -------------*/
  147. /* Note: Not all fields are listed because of variable lengths, */
  148. /* see the code in p80211.c to see how we search for fields */
  149. /* Note: These offsets are from the start of the frame data */
  150. #define WLAN_BEACON_OFF_TS 0
  151. #define WLAN_BEACON_OFF_BCN_int 8
  152. #define WLAN_BEACON_OFF_CAPINFO 10
  153. #define WLAN_BEACON_OFF_SSID 12
  154. #define WLAN_DISASSOC_OFF_REASON 0
  155. #define WLAN_ASSOCREQ_OFF_CAP_INFO 0
  156. #define WLAN_ASSOCREQ_OFF_LISTEN_int 2
  157. #define WLAN_ASSOCREQ_OFF_SSID 4
  158. #define WLAN_ASSOCRESP_OFF_CAP_INFO 0
  159. #define WLAN_ASSOCRESP_OFF_STATUS 2
  160. #define WLAN_ASSOCRESP_OFF_AID 4
  161. #define WLAN_ASSOCRESP_OFF_SUPP_RATES 6
  162. #define WLAN_REASSOCREQ_OFF_CAP_INFO 0
  163. #define WLAN_REASSOCREQ_OFF_LISTEN_int 2
  164. #define WLAN_REASSOCREQ_OFF_CURR_AP 4
  165. #define WLAN_REASSOCREQ_OFF_SSID 10
  166. #define WLAN_REASSOCRESP_OFF_CAP_INFO 0
  167. #define WLAN_REASSOCRESP_OFF_STATUS 2
  168. #define WLAN_REASSOCRESP_OFF_AID 4
  169. #define WLAN_REASSOCRESP_OFF_SUPP_RATES 6
  170. #define WLAN_PROBEREQ_OFF_SSID 0
  171. #define WLAN_PROBERESP_OFF_TS 0
  172. #define WLAN_PROBERESP_OFF_BCN_int 8
  173. #define WLAN_PROBERESP_OFF_CAP_INFO 10
  174. #define WLAN_PROBERESP_OFF_SSID 12
  175. #define WLAN_AUTHEN_OFF_AUTH_ALG 0
  176. #define WLAN_AUTHEN_OFF_AUTH_SEQ 2
  177. #define WLAN_AUTHEN_OFF_STATUS 4
  178. #define WLAN_AUTHEN_OFF_CHALLENGE 6
  179. #define WLAN_DEAUTHEN_OFF_REASON 0
  180. /*-- Capability Field ---------------------------*/
  181. #define WLAN_GET_MGMT_CAP_INFO_ESS(n) ((n) & BIT(0))
  182. #define WLAN_GET_MGMT_CAP_INFO_IBSS(n) (((n) & BIT(1)) >> 1)
  183. #define WLAN_GET_MGMT_CAP_INFO_CFPOLLABLE(n) (((n) & BIT(2)) >> 2)
  184. #define WLAN_GET_MGMT_CAP_INFO_CFPOLLREQ(n) (((n) & BIT(3)) >> 3)
  185. #define WLAN_GET_MGMT_CAP_INFO_PRIVACY(n) (((n) & BIT(4)) >> 4)
  186. /* p80211b additions */
  187. #define WLAN_GET_MGMT_CAP_INFO_SHORT(n) (((n) & BIT(5)) >> 5)
  188. #define WLAN_GET_MGMT_CAP_INFO_PBCC(n) (((n) & BIT(6)) >> 6)
  189. #define WLAN_GET_MGMT_CAP_INFO_AGILITY(n) (((n) & BIT(7)) >> 7)
  190. #define WLAN_SET_MGMT_CAP_INFO_ESS(n) (n)
  191. #define WLAN_SET_MGMT_CAP_INFO_IBSS(n) ((n) << 1)
  192. #define WLAN_SET_MGMT_CAP_INFO_CFPOLLABLE(n) ((n) << 2)
  193. #define WLAN_SET_MGMT_CAP_INFO_CFPOLLREQ(n) ((n) << 3)
  194. #define WLAN_SET_MGMT_CAP_INFO_PRIVACY(n) ((n) << 4)
  195. /* p80211b additions */
  196. #define WLAN_SET_MGMT_CAP_INFO_SHORT(n) ((n) << 5)
  197. #define WLAN_SET_MGMT_CAP_INFO_PBCC(n) ((n) << 6)
  198. #define WLAN_SET_MGMT_CAP_INFO_AGILITY(n) ((n) << 7)
  199. /*-- Information Element Types --------------------*/
  200. /* prototype structure, all IEs start with these members */
  201. struct wlan_ie {
  202. u8 eid;
  203. u8 len;
  204. } __packed;
  205. /*-- Service Set Identity (SSID) -----------------*/
  206. struct wlan_ie_ssid {
  207. u8 eid;
  208. u8 len;
  209. u8 ssid[1]; /* may be zero, ptrs may overlap */
  210. } __packed;
  211. /*-- Supported Rates -----------------------------*/
  212. struct wlan_ie_supp_rates {
  213. u8 eid;
  214. u8 len;
  215. u8 rates[1]; /* had better be at LEAST one! */
  216. } __packed;
  217. /*-- FH Parameter Set ----------------------------*/
  218. struct wlan_ie_fh_parms {
  219. u8 eid;
  220. u8 len;
  221. u16 dwell;
  222. u8 hopset;
  223. u8 hoppattern;
  224. u8 hopindex;
  225. } __packed;
  226. /*-- DS Parameter Set ----------------------------*/
  227. struct wlan_ie_ds_parms {
  228. u8 eid;
  229. u8 len;
  230. u8 curr_ch;
  231. } __packed;
  232. /*-- CF Parameter Set ----------------------------*/
  233. struct wlan_ie_cf_parms {
  234. u8 eid;
  235. u8 len;
  236. u8 cfp_cnt;
  237. u8 cfp_period;
  238. u16 cfp_maxdur;
  239. u16 cfp_durremaining;
  240. } __packed;
  241. /*-- TIM ------------------------------------------*/
  242. struct wlan_ie_tim {
  243. u8 eid;
  244. u8 len;
  245. u8 dtim_cnt;
  246. u8 dtim_period;
  247. u8 bitmap_ctl;
  248. u8 virt_bm[1];
  249. } __packed;
  250. /*-- IBSS Parameter Set ---------------------------*/
  251. struct wlan_ie_ibss_parms {
  252. u8 eid;
  253. u8 len;
  254. u16 atim_win;
  255. } __packed;
  256. /*-- Challenge Text ------------------------------*/
  257. struct wlan_ie_challenge {
  258. u8 eid;
  259. u8 len;
  260. u8 challenge[1];
  261. } __packed;
  262. /*-------------------------------------------------*/
  263. /* Frame Types */
  264. /* prototype structure, all mgmt frame types will start with these members */
  265. struct wlan_fr_mgmt {
  266. u16 type;
  267. u16 len; /* DOES NOT include CRC !!!! */
  268. u8 *buf;
  269. union p80211_hdr *hdr;
  270. /* used for target specific data, skb in Linux */
  271. void *priv;
  272. /*-- fixed fields -----------*/
  273. /*-- info elements ----------*/
  274. };
  275. /*-- Beacon ---------------------------------------*/
  276. struct wlan_fr_beacon {
  277. u16 type;
  278. u16 len;
  279. u8 *buf;
  280. union p80211_hdr *hdr;
  281. /* used for target specific data, skb in Linux */
  282. void *priv;
  283. /*-- fixed fields -----------*/
  284. u64 *ts;
  285. u16 *bcn_int;
  286. u16 *cap_info;
  287. /*-- info elements ----------*/
  288. struct wlan_ie_ssid *ssid;
  289. struct wlan_ie_supp_rates *supp_rates;
  290. struct wlan_ie_fh_parms *fh_parms;
  291. struct wlan_ie_ds_parms *ds_parms;
  292. struct wlan_ie_cf_parms *cf_parms;
  293. struct wlan_ie_ibss_parms *ibss_parms;
  294. struct wlan_ie_tim *tim;
  295. };
  296. /*-- IBSS ATIM ------------------------------------*/
  297. struct wlan_fr_ibssatim {
  298. u16 type;
  299. u16 len;
  300. u8 *buf;
  301. union p80211_hdr *hdr;
  302. /* used for target specific data, skb in Linux */
  303. void *priv;
  304. /*-- fixed fields -----------*/
  305. /*-- info elements ----------*/
  306. /* this frame type has a null body */
  307. };
  308. /*-- Disassociation -------------------------------*/
  309. struct wlan_fr_disassoc {
  310. u16 type;
  311. u16 len;
  312. u8 *buf;
  313. union p80211_hdr *hdr;
  314. /* used for target specific data, skb in Linux */
  315. void *priv;
  316. /*-- fixed fields -----------*/
  317. u16 *reason;
  318. /*-- info elements ----------*/
  319. };
  320. /*-- Association Request --------------------------*/
  321. struct wlan_fr_assocreq {
  322. u16 type;
  323. u16 len;
  324. u8 *buf;
  325. union p80211_hdr *hdr;
  326. /* used for target specific data, skb in Linux */
  327. void *priv;
  328. /*-- fixed fields -----------*/
  329. u16 *cap_info;
  330. u16 *listen_int;
  331. /*-- info elements ----------*/
  332. struct wlan_ie_ssid *ssid;
  333. struct wlan_ie_supp_rates *supp_rates;
  334. };
  335. /*-- Association Response -------------------------*/
  336. struct wlan_fr_assocresp {
  337. u16 type;
  338. u16 len;
  339. u8 *buf;
  340. union p80211_hdr *hdr;
  341. /* used for target specific data, skb in Linux */
  342. void *priv;
  343. /*-- fixed fields -----------*/
  344. u16 *cap_info;
  345. u16 *status;
  346. u16 *aid;
  347. /*-- info elements ----------*/
  348. struct wlan_ie_supp_rates *supp_rates;
  349. };
  350. /*-- Reassociation Request ------------------------*/
  351. struct wlan_fr_reassocreq {
  352. u16 type;
  353. u16 len;
  354. u8 *buf;
  355. union p80211_hdr *hdr;
  356. /* used for target specific data, skb in Linux */
  357. void *priv;
  358. /*-- fixed fields -----------*/
  359. u16 *cap_info;
  360. u16 *listen_int;
  361. u8 *curr_ap;
  362. /*-- info elements ----------*/
  363. struct wlan_ie_ssid *ssid;
  364. struct wlan_ie_supp_rates *supp_rates;
  365. };
  366. /*-- Reassociation Response -----------------------*/
  367. struct wlan_fr_reassocresp {
  368. u16 type;
  369. u16 len;
  370. u8 *buf;
  371. union p80211_hdr *hdr;
  372. /* used for target specific data, skb in Linux */
  373. void *priv;
  374. /*-- fixed fields -----------*/
  375. u16 *cap_info;
  376. u16 *status;
  377. u16 *aid;
  378. /*-- info elements ----------*/
  379. struct wlan_ie_supp_rates *supp_rates;
  380. };
  381. /*-- Probe Request --------------------------------*/
  382. struct wlan_fr_probereq {
  383. u16 type;
  384. u16 len;
  385. u8 *buf;
  386. union p80211_hdr *hdr;
  387. /* used for target specific data, skb in Linux */
  388. void *priv;
  389. /*-- fixed fields -----------*/
  390. /*-- info elements ----------*/
  391. struct wlan_ie_ssid *ssid;
  392. struct wlan_ie_supp_rates *supp_rates;
  393. };
  394. /*-- Probe Response -------------------------------*/
  395. struct wlan_fr_proberesp {
  396. u16 type;
  397. u16 len;
  398. u8 *buf;
  399. union p80211_hdr *hdr;
  400. /* used for target specific data, skb in Linux */
  401. void *priv;
  402. /*-- fixed fields -----------*/
  403. u64 *ts;
  404. u16 *bcn_int;
  405. u16 *cap_info;
  406. /*-- info elements ----------*/
  407. struct wlan_ie_ssid *ssid;
  408. struct wlan_ie_supp_rates *supp_rates;
  409. struct wlan_ie_fh_parms *fh_parms;
  410. struct wlan_ie_ds_parms *ds_parms;
  411. struct wlan_ie_cf_parms *cf_parms;
  412. struct wlan_ie_ibss_parms *ibss_parms;
  413. };
  414. /*-- Authentication -------------------------------*/
  415. struct wlan_fr_authen {
  416. u16 type;
  417. u16 len;
  418. u8 *buf;
  419. union p80211_hdr *hdr;
  420. /* used for target specific data, skb in Linux */
  421. void *priv;
  422. /*-- fixed fields -----------*/
  423. u16 *auth_alg;
  424. u16 *auth_seq;
  425. u16 *status;
  426. /*-- info elements ----------*/
  427. struct wlan_ie_challenge *challenge;
  428. };
  429. /*-- Deauthenication -----------------------------*/
  430. struct wlan_fr_deauthen {
  431. u16 type;
  432. u16 len;
  433. u8 *buf;
  434. union p80211_hdr *hdr;
  435. /* used for target specific data, skb in Linux */
  436. void *priv;
  437. /*-- fixed fields -----------*/
  438. u16 *reason;
  439. /*-- info elements ----------*/
  440. };
  441. void wlan_mgmt_encode_beacon(struct wlan_fr_beacon *f);
  442. void wlan_mgmt_decode_beacon(struct wlan_fr_beacon *f);
  443. void wlan_mgmt_encode_disassoc(struct wlan_fr_disassoc *f);
  444. void wlan_mgmt_decode_disassoc(struct wlan_fr_disassoc *f);
  445. void wlan_mgmt_encode_assocreq(struct wlan_fr_assocreq *f);
  446. void wlan_mgmt_decode_assocreq(struct wlan_fr_assocreq *f);
  447. void wlan_mgmt_encode_assocresp(struct wlan_fr_assocresp *f);
  448. void wlan_mgmt_decode_assocresp(struct wlan_fr_assocresp *f);
  449. void wlan_mgmt_encode_reassocreq(struct wlan_fr_reassocreq *f);
  450. void wlan_mgmt_decode_reassocreq(struct wlan_fr_reassocreq *f);
  451. void wlan_mgmt_encode_reassocresp(struct wlan_fr_reassocresp *f);
  452. void wlan_mgmt_decode_reassocresp(struct wlan_fr_reassocresp *f);
  453. void wlan_mgmt_encode_probereq(struct wlan_fr_probereq *f);
  454. void wlan_mgmt_decode_probereq(struct wlan_fr_probereq *f);
  455. void wlan_mgmt_encode_proberesp(struct wlan_fr_proberesp *f);
  456. void wlan_mgmt_decode_proberesp(struct wlan_fr_proberesp *f);
  457. void wlan_mgmt_encode_authen(struct wlan_fr_authen *f);
  458. void wlan_mgmt_decode_authen(struct wlan_fr_authen *f);
  459. void wlan_mgmt_encode_deauthen(struct wlan_fr_deauthen *f);
  460. void wlan_mgmt_decode_deauthen(struct wlan_fr_deauthen *f);
  461. #endif /* _P80211MGMT_H */