ieee80211.h 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970
  1. /* $OpenBSD: ieee80211.h,v 1.52 2015/07/14 21:13:12 stsp Exp $ */
  2. /* $NetBSD: ieee80211.h,v 1.6 2004/04/30 23:51:53 dyoung Exp $ */
  3. /*-
  4. * Copyright (c) 2001 Atsushi Onoe
  5. * Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting
  6. * All rights reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. * 1. Redistributions of source code must retain the above copyright
  12. * notice, this list of conditions and the following disclaimer.
  13. * 2. Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in the
  15. * documentation and/or other materials provided with the distribution.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  18. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  19. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  20. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  21. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  22. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  23. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  24. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  26. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. */
  28. #ifndef _NET80211_IEEE80211_H_
  29. #define _NET80211_IEEE80211_H_
  30. /*
  31. * 802.11 protocol definitions.
  32. */
  33. #define IEEE80211_ADDR_LEN 6 /* size of 802.11 address */
  34. /* is 802.11 address multicast/broadcast? */
  35. #define IEEE80211_IS_MULTICAST(_a) (*(_a) & 0x01)
  36. /*
  37. * Generic definitions for IEEE 802.11 frames.
  38. */
  39. struct ieee80211_frame {
  40. u_int8_t i_fc[2];
  41. u_int8_t i_dur[2];
  42. u_int8_t i_addr1[IEEE80211_ADDR_LEN];
  43. u_int8_t i_addr2[IEEE80211_ADDR_LEN];
  44. u_int8_t i_addr3[IEEE80211_ADDR_LEN];
  45. u_int8_t i_seq[2];
  46. } __packed;
  47. struct ieee80211_qosframe {
  48. u_int8_t i_fc[2];
  49. u_int8_t i_dur[2];
  50. u_int8_t i_addr1[IEEE80211_ADDR_LEN];
  51. u_int8_t i_addr2[IEEE80211_ADDR_LEN];
  52. u_int8_t i_addr3[IEEE80211_ADDR_LEN];
  53. u_int8_t i_seq[2];
  54. u_int8_t i_qos[2];
  55. } __packed;
  56. struct ieee80211_htframe { /* 11n */
  57. u_int8_t i_fc[2];
  58. u_int8_t i_dur[2];
  59. u_int8_t i_addr1[IEEE80211_ADDR_LEN];
  60. u_int8_t i_addr2[IEEE80211_ADDR_LEN];
  61. u_int8_t i_addr3[IEEE80211_ADDR_LEN];
  62. u_int8_t i_seq[2];
  63. u_int8_t i_qos[2];
  64. u_int8_t i_ht[4];
  65. } __packed;
  66. struct ieee80211_frame_addr4 {
  67. u_int8_t i_fc[2];
  68. u_int8_t i_dur[2];
  69. u_int8_t i_addr1[IEEE80211_ADDR_LEN];
  70. u_int8_t i_addr2[IEEE80211_ADDR_LEN];
  71. u_int8_t i_addr3[IEEE80211_ADDR_LEN];
  72. u_int8_t i_seq[2];
  73. u_int8_t i_addr4[IEEE80211_ADDR_LEN];
  74. } __packed;
  75. struct ieee80211_qosframe_addr4 {
  76. u_int8_t i_fc[2];
  77. u_int8_t i_dur[2];
  78. u_int8_t i_addr1[IEEE80211_ADDR_LEN];
  79. u_int8_t i_addr2[IEEE80211_ADDR_LEN];
  80. u_int8_t i_addr3[IEEE80211_ADDR_LEN];
  81. u_int8_t i_seq[2];
  82. u_int8_t i_addr4[IEEE80211_ADDR_LEN];
  83. u_int8_t i_qos[2];
  84. } __packed;
  85. struct ieee80211_htframe_addr4 { /* 11n */
  86. u_int8_t i_fc[2];
  87. u_int8_t i_dur[2];
  88. u_int8_t i_addr1[IEEE80211_ADDR_LEN];
  89. u_int8_t i_addr2[IEEE80211_ADDR_LEN];
  90. u_int8_t i_addr3[IEEE80211_ADDR_LEN];
  91. u_int8_t i_seq[2];
  92. u_int8_t i_addr4[IEEE80211_ADDR_LEN];
  93. u_int8_t i_qos[2];
  94. u_int8_t i_ht[4];
  95. } __packed;
  96. #define IEEE80211_FC0_VERSION_MASK 0x03
  97. #define IEEE80211_FC0_VERSION_SHIFT 0
  98. #define IEEE80211_FC0_VERSION_0 0x00
  99. #define IEEE80211_FC0_TYPE_MASK 0x0c
  100. #define IEEE80211_FC0_TYPE_SHIFT 2
  101. #define IEEE80211_FC0_TYPE_MGT 0x00
  102. #define IEEE80211_FC0_TYPE_CTL 0x04
  103. #define IEEE80211_FC0_TYPE_DATA 0x08
  104. #define IEEE80211_FC0_SUBTYPE_MASK 0xf0
  105. #define IEEE80211_FC0_SUBTYPE_SHIFT 4
  106. /* for TYPE_MGT */
  107. #define IEEE80211_FC0_SUBTYPE_ASSOC_REQ 0x00
  108. #define IEEE80211_FC0_SUBTYPE_ASSOC_RESP 0x10
  109. #define IEEE80211_FC0_SUBTYPE_REASSOC_REQ 0x20
  110. #define IEEE80211_FC0_SUBTYPE_REASSOC_RESP 0x30
  111. #define IEEE80211_FC0_SUBTYPE_PROBE_REQ 0x40
  112. #define IEEE80211_FC0_SUBTYPE_PROBE_RESP 0x50
  113. #define IEEE80211_FC0_SUBTYPE_BEACON 0x80
  114. #define IEEE80211_FC0_SUBTYPE_ATIM 0x90
  115. #define IEEE80211_FC0_SUBTYPE_DISASSOC 0xa0
  116. #define IEEE80211_FC0_SUBTYPE_AUTH 0xb0
  117. #define IEEE80211_FC0_SUBTYPE_DEAUTH 0xc0
  118. #define IEEE80211_FC0_SUBTYPE_ACTION 0xd0
  119. #define IEEE80211_FC0_SUBTYPE_ACTION_NOACK 0xe0 /* 11n */
  120. /* for TYPE_CTL */
  121. #define IEEE80211_FC0_SUBTYPE_WRAPPER 0x70 /* 11n */
  122. #define IEEE80211_FC0_SUBTYPE_BAR 0x80
  123. #define IEEE80211_FC0_SUBTYPE_BA 0x90
  124. #define IEEE80211_FC0_SUBTYPE_PS_POLL 0xa0
  125. #define IEEE80211_FC0_SUBTYPE_RTS 0xb0
  126. #define IEEE80211_FC0_SUBTYPE_CTS 0xc0
  127. #define IEEE80211_FC0_SUBTYPE_ACK 0xd0
  128. #define IEEE80211_FC0_SUBTYPE_CF_END 0xe0
  129. #define IEEE80211_FC0_SUBTYPE_CF_END_ACK 0xf0
  130. /* for TYPE_DATA (bit combination) */
  131. #define IEEE80211_FC0_SUBTYPE_DATA 0x00
  132. #define IEEE80211_FC0_SUBTYPE_CF_ACK 0x10
  133. #define IEEE80211_FC0_SUBTYPE_CF_POLL 0x20
  134. #define IEEE80211_FC0_SUBTYPE_CF_ACPL 0x30
  135. #define IEEE80211_FC0_SUBTYPE_NODATA 0x40
  136. #define IEEE80211_FC0_SUBTYPE_CFACK 0x50
  137. #define IEEE80211_FC0_SUBTYPE_CFPOLL 0x60
  138. #define IEEE80211_FC0_SUBTYPE_CF_ACK_CF_ACK 0x70
  139. #define IEEE80211_FC0_SUBTYPE_QOS 0x80
  140. #define IEEE80211_FC1_DIR_MASK 0x03
  141. #define IEEE80211_FC1_DIR_NODS 0x00 /* STA->STA */
  142. #define IEEE80211_FC1_DIR_TODS 0x01 /* STA->AP */
  143. #define IEEE80211_FC1_DIR_FROMDS 0x02 /* AP ->STA */
  144. #define IEEE80211_FC1_DIR_DSTODS 0x03 /* AP ->AP */
  145. #define IEEE80211_FC1_MORE_FRAG 0x04
  146. #define IEEE80211_FC1_RETRY 0x08
  147. #define IEEE80211_FC1_PWR_MGT 0x10
  148. #define IEEE80211_FC1_MORE_DATA 0x20
  149. #define IEEE80211_FC1_PROTECTED 0x40
  150. #define IEEE80211_FC1_WEP 0x40 /* pre-RSNA compat */
  151. #define IEEE80211_FC1_ORDER 0x80
  152. #define IEEE80211_FC1_BITS \
  153. "\20\03MORE_FRAG\04RETRY\05PWR_MGT\06MORE_DATA" \
  154. "\07PROTECTED\08ORDER"
  155. /*
  156. * Sequence Control field (see 802.11-2012 8.2.4.4).
  157. */
  158. #define IEEE80211_SEQ_FRAG_MASK 0x000f
  159. #define IEEE80211_SEQ_FRAG_SHIFT 0
  160. #define IEEE80211_SEQ_SEQ_MASK 0xfff0
  161. #define IEEE80211_SEQ_SEQ_SHIFT 4
  162. #define IEEE80211_NWID_LEN 32
  163. #define IEEE80211_MMIE_LEN 18 /* 11w */
  164. /*
  165. * QoS Control field (see 802.11-2012 8.2.4.5).
  166. */
  167. #define IEEE80211_QOS_TXOP 0xff00
  168. #define IEEE80211_QOS_AMSDU 0x0080 /* 11n */
  169. #define IEEE80211_QOS_ACK_POLICY_NORMAL 0x0000
  170. #define IEEE80211_QOS_ACK_POLICY_NOACK 0x0020
  171. #define IEEE80211_QOS_ACK_POLICY_NOEXPLACK 0x0040
  172. #define IEEE80211_QOS_ACK_POLICY_BA 0x0060
  173. #define IEEE80211_QOS_ACK_POLICY_MASK 0x0060
  174. #define IEEE80211_QOS_ACK_POLICY_SHIFT 5
  175. #define IEEE80211_QOS_EOSP 0x0010
  176. #define IEEE80211_QOS_TID 0x000f
  177. /*
  178. * Control frames.
  179. */
  180. struct ieee80211_frame_min {
  181. u_int8_t i_fc[2];
  182. u_int8_t i_dur[2];
  183. u_int8_t i_addr1[IEEE80211_ADDR_LEN];
  184. u_int8_t i_addr2[IEEE80211_ADDR_LEN];
  185. /* FCS */
  186. } __packed;
  187. struct ieee80211_frame_rts {
  188. u_int8_t i_fc[2];
  189. u_int8_t i_dur[2];
  190. u_int8_t i_ra[IEEE80211_ADDR_LEN];
  191. u_int8_t i_ta[IEEE80211_ADDR_LEN];
  192. /* FCS */
  193. } __packed;
  194. struct ieee80211_frame_cts {
  195. u_int8_t i_fc[2];
  196. u_int8_t i_dur[2];
  197. u_int8_t i_ra[IEEE80211_ADDR_LEN];
  198. /* FCS */
  199. } __packed;
  200. struct ieee80211_frame_ack {
  201. u_int8_t i_fc[2];
  202. u_int8_t i_dur[2];
  203. u_int8_t i_ra[IEEE80211_ADDR_LEN];
  204. /* FCS */
  205. } __packed;
  206. struct ieee80211_frame_pspoll {
  207. u_int8_t i_fc[2];
  208. u_int8_t i_aid[2];
  209. u_int8_t i_bssid[IEEE80211_ADDR_LEN];
  210. u_int8_t i_ta[IEEE80211_ADDR_LEN];
  211. /* FCS */
  212. } __packed;
  213. struct ieee80211_frame_cfend { /* NB: also CF-End+CF-Ack */
  214. u_int8_t i_fc[2];
  215. u_int8_t i_dur[2]; /* should be zero */
  216. u_int8_t i_ra[IEEE80211_ADDR_LEN];
  217. u_int8_t i_bssid[IEEE80211_ADDR_LEN];
  218. /* FCS */
  219. } __packed;
  220. #ifdef _KERNEL
  221. static __inline int
  222. ieee80211_has_seq(const struct ieee80211_frame *wh)
  223. {
  224. return (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) !=
  225. IEEE80211_FC0_TYPE_CTL;
  226. }
  227. static __inline int
  228. ieee80211_has_addr4(const struct ieee80211_frame *wh)
  229. {
  230. return (wh->i_fc[1] & IEEE80211_FC1_DIR_MASK) ==
  231. IEEE80211_FC1_DIR_DSTODS;
  232. }
  233. static __inline int
  234. ieee80211_has_qos(const struct ieee80211_frame *wh)
  235. {
  236. return (wh->i_fc[0] &
  237. (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_QOS)) ==
  238. (IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_QOS);
  239. }
  240. static __inline int
  241. ieee80211_has_htc(const struct ieee80211_frame *wh)
  242. {
  243. return (wh->i_fc[1] & IEEE80211_FC1_ORDER) &&
  244. (ieee80211_has_qos(wh) ||
  245. (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) ==
  246. IEEE80211_FC0_TYPE_MGT);
  247. }
  248. static __inline u_int16_t
  249. ieee80211_get_qos(const struct ieee80211_frame *wh)
  250. {
  251. const u_int8_t *frm;
  252. if (ieee80211_has_addr4(wh))
  253. frm = ((const struct ieee80211_qosframe_addr4 *)wh)->i_qos;
  254. else
  255. frm = ((const struct ieee80211_qosframe *)wh)->i_qos;
  256. return letoh16(*(const u_int16_t *)frm);
  257. }
  258. #endif /* _KERNEL */
  259. /*
  260. * Capability Information field (see 802.11-2012 8.4.1.4).
  261. */
  262. #define IEEE80211_CAPINFO_ESS 0x0001
  263. #define IEEE80211_CAPINFO_IBSS 0x0002
  264. #define IEEE80211_CAPINFO_CF_POLLABLE 0x0004
  265. #define IEEE80211_CAPINFO_CF_POLLREQ 0x0008
  266. #define IEEE80211_CAPINFO_PRIVACY 0x0010
  267. #define IEEE80211_CAPINFO_SHORT_PREAMBLE 0x0020
  268. #define IEEE80211_CAPINFO_PBCC 0x0040
  269. #define IEEE80211_CAPINFO_CHNL_AGILITY 0x0080
  270. #define IEEE80211_CAPINFO_SPECTRUM_MGMT 0x0100
  271. #define IEEE80211_CAPINFO_QOS 0x0200
  272. #define IEEE80211_CAPINFO_SHORT_SLOTTIME 0x0400
  273. #define IEEE80211_CAPINFO_APSD 0x0800
  274. #define IEEE80211_CAPINFO_RADIO_MEASUREMENT 0x1000
  275. #define IEEE80211_CAPINFO_DSSSOFDM 0x2000
  276. #define IEEE80211_CAPINFO_DELAYED_B_ACK 0x4000
  277. #define IEEE80211_CAPINFO_IMMEDIATE_B_ACK 0x8000
  278. #define IEEE80211_CAPINFO_BITS \
  279. "\10\01ESS\02IBSS\03CF_POLLABLE\04CF_POLLREQ" \
  280. "\05PRIVACY\06SHORT_PREAMBLE\07PBCC\10CHNL_AGILITY" \
  281. "\11SPECTRUM_MGMT\12QOS\13SHORT_SLOTTIME\14APSD" \
  282. "\15RADIO_MEASUREMENT\16DSSSOFDM\17DELAYED_B_ACK\20IMMEDIATE_B_ACK"
  283. /*
  284. * Information element IDs (see 802.11-2012 Table 8.4.2).
  285. */
  286. enum {
  287. IEEE80211_ELEMID_SSID = 0,
  288. IEEE80211_ELEMID_RATES = 1,
  289. IEEE80211_ELEMID_FHPARMS = 2,
  290. IEEE80211_ELEMID_DSPARMS = 3,
  291. IEEE80211_ELEMID_CFPARMS = 4,
  292. IEEE80211_ELEMID_TIM = 5,
  293. IEEE80211_ELEMID_IBSSPARMS = 6,
  294. IEEE80211_ELEMID_COUNTRY = 7,
  295. IEEE80211_ELEMID_HOPPING_PARMS = 8,
  296. IEEE80211_ELEMID_HOPPING_PATTERN = 9,
  297. IEEE80211_ELEMID_REQUEST = 10,
  298. IEEE80211_ELEMID_QBSS_LOAD = 11,
  299. IEEE80211_ELEMID_EDCAPARMS = 12,
  300. IEEE80211_ELEMID_TSPEC = 13,
  301. IEEE80211_ELEMID_TCLASS = 14,
  302. IEEE80211_ELEMID_SCHEDULE = 15,
  303. IEEE80211_ELEMID_CHALLENGE = 16,
  304. /* 17-31 reserved for challenge text extension */
  305. IEEE80211_ELEMID_POWER_CONSTRAINT = 32,
  306. IEEE80211_ELEMID_POWER_CAP = 33,
  307. IEEE80211_ELEMID_TPC_REQUEST = 34,
  308. IEEE80211_ELEMID_TPC_REPORT = 35,
  309. IEEE80211_ELEMID_SUPP_CHNLS = 35,
  310. IEEE80211_ELEMID_CSA = 37, /* 11h */
  311. IEEE80211_ELEMID_MEASUREMENT_REQUEST = 38, /* DFS */
  312. IEEE80211_ELEMID_MEASUREMENT_REPORT = 39, /* DFS */
  313. IEEE80211_ELEMID_QUIET = 40,
  314. IEEE80211_ELEMID_IBSS_DFS = 41,
  315. IEEE80211_ELEMID_ERP = 42,
  316. IEEE80211_ELEMID_TS_DELAY = 43,
  317. IEEE80211_ELEMID_TCLAS = 44,
  318. IEEE80211_ELEMID_HTCAPS = 45, /* 11n */
  319. IEEE80211_ELEMID_QOS_CAP = 46,
  320. /* 47 reserved */
  321. IEEE80211_ELEMID_RSN = 48,
  322. /* 49 reserved */
  323. IEEE80211_ELEMID_XRATES = 50,
  324. IEEE80211_ELEMID_AP_CHNL_REPORT = 51,
  325. IEEE80211_ELEMID_NBR_REPORT = 52,
  326. IEEE80211_ELEMID_RCPI = 53,
  327. IEEE80211_ELEMID_MDE = 54,
  328. IEEE80211_ELEMID_FTE = 55,
  329. IEEE80211_ELEMID_TIE = 56, /* 11r */
  330. IEEE80211_ELEMID_RDE = 57,
  331. IEEE80211_ELEMID_DSE = 58,
  332. IEEE80211_ELEMID_SUPP_OPCLASS = 59,
  333. IEEE80211_ELEMID_XCSA = 60,
  334. IEEE80211_ELEMID_HTOP = 61, /* 11n */
  335. IEEE80211_ELEMID_SECONDARY_CHANL_OFFSET = 62, /* 11n */
  336. IEEE80211_ELEMID_AVG_ACCESS_DELAY = 63,
  337. IEEE80211_ELEMID_ANTENNA = 64,
  338. IEEE80211_ELEMID_RSNI = 65,
  339. IEEE80211_ELEMID_MEASUREMENT_PILOT_TX = 66,
  340. IEEE80211_ELEMID_AVAIL_CAPACITY = 67,
  341. IEEE80211_ELEMID_AC_ACCESS_DELAY = 68,
  342. IEEE80211_ELEMID_TIME_ADVERT = 69,
  343. IEEE80211_ELEMID_RM = 70,
  344. IEEE80211_ELEMID_MULTI_BSSID = 71,
  345. IEEE80211_ELEMID_20_40_CBW_COEX = 72, /* 11n */
  346. IEEE80211_ELEMID_20_40_CBW_INTOLERANT = 73, /* 11n */
  347. IEEE80211_ELEMID_SCAN_PARAM_OVERLAP = 74,
  348. IEEE80211_ELEMID_RIC = 75,
  349. IEEE80211_ELEMID_MMIE = 76, /* 11w */
  350. IEEE80211_ELEMID_EVENT_REQUEST = 78,
  351. IEEE80211_ELEMID_EVENT_REPORT = 79,
  352. IEEE80211_ELEMID_DIAG_REQUEST = 80,
  353. IEEE80211_ELEMID_DIAG_REPORT = 81,
  354. IEEE80211_ELEMID_LOCATION_PARMS = 82,
  355. IEEE80211_ELEMID_NONTX_BSSID = 83,
  356. IEEE80211_ELEMID_SSID_LIST = 84,
  357. IEEE80211_ELEMID_MULTI_BSSID_IDX = 85,
  358. IEEE80211_ELEMID_FMS_DESC = 86,
  359. IEEE80211_ELEMID_FMS_REQUEST = 87,
  360. IEEE80211_ELEMID_FMS_RESPONSE = 88,
  361. IEEE80211_ELEMID_QOS_TRAFFIC_CAP = 89,
  362. IEEE80211_ELEMID_MAX_IDLE_PERIOD = 90,
  363. IEEE80211_ELEMID_TFS_REQUEST = 91,
  364. IEEE80211_ELEMID_TFS_RESPONSE = 92,
  365. IEEE80211_ELEMID_WNM_SLEEP = 93,
  366. IEEE80211_ELEMID_TIM_BCAST_REQUEST = 94,
  367. IEEE80211_ELEMID_TIM_BCAST_RESPONSE = 95,
  368. IEEE80211_ELEMID_INTERFERENCE_REPORT = 96,
  369. IEEE80211_ELEMID_CHNL_USAGE = 97,
  370. IEEE80211_ELEMID_TIME_ZONE = 98,
  371. IEEE80211_ELEMID_DMS_REQUEST = 99,
  372. IEEE80211_ELEMID_DMS_RESPONSE = 100,
  373. IEEE80211_ELEMID_LINK_ID = 101,
  374. IEEE80211_ELEMID_WAKE_SCHED = 102,
  375. /* 103 undefined */
  376. IEEE80211_ELEMID_CHNL_SWITCH_TIMING = 104,
  377. IEEE80211_ELEMID_PTI_CTRL = 105,
  378. IEEE80211_ELEMID_TPU_BUF_STATUS = 106,
  379. IEEE80211_ELEMID_INTERWORKING = 107,
  380. IEEE80211_ELEMID_ADVERT_PROTOCOL = 108,
  381. IEEE80211_ELEMID_EXPEDITED_BW_REQUEST = 109,
  382. IEEE80211_ELEMID_QOS_MAP_SET = 110,
  383. IEEE80211_ELEMID_ROAMING_CONSORTIUM = 111,
  384. IEEE80211_ELEMID_EMERGENCY_ALERT_ID = 112,
  385. IEEE80211_ELEMID_MESHCONF = 113,
  386. IEEE80211_ELEMID_MESHID = 114,
  387. IEEE80211_ELEMID_MESHLINK = 115,
  388. IEEE80211_ELEMID_MESHCNGST = 116,
  389. IEEE80211_ELEMID_MESHPEER = 117,
  390. IEEE80211_ELEMID_MESHCSA = 118,
  391. IEEE80211_ELEMID_MESHAWAKEW = 119,
  392. IEEE80211_ELEMID_MESHBEACONT = 120,
  393. IEEE80211_ELEMID_MCCAOP_SETUP_REQUEST = 121,
  394. IEEE80211_ELEMID_MCCAOP_SETUP_REPLY = 122,
  395. IEEE80211_ELEMID_MCCAOP_ADVERT = 123,
  396. IEEE80211_ELEMID_MCCAOP_TEARDOWN = 124,
  397. IEEE80211_ELEMID_MESHGANN = 125,
  398. IEEE80211_ELEMID_MESHRANN = 126,
  399. IEEE80211_ELEMID_XCAPS = 127,
  400. /* 128-129 reserved */
  401. IEEE80211_ELEMID_MESHPREQ = 130,
  402. IEEE80211_ELEMID_MESHPREP = 131,
  403. IEEE80211_ELEMID_MESHPERR = 132,
  404. /* 133-136 reserved */
  405. IEEE80211_ELEMID_MESHPXU = 137,
  406. IEEE80211_ELEMID_MESHPXUC = 138,
  407. IEEE80211_ELEMID_AUTH_MESH_PEERING_XCHG = 139,
  408. IEEE80211_ELEMID_MIC = 140,
  409. IEEE80211_ELEMID_DEST_URI = 141,
  410. IEEE80211_ELEMID_U_APSD_COEX = 142,
  411. /* 143-174 reserved */
  412. IEEE80211_ELEMID_MCCAOP_ADVERT_OVIEW = 174,
  413. /* 175-220 reserved */
  414. IEEE80211_ELEMID_VENDOR = 221 /* vendor private */
  415. /* 222-255 reserved */
  416. };
  417. /*
  418. * Action field category values (see 802.11-2012 8.4.1.11 Table 8-38).
  419. */
  420. enum {
  421. IEEE80211_CATEG_SPECTRUM = 0,
  422. IEEE80211_CATEG_QOS = 1,
  423. IEEE80211_CATEG_DLS = 2,
  424. IEEE80211_CATEG_BA = 3,
  425. IEEE80211_CATEG_PUB = 4,
  426. IEEE80211_CATEG_RADIO_MSRMNT = 5,
  427. IEEE80211_CATEG_FAST_BSS_TRANS = 6,
  428. IEEE80211_CATEG_HT = 7, /* 11n */
  429. IEEE80211_CATEG_SA_QUERY = 8, /* 11w */
  430. IEEE80211_CATEG_PROT_DUAL_PUBLIC_ACTION = 9,
  431. IEEE80211_CATEG_WNM = 10,
  432. IEEE80211_CATEG_UNPROT_WNM = 11,
  433. IEEE80211_CATEG_TDLS = 12,
  434. IEEE80211_CATEG_MESH = 13,
  435. IEEE80211_CATEG_MULTIHOP = 14,
  436. IEEE80211_CATEG_SELF_PROT = 15,
  437. /* 16-125 reserved */
  438. IEEE80211_CATEG_PROT_VENDOR = 126,
  439. IEEE80211_CATEG_VENDOR = 127,
  440. /* 128-255 error */
  441. };
  442. /*
  443. * Block Ack Action field values (see 802.11-2012 8.5.5 Table 8-202).
  444. */
  445. #define IEEE80211_ACTION_ADDBA_REQ 0
  446. #define IEEE80211_ACTION_ADDBA_RESP 1
  447. #define IEEE80211_ACTION_DELBA 2
  448. /* 3-255 reserved */
  449. /*
  450. * SA Query Action field values (see 802.11-2012 8.5.10 Table 8-227).
  451. */
  452. #define IEEE80211_ACTION_SA_QUERY_REQ 0
  453. #define IEEE80211_ACTION_SA_QUERY_RESP 1
  454. /*
  455. * HT Action field values (see 802.11-2012 8.5.12 Table 8-229).
  456. */
  457. #define IEEE80211_ACTION_NOTIFYCW 0
  458. #define IEEE80211_ACTION_SM_PWRSAVE 1
  459. #define IEEE80211_ACTION_PSMP 2
  460. #define IEEE80211_ACTION_SET_PCO_PHASE 3
  461. #define IEEE80211_ACTION_CSI 4
  462. #define IEEE80211_ACTION_NONCOMPRESSED_BF 5
  463. #define IEEE80211_ACTION_COMPRESSED_BF 6
  464. #define IEEE80211_ACTION_ASEL_IDX_FEEDBACK 7
  465. /* 8-255 reserved */
  466. #define IEEE80211_RATE_BASIC 0x80
  467. #define IEEE80211_RATE_VAL 0x7f
  468. #define IEEE80211_RATE_SIZE 8 /* 802.11 standard */
  469. #define IEEE80211_RATE_MAXSIZE 15 /* max rates we'll handle */
  470. /*
  471. * BlockAck/BlockAckReq Control field (see 802.11-2012 8.3.1.9 Figure 8-25).
  472. */
  473. #define IEEE80211_BA_ACK_POLICY 0x0001
  474. #define IEEE80211_BA_MULTI_TID 0x0002
  475. #define IEEE80211_BA_COMPRESSED 0x0004
  476. #define IEEE80211_BA_TID_INFO_MASK 0xf000
  477. #define IEEE80211_BA_TID_INFO_SHIFT 12
  478. /*
  479. * DELBA Parameter Set field (see 802.11-2012 8.4.1.16 Figure 8-50).
  480. */
  481. #define IEEE80211_DELBA_INITIATOR 0x0800
  482. #define IEEE80211_DELBA_TID_INFO_MASK 0xf000
  483. #define IEEE80211_DELBA_TID_INFO_SHIFT 12
  484. /*
  485. * ERP information element parameters (see 802.11-2012 8.4.2.14 Figure 8-95).
  486. */
  487. #define IEEE80211_ERP_NON_ERP_PRESENT 0x01
  488. #define IEEE80211_ERP_USE_PROTECTION 0x02
  489. #define IEEE80211_ERP_BARKER_MODE 0x04
  490. /*
  491. * RSN capabilities (see 802.11-2012 8.4.2.27.4).
  492. */
  493. #define IEEE80211_RSNCAP_PREAUTH 0x0001
  494. #define IEEE80211_RSNCAP_NOPAIRWISE 0x0002
  495. #define IEEE80211_RSNCAP_PTKSA_RCNT_MASK 0x000c
  496. #define IEEE80211_RSNCAP_PTKSA_RCNT_SHIFT 2
  497. #define IEEE80211_RSNCAP_GTKSA_RCNT_MASK 0x0030
  498. #define IEEE80211_RSNCAP_GTKSA_RCNT_SHIFT 4
  499. #define IEEE80211_RSNCAP_RCNT1 0
  500. #define IEEE80211_RSNCAP_RCNT2 1
  501. #define IEEE80211_RSNCAP_RCNT4 2
  502. #define IEEE80211_RSNCAP_RCNT16 3
  503. #define IEEE80211_RSNCAP_MFPR 0x0040 /* 11w */
  504. #define IEEE80211_RSNCAP_MFPC 0x0080 /* 11w */
  505. #define IEEE80211_RSNCAP_PEERKEYENA 0x0200
  506. #define IEEE80211_RSNCAP_SPPAMSDUC 0x0400 /* 11n */
  507. #define IEEE80211_RSNCAP_SPPAMSDUR 0x0800 /* 11n */
  508. #define IEEE80211_RSNCAP_PBAC 0x1000 /* 11n */
  509. #define IEEE80211_RSNCAP_EXTENDED_KEYID 0x2000
  510. /*
  511. * HT Capabilities Info (see 802.11-2012 8.4.2.58.2).
  512. */
  513. #define IEEE80211_HTCAP_LDPC 0x00000001
  514. #define IEEE80211_HTCAP_CBW20_40 0x00000002
  515. #define IEEE80211_HTCAP_SMPS_MASK 0x0000000c
  516. #define IEEE80211_HTCAP_SMPS_SHIFT 2
  517. #define IEEE80211_HTCAP_SMPS_STA 0
  518. #define IEEE80211_HTCAP_SMPS_DYN 1
  519. #define IEEE80211_HTCAP_SMPS_DIS 3
  520. #define IEEE80211_HTCAP_GF 0x00000010
  521. #define IEEE80211_HTCAP_SGI20 0x00000020
  522. #define IEEE80211_HTCAP_SGI40 0x00000040
  523. #define IEEE80211_HTCAP_TXSTBC 0x00000080
  524. #define IEEE80211_HTCAP_RXSTBC_MASK 0x00000300
  525. #define IEEE80211_HTCAP_RXSTBC_SHIFT 8
  526. #define IEEE80211_HTCAP_DELAYEDBA 0x00000400
  527. #define IEEE80211_HTCAP_AMSDU7935 0x00000800
  528. #define IEEE80211_HTCAP_DSSSCCK40 0x00001000
  529. #define IEEE80211_HTCAP_PSMP 0x00002000
  530. #define IEEE80211_HTCAP_40INTOLERANT 0x00004000
  531. #define IEEE80211_HTCAP_LSIGTXOPPROT 0x00008000
  532. /*
  533. * HT Extended Capabilities (see 802.11-2012 8.4.2.58.5).
  534. */
  535. #define IEEE80211_HTXCAP_PCO 0x0001
  536. #define IEEE80211_HTXCAP_PCOTT_MASK 0x0006
  537. #define IEEE80211_HTXCAP_PCOTT_SHIFT 1
  538. #define IEEE80211_HTXCAP_PCOTT_400 1
  539. #define IEEE80211_HTXCAP_PCOTT_1500 2
  540. #define IEEE80211_HTXCAP_PCOTT_5000 3
  541. /* Bits 3-7 are reserved. */
  542. #define IEEE80211_HTXCAP_MFB_MASK 0x0300
  543. #define IEEE80211_HTXCAP_MFB_SHIFT 8
  544. #define IEEE80211_HTXCAP_MFB_NONE 0
  545. #define IEEE80211_HTXCAP_MFB_UNSOL 2
  546. #define IEEE80211_HTXCAP_MFB_BOTH 3
  547. #define IEEE80211_HTXCAP_HTC 0x0400
  548. #define IEEE80211_HTXCAP_RDRESP 0x0800
  549. /* Bits 12-15 are reserved. */
  550. /*
  551. * Transmit Beamforming (TxBF) Capabilities (see 802.11-2012 8.4.2.58.6).
  552. */
  553. #define IEEE80211_TXBFCAP_IMPLICIT_RX 0x00000001
  554. #define IEEE80211_TXBFCAP_RSSC 0x00000002
  555. #define IEEE80211_TXBFCAP_TSSC 0x00000004
  556. #define IEEE80211_TXBFCAP_RNDP 0x00000008
  557. #define IEEE80211_TXBFCAP_TNDP 0x00000010
  558. #define IEEE80211_TXBFCAP_IMPLICIT_TX 0x00000020
  559. #define IEEE80211_TXBFCAP_CALIB_MASK 0x000000c0
  560. #define IEEE80211_TXBFCAP_CALIB_SHIFT 6
  561. #define IEEE80211_TXBFCAP_TX_CSI 0x00000100
  562. #define IEEE80211_TXBFCAP_EXPLICIT_NSC 0x00000200
  563. #define IEEE80211_TXBFCAP_EXPLICIT_CSC 0x00000400
  564. #define IEEE80211_TXBFCAP_CSI_FB_DELAYED 0x00000800
  565. #define IEEE80211_TXBFCAP_CSI_FB_IMMEDIATE 0x00001000
  566. #define IEEE80211_TXBFCAP_EXPLICIT_NB_FB_DELAYED 0x00002000
  567. #define IEEE80211_TXBFCAP_EXPLICIT_NB_FB_IMMEDIATE 0x00004000
  568. #define IEEE80211_TXBFCAP_EXPLICIT_CB_FB_DELAYED 0x00008000
  569. #define IEEE80211_TXBFCAP_EXPLICIT_CB_FB_IMMEDIATE 0x00010000
  570. #define IEEE80211_TXBFCAP_MINIMAL_GROUPING_1_2 0x00020000
  571. #define IEEE80211_TXBFCAP_MINIMAL_GROUPING_1_4 0x00040000
  572. #define IEEE80211_TXBFCAP_CSI_NUM_ANT_MASK 0x00180000
  573. #define IEEE80211_TXBFCAP_CSI_NUM_ANT_SHIFT 19
  574. #define IEEE80211_TXBFCAP_NS_NUM_ANT_MASK 0x00600000
  575. #define IEEE80211_TXBFCAP_NS_NUM_ANT_SHIFT 21
  576. #define IEEE80211_TXBFCAP_CS_NUM_ANT_MASK 0x01800000
  577. #define IEEE80211_TXBFCAP_CS_NUM_ANT_SHIFT 23
  578. #define IEEE80211_TXBFCAP_CSI_NUM_ROWS_MASK 0x06000000
  579. #define IEEE80211_TXBFCAP_CSI_NUM_ROWS_SHIFT 25
  580. #define IEEE80211_TXBFCAP_CHANL_ESTIMATE_MASK 0x18000000
  581. #define IEEE80211_TXBFCAP_CHANL_ESTIMATE_SHIFT 27
  582. /*
  583. * Antenna Selection (ASEL) Capability (see 802.11-2012 8.4.2.58.7).
  584. */
  585. #define IEEE80211_ASELCAP_ASEL 0x01
  586. #define IEEE80211_ASELCAP_CSIFB_TX 0x02
  587. #define IEEE80211_ASELCAP_ANT_IDX_FB_TX 0x04
  588. #define IEEE80211_ASELCAP_CSIFB 0x08
  589. #define IEEE80211_ASELCAP_ANT_IDX_FB 0x10
  590. #define IEEE80211_ASELCAP_ASEL_RX 0x20
  591. #define IEEE80211_ASELCAP_TX_SOUND_PPDU 0x20
  592. /* Bit 7 is reserved. */
  593. /*
  594. * HT Operation element (see 802.11-2012 8.4.2.59).
  595. */
  596. /* Byte 1. */
  597. #define IEEE80211_HTOP0_SCO_MASK 0x03
  598. #define IEEE80211_HTOP0_SCO_SHIFT 0
  599. #define IEEE80211_HTOP0_SCO_SCN 0
  600. #define IEEE80211_HTOP0_SCO_SCA 1
  601. #define IEEE80211_HTOP0_SCO_SCB 3
  602. #define IEEE80211_HTOP0_CHW 0x04
  603. #define IEEE80211_HTOP0_RIFS 0x08
  604. /* bits 4-7 reserved */
  605. /* Bytes 2-3. */
  606. #define IEEE80211_HTOP1_PROT_MASK 0x0003
  607. #define IEEE80211_HTOP1_PROT_SHIFT 0
  608. #define IEEE80211_HTOP1_NONGF_STA 0x0004
  609. /* Bit 3 is reserved. */
  610. #define IEEE80211_HTOP1_OBSS_NONHT_STA 0x0010
  611. /* Bits 5-15 are reserved. */
  612. /* Bytes 4-5. */
  613. /* Bits 0-5 are reserved. */
  614. #define IEEE80211_HTOP2_DUALBEACON 0x0040
  615. #define IEEE80211_HTOP2_DUALCTSPROT 0x0080
  616. #define IEEE80211_HTOP2_STBCBEACON 0x0100
  617. #define IEEE80211_HTOP2_LSIGTXOP 0x0200
  618. #define IEEE80211_HTOP2_PCOACTIVE 0x0400
  619. #define IEEE80211_HTOP2_PCOPHASE40 0x0800
  620. /* Bits 12-15 are reserved. */
  621. /*
  622. * EDCA Access Categories.
  623. */
  624. enum ieee80211_edca_ac {
  625. EDCA_AC_BK = 1, /* Background */
  626. EDCA_AC_BE = 0, /* Best Effort */
  627. EDCA_AC_VI = 2, /* Video */
  628. EDCA_AC_VO = 3 /* Voice */
  629. };
  630. #define EDCA_NUM_AC 4
  631. /* number of TID values (traffic identifier) */
  632. #define IEEE80211_NUM_TID 16
  633. /* Atheros private advanced capabilities info */
  634. #define ATHEROS_CAP_TURBO_PRIME 0x01
  635. #define ATHEROS_CAP_COMPRESSION 0x02
  636. #define ATHEROS_CAP_FAST_FRAME 0x04
  637. /* bits 3-6 reserved */
  638. #define ATHEROS_CAP_BOOST 0x80
  639. /*-
  640. * Organizationally Unique Identifiers.
  641. * See http://standards.ieee.org/regauth/oui/oui.txt for a list.
  642. */
  643. #define ATHEROS_OUI ((const u_int8_t[]){ 0x00, 0x03, 0x7f })
  644. #define BROADCOM_OUI ((const u_int8_t[]){ 0x00, 0x90, 0x4c })
  645. #define IEEE80211_OUI ((const u_int8_t[]){ 0x00, 0x0f, 0xac })
  646. #define MICROSOFT_OUI ((const u_int8_t[]){ 0x00, 0x50, 0xf2 })
  647. #define IEEE80211_AUTH_ALGORITHM(auth) \
  648. ((auth)[0] | ((auth)[1] << 8))
  649. #define IEEE80211_AUTH_TRANSACTION(auth) \
  650. ((auth)[2] | ((auth)[3] << 8))
  651. #define IEEE80211_AUTH_STATUS(auth) \
  652. ((auth)[4] | ((auth)[5] << 8))
  653. /*
  654. * Authentication Algorithm Number field (see 7.3.1.1).
  655. */
  656. #define IEEE80211_AUTH_ALG_OPEN 0x0000
  657. #define IEEE80211_AUTH_ALG_SHARED 0x0001
  658. #define IEEE80211_AUTH_ALG_LEAP 0x0080
  659. /*
  660. * Authentication Transaction Sequence Number field (see 7.3.1.2).
  661. */
  662. enum {
  663. IEEE80211_AUTH_OPEN_REQUEST = 1,
  664. IEEE80211_AUTH_OPEN_RESPONSE = 2
  665. };
  666. enum {
  667. IEEE80211_AUTH_SHARED_REQUEST = 1,
  668. IEEE80211_AUTH_SHARED_CHALLENGE = 2,
  669. IEEE80211_AUTH_SHARED_RESPONSE = 3,
  670. IEEE80211_AUTH_SHARED_PASS = 4
  671. };
  672. /*
  673. * Reason codes (see Table 22).
  674. */
  675. enum {
  676. IEEE80211_REASON_UNSPECIFIED = 1,
  677. IEEE80211_REASON_AUTH_EXPIRE = 2,
  678. IEEE80211_REASON_AUTH_LEAVE = 3,
  679. IEEE80211_REASON_ASSOC_EXPIRE = 4,
  680. IEEE80211_REASON_ASSOC_TOOMANY = 5,
  681. IEEE80211_REASON_NOT_AUTHED = 6,
  682. IEEE80211_REASON_NOT_ASSOCED = 7,
  683. IEEE80211_REASON_ASSOC_LEAVE = 8,
  684. IEEE80211_REASON_ASSOC_NOT_AUTHED = 9,
  685. /* XXX the following two reason codes are not correct */
  686. IEEE80211_REASON_RSN_REQUIRED = 11,
  687. IEEE80211_REASON_RSN_INCONSISTENT = 12,
  688. IEEE80211_REASON_IE_INVALID = 13,
  689. IEEE80211_REASON_MIC_FAILURE = 14,
  690. IEEE80211_REASON_4WAY_TIMEOUT = 15,
  691. IEEE80211_REASON_GROUP_TIMEOUT = 16,
  692. IEEE80211_REASON_RSN_DIFFERENT_IE = 17,
  693. IEEE80211_REASON_BAD_GROUP_CIPHER = 18,
  694. IEEE80211_REASON_BAD_PAIRWISE_CIPHER = 19,
  695. IEEE80211_REASON_BAD_AKMP = 20,
  696. IEEE80211_REASON_RSN_IE_VER_UNSUP = 21,
  697. IEEE80211_REASON_RSN_IE_BAD_CAP = 22,
  698. IEEE80211_REASON_CIPHER_REJ_POLICY = 24,
  699. IEEE80211_REASON_SETUP_REQUIRED = 38,
  700. IEEE80211_REASON_TIMEOUT = 39
  701. };
  702. /*
  703. * Status codes (see Table 23).
  704. */
  705. enum {
  706. IEEE80211_STATUS_SUCCESS = 0,
  707. IEEE80211_STATUS_UNSPECIFIED = 1,
  708. IEEE80211_STATUS_CAPINFO = 10,
  709. IEEE80211_STATUS_NOT_ASSOCED = 11,
  710. IEEE80211_STATUS_OTHER = 12,
  711. IEEE80211_STATUS_ALG = 13,
  712. IEEE80211_STATUS_SEQUENCE = 14,
  713. IEEE80211_STATUS_CHALLENGE = 15,
  714. IEEE80211_STATUS_TIMEOUT = 16,
  715. IEEE80211_STATUS_TOOMANY = 17,
  716. IEEE80211_STATUS_BASIC_RATE = 18,
  717. IEEE80211_STATUS_SP_REQUIRED = 19,
  718. IEEE80211_STATUS_PBCC_REQUIRED = 20,
  719. IEEE80211_STATUS_CA_REQUIRED = 21,
  720. IEEE80211_STATUS_TOO_MANY_STATIONS = 22,
  721. IEEE80211_STATUS_RATES = 23,
  722. IEEE80211_STATUS_SHORTSLOT_REQUIRED = 25,
  723. IEEE80211_STATUS_DSSSOFDM_REQUIRED = 26,
  724. IEEE80211_STATUS_TRY_AGAIN_LATER = 30,
  725. IEEE80211_STATUS_MFP_POLICY = 31,
  726. IEEE80211_STATUS_REFUSED = 37,
  727. IEEE80211_STATUS_INVALID_PARAM = 38,
  728. IEEE80211_STATUS_IE_INVALID = 40,
  729. IEEE80211_STATUS_BAD_GROUP_CIPHER = 41,
  730. IEEE80211_STATUS_BAD_PAIRWISE_CIPHER = 42,
  731. IEEE80211_STATUS_BAD_AKMP = 43,
  732. IEEE80211_STATUS_RSN_IE_VER_UNSUP = 44,
  733. IEEE80211_STATUS_CIPHER_REJ_POLICY = 46,
  734. };
  735. #define IEEE80211_WEP_KEYLEN 5 /* 40bit */
  736. #define IEEE80211_WEP_NKID 4 /* number of key ids */
  737. #define IEEE80211_CHALLENGE_LEN 128
  738. /* WEP header constants */
  739. #define IEEE80211_WEP_IVLEN 3 /* 24bit */
  740. #define IEEE80211_WEP_KIDLEN 1 /* 1 octet */
  741. #define IEEE80211_WEP_CRCLEN 4 /* CRC-32 */
  742. #define IEEE80211_CRC_LEN 4
  743. #define IEEE80211_WEP_TOTLEN (IEEE80211_WEP_IVLEN + \
  744. IEEE80211_WEP_KIDLEN + \
  745. IEEE80211_WEP_CRCLEN)
  746. /*
  747. * 802.11i defines an extended IV for use with non-WEP ciphers.
  748. * When the EXTIV bit is set in the key id byte an additional
  749. * 4 bytes immediately follow the IV for TKIP. For CCMP the
  750. * EXTIV bit is likewise set but the 8 bytes represent the
  751. * CCMP header rather than IV+extended-IV.
  752. */
  753. #define IEEE80211_WEP_EXTIV 0x20
  754. #define IEEE80211_WEP_EXTIVLEN 4 /* extended IV length */
  755. #define IEEE80211_WEP_MICLEN 8 /* trailing MIC */
  756. /*
  757. * Maximum acceptable MTU is:
  758. * IEEE80211_MAX_LEN - WEP overhead - CRC -
  759. * QoS overhead - RSN/WPA overhead
  760. * Min is arbitrarily chosen > IEEE80211_MIN_LEN. The default
  761. * mtu is Ethernet-compatible; it's set by ether_ifattach.
  762. */
  763. #define IEEE80211_MTU_MAX 2290
  764. #define IEEE80211_MTU_MIN 32
  765. #define IEEE80211_MAX_LEN (2300 + IEEE80211_CRC_LEN + \
  766. (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + IEEE80211_WEP_CRCLEN))
  767. #define IEEE80211_ACK_LEN \
  768. (sizeof(struct ieee80211_frame_ack) + IEEE80211_CRC_LEN)
  769. #define IEEE80211_MIN_LEN \
  770. (sizeof(struct ieee80211_frame_min) + IEEE80211_CRC_LEN)
  771. /*
  772. * The 802.11 spec says at most 2007 stations may be
  773. * associated at once. For most AP's this is way more
  774. * than is feasible so we use a default of 1800. This
  775. * number may be overridden by the driver and/or by
  776. * user configuration.
  777. */
  778. #define IEEE80211_AID_MAX 2007
  779. #define IEEE80211_AID_DEF 1800
  780. #define IEEE80211_AID(b) ((b) &~ 0xc000)
  781. /*
  782. * RTS frame length parameters. The default is specified in
  783. * the 802.11 spec. The max may be wrong for jumbo frames.
  784. */
  785. #define IEEE80211_RTS_DEFAULT 512
  786. #define IEEE80211_RTS_MIN 1
  787. #define IEEE80211_RTS_MAX IEEE80211_MAX_LEN
  788. #define IEEE80211_PLCP_SERVICE 0x00
  789. #define IEEE80211_PLCP_SERVICE_PBCC 0x08 /* PBCC encoded */
  790. #define IEEE80211_PLCP_SERVICE_LENEXT 0x80 /* length extension bit */
  791. /* One Time Unit (TU) is 1Kus = 1024 microseconds. */
  792. #define IEEE80211_DUR_TU 1024
  793. /* IEEE 802.11b durations for DSSS PHY in microseconds */
  794. #define IEEE80211_DUR_DS_LONG_PREAMBLE 144
  795. #define IEEE80211_DUR_DS_SHORT_PREAMBLE 72
  796. #define IEEE80211_DUR_DS_PREAMBLE_DIFFERENCE \
  797. (IEEE80211_DUR_DS_LONG_PREAMBLE - IEEE80211_DUR_DS_SHORT_PREAMBLE)
  798. #define IEEE80211_DUR_DS_FAST_PLCPHDR 24
  799. #define IEEE80211_DUR_DS_SLOW_PLCPHDR 48
  800. #define IEEE80211_DUR_DS_PLCPHDR_DIFFERENCE \
  801. (IEEE80211_DUR_DS_SLOW_PLCPHDR - IEEE80211_DUR_DS_FAST_PLCPHDR)
  802. #define IEEE80211_DUR_DS_SLOW_ACK 112
  803. #define IEEE80211_DUR_DS_FAST_ACK 56
  804. #define IEEE80211_DUR_DS_SLOW_CTS 112
  805. #define IEEE80211_DUR_DS_FAST_CTS 56
  806. #define IEEE80211_DUR_DS_SLOT 20
  807. #define IEEE80211_DUR_DS_SIFS 10
  808. #define IEEE80211_DUR_DS_PIFS (IEEE80211_DUR_DS_SIFS + IEEE80211_DUR_DS_SLOT)
  809. #define IEEE80211_DUR_DS_DIFS (IEEE80211_DUR_DS_SIFS + \
  810. 2 * IEEE80211_DUR_DS_SLOT)
  811. #define IEEE80211_DUR_DS_EIFS (IEEE80211_DUR_DS_SIFS + \
  812. IEEE80211_DUR_DS_SLOW_ACK + \
  813. IEEE80211_DUR_DS_LONG_PREAMBLE + \
  814. IEEE80211_DUR_DS_SLOW_PLCPHDR + \
  815. IEEE80211_DUR_DIFS)
  816. /*
  817. * The RSNA key descriptor used by IEEE 802.11 does not use the IEEE 802.1X
  818. * key descriptor. Instead, it uses the key descriptor described in 8.5.2.
  819. */
  820. #define EAPOL_KEY_NONCE_LEN 32
  821. #define EAPOL_KEY_IV_LEN 16
  822. #define EAPOL_KEY_MIC_LEN 16
  823. struct ieee80211_eapol_key {
  824. u_int8_t version;
  825. #define EAPOL_VERSION 1
  826. u_int8_t type;
  827. /* IEEE Std 802.1X-2004, 7.5.4 (only type EAPOL-Key is used here) */
  828. #define EAP_PACKET 0
  829. #define EAPOL_START 1
  830. #define EAPOL_LOGOFF 2
  831. #define EAPOL_KEY 3
  832. #define EAPOL_ASF_ALERT 4
  833. u_int8_t len[2];
  834. u_int8_t desc;
  835. /* IEEE Std 802.1X-2004, 7.6.1 */
  836. #define EAPOL_KEY_DESC_RC4 1 /* deprecated */
  837. #define EAPOL_KEY_DESC_IEEE80211 2
  838. #define EAPOL_KEY_DESC_WPA 254 /* non-standard WPA */
  839. u_int8_t info[2];
  840. #define EAPOL_KEY_VERSION_MASK 0x7
  841. #define EAPOL_KEY_DESC_V1 1
  842. #define EAPOL_KEY_DESC_V2 2
  843. #define EAPOL_KEY_DESC_V3 3 /* 11r */
  844. #define EAPOL_KEY_PAIRWISE (1 << 3)
  845. #define EAPOL_KEY_INSTALL (1 << 6) /* I */
  846. #define EAPOL_KEY_KEYACK (1 << 7) /* A */
  847. #define EAPOL_KEY_KEYMIC (1 << 8) /* M */
  848. #define EAPOL_KEY_SECURE (1 << 9) /* S */
  849. #define EAPOL_KEY_ERROR (1 << 10)
  850. #define EAPOL_KEY_REQUEST (1 << 11)
  851. #define EAPOL_KEY_ENCRYPTED (1 << 12)
  852. #define EAPOL_KEY_SMK (1 << 13)
  853. /* WPA compatibility */
  854. #define EAPOL_KEY_WPA_KID_MASK 0x3
  855. #define EAPOL_KEY_WPA_KID_SHIFT 4
  856. #define EAPOL_KEY_WPA_TX EAPOL_KEY_INSTALL
  857. u_int8_t keylen[2];
  858. u_int8_t replaycnt[8];
  859. u_int8_t nonce[EAPOL_KEY_NONCE_LEN];
  860. u_int8_t iv[EAPOL_KEY_IV_LEN];
  861. u_int8_t rsc[8];
  862. u_int8_t reserved[8];
  863. u_int8_t mic[EAPOL_KEY_MIC_LEN];
  864. u_int8_t paylen[2];
  865. } __packed;
  866. /* Pairwise Transient Key (see 8.5.1.2) */
  867. struct ieee80211_ptk {
  868. u_int8_t kck[16]; /* Key Confirmation Key */
  869. u_int8_t kek[16]; /* Key Encryption Key */
  870. u_int8_t tk[32]; /* Temporal Key */
  871. } __packed;
  872. #define IEEE80211_PMKID_LEN 16
  873. #define IEEE80211_SMKID_LEN 16
  874. /*
  875. * Key Data Encapsulation (see Table 62).
  876. */
  877. enum {
  878. IEEE80211_KDE_GTK = 1,
  879. IEEE80211_KDE_MACADDR = 3,
  880. IEEE80211_KDE_PMKID = 4,
  881. IEEE80211_KDE_SMK = 5,
  882. IEEE80211_KDE_NONCE = 6,
  883. IEEE80211_KDE_LIFETIME = 7,
  884. IEEE80211_KDE_ERROR = 8,
  885. IEEE80211_KDE_IGTK = 9 /* 11w */
  886. };
  887. #endif /* _NET80211_IEEE80211_H_ */