ieee80211.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of version 2 of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  17. *
  18. * Modifications for inclusion into the Linux staging tree are
  19. * Copyright(c) 2010 Larry Finger. All rights reserved.
  20. *
  21. * Contact information:
  22. * WLAN FAE <wlanfae@realtek.com>
  23. * Larry Finger <Larry.Finger@lwfinger.net>
  24. *
  25. ******************************************************************************/
  26. #ifndef __IEEE80211_H
  27. #define __IEEE80211_H
  28. #include "osdep_service.h"
  29. #include "drv_types.h"
  30. #include "wifi.h"
  31. #include <linux/compiler.h>
  32. #include <linux/wireless.h>
  33. #define MGMT_QUEUE_NUM 5
  34. #define ETH_ALEN 6
  35. #define IEEE_CMD_SET_WPA_PARAM 1
  36. #define IEEE_CMD_SET_WPA_IE 2
  37. #define IEEE_CMD_SET_ENCRYPTION 3
  38. #define IEEE_CMD_MLME 4
  39. #define IEEE_PARAM_WPA_ENABLED 1
  40. #define IEEE_PARAM_TKIP_COUNTERMEASURES 2
  41. #define IEEE_PARAM_DROP_UNENCRYPTED 3
  42. #define IEEE_PARAM_PRIVACY_INVOKED 4
  43. #define IEEE_PARAM_AUTH_ALGS 5
  44. #define IEEE_PARAM_IEEE_802_1X 6
  45. #define IEEE_PARAM_WPAX_SELECT 7
  46. #define AUTH_ALG_OPEN_SYSTEM 0x1
  47. #define AUTH_ALG_SHARED_KEY 0x2
  48. #define AUTH_ALG_LEAP 0x00000004
  49. #define IEEE_MLME_STA_DEAUTH 1
  50. #define IEEE_MLME_STA_DISASSOC 2
  51. #define IEEE_CRYPT_ERR_UNKNOWN_ALG 2
  52. #define IEEE_CRYPT_ERR_UNKNOWN_ADDR 3
  53. #define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED 4
  54. #define IEEE_CRYPT_ERR_KEY_SET_FAILED 5
  55. #define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED 6
  56. #define IEEE_CRYPT_ERR_CARD_CONF_FAILED 7
  57. #define IEEE_CRYPT_ALG_NAME_LEN 16
  58. #define WPA_CIPHER_NONE BIT(0)
  59. #define WPA_CIPHER_WEP40 BIT(1)
  60. #define WPA_CIPHER_WEP104 BIT(2)
  61. #define WPA_CIPHER_TKIP BIT(3)
  62. #define WPA_CIPHER_CCMP BIT(4)
  63. #define WPA_SELECTOR_LEN 4
  64. #define RSN_HEADER_LEN 4
  65. #define RSN_SELECTOR_LEN 4
  66. enum NETWORK_TYPE {
  67. WIRELESS_INVALID = 0,
  68. WIRELESS_11B = 1,
  69. WIRELESS_11G = 2,
  70. WIRELESS_11BG = (WIRELESS_11B | WIRELESS_11G),
  71. WIRELESS_11A = 4,
  72. WIRELESS_11N = 8,
  73. WIRELESS_11GN = (WIRELESS_11G | WIRELESS_11N),
  74. WIRELESS_11BGN = (WIRELESS_11B | WIRELESS_11G | WIRELESS_11N),
  75. };
  76. struct ieee_param {
  77. u32 cmd;
  78. u8 sta_addr[ETH_ALEN];
  79. union {
  80. struct {
  81. u8 name;
  82. u32 value;
  83. } wpa_param;
  84. struct {
  85. u32 len;
  86. u8 reserved[32];
  87. u8 data[0];
  88. } wpa_ie;
  89. struct {
  90. int command;
  91. int reason_code;
  92. } mlme;
  93. struct {
  94. u8 alg[IEEE_CRYPT_ALG_NAME_LEN];
  95. u8 set_tx;
  96. u32 err;
  97. u8 idx;
  98. u8 seq[8]; /* sequence counter (set: RX, get: TX) */
  99. u16 key_len;
  100. u8 key[0];
  101. } crypt;
  102. } u;
  103. };
  104. #define IEEE80211_DATA_LEN 2304
  105. /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
  106. * 6.2.1.1.2.
  107. *
  108. * The figure in section 7.1.2 suggests a body size of up to 2312
  109. * bytes is allowed, which is a bit confusing, I suspect this
  110. * represents the 2304 bytes of real data, plus a possible 8 bytes of
  111. * WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro)
  112. */
  113. #define IEEE80211_HLEN 30
  114. #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
  115. /* this is stolen from ipw2200 driver */
  116. #define IEEE_IBSS_MAC_HASH_SIZE 31
  117. struct ieee_ibss_seq {
  118. u8 mac[ETH_ALEN];
  119. u16 seq_num;
  120. u16 frag_num;
  121. unsigned long packet_time;
  122. struct list_head list;
  123. };
  124. struct ieee80211_hdr {
  125. __le16 frame_ctl;
  126. __le16 duration_id;
  127. u8 addr1[ETH_ALEN];
  128. u8 addr2[ETH_ALEN];
  129. u8 addr3[ETH_ALEN];
  130. __le16 seq_ctl;
  131. u8 addr4[ETH_ALEN];
  132. } __packed __aligned(2);
  133. struct ieee80211_hdr_3addr {
  134. __le16 frame_ctl;
  135. __le16 duration_id;
  136. u8 addr1[ETH_ALEN];
  137. u8 addr2[ETH_ALEN];
  138. u8 addr3[ETH_ALEN];
  139. __le16 seq_ctl;
  140. } __packed __aligned(2);
  141. struct ieee80211_hdr_qos {
  142. __le16 frame_ctl;
  143. __le16 duration_id;
  144. u8 addr1[ETH_ALEN];
  145. u8 addr2[ETH_ALEN];
  146. u8 addr3[ETH_ALEN];
  147. __le16 seq_ctl;
  148. u8 addr4[ETH_ALEN];
  149. __le16 qc;
  150. } __packed __aligned(2);
  151. struct ieee80211_hdr_3addr_qos {
  152. __le16 frame_ctl;
  153. __le16 duration_id;
  154. u8 addr1[ETH_ALEN];
  155. u8 addr2[ETH_ALEN];
  156. u8 addr3[ETH_ALEN];
  157. __le16 seq_ctl;
  158. __le16 qc;
  159. } __packed;
  160. struct eapol {
  161. u8 snap[6];
  162. __be16 ethertype;
  163. u8 version;
  164. u8 type;
  165. __le16 length;
  166. } __packed;
  167. enum eap_type {
  168. EAP_PACKET = 0,
  169. EAPOL_START,
  170. EAPOL_LOGOFF,
  171. EAPOL_KEY,
  172. EAPOL_ENCAP_ASF_ALERT
  173. };
  174. #define IEEE80211_3ADDR_LEN 24
  175. #define IEEE80211_4ADDR_LEN 30
  176. #define IEEE80211_FCS_LEN 4
  177. #define MIN_FRAG_THRESHOLD 256U
  178. #define MAX_FRAG_THRESHOLD 2346U
  179. /* Frame control field constants */
  180. #define IEEE80211_FCTL_VERS 0x0002
  181. #define IEEE80211_FCTL_FTYPE 0x000c
  182. #define IEEE80211_FCTL_STYPE 0x00f0
  183. #define IEEE80211_FCTL_TODS 0x0100
  184. #define IEEE80211_FCTL_FROMDS 0x0200
  185. #define IEEE80211_FCTL_MOREFRAGS 0x0400
  186. #define IEEE80211_FCTL_RETRY 0x0800
  187. #define IEEE80211_FCTL_PM 0x1000
  188. #define IEEE80211_FCTL_MOREDATA 0x2000
  189. #define IEEE80211_FCTL_WEP 0x4000
  190. #define IEEE80211_FCTL_ORDER 0x8000
  191. #define IEEE80211_FTYPE_MGMT 0x0000
  192. #define IEEE80211_FTYPE_CTL 0x0004
  193. #define IEEE80211_FTYPE_DATA 0x0008
  194. /* management */
  195. #define IEEE80211_STYPE_ASSOC_REQ 0x0000
  196. #define IEEE80211_STYPE_ASSOC_RESP 0x0010
  197. #define IEEE80211_STYPE_REASSOC_REQ 0x0020
  198. #define IEEE80211_STYPE_REASSOC_RESP 0x0030
  199. #define IEEE80211_STYPE_PROBE_REQ 0x0040
  200. #define IEEE80211_STYPE_PROBE_RESP 0x0050
  201. #define IEEE80211_STYPE_BEACON 0x0080
  202. #define IEEE80211_STYPE_ATIM 0x0090
  203. #define IEEE80211_STYPE_DISASSOC 0x00A0
  204. #define IEEE80211_STYPE_AUTH 0x00B0
  205. #define IEEE80211_STYPE_DEAUTH 0x00C0
  206. /* control */
  207. #define IEEE80211_STYPE_PSPOLL 0x00A0
  208. #define IEEE80211_STYPE_RTS 0x00B0
  209. #define IEEE80211_STYPE_CTS 0x00C0
  210. #define IEEE80211_STYPE_ACK 0x00D0
  211. #define IEEE80211_STYPE_CFEND 0x00E0
  212. #define IEEE80211_STYPE_CFENDACK 0x00F0
  213. /* data */
  214. #define IEEE80211_STYPE_DATA 0x0000
  215. #define IEEE80211_STYPE_DATA_CFACK 0x0010
  216. #define IEEE80211_STYPE_DATA_CFPOLL 0x0020
  217. #define IEEE80211_STYPE_DATA_CFACKPOLL 0x0030
  218. #define IEEE80211_STYPE_NULLFUNC 0x0040
  219. #define IEEE80211_STYPE_CFACK 0x0050
  220. #define IEEE80211_STYPE_CFPOLL 0x0060
  221. #define IEEE80211_STYPE_CFACKPOLL 0x0070
  222. #define IEEE80211_QOS_DATAGRP 0x0080
  223. #define IEEE80211_QoS_DATAGRP IEEE80211_QOS_DATAGRP
  224. #define IEEE80211_SCTL_FRAG 0x000F
  225. #define IEEE80211_SCTL_SEQ 0xFFF0
  226. /* QoS,QOS */
  227. #define NORMAL_ACK 0
  228. #define NO_ACK 1
  229. #define NON_EXPLICIT_ACK 2
  230. #define BLOCK_ACK 3
  231. #ifndef ETH_P_PAE
  232. #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
  233. #endif /* ETH_P_PAE */
  234. #define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
  235. #define ETH_P_ECONET 0x0018
  236. #ifndef ETH_P_80211_RAW
  237. #define ETH_P_80211_RAW (ETH_P_ECONET + 1)
  238. #endif
  239. /* IEEE 802.11 defines */
  240. #define P80211_OUI_LEN 3
  241. struct ieee80211_snap_hdr {
  242. u8 dsap; /* always 0xAA */
  243. u8 ssap; /* always 0xAA */
  244. u8 ctrl; /* always 0x03 */
  245. u8 oui[P80211_OUI_LEN]; /* organizational universal id */
  246. } __packed;
  247. #define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
  248. #define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE)
  249. #define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE)
  250. #define WLAN_QC_GET_TID(qc) ((qc) & 0x0f)
  251. #define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG)
  252. #define WLAN_GET_SEQ_SEQ(seq) ((seq) & IEEE80211_SCTL_SEQ)
  253. /* Authentication algorithms */
  254. #define WLAN_AUTH_OPEN 0
  255. #define WLAN_AUTH_SHARED_KEY 1
  256. #define WLAN_AUTH_CHALLENGE_LEN 128
  257. #define WLAN_CAPABILITY_BSS (1<<0)
  258. #define WLAN_CAPABILITY_IBSS (1<<1)
  259. #define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
  260. #define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
  261. #define WLAN_CAPABILITY_PRIVACY (1<<4)
  262. #define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
  263. #define WLAN_CAPABILITY_PBCC (1<<6)
  264. #define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
  265. #define WLAN_CAPABILITY_SHORT_SLOT (1<<10)
  266. /* Information Element IDs */
  267. #define WLAN_EID_SSID 0
  268. #define WLAN_EID_SUPP_RATES 1
  269. #define WLAN_EID_FH_PARAMS 2
  270. #define WLAN_EID_DS_PARAMS 3
  271. #define WLAN_EID_CF_PARAMS 4
  272. #define WLAN_EID_TIM 5
  273. #define WLAN_EID_IBSS_PARAMS 6
  274. #define WLAN_EID_CHALLENGE 16
  275. #define WLAN_EID_RSN 48
  276. #define WLAN_EID_GENERIC 221
  277. #define IEEE80211_MGMT_HDR_LEN 24
  278. #define IEEE80211_DATA_HDR3_LEN 24
  279. #define IEEE80211_DATA_HDR4_LEN 30
  280. #define IEEE80211_STATMASK_SIGNAL (1<<0)
  281. #define IEEE80211_STATMASK_RSSI (1<<1)
  282. #define IEEE80211_STATMASK_NOISE (1<<2)
  283. #define IEEE80211_STATMASK_RATE (1<<3)
  284. #define IEEE80211_STATMASK_WEMASK 0x7
  285. #define IEEE80211_CCK_MODULATION (1<<0)
  286. #define IEEE80211_OFDM_MODULATION (1<<1)
  287. #define IEEE80211_24GHZ_BAND (1<<0)
  288. #define IEEE80211_52GHZ_BAND (1<<1)
  289. #define IEEE80211_CCK_RATE_LEN 4
  290. #define IEEE80211_NUM_OFDM_RATESLEN 8
  291. #define IEEE80211_CCK_RATE_1MB 0x02
  292. #define IEEE80211_CCK_RATE_2MB 0x04
  293. #define IEEE80211_CCK_RATE_5MB 0x0B
  294. #define IEEE80211_CCK_RATE_11MB 0x16
  295. #define IEEE80211_OFDM_RATE_LEN 8
  296. #define IEEE80211_OFDM_RATE_6MB 0x0C
  297. #define IEEE80211_OFDM_RATE_9MB 0x12
  298. #define IEEE80211_OFDM_RATE_12MB 0x18
  299. #define IEEE80211_OFDM_RATE_18MB 0x24
  300. #define IEEE80211_OFDM_RATE_24MB 0x30
  301. #define IEEE80211_OFDM_RATE_36MB 0x48
  302. #define IEEE80211_OFDM_RATE_48MB 0x60
  303. #define IEEE80211_OFDM_RATE_54MB 0x6C
  304. #define IEEE80211_BASIC_RATE_MASK 0x80
  305. #define IEEE80211_CCK_RATE_1MB_MASK (1<<0)
  306. #define IEEE80211_CCK_RATE_2MB_MASK (1<<1)
  307. #define IEEE80211_CCK_RATE_5MB_MASK (1<<2)
  308. #define IEEE80211_CCK_RATE_11MB_MASK (1<<3)
  309. #define IEEE80211_OFDM_RATE_6MB_MASK (1<<4)
  310. #define IEEE80211_OFDM_RATE_9MB_MASK (1<<5)
  311. #define IEEE80211_OFDM_RATE_12MB_MASK (1<<6)
  312. #define IEEE80211_OFDM_RATE_18MB_MASK (1<<7)
  313. #define IEEE80211_OFDM_RATE_24MB_MASK (1<<8)
  314. #define IEEE80211_OFDM_RATE_36MB_MASK (1<<9)
  315. #define IEEE80211_OFDM_RATE_48MB_MASK (1<<10)
  316. #define IEEE80211_OFDM_RATE_54MB_MASK (1<<11)
  317. #define IEEE80211_CCK_RATES_MASK 0x0000000F
  318. #define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \
  319. IEEE80211_CCK_RATE_2MB_MASK)
  320. #define IEEE80211_CCK_DEFAULT_RATES_MASK (IEEE80211_CCK_BASIC_RATES_MASK | \
  321. IEEE80211_CCK_RATE_5MB_MASK | \
  322. IEEE80211_CCK_RATE_11MB_MASK)
  323. #define IEEE80211_OFDM_RATES_MASK 0x00000FF0
  324. #define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \
  325. IEEE80211_OFDM_RATE_12MB_MASK | \
  326. IEEE80211_OFDM_RATE_24MB_MASK)
  327. #define IEEE80211_OFDM_DEFAULT_RATES_MASK (IEEE80211_OFDM_BASIC_RATES_MASK | \
  328. IEEE80211_OFDM_RATE_9MB_MASK | \
  329. IEEE80211_OFDM_RATE_18MB_MASK | \
  330. IEEE80211_OFDM_RATE_36MB_MASK | \
  331. IEEE80211_OFDM_RATE_48MB_MASK | \
  332. IEEE80211_OFDM_RATE_54MB_MASK)
  333. #define IEEE80211_DEFAULT_RATES_MASK (IEEE80211_OFDM_DEFAULT_RATES_MASK | \
  334. IEEE80211_CCK_DEFAULT_RATES_MASK)
  335. #define IEEE80211_NUM_OFDM_RATES 8
  336. #define IEEE80211_NUM_CCK_RATES 4
  337. #define IEEE80211_OFDM_SHIFT_MASK_A 4
  338. /* NOTE: This data is for statistical purposes; not all hardware provides this
  339. * information for frames received. Not setting these will not cause
  340. * any adverse affects.
  341. */
  342. struct ieee80211_rx_stats {
  343. s8 rssi;
  344. u8 signal;
  345. u8 noise;
  346. u8 received_channel;
  347. u16 rate; /* in 100 kbps */
  348. u8 mask;
  349. u8 freq;
  350. u16 len;
  351. };
  352. /* IEEE 802.11 requires that STA supports concurrent reception of at least
  353. * three fragmented frames. This define can be increased to support more
  354. * concurrent frames, but it should be noted that each entry can consume about
  355. * 2 kB of RAM and increasing cache size will slow down frame reassembly.
  356. */
  357. #define IEEE80211_FRAG_CACHE_LEN 4
  358. struct ieee80211_frag_entry {
  359. u32 first_frag_time;
  360. uint seq;
  361. uint last_frag;
  362. uint qos; /*jackson*/
  363. uint tid; /*jackson*/
  364. struct sk_buff *skb;
  365. u8 src_addr[ETH_ALEN];
  366. u8 dst_addr[ETH_ALEN];
  367. };
  368. struct ieee80211_stats {
  369. uint tx_unicast_frames;
  370. uint tx_multicast_frames;
  371. uint tx_fragments;
  372. uint tx_unicast_octets;
  373. uint tx_multicast_octets;
  374. uint tx_deferred_transmissions;
  375. uint tx_single_retry_frames;
  376. uint tx_multiple_retry_frames;
  377. uint tx_retry_limit_exceeded;
  378. uint tx_discards;
  379. uint rx_unicast_frames;
  380. uint rx_multicast_frames;
  381. uint rx_fragments;
  382. uint rx_unicast_octets;
  383. uint rx_multicast_octets;
  384. uint rx_fcs_errors;
  385. uint rx_discards_no_buffer;
  386. uint tx_discards_wrong_sa;
  387. uint rx_discards_undecryptable;
  388. uint rx_message_in_msg_fragments;
  389. uint rx_message_in_bad_msg_fragments;
  390. };
  391. struct ieee80211_softmac_stats {
  392. uint rx_ass_ok;
  393. uint rx_ass_err;
  394. uint rx_probe_rq;
  395. uint tx_probe_rs;
  396. uint tx_beacons;
  397. uint rx_auth_rq;
  398. uint rx_auth_rs_ok;
  399. uint rx_auth_rs_err;
  400. uint tx_auth_rq;
  401. uint no_auth_rs;
  402. uint no_ass_rs;
  403. uint tx_ass_rq;
  404. uint rx_ass_rq;
  405. uint tx_probe_rq;
  406. uint reassoc;
  407. uint swtxstop;
  408. uint swtxawake;
  409. };
  410. #define SEC_KEY_1 (1<<0)
  411. #define SEC_KEY_2 (1<<1)
  412. #define SEC_KEY_3 (1<<2)
  413. #define SEC_KEY_4 (1<<3)
  414. #define SEC_ACTIVE_KEY (1<<4)
  415. #define SEC_AUTH_MODE (1<<5)
  416. #define SEC_UNICAST_GROUP (1<<6)
  417. #define SEC_LEVEL (1<<7)
  418. #define SEC_ENABLED (1<<8)
  419. #define SEC_LEVEL_0 0 /* None */
  420. #define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */
  421. #define SEC_LEVEL_2 2 /* Level 1 + TKIP */
  422. #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
  423. #define SEC_LEVEL_3 4 /* Level 2 + CCMP */
  424. #define WEP_KEYS 4
  425. #define WEP_KEY_LEN 13
  426. struct ieee80211_security {
  427. u16 active_key:2,
  428. enabled:1,
  429. auth_mode:2,
  430. auth_algo:4,
  431. unicast_uses_group:1;
  432. u8 key_sizes[WEP_KEYS];
  433. u8 keys[WEP_KEYS][WEP_KEY_LEN];
  434. u8 level;
  435. u16 flags;
  436. } __packed;
  437. /*
  438. *
  439. * 802.11 data frame from AP
  440. *
  441. * ,-------------------------------------------------------------------.
  442. * Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
  443. * |------|------|---------|---------|---------|------|---------|------|
  444. * Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs |
  445. * | | tion | (BSSID) | | | ence | data | |
  446. * `-------------------------------------------------------------------'
  447. *
  448. * Total: 28-2340 bytes
  449. *
  450. */
  451. struct ieee80211_header_data {
  452. __le16 frame_ctl;
  453. __le16 duration_id;
  454. u8 addr1[6];
  455. u8 addr2[6];
  456. u8 addr3[6];
  457. __le16 seq_ctrl;
  458. } __packed __aligned(2);
  459. #define BEACON_PROBE_SSID_ID_POSITION 12
  460. /* Management Frame Information Element Types */
  461. #define MFIE_TYPE_SSID 0
  462. #define MFIE_TYPE_RATES 1
  463. #define MFIE_TYPE_FH_SET 2
  464. #define MFIE_TYPE_DS_SET 3
  465. #define MFIE_TYPE_CF_SET 4
  466. #define MFIE_TYPE_TIM 5
  467. #define MFIE_TYPE_IBSS_SET 6
  468. #define MFIE_TYPE_CHALLENGE 16
  469. #define MFIE_TYPE_ERP 42
  470. #define MFIE_TYPE_RSN 48
  471. #define MFIE_TYPE_RATES_EX 50
  472. #define MFIE_TYPE_GENERIC 221
  473. struct ieee80211_info_element_hdr {
  474. u8 id;
  475. u8 len;
  476. } __packed;
  477. struct ieee80211_info_element {
  478. u8 id;
  479. u8 len;
  480. u8 data[0];
  481. } __packed;
  482. /*
  483. * These are the data types that can make up management packets
  484. *
  485. __le16 auth_algorithm;
  486. __le16 auth_sequence;
  487. __le16 beacon_interval;
  488. __le16 capability;
  489. u8 current_ap[ETH_ALEN];
  490. __le16 listen_interval;
  491. struct {
  492. u16 association_id:14, reserved:2;
  493. } __packed;
  494. __le32 time_stamp[2];
  495. __le16 reason;
  496. __le16 status;
  497. */
  498. #define IEEE80211_DEFAULT_TX_ESSID "Penguin"
  499. #define IEEE80211_DEFAULT_BASIC_RATE 10
  500. struct ieee80211_authentication {
  501. struct ieee80211_header_data header;
  502. __le16 algorithm;
  503. __le16 transaction;
  504. __le16 status;
  505. } __packed;
  506. struct ieee80211_probe_response {
  507. struct ieee80211_header_data header;
  508. __le32 time_stamp[2];
  509. __le16 beacon_interval;
  510. __le16 capability;
  511. struct ieee80211_info_element info_element;
  512. } __packed;
  513. struct ieee80211_probe_request {
  514. struct ieee80211_header_data header;
  515. } __packed;
  516. struct ieee80211_assoc_request_frame {
  517. struct ieee80211_hdr_3addr header;
  518. __le16 capability;
  519. __le16 listen_interval;
  520. struct ieee80211_info_element_hdr info_element;
  521. } __packed;
  522. struct ieee80211_assoc_response_frame {
  523. struct ieee80211_hdr_3addr header;
  524. __le16 capability;
  525. __le16 status;
  526. __le16 aid;
  527. } __packed;
  528. struct ieee80211_txb {
  529. u8 nr_frags;
  530. u8 encrypted;
  531. u16 reserved;
  532. u16 frag_size;
  533. u16 payload_size;
  534. struct sk_buff *fragments[0];
  535. };
  536. /* SWEEP TABLE ENTRIES NUMBER*/
  537. #define MAX_SWEEP_TAB_ENTRIES 42
  538. #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
  539. /* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs
  540. * only use 8, and then use extended rates for the remaining supported
  541. * rates. Other APs, however, stick all of their supported rates on the
  542. * main rates information element...
  543. */
  544. #define MAX_RATES_LENGTH ((u8)12)
  545. #define MAX_RATES_EX_LENGTH ((u8)16)
  546. #define MAX_NETWORK_COUNT 128
  547. #define MAX_CHANNEL_NUMBER 161
  548. #define IEEE80211_SOFTMAC_SCAN_TIME 400
  549. /*(HZ / 2)*/
  550. #define IEEE80211_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2)
  551. #define CRC_LENGTH 4U
  552. #define MAX_WPA_IE_LEN 128
  553. #define NETWORK_EMPTY_ESSID (1<<0)
  554. #define NETWORK_HAS_OFDM (1<<1)
  555. #define NETWORK_HAS_CCK (1<<2)
  556. #define IEEE80211_DTIM_MBCAST 4
  557. #define IEEE80211_DTIM_UCAST 2
  558. #define IEEE80211_DTIM_VALID 1
  559. #define IEEE80211_DTIM_INVALID 0
  560. #define IEEE80211_PS_DISABLED 0
  561. #define IEEE80211_PS_UNICAST IEEE80211_DTIM_UCAST
  562. #define IEEE80211_PS_MBCAST IEEE80211_DTIM_MBCAST
  563. #define IW_ESSID_MAX_SIZE 32
  564. /*
  565. * join_res:
  566. * -1: authentication fail
  567. * -2: association fail
  568. * > 0: TID
  569. */
  570. enum ieee80211_state {
  571. /* the card is not linked at all */
  572. IEEE80211_NOLINK = 0,
  573. /* IEEE80211_ASSOCIATING* are for BSS client mode
  574. * the driver shall not perform RX filtering unless
  575. * the state is LINKED.
  576. * The driver shall just check for the state LINKED and
  577. * defaults to NOLINK for ALL the other states (including
  578. * LINKED_SCANNING)
  579. */
  580. /* the association procedure will start (wq scheduling)*/
  581. IEEE80211_ASSOCIATING,
  582. IEEE80211_ASSOCIATING_RETRY,
  583. /* the association procedure is sending AUTH request*/
  584. IEEE80211_ASSOCIATING_AUTHENTICATING,
  585. /* the association procedure has successfully authenticated
  586. * and is sending association request
  587. */
  588. IEEE80211_ASSOCIATING_AUTHENTICATED,
  589. /* the link is ok. the card associated to a BSS or linked
  590. * to a ibss cell or acting as an AP and creating the bss
  591. */
  592. IEEE80211_LINKED,
  593. /* same as LINKED, but the driver shall apply RX filter
  594. * rules as we are in NO_LINK mode. As the card is still
  595. * logically linked, but it is doing a syncro site survey
  596. * then it will be back to LINKED state.
  597. */
  598. IEEE80211_LINKED_SCANNING,
  599. };
  600. #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
  601. #define DEFAULT_FTS 2346
  602. #define CFG_IEEE80211_RESERVE_FCS (1<<0)
  603. #define CFG_IEEE80211_COMPUTE_FCS (1<<1)
  604. #define MAXTID 16
  605. #define IEEE_A (1<<0)
  606. #define IEEE_B (1<<1)
  607. #define IEEE_G (1<<2)
  608. #define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
  609. static inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
  610. {
  611. /* Single white space is for Linksys APs */
  612. if (essid_len == 1 && essid[0] == ' ')
  613. return 1;
  614. /* Otherwise, if the entire essid is 0, we assume it is hidden */
  615. while (essid_len) {
  616. essid_len--;
  617. if (essid[essid_len] != '\0')
  618. return 0;
  619. }
  620. return 1;
  621. }
  622. static inline int ieee80211_get_hdrlen(u16 fc)
  623. {
  624. int hdrlen = 24;
  625. switch (WLAN_FC_GET_TYPE(fc)) {
  626. case IEEE80211_FTYPE_DATA:
  627. if (fc & IEEE80211_QOS_DATAGRP)
  628. hdrlen += 2;
  629. if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
  630. hdrlen += 6; /* Addr4 */
  631. break;
  632. case IEEE80211_FTYPE_CTL:
  633. switch (WLAN_FC_GET_STYPE(fc)) {
  634. case IEEE80211_STYPE_CTS:
  635. case IEEE80211_STYPE_ACK:
  636. hdrlen = 10;
  637. break;
  638. default:
  639. hdrlen = 16;
  640. break;
  641. }
  642. break;
  643. }
  644. return hdrlen;
  645. }
  646. struct registry_priv;
  647. u8 *r8712_set_ie(u8 *pbuf, sint index, uint len, u8 *source, uint *frlen);
  648. u8 *r8712_get_ie(u8 *pbuf, sint index, sint *len, sint limit);
  649. unsigned char *r8712_get_wpa_ie(unsigned char *pie, int *rsn_ie_len, int limit);
  650. unsigned char *r8712_get_wpa2_ie(unsigned char *pie, int *rsn_ie_len,
  651. int limit);
  652. int r8712_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher,
  653. int *pairwise_cipher);
  654. int r8712_parse_wpa2_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher,
  655. int *pairwise_cipher);
  656. int r8712_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len,
  657. u8 *wpa_ie, u16 *wpa_len);
  658. int r8712_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen);
  659. int r8712_generate_ie(struct registry_priv *pregistrypriv);
  660. uint r8712_is_cckrates_included(u8 *rate);
  661. uint r8712_is_cckratesonly_included(u8 *rate);
  662. #endif /* IEEE80211_H */