2 * Merged with mainline ieee80211.h in Aug 2004. Original ieee802_11
3 * remains copyright by the original authors
5 * Portions of the merged code are based on Host AP (software wireless
6 * LAN access point) driver for Intersil Prism2/2.5/3.
8 * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
10 * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
12 * Adaption to a generic IEEE 802.11 stack by James Ketrenos
13 * <jketreno@linux.intel.com>
14 * Copyright (c) 2004, Intel Corporation
16 * Modified for Realtek's wi-fi cards by Andrea Merello
17 * <andreamrl@tiscali.it>
19 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License version 2 as
21 * published by the Free Software Foundation. See README and COPYING for
26 #include <linux/if_ether.h> /* ETH_ALEN */
27 #include <linux/kernel.h> /* ARRAY_SIZE */
28 #include <linux/version.h>
29 #include <linux/jiffies.h>
30 #include <linux/timer.h>
31 #include <linux/sched.h>
32 #include <linux/wireless.h>
48 #define KEY_TYPE_NA 0x0
49 #define KEY_TYPE_WEP40 0x1
50 #define KEY_TYPE_TKIP 0x2
51 #define KEY_TYPE_CCMP 0x4
52 #define KEY_TYPE_WEP104 0x5
56 #define MGMT_QUEUE_NUM 5
59 #define IEEE_CMD_SET_WPA_PARAM 1
60 #define IEEE_CMD_SET_WPA_IE 2
61 #define IEEE_CMD_SET_ENCRYPTION 3
62 #define IEEE_CMD_MLME 4
64 #define IEEE_PARAM_WPA_ENABLED 1
65 #define IEEE_PARAM_TKIP_COUNTERMEASURES 2
66 #define IEEE_PARAM_DROP_UNENCRYPTED 3
67 #define IEEE_PARAM_PRIVACY_INVOKED 4
68 #define IEEE_PARAM_AUTH_ALGS 5
69 #define IEEE_PARAM_IEEE_802_1X 6
70 //It should consistent with the driver_XXX.c
72 #define IEEE_PARAM_WPAX_SELECT 7
73 //Added for notify the encryption type selection
75 #define IEEE_PROTO_WPA 1
76 #define IEEE_PROTO_RSN 2
77 //Added for notify the encryption type selection
79 #define IEEE_WPAX_USEGROUP 0
80 #define IEEE_WPAX_WEP40 1
81 #define IEEE_WPAX_TKIP 2
82 #define IEEE_WPAX_WRAP 3
83 #define IEEE_WPAX_CCMP 4
84 #define IEEE_WPAX_WEP104 5
86 #define IEEE_KEY_MGMT_IEEE8021X 1
87 #define IEEE_KEY_MGMT_PSK 2
91 #define IEEE_MLME_STA_DEAUTH 1
92 #define IEEE_MLME_STA_DISASSOC 2
95 #define IEEE_CRYPT_ERR_UNKNOWN_ALG 2
96 #define IEEE_CRYPT_ERR_UNKNOWN_ADDR 3
97 #define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED 4
98 #define IEEE_CRYPT_ERR_KEY_SET_FAILED 5
99 #define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED 6
100 #define IEEE_CRYPT_ERR_CARD_CONF_FAILED 7
103 #define IEEE_CRYPT_ALG_NAME_LEN 16
106 typedef struct ieee_param {
108 u8 sta_addr[ETH_ALEN];
124 u8 alg[IEEE_CRYPT_ALG_NAME_LEN];
128 u8 seq[8]; /* sequence counter (set: RX, get: TX) */
137 #define MSECS(t) msecs_to_jiffies(t)
138 #define msleep_interruptible_rtl msleep_interruptible
140 #define IEEE80211_DATA_LEN 2304
141 /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
144 The figure in section 7.1.2 suggests a body size of up to 2312
145 bytes is allowed, which is a bit confusing, I suspect this
146 represents the 2304 bytes of real data, plus a possible 8 bytes of
147 WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
150 #define IEEE80211_HLEN 30
151 #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
153 /* this is stolen and modified from the madwifi driver*/
154 #define IEEE80211_FC0_TYPE_MASK 0x0c
155 #define IEEE80211_FC0_TYPE_DATA 0x08
156 #define IEEE80211_FC0_SUBTYPE_MASK 0xB0
157 #define IEEE80211_FC0_SUBTYPE_QOS 0x80
159 #define IEEE80211_QOS_HAS_SEQ(fc) \
160 (((fc) & (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK)) == \
161 (IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_QOS))
163 /* this is stolen from ipw2200 driver */
164 #define IEEE_IBSS_MAC_HASH_SIZE 31
165 struct ieee_ibss_seq {
169 unsigned long packet_time[17];
170 struct list_head list;
173 struct ieee80211_hdr {
181 } __attribute__ ((packed));
183 struct ieee80211_hdr_QOS {
192 } __attribute__ ((packed));
194 struct ieee80211_hdr_3addr {
201 } __attribute__ ((packed));
203 struct ieee80211_hdr_3addr_QOS {
211 } __attribute__ ((packed));
218 EAPOL_ENCAP_ASF_ALERT
221 static const char *eap_types[] = {
222 [EAP_PACKET] = "EAP-Packet",
223 [EAPOL_START] = "EAPOL-Start",
224 [EAPOL_LOGOFF] = "EAPOL-Logoff",
225 [EAPOL_KEY] = "EAPOL-Key",
226 [EAPOL_ENCAP_ASF_ALERT] = "EAPOL-Encap-ASF-Alert"
229 static inline const char *eap_get_type(int type)
231 return (type >= ARRAY_SIZE(eap_types)) ? "Unknown" : eap_types[type];
240 } __attribute__ ((packed));
242 #define IEEE80211_3ADDR_LEN 24
243 #define IEEE80211_4ADDR_LEN 30
244 #define IEEE80211_FCS_LEN 4
246 #define MIN_FRAG_THRESHOLD 256U
247 #define MAX_FRAG_THRESHOLD 2346U
249 /* Frame control field constants */
250 #define IEEE80211_FCTL_VERS 0x0002
251 #define IEEE80211_FCTL_FTYPE 0x000c
252 #define IEEE80211_FCTL_STYPE 0x00f0
253 #define IEEE80211_FCTL_TODS 0x0100
254 #define IEEE80211_FCTL_FROMDS 0x0200
255 #define IEEE80211_FCTL_DSTODS 0x0300 //added by david
256 #define IEEE80211_FCTL_MOREFRAGS 0x0400
257 #define IEEE80211_FCTL_RETRY 0x0800
258 #define IEEE80211_FCTL_PM 0x1000
259 #define IEEE80211_FCTL_MOREDATA 0x2000
260 #define IEEE80211_FCTL_WEP 0x4000
261 #define IEEE80211_FCTL_ORDER 0x8000
263 #define IEEE80211_FTYPE_MGMT 0x0000
264 #define IEEE80211_FTYPE_CTL 0x0004
265 #define IEEE80211_FTYPE_DATA 0x0008
268 #define IEEE80211_STYPE_ASSOC_REQ 0x0000
269 #define IEEE80211_STYPE_ASSOC_RESP 0x0010
270 #define IEEE80211_STYPE_REASSOC_REQ 0x0020
271 #define IEEE80211_STYPE_REASSOC_RESP 0x0030
272 #define IEEE80211_STYPE_PROBE_REQ 0x0040
273 #define IEEE80211_STYPE_PROBE_RESP 0x0050
274 #define IEEE80211_STYPE_BEACON 0x0080
275 #define IEEE80211_STYPE_ATIM 0x0090
276 #define IEEE80211_STYPE_DISASSOC 0x00A0
277 #define IEEE80211_STYPE_AUTH 0x00B0
278 #define IEEE80211_STYPE_DEAUTH 0x00C0
279 #define IEEE80211_STYPE_MANAGE_ACT 0x00D0
282 #define IEEE80211_STYPE_PSPOLL 0x00A0
283 #define IEEE80211_STYPE_RTS 0x00B0
284 #define IEEE80211_STYPE_CTS 0x00C0
285 #define IEEE80211_STYPE_ACK 0x00D0
286 #define IEEE80211_STYPE_CFEND 0x00E0
287 #define IEEE80211_STYPE_CFENDACK 0x00F0
290 #define IEEE80211_STYPE_DATA 0x0000
291 #define IEEE80211_STYPE_DATA_CFACK 0x0010
292 #define IEEE80211_STYPE_DATA_CFPOLL 0x0020
293 #define IEEE80211_STYPE_DATA_CFACKPOLL 0x0030
294 #define IEEE80211_STYPE_NULLFUNC 0x0040
295 #define IEEE80211_STYPE_CFACK 0x0050
296 #define IEEE80211_STYPE_CFPOLL 0x0060
297 #define IEEE80211_STYPE_CFACKPOLL 0x0070
298 #define IEEE80211_STYPE_QOS_DATA 0x0080 //added for WMM 2006/8/2
299 #define IEEE80211_STYPE_QOS_NULL 0x00C0
302 #define IEEE80211_SCTL_FRAG 0x000F
303 #define IEEE80211_SCTL_SEQ 0xFFF0
308 #ifdef CONFIG_IEEE80211_DEBUG
309 extern u32 ieee80211_debug_level;
310 #define IEEE80211_DEBUG(level, fmt, args...) \
311 do { if (ieee80211_debug_level & (level)) \
312 printk(KERN_DEBUG "ieee80211: %c %s " fmt, \
313 in_interrupt() ? 'I' : 'U', __func__ , ## args); } while (0)
315 #define IEEE80211_DEBUG(level, fmt, args...) do {} while (0)
316 #endif /* CONFIG_IEEE80211_DEBUG */
319 * To use the debug system;
321 * If you are defining a new debug classification, simply add it to the #define
322 * list here in the form of:
324 * #define IEEE80211_DL_xxxx VALUE
326 * shifting value to the left one bit from the previous entry. xxxx should be
327 * the name of the classification (for example, WEP)
329 * You then need to either add a IEEE80211_xxxx_DEBUG() macro definition for your
330 * classification, or use IEEE80211_DEBUG(IEEE80211_DL_xxxx, ...) whenever you want
331 * to send output to that classification.
333 * To add your debug level to the list of levels seen when you perform
335 * % cat /proc/net/ipw/debug_level
337 * you simply need to add your entry to the ipw_debug_levels array.
339 * If you do not see debug_level in /proc/net/ipw then you do not have
340 * CONFIG_IEEE80211_DEBUG defined in your kernel configuration
344 #define IEEE80211_DL_INFO (1<<0)
345 #define IEEE80211_DL_WX (1<<1)
346 #define IEEE80211_DL_SCAN (1<<2)
347 #define IEEE80211_DL_STATE (1<<3)
348 #define IEEE80211_DL_MGMT (1<<4)
349 #define IEEE80211_DL_FRAG (1<<5)
350 #define IEEE80211_DL_EAP (1<<6)
351 #define IEEE80211_DL_DROP (1<<7)
353 #define IEEE80211_DL_TX (1<<8)
354 #define IEEE80211_DL_RX (1<<9)
356 #define IEEE80211_ERROR(f, a...) printk(KERN_ERR "ieee80211: " f, ## a)
357 #define IEEE80211_WARNING(f, a...) printk(KERN_WARNING "ieee80211: " f, ## a)
358 #define IEEE80211_DEBUG_INFO(f, a...) IEEE80211_DEBUG(IEEE80211_DL_INFO, f, ## a)
360 #define IEEE80211_DEBUG_WX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_WX, f, ## a)
361 #define IEEE80211_DEBUG_SCAN(f, a...) IEEE80211_DEBUG(IEEE80211_DL_SCAN, f, ## a)
362 //#define IEEE_DEBUG_SCAN IEEE80211_WARNING
363 #define IEEE80211_DEBUG_STATE(f, a...) IEEE80211_DEBUG(IEEE80211_DL_STATE, f, ## a)
364 #define IEEE80211_DEBUG_MGMT(f, a...) IEEE80211_DEBUG(IEEE80211_DL_MGMT, f, ## a)
365 #define IEEE80211_DEBUG_FRAG(f, a...) IEEE80211_DEBUG(IEEE80211_DL_FRAG, f, ## a)
366 #define IEEE80211_DEBUG_EAP(f, a...) IEEE80211_DEBUG(IEEE80211_DL_EAP, f, ## a)
367 #define IEEE80211_DEBUG_DROP(f, a...) IEEE80211_DEBUG(IEEE80211_DL_DROP, f, ## a)
368 #define IEEE80211_DEBUG_TX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_TX, f, ## a)
369 #define IEEE80211_DEBUG_RX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_RX, f, ## a)
370 #include <linux/netdevice.h>
371 #include <linux/wireless.h>
372 #include <linux/if_arp.h> /* ARPHRD_ETHER */
375 #define WIRELESS_SPY // enable iwspy support
377 #include <net/iw_handler.h> // new driver API
380 #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
381 #endif /* ETH_P_PAE */
383 #define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
385 #ifndef ETH_P_80211_RAW
386 #define ETH_P_80211_RAW (ETH_P_ECONET + 1)
389 /* IEEE 802.11 defines */
391 #define P80211_OUI_LEN 3
393 struct ieee80211_snap_hdr {
395 u8 dsap; /* always 0xAA */
396 u8 ssap; /* always 0xAA */
397 u8 ctrl; /* always 0x03 */
398 u8 oui[P80211_OUI_LEN]; /* organizational universal id */
400 } __attribute__ ((packed));
402 #define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
404 #define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE)
405 #define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE)
407 #define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG)
408 #define WLAN_GET_SEQ_SEQ(seq) ((seq) & IEEE80211_SCTL_SEQ)
410 /* Authentication algorithms */
411 #define WLAN_AUTH_OPEN 0
412 #define WLAN_AUTH_SHARED_KEY 1
414 #define WLAN_AUTH_CHALLENGE_LEN 128
416 #define WLAN_CAPABILITY_BSS (1<<0)
417 #define WLAN_CAPABILITY_IBSS (1<<1)
418 #define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
419 #define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
420 #define WLAN_CAPABILITY_PRIVACY (1<<4)
421 #define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
422 #define WLAN_CAPABILITY_PBCC (1<<6)
423 #define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
424 #define WLAN_CAPABILITY_SHORT_SLOT (1<<10)
427 #define WLAN_STATUS_SUCCESS 0
428 #define WLAN_STATUS_UNSPECIFIED_FAILURE 1
429 #define WLAN_STATUS_CAPS_UNSUPPORTED 10
430 #define WLAN_STATUS_REASSOC_NO_ASSOC 11
431 #define WLAN_STATUS_ASSOC_DENIED_UNSPEC 12
432 #define WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG 13
433 #define WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION 14
434 #define WLAN_STATUS_CHALLENGE_FAIL 15
435 #define WLAN_STATUS_AUTH_TIMEOUT 16
436 #define WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA 17
437 #define WLAN_STATUS_ASSOC_DENIED_RATES 18
439 #define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19
440 #define WLAN_STATUS_ASSOC_DENIED_NOPBCC 20
441 #define WLAN_STATUS_ASSOC_DENIED_NOAGILITY 21
444 #define WLAN_REASON_UNSPECIFIED 1
445 #define WLAN_REASON_PREV_AUTH_NOT_VALID 2
446 #define WLAN_REASON_DEAUTH_LEAVING 3
447 #define WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY 4
448 #define WLAN_REASON_DISASSOC_AP_BUSY 5
449 #define WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA 6
450 #define WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA 7
451 #define WLAN_REASON_DISASSOC_STA_HAS_LEFT 8
452 #define WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH 9
455 /* Information Element IDs */
456 #define WLAN_EID_SSID 0
457 #define WLAN_EID_SUPP_RATES 1
458 #define WLAN_EID_FH_PARAMS 2
459 #define WLAN_EID_DS_PARAMS 3
460 #define WLAN_EID_CF_PARAMS 4
461 #define WLAN_EID_TIM 5
462 #define WLAN_EID_IBSS_PARAMS 6
463 #define WLAN_EID_CHALLENGE 16
464 #define WLAN_EID_RSN 48
465 #define WLAN_EID_GENERIC 221
467 #define IEEE80211_MGMT_HDR_LEN 24
468 #define IEEE80211_DATA_HDR3_LEN 24
469 #define IEEE80211_DATA_HDR4_LEN 30
472 #define IEEE80211_STATMASK_SIGNAL (1<<0)
473 #define IEEE80211_STATMASK_RSSI (1<<1)
474 #define IEEE80211_STATMASK_NOISE (1<<2)
475 #define IEEE80211_STATMASK_RATE (1<<3)
476 #define IEEE80211_STATMASK_WEMASK 0x7
479 #define IEEE80211_CCK_MODULATION (1<<0)
480 #define IEEE80211_OFDM_MODULATION (1<<1)
482 #define IEEE80211_24GHZ_BAND (1<<0)
483 #define IEEE80211_52GHZ_BAND (1<<1)
485 #define IEEE80211_CCK_RATE_LEN 4
486 #define IEEE80211_CCK_RATE_1MB 0x02
487 #define IEEE80211_CCK_RATE_2MB 0x04
488 #define IEEE80211_CCK_RATE_5MB 0x0B
489 #define IEEE80211_CCK_RATE_11MB 0x16
490 #define IEEE80211_OFDM_RATE_LEN 8
491 #define IEEE80211_OFDM_RATE_6MB 0x0C
492 #define IEEE80211_OFDM_RATE_9MB 0x12
493 #define IEEE80211_OFDM_RATE_12MB 0x18
494 #define IEEE80211_OFDM_RATE_18MB 0x24
495 #define IEEE80211_OFDM_RATE_24MB 0x30
496 #define IEEE80211_OFDM_RATE_36MB 0x48
497 #define IEEE80211_OFDM_RATE_48MB 0x60
498 #define IEEE80211_OFDM_RATE_54MB 0x6C
499 #define IEEE80211_BASIC_RATE_MASK 0x80
501 #define IEEE80211_CCK_RATE_1MB_MASK (1<<0)
502 #define IEEE80211_CCK_RATE_2MB_MASK (1<<1)
503 #define IEEE80211_CCK_RATE_5MB_MASK (1<<2)
504 #define IEEE80211_CCK_RATE_11MB_MASK (1<<3)
505 #define IEEE80211_OFDM_RATE_6MB_MASK (1<<4)
506 #define IEEE80211_OFDM_RATE_9MB_MASK (1<<5)
507 #define IEEE80211_OFDM_RATE_12MB_MASK (1<<6)
508 #define IEEE80211_OFDM_RATE_18MB_MASK (1<<7)
509 #define IEEE80211_OFDM_RATE_24MB_MASK (1<<8)
510 #define IEEE80211_OFDM_RATE_36MB_MASK (1<<9)
511 #define IEEE80211_OFDM_RATE_48MB_MASK (1<<10)
512 #define IEEE80211_OFDM_RATE_54MB_MASK (1<<11)
514 #define IEEE80211_CCK_RATES_MASK 0x0000000F
515 #define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \
516 IEEE80211_CCK_RATE_2MB_MASK)
517 #define IEEE80211_CCK_DEFAULT_RATES_MASK (IEEE80211_CCK_BASIC_RATES_MASK | \
518 IEEE80211_CCK_RATE_5MB_MASK | \
519 IEEE80211_CCK_RATE_11MB_MASK)
521 #define IEEE80211_OFDM_RATES_MASK 0x00000FF0
522 #define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \
523 IEEE80211_OFDM_RATE_12MB_MASK | \
524 IEEE80211_OFDM_RATE_24MB_MASK)
525 #define IEEE80211_OFDM_DEFAULT_RATES_MASK (IEEE80211_OFDM_BASIC_RATES_MASK | \
526 IEEE80211_OFDM_RATE_9MB_MASK | \
527 IEEE80211_OFDM_RATE_18MB_MASK | \
528 IEEE80211_OFDM_RATE_36MB_MASK | \
529 IEEE80211_OFDM_RATE_48MB_MASK | \
530 IEEE80211_OFDM_RATE_54MB_MASK)
531 #define IEEE80211_DEFAULT_RATES_MASK (IEEE80211_OFDM_DEFAULT_RATES_MASK | \
532 IEEE80211_CCK_DEFAULT_RATES_MASK)
534 #define IEEE80211_NUM_OFDM_RATES 8
535 #define IEEE80211_NUM_CCK_RATES 4
536 #define IEEE80211_OFDM_SHIFT_MASK_A 4
541 /* NOTE: This data is for statistical purposes; not all hardware provides this
542 * information for frames received. Not setting these will not cause
543 * any adverse affects. */
544 struct ieee80211_rx_stats {
550 u16 rate; /* in 100 kbps */
559 /* IEEE 802.11 requires that STA supports concurrent reception of at least
560 * three fragmented frames. This define can be increased to support more
561 * concurrent frames, but it should be noted that each entry can consume about
562 * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
563 #define IEEE80211_FRAG_CACHE_LEN 4
565 struct ieee80211_frag_entry {
566 unsigned long first_frag_time;
568 unsigned int last_frag;
570 u8 src_addr[ETH_ALEN];
571 u8 dst_addr[ETH_ALEN];
574 struct ieee80211_stats {
575 unsigned int tx_unicast_frames;
576 unsigned int tx_multicast_frames;
577 unsigned int tx_fragments;
578 unsigned int tx_unicast_octets;
579 unsigned int tx_multicast_octets;
580 unsigned int tx_deferred_transmissions;
581 unsigned int tx_single_retry_frames;
582 unsigned int tx_multiple_retry_frames;
583 unsigned int tx_retry_limit_exceeded;
584 unsigned int tx_discards;
585 unsigned int rx_unicast_frames;
586 unsigned int rx_multicast_frames;
587 unsigned int rx_fragments;
588 unsigned int rx_unicast_octets;
589 unsigned int rx_multicast_octets;
590 unsigned int rx_fcs_errors;
591 unsigned int rx_discards_no_buffer;
592 unsigned int tx_discards_wrong_sa;
593 unsigned int rx_discards_undecryptable;
594 unsigned int rx_message_in_msg_fragments;
595 unsigned int rx_message_in_bad_msg_fragments;
598 struct ieee80211_softmac_stats{
599 unsigned int rx_ass_ok;
600 unsigned int rx_ass_err;
601 unsigned int rx_probe_rq;
602 unsigned int tx_probe_rs;
603 unsigned int tx_beacons;
604 unsigned int rx_auth_rq;
605 unsigned int rx_auth_rs_ok;
606 unsigned int rx_auth_rs_err;
607 unsigned int tx_auth_rq;
608 unsigned int no_auth_rs;
609 unsigned int no_ass_rs;
610 unsigned int tx_ass_rq;
611 unsigned int rx_ass_rq;
612 unsigned int tx_probe_rq;
613 unsigned int reassoc;
614 unsigned int swtxstop;
615 unsigned int swtxawake;
618 struct ieee80211_device;
620 #include "ieee80211_crypt.h"
622 #define SEC_KEY_1 (1<<0)
623 #define SEC_KEY_2 (1<<1)
624 #define SEC_KEY_3 (1<<2)
625 #define SEC_KEY_4 (1<<3)
626 #define SEC_ACTIVE_KEY (1<<4)
627 #define SEC_AUTH_MODE (1<<5)
628 #define SEC_UNICAST_GROUP (1<<6)
629 #define SEC_LEVEL (1<<7)
630 #define SEC_ENABLED (1<<8)
632 #define SEC_LEVEL_0 0 /* None */
633 #define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */
634 #define SEC_LEVEL_2 2 /* Level 1 + TKIP */
635 #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
636 #define SEC_LEVEL_3 4 /* Level 2 + CCMP */
639 #define WEP_KEY_LEN 13
641 #define WEP_KEY_LEN_MODIF 32
643 struct ieee80211_security {
648 unicast_uses_group:1;
649 u8 key_sizes[WEP_KEYS];
650 u8 keys[WEP_KEYS][WEP_KEY_LEN_MODIF];
653 } __attribute__ ((packed));
658 802.11 data frame from AP
660 ,-------------------------------------------------------------------.
661 Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
662 |------|------|---------|---------|---------|------|---------|------|
663 Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs |
664 | | tion | (BSSID) | | | ence | data | |
665 `-------------------------------------------------------------------'
671 struct ieee80211_header_data {
680 #define BEACON_PROBE_SSID_ID_POSITION 12
682 /* Management Frame Information Element Types */
683 #define MFIE_TYPE_SSID 0
684 #define MFIE_TYPE_RATES 1
685 #define MFIE_TYPE_FH_SET 2
686 #define MFIE_TYPE_DS_SET 3
687 #define MFIE_TYPE_CF_SET 4
688 #define MFIE_TYPE_TIM 5
689 #define MFIE_TYPE_IBSS_SET 6
690 #define MFIE_TYPE_COUNTRY 7 //+YJ,080625
691 #define MFIE_TYPE_CHALLENGE 16
692 #define MFIE_TYPE_ERP 42
693 #define MFIE_TYPE_RSN 48
694 #define MFIE_TYPE_RATES_EX 50
695 #define MFIE_TYPE_GENERIC 221
699 COUNTRY_CODE_FCC = 0,
701 COUNTRY_CODE_ETSI = 2,
702 COUNTRY_CODE_SPAIN = 3,
703 COUNTRY_CODE_FRANCE = 4,
704 COUNTRY_CODE_MKK = 5,
705 COUNTRY_CODE_MKK1 = 6,
706 COUNTRY_CODE_ISRAEL = 7,
707 COUNTRY_CODE_TELEC = 8,
708 COUNTRY_CODE_GLOBAL_DOMAIN = 9,
709 COUNTRY_CODE_WORLD_WIDE_13_INDEX = 10
710 }country_code_type_t;
712 struct ieee80211_info_element_hdr {
715 } __attribute__ ((packed));
717 struct ieee80211_info_element {
721 } __attribute__ ((packed));
724 * These are the data types that can make up management packets
730 u8 current_ap[ETH_ALEN];
733 u16 association_id:14, reserved:2;
734 } __attribute__ ((packed));
740 #define IEEE80211_DEFAULT_TX_ESSID "Penguin"
741 #define IEEE80211_DEFAULT_BASIC_RATE 10
743 struct ieee80211_authentication {
744 struct ieee80211_header_data header;
748 //struct ieee80211_info_element_hdr info_element;
749 } __attribute__ ((packed));
752 struct ieee80211_probe_response {
753 struct ieee80211_header_data header;
757 struct ieee80211_info_element info_element;
758 } __attribute__ ((packed));
760 struct ieee80211_probe_request {
761 struct ieee80211_header_data header;
762 /*struct ieee80211_info_element info_element;*/
763 } __attribute__ ((packed));
765 struct ieee80211_assoc_request_frame {
766 struct ieee80211_hdr_3addr header;
769 //u8 current_ap[ETH_ALEN];
770 struct ieee80211_info_element_hdr info_element;
771 } __attribute__ ((packed));
773 struct ieee80211_assoc_response_frame {
774 struct ieee80211_hdr_3addr header;
778 struct ieee80211_info_element info_element; /* supported rates */
779 } __attribute__ ((packed));
781 struct ieee80211_disassoc_frame{
782 struct ieee80211_hdr_3addr header;
784 }__attribute__ ((packed));
786 struct ieee80211_txb {
792 struct sk_buff *fragments[0];
795 struct ieee80211_wmm_ac_param {
801 struct ieee80211_wmm_ts_info {
805 } __attribute__ ((packed));
807 struct ieee80211_wmm_tspec_elem {
808 struct ieee80211_wmm_ts_info ts_info;
824 }__attribute__((packed));
826 enum {WMM_all_frame, WMM_two_frame, WMM_four_frame, WMM_six_frame};
827 #define MAX_SP_Len (WMM_all_frame << 4)
828 #define IEEE80211_QOS_TID 0x0f
829 #define QOS_CTL_NOTCONTAIN_ACK (0x01 << 5)
831 /* SWEEP TABLE ENTRIES NUMBER*/
832 #define MAX_SWEEP_TAB_ENTRIES 42
833 #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
834 /* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs
835 * only use 8, and then use extended rates for the remaining supported
836 * rates. Other APs, however, stick all of their supported rates on the
837 * main rates information element... */
838 #define MAX_RATES_LENGTH ((u8)12)
839 #define MAX_RATES_EX_LENGTH ((u8)16)
840 #define MAX_NETWORK_COUNT 128
841 //#define MAX_CHANNEL_NUMBER 161
842 #define MAX_CHANNEL_NUMBER 165 //YJ,modified,080625
843 #define MAX_IE_LEN 0xFF //+YJ,080625
845 typedef struct _CHANNEL_LIST{
846 u8 Channel[MAX_CHANNEL_NUMBER + 1];
848 }CHANNEL_LIST, *PCHANNEL_LIST;
850 #define IEEE80211_SOFTMAC_SCAN_TIME 100//400
853 #define IEEE80211_WATCH_DOG_TIME 2000
856 #define ANTENNA_DIVERSITY_TIMER_PERIOD 1000 // 1000 m
858 #define IEEE80211_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2)
860 #define CRC_LENGTH 4U
862 #define MAX_WPA_IE_LEN 64
864 #define NETWORK_EMPTY_ESSID (1<<0)
865 #define NETWORK_HAS_OFDM (1<<1)
866 #define NETWORK_HAS_CCK (1<<2)
868 #define IEEE80211_DTIM_MBCAST 4
869 #define IEEE80211_DTIM_UCAST 2
870 #define IEEE80211_DTIM_VALID 1
871 #define IEEE80211_DTIM_INVALID 0
873 #define IEEE80211_PS_DISABLED 0
874 #define IEEE80211_PS_UNICAST IEEE80211_DTIM_UCAST
875 #define IEEE80211_PS_MBCAST IEEE80211_DTIM_MBCAST
876 #define IEEE80211_PS_ENABLE IEEE80211_DTIM_VALID
877 //added by David for QoS 2006/6/30
878 //#define WMM_Hang_8187
883 #define WME_AC_BE 0x00
884 #define WME_AC_BK 0x01
885 #define WME_AC_VI 0x02
886 #define WME_AC_VO 0x03
887 #define WME_ACI_MASK 0x03
888 #define WME_AIFSN_MASK 0x03
889 #define WME_AC_PRAM_LEN 16
891 //UP Mapping to AC, using in MgntQuery_SequenceNumber() and maybe for DSCP
892 //#define UP2AC(up) ((up<3) ? ((up==0)?1:0) : (up>>1))
893 #define UP2AC(up) ( \
894 ((up) < 1) ? WME_AC_BE : \
895 ((up) < 3) ? WME_AC_BK : \
896 ((up) < 4) ? WME_AC_BE : \
897 ((up) < 6) ? WME_AC_VI : \
899 //AC Mapping to UP, using in Tx part for selecting the corresponding TX queue
900 #define AC2UP(_ac) ( \
901 ((_ac) == WME_AC_VO) ? 6 : \
902 ((_ac) == WME_AC_VI) ? 5 : \
903 ((_ac) == WME_AC_BK) ? 1 : \
906 #define ETHER_ADDR_LEN 6 /* length of an Ethernet address */
907 struct ether_header {
908 u8 ether_dhost[ETHER_ADDR_LEN];
909 u8 ether_shost[ETHER_ADDR_LEN];
911 } __attribute__((packed));
913 #ifndef ETHERTYPE_PAE
914 #define ETHERTYPE_PAE 0x888e /* EAPOL PAE/802.1x */
917 #define ETHERTYPE_IP 0x0800 /* IP protocol */
920 struct ieee80211_network {
921 /* These entries are used to identify a unique network */
924 /* Ensure null-terminated for any debug msgs */
925 u8 ssid[IW_ESSID_MAX_SIZE + 1];
928 /* These are network statistics */
929 struct ieee80211_rx_stats stats;
931 u8 rates[MAX_RATES_LENGTH];
933 u8 rates_ex[MAX_RATES_EX_LENGTH];
935 unsigned long last_scanned;
943 u8 wpa_ie[MAX_WPA_IE_LEN];
945 u8 rsn_ie[MAX_WPA_IE_LEN];
949 u32 last_dtim_sta_time[2];
950 struct list_head list;
953 struct ieee80211_wmm_ac_param wmm_param[4];
959 u8 Turbo_Enable;//enable turbo mode, added by thomas
961 u8 CountryIeBuf[MAX_IE_LEN];
964 enum ieee80211_state {
966 /* the card is not linked at all */
967 IEEE80211_NOLINK = 0,
969 /* IEEE80211_ASSOCIATING* are for BSS client mode
970 * the driver shall not perform RX filtering unless
971 * the state is LINKED.
972 * The driver shall just check for the state LINKED and
973 * defaults to NOLINK for ALL the other states (including
977 /* the association procedure will start (wq scheduling)*/
978 IEEE80211_ASSOCIATING,
979 IEEE80211_ASSOCIATING_RETRY,
981 /* the association procedure is sending AUTH request*/
982 IEEE80211_ASSOCIATING_AUTHENTICATING,
984 /* the association procedure has successfully authentcated
985 * and is sending association request
987 IEEE80211_ASSOCIATING_AUTHENTICATED,
989 /* the link is ok. the card associated to a BSS or linked
990 * to a ibss cell or acting as an AP and creating the bss
994 /* same as LINKED, but the driver shall apply RX filter
995 * rules as we are in NO_LINK mode. As the card is still
996 * logically linked, but it is doing a syncro site survey
997 * then it will be back to LINKED state.
999 IEEE80211_LINKED_SCANNING,
1003 #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
1004 #define DEFAULT_FTS 2346
1005 #define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
1006 #define MAC_ARG(x) ((u8*)(x))[0],((u8*)(x))[1],((u8*)(x))[2],((u8*)(x))[3],((u8*)(x))[4],((u8*)(x))[5]
1008 #define CFG_IEEE80211_RESERVE_FCS (1<<0)
1009 #define CFG_IEEE80211_COMPUTE_FCS (1<<1)
1011 typedef struct tx_pending_t{
1013 struct ieee80211_txb *txb;
1017 struct ieee80211_device {
1018 struct net_device *dev;
1020 /* Bookkeeping structures */
1021 struct net_device_stats stats;
1022 struct ieee80211_stats ieee_stats;
1023 struct ieee80211_softmac_stats softmac_stats;
1025 /* Probe / Beacon management */
1026 struct list_head network_free_list;
1027 struct list_head network_list;
1028 struct ieee80211_network *networks;
1032 int iw_mode; /* operating mode (IW_MODE_*) */
1035 spinlock_t wpax_suitlist_lock;
1037 int tx_headroom; /* Set to size of any additional room needed at front
1038 * of allocated Tx SKBs */
1041 /* WEP and other encryption related settings at the device level */
1042 int open_wep; /* Set to 1 to allow unencrypted frames */
1044 int reset_on_keychange; /* Set to 1 if the HW needs to be reset on
1045 * WEP key changes */
1047 /* If the host performs {en,de}cryption, then set to 1 */
1050 int ieee802_1x; /* is IEEE 802.1X used */
1054 int drop_unencrypted;
1055 int tkip_countermeasures;
1056 int privacy_invoked;
1061 u16 pairwise_key_type;
1062 u16 broadcast_key_type;
1064 struct list_head crypt_deinit_list;
1065 struct ieee80211_crypt_data *crypt[WEP_KEYS];
1066 int tx_keyidx; /* default TX key index (crypt[tx_keyidx]) */
1067 struct timer_list crypt_deinit_timer;
1069 int bcrx_sta_key; /* use individual keys to override default keys even
1070 * with RX of broad/multicast frames */
1072 /* Fragmentation structures */
1073 // each streaming contain a entry
1074 struct ieee80211_frag_entry frag_cache[17][IEEE80211_FRAG_CACHE_LEN];
1075 unsigned int frag_next_idx[17];
1076 u16 fts; /* Fragmentation Threshold */
1078 /* This stores infos for the current network.
1079 * Either the network we are associated in INFRASTRUCTURE
1080 * or the network that we are creating in MASTER mode.
1081 * ad-hoc is a mixture ;-).
1082 * Note that in infrastructure mode, even when not associated,
1083 * fields bssid and essid may be valid (if wpa_set and essid_set
1084 * are true) as thy carry the value set by the user via iwconfig
1086 struct ieee80211_network current_network;
1089 enum ieee80211_state state;
1092 int mode; /* A, B, G */
1093 int modulation; /* CCK, OFDM */
1094 int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */
1095 int abg_true; /* ABG flag */
1097 /* used for forcing the ibss workqueue to terminate
1098 * without wait for the syncro scan to terminate
1100 short sync_scan_hurryup;
1105 // For Liteon Ch12~13 passive scan
1106 u8 MinPassiveChnlNum;
1109 int rate; /* current rate */
1111 //FIXME: pleace callback, see if redundant with softmac_features
1114 /* this contains flags for selectively enable softmac support */
1115 u16 softmac_features;
1117 /* if the sequence control field is not filled by HW */
1120 /* association procedure transaction sequence number */
1123 /* AID for RTXed association responses */
1126 /* power save mode related*/
1130 struct tasklet_struct ps_task;
1135 /* used if IEEE_SOFTMAC_TX_QUEUE is set */
1138 short proto_started;
1140 struct semaphore wx_sem;
1141 struct semaphore scan_sem;
1143 spinlock_t mgmt_tx_lock;
1144 spinlock_t beacon_lock;
1151 u8 wpax_type_set; //{added by David, 2006.9.28}
1152 u32 wpax_type_notify; //{added by David, 2006.9.26}
1154 /* QoS related flag */
1155 char init_wmmparam_flag;
1157 /* for discarding duplicated packets in IBSS */
1158 struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE];
1160 /* for discarding duplicated packets in BSS */
1161 u16 last_rxseq_num[17]; /* rx seq previous per-tid */
1162 u16 last_rxfrag_num[17];/* tx frag previous per-tid */
1163 unsigned long last_packet_time[17];
1166 unsigned long last_rx_ps_time;
1168 /* used if IEEE_SOFTMAC_SINGLE_QUEUE is set */
1169 struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM];
1170 int mgmt_queue_head;
1171 int mgmt_queue_tail;
1174 /* used if IEEE_SOFTMAC_TX_QUEUE is set */
1175 struct tx_pending_t tx_pending;
1177 /* used if IEEE_SOFTMAC_ASSOCIATE is set */
1178 struct timer_list associate_timer;
1180 /* used if IEEE_SOFTMAC_BEACONS is set */
1181 struct timer_list beacon_timer;
1183 struct work_struct associate_complete_wq;
1184 // struct work_struct associate_retry_wq;
1185 struct work_struct associate_procedure_wq;
1186 // struct work_struct softmac_scan_wq;
1187 struct work_struct wx_sync_scan_wq;
1188 struct work_struct wmm_param_update_wq;
1189 struct work_struct ps_request_tx_ack_wq;//for ps
1190 // struct work_struct hw_wakeup_wq;
1191 // struct work_struct hw_sleep_wq;
1192 // struct work_struct watch_dog_wq;
1197 unsigned long NumRxDataInPeriod; //YJ,add,080828
1198 unsigned long NumRxBcnInPeriod; //YJ,add,080828
1199 unsigned long NumRxOkTotal;
1200 unsigned long NumRxUnicast;//YJ,add,080828,for keep alive
1202 struct delayed_work softmac_scan_wq;
1203 struct delayed_work associate_retry_wq;
1204 struct delayed_work hw_wakeup_wq;
1205 struct delayed_work hw_sleep_wq;//+by amy 080324
1206 struct delayed_work watch_dog_wq;
1207 struct delayed_work sw_antenna_wq;
1208 struct delayed_work start_ibss_wq;
1209 //by amy for rate adaptive 080312
1210 struct delayed_work rate_adapter_wq;
1211 //by amy for rate adaptive
1212 struct delayed_work hw_dig_wq;
1213 struct delayed_work tx_pw_wq;
1215 //Added for RF power on power off by lizhaoming 080512
1216 struct delayed_work GPIOChangeRFWorkItem;
1218 struct workqueue_struct *wq;
1220 /* Callback functions */
1221 void (*set_security)(struct net_device *dev,
1222 struct ieee80211_security *sec);
1224 /* Used to TX data frame by using txb structs.
1225 * this is not used if in the softmac_features
1226 * is set the flag IEEE_SOFTMAC_TX_QUEUE
1228 int (*hard_start_xmit)(struct ieee80211_txb *txb,
1229 struct net_device *dev);
1231 int (*reset_port)(struct net_device *dev);
1233 /* Softmac-generated frames (mamagement) are TXed via this
1234 * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is
1235 * not set. As some cards may have different HW queues that
1236 * one might want to use for data and management frames
1237 * the option to have two callbacks might be useful.
1238 * This fucntion can't sleep.
1240 int (*softmac_hard_start_xmit)(struct sk_buff *skb,
1241 struct net_device *dev);
1243 /* used instead of hard_start_xmit (not softmac_hard_start_xmit)
1244 * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data
1245 * frames. I the option IEEE_SOFTMAC_SINGLE_QUEUE is also set
1246 * then also management frames are sent via this callback.
1247 * This function can't sleep.
1249 void (*softmac_data_hard_start_xmit)(struct sk_buff *skb,
1250 struct net_device *dev,int rate);
1252 /* stops the HW queue for DATA frames. Useful to avoid
1253 * waste time to TX data frame when we are reassociating
1254 * This function can sleep.
1256 void (*data_hard_stop)(struct net_device *dev);
1258 /* OK this is complementar to data_poll_hard_stop */
1259 void (*data_hard_resume)(struct net_device *dev);
1261 /* ask to the driver to retune the radio .
1262 * This function can sleep. the driver should ensure
1263 * the radio has been swithced before return.
1265 void (*set_chan)(struct net_device *dev,short ch);
1267 /* These are not used if the ieee stack takes care of
1268 * scanning (IEEE_SOFTMAC_SCAN feature set).
1269 * In this case only the set_chan is used.
1271 * The syncro version is similar to the start_scan but
1272 * does not return until all channels has been scanned.
1273 * this is called in user context and should sleep,
1274 * it is called in a work_queue when swithcing to ad-hoc mode
1275 * or in behalf of iwlist scan when the card is associated
1276 * and root user ask for a scan.
1277 * the fucntion stop_scan should stop both the syncro and
1278 * background scanning and can sleep.
1279 * The fucntion start_scan should initiate the background
1280 * scanning and can't sleep.
1282 void (*scan_syncro)(struct net_device *dev);
1283 void (*start_scan)(struct net_device *dev);
1284 void (*stop_scan)(struct net_device *dev);
1286 /* indicate the driver that the link state is changed
1287 * for example it may indicate the card is associated now.
1288 * Driver might be interested in this to apply RX filter
1289 * rules or simply light the LINK led
1291 void (*link_change)(struct net_device *dev);
1293 /* these two function indicates to the HW when to start
1294 * and stop to send beacons. This is used when the
1295 * IEEE_SOFTMAC_BEACONS is not set. For now the
1296 * stop_send_bacons is NOT guaranteed to be called only
1297 * after start_send_beacons.
1299 void (*start_send_beacons) (struct net_device *dev);
1300 void (*stop_send_beacons) (struct net_device *dev);
1302 /* power save mode related */
1303 void (*sta_wake_up) (struct net_device *dev);
1304 void (*ps_request_tx_ack) (struct net_device *dev);
1305 void (*enter_sleep_state) (struct net_device *dev, u32 th, u32 tl);
1306 short (*ps_is_queue_empty) (struct net_device *dev);
1309 //void (*wmm_param_update) (struct net_device *dev, u8 *ac_param);
1310 //void (*wmm_param_update) (struct ieee80211_device *ieee);
1312 /* This must be the last item so that it points to the data
1313 * allocated beyond this structure by alloc_ieee80211 */
1317 #define IEEE_A (1<<0)
1318 #define IEEE_B (1<<1)
1319 #define IEEE_G (1<<2)
1320 #define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
1322 /* Generate a 802.11 header */
1324 /* Uses the channel change callback directly
1325 * instead of [start/stop] scan callbacks
1327 #define IEEE_SOFTMAC_SCAN (1<<2)
1329 /* Perform authentication and association handshake */
1330 #define IEEE_SOFTMAC_ASSOCIATE (1<<3)
1332 /* Generate probe requests */
1333 #define IEEE_SOFTMAC_PROBERQ (1<<4)
1335 /* Generate respones to probe requests */
1336 #define IEEE_SOFTMAC_PROBERS (1<<5)
1338 /* The ieee802.11 stack will manages the netif queue
1339 * wake/stop for the driver, taking care of 802.11
1340 * fragmentation. See softmac.c for details. */
1341 #define IEEE_SOFTMAC_TX_QUEUE (1<<7)
1343 /* Uses only the softmac_data_hard_start_xmit
1344 * even for TX management frames.
1346 #define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8)
1348 /* Generate beacons. The stack will enqueue beacons
1351 #define IEEE_SOFTMAC_BEACONS (1<<6)
1355 static inline void *ieee80211_priv(struct net_device *dev)
1357 return ((struct ieee80211_device *)netdev_priv(dev))->priv;
1360 extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
1362 /* Single white space is for Linksys APs */
1363 if (essid_len == 1 && essid[0] == ' ')
1366 /* Otherwise, if the entire essid is 0, we assume it is hidden */
1369 if (essid[essid_len] != '\0')
1376 extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode)
1379 * It is possible for both access points and our device to support
1380 * combinations of modes, so as long as there is one valid combination
1381 * of ap/device supported modes, then return success
1384 if ((mode & IEEE_A) &&
1385 (ieee->modulation & IEEE80211_OFDM_MODULATION) &&
1386 (ieee->freq_band & IEEE80211_52GHZ_BAND))
1389 if ((mode & IEEE_G) &&
1390 (ieee->modulation & IEEE80211_OFDM_MODULATION) &&
1391 (ieee->freq_band & IEEE80211_24GHZ_BAND))
1394 if ((mode & IEEE_B) &&
1395 (ieee->modulation & IEEE80211_CCK_MODULATION) &&
1396 (ieee->freq_band & IEEE80211_24GHZ_BAND))
1402 extern inline int ieee80211_get_hdrlen(u16 fc)
1406 switch (WLAN_FC_GET_TYPE(fc)) {
1407 case IEEE80211_FTYPE_DATA:
1408 if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
1409 hdrlen = 30; /* Addr4 */
1410 if(IEEE80211_QOS_HAS_SEQ(fc))
1411 hdrlen += 2; /* QOS ctrl*/
1413 case IEEE80211_FTYPE_CTL:
1414 switch (WLAN_FC_GET_STYPE(fc)) {
1415 case IEEE80211_STYPE_CTS:
1416 case IEEE80211_STYPE_ACK:
1432 extern void free_ieee80211(struct net_device *dev);
1433 extern struct net_device *alloc_ieee80211(int sizeof_priv);
1435 extern int ieee80211_set_encryption(struct ieee80211_device *ieee);
1437 /* ieee80211_tx.c */
1439 extern int ieee80211_encrypt_fragment(
1440 struct ieee80211_device *ieee,
1441 struct sk_buff *frag,
1444 extern int ieee80211_xmit(struct sk_buff *skb,
1445 struct net_device *dev);
1446 extern void ieee80211_txb_free(struct ieee80211_txb *);
1449 /* ieee80211_rx.c */
1450 extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
1451 struct ieee80211_rx_stats *rx_stats);
1452 extern void ieee80211_rx_mgt(struct ieee80211_device *ieee,
1453 struct ieee80211_hdr *header,
1454 struct ieee80211_rx_stats *stats);
1456 /* ieee80211_wx.c */
1457 extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
1458 struct iw_request_info *info,
1459 union iwreq_data *wrqu, char *key);
1460 extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
1461 struct iw_request_info *info,
1462 union iwreq_data *wrqu, char *key);
1463 extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
1464 struct iw_request_info *info,
1465 union iwreq_data *wrqu, char *key);
1466 extern int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee,
1467 struct iw_request_info *info,
1468 union iwreq_data* wrqu, char *extra);
1469 int ieee80211_wx_set_auth(struct ieee80211_device *ieee,
1470 struct iw_request_info *info,
1471 struct iw_param *data, char *extra);
1472 int ieee80211_wx_set_mlme(struct ieee80211_device *ieee,
1473 struct iw_request_info *info,
1474 union iwreq_data *wrqu, char *extra);
1476 int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len);
1477 /* ieee80211_softmac.c */
1478 extern short ieee80211_is_54g(struct ieee80211_network net);
1479 extern short ieee80211_is_shortslot(struct ieee80211_network net);
1480 extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb,
1481 struct ieee80211_rx_stats *rx_stats, u16 type,
1483 extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net);
1485 extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee);
1486 extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee);
1487 extern void ieee80211_start_bss(struct ieee80211_device *ieee);
1488 extern void ieee80211_start_master_bss(struct ieee80211_device *ieee);
1489 extern void ieee80211_start_ibss(struct ieee80211_device *ieee);
1490 extern void ieee80211_softmac_init(struct ieee80211_device *ieee);
1491 extern void ieee80211_softmac_free(struct ieee80211_device *ieee);
1492 extern void ieee80211_associate_abort(struct ieee80211_device *ieee);
1493 extern void ieee80211_disassociate(struct ieee80211_device *ieee);
1494 extern void ieee80211_stop_scan(struct ieee80211_device *ieee);
1495 extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee);
1496 extern void ieee80211_check_all_nets(struct ieee80211_device *ieee);
1497 extern void ieee80211_start_protocol(struct ieee80211_device *ieee);
1498 extern void ieee80211_stop_protocol(struct ieee80211_device *ieee);
1499 extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee);
1500 extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee);
1501 extern void ieee80211_reset_queue(struct ieee80211_device *ieee);
1502 extern void ieee80211_wake_queue(struct ieee80211_device *ieee);
1503 extern void ieee80211_stop_queue(struct ieee80211_device *ieee);
1504 extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee);
1505 extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee);
1506 extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee);
1507 extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p);
1508 extern void notify_wx_assoc_event(struct ieee80211_device *ieee);
1509 extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success);
1510 extern void SendDisassociation(struct ieee80211_device *ieee,u8* asSta,u8 asRsn);
1511 extern void ieee80211_start_scan(struct ieee80211_device *ieee);
1513 //Add for RF power on power off by lizhaoming 080512
1514 extern void SendDisassociation(struct ieee80211_device *ieee,
1518 /* ieee80211_crypt_ccmp&tkip&wep.c */
1519 extern void ieee80211_tkip_null(void);
1520 extern void ieee80211_wep_null(void);
1521 extern void ieee80211_ccmp_null(void);
1522 /* ieee80211_softmac_wx.c */
1524 extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee,
1525 struct iw_request_info *info,
1526 union iwreq_data *wrqu, char *ext);
1528 extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee,
1529 struct iw_request_info *info,
1530 union iwreq_data *awrq,
1533 extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b);
1535 extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee,
1536 struct iw_request_info *info,
1537 union iwreq_data *wrqu, char *extra);
1539 extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee,
1540 struct iw_request_info *info,
1541 union iwreq_data *wrqu, char *extra);
1543 extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
1544 union iwreq_data *wrqu, char *b);
1546 extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a,
1547 union iwreq_data *wrqu, char *b);
1549 extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee,
1550 struct iw_request_info *a,
1551 union iwreq_data *wrqu, char *extra);
1553 extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
1554 union iwreq_data *wrqu, char *b);
1556 extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
1557 union iwreq_data *wrqu, char *b);
1559 extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
1560 union iwreq_data *wrqu, char *b);
1562 extern void ieee80211_wx_sync_scan_wq(struct work_struct *work);
1564 extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee,
1565 struct iw_request_info *info,
1566 union iwreq_data *wrqu, char *extra);
1568 extern int ieee80211_wx_get_name(struct ieee80211_device *ieee,
1569 struct iw_request_info *info,
1570 union iwreq_data *wrqu, char *extra);
1572 extern int ieee80211_wx_set_power(struct ieee80211_device *ieee,
1573 struct iw_request_info *info,
1574 union iwreq_data *wrqu, char *extra);
1576 extern int ieee80211_wx_get_power(struct ieee80211_device *ieee,
1577 struct iw_request_info *info,
1578 union iwreq_data *wrqu, char *extra);
1580 extern void ieee80211_softmac_ips_scan_syncro(struct ieee80211_device *ieee);
1582 extern void ieee80211_sta_ps_send_null_frame(struct ieee80211_device *ieee, short pwr);
1584 extern const long ieee80211_wlan_frequencies[];
1586 extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee)
1591 extern inline int ieee80211_get_scans(struct ieee80211_device *ieee)
1596 static inline const char *escape_essid(const char *essid, u8 essid_len) {
1597 static char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
1598 const char *s = essid;
1601 if (ieee80211_is_empty_essid(essid, essid_len)) {
1602 memcpy(escaped, "<hidden>", sizeof("<hidden>"));
1606 essid_len = min(essid_len, (u8)IW_ESSID_MAX_SIZE);
1607 while (essid_len--) {
1619 #endif /* IEEE80211_H */