libipw.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080
  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, libipw_geo APIs,
  24. * various structure changes, and crypto API init method
  25. */
  26. #ifndef LIBIPW_H
  27. #define LIBIPW_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. #include <net/cfg80211.h>
  34. #define LIBIPW_VERSION "git-1.1.13"
  35. #define LIBIPW_DATA_LEN 2304
  36. /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
  37. 6.2.1.1.2.
  38. The figure in section 7.1.2 suggests a body size of up to 2312
  39. bytes is allowed, which is a bit confusing, I suspect this
  40. represents the 2304 bytes of real data, plus a possible 8 bytes of
  41. WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
  42. #define LIBIPW_1ADDR_LEN 10
  43. #define LIBIPW_2ADDR_LEN 16
  44. #define LIBIPW_3ADDR_LEN 24
  45. #define LIBIPW_4ADDR_LEN 30
  46. #define LIBIPW_FCS_LEN 4
  47. #define LIBIPW_HLEN (LIBIPW_4ADDR_LEN)
  48. #define LIBIPW_FRAME_LEN (LIBIPW_DATA_LEN + LIBIPW_HLEN)
  49. #define MIN_FRAG_THRESHOLD 256U
  50. #define MAX_FRAG_THRESHOLD 2346U
  51. /* QOS control */
  52. #define LIBIPW_QCTL_TID 0x000F
  53. /* debug macros */
  54. #ifdef CONFIG_LIBIPW_DEBUG
  55. extern u32 libipw_debug_level;
  56. #define LIBIPW_DEBUG(level, fmt, args...) \
  57. do { if (libipw_debug_level & (level)) \
  58. printk(KERN_DEBUG "libipw: %c %s " fmt, \
  59. in_interrupt() ? 'I' : 'U', __func__ , ## args); } while (0)
  60. #else
  61. #define LIBIPW_DEBUG(level, fmt, args...) do {} while (0)
  62. #endif /* CONFIG_LIBIPW_DEBUG */
  63. /*
  64. * To use the debug system:
  65. *
  66. * If you are defining a new debug classification, simply add it to the #define
  67. * list here in the form of:
  68. *
  69. * #define LIBIPW_DL_xxxx VALUE
  70. *
  71. * shifting value to the left one bit from the previous entry. xxxx should be
  72. * the name of the classification (for example, WEP)
  73. *
  74. * You then need to either add a LIBIPW_xxxx_DEBUG() macro definition for your
  75. * classification, or use LIBIPW_DEBUG(LIBIPW_DL_xxxx, ...) whenever you want
  76. * to send output to that classification.
  77. *
  78. * To add your debug level to the list of levels seen when you perform
  79. *
  80. * % cat /proc/net/ieee80211/debug_level
  81. *
  82. * you simply need to add your entry to the libipw_debug_level array.
  83. *
  84. * If you do not see debug_level in /proc/net/ieee80211 then you do not have
  85. * CONFIG_LIBIPW_DEBUG defined in your kernel configuration
  86. *
  87. */
  88. #define LIBIPW_DL_INFO (1<<0)
  89. #define LIBIPW_DL_WX (1<<1)
  90. #define LIBIPW_DL_SCAN (1<<2)
  91. #define LIBIPW_DL_STATE (1<<3)
  92. #define LIBIPW_DL_MGMT (1<<4)
  93. #define LIBIPW_DL_FRAG (1<<5)
  94. #define LIBIPW_DL_DROP (1<<7)
  95. #define LIBIPW_DL_TX (1<<8)
  96. #define LIBIPW_DL_RX (1<<9)
  97. #define LIBIPW_DL_QOS (1<<31)
  98. #define LIBIPW_ERROR(f, a...) printk(KERN_ERR "libipw: " f, ## a)
  99. #define LIBIPW_WARNING(f, a...) printk(KERN_WARNING "libipw: " f, ## a)
  100. #define LIBIPW_DEBUG_INFO(f, a...) LIBIPW_DEBUG(LIBIPW_DL_INFO, f, ## a)
  101. #define LIBIPW_DEBUG_WX(f, a...) LIBIPW_DEBUG(LIBIPW_DL_WX, f, ## a)
  102. #define LIBIPW_DEBUG_SCAN(f, a...) LIBIPW_DEBUG(LIBIPW_DL_SCAN, f, ## a)
  103. #define LIBIPW_DEBUG_STATE(f, a...) LIBIPW_DEBUG(LIBIPW_DL_STATE, f, ## a)
  104. #define LIBIPW_DEBUG_MGMT(f, a...) LIBIPW_DEBUG(LIBIPW_DL_MGMT, f, ## a)
  105. #define LIBIPW_DEBUG_FRAG(f, a...) LIBIPW_DEBUG(LIBIPW_DL_FRAG, f, ## a)
  106. #define LIBIPW_DEBUG_DROP(f, a...) LIBIPW_DEBUG(LIBIPW_DL_DROP, f, ## a)
  107. #define LIBIPW_DEBUG_TX(f, a...) LIBIPW_DEBUG(LIBIPW_DL_TX, f, ## a)
  108. #define LIBIPW_DEBUG_RX(f, a...) LIBIPW_DEBUG(LIBIPW_DL_RX, f, ## a)
  109. #define LIBIPW_DEBUG_QOS(f, a...) LIBIPW_DEBUG(LIBIPW_DL_QOS, f, ## a)
  110. #include <linux/netdevice.h>
  111. #include <linux/if_arp.h> /* ARPHRD_ETHER */
  112. #ifndef WIRELESS_SPY
  113. #define WIRELESS_SPY /* enable iwspy support */
  114. #endif
  115. #include <net/iw_handler.h> /* new driver API */
  116. #define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
  117. #ifndef ETH_P_80211_RAW
  118. #define ETH_P_80211_RAW (ETH_P_ECONET + 1)
  119. #endif
  120. /* IEEE 802.11 defines */
  121. #define P80211_OUI_LEN 3
  122. struct libipw_snap_hdr {
  123. u8 dsap; /* always 0xAA */
  124. u8 ssap; /* always 0xAA */
  125. u8 ctrl; /* always 0x03 */
  126. u8 oui[P80211_OUI_LEN]; /* organizational universal id */
  127. } __packed;
  128. #define SNAP_SIZE sizeof(struct libipw_snap_hdr)
  129. #define WLAN_FC_GET_VERS(fc) ((fc) & IEEE80211_FCTL_VERS)
  130. #define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE)
  131. #define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE)
  132. #define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG)
  133. #define WLAN_GET_SEQ_SEQ(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
  134. #define LIBIPW_STATMASK_SIGNAL (1<<0)
  135. #define LIBIPW_STATMASK_RSSI (1<<1)
  136. #define LIBIPW_STATMASK_NOISE (1<<2)
  137. #define LIBIPW_STATMASK_RATE (1<<3)
  138. #define LIBIPW_STATMASK_WEMASK 0x7
  139. #define LIBIPW_CCK_MODULATION (1<<0)
  140. #define LIBIPW_OFDM_MODULATION (1<<1)
  141. #define LIBIPW_24GHZ_BAND (1<<0)
  142. #define LIBIPW_52GHZ_BAND (1<<1)
  143. #define LIBIPW_CCK_RATE_1MB 0x02
  144. #define LIBIPW_CCK_RATE_2MB 0x04
  145. #define LIBIPW_CCK_RATE_5MB 0x0B
  146. #define LIBIPW_CCK_RATE_11MB 0x16
  147. #define LIBIPW_OFDM_RATE_6MB 0x0C
  148. #define LIBIPW_OFDM_RATE_9MB 0x12
  149. #define LIBIPW_OFDM_RATE_12MB 0x18
  150. #define LIBIPW_OFDM_RATE_18MB 0x24
  151. #define LIBIPW_OFDM_RATE_24MB 0x30
  152. #define LIBIPW_OFDM_RATE_36MB 0x48
  153. #define LIBIPW_OFDM_RATE_48MB 0x60
  154. #define LIBIPW_OFDM_RATE_54MB 0x6C
  155. #define LIBIPW_BASIC_RATE_MASK 0x80
  156. #define LIBIPW_CCK_RATE_1MB_MASK (1<<0)
  157. #define LIBIPW_CCK_RATE_2MB_MASK (1<<1)
  158. #define LIBIPW_CCK_RATE_5MB_MASK (1<<2)
  159. #define LIBIPW_CCK_RATE_11MB_MASK (1<<3)
  160. #define LIBIPW_OFDM_RATE_6MB_MASK (1<<4)
  161. #define LIBIPW_OFDM_RATE_9MB_MASK (1<<5)
  162. #define LIBIPW_OFDM_RATE_12MB_MASK (1<<6)
  163. #define LIBIPW_OFDM_RATE_18MB_MASK (1<<7)
  164. #define LIBIPW_OFDM_RATE_24MB_MASK (1<<8)
  165. #define LIBIPW_OFDM_RATE_36MB_MASK (1<<9)
  166. #define LIBIPW_OFDM_RATE_48MB_MASK (1<<10)
  167. #define LIBIPW_OFDM_RATE_54MB_MASK (1<<11)
  168. #define LIBIPW_CCK_RATES_MASK 0x0000000F
  169. #define LIBIPW_CCK_BASIC_RATES_MASK (LIBIPW_CCK_RATE_1MB_MASK | \
  170. LIBIPW_CCK_RATE_2MB_MASK)
  171. #define LIBIPW_CCK_DEFAULT_RATES_MASK (LIBIPW_CCK_BASIC_RATES_MASK | \
  172. LIBIPW_CCK_RATE_5MB_MASK | \
  173. LIBIPW_CCK_RATE_11MB_MASK)
  174. #define LIBIPW_OFDM_RATES_MASK 0x00000FF0
  175. #define LIBIPW_OFDM_BASIC_RATES_MASK (LIBIPW_OFDM_RATE_6MB_MASK | \
  176. LIBIPW_OFDM_RATE_12MB_MASK | \
  177. LIBIPW_OFDM_RATE_24MB_MASK)
  178. #define LIBIPW_OFDM_DEFAULT_RATES_MASK (LIBIPW_OFDM_BASIC_RATES_MASK | \
  179. LIBIPW_OFDM_RATE_9MB_MASK | \
  180. LIBIPW_OFDM_RATE_18MB_MASK | \
  181. LIBIPW_OFDM_RATE_36MB_MASK | \
  182. LIBIPW_OFDM_RATE_48MB_MASK | \
  183. LIBIPW_OFDM_RATE_54MB_MASK)
  184. #define LIBIPW_DEFAULT_RATES_MASK (LIBIPW_OFDM_DEFAULT_RATES_MASK | \
  185. LIBIPW_CCK_DEFAULT_RATES_MASK)
  186. #define LIBIPW_NUM_OFDM_RATES 8
  187. #define LIBIPW_NUM_CCK_RATES 4
  188. #define LIBIPW_OFDM_SHIFT_MASK_A 4
  189. /* NOTE: This data is for statistical purposes; not all hardware provides this
  190. * information for frames received.
  191. * For libipw_rx_mgt, you need to set at least the 'len' parameter.
  192. */
  193. struct libipw_rx_stats {
  194. u32 mac_time;
  195. s8 rssi;
  196. u8 signal;
  197. u8 noise;
  198. u16 rate; /* in 100 kbps */
  199. u8 received_channel;
  200. u8 control;
  201. u8 mask;
  202. u8 freq;
  203. u16 len;
  204. u64 tsf;
  205. u32 beacon_time;
  206. };
  207. /* IEEE 802.11 requires that STA supports concurrent reception of at least
  208. * three fragmented frames. This define can be increased to support more
  209. * concurrent frames, but it should be noted that each entry can consume about
  210. * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
  211. #define LIBIPW_FRAG_CACHE_LEN 4
  212. struct libipw_frag_entry {
  213. unsigned long first_frag_time;
  214. unsigned int seq;
  215. unsigned int last_frag;
  216. struct sk_buff *skb;
  217. u8 src_addr[ETH_ALEN];
  218. u8 dst_addr[ETH_ALEN];
  219. };
  220. struct libipw_stats {
  221. unsigned int tx_unicast_frames;
  222. unsigned int tx_multicast_frames;
  223. unsigned int tx_fragments;
  224. unsigned int tx_unicast_octets;
  225. unsigned int tx_multicast_octets;
  226. unsigned int tx_deferred_transmissions;
  227. unsigned int tx_single_retry_frames;
  228. unsigned int tx_multiple_retry_frames;
  229. unsigned int tx_retry_limit_exceeded;
  230. unsigned int tx_discards;
  231. unsigned int rx_unicast_frames;
  232. unsigned int rx_multicast_frames;
  233. unsigned int rx_fragments;
  234. unsigned int rx_unicast_octets;
  235. unsigned int rx_multicast_octets;
  236. unsigned int rx_fcs_errors;
  237. unsigned int rx_discards_no_buffer;
  238. unsigned int tx_discards_wrong_sa;
  239. unsigned int rx_discards_undecryptable;
  240. unsigned int rx_message_in_msg_fragments;
  241. unsigned int rx_message_in_bad_msg_fragments;
  242. };
  243. struct libipw_device;
  244. #define SEC_KEY_1 (1<<0)
  245. #define SEC_KEY_2 (1<<1)
  246. #define SEC_KEY_3 (1<<2)
  247. #define SEC_KEY_4 (1<<3)
  248. #define SEC_ACTIVE_KEY (1<<4)
  249. #define SEC_AUTH_MODE (1<<5)
  250. #define SEC_UNICAST_GROUP (1<<6)
  251. #define SEC_LEVEL (1<<7)
  252. #define SEC_ENABLED (1<<8)
  253. #define SEC_ENCRYPT (1<<9)
  254. #define SEC_LEVEL_0 0 /* None */
  255. #define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */
  256. #define SEC_LEVEL_2 2 /* Level 1 + TKIP */
  257. #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
  258. #define SEC_LEVEL_3 4 /* Level 2 + CCMP */
  259. #define SEC_ALG_NONE 0
  260. #define SEC_ALG_WEP 1
  261. #define SEC_ALG_TKIP 2
  262. #define SEC_ALG_CCMP 3
  263. #define WEP_KEYS 4
  264. #define WEP_KEY_LEN 13
  265. #define SCM_KEY_LEN 32
  266. #define SCM_TEMPORAL_KEY_LENGTH 16
  267. struct libipw_security {
  268. u16 active_key:2, enabled:1, unicast_uses_group:1, encrypt:1;
  269. u8 auth_mode;
  270. u8 encode_alg[WEP_KEYS];
  271. u8 key_sizes[WEP_KEYS];
  272. u8 keys[WEP_KEYS][SCM_KEY_LEN];
  273. u8 level;
  274. u16 flags;
  275. } __packed;
  276. /*
  277. 802.11 data frame from AP
  278. ,-------------------------------------------------------------------.
  279. Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
  280. |------|------|---------|---------|---------|------|---------|------|
  281. Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs |
  282. | | tion | (BSSID) | | | ence | data | |
  283. `-------------------------------------------------------------------'
  284. Total: 28-2340 bytes
  285. */
  286. #define BEACON_PROBE_SSID_ID_POSITION 12
  287. struct libipw_hdr_1addr {
  288. __le16 frame_ctl;
  289. __le16 duration_id;
  290. u8 addr1[ETH_ALEN];
  291. u8 payload[0];
  292. } __packed;
  293. struct libipw_hdr_2addr {
  294. __le16 frame_ctl;
  295. __le16 duration_id;
  296. u8 addr1[ETH_ALEN];
  297. u8 addr2[ETH_ALEN];
  298. u8 payload[0];
  299. } __packed;
  300. struct libipw_hdr_3addr {
  301. __le16 frame_ctl;
  302. __le16 duration_id;
  303. u8 addr1[ETH_ALEN];
  304. u8 addr2[ETH_ALEN];
  305. u8 addr3[ETH_ALEN];
  306. __le16 seq_ctl;
  307. u8 payload[0];
  308. } __packed;
  309. struct libipw_hdr_4addr {
  310. __le16 frame_ctl;
  311. __le16 duration_id;
  312. u8 addr1[ETH_ALEN];
  313. u8 addr2[ETH_ALEN];
  314. u8 addr3[ETH_ALEN];
  315. __le16 seq_ctl;
  316. u8 addr4[ETH_ALEN];
  317. u8 payload[0];
  318. } __packed;
  319. struct libipw_hdr_3addrqos {
  320. __le16 frame_ctl;
  321. __le16 duration_id;
  322. u8 addr1[ETH_ALEN];
  323. u8 addr2[ETH_ALEN];
  324. u8 addr3[ETH_ALEN];
  325. __le16 seq_ctl;
  326. u8 payload[0];
  327. __le16 qos_ctl;
  328. } __packed;
  329. struct libipw_info_element {
  330. u8 id;
  331. u8 len;
  332. u8 data[0];
  333. } __packed;
  334. /*
  335. * These are the data types that can make up management packets
  336. *
  337. u16 auth_algorithm;
  338. u16 auth_sequence;
  339. u16 beacon_interval;
  340. u16 capability;
  341. u8 current_ap[ETH_ALEN];
  342. u16 listen_interval;
  343. struct {
  344. u16 association_id:14, reserved:2;
  345. } __packed;
  346. u32 time_stamp[2];
  347. u16 reason;
  348. u16 status;
  349. */
  350. struct libipw_auth {
  351. struct libipw_hdr_3addr header;
  352. __le16 algorithm;
  353. __le16 transaction;
  354. __le16 status;
  355. /* challenge */
  356. struct libipw_info_element info_element[0];
  357. } __packed;
  358. struct libipw_channel_switch {
  359. u8 id;
  360. u8 len;
  361. u8 mode;
  362. u8 channel;
  363. u8 count;
  364. } __packed;
  365. struct libipw_action {
  366. struct libipw_hdr_3addr header;
  367. u8 category;
  368. u8 action;
  369. union {
  370. struct libipw_action_exchange {
  371. u8 token;
  372. struct libipw_info_element info_element[0];
  373. } exchange;
  374. struct libipw_channel_switch channel_switch;
  375. } format;
  376. } __packed;
  377. struct libipw_disassoc {
  378. struct libipw_hdr_3addr header;
  379. __le16 reason;
  380. } __packed;
  381. /* Alias deauth for disassoc */
  382. #define libipw_deauth libipw_disassoc
  383. struct libipw_probe_request {
  384. struct libipw_hdr_3addr header;
  385. /* SSID, supported rates */
  386. struct libipw_info_element info_element[0];
  387. } __packed;
  388. struct libipw_probe_response {
  389. struct libipw_hdr_3addr header;
  390. __le32 time_stamp[2];
  391. __le16 beacon_interval;
  392. __le16 capability;
  393. /* SSID, supported rates, FH params, DS params,
  394. * CF params, IBSS params, TIM (if beacon), RSN */
  395. struct libipw_info_element info_element[0];
  396. } __packed;
  397. /* Alias beacon for probe_response */
  398. #define libipw_beacon libipw_probe_response
  399. struct libipw_assoc_request {
  400. struct libipw_hdr_3addr header;
  401. __le16 capability;
  402. __le16 listen_interval;
  403. /* SSID, supported rates, RSN */
  404. struct libipw_info_element info_element[0];
  405. } __packed;
  406. struct libipw_reassoc_request {
  407. struct libipw_hdr_3addr header;
  408. __le16 capability;
  409. __le16 listen_interval;
  410. u8 current_ap[ETH_ALEN];
  411. struct libipw_info_element info_element[0];
  412. } __packed;
  413. struct libipw_assoc_response {
  414. struct libipw_hdr_3addr header;
  415. __le16 capability;
  416. __le16 status;
  417. __le16 aid;
  418. /* supported rates */
  419. struct libipw_info_element info_element[0];
  420. } __packed;
  421. struct libipw_txb {
  422. u8 nr_frags;
  423. u8 encrypted;
  424. u8 rts_included;
  425. u8 reserved;
  426. u16 frag_size;
  427. u16 payload_size;
  428. struct sk_buff *fragments[0];
  429. };
  430. /* SWEEP TABLE ENTRIES NUMBER */
  431. #define MAX_SWEEP_TAB_ENTRIES 42
  432. #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
  433. /* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs
  434. * only use 8, and then use extended rates for the remaining supported
  435. * rates. Other APs, however, stick all of their supported rates on the
  436. * main rates information element... */
  437. #define MAX_RATES_LENGTH ((u8)12)
  438. #define MAX_RATES_EX_LENGTH ((u8)16)
  439. #define MAX_NETWORK_COUNT 128
  440. #define CRC_LENGTH 4U
  441. #define MAX_WPA_IE_LEN 64
  442. #define NETWORK_HAS_OFDM (1<<1)
  443. #define NETWORK_HAS_CCK (1<<2)
  444. /* QoS structure */
  445. #define NETWORK_HAS_QOS_PARAMETERS (1<<3)
  446. #define NETWORK_HAS_QOS_INFORMATION (1<<4)
  447. #define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \
  448. NETWORK_HAS_QOS_INFORMATION)
  449. /* 802.11h */
  450. #define NETWORK_HAS_POWER_CONSTRAINT (1<<5)
  451. #define NETWORK_HAS_CSA (1<<6)
  452. #define NETWORK_HAS_QUIET (1<<7)
  453. #define NETWORK_HAS_IBSS_DFS (1<<8)
  454. #define NETWORK_HAS_TPC_REPORT (1<<9)
  455. #define NETWORK_HAS_ERP_VALUE (1<<10)
  456. #define QOS_QUEUE_NUM 4
  457. #define QOS_OUI_LEN 3
  458. #define QOS_OUI_TYPE 2
  459. #define QOS_ELEMENT_ID 221
  460. #define QOS_OUI_INFO_SUB_TYPE 0
  461. #define QOS_OUI_PARAM_SUB_TYPE 1
  462. #define QOS_VERSION_1 1
  463. #define QOS_AIFSN_MIN_VALUE 2
  464. struct libipw_qos_information_element {
  465. u8 elementID;
  466. u8 length;
  467. u8 qui[QOS_OUI_LEN];
  468. u8 qui_type;
  469. u8 qui_subtype;
  470. u8 version;
  471. u8 ac_info;
  472. } __packed;
  473. struct libipw_qos_ac_parameter {
  474. u8 aci_aifsn;
  475. u8 ecw_min_max;
  476. __le16 tx_op_limit;
  477. } __packed;
  478. struct libipw_qos_parameter_info {
  479. struct libipw_qos_information_element info_element;
  480. u8 reserved;
  481. struct libipw_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM];
  482. } __packed;
  483. struct libipw_qos_parameters {
  484. __le16 cw_min[QOS_QUEUE_NUM];
  485. __le16 cw_max[QOS_QUEUE_NUM];
  486. u8 aifs[QOS_QUEUE_NUM];
  487. u8 flag[QOS_QUEUE_NUM];
  488. __le16 tx_op_limit[QOS_QUEUE_NUM];
  489. } __packed;
  490. struct libipw_qos_data {
  491. struct libipw_qos_parameters parameters;
  492. int active;
  493. int supported;
  494. u8 param_count;
  495. u8 old_param_count;
  496. };
  497. struct libipw_tim_parameters {
  498. u8 tim_count;
  499. u8 tim_period;
  500. } __packed;
  501. /*******************************************************/
  502. enum { /* libipw_basic_report.map */
  503. LIBIPW_BASIC_MAP_BSS = (1 << 0),
  504. LIBIPW_BASIC_MAP_OFDM = (1 << 1),
  505. LIBIPW_BASIC_MAP_UNIDENTIFIED = (1 << 2),
  506. LIBIPW_BASIC_MAP_RADAR = (1 << 3),
  507. LIBIPW_BASIC_MAP_UNMEASURED = (1 << 4),
  508. /* Bits 5-7 are reserved */
  509. };
  510. struct libipw_basic_report {
  511. u8 channel;
  512. __le64 start_time;
  513. __le16 duration;
  514. u8 map;
  515. } __packed;
  516. enum { /* libipw_measurement_request.mode */
  517. /* Bit 0 is reserved */
  518. LIBIPW_MEASUREMENT_ENABLE = (1 << 1),
  519. LIBIPW_MEASUREMENT_REQUEST = (1 << 2),
  520. LIBIPW_MEASUREMENT_REPORT = (1 << 3),
  521. /* Bits 4-7 are reserved */
  522. };
  523. enum {
  524. LIBIPW_REPORT_BASIC = 0, /* required */
  525. LIBIPW_REPORT_CCA = 1, /* optional */
  526. LIBIPW_REPORT_RPI = 2, /* optional */
  527. /* 3-255 reserved */
  528. };
  529. struct libipw_measurement_params {
  530. u8 channel;
  531. __le64 start_time;
  532. __le16 duration;
  533. } __packed;
  534. struct libipw_measurement_request {
  535. struct libipw_info_element ie;
  536. u8 token;
  537. u8 mode;
  538. u8 type;
  539. struct libipw_measurement_params params[0];
  540. } __packed;
  541. struct libipw_measurement_report {
  542. struct libipw_info_element ie;
  543. u8 token;
  544. u8 mode;
  545. u8 type;
  546. union {
  547. struct libipw_basic_report basic[0];
  548. } u;
  549. } __packed;
  550. struct libipw_tpc_report {
  551. u8 transmit_power;
  552. u8 link_margin;
  553. } __packed;
  554. struct libipw_channel_map {
  555. u8 channel;
  556. u8 map;
  557. } __packed;
  558. struct libipw_ibss_dfs {
  559. struct libipw_info_element ie;
  560. u8 owner[ETH_ALEN];
  561. u8 recovery_interval;
  562. struct libipw_channel_map channel_map[0];
  563. };
  564. struct libipw_csa {
  565. u8 mode;
  566. u8 channel;
  567. u8 count;
  568. } __packed;
  569. struct libipw_quiet {
  570. u8 count;
  571. u8 period;
  572. u8 duration;
  573. u8 offset;
  574. } __packed;
  575. struct libipw_network {
  576. /* These entries are used to identify a unique network */
  577. u8 bssid[ETH_ALEN];
  578. u8 channel;
  579. /* Ensure null-terminated for any debug msgs */
  580. u8 ssid[IW_ESSID_MAX_SIZE + 1];
  581. u8 ssid_len;
  582. struct libipw_qos_data qos_data;
  583. /* These are network statistics */
  584. struct libipw_rx_stats stats;
  585. u16 capability;
  586. u8 rates[MAX_RATES_LENGTH];
  587. u8 rates_len;
  588. u8 rates_ex[MAX_RATES_EX_LENGTH];
  589. u8 rates_ex_len;
  590. unsigned long last_scanned;
  591. u8 mode;
  592. u32 flags;
  593. u32 last_associate;
  594. u32 time_stamp[2];
  595. u16 beacon_interval;
  596. u16 listen_interval;
  597. u16 atim_window;
  598. u8 erp_value;
  599. u8 wpa_ie[MAX_WPA_IE_LEN];
  600. size_t wpa_ie_len;
  601. u8 rsn_ie[MAX_WPA_IE_LEN];
  602. size_t rsn_ie_len;
  603. struct libipw_tim_parameters tim;
  604. /* 802.11h info */
  605. /* Power Constraint - mandatory if spctrm mgmt required */
  606. u8 power_constraint;
  607. /* TPC Report - mandatory if spctrm mgmt required */
  608. struct libipw_tpc_report tpc_report;
  609. /* IBSS DFS - mandatory if spctrm mgmt required and IBSS
  610. * NOTE: This is variable length and so must be allocated dynamically */
  611. struct libipw_ibss_dfs *ibss_dfs;
  612. /* Channel Switch Announcement - optional if spctrm mgmt required */
  613. struct libipw_csa csa;
  614. /* Quiet - optional if spctrm mgmt required */
  615. struct libipw_quiet quiet;
  616. struct list_head list;
  617. };
  618. enum libipw_state {
  619. LIBIPW_UNINITIALIZED = 0,
  620. LIBIPW_INITIALIZED,
  621. LIBIPW_ASSOCIATING,
  622. LIBIPW_ASSOCIATED,
  623. LIBIPW_AUTHENTICATING,
  624. LIBIPW_AUTHENTICATED,
  625. LIBIPW_SHUTDOWN
  626. };
  627. #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
  628. #define DEFAULT_FTS 2346
  629. #define CFG_LIBIPW_RESERVE_FCS (1<<0)
  630. #define CFG_LIBIPW_COMPUTE_FCS (1<<1)
  631. #define CFG_LIBIPW_RTS (1<<2)
  632. #define LIBIPW_24GHZ_MIN_CHANNEL 1
  633. #define LIBIPW_24GHZ_MAX_CHANNEL 14
  634. #define LIBIPW_24GHZ_CHANNELS (LIBIPW_24GHZ_MAX_CHANNEL - \
  635. LIBIPW_24GHZ_MIN_CHANNEL + 1)
  636. #define LIBIPW_52GHZ_MIN_CHANNEL 34
  637. #define LIBIPW_52GHZ_MAX_CHANNEL 165
  638. #define LIBIPW_52GHZ_CHANNELS (LIBIPW_52GHZ_MAX_CHANNEL - \
  639. LIBIPW_52GHZ_MIN_CHANNEL + 1)
  640. enum {
  641. LIBIPW_CH_PASSIVE_ONLY = (1 << 0),
  642. LIBIPW_CH_80211H_RULES = (1 << 1),
  643. LIBIPW_CH_B_ONLY = (1 << 2),
  644. LIBIPW_CH_NO_IBSS = (1 << 3),
  645. LIBIPW_CH_UNIFORM_SPREADING = (1 << 4),
  646. LIBIPW_CH_RADAR_DETECT = (1 << 5),
  647. LIBIPW_CH_INVALID = (1 << 6),
  648. };
  649. struct libipw_channel {
  650. u32 freq; /* in MHz */
  651. u8 channel;
  652. u8 flags;
  653. u8 max_power; /* in dBm */
  654. };
  655. struct libipw_geo {
  656. u8 name[4];
  657. u8 bg_channels;
  658. u8 a_channels;
  659. struct libipw_channel bg[LIBIPW_24GHZ_CHANNELS];
  660. struct libipw_channel a[LIBIPW_52GHZ_CHANNELS];
  661. };
  662. struct libipw_device {
  663. struct net_device *dev;
  664. struct wireless_dev wdev;
  665. struct libipw_security sec;
  666. /* Bookkeeping structures */
  667. struct libipw_stats ieee_stats;
  668. struct libipw_geo geo;
  669. struct ieee80211_supported_band bg_band;
  670. struct ieee80211_supported_band a_band;
  671. /* Probe / Beacon management */
  672. struct list_head network_free_list;
  673. struct list_head network_list;
  674. struct libipw_network *networks[MAX_NETWORK_COUNT];
  675. int scans;
  676. int scan_age;
  677. int iw_mode; /* operating mode (IW_MODE_*) */
  678. struct iw_spy_data spy_data; /* iwspy support */
  679. spinlock_t lock;
  680. int tx_headroom; /* Set to size of any additional room needed at front
  681. * of allocated Tx SKBs */
  682. u32 config;
  683. /* WEP and other encryption related settings at the device level */
  684. int open_wep; /* Set to 1 to allow unencrypted frames */
  685. /* If the host performs {en,de}cryption, then set to 1 */
  686. int host_encrypt;
  687. int host_encrypt_msdu;
  688. int host_decrypt;
  689. /* host performs multicast decryption */
  690. int host_mc_decrypt;
  691. /* host should strip IV and ICV from protected frames */
  692. /* meaningful only when hardware decryption is being used */
  693. int host_strip_iv_icv;
  694. int host_open_frag;
  695. int ieee802_1x; /* is IEEE 802.1X used */
  696. /* WPA data */
  697. int wpa_enabled;
  698. int drop_unencrypted;
  699. int privacy_invoked;
  700. size_t wpa_ie_len;
  701. u8 *wpa_ie;
  702. struct lib80211_crypt_info crypt_info;
  703. int bcrx_sta_key; /* use individual keys to override default keys even
  704. * with RX of broad/multicast frames */
  705. /* Fragmentation structures */
  706. struct libipw_frag_entry frag_cache[LIBIPW_FRAG_CACHE_LEN];
  707. unsigned int frag_next_idx;
  708. u16 fts; /* Fragmentation Threshold */
  709. u16 rts; /* RTS threshold */
  710. /* Association info */
  711. u8 bssid[ETH_ALEN];
  712. enum libipw_state state;
  713. int mode; /* A, B, G */
  714. int modulation; /* CCK, OFDM */
  715. int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */
  716. int abg_true; /* ABG flag */
  717. int perfect_rssi;
  718. int worst_rssi;
  719. u16 prev_seq_ctl; /* used to drop duplicate frames */
  720. /* Callback functions */
  721. void (*set_security) (struct net_device * dev,
  722. struct libipw_security * sec);
  723. netdev_tx_t (*hard_start_xmit) (struct libipw_txb * txb,
  724. struct net_device * dev, int pri);
  725. int (*is_queue_full) (struct net_device * dev, int pri);
  726. int (*handle_management) (struct net_device * dev,
  727. struct libipw_network * network, u16 type);
  728. int (*is_qos_active) (struct net_device *dev, struct sk_buff *skb);
  729. /* Typical STA methods */
  730. int (*handle_auth) (struct net_device * dev,
  731. struct libipw_auth * auth);
  732. int (*handle_deauth) (struct net_device * dev,
  733. struct libipw_deauth * auth);
  734. int (*handle_action) (struct net_device * dev,
  735. struct libipw_action * action,
  736. struct libipw_rx_stats * stats);
  737. int (*handle_disassoc) (struct net_device * dev,
  738. struct libipw_disassoc * assoc);
  739. int (*handle_beacon) (struct net_device * dev,
  740. struct libipw_beacon * beacon,
  741. struct libipw_network * network);
  742. int (*handle_probe_response) (struct net_device * dev,
  743. struct libipw_probe_response * resp,
  744. struct libipw_network * network);
  745. int (*handle_probe_request) (struct net_device * dev,
  746. struct libipw_probe_request * req,
  747. struct libipw_rx_stats * stats);
  748. int (*handle_assoc_response) (struct net_device * dev,
  749. struct libipw_assoc_response * resp,
  750. struct libipw_network * network);
  751. /* Typical AP methods */
  752. int (*handle_assoc_request) (struct net_device * dev);
  753. int (*handle_reassoc_request) (struct net_device * dev,
  754. struct libipw_reassoc_request * req);
  755. /* This must be the last item so that it points to the data
  756. * allocated beyond this structure by alloc_libipw */
  757. u8 priv[0];
  758. };
  759. #define IEEE_A (1<<0)
  760. #define IEEE_B (1<<1)
  761. #define IEEE_G (1<<2)
  762. #define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
  763. static inline void *libipw_priv(struct net_device *dev)
  764. {
  765. return ((struct libipw_device *)netdev_priv(dev))->priv;
  766. }
  767. static inline int libipw_is_valid_mode(struct libipw_device *ieee,
  768. int mode)
  769. {
  770. /*
  771. * It is possible for both access points and our device to support
  772. * combinations of modes, so as long as there is one valid combination
  773. * of ap/device supported modes, then return success
  774. *
  775. */
  776. if ((mode & IEEE_A) &&
  777. (ieee->modulation & LIBIPW_OFDM_MODULATION) &&
  778. (ieee->freq_band & LIBIPW_52GHZ_BAND))
  779. return 1;
  780. if ((mode & IEEE_G) &&
  781. (ieee->modulation & LIBIPW_OFDM_MODULATION) &&
  782. (ieee->freq_band & LIBIPW_24GHZ_BAND))
  783. return 1;
  784. if ((mode & IEEE_B) &&
  785. (ieee->modulation & LIBIPW_CCK_MODULATION) &&
  786. (ieee->freq_band & LIBIPW_24GHZ_BAND))
  787. return 1;
  788. return 0;
  789. }
  790. static inline int libipw_get_hdrlen(u16 fc)
  791. {
  792. int hdrlen = LIBIPW_3ADDR_LEN;
  793. u16 stype = WLAN_FC_GET_STYPE(fc);
  794. switch (WLAN_FC_GET_TYPE(fc)) {
  795. case IEEE80211_FTYPE_DATA:
  796. if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
  797. hdrlen = LIBIPW_4ADDR_LEN;
  798. if (stype & IEEE80211_STYPE_QOS_DATA)
  799. hdrlen += 2;
  800. break;
  801. case IEEE80211_FTYPE_CTL:
  802. switch (WLAN_FC_GET_STYPE(fc)) {
  803. case IEEE80211_STYPE_CTS:
  804. case IEEE80211_STYPE_ACK:
  805. hdrlen = LIBIPW_1ADDR_LEN;
  806. break;
  807. default:
  808. hdrlen = LIBIPW_2ADDR_LEN;
  809. break;
  810. }
  811. break;
  812. }
  813. return hdrlen;
  814. }
  815. static inline u8 *libipw_get_payload(struct ieee80211_hdr *hdr)
  816. {
  817. switch (libipw_get_hdrlen(le16_to_cpu(hdr->frame_control))) {
  818. case LIBIPW_1ADDR_LEN:
  819. return ((struct libipw_hdr_1addr *)hdr)->payload;
  820. case LIBIPW_2ADDR_LEN:
  821. return ((struct libipw_hdr_2addr *)hdr)->payload;
  822. case LIBIPW_3ADDR_LEN:
  823. return ((struct libipw_hdr_3addr *)hdr)->payload;
  824. case LIBIPW_4ADDR_LEN:
  825. return ((struct libipw_hdr_4addr *)hdr)->payload;
  826. }
  827. return NULL;
  828. }
  829. static inline int libipw_is_ofdm_rate(u8 rate)
  830. {
  831. switch (rate & ~LIBIPW_BASIC_RATE_MASK) {
  832. case LIBIPW_OFDM_RATE_6MB:
  833. case LIBIPW_OFDM_RATE_9MB:
  834. case LIBIPW_OFDM_RATE_12MB:
  835. case LIBIPW_OFDM_RATE_18MB:
  836. case LIBIPW_OFDM_RATE_24MB:
  837. case LIBIPW_OFDM_RATE_36MB:
  838. case LIBIPW_OFDM_RATE_48MB:
  839. case LIBIPW_OFDM_RATE_54MB:
  840. return 1;
  841. }
  842. return 0;
  843. }
  844. static inline int libipw_is_cck_rate(u8 rate)
  845. {
  846. switch (rate & ~LIBIPW_BASIC_RATE_MASK) {
  847. case LIBIPW_CCK_RATE_1MB:
  848. case LIBIPW_CCK_RATE_2MB:
  849. case LIBIPW_CCK_RATE_5MB:
  850. case LIBIPW_CCK_RATE_11MB:
  851. return 1;
  852. }
  853. return 0;
  854. }
  855. /* libipw.c */
  856. extern void free_libipw(struct net_device *dev, int monitor);
  857. extern struct net_device *alloc_libipw(int sizeof_priv, int monitor);
  858. extern int libipw_change_mtu(struct net_device *dev, int new_mtu);
  859. extern void libipw_networks_age(struct libipw_device *ieee,
  860. unsigned long age_secs);
  861. extern int libipw_set_encryption(struct libipw_device *ieee);
  862. /* libipw_tx.c */
  863. extern netdev_tx_t libipw_xmit(struct sk_buff *skb,
  864. struct net_device *dev);
  865. extern void libipw_txb_free(struct libipw_txb *);
  866. /* libipw_rx.c */
  867. extern void libipw_rx_any(struct libipw_device *ieee,
  868. struct sk_buff *skb, struct libipw_rx_stats *stats);
  869. extern int libipw_rx(struct libipw_device *ieee, struct sk_buff *skb,
  870. struct libipw_rx_stats *rx_stats);
  871. /* make sure to set stats->len */
  872. extern void libipw_rx_mgt(struct libipw_device *ieee,
  873. struct libipw_hdr_4addr *header,
  874. struct libipw_rx_stats *stats);
  875. extern void libipw_network_reset(struct libipw_network *network);
  876. /* libipw_geo.c */
  877. extern const struct libipw_geo *libipw_get_geo(struct libipw_device
  878. *ieee);
  879. extern int libipw_set_geo(struct libipw_device *ieee,
  880. const struct libipw_geo *geo);
  881. extern int libipw_is_valid_channel(struct libipw_device *ieee,
  882. u8 channel);
  883. extern int libipw_channel_to_index(struct libipw_device *ieee,
  884. u8 channel);
  885. extern u8 libipw_freq_to_channel(struct libipw_device *ieee, u32 freq);
  886. extern u8 libipw_get_channel_flags(struct libipw_device *ieee,
  887. u8 channel);
  888. extern const struct libipw_channel *libipw_get_channel(struct
  889. libipw_device
  890. *ieee, u8 channel);
  891. extern u32 libipw_channel_to_freq(struct libipw_device * ieee,
  892. u8 channel);
  893. /* libipw_wx.c */
  894. extern int libipw_wx_get_scan(struct libipw_device *ieee,
  895. struct iw_request_info *info,
  896. union iwreq_data *wrqu, char *key);
  897. extern int libipw_wx_set_encode(struct libipw_device *ieee,
  898. struct iw_request_info *info,
  899. union iwreq_data *wrqu, char *key);
  900. extern int libipw_wx_get_encode(struct libipw_device *ieee,
  901. struct iw_request_info *info,
  902. union iwreq_data *wrqu, char *key);
  903. extern int libipw_wx_set_encodeext(struct libipw_device *ieee,
  904. struct iw_request_info *info,
  905. union iwreq_data *wrqu, char *extra);
  906. extern int libipw_wx_get_encodeext(struct libipw_device *ieee,
  907. struct iw_request_info *info,
  908. union iwreq_data *wrqu, char *extra);
  909. static inline void libipw_increment_scans(struct libipw_device *ieee)
  910. {
  911. ieee->scans++;
  912. }
  913. static inline int libipw_get_scans(struct libipw_device *ieee)
  914. {
  915. return ieee->scans;
  916. }
  917. #endif /* LIBIPW_H */