ieee80211.h 38 KB

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