ieee80211.h 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083
  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_SHORT_SLOT_TIME (1<<10)
  194. #define WLAN_CAPABILITY_OSSS_OFDM (1<<13)
  195. /* Status codes */
  196. enum ieee80211_statuscode {
  197. WLAN_STATUS_SUCCESS = 0,
  198. WLAN_STATUS_UNSPECIFIED_FAILURE = 1,
  199. WLAN_STATUS_CAPS_UNSUPPORTED = 10,
  200. WLAN_STATUS_REASSOC_NO_ASSOC = 11,
  201. WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12,
  202. WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13,
  203. WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14,
  204. WLAN_STATUS_CHALLENGE_FAIL = 15,
  205. WLAN_STATUS_AUTH_TIMEOUT = 16,
  206. WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17,
  207. WLAN_STATUS_ASSOC_DENIED_RATES = 18,
  208. /* 802.11b */
  209. WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19,
  210. WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20,
  211. WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21,
  212. /* 802.11h */
  213. WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22,
  214. WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23,
  215. WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24,
  216. /* 802.11g */
  217. WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25,
  218. WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26,
  219. /* 802.11i */
  220. WLAN_STATUS_INVALID_IE = 40,
  221. WLAN_STATUS_INVALID_GROUP_CIPHER = 41,
  222. WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42,
  223. WLAN_STATUS_INVALID_AKMP = 43,
  224. WLAN_STATUS_UNSUPP_RSN_VERSION = 44,
  225. WLAN_STATUS_INVALID_RSN_IE_CAP = 45,
  226. WLAN_STATUS_CIPHER_SUITE_REJECTED = 46,
  227. };
  228. /* Reason codes */
  229. enum ieee80211_reasoncode {
  230. WLAN_REASON_UNSPECIFIED = 1,
  231. WLAN_REASON_PREV_AUTH_NOT_VALID = 2,
  232. WLAN_REASON_DEAUTH_LEAVING = 3,
  233. WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4,
  234. WLAN_REASON_DISASSOC_AP_BUSY = 5,
  235. WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6,
  236. WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7,
  237. WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8,
  238. WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9,
  239. /* 802.11h */
  240. WLAN_REASON_DISASSOC_BAD_POWER = 10,
  241. WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11,
  242. /* 802.11i */
  243. WLAN_REASON_INVALID_IE = 13,
  244. WLAN_REASON_MIC_FAILURE = 14,
  245. WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15,
  246. WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16,
  247. WLAN_REASON_IE_DIFFERENT = 17,
  248. WLAN_REASON_INVALID_GROUP_CIPHER = 18,
  249. WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19,
  250. WLAN_REASON_INVALID_AKMP = 20,
  251. WLAN_REASON_UNSUPP_RSN_VERSION = 21,
  252. WLAN_REASON_INVALID_RSN_IE_CAP = 22,
  253. WLAN_REASON_IEEE8021X_FAILED = 23,
  254. WLAN_REASON_CIPHER_SUITE_REJECTED = 24,
  255. };
  256. #define IEEE80211_STATMASK_SIGNAL (1<<0)
  257. #define IEEE80211_STATMASK_RSSI (1<<1)
  258. #define IEEE80211_STATMASK_NOISE (1<<2)
  259. #define IEEE80211_STATMASK_RATE (1<<3)
  260. #define IEEE80211_STATMASK_WEMASK 0x7
  261. #define IEEE80211_CCK_MODULATION (1<<0)
  262. #define IEEE80211_OFDM_MODULATION (1<<1)
  263. #define IEEE80211_24GHZ_BAND (1<<0)
  264. #define IEEE80211_52GHZ_BAND (1<<1)
  265. #define IEEE80211_CCK_RATE_1MB 0x02
  266. #define IEEE80211_CCK_RATE_2MB 0x04
  267. #define IEEE80211_CCK_RATE_5MB 0x0B
  268. #define IEEE80211_CCK_RATE_11MB 0x16
  269. #define IEEE80211_OFDM_RATE_6MB 0x0C
  270. #define IEEE80211_OFDM_RATE_9MB 0x12
  271. #define IEEE80211_OFDM_RATE_12MB 0x18
  272. #define IEEE80211_OFDM_RATE_18MB 0x24
  273. #define IEEE80211_OFDM_RATE_24MB 0x30
  274. #define IEEE80211_OFDM_RATE_36MB 0x48
  275. #define IEEE80211_OFDM_RATE_48MB 0x60
  276. #define IEEE80211_OFDM_RATE_54MB 0x6C
  277. #define IEEE80211_BASIC_RATE_MASK 0x80
  278. #define IEEE80211_CCK_RATE_1MB_MASK (1<<0)
  279. #define IEEE80211_CCK_RATE_2MB_MASK (1<<1)
  280. #define IEEE80211_CCK_RATE_5MB_MASK (1<<2)
  281. #define IEEE80211_CCK_RATE_11MB_MASK (1<<3)
  282. #define IEEE80211_OFDM_RATE_6MB_MASK (1<<4)
  283. #define IEEE80211_OFDM_RATE_9MB_MASK (1<<5)
  284. #define IEEE80211_OFDM_RATE_12MB_MASK (1<<6)
  285. #define IEEE80211_OFDM_RATE_18MB_MASK (1<<7)
  286. #define IEEE80211_OFDM_RATE_24MB_MASK (1<<8)
  287. #define IEEE80211_OFDM_RATE_36MB_MASK (1<<9)
  288. #define IEEE80211_OFDM_RATE_48MB_MASK (1<<10)
  289. #define IEEE80211_OFDM_RATE_54MB_MASK (1<<11)
  290. #define IEEE80211_CCK_RATES_MASK 0x0000000F
  291. #define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \
  292. IEEE80211_CCK_RATE_2MB_MASK)
  293. #define IEEE80211_CCK_DEFAULT_RATES_MASK (IEEE80211_CCK_BASIC_RATES_MASK | \
  294. IEEE80211_CCK_RATE_5MB_MASK | \
  295. IEEE80211_CCK_RATE_11MB_MASK)
  296. #define IEEE80211_OFDM_RATES_MASK 0x00000FF0
  297. #define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \
  298. IEEE80211_OFDM_RATE_12MB_MASK | \
  299. IEEE80211_OFDM_RATE_24MB_MASK)
  300. #define IEEE80211_OFDM_DEFAULT_RATES_MASK (IEEE80211_OFDM_BASIC_RATES_MASK | \
  301. IEEE80211_OFDM_RATE_9MB_MASK | \
  302. IEEE80211_OFDM_RATE_18MB_MASK | \
  303. IEEE80211_OFDM_RATE_36MB_MASK | \
  304. IEEE80211_OFDM_RATE_48MB_MASK | \
  305. IEEE80211_OFDM_RATE_54MB_MASK)
  306. #define IEEE80211_DEFAULT_RATES_MASK (IEEE80211_OFDM_DEFAULT_RATES_MASK | \
  307. IEEE80211_CCK_DEFAULT_RATES_MASK)
  308. #define IEEE80211_NUM_OFDM_RATES 8
  309. #define IEEE80211_NUM_CCK_RATES 4
  310. #define IEEE80211_OFDM_SHIFT_MASK_A 4
  311. /* NOTE: This data is for statistical purposes; not all hardware provides this
  312. * information for frames received. Not setting these will not cause
  313. * any adverse affects. */
  314. struct ieee80211_rx_stats {
  315. u32 mac_time;
  316. s8 rssi;
  317. u8 signal;
  318. u8 noise;
  319. u16 rate; /* in 100 kbps */
  320. u8 received_channel;
  321. u8 control;
  322. u8 mask;
  323. u8 freq;
  324. u16 len;
  325. };
  326. /* IEEE 802.11 requires that STA supports concurrent reception of at least
  327. * three fragmented frames. This define can be increased to support more
  328. * concurrent frames, but it should be noted that each entry can consume about
  329. * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
  330. #define IEEE80211_FRAG_CACHE_LEN 4
  331. struct ieee80211_frag_entry {
  332. unsigned long first_frag_time;
  333. unsigned int seq;
  334. unsigned int last_frag;
  335. struct sk_buff *skb;
  336. u8 src_addr[ETH_ALEN];
  337. u8 dst_addr[ETH_ALEN];
  338. };
  339. struct ieee80211_stats {
  340. unsigned int tx_unicast_frames;
  341. unsigned int tx_multicast_frames;
  342. unsigned int tx_fragments;
  343. unsigned int tx_unicast_octets;
  344. unsigned int tx_multicast_octets;
  345. unsigned int tx_deferred_transmissions;
  346. unsigned int tx_single_retry_frames;
  347. unsigned int tx_multiple_retry_frames;
  348. unsigned int tx_retry_limit_exceeded;
  349. unsigned int tx_discards;
  350. unsigned int rx_unicast_frames;
  351. unsigned int rx_multicast_frames;
  352. unsigned int rx_fragments;
  353. unsigned int rx_unicast_octets;
  354. unsigned int rx_multicast_octets;
  355. unsigned int rx_fcs_errors;
  356. unsigned int rx_discards_no_buffer;
  357. unsigned int tx_discards_wrong_sa;
  358. unsigned int rx_discards_undecryptable;
  359. unsigned int rx_message_in_msg_fragments;
  360. unsigned int rx_message_in_bad_msg_fragments;
  361. };
  362. struct ieee80211_device;
  363. #include "ieee80211_crypt.h"
  364. #define SEC_KEY_1 (1<<0)
  365. #define SEC_KEY_2 (1<<1)
  366. #define SEC_KEY_3 (1<<2)
  367. #define SEC_KEY_4 (1<<3)
  368. #define SEC_ACTIVE_KEY (1<<4)
  369. #define SEC_AUTH_MODE (1<<5)
  370. #define SEC_UNICAST_GROUP (1<<6)
  371. #define SEC_LEVEL (1<<7)
  372. #define SEC_ENABLED (1<<8)
  373. #define SEC_ENCRYPT (1<<9)
  374. #define SEC_LEVEL_0 0 /* None */
  375. #define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */
  376. #define SEC_LEVEL_2 2 /* Level 1 + TKIP */
  377. #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
  378. #define SEC_LEVEL_3 4 /* Level 2 + CCMP */
  379. #define SEC_ALG_NONE 0
  380. #define SEC_ALG_WEP 1
  381. #define SEC_ALG_TKIP 2
  382. #define SEC_ALG_CCMP 3
  383. #define WEP_KEYS 4
  384. #define WEP_KEY_LEN 13
  385. #define SCM_KEY_LEN 32
  386. #define SCM_TEMPORAL_KEY_LENGTH 16
  387. struct ieee80211_security {
  388. u16 active_key:2,
  389. enabled:1,
  390. auth_mode:2, auth_algo:4, unicast_uses_group:1, encrypt:1;
  391. u8 encode_alg[WEP_KEYS];
  392. u8 key_sizes[WEP_KEYS];
  393. u8 keys[WEP_KEYS][SCM_KEY_LEN];
  394. u8 level;
  395. u16 flags;
  396. } __attribute__ ((packed));
  397. /*
  398. 802.11 data frame from AP
  399. ,-------------------------------------------------------------------.
  400. Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
  401. |------|------|---------|---------|---------|------|---------|------|
  402. Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs |
  403. | | tion | (BSSID) | | | ence | data | |
  404. `-------------------------------------------------------------------'
  405. Total: 28-2340 bytes
  406. */
  407. #define BEACON_PROBE_SSID_ID_POSITION 12
  408. /* Management Frame Information Element Types */
  409. enum ieee80211_mfie {
  410. MFIE_TYPE_SSID = 0,
  411. MFIE_TYPE_RATES = 1,
  412. MFIE_TYPE_FH_SET = 2,
  413. MFIE_TYPE_DS_SET = 3,
  414. MFIE_TYPE_CF_SET = 4,
  415. MFIE_TYPE_TIM = 5,
  416. MFIE_TYPE_IBSS_SET = 6,
  417. MFIE_TYPE_COUNTRY = 7,
  418. MFIE_TYPE_HOP_PARAMS = 8,
  419. MFIE_TYPE_HOP_TABLE = 9,
  420. MFIE_TYPE_REQUEST = 10,
  421. MFIE_TYPE_CHALLENGE = 16,
  422. MFIE_TYPE_POWER_CONSTRAINT = 32,
  423. MFIE_TYPE_POWER_CAPABILITY = 33,
  424. MFIE_TYPE_TPC_REQUEST = 34,
  425. MFIE_TYPE_TPC_REPORT = 35,
  426. MFIE_TYPE_SUPP_CHANNELS = 36,
  427. MFIE_TYPE_CSA = 37,
  428. MFIE_TYPE_MEASURE_REQUEST = 38,
  429. MFIE_TYPE_MEASURE_REPORT = 39,
  430. MFIE_TYPE_QUIET = 40,
  431. MFIE_TYPE_IBSS_DFS = 41,
  432. MFIE_TYPE_ERP_INFO = 42,
  433. MFIE_TYPE_RSN = 48,
  434. MFIE_TYPE_RATES_EX = 50,
  435. MFIE_TYPE_GENERIC = 221,
  436. MFIE_TYPE_QOS_PARAMETER = 222,
  437. };
  438. /* Minimal header; can be used for passing 802.11 frames with sufficient
  439. * information to determine what type of underlying data type is actually
  440. * stored in the data. */
  441. struct ieee80211_hdr {
  442. u16 frame_ctl;
  443. u16 duration_id;
  444. u8 payload[0];
  445. } __attribute__ ((packed));
  446. struct ieee80211_hdr_1addr {
  447. u16 frame_ctl;
  448. u16 duration_id;
  449. u8 addr1[ETH_ALEN];
  450. u8 payload[0];
  451. } __attribute__ ((packed));
  452. struct ieee80211_hdr_2addr {
  453. u16 frame_ctl;
  454. u16 duration_id;
  455. u8 addr1[ETH_ALEN];
  456. u8 addr2[ETH_ALEN];
  457. u8 payload[0];
  458. } __attribute__ ((packed));
  459. struct ieee80211_hdr_3addr {
  460. u16 frame_ctl;
  461. u16 duration_id;
  462. u8 addr1[ETH_ALEN];
  463. u8 addr2[ETH_ALEN];
  464. u8 addr3[ETH_ALEN];
  465. u16 seq_ctl;
  466. u8 payload[0];
  467. } __attribute__ ((packed));
  468. struct ieee80211_hdr_4addr {
  469. u16 frame_ctl;
  470. u16 duration_id;
  471. u8 addr1[ETH_ALEN];
  472. u8 addr2[ETH_ALEN];
  473. u8 addr3[ETH_ALEN];
  474. u16 seq_ctl;
  475. u8 addr4[ETH_ALEN];
  476. u8 payload[0];
  477. } __attribute__ ((packed));
  478. struct ieee80211_hdr_3addrqos {
  479. u16 frame_ctl;
  480. u16 duration_id;
  481. u8 addr1[ETH_ALEN];
  482. u8 addr2[ETH_ALEN];
  483. u8 addr3[ETH_ALEN];
  484. u16 seq_ctl;
  485. u8 payload[0];
  486. u16 qos_ctl;
  487. } __attribute__ ((packed));
  488. struct ieee80211_hdr_4addrqos {
  489. u16 frame_ctl;
  490. u16 duration_id;
  491. u8 addr1[ETH_ALEN];
  492. u8 addr2[ETH_ALEN];
  493. u8 addr3[ETH_ALEN];
  494. u16 seq_ctl;
  495. u8 addr4[ETH_ALEN];
  496. u8 payload[0];
  497. u16 qos_ctl;
  498. } __attribute__ ((packed));
  499. struct ieee80211_info_element {
  500. u8 id;
  501. u8 len;
  502. u8 data[0];
  503. } __attribute__ ((packed));
  504. /*
  505. * These are the data types that can make up management packets
  506. *
  507. u16 auth_algorithm;
  508. u16 auth_sequence;
  509. u16 beacon_interval;
  510. u16 capability;
  511. u8 current_ap[ETH_ALEN];
  512. u16 listen_interval;
  513. struct {
  514. u16 association_id:14, reserved:2;
  515. } __attribute__ ((packed));
  516. u32 time_stamp[2];
  517. u16 reason;
  518. u16 status;
  519. */
  520. struct ieee80211_auth {
  521. struct ieee80211_hdr_3addr header;
  522. __le16 algorithm;
  523. __le16 transaction;
  524. __le16 status;
  525. struct ieee80211_info_element info_element[0];
  526. } __attribute__ ((packed));
  527. struct ieee80211_disassoc {
  528. struct ieee80211_hdr_3addr header;
  529. u16 reason_code;
  530. struct ieee80211_info_element info_element[0];
  531. } __attribute__ ((packed));
  532. struct ieee80211_probe_request {
  533. struct ieee80211_hdr_3addr header;
  534. struct ieee80211_info_element info_element[0];
  535. } __attribute__ ((packed));
  536. struct ieee80211_probe_response {
  537. struct ieee80211_hdr_3addr header;
  538. u32 time_stamp[2];
  539. __le16 beacon_interval;
  540. __le16 capability;
  541. struct ieee80211_info_element info_element[0];
  542. } __attribute__ ((packed));
  543. /* Alias beacon for probe_response */
  544. #define ieee80211_beacon ieee80211_probe_response
  545. struct ieee80211_assoc_request {
  546. struct ieee80211_hdr_3addr header;
  547. u16 capability;
  548. u16 listen_interval;
  549. struct ieee80211_info_element info_element[0];
  550. } __attribute__ ((packed));
  551. struct ieee80211_reassoc_request {
  552. struct ieee80211_hdr_3addr header;
  553. __le16 capability;
  554. __le16 listen_interval;
  555. u8 current_ap[ETH_ALEN];
  556. struct ieee80211_info_element info_element[0];
  557. } __attribute__ ((packed));
  558. struct ieee80211_assoc_response {
  559. struct ieee80211_hdr_3addr header;
  560. __le16 capability;
  561. __le16 status;
  562. __le16 aid;
  563. struct ieee80211_info_element info_element[0]; /* supported rates */
  564. } __attribute__ ((packed));
  565. struct ieee80211_txb {
  566. u8 nr_frags;
  567. u8 encrypted;
  568. u8 rts_included;
  569. u8 reserved;
  570. u16 frag_size;
  571. u16 payload_size;
  572. struct sk_buff *fragments[0];
  573. };
  574. /* SWEEP TABLE ENTRIES NUMBER */
  575. #define MAX_SWEEP_TAB_ENTRIES 42
  576. #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
  577. /* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs
  578. * only use 8, and then use extended rates for the remaining supported
  579. * rates. Other APs, however, stick all of their supported rates on the
  580. * main rates information element... */
  581. #define MAX_RATES_LENGTH ((u8)12)
  582. #define MAX_RATES_EX_LENGTH ((u8)16)
  583. #define MAX_NETWORK_COUNT 128
  584. #define CRC_LENGTH 4U
  585. #define MAX_WPA_IE_LEN 64
  586. #define NETWORK_EMPTY_ESSID (1<<0)
  587. #define NETWORK_HAS_OFDM (1<<1)
  588. #define NETWORK_HAS_CCK (1<<2)
  589. /* QoS structure */
  590. #define NETWORK_HAS_QOS_PARAMETERS (1<<3)
  591. #define NETWORK_HAS_QOS_INFORMATION (1<<4)
  592. #define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | NETWORK_HAS_QOS_INFORMATION)
  593. #define QOS_QUEUE_NUM 4
  594. #define QOS_OUI_LEN 3
  595. #define QOS_OUI_TYPE 2
  596. #define QOS_ELEMENT_ID 221
  597. #define QOS_OUI_INFO_SUB_TYPE 0
  598. #define QOS_OUI_PARAM_SUB_TYPE 1
  599. #define QOS_VERSION_1 1
  600. #define QOS_AIFSN_MIN_VALUE 2
  601. struct ieee80211_qos_information_element {
  602. u8 elementID;
  603. u8 length;
  604. u8 qui[QOS_OUI_LEN];
  605. u8 qui_type;
  606. u8 qui_subtype;
  607. u8 version;
  608. u8 ac_info;
  609. } __attribute__ ((packed));
  610. struct ieee80211_qos_ac_parameter {
  611. u8 aci_aifsn;
  612. u8 ecw_min_max;
  613. u16 tx_op_limit;
  614. } __attribute__ ((packed));
  615. struct ieee80211_qos_parameter_info {
  616. struct ieee80211_qos_information_element info_element;
  617. u8 reserved;
  618. struct ieee80211_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM];
  619. } __attribute__ ((packed));
  620. struct ieee80211_qos_parameters {
  621. u16 cw_min[QOS_QUEUE_NUM];
  622. u16 cw_max[QOS_QUEUE_NUM];
  623. u8 aifs[QOS_QUEUE_NUM];
  624. u8 flag[QOS_QUEUE_NUM];
  625. u16 tx_op_limit[QOS_QUEUE_NUM];
  626. } __attribute__ ((packed));
  627. struct ieee80211_qos_data {
  628. struct ieee80211_qos_parameters parameters;
  629. int active;
  630. int supported;
  631. u8 param_count;
  632. u8 old_param_count;
  633. };
  634. struct ieee80211_tim_parameters {
  635. u8 tim_count;
  636. u8 tim_period;
  637. } __attribute__ ((packed));
  638. /*******************************************************/
  639. struct ieee80211_network {
  640. /* These entries are used to identify a unique network */
  641. u8 bssid[ETH_ALEN];
  642. u8 channel;
  643. /* Ensure null-terminated for any debug msgs */
  644. u8 ssid[IW_ESSID_MAX_SIZE + 1];
  645. u8 ssid_len;
  646. struct ieee80211_qos_data qos_data;
  647. /* These are network statistics */
  648. struct ieee80211_rx_stats stats;
  649. u16 capability;
  650. u8 rates[MAX_RATES_LENGTH];
  651. u8 rates_len;
  652. u8 rates_ex[MAX_RATES_EX_LENGTH];
  653. u8 rates_ex_len;
  654. unsigned long last_scanned;
  655. u8 mode;
  656. u8 flags;
  657. u32 last_associate;
  658. u32 time_stamp[2];
  659. u16 beacon_interval;
  660. u16 listen_interval;
  661. u16 atim_window;
  662. u8 wpa_ie[MAX_WPA_IE_LEN];
  663. size_t wpa_ie_len;
  664. u8 rsn_ie[MAX_WPA_IE_LEN];
  665. size_t rsn_ie_len;
  666. struct ieee80211_tim_parameters tim;
  667. struct list_head list;
  668. };
  669. enum ieee80211_state {
  670. IEEE80211_UNINITIALIZED = 0,
  671. IEEE80211_INITIALIZED,
  672. IEEE80211_ASSOCIATING,
  673. IEEE80211_ASSOCIATED,
  674. IEEE80211_AUTHENTICATING,
  675. IEEE80211_AUTHENTICATED,
  676. IEEE80211_SHUTDOWN
  677. };
  678. #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
  679. #define DEFAULT_FTS 2346
  680. #define CFG_IEEE80211_RESERVE_FCS (1<<0)
  681. #define CFG_IEEE80211_COMPUTE_FCS (1<<1)
  682. #define CFG_IEEE80211_RTS (1<<2)
  683. #define IEEE80211_24GHZ_MIN_CHANNEL 1
  684. #define IEEE80211_24GHZ_MAX_CHANNEL 14
  685. #define IEEE80211_24GHZ_CHANNELS 14
  686. #define IEEE80211_52GHZ_MIN_CHANNEL 36
  687. #define IEEE80211_52GHZ_MAX_CHANNEL 165
  688. #define IEEE80211_52GHZ_CHANNELS 32
  689. enum {
  690. IEEE80211_CH_PASSIVE_ONLY = (1 << 0),
  691. IEEE80211_CH_B_ONLY = (1 << 2),
  692. IEEE80211_CH_NO_IBSS = (1 << 3),
  693. IEEE80211_CH_UNIFORM_SPREADING = (1 << 4),
  694. IEEE80211_CH_RADAR_DETECT = (1 << 5),
  695. IEEE80211_CH_INVALID = (1 << 6),
  696. };
  697. struct ieee80211_channel {
  698. u16 freq;
  699. u8 channel;
  700. u8 flags;
  701. u8 max_power;
  702. };
  703. struct ieee80211_geo {
  704. u8 name[4];
  705. u8 bg_channels;
  706. u8 a_channels;
  707. struct ieee80211_channel bg[IEEE80211_24GHZ_CHANNELS];
  708. struct ieee80211_channel a[IEEE80211_52GHZ_CHANNELS];
  709. };
  710. struct ieee80211_device {
  711. struct net_device *dev;
  712. struct ieee80211_security sec;
  713. /* Bookkeeping structures */
  714. struct net_device_stats stats;
  715. struct ieee80211_stats ieee_stats;
  716. struct ieee80211_geo geo;
  717. /* Probe / Beacon management */
  718. struct list_head network_free_list;
  719. struct list_head network_list;
  720. struct ieee80211_network *networks;
  721. int scans;
  722. int scan_age;
  723. int iw_mode; /* operating mode (IW_MODE_*) */
  724. struct iw_spy_data spy_data; /* iwspy support */
  725. spinlock_t lock;
  726. int tx_headroom; /* Set to size of any additional room needed at front
  727. * of allocated Tx SKBs */
  728. u32 config;
  729. /* WEP and other encryption related settings at the device level */
  730. int open_wep; /* Set to 1 to allow unencrypted frames */
  731. int reset_on_keychange; /* Set to 1 if the HW needs to be reset on
  732. * WEP key changes */
  733. /* If the host performs {en,de}cryption, then set to 1 */
  734. int host_encrypt;
  735. int host_encrypt_msdu;
  736. int host_decrypt;
  737. int host_open_frag;
  738. int ieee802_1x; /* is IEEE 802.1X used */
  739. /* WPA data */
  740. int wpa_enabled;
  741. int drop_unencrypted;
  742. int tkip_countermeasures;
  743. int privacy_invoked;
  744. size_t wpa_ie_len;
  745. u8 *wpa_ie;
  746. struct list_head crypt_deinit_list;
  747. struct ieee80211_crypt_data *crypt[WEP_KEYS];
  748. int tx_keyidx; /* default TX key index (crypt[tx_keyidx]) */
  749. struct timer_list crypt_deinit_timer;
  750. int crypt_quiesced;
  751. int bcrx_sta_key; /* use individual keys to override default keys even
  752. * with RX of broad/multicast frames */
  753. /* Fragmentation structures */
  754. struct ieee80211_frag_entry frag_cache[IEEE80211_FRAG_CACHE_LEN];
  755. unsigned int frag_next_idx;
  756. u16 fts; /* Fragmentation Threshold */
  757. u16 rts; /* RTS threshold */
  758. /* Association info */
  759. u8 bssid[ETH_ALEN];
  760. enum ieee80211_state state;
  761. int mode; /* A, B, G */
  762. int modulation; /* CCK, OFDM */
  763. int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */
  764. int abg_true; /* ABG flag */
  765. int perfect_rssi;
  766. int worst_rssi;
  767. /* Callback functions */
  768. void (*set_security) (struct net_device * dev,
  769. struct ieee80211_security * sec);
  770. int (*hard_start_xmit) (struct ieee80211_txb * txb,
  771. struct net_device * dev, int pri);
  772. int (*reset_port) (struct net_device * dev);
  773. int (*is_queue_full) (struct net_device * dev, int pri);
  774. int (*handle_management) (struct net_device * dev,
  775. struct ieee80211_network * network, u16 type);
  776. /* Typical STA methods */
  777. int (*handle_auth) (struct net_device * dev,
  778. struct ieee80211_auth * auth);
  779. int (*handle_disassoc) (struct net_device * dev,
  780. struct ieee80211_disassoc * assoc);
  781. int (*handle_beacon) (struct net_device * dev,
  782. struct ieee80211_beacon * beacon,
  783. struct ieee80211_network * network);
  784. int (*handle_probe_response) (struct net_device * dev,
  785. struct ieee80211_probe_response * resp,
  786. struct ieee80211_network * network);
  787. int (*handle_assoc_response) (struct net_device * dev,
  788. struct ieee80211_assoc_response * resp,
  789. struct ieee80211_network * network);
  790. /* Typical AP methods */
  791. int (*handle_assoc_request) (struct net_device * dev);
  792. int (*handle_reassoc_request) (struct net_device * dev,
  793. struct ieee80211_reassoc_request * req);
  794. /* This must be the last item so that it points to the data
  795. * allocated beyond this structure by alloc_ieee80211 */
  796. u8 priv[0];
  797. };
  798. #define IEEE_A (1<<0)
  799. #define IEEE_B (1<<1)
  800. #define IEEE_G (1<<2)
  801. #define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
  802. extern inline void *ieee80211_priv(struct net_device *dev)
  803. {
  804. return ((struct ieee80211_device *)netdev_priv(dev))->priv;
  805. }
  806. extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
  807. {
  808. /* Single white space is for Linksys APs */
  809. if (essid_len == 1 && essid[0] == ' ')
  810. return 1;
  811. /* Otherwise, if the entire essid is 0, we assume it is hidden */
  812. while (essid_len) {
  813. essid_len--;
  814. if (essid[essid_len] != '\0')
  815. return 0;
  816. }
  817. return 1;
  818. }
  819. extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee,
  820. int mode)
  821. {
  822. /*
  823. * It is possible for both access points and our device to support
  824. * combinations of modes, so as long as there is one valid combination
  825. * of ap/device supported modes, then return success
  826. *
  827. */
  828. if ((mode & IEEE_A) &&
  829. (ieee->modulation & IEEE80211_OFDM_MODULATION) &&
  830. (ieee->freq_band & IEEE80211_52GHZ_BAND))
  831. return 1;
  832. if ((mode & IEEE_G) &&
  833. (ieee->modulation & IEEE80211_OFDM_MODULATION) &&
  834. (ieee->freq_band & IEEE80211_24GHZ_BAND))
  835. return 1;
  836. if ((mode & IEEE_B) &&
  837. (ieee->modulation & IEEE80211_CCK_MODULATION) &&
  838. (ieee->freq_band & IEEE80211_24GHZ_BAND))
  839. return 1;
  840. return 0;
  841. }
  842. extern inline int ieee80211_get_hdrlen(u16 fc)
  843. {
  844. int hdrlen = IEEE80211_3ADDR_LEN;
  845. u16 stype = WLAN_FC_GET_STYPE(fc);
  846. switch (WLAN_FC_GET_TYPE(fc)) {
  847. case IEEE80211_FTYPE_DATA:
  848. if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
  849. hdrlen = IEEE80211_4ADDR_LEN;
  850. if (stype & IEEE80211_STYPE_QOS_DATA)
  851. hdrlen += 2;
  852. break;
  853. case IEEE80211_FTYPE_CTL:
  854. switch (WLAN_FC_GET_STYPE(fc)) {
  855. case IEEE80211_STYPE_CTS:
  856. case IEEE80211_STYPE_ACK:
  857. hdrlen = IEEE80211_1ADDR_LEN;
  858. break;
  859. default:
  860. hdrlen = IEEE80211_2ADDR_LEN;
  861. break;
  862. }
  863. break;
  864. }
  865. return hdrlen;
  866. }
  867. extern inline u8 *ieee80211_get_payload(struct ieee80211_hdr *hdr)
  868. {
  869. switch (ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl))) {
  870. case IEEE80211_1ADDR_LEN:
  871. return ((struct ieee80211_hdr_1addr *)hdr)->payload;
  872. case IEEE80211_2ADDR_LEN:
  873. return ((struct ieee80211_hdr_2addr *)hdr)->payload;
  874. case IEEE80211_3ADDR_LEN:
  875. return ((struct ieee80211_hdr_3addr *)hdr)->payload;
  876. case IEEE80211_4ADDR_LEN:
  877. return ((struct ieee80211_hdr_4addr *)hdr)->payload;
  878. }
  879. }
  880. /* ieee80211.c */
  881. extern void free_ieee80211(struct net_device *dev);
  882. extern struct net_device *alloc_ieee80211(int sizeof_priv);
  883. extern int ieee80211_set_encryption(struct ieee80211_device *ieee);
  884. /* ieee80211_tx.c */
  885. extern int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev);
  886. extern void ieee80211_txb_free(struct ieee80211_txb *);
  887. extern int ieee80211_tx_frame(struct ieee80211_device *ieee,
  888. struct ieee80211_hdr *frame, int len);
  889. /* ieee80211_rx.c */
  890. extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
  891. struct ieee80211_rx_stats *rx_stats);
  892. extern void ieee80211_rx_mgt(struct ieee80211_device *ieee,
  893. struct ieee80211_hdr_4addr *header,
  894. struct ieee80211_rx_stats *stats);
  895. /* ieee80211_geo.c */
  896. extern const struct ieee80211_geo *ieee80211_get_geo(struct ieee80211_device
  897. *ieee);
  898. extern int ieee80211_set_geo(struct ieee80211_device *ieee,
  899. const struct ieee80211_geo *geo);
  900. extern int ieee80211_is_valid_channel(struct ieee80211_device *ieee,
  901. u8 channel);
  902. extern int ieee80211_channel_to_index(struct ieee80211_device *ieee,
  903. u8 channel);
  904. extern u8 ieee80211_freq_to_channel(struct ieee80211_device *ieee, u32 freq);
  905. /* ieee80211_wx.c */
  906. extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
  907. struct iw_request_info *info,
  908. union iwreq_data *wrqu, char *key);
  909. extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
  910. struct iw_request_info *info,
  911. union iwreq_data *wrqu, char *key);
  912. extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
  913. struct iw_request_info *info,
  914. union iwreq_data *wrqu, char *key);
  915. #if WIRELESS_EXT > 17
  916. extern int ieee80211_wx_set_encodeext(struct ieee80211_device *ieee,
  917. struct iw_request_info *info,
  918. union iwreq_data *wrqu, char *extra);
  919. extern int ieee80211_wx_get_encodeext(struct ieee80211_device *ieee,
  920. struct iw_request_info *info,
  921. union iwreq_data *wrqu, char *extra);
  922. #endif
  923. extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee)
  924. {
  925. ieee->scans++;
  926. }
  927. extern inline int ieee80211_get_scans(struct ieee80211_device *ieee)
  928. {
  929. return ieee->scans;
  930. }
  931. #endif /* IEEE80211_H */