1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#ifndef IEEE80211_H
25#define IEEE80211_H
26#include <linux/if_ether.h>
27#include <linux/kernel.h>
28#include <linux/version.h>
29#include <linux/jiffies.h>
30#include <linux/timer.h>
31#include <linux/sched.h>
32#include <linux/semaphore.h>
33#include <linux/wireless.h>
34#include <linux/ieee80211.h>
35
36#define KEY_TYPE_NA 0x0
37#define KEY_TYPE_WEP40 0x1
38#define KEY_TYPE_TKIP 0x2
39#define KEY_TYPE_CCMP 0x4
40#define KEY_TYPE_WEP104 0x5
41
42#define aSifsTime 10
43
44#define MGMT_QUEUE_NUM 5
45
46
47#define IEEE_CMD_SET_WPA_PARAM 1
48#define IEEE_CMD_SET_WPA_IE 2
49#define IEEE_CMD_SET_ENCRYPTION 3
50#define IEEE_CMD_MLME 4
51
52#define IEEE_PARAM_WPA_ENABLED 1
53#define IEEE_PARAM_TKIP_COUNTERMEASURES 2
54#define IEEE_PARAM_DROP_UNENCRYPTED 3
55#define IEEE_PARAM_PRIVACY_INVOKED 4
56#define IEEE_PARAM_AUTH_ALGS 5
57#define IEEE_PARAM_IEEE_802_1X 6
58
59
60#define IEEE_PARAM_WPAX_SELECT 7
61
62
63#define IEEE_PROTO_WPA 1
64#define IEEE_PROTO_RSN 2
65
66
67#define IEEE_WPAX_USEGROUP 0
68#define IEEE_WPAX_WEP40 1
69#define IEEE_WPAX_TKIP 2
70#define IEEE_WPAX_WRAP 3
71#define IEEE_WPAX_CCMP 4
72#define IEEE_WPAX_WEP104 5
73
74#define IEEE_KEY_MGMT_IEEE8021X 1
75#define IEEE_KEY_MGMT_PSK 2
76
77
78
79#define IEEE_MLME_STA_DEAUTH 1
80#define IEEE_MLME_STA_DISASSOC 2
81
82
83#define IEEE_CRYPT_ERR_UNKNOWN_ALG 2
84#define IEEE_CRYPT_ERR_UNKNOWN_ADDR 3
85#define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED 4
86#define IEEE_CRYPT_ERR_KEY_SET_FAILED 5
87#define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED 6
88#define IEEE_CRYPT_ERR_CARD_CONF_FAILED 7
89
90
91#define IEEE_CRYPT_ALG_NAME_LEN 16
92
93
94typedef struct ieee_param {
95 u32 cmd;
96 u8 sta_addr[ETH_ALEN];
97 union {
98 struct {
99 u8 name;
100 u32 value;
101 } wpa_param;
102 struct {
103 u32 len;
104 u8 reserved[32];
105 u8 data[0];
106 } wpa_ie;
107 struct{
108 int command;
109 int reason_code;
110 } mlme;
111 struct {
112 u8 alg[IEEE_CRYPT_ALG_NAME_LEN];
113 u8 set_tx;
114 u32 err;
115 u8 idx;
116 u8 seq[8];
117 u16 key_len;
118 u8 key[0];
119 } crypt;
120
121 } u;
122}ieee_param;
123
124
125#define MSECS(t) msecs_to_jiffies(t)
126#define msleep_interruptible_rtl msleep_interruptible
127
128#define IEEE80211_DATA_LEN 2304
129
130
131
132
133
134
135
136
137#define IEEE80211_3ADDR_LEN 24
138#define IEEE80211_4ADDR_LEN 30
139#define IEEE80211_FCS_LEN 4
140#define IEEE80211_HLEN IEEE80211_4ADDR_LEN
141#define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
142#define IEEE80211_MGMT_HDR_LEN 24
143#define IEEE80211_DATA_HDR3_LEN 24
144#define IEEE80211_DATA_HDR4_LEN 30
145
146#define MIN_FRAG_THRESHOLD 256U
147#define MAX_FRAG_THRESHOLD 2346U
148
149
150#define IEEE80211_FCTL_DSTODS 0x0300
151#define IEEE80211_FCTL_WEP 0x4000
152
153
154
155#ifdef CONFIG_IEEE80211_DEBUG
156extern u32 ieee80211_debug_level;
157#define IEEE80211_DEBUG(level, fmt, args...) \
158do { if (ieee80211_debug_level & (level)) \
159 printk(KERN_DEBUG "ieee80211: %c %s " fmt, \
160 in_interrupt() ? 'I' : 'U', __func__ , ## args); } while (0)
161#else
162#define IEEE80211_DEBUG(level, fmt, args...) do {} while (0)
163#endif
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191#define IEEE80211_DL_INFO (1<<0)
192#define IEEE80211_DL_WX (1<<1)
193#define IEEE80211_DL_SCAN (1<<2)
194#define IEEE80211_DL_STATE (1<<3)
195#define IEEE80211_DL_MGMT (1<<4)
196#define IEEE80211_DL_FRAG (1<<5)
197#define IEEE80211_DL_EAP (1<<6)
198#define IEEE80211_DL_DROP (1<<7)
199
200#define IEEE80211_DL_TX (1<<8)
201#define IEEE80211_DL_RX (1<<9)
202
203#define IEEE80211_ERROR(f, a...) printk(KERN_ERR "ieee80211: " f, ## a)
204#define IEEE80211_WARNING(f, a...) printk(KERN_WARNING "ieee80211: " f, ## a)
205#define IEEE80211_DEBUG_INFO(f, a...) IEEE80211_DEBUG(IEEE80211_DL_INFO, f, ## a)
206
207#define IEEE80211_DEBUG_WX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_WX, f, ## a)
208#define IEEE80211_DEBUG_SCAN(f, a...) IEEE80211_DEBUG(IEEE80211_DL_SCAN, f, ## a)
209
210#define IEEE80211_DEBUG_STATE(f, a...) IEEE80211_DEBUG(IEEE80211_DL_STATE, f, ## a)
211#define IEEE80211_DEBUG_MGMT(f, a...) IEEE80211_DEBUG(IEEE80211_DL_MGMT, f, ## a)
212#define IEEE80211_DEBUG_FRAG(f, a...) IEEE80211_DEBUG(IEEE80211_DL_FRAG, f, ## a)
213#define IEEE80211_DEBUG_EAP(f, a...) IEEE80211_DEBUG(IEEE80211_DL_EAP, f, ## a)
214#define IEEE80211_DEBUG_DROP(f, a...) IEEE80211_DEBUG(IEEE80211_DL_DROP, f, ## a)
215#define IEEE80211_DEBUG_TX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_TX, f, ## a)
216#define IEEE80211_DEBUG_RX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_RX, f, ## a)
217#include <linux/netdevice.h>
218#include <linux/if_arp.h>
219
220#ifndef WIRELESS_SPY
221#define WIRELESS_SPY
222#endif
223#include <net/iw_handler.h>
224
225#ifndef ETH_P_PAE
226#define ETH_P_PAE 0x888E
227#endif
228
229#define ETH_P_PREAUTH 0x88C7
230
231#ifndef ETH_P_80211_RAW
232#define ETH_P_80211_RAW (ETH_P_ECONET + 1)
233#endif
234
235
236
237#define P80211_OUI_LEN 3
238
239struct ieee80211_snap_hdr {
240
241 u8 dsap;
242 u8 ssap;
243 u8 ctrl;
244 u8 oui[P80211_OUI_LEN];
245
246} __attribute__ ((packed));
247
248#define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
249
250#define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE)
251#define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE)
252
253#define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG)
254#define WLAN_GET_SEQ_SEQ(seq) ((seq) & IEEE80211_SCTL_SEQ)
255
256#define WLAN_CAPABILITY_BSS (1<<0)
257#define WLAN_CAPABILITY_SHORT_SLOT (1<<10)
258
259#define IEEE80211_STATMASK_SIGNAL (1<<0)
260#define IEEE80211_STATMASK_RSSI (1<<1)
261#define IEEE80211_STATMASK_NOISE (1<<2)
262#define IEEE80211_STATMASK_RATE (1<<3)
263#define IEEE80211_STATMASK_WEMASK 0x7
264
265
266#define IEEE80211_CCK_MODULATION (1<<0)
267#define IEEE80211_OFDM_MODULATION (1<<1)
268
269#define IEEE80211_24GHZ_BAND (1<<0)
270#define IEEE80211_52GHZ_BAND (1<<1)
271
272#define IEEE80211_CCK_RATE_LEN 4
273#define IEEE80211_CCK_RATE_1MB 0x02
274#define IEEE80211_CCK_RATE_2MB 0x04
275#define IEEE80211_CCK_RATE_5MB 0x0B
276#define IEEE80211_CCK_RATE_11MB 0x16
277#define IEEE80211_OFDM_RATE_LEN 8
278#define IEEE80211_OFDM_RATE_6MB 0x0C
279#define IEEE80211_OFDM_RATE_9MB 0x12
280#define IEEE80211_OFDM_RATE_12MB 0x18
281#define IEEE80211_OFDM_RATE_18MB 0x24
282#define IEEE80211_OFDM_RATE_24MB 0x30
283#define IEEE80211_OFDM_RATE_36MB 0x48
284#define IEEE80211_OFDM_RATE_48MB 0x60
285#define IEEE80211_OFDM_RATE_54MB 0x6C
286#define IEEE80211_BASIC_RATE_MASK 0x80
287
288#define IEEE80211_CCK_RATE_1MB_MASK (1<<0)
289#define IEEE80211_CCK_RATE_2MB_MASK (1<<1)
290#define IEEE80211_CCK_RATE_5MB_MASK (1<<2)
291#define IEEE80211_CCK_RATE_11MB_MASK (1<<3)
292#define IEEE80211_OFDM_RATE_6MB_MASK (1<<4)
293#define IEEE80211_OFDM_RATE_9MB_MASK (1<<5)
294#define IEEE80211_OFDM_RATE_12MB_MASK (1<<6)
295#define IEEE80211_OFDM_RATE_18MB_MASK (1<<7)
296#define IEEE80211_OFDM_RATE_24MB_MASK (1<<8)
297#define IEEE80211_OFDM_RATE_36MB_MASK (1<<9)
298#define IEEE80211_OFDM_RATE_48MB_MASK (1<<10)
299#define IEEE80211_OFDM_RATE_54MB_MASK (1<<11)
300
301#define IEEE80211_CCK_RATES_MASK 0x0000000F
302#define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \
303 IEEE80211_CCK_RATE_2MB_MASK)
304#define IEEE80211_CCK_DEFAULT_RATES_MASK (IEEE80211_CCK_BASIC_RATES_MASK | \
305 IEEE80211_CCK_RATE_5MB_MASK | \
306 IEEE80211_CCK_RATE_11MB_MASK)
307
308#define IEEE80211_OFDM_RATES_MASK 0x00000FF0
309#define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \
310 IEEE80211_OFDM_RATE_12MB_MASK | \
311 IEEE80211_OFDM_RATE_24MB_MASK)
312#define IEEE80211_OFDM_DEFAULT_RATES_MASK (IEEE80211_OFDM_BASIC_RATES_MASK | \
313 IEEE80211_OFDM_RATE_9MB_MASK | \
314 IEEE80211_OFDM_RATE_18MB_MASK | \
315 IEEE80211_OFDM_RATE_36MB_MASK | \
316 IEEE80211_OFDM_RATE_48MB_MASK | \
317 IEEE80211_OFDM_RATE_54MB_MASK)
318#define IEEE80211_DEFAULT_RATES_MASK (IEEE80211_OFDM_DEFAULT_RATES_MASK | \
319 IEEE80211_CCK_DEFAULT_RATES_MASK)
320
321#define IEEE80211_NUM_OFDM_RATES 8
322#define IEEE80211_NUM_CCK_RATES 4
323#define IEEE80211_OFDM_SHIFT_MASK_A 4
324
325
326#define IEEE80211_FC0_TYPE_MASK 0x0c
327#define IEEE80211_FC0_TYPE_DATA 0x08
328#define IEEE80211_FC0_SUBTYPE_MASK 0xB0
329#define IEEE80211_FC0_SUBTYPE_QOS 0x80
330
331#define IEEE80211_QOS_HAS_SEQ(fc) \
332 (((fc) & (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK)) == \
333 (IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_QOS))
334
335
336#define IEEE_IBSS_MAC_HASH_SIZE 31
337struct ieee_ibss_seq {
338 u8 mac[ETH_ALEN];
339 u16 seq_num[17];
340 u16 frag_num[17];
341 unsigned long packet_time[17];
342 struct list_head list;
343};
344
345
346
347
348struct ieee80211_rx_stats {
349 u32 mac_time[2];
350 u8 signalstrength;
351 s8 rssi;
352 u8 signal;
353 u8 noise;
354 u16 rate;
355 u8 received_channel;
356 u8 control;
357 u8 mask;
358 u8 freq;
359 u16 len;
360 u8 nic_type;
361};
362
363
364
365
366
367#define IEEE80211_FRAG_CACHE_LEN 4
368
369struct ieee80211_frag_entry {
370 unsigned long first_frag_time;
371 unsigned int seq;
372 unsigned int last_frag;
373 struct sk_buff *skb;
374 u8 src_addr[ETH_ALEN];
375 u8 dst_addr[ETH_ALEN];
376};
377
378struct ieee80211_stats {
379 unsigned int tx_unicast_frames;
380 unsigned int tx_multicast_frames;
381 unsigned int tx_fragments;
382 unsigned int tx_unicast_octets;
383 unsigned int tx_multicast_octets;
384 unsigned int tx_deferred_transmissions;
385 unsigned int tx_single_retry_frames;
386 unsigned int tx_multiple_retry_frames;
387 unsigned int tx_retry_limit_exceeded;
388 unsigned int tx_discards;
389 unsigned int rx_unicast_frames;
390 unsigned int rx_multicast_frames;
391 unsigned int rx_fragments;
392 unsigned int rx_unicast_octets;
393 unsigned int rx_multicast_octets;
394 unsigned int rx_fcs_errors;
395 unsigned int rx_discards_no_buffer;
396 unsigned int tx_discards_wrong_sa;
397 unsigned int rx_discards_undecryptable;
398 unsigned int rx_message_in_msg_fragments;
399 unsigned int rx_message_in_bad_msg_fragments;
400};
401
402struct ieee80211_device;
403
404#include "ieee80211_crypt.h"
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
416#define SEC_LEVEL_0 0
417#define SEC_LEVEL_1 1
418#define SEC_LEVEL_2 2
419#define SEC_LEVEL_2_CKIP 3
420#define SEC_LEVEL_3 4
421
422#define WEP_KEYS 4
423#define WEP_KEY_LEN 13
424
425#define WEP_KEY_LEN_MODIF 32
426
427struct ieee80211_security {
428 u16 active_key:2,
429 enabled:1,
430 auth_mode:2,
431 auth_algo:4,
432 unicast_uses_group:1;
433 u8 key_sizes[WEP_KEYS];
434 u8 keys[WEP_KEYS][WEP_KEY_LEN_MODIF];
435 u8 level;
436 u16 flags;
437} __attribute__ ((packed));
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456enum {
457 MFIE_TYPE_SSID = 0,
458 MFIE_TYPE_RATES = 1,
459 MFIE_TYPE_FH_SET = 2,
460 MFIE_TYPE_DS_SET = 3,
461 MFIE_TYPE_CF_SET = 4,
462 MFIE_TYPE_TIM = 5,
463 MFIE_TYPE_IBSS_SET = 6,
464 MFIE_TYPE_COUNTRY = 7,
465 MFIE_TYPE_CHALLENGE = 16,
466 MFIE_TYPE_ERP = 42,
467 MFIE_TYPE_RSN = 48,
468 MFIE_TYPE_RATES_EX = 50,
469 MFIE_TYPE_GENERIC = 221,
470};
471
472struct ieee80211_header_data {
473 u16 frame_ctl;
474 u16 duration_id;
475 u8 addr1[6];
476 u8 addr2[6];
477 u8 addr3[6];
478 u16 seq_ctrl;
479};
480
481struct ieee80211_hdr_4addr {
482 u16 frame_ctl;
483 u16 duration_id;
484 u8 addr1[ETH_ALEN];
485 u8 addr2[ETH_ALEN];
486 u8 addr3[ETH_ALEN];
487 u16 seq_ctl;
488 u8 addr4[ETH_ALEN];
489} __attribute__ ((packed));
490
491struct ieee80211_hdr_3addrqos {
492 u16 frame_ctl;
493 u16 duration_id;
494 u8 addr1[ETH_ALEN];
495 u8 addr2[ETH_ALEN];
496 u8 addr3[ETH_ALEN];
497 u16 seq_ctl;
498 u16 qos_ctl;
499} __attribute__ ((packed));
500
501struct ieee80211_hdr_4addrqos {
502 u16 frame_ctl;
503 u16 duration_id;
504 u8 addr1[ETH_ALEN];
505 u8 addr2[ETH_ALEN];
506 u8 addr3[ETH_ALEN];
507 u16 seq_ctl;
508 u8 addr4[ETH_ALEN];
509 u16 qos_ctl;
510} __attribute__ ((packed));
511
512struct ieee80211_info_element_hdr {
513 u8 id;
514 u8 len;
515} __attribute__ ((packed));
516
517struct ieee80211_info_element {
518 u8 id;
519 u8 len;
520 u8 data[0];
521} __attribute__ ((packed));
522
523struct ieee80211_authentication {
524 struct ieee80211_header_data header;
525 u16 algorithm;
526 u16 transaction;
527 u16 status;
528
529} __attribute__ ((packed));
530
531struct ieee80211_disassoc_frame {
532 struct ieee80211_hdr_3addr header;
533 u16 reasoncode;
534} __attribute__ ((packed));
535
536struct ieee80211_probe_request {
537 struct ieee80211_header_data header;
538
539} __attribute__ ((packed));
540
541struct ieee80211_probe_response {
542 struct ieee80211_header_data header;
543 u32 time_stamp[2];
544 u16 beacon_interval;
545 u16 capability;
546 struct ieee80211_info_element info_element;
547} __attribute__ ((packed));
548
549struct ieee80211_assoc_request_frame {
550 struct ieee80211_hdr_3addr header;
551 u16 capability;
552 u16 listen_interval;
553
554 struct ieee80211_info_element_hdr info_element;
555} __attribute__ ((packed));
556
557struct ieee80211_assoc_response_frame {
558 struct ieee80211_hdr_3addr header;
559 u16 capability;
560 u16 status;
561 u16 aid;
562 struct ieee80211_info_element info_element;
563} __attribute__ ((packed));
564
565struct ieee80211_txb {
566 u8 nr_frags;
567 u8 encrypted;
568 u16 reserved;
569 u16 frag_size;
570 u16 payload_size;
571 struct sk_buff *fragments[0];
572};
573
574
575#define MAX_SWEEP_TAB_ENTRIES 42
576#define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
577
578
579
580
581
582#define MAX_RATES_LENGTH ((u8)12)
583#define MAX_RATES_EX_LENGTH ((u8)16)
584
585#define MAX_NETWORK_COUNT 128
586
587#define MAX_CHANNEL_NUMBER 165
588
589#define IEEE80211_SOFTMAC_SCAN_TIME 100
590#define IEEE80211_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2)
591
592#define CRC_LENGTH 4U
593
594#define MAX_WPA_IE_LEN 64
595
596#define NETWORK_EMPTY_ESSID (1 << 0)
597#define NETWORK_HAS_OFDM (1 << 1)
598#define NETWORK_HAS_CCK (1 << 2)
599
600struct ieee80211_wmm_ac_param {
601 u8 ac_aci_acm_aifsn;
602 u8 ac_ecwmin_ecwmax;
603 u16 ac_txop_limit;
604};
605
606struct ieee80211_wmm_ts_info {
607 u8 ac_dir_tid;
608 u8 ac_up_psb;
609 u8 reserved;
610} __attribute__ ((packed));
611
612struct ieee80211_wmm_tspec_elem {
613 struct ieee80211_wmm_ts_info ts_info;
614 u16 norm_msdu_size;
615 u16 max_msdu_size;
616 u32 min_serv_inter;
617 u32 max_serv_inter;
618 u32 inact_inter;
619 u32 suspen_inter;
620 u32 serv_start_time;
621 u32 min_data_rate;
622 u32 mean_data_rate;
623 u32 peak_data_rate;
624 u32 max_burst_size;
625 u32 delay_bound;
626 u32 min_phy_rate;
627 u16 surp_band_allow;
628 u16 medium_time;
629}__attribute__((packed));
630
631enum eap_type {
632 EAP_PACKET = 0,
633 EAPOL_START,
634 EAPOL_LOGOFF,
635 EAPOL_KEY,
636 EAPOL_ENCAP_ASF_ALERT
637};
638
639static const char *eap_types[] = {
640 [EAP_PACKET] = "EAP-Packet",
641 [EAPOL_START] = "EAPOL-Start",
642 [EAPOL_LOGOFF] = "EAPOL-Logoff",
643 [EAPOL_KEY] = "EAPOL-Key",
644 [EAPOL_ENCAP_ASF_ALERT] = "EAPOL-Encap-ASF-Alert"
645};
646
647static inline const char *eap_get_type(int type)
648{
649 return (type >= ARRAY_SIZE(eap_types)) ? "Unknown" : eap_types[type];
650}
651
652struct eapol {
653 u8 snap[6];
654 u16 ethertype;
655 u8 version;
656 u8 type;
657 u16 length;
658} __attribute__ ((packed));
659
660struct ieee80211_softmac_stats {
661 unsigned int rx_ass_ok;
662 unsigned int rx_ass_err;
663 unsigned int rx_probe_rq;
664 unsigned int tx_probe_rs;
665 unsigned int tx_beacons;
666 unsigned int rx_auth_rq;
667 unsigned int rx_auth_rs_ok;
668 unsigned int rx_auth_rs_err;
669 unsigned int tx_auth_rq;
670 unsigned int no_auth_rs;
671 unsigned int no_ass_rs;
672 unsigned int tx_ass_rq;
673 unsigned int rx_ass_rq;
674 unsigned int tx_probe_rq;
675 unsigned int reassoc;
676 unsigned int swtxstop;
677 unsigned int swtxawake;
678};
679
680#define BEACON_PROBE_SSID_ID_POSITION 12
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699#define IEEE80211_DEFAULT_TX_ESSID "Penguin"
700#define IEEE80211_DEFAULT_BASIC_RATE 10
701
702enum {WMM_all_frame, WMM_two_frame, WMM_four_frame, WMM_six_frame};
703#define MAX_SP_Len (WMM_all_frame << 4)
704#define IEEE80211_QOS_TID 0x0f
705#define QOS_CTL_NOTCONTAIN_ACK (0x01 << 5)
706
707#define MAX_IE_LEN 0xFF
708
709typedef struct _CHANNEL_LIST{
710 u8 Channel[MAX_CHANNEL_NUMBER + 1];
711 u8 Len;
712}CHANNEL_LIST, *PCHANNEL_LIST;
713
714
715#define IEEE80211_WATCH_DOG_TIME 2000
716
717
718#define ANTENNA_DIVERSITY_TIMER_PERIOD 1000
719
720
721#define IEEE80211_DTIM_MBCAST 4
722#define IEEE80211_DTIM_UCAST 2
723#define IEEE80211_DTIM_VALID 1
724#define IEEE80211_DTIM_INVALID 0
725
726#define IEEE80211_PS_DISABLED 0
727#define IEEE80211_PS_UNICAST IEEE80211_DTIM_UCAST
728#define IEEE80211_PS_MBCAST IEEE80211_DTIM_MBCAST
729#define IEEE80211_PS_ENABLE IEEE80211_DTIM_VALID
730
731
732#ifdef WMM_Hang_8187
733#undef WMM_Hang_8187
734#endif
735
736#define WME_AC_BE 0x00
737#define WME_AC_BK 0x01
738#define WME_AC_VI 0x02
739#define WME_AC_VO 0x03
740#define WME_ACI_MASK 0x03
741#define WME_AIFSN_MASK 0x03
742#define WME_AC_PRAM_LEN 16
743
744
745
746#define UP2AC(up) ( \
747 ((up) < 1) ? WME_AC_BE : \
748 ((up) < 3) ? WME_AC_BK : \
749 ((up) < 4) ? WME_AC_BE : \
750 ((up) < 6) ? WME_AC_VI : \
751 WME_AC_VO)
752
753#define AC2UP(_ac) ( \
754 ((_ac) == WME_AC_VO) ? 6 : \
755 ((_ac) == WME_AC_VI) ? 5 : \
756 ((_ac) == WME_AC_BK) ? 1 : \
757 0)
758
759#define ETHER_ADDR_LEN 6
760struct ether_header {
761 u8 ether_dhost[ETHER_ADDR_LEN];
762 u8 ether_shost[ETHER_ADDR_LEN];
763 u16 ether_type;
764} __attribute__((packed));
765
766#ifndef ETHERTYPE_PAE
767#define ETHERTYPE_PAE 0x888e
768#endif
769#ifndef ETHERTYPE_IP
770#define ETHERTYPE_IP 0x0800
771#endif
772
773struct ieee80211_network {
774
775 u8 bssid[ETH_ALEN];
776 u8 channel;
777
778 u8 ssid[IW_ESSID_MAX_SIZE + 1];
779 u8 ssid_len;
780
781
782 struct ieee80211_rx_stats stats;
783 u16 capability;
784 u8 rates[MAX_RATES_LENGTH];
785 u8 rates_len;
786 u8 rates_ex[MAX_RATES_EX_LENGTH];
787 u8 rates_ex_len;
788 unsigned long last_scanned;
789 u8 mode;
790 u8 flags;
791 u32 last_associate;
792 u32 time_stamp[2];
793 u16 beacon_interval;
794 u16 listen_interval;
795 u16 atim_window;
796 u8 wpa_ie[MAX_WPA_IE_LEN];
797 size_t wpa_ie_len;
798 u8 rsn_ie[MAX_WPA_IE_LEN];
799 size_t rsn_ie_len;
800 u8 dtim_period;
801 u8 dtim_data;
802 u32 last_dtim_sta_time[2];
803 struct list_head list;
804
805 u8 wmm_info;
806 struct ieee80211_wmm_ac_param wmm_param[4];
807 u8 QoS_Enable;
808 u8 SignalStrength;
809
810 u8 HighestOperaRate;
811
812 u8 Turbo_Enable;
813 u16 CountryIeLen;
814 u8 CountryIeBuf[MAX_IE_LEN];
815};
816
817enum ieee80211_state {
818
819
820 IEEE80211_NOLINK = 0,
821
822
823
824
825
826
827
828
829
830
831 IEEE80211_ASSOCIATING,
832 IEEE80211_ASSOCIATING_RETRY,
833
834
835 IEEE80211_ASSOCIATING_AUTHENTICATING,
836
837
838
839
840 IEEE80211_ASSOCIATING_AUTHENTICATED,
841
842
843
844
845 IEEE80211_LINKED,
846
847
848
849
850
851
852 IEEE80211_LINKED_SCANNING,
853
854};
855
856#define DEFAULT_MAX_SCAN_AGE (15 * HZ)
857#define DEFAULT_FTS 2346
858
859#define CFG_IEEE80211_RESERVE_FCS (1<<0)
860#define CFG_IEEE80211_COMPUTE_FCS (1<<1)
861
862typedef struct tx_pending_t{
863 int frag;
864 struct ieee80211_txb *txb;
865}tx_pending_t;
866
867enum {
868 COUNTRY_CODE_FCC = 0,
869 COUNTRY_CODE_IC = 1,
870 COUNTRY_CODE_ETSI = 2,
871 COUNTRY_CODE_SPAIN = 3,
872 COUNTRY_CODE_FRANCE = 4,
873 COUNTRY_CODE_MKK = 5,
874 COUNTRY_CODE_MKK1 = 6,
875 COUNTRY_CODE_ISRAEL = 7,
876 COUNTRY_CODE_TELEC = 8,
877 COUNTRY_CODE_GLOBAL_DOMAIN = 9,
878 COUNTRY_CODE_WORLD_WIDE_13_INDEX = 10
879};
880
881struct ieee80211_device {
882 struct net_device *dev;
883
884
885 struct net_device_stats stats;
886 struct ieee80211_stats ieee_stats;
887 struct ieee80211_softmac_stats softmac_stats;
888
889
890 struct list_head network_free_list;
891 struct list_head network_list;
892 struct ieee80211_network *networks;
893 int scans;
894 int scan_age;
895
896 int iw_mode;
897
898 spinlock_t lock;
899 spinlock_t wpax_suitlist_lock;
900
901 int tx_headroom;
902
903 u32 config;
904
905
906 int open_wep;
907
908 int reset_on_keychange;
909
910
911
912 int host_encrypt;
913 int host_decrypt;
914 int ieee802_1x;
915
916
917 int wpa_enabled;
918 int drop_unencrypted;
919 int tkip_countermeasures;
920 int privacy_invoked;
921 size_t wpa_ie_len;
922 u8 *wpa_ie;
923
924 u8 ap_mac_addr[6];
925 u16 pairwise_key_type;
926 u16 broadcast_key_type;
927
928 struct list_head crypt_deinit_list;
929 struct ieee80211_crypt_data *crypt[WEP_KEYS];
930 int tx_keyidx;
931 struct timer_list crypt_deinit_timer;
932
933 int bcrx_sta_key;
934
935
936
937
938 struct ieee80211_frag_entry frag_cache[17][IEEE80211_FRAG_CACHE_LEN];
939 unsigned int frag_next_idx[17];
940 u16 fts;
941
942
943
944
945
946
947
948
949
950 struct ieee80211_network current_network;
951
952
953 enum ieee80211_state state;
954
955 int short_slot;
956 int mode;
957 int modulation;
958 int freq_band;
959 int abg_true;
960
961
962
963
964 short sync_scan_hurryup;
965
966 void * pDot11dInfo;
967 bool bGlobalDomain;
968
969
970 u8 MinPassiveChnlNum;
971 u8 IbssStartChnl;
972
973 int rate;
974 int basic_rate;
975
976 short active_scan;
977
978
979 u16 softmac_features;
980
981
982 u16 seq_ctrl[5];
983
984
985 u16 associate_seq;
986
987
988 u16 assoc_id;
989
990
991 short ps;
992 short sta_sleep;
993 int ps_timeout;
994 struct tasklet_struct ps_task;
995 u32 ps_th;
996 u32 ps_tl;
997
998 short raw_tx;
999
1000 short queue_stop;
1001 short scanning;
1002 short proto_started;
1003
1004 struct semaphore wx_sem;
1005 struct semaphore scan_sem;
1006
1007 spinlock_t mgmt_tx_lock;
1008 spinlock_t beacon_lock;
1009
1010 short beacon_txing;
1011
1012 short wap_set;
1013 short ssid_set;
1014
1015 u8 wpax_type_set;
1016 u32 wpax_type_notify;
1017
1018
1019 char init_wmmparam_flag;
1020
1021
1022 struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE];
1023
1024
1025 u16 last_rxseq_num[17];
1026 u16 last_rxfrag_num[17];
1027 unsigned long last_packet_time[17];
1028
1029
1030 unsigned long last_rx_ps_time;
1031
1032
1033 struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM];
1034 int mgmt_queue_head;
1035 int mgmt_queue_tail;
1036
1037
1038
1039 struct tx_pending_t tx_pending;
1040
1041
1042 struct timer_list associate_timer;
1043
1044
1045 struct timer_list beacon_timer;
1046
1047 struct work_struct associate_complete_wq;
1048
1049 struct work_struct associate_procedure_wq;
1050
1051 struct work_struct wx_sync_scan_wq;
1052 struct work_struct wmm_param_update_wq;
1053 struct work_struct ps_request_tx_ack_wq;
1054
1055
1056
1057 bool bInactivePs;
1058 bool actscanning;
1059 bool beinretry;
1060 u16 ListenInterval;
1061 unsigned long NumRxDataInPeriod;
1062 unsigned long NumRxBcnInPeriod;
1063 unsigned long NumRxOkTotal;
1064 unsigned long NumRxUnicast;
1065 bool bHwRadioOff;
1066 struct delayed_work softmac_scan_wq;
1067 struct delayed_work associate_retry_wq;
1068 struct delayed_work hw_wakeup_wq;
1069 struct delayed_work hw_sleep_wq;
1070 struct delayed_work watch_dog_wq;
1071 struct delayed_work sw_antenna_wq;
1072 struct delayed_work start_ibss_wq;
1073
1074 struct delayed_work rate_adapter_wq;
1075
1076 struct delayed_work hw_dig_wq;
1077 struct delayed_work tx_pw_wq;
1078
1079
1080 struct delayed_work GPIOChangeRFWorkItem;
1081
1082 struct workqueue_struct *wq;
1083
1084
1085 void (*set_security)(struct net_device *dev,
1086 struct ieee80211_security *sec);
1087
1088
1089
1090
1091
1092 int (*hard_start_xmit)(struct ieee80211_txb *txb,
1093 struct net_device *dev);
1094
1095 int (*reset_port)(struct net_device *dev);
1096
1097
1098
1099
1100
1101
1102
1103
1104 int (*softmac_hard_start_xmit)(struct sk_buff *skb,
1105 struct net_device *dev);
1106
1107
1108
1109
1110
1111
1112
1113 void (*softmac_data_hard_start_xmit)(struct sk_buff *skb,
1114 struct net_device *dev,int rate);
1115
1116
1117
1118
1119
1120 void (*data_hard_stop)(struct net_device *dev);
1121
1122
1123 void (*data_hard_resume)(struct net_device *dev);
1124
1125
1126
1127
1128
1129 void (*set_chan)(struct net_device *dev,short ch);
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146 void (*scan_syncro)(struct net_device *dev);
1147 void (*start_scan)(struct net_device *dev);
1148 void (*stop_scan)(struct net_device *dev);
1149
1150
1151
1152
1153
1154
1155 void (*link_change)(struct net_device *dev);
1156
1157
1158
1159
1160
1161
1162
1163 void (*start_send_beacons) (struct net_device *dev);
1164 void (*stop_send_beacons) (struct net_device *dev);
1165
1166
1167 void (*sta_wake_up) (struct net_device *dev);
1168 void (*ps_request_tx_ack) (struct net_device *dev);
1169 void (*enter_sleep_state) (struct net_device *dev, u32 th, u32 tl);
1170 short (*ps_is_queue_empty) (struct net_device *dev);
1171
1172
1173
1174
1175
1176
1177
1178 u8 priv[0];
1179};
1180
1181#define IEEE_A (1<<0)
1182#define IEEE_B (1<<1)
1183#define IEEE_G (1<<2)
1184#define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
1185
1186
1187
1188
1189
1190
1191#define IEEE_SOFTMAC_SCAN (1<<2)
1192
1193
1194#define IEEE_SOFTMAC_ASSOCIATE (1<<3)
1195
1196
1197#define IEEE_SOFTMAC_PROBERQ (1<<4)
1198
1199
1200#define IEEE_SOFTMAC_PROBERS (1<<5)
1201
1202
1203
1204
1205#define IEEE_SOFTMAC_TX_QUEUE (1<<7)
1206
1207
1208
1209
1210#define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8)
1211
1212
1213
1214
1215#define IEEE_SOFTMAC_BEACONS (1<<6)
1216
1217
1218
1219static inline void *ieee80211_priv(struct net_device *dev)
1220{
1221 return ((struct ieee80211_device *)netdev_priv(dev))->priv;
1222}
1223
1224extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
1225{
1226
1227 if (essid_len == 1 && essid[0] == ' ')
1228 return 1;
1229
1230
1231 while (essid_len) {
1232 essid_len--;
1233 if (essid[essid_len] != '\0')
1234 return 0;
1235 }
1236
1237 return 1;
1238}
1239
1240extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode)
1241{
1242
1243
1244
1245
1246
1247
1248 if ((mode & IEEE_A) &&
1249 (ieee->modulation & IEEE80211_OFDM_MODULATION) &&
1250 (ieee->freq_band & IEEE80211_52GHZ_BAND))
1251 return 1;
1252
1253 if ((mode & IEEE_G) &&
1254 (ieee->modulation & IEEE80211_OFDM_MODULATION) &&
1255 (ieee->freq_band & IEEE80211_24GHZ_BAND))
1256 return 1;
1257
1258 if ((mode & IEEE_B) &&
1259 (ieee->modulation & IEEE80211_CCK_MODULATION) &&
1260 (ieee->freq_band & IEEE80211_24GHZ_BAND))
1261 return 1;
1262
1263 return 0;
1264}
1265
1266extern inline int ieee80211_get_hdrlen(u16 fc)
1267{
1268 int hdrlen = 24;
1269
1270 switch (WLAN_FC_GET_TYPE(fc)) {
1271 case IEEE80211_FTYPE_DATA:
1272 if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
1273 hdrlen = 30;
1274 if(IEEE80211_QOS_HAS_SEQ(fc))
1275 hdrlen += 2;
1276 break;
1277 case IEEE80211_FTYPE_CTL:
1278 switch (WLAN_FC_GET_STYPE(fc)) {
1279 case IEEE80211_STYPE_CTS:
1280 case IEEE80211_STYPE_ACK:
1281 hdrlen = 10;
1282 break;
1283 default:
1284 hdrlen = 16;
1285 break;
1286 }
1287 break;
1288 }
1289
1290 return hdrlen;
1291}
1292
1293
1294
1295
1296extern void free_ieee80211(struct net_device *dev);
1297extern struct net_device *alloc_ieee80211(int sizeof_priv);
1298
1299extern int ieee80211_set_encryption(struct ieee80211_device *ieee);
1300
1301
1302
1303extern int ieee80211_encrypt_fragment(
1304 struct ieee80211_device *ieee,
1305 struct sk_buff *frag,
1306 int hdr_len);
1307
1308extern int ieee80211_rtl_xmit(struct sk_buff *skb,
1309 struct net_device *dev);
1310extern void ieee80211_txb_free(struct ieee80211_txb *);
1311
1312
1313
1314extern int ieee80211_rtl_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
1315 struct ieee80211_rx_stats *rx_stats);
1316extern void ieee80211_rx_mgt(struct ieee80211_device *ieee,
1317 struct ieee80211_hdr_4addr *header,
1318 struct ieee80211_rx_stats *stats);
1319
1320
1321extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
1322 struct iw_request_info *info,
1323 union iwreq_data *wrqu, char *key);
1324extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
1325 struct iw_request_info *info,
1326 union iwreq_data *wrqu, char *key);
1327extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
1328 struct iw_request_info *info,
1329 union iwreq_data *wrqu, char *key);
1330extern int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee,
1331 struct iw_request_info *info,
1332 union iwreq_data* wrqu, char *extra);
1333int ieee80211_wx_set_auth(struct ieee80211_device *ieee,
1334 struct iw_request_info *info,
1335 struct iw_param *data, char *extra);
1336int ieee80211_wx_set_mlme(struct ieee80211_device *ieee,
1337 struct iw_request_info *info,
1338 union iwreq_data *wrqu, char *extra);
1339
1340int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len);
1341
1342extern short ieee80211_is_54g(struct ieee80211_network net);
1343extern short ieee80211_is_shortslot(struct ieee80211_network net);
1344extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb,
1345 struct ieee80211_rx_stats *rx_stats, u16 type,
1346 u16 stype);
1347extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net);
1348
1349extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee);
1350extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee);
1351extern void ieee80211_start_bss(struct ieee80211_device *ieee);
1352extern void ieee80211_start_master_bss(struct ieee80211_device *ieee);
1353extern void ieee80211_start_ibss(struct ieee80211_device *ieee);
1354extern void ieee80211_softmac_init(struct ieee80211_device *ieee);
1355extern void ieee80211_softmac_free(struct ieee80211_device *ieee);
1356extern void ieee80211_associate_abort(struct ieee80211_device *ieee);
1357extern void ieee80211_disassociate(struct ieee80211_device *ieee);
1358extern void ieee80211_stop_scan(struct ieee80211_device *ieee);
1359extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee);
1360extern void ieee80211_check_all_nets(struct ieee80211_device *ieee);
1361extern void ieee80211_start_protocol(struct ieee80211_device *ieee);
1362extern void ieee80211_stop_protocol(struct ieee80211_device *ieee);
1363extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee);
1364extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee);
1365extern void ieee80211_reset_queue(struct ieee80211_device *ieee);
1366extern void ieee80211_rtl_wake_queue(struct ieee80211_device *ieee);
1367extern void ieee80211_rtl_stop_queue(struct ieee80211_device *ieee);
1368extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee);
1369extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee);
1370extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee);
1371extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p);
1372extern void notify_wx_assoc_event(struct ieee80211_device *ieee);
1373extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success);
1374extern void SendDisassociation(struct ieee80211_device *ieee,u8* asSta,u8 asRsn);
1375extern void ieee80211_rtl_start_scan(struct ieee80211_device *ieee);
1376
1377
1378extern void SendDisassociation(struct ieee80211_device *ieee,
1379 u8* asSta,
1380 u8 asRsn);
1381
1382
1383extern void ieee80211_tkip_null(void);
1384extern void ieee80211_wep_null(void);
1385extern void ieee80211_ccmp_null(void);
1386
1387
1388extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee,
1389 struct iw_request_info *info,
1390 union iwreq_data *wrqu, char *ext);
1391
1392extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee,
1393 struct iw_request_info *info,
1394 union iwreq_data *awrq,
1395 char *extra);
1396
1397extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b);
1398
1399extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee,
1400 struct iw_request_info *info,
1401 union iwreq_data *wrqu, char *extra);
1402
1403extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee,
1404 struct iw_request_info *info,
1405 union iwreq_data *wrqu, char *extra);
1406
1407extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
1408 union iwreq_data *wrqu, char *b);
1409
1410extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a,
1411 union iwreq_data *wrqu, char *b);
1412
1413extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee,
1414 struct iw_request_info *a,
1415 union iwreq_data *wrqu, char *extra);
1416
1417extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
1418 union iwreq_data *wrqu, char *b);
1419
1420extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
1421 union iwreq_data *wrqu, char *b);
1422
1423extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
1424 union iwreq_data *wrqu, char *b);
1425
1426extern void ieee80211_wx_sync_scan_wq(struct work_struct *work);
1427
1428extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee,
1429 struct iw_request_info *info,
1430 union iwreq_data *wrqu, char *extra);
1431
1432extern int ieee80211_wx_get_name(struct ieee80211_device *ieee,
1433 struct iw_request_info *info,
1434 union iwreq_data *wrqu, char *extra);
1435
1436extern int ieee80211_wx_set_power(struct ieee80211_device *ieee,
1437 struct iw_request_info *info,
1438 union iwreq_data *wrqu, char *extra);
1439
1440extern int ieee80211_wx_get_power(struct ieee80211_device *ieee,
1441 struct iw_request_info *info,
1442 union iwreq_data *wrqu, char *extra);
1443
1444extern void ieee80211_softmac_ips_scan_syncro(struct ieee80211_device *ieee);
1445
1446extern void ieee80211_sta_ps_send_null_frame(struct ieee80211_device *ieee, short pwr);
1447
1448extern const long ieee80211_wlan_frequencies[];
1449
1450extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee)
1451{
1452 ieee->scans++;
1453}
1454
1455extern inline int ieee80211_get_scans(struct ieee80211_device *ieee)
1456{
1457 return ieee->scans;
1458}
1459
1460static inline const char *escape_essid(const char *essid, u8 essid_len) {
1461 static char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
1462 const char *s = essid;
1463 char *d = escaped;
1464
1465 if (ieee80211_is_empty_essid(essid, essid_len)) {
1466 memcpy(escaped, "<hidden>", sizeof("<hidden>"));
1467 return escaped;
1468 }
1469
1470 essid_len = min(essid_len, (u8)IW_ESSID_MAX_SIZE);
1471 while (essid_len--) {
1472 if (*s == '\0') {
1473 *d++ = '\\';
1474 *d++ = '0';
1475 s++;
1476 } else {
1477 *d++ = *s++;
1478 }
1479 }
1480 *d = '\0';
1481 return escaped;
1482}
1483#endif
1484