ieee80211.h 31 KB

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