ieee80211.h 38 KB

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