ieee80211.h 38 KB

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