ieee80211.h 20 KB

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