ieee80211.h 20 KB

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