ieee80211.h 33 KB

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