ieee80211.h 32 KB

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