ieee80211.h 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335
  1. /*
  2. * Merged with mainline ieee80211.h in Aug 2004. Original ieee802_11
  3. * remains copyright by the original authors
  4. *
  5. * Portions of the merged code are based on Host AP (software wireless
  6. * LAN access point) driver for Intersil Prism2/2.5/3.
  7. *
  8. * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
  9. * <j@w1.fi>
  10. * Copyright (c) 2002-2003, Jouni Malinen <j@w1.fi>
  11. *
  12. * Adaption to a generic IEEE 802.11 stack by James Ketrenos
  13. * <jketreno@linux.intel.com>
  14. * Copyright (c) 2004-2005, Intel Corporation
  15. *
  16. * This program is free software; you can redistribute it and/or modify
  17. * it under the terms of the GNU General Public License version 2 as
  18. * published by the Free Software Foundation. See README and COPYING for
  19. * more details.
  20. *
  21. * API Version History
  22. * 1.0.x -- Initial version
  23. * 1.1.x -- Added radiotap, QoS, TIM, ieee80211_geo APIs,
  24. * various structure changes, and crypto API init method
  25. */
  26. #ifndef IEEE80211_H
  27. #define IEEE80211_H
  28. #include <linux/if_ether.h> /* ETH_ALEN */
  29. #include <linux/kernel.h> /* ARRAY_SIZE */
  30. #include <linux/wireless.h>
  31. #define IEEE80211_VERSION "git-1.1.13"
  32. #define IEEE80211_DATA_LEN 2304
  33. /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
  34. 6.2.1.1.2.
  35. The figure in section 7.1.2 suggests a body size of up to 2312
  36. bytes is allowed, which is a bit confusing, I suspect this
  37. represents the 2304 bytes of real data, plus a possible 8 bytes of
  38. WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
  39. #define IEEE80211_1ADDR_LEN 10
  40. #define IEEE80211_2ADDR_LEN 16
  41. #define IEEE80211_3ADDR_LEN 24
  42. #define IEEE80211_4ADDR_LEN 30
  43. #define IEEE80211_FCS_LEN 4
  44. #define IEEE80211_HLEN (IEEE80211_4ADDR_LEN)
  45. #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
  46. #define MIN_FRAG_THRESHOLD 256U
  47. #define MAX_FRAG_THRESHOLD 2346U
  48. /* Frame control field constants */
  49. #define IEEE80211_FCTL_VERS 0x0003
  50. #define IEEE80211_FCTL_FTYPE 0x000c
  51. #define IEEE80211_FCTL_STYPE 0x00f0
  52. #define IEEE80211_FCTL_TODS 0x0100
  53. #define IEEE80211_FCTL_FROMDS 0x0200
  54. #define IEEE80211_FCTL_MOREFRAGS 0x0400
  55. #define IEEE80211_FCTL_RETRY 0x0800
  56. #define IEEE80211_FCTL_PM 0x1000
  57. #define IEEE80211_FCTL_MOREDATA 0x2000
  58. #define IEEE80211_FCTL_PROTECTED 0x4000
  59. #define IEEE80211_FCTL_ORDER 0x8000
  60. #define IEEE80211_FTYPE_MGMT 0x0000
  61. #define IEEE80211_FTYPE_CTL 0x0004
  62. #define IEEE80211_FTYPE_DATA 0x0008
  63. /* management */
  64. #define IEEE80211_STYPE_ASSOC_REQ 0x0000
  65. #define IEEE80211_STYPE_ASSOC_RESP 0x0010
  66. #define IEEE80211_STYPE_REASSOC_REQ 0x0020
  67. #define IEEE80211_STYPE_REASSOC_RESP 0x0030
  68. #define IEEE80211_STYPE_PROBE_REQ 0x0040
  69. #define IEEE80211_STYPE_PROBE_RESP 0x0050
  70. #define IEEE80211_STYPE_BEACON 0x0080
  71. #define IEEE80211_STYPE_ATIM 0x0090
  72. #define IEEE80211_STYPE_DISASSOC 0x00A0
  73. #define IEEE80211_STYPE_AUTH 0x00B0
  74. #define IEEE80211_STYPE_DEAUTH 0x00C0
  75. #define IEEE80211_STYPE_ACTION 0x00D0
  76. /* control */
  77. #define IEEE80211_STYPE_PSPOLL 0x00A0
  78. #define IEEE80211_STYPE_RTS 0x00B0
  79. #define IEEE80211_STYPE_CTS 0x00C0
  80. #define IEEE80211_STYPE_ACK 0x00D0
  81. #define IEEE80211_STYPE_CFEND 0x00E0
  82. #define IEEE80211_STYPE_CFENDACK 0x00F0
  83. /* data */
  84. #define IEEE80211_STYPE_DATA 0x0000
  85. #define IEEE80211_STYPE_DATA_CFACK 0x0010
  86. #define IEEE80211_STYPE_DATA_CFPOLL 0x0020
  87. #define IEEE80211_STYPE_DATA_CFACKPOLL 0x0030
  88. #define IEEE80211_STYPE_NULLFUNC 0x0040
  89. #define IEEE80211_STYPE_CFACK 0x0050
  90. #define IEEE80211_STYPE_CFPOLL 0x0060
  91. #define IEEE80211_STYPE_CFACKPOLL 0x0070
  92. #define IEEE80211_STYPE_QOS_DATA 0x0080
  93. #define IEEE80211_SCTL_FRAG 0x000F
  94. #define IEEE80211_SCTL_SEQ 0xFFF0
  95. /* QOS control */
  96. #define IEEE80211_QCTL_TID 0x000F
  97. /* debug macros */
  98. #ifdef CONFIG_IEEE80211_DEBUG
  99. extern u32 ieee80211_debug_level;
  100. #define IEEE80211_DEBUG(level, fmt, args...) \
  101. do { if (ieee80211_debug_level & (level)) \
  102. printk(KERN_DEBUG "ieee80211: %c %s " fmt, \
  103. in_interrupt() ? 'I' : 'U', __FUNCTION__ , ## args); } while (0)
  104. static inline bool ieee80211_ratelimit_debug(u32 level)
  105. {
  106. return (ieee80211_debug_level & level) && net_ratelimit();
  107. }
  108. #else
  109. #define IEEE80211_DEBUG(level, fmt, args...) do {} while (0)
  110. static inline bool ieee80211_ratelimit_debug(u32 level)
  111. {
  112. return false;
  113. }
  114. #endif /* CONFIG_IEEE80211_DEBUG */
  115. /* escape_essid() is intended to be used in debug (and possibly error)
  116. * messages. It should never be used for passing essid to user space. */
  117. const char *escape_essid(const char *essid, u8 essid_len);
  118. /*
  119. * To use the debug system:
  120. *
  121. * If you are defining a new debug classification, simply add it to the #define
  122. * list here in the form of:
  123. *
  124. * #define IEEE80211_DL_xxxx VALUE
  125. *
  126. * shifting value to the left one bit from the previous entry. xxxx should be
  127. * the name of the classification (for example, WEP)
  128. *
  129. * You then need to either add a IEEE80211_xxxx_DEBUG() macro definition for your
  130. * classification, or use IEEE80211_DEBUG(IEEE80211_DL_xxxx, ...) whenever you want
  131. * to send output to that classification.
  132. *
  133. * To add your debug level to the list of levels seen when you perform
  134. *
  135. * % cat /proc/net/ieee80211/debug_level
  136. *
  137. * you simply need to add your entry to the ieee80211_debug_level array.
  138. *
  139. * If you do not see debug_level in /proc/net/ieee80211 then you do not have
  140. * CONFIG_IEEE80211_DEBUG defined in your kernel configuration
  141. *
  142. */
  143. #define IEEE80211_DL_INFO (1<<0)
  144. #define IEEE80211_DL_WX (1<<1)
  145. #define IEEE80211_DL_SCAN (1<<2)
  146. #define IEEE80211_DL_STATE (1<<3)
  147. #define IEEE80211_DL_MGMT (1<<4)
  148. #define IEEE80211_DL_FRAG (1<<5)
  149. #define IEEE80211_DL_DROP (1<<7)
  150. #define IEEE80211_DL_TX (1<<8)
  151. #define IEEE80211_DL_RX (1<<9)
  152. #define IEEE80211_DL_QOS (1<<31)
  153. #define IEEE80211_ERROR(f, a...) printk(KERN_ERR "ieee80211: " f, ## a)
  154. #define IEEE80211_WARNING(f, a...) printk(KERN_WARNING "ieee80211: " f, ## a)
  155. #define IEEE80211_DEBUG_INFO(f, a...) IEEE80211_DEBUG(IEEE80211_DL_INFO, f, ## a)
  156. #define IEEE80211_DEBUG_WX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_WX, f, ## a)
  157. #define IEEE80211_DEBUG_SCAN(f, a...) IEEE80211_DEBUG(IEEE80211_DL_SCAN, f, ## a)
  158. #define IEEE80211_DEBUG_STATE(f, a...) IEEE80211_DEBUG(IEEE80211_DL_STATE, f, ## a)
  159. #define IEEE80211_DEBUG_MGMT(f, a...) IEEE80211_DEBUG(IEEE80211_DL_MGMT, f, ## a)
  160. #define IEEE80211_DEBUG_FRAG(f, a...) IEEE80211_DEBUG(IEEE80211_DL_FRAG, f, ## a)
  161. #define IEEE80211_DEBUG_DROP(f, a...) IEEE80211_DEBUG(IEEE80211_DL_DROP, f, ## a)
  162. #define IEEE80211_DEBUG_TX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_TX, f, ## a)
  163. #define IEEE80211_DEBUG_RX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_RX, f, ## a)
  164. #define IEEE80211_DEBUG_QOS(f, a...) IEEE80211_DEBUG(IEEE80211_DL_QOS, f, ## a)
  165. #include <linux/netdevice.h>
  166. #include <linux/wireless.h>
  167. #include <linux/if_arp.h> /* ARPHRD_ETHER */
  168. #ifndef WIRELESS_SPY
  169. #define WIRELESS_SPY /* enable iwspy support */
  170. #endif
  171. #include <net/iw_handler.h> /* new driver API */
  172. #ifndef ETH_P_PAE
  173. #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
  174. #endif /* ETH_P_PAE */
  175. #define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
  176. #ifndef ETH_P_80211_RAW
  177. #define ETH_P_80211_RAW (ETH_P_ECONET + 1)
  178. #endif
  179. /* IEEE 802.11 defines */
  180. #define P80211_OUI_LEN 3
  181. struct ieee80211_snap_hdr {
  182. u8 dsap; /* always 0xAA */
  183. u8 ssap; /* always 0xAA */
  184. u8 ctrl; /* always 0x03 */
  185. u8 oui[P80211_OUI_LEN]; /* organizational universal id */
  186. } __attribute__ ((packed));
  187. #define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
  188. #define WLAN_FC_GET_VERS(fc) ((fc) & IEEE80211_FCTL_VERS)
  189. #define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE)
  190. #define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE)
  191. #define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG)
  192. #define WLAN_GET_SEQ_SEQ(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
  193. /* Authentication algorithms */
  194. #define WLAN_AUTH_OPEN 0
  195. #define WLAN_AUTH_SHARED_KEY 1
  196. #define WLAN_AUTH_LEAP 2
  197. #define WLAN_AUTH_CHALLENGE_LEN 128
  198. #define WLAN_CAPABILITY_ESS (1<<0)
  199. #define WLAN_CAPABILITY_IBSS (1<<1)
  200. #define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
  201. #define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
  202. #define WLAN_CAPABILITY_PRIVACY (1<<4)
  203. #define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
  204. #define WLAN_CAPABILITY_PBCC (1<<6)
  205. #define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
  206. #define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8)
  207. #define WLAN_CAPABILITY_QOS (1<<9)
  208. #define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10)
  209. #define WLAN_CAPABILITY_DSSS_OFDM (1<<13)
  210. /* 802.11g ERP information element */
  211. #define WLAN_ERP_NON_ERP_PRESENT (1<<0)
  212. #define WLAN_ERP_USE_PROTECTION (1<<1)
  213. #define WLAN_ERP_BARKER_PREAMBLE (1<<2)
  214. /* Status codes */
  215. enum ieee80211_statuscode {
  216. WLAN_STATUS_SUCCESS = 0,
  217. WLAN_STATUS_UNSPECIFIED_FAILURE = 1,
  218. WLAN_STATUS_CAPS_UNSUPPORTED = 10,
  219. WLAN_STATUS_REASSOC_NO_ASSOC = 11,
  220. WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12,
  221. WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13,
  222. WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14,
  223. WLAN_STATUS_CHALLENGE_FAIL = 15,
  224. WLAN_STATUS_AUTH_TIMEOUT = 16,
  225. WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17,
  226. WLAN_STATUS_ASSOC_DENIED_RATES = 18,
  227. /* 802.11b */
  228. WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19,
  229. WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20,
  230. WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21,
  231. /* 802.11h */
  232. WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22,
  233. WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23,
  234. WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24,
  235. /* 802.11g */
  236. WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25,
  237. WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26,
  238. /* 802.11i */
  239. WLAN_STATUS_INVALID_IE = 40,
  240. WLAN_STATUS_INVALID_GROUP_CIPHER = 41,
  241. WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42,
  242. WLAN_STATUS_INVALID_AKMP = 43,
  243. WLAN_STATUS_UNSUPP_RSN_VERSION = 44,
  244. WLAN_STATUS_INVALID_RSN_IE_CAP = 45,
  245. WLAN_STATUS_CIPHER_SUITE_REJECTED = 46,
  246. };
  247. /* Reason codes */
  248. enum ieee80211_reasoncode {
  249. WLAN_REASON_UNSPECIFIED = 1,
  250. WLAN_REASON_PREV_AUTH_NOT_VALID = 2,
  251. WLAN_REASON_DEAUTH_LEAVING = 3,
  252. WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4,
  253. WLAN_REASON_DISASSOC_AP_BUSY = 5,
  254. WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6,
  255. WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7,
  256. WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8,
  257. WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9,
  258. /* 802.11h */
  259. WLAN_REASON_DISASSOC_BAD_POWER = 10,
  260. WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11,
  261. /* 802.11i */
  262. WLAN_REASON_INVALID_IE = 13,
  263. WLAN_REASON_MIC_FAILURE = 14,
  264. WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15,
  265. WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16,
  266. WLAN_REASON_IE_DIFFERENT = 17,
  267. WLAN_REASON_INVALID_GROUP_CIPHER = 18,
  268. WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19,
  269. WLAN_REASON_INVALID_AKMP = 20,
  270. WLAN_REASON_UNSUPP_RSN_VERSION = 21,
  271. WLAN_REASON_INVALID_RSN_IE_CAP = 22,
  272. WLAN_REASON_IEEE8021X_FAILED = 23,
  273. WLAN_REASON_CIPHER_SUITE_REJECTED = 24,
  274. };
  275. /* Action categories - 802.11h */
  276. enum ieee80211_actioncategories {
  277. WLAN_ACTION_SPECTRUM_MGMT = 0,
  278. /* Reserved 1-127 */
  279. /* Error 128-255 */
  280. };
  281. /* Action details - 802.11h */
  282. enum ieee80211_actiondetails {
  283. WLAN_ACTION_CATEGORY_MEASURE_REQUEST = 0,
  284. WLAN_ACTION_CATEGORY_MEASURE_REPORT = 1,
  285. WLAN_ACTION_CATEGORY_TPC_REQUEST = 2,
  286. WLAN_ACTION_CATEGORY_TPC_REPORT = 3,
  287. WLAN_ACTION_CATEGORY_CHANNEL_SWITCH = 4,
  288. /* 5 - 255 Reserved */
  289. };
  290. #define IEEE80211_STATMASK_SIGNAL (1<<0)
  291. #define IEEE80211_STATMASK_RSSI (1<<1)
  292. #define IEEE80211_STATMASK_NOISE (1<<2)
  293. #define IEEE80211_STATMASK_RATE (1<<3)
  294. #define IEEE80211_STATMASK_WEMASK 0x7
  295. #define IEEE80211_CCK_MODULATION (1<<0)
  296. #define IEEE80211_OFDM_MODULATION (1<<1)
  297. #define IEEE80211_24GHZ_BAND (1<<0)
  298. #define IEEE80211_52GHZ_BAND (1<<1)
  299. #define IEEE80211_CCK_RATE_1MB 0x02
  300. #define IEEE80211_CCK_RATE_2MB 0x04
  301. #define IEEE80211_CCK_RATE_5MB 0x0B
  302. #define IEEE80211_CCK_RATE_11MB 0x16
  303. #define IEEE80211_OFDM_RATE_6MB 0x0C
  304. #define IEEE80211_OFDM_RATE_9MB 0x12
  305. #define IEEE80211_OFDM_RATE_12MB 0x18
  306. #define IEEE80211_OFDM_RATE_18MB 0x24
  307. #define IEEE80211_OFDM_RATE_24MB 0x30
  308. #define IEEE80211_OFDM_RATE_36MB 0x48
  309. #define IEEE80211_OFDM_RATE_48MB 0x60
  310. #define IEEE80211_OFDM_RATE_54MB 0x6C
  311. #define IEEE80211_BASIC_RATE_MASK 0x80
  312. #define IEEE80211_CCK_RATE_1MB_MASK (1<<0)
  313. #define IEEE80211_CCK_RATE_2MB_MASK (1<<1)
  314. #define IEEE80211_CCK_RATE_5MB_MASK (1<<2)
  315. #define IEEE80211_CCK_RATE_11MB_MASK (1<<3)
  316. #define IEEE80211_OFDM_RATE_6MB_MASK (1<<4)
  317. #define IEEE80211_OFDM_RATE_9MB_MASK (1<<5)
  318. #define IEEE80211_OFDM_RATE_12MB_MASK (1<<6)
  319. #define IEEE80211_OFDM_RATE_18MB_MASK (1<<7)
  320. #define IEEE80211_OFDM_RATE_24MB_MASK (1<<8)
  321. #define IEEE80211_OFDM_RATE_36MB_MASK (1<<9)
  322. #define IEEE80211_OFDM_RATE_48MB_MASK (1<<10)
  323. #define IEEE80211_OFDM_RATE_54MB_MASK (1<<11)
  324. #define IEEE80211_CCK_RATES_MASK 0x0000000F
  325. #define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \
  326. IEEE80211_CCK_RATE_2MB_MASK)
  327. #define IEEE80211_CCK_DEFAULT_RATES_MASK (IEEE80211_CCK_BASIC_RATES_MASK | \
  328. IEEE80211_CCK_RATE_5MB_MASK | \
  329. IEEE80211_CCK_RATE_11MB_MASK)
  330. #define IEEE80211_OFDM_RATES_MASK 0x00000FF0
  331. #define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \
  332. IEEE80211_OFDM_RATE_12MB_MASK | \
  333. IEEE80211_OFDM_RATE_24MB_MASK)
  334. #define IEEE80211_OFDM_DEFAULT_RATES_MASK (IEEE80211_OFDM_BASIC_RATES_MASK | \
  335. IEEE80211_OFDM_RATE_9MB_MASK | \
  336. IEEE80211_OFDM_RATE_18MB_MASK | \
  337. IEEE80211_OFDM_RATE_36MB_MASK | \
  338. IEEE80211_OFDM_RATE_48MB_MASK | \
  339. IEEE80211_OFDM_RATE_54MB_MASK)
  340. #define IEEE80211_DEFAULT_RATES_MASK (IEEE80211_OFDM_DEFAULT_RATES_MASK | \
  341. IEEE80211_CCK_DEFAULT_RATES_MASK)
  342. #define IEEE80211_NUM_OFDM_RATES 8
  343. #define IEEE80211_NUM_CCK_RATES 4
  344. #define IEEE80211_OFDM_SHIFT_MASK_A 4
  345. /* NOTE: This data is for statistical purposes; not all hardware provides this
  346. * information for frames received.
  347. * For ieee80211_rx_mgt, you need to set at least the 'len' parameter.
  348. */
  349. struct ieee80211_rx_stats {
  350. u32 mac_time;
  351. s8 rssi;
  352. u8 signal;
  353. u8 noise;
  354. u16 rate; /* in 100 kbps */
  355. u8 received_channel;
  356. u8 control;
  357. u8 mask;
  358. u8 freq;
  359. u16 len;
  360. u64 tsf;
  361. u32 beacon_time;
  362. };
  363. /* IEEE 802.11 requires that STA supports concurrent reception of at least
  364. * three fragmented frames. This define can be increased to support more
  365. * concurrent frames, but it should be noted that each entry can consume about
  366. * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
  367. #define IEEE80211_FRAG_CACHE_LEN 4
  368. struct ieee80211_frag_entry {
  369. unsigned long first_frag_time;
  370. unsigned int seq;
  371. unsigned int last_frag;
  372. struct sk_buff *skb;
  373. u8 src_addr[ETH_ALEN];
  374. u8 dst_addr[ETH_ALEN];
  375. };
  376. struct ieee80211_stats {
  377. unsigned int tx_unicast_frames;
  378. unsigned int tx_multicast_frames;
  379. unsigned int tx_fragments;
  380. unsigned int tx_unicast_octets;
  381. unsigned int tx_multicast_octets;
  382. unsigned int tx_deferred_transmissions;
  383. unsigned int tx_single_retry_frames;
  384. unsigned int tx_multiple_retry_frames;
  385. unsigned int tx_retry_limit_exceeded;
  386. unsigned int tx_discards;
  387. unsigned int rx_unicast_frames;
  388. unsigned int rx_multicast_frames;
  389. unsigned int rx_fragments;
  390. unsigned int rx_unicast_octets;
  391. unsigned int rx_multicast_octets;
  392. unsigned int rx_fcs_errors;
  393. unsigned int rx_discards_no_buffer;
  394. unsigned int tx_discards_wrong_sa;
  395. unsigned int rx_discards_undecryptable;
  396. unsigned int rx_message_in_msg_fragments;
  397. unsigned int rx_message_in_bad_msg_fragments;
  398. };
  399. struct ieee80211_device;
  400. #include "ieee80211_crypt.h"
  401. #define SEC_KEY_1 (1<<0)
  402. #define SEC_KEY_2 (1<<1)
  403. #define SEC_KEY_3 (1<<2)
  404. #define SEC_KEY_4 (1<<3)
  405. #define SEC_ACTIVE_KEY (1<<4)
  406. #define SEC_AUTH_MODE (1<<5)
  407. #define SEC_UNICAST_GROUP (1<<6)
  408. #define SEC_LEVEL (1<<7)
  409. #define SEC_ENABLED (1<<8)
  410. #define SEC_ENCRYPT (1<<9)
  411. #define SEC_LEVEL_0 0 /* None */
  412. #define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */
  413. #define SEC_LEVEL_2 2 /* Level 1 + TKIP */
  414. #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
  415. #define SEC_LEVEL_3 4 /* Level 2 + CCMP */
  416. #define SEC_ALG_NONE 0
  417. #define SEC_ALG_WEP 1
  418. #define SEC_ALG_TKIP 2
  419. #define SEC_ALG_CCMP 3
  420. #define WEP_KEYS 4
  421. #define WEP_KEY_LEN 13
  422. #define SCM_KEY_LEN 32
  423. #define SCM_TEMPORAL_KEY_LENGTH 16
  424. struct ieee80211_security {
  425. u16 active_key:2,
  426. enabled:1,
  427. auth_mode:2, auth_algo:4, unicast_uses_group:1, encrypt:1;
  428. u8 encode_alg[WEP_KEYS];
  429. u8 key_sizes[WEP_KEYS];
  430. u8 keys[WEP_KEYS][SCM_KEY_LEN];
  431. u8 level;
  432. u16 flags;
  433. } __attribute__ ((packed));
  434. /*
  435. 802.11 data frame from AP
  436. ,-------------------------------------------------------------------.
  437. Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
  438. |------|------|---------|---------|---------|------|---------|------|
  439. Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs |
  440. | | tion | (BSSID) | | | ence | data | |
  441. `-------------------------------------------------------------------'
  442. Total: 28-2340 bytes
  443. */
  444. #define BEACON_PROBE_SSID_ID_POSITION 12
  445. /* Management Frame Information Element Types */
  446. enum ieee80211_mfie {
  447. MFIE_TYPE_SSID = 0,
  448. MFIE_TYPE_RATES = 1,
  449. MFIE_TYPE_FH_SET = 2,
  450. MFIE_TYPE_DS_SET = 3,
  451. MFIE_TYPE_CF_SET = 4,
  452. MFIE_TYPE_TIM = 5,
  453. MFIE_TYPE_IBSS_SET = 6,
  454. MFIE_TYPE_COUNTRY = 7,
  455. MFIE_TYPE_HOP_PARAMS = 8,
  456. MFIE_TYPE_HOP_TABLE = 9,
  457. MFIE_TYPE_REQUEST = 10,
  458. MFIE_TYPE_CHALLENGE = 16,
  459. MFIE_TYPE_POWER_CONSTRAINT = 32,
  460. MFIE_TYPE_POWER_CAPABILITY = 33,
  461. MFIE_TYPE_TPC_REQUEST = 34,
  462. MFIE_TYPE_TPC_REPORT = 35,
  463. MFIE_TYPE_SUPP_CHANNELS = 36,
  464. MFIE_TYPE_CSA = 37,
  465. MFIE_TYPE_MEASURE_REQUEST = 38,
  466. MFIE_TYPE_MEASURE_REPORT = 39,
  467. MFIE_TYPE_QUIET = 40,
  468. MFIE_TYPE_IBSS_DFS = 41,
  469. MFIE_TYPE_ERP_INFO = 42,
  470. MFIE_TYPE_RSN = 48,
  471. MFIE_TYPE_RATES_EX = 50,
  472. MFIE_TYPE_GENERIC = 221,
  473. MFIE_TYPE_QOS_PARAMETER = 222,
  474. };
  475. /* Minimal header; can be used for passing 802.11 frames with sufficient
  476. * information to determine what type of underlying data type is actually
  477. * stored in the data. */
  478. struct ieee80211_hdr {
  479. __le16 frame_ctl;
  480. __le16 duration_id;
  481. u8 payload[0];
  482. } __attribute__ ((packed));
  483. struct ieee80211_hdr_1addr {
  484. __le16 frame_ctl;
  485. __le16 duration_id;
  486. u8 addr1[ETH_ALEN];
  487. u8 payload[0];
  488. } __attribute__ ((packed));
  489. struct ieee80211_hdr_2addr {
  490. __le16 frame_ctl;
  491. __le16 duration_id;
  492. u8 addr1[ETH_ALEN];
  493. u8 addr2[ETH_ALEN];
  494. u8 payload[0];
  495. } __attribute__ ((packed));
  496. struct ieee80211_hdr_3addr {
  497. __le16 frame_ctl;
  498. __le16 duration_id;
  499. u8 addr1[ETH_ALEN];
  500. u8 addr2[ETH_ALEN];
  501. u8 addr3[ETH_ALEN];
  502. __le16 seq_ctl;
  503. u8 payload[0];
  504. } __attribute__ ((packed));
  505. struct ieee80211_hdr_4addr {
  506. __le16 frame_ctl;
  507. __le16 duration_id;
  508. u8 addr1[ETH_ALEN];
  509. u8 addr2[ETH_ALEN];
  510. u8 addr3[ETH_ALEN];
  511. __le16 seq_ctl;
  512. u8 addr4[ETH_ALEN];
  513. u8 payload[0];
  514. } __attribute__ ((packed));
  515. struct ieee80211_hdr_3addrqos {
  516. __le16 frame_ctl;
  517. __le16 duration_id;
  518. u8 addr1[ETH_ALEN];
  519. u8 addr2[ETH_ALEN];
  520. u8 addr3[ETH_ALEN];
  521. __le16 seq_ctl;
  522. u8 payload[0];
  523. __le16 qos_ctl;
  524. } __attribute__ ((packed));
  525. struct ieee80211_hdr_4addrqos {
  526. __le16 frame_ctl;
  527. __le16 duration_id;
  528. u8 addr1[ETH_ALEN];
  529. u8 addr2[ETH_ALEN];
  530. u8 addr3[ETH_ALEN];
  531. __le16 seq_ctl;
  532. u8 addr4[ETH_ALEN];
  533. u8 payload[0];
  534. __le16 qos_ctl;
  535. } __attribute__ ((packed));
  536. struct ieee80211_info_element {
  537. u8 id;
  538. u8 len;
  539. u8 data[0];
  540. } __attribute__ ((packed));
  541. /*
  542. * These are the data types that can make up management packets
  543. *
  544. u16 auth_algorithm;
  545. u16 auth_sequence;
  546. u16 beacon_interval;
  547. u16 capability;
  548. u8 current_ap[ETH_ALEN];
  549. u16 listen_interval;
  550. struct {
  551. u16 association_id:14, reserved:2;
  552. } __attribute__ ((packed));
  553. u32 time_stamp[2];
  554. u16 reason;
  555. u16 status;
  556. */
  557. struct ieee80211_auth {
  558. struct ieee80211_hdr_3addr header;
  559. __le16 algorithm;
  560. __le16 transaction;
  561. __le16 status;
  562. /* challenge */
  563. struct ieee80211_info_element info_element[0];
  564. } __attribute__ ((packed));
  565. struct ieee80211_channel_switch {
  566. u8 id;
  567. u8 len;
  568. u8 mode;
  569. u8 channel;
  570. u8 count;
  571. } __attribute__ ((packed));
  572. struct ieee80211_action {
  573. struct ieee80211_hdr_3addr header;
  574. u8 category;
  575. u8 action;
  576. union {
  577. struct ieee80211_action_exchange {
  578. u8 token;
  579. struct ieee80211_info_element info_element[0];
  580. } exchange;
  581. struct ieee80211_channel_switch channel_switch;
  582. } format;
  583. } __attribute__ ((packed));
  584. struct ieee80211_disassoc {
  585. struct ieee80211_hdr_3addr header;
  586. __le16 reason;
  587. } __attribute__ ((packed));
  588. /* Alias deauth for disassoc */
  589. #define ieee80211_deauth ieee80211_disassoc
  590. struct ieee80211_probe_request {
  591. struct ieee80211_hdr_3addr header;
  592. /* SSID, supported rates */
  593. struct ieee80211_info_element info_element[0];
  594. } __attribute__ ((packed));
  595. struct ieee80211_probe_response {
  596. struct ieee80211_hdr_3addr header;
  597. u32 time_stamp[2];
  598. __le16 beacon_interval;
  599. __le16 capability;
  600. /* SSID, supported rates, FH params, DS params,
  601. * CF params, IBSS params, TIM (if beacon), RSN */
  602. struct ieee80211_info_element info_element[0];
  603. } __attribute__ ((packed));
  604. /* Alias beacon for probe_response */
  605. #define ieee80211_beacon ieee80211_probe_response
  606. struct ieee80211_assoc_request {
  607. struct ieee80211_hdr_3addr header;
  608. __le16 capability;
  609. __le16 listen_interval;
  610. /* SSID, supported rates, RSN */
  611. struct ieee80211_info_element info_element[0];
  612. } __attribute__ ((packed));
  613. struct ieee80211_reassoc_request {
  614. struct ieee80211_hdr_3addr header;
  615. __le16 capability;
  616. __le16 listen_interval;
  617. u8 current_ap[ETH_ALEN];
  618. struct ieee80211_info_element info_element[0];
  619. } __attribute__ ((packed));
  620. struct ieee80211_assoc_response {
  621. struct ieee80211_hdr_3addr header;
  622. __le16 capability;
  623. __le16 status;
  624. __le16 aid;
  625. /* supported rates */
  626. struct ieee80211_info_element info_element[0];
  627. } __attribute__ ((packed));
  628. struct ieee80211_txb {
  629. u8 nr_frags;
  630. u8 encrypted;
  631. u8 rts_included;
  632. u8 reserved;
  633. __le16 frag_size;
  634. __le16 payload_size;
  635. struct sk_buff *fragments[0];
  636. };
  637. /* SWEEP TABLE ENTRIES NUMBER */
  638. #define MAX_SWEEP_TAB_ENTRIES 42
  639. #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
  640. /* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs
  641. * only use 8, and then use extended rates for the remaining supported
  642. * rates. Other APs, however, stick all of their supported rates on the
  643. * main rates information element... */
  644. #define MAX_RATES_LENGTH ((u8)12)
  645. #define MAX_RATES_EX_LENGTH ((u8)16)
  646. #define MAX_NETWORK_COUNT 128
  647. #define CRC_LENGTH 4U
  648. #define MAX_WPA_IE_LEN 64
  649. #define NETWORK_EMPTY_ESSID (1<<0)
  650. #define NETWORK_HAS_OFDM (1<<1)
  651. #define NETWORK_HAS_CCK (1<<2)
  652. /* QoS structure */
  653. #define NETWORK_HAS_QOS_PARAMETERS (1<<3)
  654. #define NETWORK_HAS_QOS_INFORMATION (1<<4)
  655. #define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \
  656. NETWORK_HAS_QOS_INFORMATION)
  657. /* 802.11h */
  658. #define NETWORK_HAS_POWER_CONSTRAINT (1<<5)
  659. #define NETWORK_HAS_CSA (1<<6)
  660. #define NETWORK_HAS_QUIET (1<<7)
  661. #define NETWORK_HAS_IBSS_DFS (1<<8)
  662. #define NETWORK_HAS_TPC_REPORT (1<<9)
  663. #define NETWORK_HAS_ERP_VALUE (1<<10)
  664. #define QOS_QUEUE_NUM 4
  665. #define QOS_OUI_LEN 3
  666. #define QOS_OUI_TYPE 2
  667. #define QOS_ELEMENT_ID 221
  668. #define QOS_OUI_INFO_SUB_TYPE 0
  669. #define QOS_OUI_PARAM_SUB_TYPE 1
  670. #define QOS_VERSION_1 1
  671. #define QOS_AIFSN_MIN_VALUE 2
  672. struct ieee80211_qos_information_element {
  673. u8 elementID;
  674. u8 length;
  675. u8 qui[QOS_OUI_LEN];
  676. u8 qui_type;
  677. u8 qui_subtype;
  678. u8 version;
  679. u8 ac_info;
  680. } __attribute__ ((packed));
  681. struct ieee80211_qos_ac_parameter {
  682. u8 aci_aifsn;
  683. u8 ecw_min_max;
  684. __le16 tx_op_limit;
  685. } __attribute__ ((packed));
  686. struct ieee80211_qos_parameter_info {
  687. struct ieee80211_qos_information_element info_element;
  688. u8 reserved;
  689. struct ieee80211_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM];
  690. } __attribute__ ((packed));
  691. struct ieee80211_qos_parameters {
  692. __le16 cw_min[QOS_QUEUE_NUM];
  693. __le16 cw_max[QOS_QUEUE_NUM];
  694. u8 aifs[QOS_QUEUE_NUM];
  695. u8 flag[QOS_QUEUE_NUM];
  696. __le16 tx_op_limit[QOS_QUEUE_NUM];
  697. } __attribute__ ((packed));
  698. struct ieee80211_qos_data {
  699. struct ieee80211_qos_parameters parameters;
  700. int active;
  701. int supported;
  702. u8 param_count;
  703. u8 old_param_count;
  704. };
  705. struct ieee80211_tim_parameters {
  706. u8 tim_count;
  707. u8 tim_period;
  708. } __attribute__ ((packed));
  709. /*******************************************************/
  710. enum { /* ieee80211_basic_report.map */
  711. IEEE80211_BASIC_MAP_BSS = (1 << 0),
  712. IEEE80211_BASIC_MAP_OFDM = (1 << 1),
  713. IEEE80211_BASIC_MAP_UNIDENTIFIED = (1 << 2),
  714. IEEE80211_BASIC_MAP_RADAR = (1 << 3),
  715. IEEE80211_BASIC_MAP_UNMEASURED = (1 << 4),
  716. /* Bits 5-7 are reserved */
  717. };
  718. struct ieee80211_basic_report {
  719. u8 channel;
  720. __le64 start_time;
  721. __le16 duration;
  722. u8 map;
  723. } __attribute__ ((packed));
  724. enum { /* ieee80211_measurement_request.mode */
  725. /* Bit 0 is reserved */
  726. IEEE80211_MEASUREMENT_ENABLE = (1 << 1),
  727. IEEE80211_MEASUREMENT_REQUEST = (1 << 2),
  728. IEEE80211_MEASUREMENT_REPORT = (1 << 3),
  729. /* Bits 4-7 are reserved */
  730. };
  731. enum {
  732. IEEE80211_REPORT_BASIC = 0, /* required */
  733. IEEE80211_REPORT_CCA = 1, /* optional */
  734. IEEE80211_REPORT_RPI = 2, /* optional */
  735. /* 3-255 reserved */
  736. };
  737. struct ieee80211_measurement_params {
  738. u8 channel;
  739. __le64 start_time;
  740. __le16 duration;
  741. } __attribute__ ((packed));
  742. struct ieee80211_measurement_request {
  743. struct ieee80211_info_element ie;
  744. u8 token;
  745. u8 mode;
  746. u8 type;
  747. struct ieee80211_measurement_params params[0];
  748. } __attribute__ ((packed));
  749. struct ieee80211_measurement_report {
  750. struct ieee80211_info_element ie;
  751. u8 token;
  752. u8 mode;
  753. u8 type;
  754. union {
  755. struct ieee80211_basic_report basic[0];
  756. } u;
  757. } __attribute__ ((packed));
  758. struct ieee80211_tpc_report {
  759. u8 transmit_power;
  760. u8 link_margin;
  761. } __attribute__ ((packed));
  762. struct ieee80211_channel_map {
  763. u8 channel;
  764. u8 map;
  765. } __attribute__ ((packed));
  766. struct ieee80211_ibss_dfs {
  767. struct ieee80211_info_element ie;
  768. u8 owner[ETH_ALEN];
  769. u8 recovery_interval;
  770. struct ieee80211_channel_map channel_map[0];
  771. };
  772. struct ieee80211_csa {
  773. u8 mode;
  774. u8 channel;
  775. u8 count;
  776. } __attribute__ ((packed));
  777. struct ieee80211_quiet {
  778. u8 count;
  779. u8 period;
  780. u8 duration;
  781. u8 offset;
  782. } __attribute__ ((packed));
  783. struct ieee80211_network {
  784. /* These entries are used to identify a unique network */
  785. u8 bssid[ETH_ALEN];
  786. u8 channel;
  787. /* Ensure null-terminated for any debug msgs */
  788. u8 ssid[IW_ESSID_MAX_SIZE + 1];
  789. u8 ssid_len;
  790. struct ieee80211_qos_data qos_data;
  791. /* These are network statistics */
  792. struct ieee80211_rx_stats stats;
  793. u16 capability;
  794. u8 rates[MAX_RATES_LENGTH];
  795. u8 rates_len;
  796. u8 rates_ex[MAX_RATES_EX_LENGTH];
  797. u8 rates_ex_len;
  798. unsigned long last_scanned;
  799. u8 mode;
  800. u32 flags;
  801. u32 last_associate;
  802. u32 time_stamp[2];
  803. u16 beacon_interval;
  804. u16 listen_interval;
  805. u16 atim_window;
  806. u8 erp_value;
  807. u8 wpa_ie[MAX_WPA_IE_LEN];
  808. size_t wpa_ie_len;
  809. u8 rsn_ie[MAX_WPA_IE_LEN];
  810. size_t rsn_ie_len;
  811. struct ieee80211_tim_parameters tim;
  812. /* 802.11h info */
  813. /* Power Constraint - mandatory if spctrm mgmt required */
  814. u8 power_constraint;
  815. /* TPC Report - mandatory if spctrm mgmt required */
  816. struct ieee80211_tpc_report tpc_report;
  817. /* IBSS DFS - mandatory if spctrm mgmt required and IBSS
  818. * NOTE: This is variable length and so must be allocated dynamically */
  819. struct ieee80211_ibss_dfs *ibss_dfs;
  820. /* Channel Switch Announcement - optional if spctrm mgmt required */
  821. struct ieee80211_csa csa;
  822. /* Quiet - optional if spctrm mgmt required */
  823. struct ieee80211_quiet quiet;
  824. struct list_head list;
  825. };
  826. enum ieee80211_state {
  827. IEEE80211_UNINITIALIZED = 0,
  828. IEEE80211_INITIALIZED,
  829. IEEE80211_ASSOCIATING,
  830. IEEE80211_ASSOCIATED,
  831. IEEE80211_AUTHENTICATING,
  832. IEEE80211_AUTHENTICATED,
  833. IEEE80211_SHUTDOWN
  834. };
  835. #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
  836. #define DEFAULT_FTS 2346
  837. #define CFG_IEEE80211_RESERVE_FCS (1<<0)
  838. #define CFG_IEEE80211_COMPUTE_FCS (1<<1)
  839. #define CFG_IEEE80211_RTS (1<<2)
  840. #define IEEE80211_24GHZ_MIN_CHANNEL 1
  841. #define IEEE80211_24GHZ_MAX_CHANNEL 14
  842. #define IEEE80211_24GHZ_CHANNELS (IEEE80211_24GHZ_MAX_CHANNEL - \
  843. IEEE80211_24GHZ_MIN_CHANNEL + 1)
  844. #define IEEE80211_52GHZ_MIN_CHANNEL 34
  845. #define IEEE80211_52GHZ_MAX_CHANNEL 165
  846. #define IEEE80211_52GHZ_CHANNELS (IEEE80211_52GHZ_MAX_CHANNEL - \
  847. IEEE80211_52GHZ_MIN_CHANNEL + 1)
  848. enum {
  849. IEEE80211_CH_PASSIVE_ONLY = (1 << 0),
  850. IEEE80211_CH_80211H_RULES = (1 << 1),
  851. IEEE80211_CH_B_ONLY = (1 << 2),
  852. IEEE80211_CH_NO_IBSS = (1 << 3),
  853. IEEE80211_CH_UNIFORM_SPREADING = (1 << 4),
  854. IEEE80211_CH_RADAR_DETECT = (1 << 5),
  855. IEEE80211_CH_INVALID = (1 << 6),
  856. };
  857. struct ieee80211_channel {
  858. u32 freq; /* in MHz */
  859. u8 channel;
  860. u8 flags;
  861. u8 max_power; /* in dBm */
  862. };
  863. struct ieee80211_geo {
  864. u8 name[4];
  865. u8 bg_channels;
  866. u8 a_channels;
  867. struct ieee80211_channel bg[IEEE80211_24GHZ_CHANNELS];
  868. struct ieee80211_channel a[IEEE80211_52GHZ_CHANNELS];
  869. };
  870. struct ieee80211_device {
  871. struct net_device *dev;
  872. struct ieee80211_security sec;
  873. /* Bookkeeping structures */
  874. struct net_device_stats stats;
  875. struct ieee80211_stats ieee_stats;
  876. struct ieee80211_geo geo;
  877. /* Probe / Beacon management */
  878. struct list_head network_free_list;
  879. struct list_head network_list;
  880. struct ieee80211_network *networks;
  881. int scans;
  882. int scan_age;
  883. int iw_mode; /* operating mode (IW_MODE_*) */
  884. struct iw_spy_data spy_data; /* iwspy support */
  885. spinlock_t lock;
  886. int tx_headroom; /* Set to size of any additional room needed at front
  887. * of allocated Tx SKBs */
  888. u32 config;
  889. /* WEP and other encryption related settings at the device level */
  890. int open_wep; /* Set to 1 to allow unencrypted frames */
  891. int reset_on_keychange; /* Set to 1 if the HW needs to be reset on
  892. * WEP key changes */
  893. /* If the host performs {en,de}cryption, then set to 1 */
  894. int host_encrypt;
  895. int host_encrypt_msdu;
  896. int host_decrypt;
  897. /* host performs multicast decryption */
  898. int host_mc_decrypt;
  899. /* host should strip IV and ICV from protected frames */
  900. /* meaningful only when hardware decryption is being used */
  901. int host_strip_iv_icv;
  902. int host_open_frag;
  903. int host_build_iv;
  904. int ieee802_1x; /* is IEEE 802.1X used */
  905. /* WPA data */
  906. int wpa_enabled;
  907. int drop_unencrypted;
  908. int privacy_invoked;
  909. size_t wpa_ie_len;
  910. u8 *wpa_ie;
  911. struct list_head crypt_deinit_list;
  912. struct ieee80211_crypt_data *crypt[WEP_KEYS];
  913. int tx_keyidx; /* default TX key index (crypt[tx_keyidx]) */
  914. struct timer_list crypt_deinit_timer;
  915. int crypt_quiesced;
  916. int bcrx_sta_key; /* use individual keys to override default keys even
  917. * with RX of broad/multicast frames */
  918. /* Fragmentation structures */
  919. struct ieee80211_frag_entry frag_cache[IEEE80211_FRAG_CACHE_LEN];
  920. unsigned int frag_next_idx;
  921. u16 fts; /* Fragmentation Threshold */
  922. u16 rts; /* RTS threshold */
  923. /* Association info */
  924. u8 bssid[ETH_ALEN];
  925. enum ieee80211_state state;
  926. int mode; /* A, B, G */
  927. int modulation; /* CCK, OFDM */
  928. int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */
  929. int abg_true; /* ABG flag */
  930. int perfect_rssi;
  931. int worst_rssi;
  932. u16 prev_seq_ctl; /* used to drop duplicate frames */
  933. /* Callback functions */
  934. void (*set_security) (struct net_device * dev,
  935. struct ieee80211_security * sec);
  936. int (*hard_start_xmit) (struct ieee80211_txb * txb,
  937. struct net_device * dev, int pri);
  938. int (*reset_port) (struct net_device * dev);
  939. int (*is_queue_full) (struct net_device * dev, int pri);
  940. int (*handle_management) (struct net_device * dev,
  941. struct ieee80211_network * network, u16 type);
  942. int (*is_qos_active) (struct net_device *dev, struct sk_buff *skb);
  943. /* Typical STA methods */
  944. int (*handle_auth) (struct net_device * dev,
  945. struct ieee80211_auth * auth);
  946. int (*handle_deauth) (struct net_device * dev,
  947. struct ieee80211_deauth * auth);
  948. int (*handle_action) (struct net_device * dev,
  949. struct ieee80211_action * action,
  950. struct ieee80211_rx_stats * stats);
  951. int (*handle_disassoc) (struct net_device * dev,
  952. struct ieee80211_disassoc * assoc);
  953. int (*handle_beacon) (struct net_device * dev,
  954. struct ieee80211_beacon * beacon,
  955. struct ieee80211_network * network);
  956. int (*handle_probe_response) (struct net_device * dev,
  957. struct ieee80211_probe_response * resp,
  958. struct ieee80211_network * network);
  959. int (*handle_probe_request) (struct net_device * dev,
  960. struct ieee80211_probe_request * req,
  961. struct ieee80211_rx_stats * stats);
  962. int (*handle_assoc_response) (struct net_device * dev,
  963. struct ieee80211_assoc_response * resp,
  964. struct ieee80211_network * network);
  965. /* Typical AP methods */
  966. int (*handle_assoc_request) (struct net_device * dev);
  967. int (*handle_reassoc_request) (struct net_device * dev,
  968. struct ieee80211_reassoc_request * req);
  969. /* This must be the last item so that it points to the data
  970. * allocated beyond this structure by alloc_ieee80211 */
  971. u8 priv[0];
  972. };
  973. #define IEEE_A (1<<0)
  974. #define IEEE_B (1<<1)
  975. #define IEEE_G (1<<2)
  976. #define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
  977. static inline void *ieee80211_priv(struct net_device *dev)
  978. {
  979. return ((struct ieee80211_device *)netdev_priv(dev))->priv;
  980. }
  981. static inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
  982. {
  983. /* Single white space is for Linksys APs */
  984. if (essid_len == 1 && essid[0] == ' ')
  985. return 1;
  986. /* Otherwise, if the entire essid is 0, we assume it is hidden */
  987. while (essid_len) {
  988. essid_len--;
  989. if (essid[essid_len] != '\0')
  990. return 0;
  991. }
  992. return 1;
  993. }
  994. static inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee,
  995. int mode)
  996. {
  997. /*
  998. * It is possible for both access points and our device to support
  999. * combinations of modes, so as long as there is one valid combination
  1000. * of ap/device supported modes, then return success
  1001. *
  1002. */
  1003. if ((mode & IEEE_A) &&
  1004. (ieee->modulation & IEEE80211_OFDM_MODULATION) &&
  1005. (ieee->freq_band & IEEE80211_52GHZ_BAND))
  1006. return 1;
  1007. if ((mode & IEEE_G) &&
  1008. (ieee->modulation & IEEE80211_OFDM_MODULATION) &&
  1009. (ieee->freq_band & IEEE80211_24GHZ_BAND))
  1010. return 1;
  1011. if ((mode & IEEE_B) &&
  1012. (ieee->modulation & IEEE80211_CCK_MODULATION) &&
  1013. (ieee->freq_band & IEEE80211_24GHZ_BAND))
  1014. return 1;
  1015. return 0;
  1016. }
  1017. static inline int ieee80211_get_hdrlen(u16 fc)
  1018. {
  1019. int hdrlen = IEEE80211_3ADDR_LEN;
  1020. u16 stype = WLAN_FC_GET_STYPE(fc);
  1021. switch (WLAN_FC_GET_TYPE(fc)) {
  1022. case IEEE80211_FTYPE_DATA:
  1023. if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
  1024. hdrlen = IEEE80211_4ADDR_LEN;
  1025. if (stype & IEEE80211_STYPE_QOS_DATA)
  1026. hdrlen += 2;
  1027. break;
  1028. case IEEE80211_FTYPE_CTL:
  1029. switch (WLAN_FC_GET_STYPE(fc)) {
  1030. case IEEE80211_STYPE_CTS:
  1031. case IEEE80211_STYPE_ACK:
  1032. hdrlen = IEEE80211_1ADDR_LEN;
  1033. break;
  1034. default:
  1035. hdrlen = IEEE80211_2ADDR_LEN;
  1036. break;
  1037. }
  1038. break;
  1039. }
  1040. return hdrlen;
  1041. }
  1042. static inline u8 *ieee80211_get_payload(struct ieee80211_hdr *hdr)
  1043. {
  1044. switch (ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl))) {
  1045. case IEEE80211_1ADDR_LEN:
  1046. return ((struct ieee80211_hdr_1addr *)hdr)->payload;
  1047. case IEEE80211_2ADDR_LEN:
  1048. return ((struct ieee80211_hdr_2addr *)hdr)->payload;
  1049. case IEEE80211_3ADDR_LEN:
  1050. return ((struct ieee80211_hdr_3addr *)hdr)->payload;
  1051. case IEEE80211_4ADDR_LEN:
  1052. return ((struct ieee80211_hdr_4addr *)hdr)->payload;
  1053. }
  1054. return NULL;
  1055. }
  1056. static inline int ieee80211_is_ofdm_rate(u8 rate)
  1057. {
  1058. switch (rate & ~IEEE80211_BASIC_RATE_MASK) {
  1059. case IEEE80211_OFDM_RATE_6MB:
  1060. case IEEE80211_OFDM_RATE_9MB:
  1061. case IEEE80211_OFDM_RATE_12MB:
  1062. case IEEE80211_OFDM_RATE_18MB:
  1063. case IEEE80211_OFDM_RATE_24MB:
  1064. case IEEE80211_OFDM_RATE_36MB:
  1065. case IEEE80211_OFDM_RATE_48MB:
  1066. case IEEE80211_OFDM_RATE_54MB:
  1067. return 1;
  1068. }
  1069. return 0;
  1070. }
  1071. static inline int ieee80211_is_cck_rate(u8 rate)
  1072. {
  1073. switch (rate & ~IEEE80211_BASIC_RATE_MASK) {
  1074. case IEEE80211_CCK_RATE_1MB:
  1075. case IEEE80211_CCK_RATE_2MB:
  1076. case IEEE80211_CCK_RATE_5MB:
  1077. case IEEE80211_CCK_RATE_11MB:
  1078. return 1;
  1079. }
  1080. return 0;
  1081. }
  1082. /* ieee80211.c */
  1083. extern void free_ieee80211(struct net_device *dev);
  1084. extern struct net_device *alloc_ieee80211(int sizeof_priv);
  1085. extern int ieee80211_set_encryption(struct ieee80211_device *ieee);
  1086. /* ieee80211_tx.c */
  1087. extern int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev);
  1088. extern void ieee80211_txb_free(struct ieee80211_txb *);
  1089. extern int ieee80211_tx_frame(struct ieee80211_device *ieee,
  1090. struct ieee80211_hdr *frame, int hdr_len,
  1091. int total_len, int encrypt_mpdu);
  1092. /* ieee80211_rx.c */
  1093. extern void ieee80211_rx_any(struct ieee80211_device *ieee,
  1094. struct sk_buff *skb, struct ieee80211_rx_stats *stats);
  1095. extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
  1096. struct ieee80211_rx_stats *rx_stats);
  1097. /* make sure to set stats->len */
  1098. extern void ieee80211_rx_mgt(struct ieee80211_device *ieee,
  1099. struct ieee80211_hdr_4addr *header,
  1100. struct ieee80211_rx_stats *stats);
  1101. extern void ieee80211_network_reset(struct ieee80211_network *network);
  1102. /* ieee80211_geo.c */
  1103. extern const struct ieee80211_geo *ieee80211_get_geo(struct ieee80211_device
  1104. *ieee);
  1105. extern int ieee80211_set_geo(struct ieee80211_device *ieee,
  1106. const struct ieee80211_geo *geo);
  1107. extern int ieee80211_is_valid_channel(struct ieee80211_device *ieee,
  1108. u8 channel);
  1109. extern int ieee80211_channel_to_index(struct ieee80211_device *ieee,
  1110. u8 channel);
  1111. extern u8 ieee80211_freq_to_channel(struct ieee80211_device *ieee, u32 freq);
  1112. extern u8 ieee80211_get_channel_flags(struct ieee80211_device *ieee,
  1113. u8 channel);
  1114. extern const struct ieee80211_channel *ieee80211_get_channel(struct
  1115. ieee80211_device
  1116. *ieee, u8 channel);
  1117. extern u32 ieee80211_channel_to_freq(struct ieee80211_device * ieee,
  1118. u8 channel);
  1119. /* ieee80211_wx.c */
  1120. extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
  1121. struct iw_request_info *info,
  1122. union iwreq_data *wrqu, char *key);
  1123. extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
  1124. struct iw_request_info *info,
  1125. union iwreq_data *wrqu, char *key);
  1126. extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
  1127. struct iw_request_info *info,
  1128. union iwreq_data *wrqu, char *key);
  1129. extern int ieee80211_wx_set_encodeext(struct ieee80211_device *ieee,
  1130. struct iw_request_info *info,
  1131. union iwreq_data *wrqu, char *extra);
  1132. extern int ieee80211_wx_get_encodeext(struct ieee80211_device *ieee,
  1133. struct iw_request_info *info,
  1134. union iwreq_data *wrqu, char *extra);
  1135. extern int ieee80211_wx_set_auth(struct net_device *dev,
  1136. struct iw_request_info *info,
  1137. union iwreq_data *wrqu,
  1138. char *extra);
  1139. extern int ieee80211_wx_get_auth(struct net_device *dev,
  1140. struct iw_request_info *info,
  1141. union iwreq_data *wrqu,
  1142. char *extra);
  1143. static inline void ieee80211_increment_scans(struct ieee80211_device *ieee)
  1144. {
  1145. ieee->scans++;
  1146. }
  1147. static inline int ieee80211_get_scans(struct ieee80211_device *ieee)
  1148. {
  1149. return ieee->scans;
  1150. }
  1151. #endif /* IEEE80211_H */