ieee80211.h 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186
  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,
  338. enabled:1,
  339. auth_mode:2, auth_algo:4, unicast_uses_group:1, encrypt:1;
  340. u8 encode_alg[WEP_KEYS];
  341. u8 key_sizes[WEP_KEYS];
  342. u8 keys[WEP_KEYS][SCM_KEY_LEN];
  343. u8 level;
  344. u16 flags;
  345. } __attribute__ ((packed));
  346. /*
  347. 802.11 data frame from AP
  348. ,-------------------------------------------------------------------.
  349. Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
  350. |------|------|---------|---------|---------|------|---------|------|
  351. Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs |
  352. | | tion | (BSSID) | | | ence | data | |
  353. `-------------------------------------------------------------------'
  354. Total: 28-2340 bytes
  355. */
  356. #define BEACON_PROBE_SSID_ID_POSITION 12
  357. /* Management Frame Information Element Types */
  358. enum ieee80211_mfie {
  359. MFIE_TYPE_SSID = 0,
  360. MFIE_TYPE_RATES = 1,
  361. MFIE_TYPE_FH_SET = 2,
  362. MFIE_TYPE_DS_SET = 3,
  363. MFIE_TYPE_CF_SET = 4,
  364. MFIE_TYPE_TIM = 5,
  365. MFIE_TYPE_IBSS_SET = 6,
  366. MFIE_TYPE_COUNTRY = 7,
  367. MFIE_TYPE_HOP_PARAMS = 8,
  368. MFIE_TYPE_HOP_TABLE = 9,
  369. MFIE_TYPE_REQUEST = 10,
  370. MFIE_TYPE_CHALLENGE = 16,
  371. MFIE_TYPE_POWER_CONSTRAINT = 32,
  372. MFIE_TYPE_POWER_CAPABILITY = 33,
  373. MFIE_TYPE_TPC_REQUEST = 34,
  374. MFIE_TYPE_TPC_REPORT = 35,
  375. MFIE_TYPE_SUPP_CHANNELS = 36,
  376. MFIE_TYPE_CSA = 37,
  377. MFIE_TYPE_MEASURE_REQUEST = 38,
  378. MFIE_TYPE_MEASURE_REPORT = 39,
  379. MFIE_TYPE_QUIET = 40,
  380. MFIE_TYPE_IBSS_DFS = 41,
  381. MFIE_TYPE_ERP_INFO = 42,
  382. MFIE_TYPE_RSN = 48,
  383. MFIE_TYPE_RATES_EX = 50,
  384. MFIE_TYPE_GENERIC = 221,
  385. MFIE_TYPE_QOS_PARAMETER = 222,
  386. };
  387. struct ieee80211_hdr_1addr {
  388. __le16 frame_ctl;
  389. __le16 duration_id;
  390. u8 addr1[ETH_ALEN];
  391. u8 payload[0];
  392. } __attribute__ ((packed));
  393. struct ieee80211_hdr_2addr {
  394. __le16 frame_ctl;
  395. __le16 duration_id;
  396. u8 addr1[ETH_ALEN];
  397. u8 addr2[ETH_ALEN];
  398. u8 payload[0];
  399. } __attribute__ ((packed));
  400. struct ieee80211_hdr_3addr {
  401. __le16 frame_ctl;
  402. __le16 duration_id;
  403. u8 addr1[ETH_ALEN];
  404. u8 addr2[ETH_ALEN];
  405. u8 addr3[ETH_ALEN];
  406. __le16 seq_ctl;
  407. u8 payload[0];
  408. } __attribute__ ((packed));
  409. struct ieee80211_hdr_4addr {
  410. __le16 frame_ctl;
  411. __le16 duration_id;
  412. u8 addr1[ETH_ALEN];
  413. u8 addr2[ETH_ALEN];
  414. u8 addr3[ETH_ALEN];
  415. __le16 seq_ctl;
  416. u8 addr4[ETH_ALEN];
  417. u8 payload[0];
  418. } __attribute__ ((packed));
  419. struct ieee80211_hdr_3addrqos {
  420. __le16 frame_ctl;
  421. __le16 duration_id;
  422. u8 addr1[ETH_ALEN];
  423. u8 addr2[ETH_ALEN];
  424. u8 addr3[ETH_ALEN];
  425. __le16 seq_ctl;
  426. u8 payload[0];
  427. __le16 qos_ctl;
  428. } __attribute__ ((packed));
  429. struct ieee80211_info_element {
  430. u8 id;
  431. u8 len;
  432. u8 data[0];
  433. } __attribute__ ((packed));
  434. /*
  435. * These are the data types that can make up management packets
  436. *
  437. u16 auth_algorithm;
  438. u16 auth_sequence;
  439. u16 beacon_interval;
  440. u16 capability;
  441. u8 current_ap[ETH_ALEN];
  442. u16 listen_interval;
  443. struct {
  444. u16 association_id:14, reserved:2;
  445. } __attribute__ ((packed));
  446. u32 time_stamp[2];
  447. u16 reason;
  448. u16 status;
  449. */
  450. struct ieee80211_auth {
  451. struct ieee80211_hdr_3addr header;
  452. __le16 algorithm;
  453. __le16 transaction;
  454. __le16 status;
  455. /* challenge */
  456. struct ieee80211_info_element info_element[0];
  457. } __attribute__ ((packed));
  458. struct ieee80211_channel_switch {
  459. u8 id;
  460. u8 len;
  461. u8 mode;
  462. u8 channel;
  463. u8 count;
  464. } __attribute__ ((packed));
  465. struct ieee80211_action {
  466. struct ieee80211_hdr_3addr header;
  467. u8 category;
  468. u8 action;
  469. union {
  470. struct ieee80211_action_exchange {
  471. u8 token;
  472. struct ieee80211_info_element info_element[0];
  473. } exchange;
  474. struct ieee80211_channel_switch channel_switch;
  475. } format;
  476. } __attribute__ ((packed));
  477. struct ieee80211_disassoc {
  478. struct ieee80211_hdr_3addr header;
  479. __le16 reason;
  480. } __attribute__ ((packed));
  481. /* Alias deauth for disassoc */
  482. #define ieee80211_deauth ieee80211_disassoc
  483. struct ieee80211_probe_request {
  484. struct ieee80211_hdr_3addr header;
  485. /* SSID, supported rates */
  486. struct ieee80211_info_element info_element[0];
  487. } __attribute__ ((packed));
  488. struct ieee80211_probe_response {
  489. struct ieee80211_hdr_3addr header;
  490. __le32 time_stamp[2];
  491. __le16 beacon_interval;
  492. __le16 capability;
  493. /* SSID, supported rates, FH params, DS params,
  494. * CF params, IBSS params, TIM (if beacon), RSN */
  495. struct ieee80211_info_element info_element[0];
  496. } __attribute__ ((packed));
  497. /* Alias beacon for probe_response */
  498. #define ieee80211_beacon ieee80211_probe_response
  499. struct ieee80211_assoc_request {
  500. struct ieee80211_hdr_3addr header;
  501. __le16 capability;
  502. __le16 listen_interval;
  503. /* SSID, supported rates, RSN */
  504. struct ieee80211_info_element info_element[0];
  505. } __attribute__ ((packed));
  506. struct ieee80211_reassoc_request {
  507. struct ieee80211_hdr_3addr header;
  508. __le16 capability;
  509. __le16 listen_interval;
  510. u8 current_ap[ETH_ALEN];
  511. struct ieee80211_info_element info_element[0];
  512. } __attribute__ ((packed));
  513. struct ieee80211_assoc_response {
  514. struct ieee80211_hdr_3addr header;
  515. __le16 capability;
  516. __le16 status;
  517. __le16 aid;
  518. /* supported rates */
  519. struct ieee80211_info_element info_element[0];
  520. } __attribute__ ((packed));
  521. struct ieee80211_txb {
  522. u8 nr_frags;
  523. u8 encrypted;
  524. u8 rts_included;
  525. u8 reserved;
  526. u16 frag_size;
  527. u16 payload_size;
  528. struct sk_buff *fragments[0];
  529. };
  530. /* SWEEP TABLE ENTRIES NUMBER */
  531. #define MAX_SWEEP_TAB_ENTRIES 42
  532. #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
  533. /* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs
  534. * only use 8, and then use extended rates for the remaining supported
  535. * rates. Other APs, however, stick all of their supported rates on the
  536. * main rates information element... */
  537. #define MAX_RATES_LENGTH ((u8)12)
  538. #define MAX_RATES_EX_LENGTH ((u8)16)
  539. #define MAX_NETWORK_COUNT 128
  540. #define CRC_LENGTH 4U
  541. #define MAX_WPA_IE_LEN 64
  542. #define NETWORK_HAS_OFDM (1<<1)
  543. #define NETWORK_HAS_CCK (1<<2)
  544. /* QoS structure */
  545. #define NETWORK_HAS_QOS_PARAMETERS (1<<3)
  546. #define NETWORK_HAS_QOS_INFORMATION (1<<4)
  547. #define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \
  548. NETWORK_HAS_QOS_INFORMATION)
  549. /* 802.11h */
  550. #define NETWORK_HAS_POWER_CONSTRAINT (1<<5)
  551. #define NETWORK_HAS_CSA (1<<6)
  552. #define NETWORK_HAS_QUIET (1<<7)
  553. #define NETWORK_HAS_IBSS_DFS (1<<8)
  554. #define NETWORK_HAS_TPC_REPORT (1<<9)
  555. #define NETWORK_HAS_ERP_VALUE (1<<10)
  556. #define QOS_QUEUE_NUM 4
  557. #define QOS_OUI_LEN 3
  558. #define QOS_OUI_TYPE 2
  559. #define QOS_ELEMENT_ID 221
  560. #define QOS_OUI_INFO_SUB_TYPE 0
  561. #define QOS_OUI_PARAM_SUB_TYPE 1
  562. #define QOS_VERSION_1 1
  563. #define QOS_AIFSN_MIN_VALUE 2
  564. struct ieee80211_qos_information_element {
  565. u8 elementID;
  566. u8 length;
  567. u8 qui[QOS_OUI_LEN];
  568. u8 qui_type;
  569. u8 qui_subtype;
  570. u8 version;
  571. u8 ac_info;
  572. } __attribute__ ((packed));
  573. struct ieee80211_qos_ac_parameter {
  574. u8 aci_aifsn;
  575. u8 ecw_min_max;
  576. __le16 tx_op_limit;
  577. } __attribute__ ((packed));
  578. struct ieee80211_qos_parameter_info {
  579. struct ieee80211_qos_information_element info_element;
  580. u8 reserved;
  581. struct ieee80211_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM];
  582. } __attribute__ ((packed));
  583. struct ieee80211_qos_parameters {
  584. __le16 cw_min[QOS_QUEUE_NUM];
  585. __le16 cw_max[QOS_QUEUE_NUM];
  586. u8 aifs[QOS_QUEUE_NUM];
  587. u8 flag[QOS_QUEUE_NUM];
  588. __le16 tx_op_limit[QOS_QUEUE_NUM];
  589. } __attribute__ ((packed));
  590. struct ieee80211_qos_data {
  591. struct ieee80211_qos_parameters parameters;
  592. int active;
  593. int supported;
  594. u8 param_count;
  595. u8 old_param_count;
  596. };
  597. struct ieee80211_tim_parameters {
  598. u8 tim_count;
  599. u8 tim_period;
  600. } __attribute__ ((packed));
  601. /*******************************************************/
  602. enum { /* ieee80211_basic_report.map */
  603. IEEE80211_BASIC_MAP_BSS = (1 << 0),
  604. IEEE80211_BASIC_MAP_OFDM = (1 << 1),
  605. IEEE80211_BASIC_MAP_UNIDENTIFIED = (1 << 2),
  606. IEEE80211_BASIC_MAP_RADAR = (1 << 3),
  607. IEEE80211_BASIC_MAP_UNMEASURED = (1 << 4),
  608. /* Bits 5-7 are reserved */
  609. };
  610. struct ieee80211_basic_report {
  611. u8 channel;
  612. __le64 start_time;
  613. __le16 duration;
  614. u8 map;
  615. } __attribute__ ((packed));
  616. enum { /* ieee80211_measurement_request.mode */
  617. /* Bit 0 is reserved */
  618. IEEE80211_MEASUREMENT_ENABLE = (1 << 1),
  619. IEEE80211_MEASUREMENT_REQUEST = (1 << 2),
  620. IEEE80211_MEASUREMENT_REPORT = (1 << 3),
  621. /* Bits 4-7 are reserved */
  622. };
  623. enum {
  624. IEEE80211_REPORT_BASIC = 0, /* required */
  625. IEEE80211_REPORT_CCA = 1, /* optional */
  626. IEEE80211_REPORT_RPI = 2, /* optional */
  627. /* 3-255 reserved */
  628. };
  629. struct ieee80211_measurement_params {
  630. u8 channel;
  631. __le64 start_time;
  632. __le16 duration;
  633. } __attribute__ ((packed));
  634. struct ieee80211_measurement_request {
  635. struct ieee80211_info_element ie;
  636. u8 token;
  637. u8 mode;
  638. u8 type;
  639. struct ieee80211_measurement_params params[0];
  640. } __attribute__ ((packed));
  641. struct ieee80211_measurement_report {
  642. struct ieee80211_info_element ie;
  643. u8 token;
  644. u8 mode;
  645. u8 type;
  646. union {
  647. struct ieee80211_basic_report basic[0];
  648. } u;
  649. } __attribute__ ((packed));
  650. struct ieee80211_tpc_report {
  651. u8 transmit_power;
  652. u8 link_margin;
  653. } __attribute__ ((packed));
  654. struct ieee80211_channel_map {
  655. u8 channel;
  656. u8 map;
  657. } __attribute__ ((packed));
  658. struct ieee80211_ibss_dfs {
  659. struct ieee80211_info_element ie;
  660. u8 owner[ETH_ALEN];
  661. u8 recovery_interval;
  662. struct ieee80211_channel_map channel_map[0];
  663. };
  664. struct ieee80211_csa {
  665. u8 mode;
  666. u8 channel;
  667. u8 count;
  668. } __attribute__ ((packed));
  669. struct ieee80211_quiet {
  670. u8 count;
  671. u8 period;
  672. u8 duration;
  673. u8 offset;
  674. } __attribute__ ((packed));
  675. struct ieee80211_network {
  676. /* These entries are used to identify a unique network */
  677. u8 bssid[ETH_ALEN];
  678. u8 channel;
  679. /* Ensure null-terminated for any debug msgs */
  680. u8 ssid[IW_ESSID_MAX_SIZE + 1];
  681. u8 ssid_len;
  682. struct ieee80211_qos_data qos_data;
  683. /* These are network statistics */
  684. struct ieee80211_rx_stats stats;
  685. u16 capability;
  686. u8 rates[MAX_RATES_LENGTH];
  687. u8 rates_len;
  688. u8 rates_ex[MAX_RATES_EX_LENGTH];
  689. u8 rates_ex_len;
  690. unsigned long last_scanned;
  691. u8 mode;
  692. u32 flags;
  693. u32 last_associate;
  694. u32 time_stamp[2];
  695. u16 beacon_interval;
  696. u16 listen_interval;
  697. u16 atim_window;
  698. u8 erp_value;
  699. u8 wpa_ie[MAX_WPA_IE_LEN];
  700. size_t wpa_ie_len;
  701. u8 rsn_ie[MAX_WPA_IE_LEN];
  702. size_t rsn_ie_len;
  703. struct ieee80211_tim_parameters tim;
  704. /* 802.11h info */
  705. /* Power Constraint - mandatory if spctrm mgmt required */
  706. u8 power_constraint;
  707. /* TPC Report - mandatory if spctrm mgmt required */
  708. struct ieee80211_tpc_report tpc_report;
  709. /* IBSS DFS - mandatory if spctrm mgmt required and IBSS
  710. * NOTE: This is variable length and so must be allocated dynamically */
  711. struct ieee80211_ibss_dfs *ibss_dfs;
  712. /* Channel Switch Announcement - optional if spctrm mgmt required */
  713. struct ieee80211_csa csa;
  714. /* Quiet - optional if spctrm mgmt required */
  715. struct ieee80211_quiet quiet;
  716. struct list_head list;
  717. };
  718. enum ieee80211_state {
  719. IEEE80211_UNINITIALIZED = 0,
  720. IEEE80211_INITIALIZED,
  721. IEEE80211_ASSOCIATING,
  722. IEEE80211_ASSOCIATED,
  723. IEEE80211_AUTHENTICATING,
  724. IEEE80211_AUTHENTICATED,
  725. IEEE80211_SHUTDOWN
  726. };
  727. #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
  728. #define DEFAULT_FTS 2346
  729. #define CFG_IEEE80211_RESERVE_FCS (1<<0)
  730. #define CFG_IEEE80211_COMPUTE_FCS (1<<1)
  731. #define CFG_IEEE80211_RTS (1<<2)
  732. #define IEEE80211_24GHZ_MIN_CHANNEL 1
  733. #define IEEE80211_24GHZ_MAX_CHANNEL 14
  734. #define IEEE80211_24GHZ_CHANNELS (IEEE80211_24GHZ_MAX_CHANNEL - \
  735. IEEE80211_24GHZ_MIN_CHANNEL + 1)
  736. #define IEEE80211_52GHZ_MIN_CHANNEL 34
  737. #define IEEE80211_52GHZ_MAX_CHANNEL 165
  738. #define IEEE80211_52GHZ_CHANNELS (IEEE80211_52GHZ_MAX_CHANNEL - \
  739. IEEE80211_52GHZ_MIN_CHANNEL + 1)
  740. enum {
  741. IEEE80211_CH_PASSIVE_ONLY = (1 << 0),
  742. IEEE80211_CH_80211H_RULES = (1 << 1),
  743. IEEE80211_CH_B_ONLY = (1 << 2),
  744. IEEE80211_CH_NO_IBSS = (1 << 3),
  745. IEEE80211_CH_UNIFORM_SPREADING = (1 << 4),
  746. IEEE80211_CH_RADAR_DETECT = (1 << 5),
  747. IEEE80211_CH_INVALID = (1 << 6),
  748. };
  749. struct ieee80211_channel {
  750. u32 freq; /* in MHz */
  751. u8 channel;
  752. u8 flags;
  753. u8 max_power; /* in dBm */
  754. };
  755. struct ieee80211_geo {
  756. u8 name[4];
  757. u8 bg_channels;
  758. u8 a_channels;
  759. struct ieee80211_channel bg[IEEE80211_24GHZ_CHANNELS];
  760. struct ieee80211_channel a[IEEE80211_52GHZ_CHANNELS];
  761. };
  762. struct ieee80211_device {
  763. struct net_device *dev;
  764. struct ieee80211_security sec;
  765. /* Bookkeeping structures */
  766. struct net_device_stats stats;
  767. struct ieee80211_stats ieee_stats;
  768. struct ieee80211_geo geo;
  769. /* Probe / Beacon management */
  770. struct list_head network_free_list;
  771. struct list_head network_list;
  772. struct ieee80211_network *networks;
  773. int scans;
  774. int scan_age;
  775. int iw_mode; /* operating mode (IW_MODE_*) */
  776. struct iw_spy_data spy_data; /* iwspy support */
  777. spinlock_t lock;
  778. int tx_headroom; /* Set to size of any additional room needed at front
  779. * of allocated Tx SKBs */
  780. u32 config;
  781. /* WEP and other encryption related settings at the device level */
  782. int open_wep; /* Set to 1 to allow unencrypted frames */
  783. int reset_on_keychange; /* Set to 1 if the HW needs to be reset on
  784. * WEP key changes */
  785. /* If the host performs {en,de}cryption, then set to 1 */
  786. int host_encrypt;
  787. int host_encrypt_msdu;
  788. int host_decrypt;
  789. /* host performs multicast decryption */
  790. int host_mc_decrypt;
  791. /* host should strip IV and ICV from protected frames */
  792. /* meaningful only when hardware decryption is being used */
  793. int host_strip_iv_icv;
  794. int host_open_frag;
  795. int host_build_iv;
  796. int ieee802_1x; /* is IEEE 802.1X used */
  797. /* WPA data */
  798. int wpa_enabled;
  799. int drop_unencrypted;
  800. int privacy_invoked;
  801. size_t wpa_ie_len;
  802. u8 *wpa_ie;
  803. struct lib80211_crypt_info crypt_info;
  804. int bcrx_sta_key; /* use individual keys to override default keys even
  805. * with RX of broad/multicast frames */
  806. /* Fragmentation structures */
  807. struct ieee80211_frag_entry frag_cache[IEEE80211_FRAG_CACHE_LEN];
  808. unsigned int frag_next_idx;
  809. u16 fts; /* Fragmentation Threshold */
  810. u16 rts; /* RTS threshold */
  811. /* Association info */
  812. u8 bssid[ETH_ALEN];
  813. enum ieee80211_state state;
  814. int mode; /* A, B, G */
  815. int modulation; /* CCK, OFDM */
  816. int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */
  817. int abg_true; /* ABG flag */
  818. int perfect_rssi;
  819. int worst_rssi;
  820. u16 prev_seq_ctl; /* used to drop duplicate frames */
  821. /* Callback functions */
  822. void (*set_security) (struct net_device * dev,
  823. struct ieee80211_security * sec);
  824. int (*hard_start_xmit) (struct ieee80211_txb * txb,
  825. struct net_device * dev, int pri);
  826. int (*reset_port) (struct net_device * dev);
  827. int (*is_queue_full) (struct net_device * dev, int pri);
  828. int (*handle_management) (struct net_device * dev,
  829. struct ieee80211_network * network, u16 type);
  830. int (*is_qos_active) (struct net_device *dev, struct sk_buff *skb);
  831. /* Typical STA methods */
  832. int (*handle_auth) (struct net_device * dev,
  833. struct ieee80211_auth * auth);
  834. int (*handle_deauth) (struct net_device * dev,
  835. struct ieee80211_deauth * auth);
  836. int (*handle_action) (struct net_device * dev,
  837. struct ieee80211_action * action,
  838. struct ieee80211_rx_stats * stats);
  839. int (*handle_disassoc) (struct net_device * dev,
  840. struct ieee80211_disassoc * assoc);
  841. int (*handle_beacon) (struct net_device * dev,
  842. struct ieee80211_beacon * beacon,
  843. struct ieee80211_network * network);
  844. int (*handle_probe_response) (struct net_device * dev,
  845. struct ieee80211_probe_response * resp,
  846. struct ieee80211_network * network);
  847. int (*handle_probe_request) (struct net_device * dev,
  848. struct ieee80211_probe_request * req,
  849. struct ieee80211_rx_stats * stats);
  850. int (*handle_assoc_response) (struct net_device * dev,
  851. struct ieee80211_assoc_response * resp,
  852. struct ieee80211_network * network);
  853. /* Typical AP methods */
  854. int (*handle_assoc_request) (struct net_device * dev);
  855. int (*handle_reassoc_request) (struct net_device * dev,
  856. struct ieee80211_reassoc_request * req);
  857. /* This must be the last item so that it points to the data
  858. * allocated beyond this structure by alloc_ieee80211 */
  859. u8 priv[0];
  860. };
  861. #define IEEE_A (1<<0)
  862. #define IEEE_B (1<<1)
  863. #define IEEE_G (1<<2)
  864. #define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
  865. static inline void *ieee80211_priv(struct net_device *dev)
  866. {
  867. return ((struct ieee80211_device *)netdev_priv(dev))->priv;
  868. }
  869. static inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee,
  870. int mode)
  871. {
  872. /*
  873. * It is possible for both access points and our device to support
  874. * combinations of modes, so as long as there is one valid combination
  875. * of ap/device supported modes, then return success
  876. *
  877. */
  878. if ((mode & IEEE_A) &&
  879. (ieee->modulation & IEEE80211_OFDM_MODULATION) &&
  880. (ieee->freq_band & IEEE80211_52GHZ_BAND))
  881. return 1;
  882. if ((mode & IEEE_G) &&
  883. (ieee->modulation & IEEE80211_OFDM_MODULATION) &&
  884. (ieee->freq_band & IEEE80211_24GHZ_BAND))
  885. return 1;
  886. if ((mode & IEEE_B) &&
  887. (ieee->modulation & IEEE80211_CCK_MODULATION) &&
  888. (ieee->freq_band & IEEE80211_24GHZ_BAND))
  889. return 1;
  890. return 0;
  891. }
  892. static inline int ieee80211_get_hdrlen(u16 fc)
  893. {
  894. int hdrlen = IEEE80211_3ADDR_LEN;
  895. u16 stype = WLAN_FC_GET_STYPE(fc);
  896. switch (WLAN_FC_GET_TYPE(fc)) {
  897. case IEEE80211_FTYPE_DATA:
  898. if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
  899. hdrlen = IEEE80211_4ADDR_LEN;
  900. if (stype & IEEE80211_STYPE_QOS_DATA)
  901. hdrlen += 2;
  902. break;
  903. case IEEE80211_FTYPE_CTL:
  904. switch (WLAN_FC_GET_STYPE(fc)) {
  905. case IEEE80211_STYPE_CTS:
  906. case IEEE80211_STYPE_ACK:
  907. hdrlen = IEEE80211_1ADDR_LEN;
  908. break;
  909. default:
  910. hdrlen = IEEE80211_2ADDR_LEN;
  911. break;
  912. }
  913. break;
  914. }
  915. return hdrlen;
  916. }
  917. static inline u8 *ieee80211_get_payload(struct ieee80211_hdr *hdr)
  918. {
  919. switch (ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_control))) {
  920. case IEEE80211_1ADDR_LEN:
  921. return ((struct ieee80211_hdr_1addr *)hdr)->payload;
  922. case IEEE80211_2ADDR_LEN:
  923. return ((struct ieee80211_hdr_2addr *)hdr)->payload;
  924. case IEEE80211_3ADDR_LEN:
  925. return ((struct ieee80211_hdr_3addr *)hdr)->payload;
  926. case IEEE80211_4ADDR_LEN:
  927. return ((struct ieee80211_hdr_4addr *)hdr)->payload;
  928. }
  929. return NULL;
  930. }
  931. static inline int ieee80211_is_ofdm_rate(u8 rate)
  932. {
  933. switch (rate & ~IEEE80211_BASIC_RATE_MASK) {
  934. case IEEE80211_OFDM_RATE_6MB:
  935. case IEEE80211_OFDM_RATE_9MB:
  936. case IEEE80211_OFDM_RATE_12MB:
  937. case IEEE80211_OFDM_RATE_18MB:
  938. case IEEE80211_OFDM_RATE_24MB:
  939. case IEEE80211_OFDM_RATE_36MB:
  940. case IEEE80211_OFDM_RATE_48MB:
  941. case IEEE80211_OFDM_RATE_54MB:
  942. return 1;
  943. }
  944. return 0;
  945. }
  946. static inline int ieee80211_is_cck_rate(u8 rate)
  947. {
  948. switch (rate & ~IEEE80211_BASIC_RATE_MASK) {
  949. case IEEE80211_CCK_RATE_1MB:
  950. case IEEE80211_CCK_RATE_2MB:
  951. case IEEE80211_CCK_RATE_5MB:
  952. case IEEE80211_CCK_RATE_11MB:
  953. return 1;
  954. }
  955. return 0;
  956. }
  957. /* ieee80211.c */
  958. extern void free_ieee80211(struct net_device *dev);
  959. extern struct net_device *alloc_ieee80211(int sizeof_priv);
  960. extern int ieee80211_set_encryption(struct ieee80211_device *ieee);
  961. /* ieee80211_tx.c */
  962. extern int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev);
  963. extern void ieee80211_txb_free(struct ieee80211_txb *);
  964. /* ieee80211_rx.c */
  965. extern void ieee80211_rx_any(struct ieee80211_device *ieee,
  966. struct sk_buff *skb, struct ieee80211_rx_stats *stats);
  967. extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
  968. struct ieee80211_rx_stats *rx_stats);
  969. /* make sure to set stats->len */
  970. extern void ieee80211_rx_mgt(struct ieee80211_device *ieee,
  971. struct ieee80211_hdr_4addr *header,
  972. struct ieee80211_rx_stats *stats);
  973. extern void ieee80211_network_reset(struct ieee80211_network *network);
  974. /* ieee80211_geo.c */
  975. extern const struct ieee80211_geo *ieee80211_get_geo(struct ieee80211_device
  976. *ieee);
  977. extern int ieee80211_set_geo(struct ieee80211_device *ieee,
  978. const struct ieee80211_geo *geo);
  979. extern int ieee80211_is_valid_channel(struct ieee80211_device *ieee,
  980. u8 channel);
  981. extern int ieee80211_channel_to_index(struct ieee80211_device *ieee,
  982. u8 channel);
  983. extern u8 ieee80211_freq_to_channel(struct ieee80211_device *ieee, u32 freq);
  984. extern u8 ieee80211_get_channel_flags(struct ieee80211_device *ieee,
  985. u8 channel);
  986. extern const struct ieee80211_channel *ieee80211_get_channel(struct
  987. ieee80211_device
  988. *ieee, u8 channel);
  989. extern u32 ieee80211_channel_to_freq(struct ieee80211_device * ieee,
  990. u8 channel);
  991. /* ieee80211_wx.c */
  992. extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
  993. struct iw_request_info *info,
  994. union iwreq_data *wrqu, char *key);
  995. extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
  996. struct iw_request_info *info,
  997. union iwreq_data *wrqu, char *key);
  998. extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
  999. struct iw_request_info *info,
  1000. union iwreq_data *wrqu, char *key);
  1001. extern int ieee80211_wx_set_encodeext(struct ieee80211_device *ieee,
  1002. struct iw_request_info *info,
  1003. union iwreq_data *wrqu, char *extra);
  1004. extern int ieee80211_wx_get_encodeext(struct ieee80211_device *ieee,
  1005. struct iw_request_info *info,
  1006. union iwreq_data *wrqu, char *extra);
  1007. static inline void ieee80211_increment_scans(struct ieee80211_device *ieee)
  1008. {
  1009. ieee->scans++;
  1010. }
  1011. static inline int ieee80211_get_scans(struct ieee80211_device *ieee)
  1012. {
  1013. return ieee->scans;
  1014. }
  1015. #endif /* IEEE80211_H */