ieee80211.h 21 KB

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