blob: 8ca3444ad48bf8bae776298cf0ea7dda106eb485 [file] [log] [blame]
Ali Baharcf3e6882011-09-04 03:14:04 +08001/******************************************************************************
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 ******************************************************************************/
Larry Finger2865d422010-08-20 10:15:30 -050026#ifndef __IEEE80211_H
27#define __IEEE80211_H
28
29#include "osdep_service.h"
30#include "drv_types.h"
31#include "wifi.h"
Michael Fiedler40878362011-06-20 16:34:27 +020032#include <linux/compiler.h>
Larry Finger2865d422010-08-20 10:15:30 -050033#include <linux/wireless.h>
34
35#define MGMT_QUEUE_NUM 5
36#define ETH_ALEN 6
37#define IEEE_CMD_SET_WPA_PARAM 1
38#define IEEE_CMD_SET_WPA_IE 2
39#define IEEE_CMD_SET_ENCRYPTION 3
40#define IEEE_CMD_MLME 4
41
42#define IEEE_PARAM_WPA_ENABLED 1
43#define IEEE_PARAM_TKIP_COUNTERMEASURES 2
44#define IEEE_PARAM_DROP_UNENCRYPTED 3
45#define IEEE_PARAM_PRIVACY_INVOKED 4
46#define IEEE_PARAM_AUTH_ALGS 5
47#define IEEE_PARAM_IEEE_802_1X 6
48#define IEEE_PARAM_WPAX_SELECT 7
49
50#define AUTH_ALG_OPEN_SYSTEM 0x1
51#define AUTH_ALG_SHARED_KEY 0x2
52#define AUTH_ALG_LEAP 0x00000004
53
54#define IEEE_MLME_STA_DEAUTH 1
55#define IEEE_MLME_STA_DISASSOC 2
56
57#define IEEE_CRYPT_ERR_UNKNOWN_ALG 2
58#define IEEE_CRYPT_ERR_UNKNOWN_ADDR 3
59#define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED 4
60#define IEEE_CRYPT_ERR_KEY_SET_FAILED 5
61#define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED 6
62#define IEEE_CRYPT_ERR_CARD_CONF_FAILED 7
63
Larry Finger2865d422010-08-20 10:15:30 -050064#define IEEE_CRYPT_ALG_NAME_LEN 16
65
66#define WPA_CIPHER_NONE BIT(0)
67#define WPA_CIPHER_WEP40 BIT(1)
68#define WPA_CIPHER_WEP104 BIT(2)
69#define WPA_CIPHER_TKIP BIT(3)
70#define WPA_CIPHER_CCMP BIT(4)
71
Larry Finger2865d422010-08-20 10:15:30 -050072#define WPA_SELECTOR_LEN 4
73#define RSN_HEADER_LEN 4
74
75#define RSN_SELECTOR_LEN 4
76
77enum NETWORK_TYPE {
78 WIRELESS_INVALID = 0,
79 WIRELESS_11B = 1,
80 WIRELESS_11G = 2,
81 WIRELESS_11BG = (WIRELESS_11B | WIRELESS_11G),
82 WIRELESS_11A = 4,
83 WIRELESS_11N = 8,
84 WIRELESS_11GN = (WIRELESS_11G | WIRELESS_11N),
85 WIRELESS_11BGN = (WIRELESS_11B | WIRELESS_11G | WIRELESS_11N),
86};
87
Larry Finger2865d422010-08-20 10:15:30 -050088struct ieee_param {
89 u32 cmd;
90 u8 sta_addr[ETH_ALEN];
91 union {
92 struct {
93 u8 name;
94 u32 value;
95 } wpa_param;
96 struct {
97 u32 len;
98 u8 reserved[32];
99 u8 data[0];
100 } wpa_ie;
Javier M. Mellid05937582011-04-02 03:01:49 +0200101 struct {
Larry Finger2865d422010-08-20 10:15:30 -0500102 int command;
103 int reason_code;
104 } mlme;
105 struct {
106 u8 alg[IEEE_CRYPT_ALG_NAME_LEN];
107 u8 set_tx;
108 u32 err;
109 u8 idx;
110 u8 seq[8]; /* sequence counter (set: RX, get: TX) */
111 u16 key_len;
112 u8 key[0];
113 } crypt;
114 } u;
115};
116
117#define IEEE80211_DATA_LEN 2304
118/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
Punit Vara652199c2015-10-08 01:25:16 +0530119 * 6.2.1.1.2.
120 *
121 * The figure in section 7.1.2 suggests a body size of up to 2312
122 * bytes is allowed, which is a bit confusing, I suspect this
123 * represents the 2304 bytes of real data, plus a possible 8 bytes of
124 * WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro)
125 */
Larry Finger2865d422010-08-20 10:15:30 -0500126
127#define IEEE80211_HLEN 30
128#define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
129
130/* this is stolen from ipw2200 driver */
131#define IEEE_IBSS_MAC_HASH_SIZE 31
132
133struct ieee_ibss_seq {
134 u8 mac[ETH_ALEN];
135 u16 seq_num;
136 u16 frag_num;
Ali Baharee5b1aa2011-09-04 03:14:21 +0800137 unsigned long packet_time;
Larry Finger2865d422010-08-20 10:15:30 -0500138 struct list_head list;
139};
140
141struct ieee80211_hdr {
142 u16 frame_ctl;
143 u16 duration_id;
144 u8 addr1[ETH_ALEN];
145 u8 addr2[ETH_ALEN];
146 u8 addr3[ETH_ALEN];
147 u16 seq_ctl;
148 u8 addr4[ETH_ALEN];
Michael Fiedler40878362011-06-20 16:34:27 +0200149} __packed;
Larry Finger2865d422010-08-20 10:15:30 -0500150
151struct ieee80211_hdr_3addr {
152 u16 frame_ctl;
153 u16 duration_id;
154 u8 addr1[ETH_ALEN];
155 u8 addr2[ETH_ALEN];
156 u8 addr3[ETH_ALEN];
157 u16 seq_ctl;
Michael Fiedler40878362011-06-20 16:34:27 +0200158} __packed;
Larry Finger2865d422010-08-20 10:15:30 -0500159
Larry Finger2865d422010-08-20 10:15:30 -0500160struct ieee80211_hdr_qos {
161 u16 frame_ctl;
162 u16 duration_id;
163 u8 addr1[ETH_ALEN];
164 u8 addr2[ETH_ALEN];
165 u8 addr3[ETH_ALEN];
166 u16 seq_ctl;
167 u8 addr4[ETH_ALEN];
168 u16 qc;
Michael Fiedler40878362011-06-20 16:34:27 +0200169} __packed;
Larry Finger2865d422010-08-20 10:15:30 -0500170
171struct ieee80211_hdr_3addr_qos {
172 u16 frame_ctl;
173 u16 duration_id;
Javier M. Mellid05937582011-04-02 03:01:49 +0200174 u8 addr1[ETH_ALEN];
175 u8 addr2[ETH_ALEN];
176 u8 addr3[ETH_ALEN];
Larry Finger2865d422010-08-20 10:15:30 -0500177 u16 seq_ctl;
Javier M. Mellid05937582011-04-02 03:01:49 +0200178 u16 qc;
Michael Fiedler40878362011-06-20 16:34:27 +0200179} __packed;
Larry Finger2865d422010-08-20 10:15:30 -0500180
181struct eapol {
182 u8 snap[6];
183 u16 ethertype;
184 u8 version;
185 u8 type;
186 u16 length;
Michael Fiedler40878362011-06-20 16:34:27 +0200187} __packed;
Larry Finger2865d422010-08-20 10:15:30 -0500188
Larry Finger2865d422010-08-20 10:15:30 -0500189enum eap_type {
190 EAP_PACKET = 0,
191 EAPOL_START,
192 EAPOL_LOGOFF,
193 EAPOL_KEY,
194 EAPOL_ENCAP_ASF_ALERT
195};
196
197#define IEEE80211_3ADDR_LEN 24
198#define IEEE80211_4ADDR_LEN 30
199#define IEEE80211_FCS_LEN 4
200
201#define MIN_FRAG_THRESHOLD 256U
202#define MAX_FRAG_THRESHOLD 2346U
203
204/* Frame control field constants */
205#define IEEE80211_FCTL_VERS 0x0002
206#define IEEE80211_FCTL_FTYPE 0x000c
207#define IEEE80211_FCTL_STYPE 0x00f0
208#define IEEE80211_FCTL_TODS 0x0100
209#define IEEE80211_FCTL_FROMDS 0x0200
210#define IEEE80211_FCTL_MOREFRAGS 0x0400
211#define IEEE80211_FCTL_RETRY 0x0800
212#define IEEE80211_FCTL_PM 0x1000
213#define IEEE80211_FCTL_MOREDATA 0x2000
214#define IEEE80211_FCTL_WEP 0x4000
215#define IEEE80211_FCTL_ORDER 0x8000
216
217#define IEEE80211_FTYPE_MGMT 0x0000
218#define IEEE80211_FTYPE_CTL 0x0004
219#define IEEE80211_FTYPE_DATA 0x0008
220
221/* management */
222#define IEEE80211_STYPE_ASSOC_REQ 0x0000
223#define IEEE80211_STYPE_ASSOC_RESP 0x0010
224#define IEEE80211_STYPE_REASSOC_REQ 0x0020
225#define IEEE80211_STYPE_REASSOC_RESP 0x0030
226#define IEEE80211_STYPE_PROBE_REQ 0x0040
227#define IEEE80211_STYPE_PROBE_RESP 0x0050
228#define IEEE80211_STYPE_BEACON 0x0080
229#define IEEE80211_STYPE_ATIM 0x0090
230#define IEEE80211_STYPE_DISASSOC 0x00A0
231#define IEEE80211_STYPE_AUTH 0x00B0
232#define IEEE80211_STYPE_DEAUTH 0x00C0
233
234/* control */
235#define IEEE80211_STYPE_PSPOLL 0x00A0
236#define IEEE80211_STYPE_RTS 0x00B0
237#define IEEE80211_STYPE_CTS 0x00C0
238#define IEEE80211_STYPE_ACK 0x00D0
239#define IEEE80211_STYPE_CFEND 0x00E0
240#define IEEE80211_STYPE_CFENDACK 0x00F0
241
242/* data */
243#define IEEE80211_STYPE_DATA 0x0000
244#define IEEE80211_STYPE_DATA_CFACK 0x0010
245#define IEEE80211_STYPE_DATA_CFPOLL 0x0020
246#define IEEE80211_STYPE_DATA_CFACKPOLL 0x0030
247#define IEEE80211_STYPE_NULLFUNC 0x0040
248#define IEEE80211_STYPE_CFACK 0x0050
249#define IEEE80211_STYPE_CFPOLL 0x0060
250#define IEEE80211_STYPE_CFACKPOLL 0x0070
251#define IEEE80211_QOS_DATAGRP 0x0080
252#define IEEE80211_QoS_DATAGRP IEEE80211_QOS_DATAGRP
253
254#define IEEE80211_SCTL_FRAG 0x000F
255#define IEEE80211_SCTL_SEQ 0xFFF0
256
257/* QoS,QOS */
258#define NORMAL_ACK 0
259#define NO_ACK 1
260#define NON_EXPLICIT_ACK 2
261#define BLOCK_ACK 3
262
263#ifndef ETH_P_PAE
264#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
265#endif /* ETH_P_PAE */
266
267#define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
268
269#define ETH_P_ECONET 0x0018
270
271#ifndef ETH_P_80211_RAW
272#define ETH_P_80211_RAW (ETH_P_ECONET + 1)
273#endif
274
275/* IEEE 802.11 defines */
276
277#define P80211_OUI_LEN 3
278
279struct ieee80211_snap_hdr {
280 u8 dsap; /* always 0xAA */
281 u8 ssap; /* always 0xAA */
282 u8 ctrl; /* always 0x03 */
283 u8 oui[P80211_OUI_LEN]; /* organizational universal id */
Michael Fiedler40878362011-06-20 16:34:27 +0200284} __packed;
Larry Finger2865d422010-08-20 10:15:30 -0500285
286#define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
287
288#define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE)
289#define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE)
290
291#define WLAN_QC_GET_TID(qc) ((qc) & 0x0f)
292
293#define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG)
294#define WLAN_GET_SEQ_SEQ(seq) ((seq) & IEEE80211_SCTL_SEQ)
295
296/* Authentication algorithms */
297#define WLAN_AUTH_OPEN 0
298#define WLAN_AUTH_SHARED_KEY 1
299
300#define WLAN_AUTH_CHALLENGE_LEN 128
301
Michael Hornung364cdb32015-11-18 20:59:13 +0100302#define WLAN_CAPABILITY_BSS BIT(0)
303#define WLAN_CAPABILITY_IBSS BIT(1)
304#define WLAN_CAPABILITY_CF_POLLABLE BIT(2)
305#define WLAN_CAPABILITY_CF_POLL_REQUEST BIT(3)
306#define WLAN_CAPABILITY_PRIVACY BIT(4)
307#define WLAN_CAPABILITY_SHORT_PREAMBLE BIT(5)
308#define WLAN_CAPABILITY_PBCC BIT(6)
309#define WLAN_CAPABILITY_CHANNEL_AGILITY BIT(7)
310#define WLAN_CAPABILITY_SHORT_SLOT BIT(10)
Larry Finger2865d422010-08-20 10:15:30 -0500311
Larry Finger2865d422010-08-20 10:15:30 -0500312/* Information Element IDs */
313#define WLAN_EID_SSID 0
314#define WLAN_EID_SUPP_RATES 1
315#define WLAN_EID_FH_PARAMS 2
316#define WLAN_EID_DS_PARAMS 3
317#define WLAN_EID_CF_PARAMS 4
318#define WLAN_EID_TIM 5
319#define WLAN_EID_IBSS_PARAMS 6
320#define WLAN_EID_CHALLENGE 16
321#define WLAN_EID_RSN 48
322#define WLAN_EID_GENERIC 221
323
324#define IEEE80211_MGMT_HDR_LEN 24
325#define IEEE80211_DATA_HDR3_LEN 24
326#define IEEE80211_DATA_HDR4_LEN 30
327
Michael Hornung364cdb32015-11-18 20:59:13 +0100328#define IEEE80211_STATMASK_SIGNAL BIT(0)
329#define IEEE80211_STATMASK_RSSI BIT(1)
330#define IEEE80211_STATMASK_NOISE BIT(2)
331#define IEEE80211_STATMASK_RATE BIT(3)
Larry Finger2865d422010-08-20 10:15:30 -0500332#define IEEE80211_STATMASK_WEMASK 0x7
333
Michael Hornung364cdb32015-11-18 20:59:13 +0100334#define IEEE80211_CCK_MODULATION BIT(0)
335#define IEEE80211_OFDM_MODULATION BIT(1)
Larry Finger2865d422010-08-20 10:15:30 -0500336
Michael Hornung364cdb32015-11-18 20:59:13 +0100337#define IEEE80211_24GHZ_BAND BIT(0)
338#define IEEE80211_52GHZ_BAND BIT(1)
Larry Finger2865d422010-08-20 10:15:30 -0500339
340#define IEEE80211_CCK_RATE_LEN 4
341#define IEEE80211_NUM_OFDM_RATESLEN 8
342
Larry Finger2865d422010-08-20 10:15:30 -0500343#define IEEE80211_CCK_RATE_1MB 0x02
344#define IEEE80211_CCK_RATE_2MB 0x04
345#define IEEE80211_CCK_RATE_5MB 0x0B
346#define IEEE80211_CCK_RATE_11MB 0x16
347#define IEEE80211_OFDM_RATE_LEN 8
348#define IEEE80211_OFDM_RATE_6MB 0x0C
349#define IEEE80211_OFDM_RATE_9MB 0x12
350#define IEEE80211_OFDM_RATE_12MB 0x18
351#define IEEE80211_OFDM_RATE_18MB 0x24
352#define IEEE80211_OFDM_RATE_24MB 0x30
353#define IEEE80211_OFDM_RATE_36MB 0x48
354#define IEEE80211_OFDM_RATE_48MB 0x60
355#define IEEE80211_OFDM_RATE_54MB 0x6C
356#define IEEE80211_BASIC_RATE_MASK 0x80
357
Michael Hornung364cdb32015-11-18 20:59:13 +0100358#define IEEE80211_CCK_RATE_1MB_MASK BIT(0)
359#define IEEE80211_CCK_RATE_2MB_MASK BIT(1)
360#define IEEE80211_CCK_RATE_5MB_MASK BIT(2)
361#define IEEE80211_CCK_RATE_11MB_MASK BIT(3)
362#define IEEE80211_OFDM_RATE_6MB_MASK BIT(4)
363#define IEEE80211_OFDM_RATE_9MB_MASK BIT(5)
364#define IEEE80211_OFDM_RATE_12MB_MASK BIT(6)
365#define IEEE80211_OFDM_RATE_18MB_MASK BIT(7)
366#define IEEE80211_OFDM_RATE_24MB_MASK BIT(8)
367#define IEEE80211_OFDM_RATE_36MB_MASK BIT(9)
368#define IEEE80211_OFDM_RATE_48MB_MASK BIT(10)
369#define IEEE80211_OFDM_RATE_54MB_MASK BIT(11)
Larry Finger2865d422010-08-20 10:15:30 -0500370
371#define IEEE80211_CCK_RATES_MASK 0x0000000F
372#define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \
373 IEEE80211_CCK_RATE_2MB_MASK)
374#define IEEE80211_CCK_DEFAULT_RATES_MASK (IEEE80211_CCK_BASIC_RATES_MASK | \
375 IEEE80211_CCK_RATE_5MB_MASK | \
376 IEEE80211_CCK_RATE_11MB_MASK)
377
378#define IEEE80211_OFDM_RATES_MASK 0x00000FF0
379#define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \
380 IEEE80211_OFDM_RATE_12MB_MASK | \
381 IEEE80211_OFDM_RATE_24MB_MASK)
382#define IEEE80211_OFDM_DEFAULT_RATES_MASK (IEEE80211_OFDM_BASIC_RATES_MASK | \
383 IEEE80211_OFDM_RATE_9MB_MASK | \
384 IEEE80211_OFDM_RATE_18MB_MASK | \
385 IEEE80211_OFDM_RATE_36MB_MASK | \
386 IEEE80211_OFDM_RATE_48MB_MASK | \
387 IEEE80211_OFDM_RATE_54MB_MASK)
388#define IEEE80211_DEFAULT_RATES_MASK (IEEE80211_OFDM_DEFAULT_RATES_MASK | \
389 IEEE80211_CCK_DEFAULT_RATES_MASK)
390
391#define IEEE80211_NUM_OFDM_RATES 8
392#define IEEE80211_NUM_CCK_RATES 4
393#define IEEE80211_OFDM_SHIFT_MASK_A 4
394
Larry Finger2865d422010-08-20 10:15:30 -0500395/* NOTE: This data is for statistical purposes; not all hardware provides this
396 * information for frames received. Not setting these will not cause
Punit Vara652199c2015-10-08 01:25:16 +0530397 * any adverse affects.
398 */
Larry Finger2865d422010-08-20 10:15:30 -0500399struct ieee80211_rx_stats {
400 s8 rssi;
401 u8 signal;
402 u8 noise;
403 u8 received_channel;
404 u16 rate; /* in 100 kbps */
405 u8 mask;
406 u8 freq;
407 u16 len;
408};
409
410/* IEEE 802.11 requires that STA supports concurrent reception of at least
411 * three fragmented frames. This define can be increased to support more
412 * concurrent frames, but it should be noted that each entry can consume about
Punit Vara652199c2015-10-08 01:25:16 +0530413 * 2 kB of RAM and increasing cache size will slow down frame reassembly.
414 */
Larry Finger2865d422010-08-20 10:15:30 -0500415#define IEEE80211_FRAG_CACHE_LEN 4
416
417struct ieee80211_frag_entry {
418 u32 first_frag_time;
419 uint seq;
420 uint last_frag;
421 uint qos; /*jackson*/
422 uint tid; /*jackson*/
423 struct sk_buff *skb;
424 u8 src_addr[ETH_ALEN];
425 u8 dst_addr[ETH_ALEN];
426};
427
428struct ieee80211_stats {
429 uint tx_unicast_frames;
430 uint tx_multicast_frames;
431 uint tx_fragments;
432 uint tx_unicast_octets;
433 uint tx_multicast_octets;
434 uint tx_deferred_transmissions;
435 uint tx_single_retry_frames;
436 uint tx_multiple_retry_frames;
437 uint tx_retry_limit_exceeded;
438 uint tx_discards;
439 uint rx_unicast_frames;
440 uint rx_multicast_frames;
441 uint rx_fragments;
442 uint rx_unicast_octets;
443 uint rx_multicast_octets;
444 uint rx_fcs_errors;
445 uint rx_discards_no_buffer;
446 uint tx_discards_wrong_sa;
447 uint rx_discards_undecryptable;
448 uint rx_message_in_msg_fragments;
449 uint rx_message_in_bad_msg_fragments;
450};
451
Javier M. Mellid05937582011-04-02 03:01:49 +0200452struct ieee80211_softmac_stats {
Larry Finger2865d422010-08-20 10:15:30 -0500453 uint rx_ass_ok;
454 uint rx_ass_err;
455 uint rx_probe_rq;
456 uint tx_probe_rs;
457 uint tx_beacons;
458 uint rx_auth_rq;
459 uint rx_auth_rs_ok;
460 uint rx_auth_rs_err;
461 uint tx_auth_rq;
462 uint no_auth_rs;
463 uint no_ass_rs;
464 uint tx_ass_rq;
465 uint rx_ass_rq;
466 uint tx_probe_rq;
467 uint reassoc;
468 uint swtxstop;
469 uint swtxawake;
470};
471
Michael Hornung364cdb32015-11-18 20:59:13 +0100472#define SEC_KEY_1 BIT(0)
473#define SEC_KEY_2 BIT(1)
474#define SEC_KEY_3 BIT(2)
475#define SEC_KEY_4 BIT(3)
476#define SEC_ACTIVE_KEY BIT(4)
477#define SEC_AUTH_MODE BIT(5)
478#define SEC_UNICAST_GROUP BIT(6)
479#define SEC_LEVEL BIT(7)
480#define SEC_ENABLED BIT(8)
Larry Finger2865d422010-08-20 10:15:30 -0500481
482#define SEC_LEVEL_0 0 /* None */
483#define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */
484#define SEC_LEVEL_2 2 /* Level 1 + TKIP */
485#define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
486#define SEC_LEVEL_3 4 /* Level 2 + CCMP */
487
488#define WEP_KEYS 4
489#define WEP_KEY_LEN 13
490
491struct ieee80211_security {
492 u16 active_key:2,
493 enabled:1,
494 auth_mode:2,
495 auth_algo:4,
496 unicast_uses_group:1;
497 u8 key_sizes[WEP_KEYS];
498 u8 keys[WEP_KEYS][WEP_KEY_LEN];
499 u8 level;
500 u16 flags;
Michael Fiedler40878362011-06-20 16:34:27 +0200501} __packed;
Larry Finger2865d422010-08-20 10:15:30 -0500502
503/*
Punit Vara652199c2015-10-08 01:25:16 +0530504 *
505 * 802.11 data frame from AP
506 *
507 * ,-------------------------------------------------------------------.
508 * Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
509 * |------|------|---------|---------|---------|------|---------|------|
510 * Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs |
511 * | | tion | (BSSID) | | | ence | data | |
512 * `-------------------------------------------------------------------'
513 *
514 * Total: 28-2340 bytes
515 *
516 */
Larry Finger2865d422010-08-20 10:15:30 -0500517
518struct ieee80211_header_data {
519 u16 frame_ctl;
520 u16 duration_id;
521 u8 addr1[6];
522 u8 addr2[6];
523 u8 addr3[6];
524 u16 seq_ctrl;
525};
526
527#define BEACON_PROBE_SSID_ID_POSITION 12
528
529/* Management Frame Information Element Types */
530#define MFIE_TYPE_SSID 0
531#define MFIE_TYPE_RATES 1
532#define MFIE_TYPE_FH_SET 2
533#define MFIE_TYPE_DS_SET 3
534#define MFIE_TYPE_CF_SET 4
535#define MFIE_TYPE_TIM 5
536#define MFIE_TYPE_IBSS_SET 6
537#define MFIE_TYPE_CHALLENGE 16
538#define MFIE_TYPE_ERP 42
539#define MFIE_TYPE_RSN 48
540#define MFIE_TYPE_RATES_EX 50
541#define MFIE_TYPE_GENERIC 221
542
543struct ieee80211_info_element_hdr {
544 u8 id;
545 u8 len;
Michael Fiedler40878362011-06-20 16:34:27 +0200546} __packed;
Larry Finger2865d422010-08-20 10:15:30 -0500547
548struct ieee80211_info_element {
549 u8 id;
550 u8 len;
551 u8 data[0];
Michael Fiedler40878362011-06-20 16:34:27 +0200552} __packed;
Larry Finger2865d422010-08-20 10:15:30 -0500553
554/*
555 * These are the data types that can make up management packets
556 *
557 u16 auth_algorithm;
558 u16 auth_sequence;
559 u16 beacon_interval;
560 u16 capability;
561 u8 current_ap[ETH_ALEN];
562 u16 listen_interval;
563 struct {
564 u16 association_id:14, reserved:2;
Michael Fiedler40878362011-06-20 16:34:27 +0200565 } __packed;
Larry Finger2865d422010-08-20 10:15:30 -0500566 u32 time_stamp[2];
567 u16 reason;
568 u16 status;
569*/
570
571#define IEEE80211_DEFAULT_TX_ESSID "Penguin"
572#define IEEE80211_DEFAULT_BASIC_RATE 10
573
574struct ieee80211_authentication {
575 struct ieee80211_header_data header;
576 u16 algorithm;
577 u16 transaction;
578 u16 status;
Michael Fiedler40878362011-06-20 16:34:27 +0200579} __packed;
Larry Finger2865d422010-08-20 10:15:30 -0500580
581struct ieee80211_probe_response {
582 struct ieee80211_header_data header;
583 u32 time_stamp[2];
584 u16 beacon_interval;
585 u16 capability;
586 struct ieee80211_info_element info_element;
Michael Fiedler40878362011-06-20 16:34:27 +0200587} __packed;
Larry Finger2865d422010-08-20 10:15:30 -0500588
589struct ieee80211_probe_request {
590 struct ieee80211_header_data header;
Michael Fiedler40878362011-06-20 16:34:27 +0200591} __packed;
Larry Finger2865d422010-08-20 10:15:30 -0500592
593struct ieee80211_assoc_request_frame {
594 struct ieee80211_hdr_3addr header;
595 u16 capability;
596 u16 listen_interval;
597 struct ieee80211_info_element_hdr info_element;
Michael Fiedler40878362011-06-20 16:34:27 +0200598} __packed;
Larry Finger2865d422010-08-20 10:15:30 -0500599
600struct ieee80211_assoc_response_frame {
601 struct ieee80211_hdr_3addr header;
602 u16 capability;
603 u16 status;
604 u16 aid;
Michael Fiedler40878362011-06-20 16:34:27 +0200605} __packed;
Larry Finger2865d422010-08-20 10:15:30 -0500606
607struct ieee80211_txb {
608 u8 nr_frags;
609 u8 encrypted;
610 u16 reserved;
611 u16 frag_size;
612 u16 payload_size;
613 struct sk_buff *fragments[0];
614};
615
616/* SWEEP TABLE ENTRIES NUMBER*/
617#define MAX_SWEEP_TAB_ENTRIES 42
618#define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
619/* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs
620 * only use 8, and then use extended rates for the remaining supported
621 * rates. Other APs, however, stick all of their supported rates on the
Punit Vara652199c2015-10-08 01:25:16 +0530622 * main rates information element...
623 */
Larry Finger2865d422010-08-20 10:15:30 -0500624#define MAX_RATES_LENGTH ((u8)12)
625#define MAX_RATES_EX_LENGTH ((u8)16)
626#define MAX_NETWORK_COUNT 128
627#define MAX_CHANNEL_NUMBER 161
628#define IEEE80211_SOFTMAC_SCAN_TIME 400
629/*(HZ / 2)*/
630#define IEEE80211_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2)
631
632#define CRC_LENGTH 4U
633
634#define MAX_WPA_IE_LEN 128
Larry Finger2865d422010-08-20 10:15:30 -0500635
Michael Hornung364cdb32015-11-18 20:59:13 +0100636#define NETWORK_EMPTY_ESSID BIT(0)
637#define NETWORK_HAS_OFDM BIT(1)
638#define NETWORK_HAS_CCK BIT(2)
Larry Finger2865d422010-08-20 10:15:30 -0500639
640#define IEEE80211_DTIM_MBCAST 4
641#define IEEE80211_DTIM_UCAST 2
642#define IEEE80211_DTIM_VALID 1
643#define IEEE80211_DTIM_INVALID 0
644
645#define IEEE80211_PS_DISABLED 0
646#define IEEE80211_PS_UNICAST IEEE80211_DTIM_UCAST
647#define IEEE80211_PS_MBCAST IEEE80211_DTIM_MBCAST
648#define IW_ESSID_MAX_SIZE 32
649/*
650 * join_res:
651 * -1: authentication fail
652 * -2: association fail
653 * > 0: TID
654 */
655
656enum ieee80211_state {
657 /* the card is not linked at all */
658 IEEE80211_NOLINK = 0,
659 /* IEEE80211_ASSOCIATING* are for BSS client mode
660 * the driver shall not perform RX filtering unless
661 * the state is LINKED.
662 * The driver shall just check for the state LINKED and
663 * defaults to NOLINK for ALL the other states (including
664 * LINKED_SCANNING)
665 */
666 /* the association procedure will start (wq scheduling)*/
667 IEEE80211_ASSOCIATING,
668 IEEE80211_ASSOCIATING_RETRY,
669 /* the association procedure is sending AUTH request*/
670 IEEE80211_ASSOCIATING_AUTHENTICATING,
Justin P. Mattockbe10ac22012-05-07 07:38:22 -0700671 /* the association procedure has successfully authenticated
Larry Finger2865d422010-08-20 10:15:30 -0500672 * and is sending association request
673 */
674 IEEE80211_ASSOCIATING_AUTHENTICATED,
675 /* the link is ok. the card associated to a BSS or linked
676 * to a ibss cell or acting as an AP and creating the bss
677 */
678 IEEE80211_LINKED,
679 /* same as LINKED, but the driver shall apply RX filter
680 * rules as we are in NO_LINK mode. As the card is still
681 * logically linked, but it is doing a syncro site survey
682 * then it will be back to LINKED state.
683 */
684 IEEE80211_LINKED_SCANNING,
685};
686
687#define DEFAULT_MAX_SCAN_AGE (15 * HZ)
688#define DEFAULT_FTS 2346
689
Michael Hornung364cdb32015-11-18 20:59:13 +0100690#define CFG_IEEE80211_RESERVE_FCS BIT(0)
691#define CFG_IEEE80211_COMPUTE_FCS BIT(1)
Larry Finger2865d422010-08-20 10:15:30 -0500692
693#define MAXTID 16
694
Michael Hornung364cdb32015-11-18 20:59:13 +0100695#define IEEE_A BIT(0)
696#define IEEE_B BIT(1)
697#define IEEE_G BIT(2)
Larry Finger2865d422010-08-20 10:15:30 -0500698#define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
699
Arnd Bergmann0c9f3a62014-06-05 22:48:15 +0200700static inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
Larry Finger2865d422010-08-20 10:15:30 -0500701{
702 /* Single white space is for Linksys APs */
703 if (essid_len == 1 && essid[0] == ' ')
704 return 1;
705 /* Otherwise, if the entire essid is 0, we assume it is hidden */
706 while (essid_len) {
707 essid_len--;
708 if (essid[essid_len] != '\0')
709 return 0;
710 }
711 return 1;
712}
713
Arnd Bergmann0c9f3a62014-06-05 22:48:15 +0200714static inline int ieee80211_get_hdrlen(u16 fc)
Larry Finger2865d422010-08-20 10:15:30 -0500715{
716 int hdrlen = 24;
717
718 switch (WLAN_FC_GET_TYPE(fc)) {
719 case IEEE80211_FTYPE_DATA:
720 if (fc & IEEE80211_QOS_DATAGRP)
721 hdrlen += 2;
722 if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
723 hdrlen += 6; /* Addr4 */
724 break;
725 case IEEE80211_FTYPE_CTL:
726 switch (WLAN_FC_GET_STYPE(fc)) {
727 case IEEE80211_STYPE_CTS:
728 case IEEE80211_STYPE_ACK:
729 hdrlen = 10;
730 break;
731 default:
732 hdrlen = 16;
733 break;
734 }
735 break;
736 }
737 return hdrlen;
738}
739
740struct registry_priv;
741
742u8 *r8712_set_ie(u8 *pbuf, sint index, uint len, u8 *source, uint *frlen);
Przemo Firsztc07f9722012-12-10 23:21:19 +0000743u8 *r8712_get_ie(u8 *pbuf, sint index, sint *len, sint limit);
Larry Finger2865d422010-08-20 10:15:30 -0500744unsigned char *r8712_get_wpa_ie(unsigned char *pie, int *rsn_ie_len, int limit);
Javier M. Mellid05937582011-04-02 03:01:49 +0200745unsigned char *r8712_get_wpa2_ie(unsigned char *pie, int *rsn_ie_len,
746 int limit);
Larry Finger2865d422010-08-20 10:15:30 -0500747int r8712_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher,
Javier M. Mellid05937582011-04-02 03:01:49 +0200748 int *pairwise_cipher);
Larry Finger2865d422010-08-20 10:15:30 -0500749int r8712_parse_wpa2_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher,
Javier M. Mellid05937582011-04-02 03:01:49 +0200750 int *pairwise_cipher);
751int r8712_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len,
752 u8 *wpa_ie, u16 *wpa_len);
Larry Finger2865d422010-08-20 10:15:30 -0500753int r8712_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen);
Ali Baharee5b1aa2011-09-04 03:14:21 +0800754int r8712_generate_ie(struct registry_priv *pregistrypriv);
Larry Finger2865d422010-08-20 10:15:30 -0500755uint r8712_is_cckrates_included(u8 *rate);
756uint r8712_is_cckratesonly_included(u8 *rate);
757
758#endif /* IEEE80211_H */
759