ieee80211.h 37.7 KB
Newer Older
J
Jeff Garzik 已提交
1 2 3 4 5 6 7 8
/*
 * Merged with mainline ieee80211.h in Aug 2004.  Original ieee802_11
 * remains copyright by the original authors
 *
 * Portions of the merged code are based on Host AP (software wireless
 * LAN access point) driver for Intersil Prism2/2.5/3.
 *
 * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
9 10
 * <j@w1.fi>
 * Copyright (c) 2002-2003, Jouni Malinen <j@w1.fi>
J
Jeff Garzik 已提交
11 12 13
 *
 * Adaption to a generic IEEE 802.11 stack by James Ketrenos
 * <jketreno@linux.intel.com>
14
 * Copyright (c) 2004-2005, Intel Corporation
J
Jeff Garzik 已提交
15 16 17 18 19
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation. See README and COPYING for
 * more details.
20 21 22 23 24
 *
 * API Version History
 * 1.0.x -- Initial version
 * 1.1.x -- Added radiotap, QoS, TIM, ieee80211_geo APIs,
 *          various structure changes, and crypto API init method
J
Jeff Garzik 已提交
25 26 27
 */
#ifndef IEEE80211_H
#define IEEE80211_H
28 29
#include <linux/if_ether.h>	/* ETH_ALEN */
#include <linux/kernel.h>	/* ARRAY_SIZE */
30
#include <linux/wireless.h>
J
Jeff Garzik 已提交
31

32
#define IEEE80211_VERSION "git-1.1.13"
33

J
Jeff Garzik 已提交
34 35 36 37 38 39 40 41 42
#define IEEE80211_DATA_LEN		2304
/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
   6.2.1.1.2.

   The figure in section 7.1.2 suggests a body size of up to 2312
   bytes is allowed, which is a bit confusing, I suspect this
   represents the 2304 bytes of real data, plus a possible 8 bytes of
   WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */

J
Jiri Benc 已提交
43 44
#define IEEE80211_1ADDR_LEN 10
#define IEEE80211_2ADDR_LEN 16
J
Jeff Garzik 已提交
45 46 47
#define IEEE80211_3ADDR_LEN 24
#define IEEE80211_4ADDR_LEN 30
#define IEEE80211_FCS_LEN    4
48 49
#define IEEE80211_HLEN			(IEEE80211_4ADDR_LEN)
#define IEEE80211_FRAME_LEN		(IEEE80211_DATA_LEN + IEEE80211_HLEN)
J
Jeff Garzik 已提交
50 51 52 53 54

#define MIN_FRAG_THRESHOLD     256U
#define	MAX_FRAG_THRESHOLD     2346U

/* Frame control field constants */
55
#define IEEE80211_FCTL_VERS		0x0003
J
Jeff Garzik 已提交
56 57 58 59 60 61 62
#define IEEE80211_FCTL_FTYPE		0x000c
#define IEEE80211_FCTL_STYPE		0x00f0
#define IEEE80211_FCTL_TODS		0x0100
#define IEEE80211_FCTL_FROMDS		0x0200
#define IEEE80211_FCTL_MOREFRAGS	0x0400
#define IEEE80211_FCTL_RETRY		0x0800
#define IEEE80211_FCTL_PM		0x1000
63 64
#define IEEE80211_FCTL_MOREDATA		0x2000
#define IEEE80211_FCTL_PROTECTED	0x4000
J
Jeff Garzik 已提交
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
#define IEEE80211_FCTL_ORDER		0x8000

#define IEEE80211_FTYPE_MGMT		0x0000
#define IEEE80211_FTYPE_CTL		0x0004
#define IEEE80211_FTYPE_DATA		0x0008

/* management */
#define IEEE80211_STYPE_ASSOC_REQ	0x0000
#define IEEE80211_STYPE_ASSOC_RESP 	0x0010
#define IEEE80211_STYPE_REASSOC_REQ	0x0020
#define IEEE80211_STYPE_REASSOC_RESP	0x0030
#define IEEE80211_STYPE_PROBE_REQ	0x0040
#define IEEE80211_STYPE_PROBE_RESP	0x0050
#define IEEE80211_STYPE_BEACON		0x0080
#define IEEE80211_STYPE_ATIM		0x0090
#define IEEE80211_STYPE_DISASSOC	0x00A0
#define IEEE80211_STYPE_AUTH		0x00B0
#define IEEE80211_STYPE_DEAUTH		0x00C0
83
#define IEEE80211_STYPE_ACTION		0x00D0
J
Jeff Garzik 已提交
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101

/* control */
#define IEEE80211_STYPE_PSPOLL		0x00A0
#define IEEE80211_STYPE_RTS		0x00B0
#define IEEE80211_STYPE_CTS		0x00C0
#define IEEE80211_STYPE_ACK		0x00D0
#define IEEE80211_STYPE_CFEND		0x00E0
#define IEEE80211_STYPE_CFENDACK	0x00F0

/* data */
#define IEEE80211_STYPE_DATA		0x0000
#define IEEE80211_STYPE_DATA_CFACK	0x0010
#define IEEE80211_STYPE_DATA_CFPOLL	0x0020
#define IEEE80211_STYPE_DATA_CFACKPOLL	0x0030
#define IEEE80211_STYPE_NULLFUNC	0x0040
#define IEEE80211_STYPE_CFACK		0x0050
#define IEEE80211_STYPE_CFPOLL		0x0060
#define IEEE80211_STYPE_CFACKPOLL	0x0070
102
#define IEEE80211_STYPE_QOS_DATA        0x0080
J
Jeff Garzik 已提交
103 104 105 106

#define IEEE80211_SCTL_FRAG		0x000F
#define IEEE80211_SCTL_SEQ		0xFFF0

107 108 109
/* QOS control */
#define IEEE80211_QCTL_TID		0x000F

J
Jeff Garzik 已提交
110 111 112 113 114 115 116 117
/* debug macros */

#ifdef CONFIG_IEEE80211_DEBUG
extern u32 ieee80211_debug_level;
#define IEEE80211_DEBUG(level, fmt, args...) \
do { if (ieee80211_debug_level & (level)) \
  printk(KERN_DEBUG "ieee80211: %c %s " fmt, \
         in_interrupt() ? 'I' : 'U', __FUNCTION__ , ## args); } while (0)
118 119 120 121
static inline bool ieee80211_ratelimit_debug(u32 level)
{
	return (ieee80211_debug_level & level) && net_ratelimit();
}
J
Jeff Garzik 已提交
122 123
#else
#define IEEE80211_DEBUG(level, fmt, args...) do {} while (0)
124 125 126 127
static inline bool ieee80211_ratelimit_debug(u32 level)
{
	return false;
}
128
#endif				/* CONFIG_IEEE80211_DEBUG */
129 130 131 132 133

/* escape_essid() is intended to be used in debug (and possibly error)
 * messages. It should never be used for passing essid to user space. */
const char *escape_essid(const char *essid, u8 essid_len);

J
Jeff Garzik 已提交
134
/*
135
 * To use the debug system:
J
Jeff Garzik 已提交
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
 *
 * If you are defining a new debug classification, simply add it to the #define
 * list here in the form of:
 *
 * #define IEEE80211_DL_xxxx VALUE
 *
 * shifting value to the left one bit from the previous entry.  xxxx should be
 * the name of the classification (for example, WEP)
 *
 * You then need to either add a IEEE80211_xxxx_DEBUG() macro definition for your
 * classification, or use IEEE80211_DEBUG(IEEE80211_DL_xxxx, ...) whenever you want
 * to send output to that classification.
 *
 * To add your debug level to the list of levels seen when you perform
 *
151
 * % cat /proc/net/ieee80211/debug_level
J
Jeff Garzik 已提交
152
 *
153
 * you simply need to add your entry to the ieee80211_debug_level array.
J
Jeff Garzik 已提交
154
 *
155
 * If you do not see debug_level in /proc/net/ieee80211 then you do not have
J
Jeff Garzik 已提交
156 157 158 159 160 161 162 163 164 165 166 167 168 169
 * CONFIG_IEEE80211_DEBUG defined in your kernel configuration
 *
 */

#define IEEE80211_DL_INFO          (1<<0)
#define IEEE80211_DL_WX            (1<<1)
#define IEEE80211_DL_SCAN          (1<<2)
#define IEEE80211_DL_STATE         (1<<3)
#define IEEE80211_DL_MGMT          (1<<4)
#define IEEE80211_DL_FRAG          (1<<5)
#define IEEE80211_DL_DROP          (1<<7)

#define IEEE80211_DL_TX            (1<<8)
#define IEEE80211_DL_RX            (1<<9)
170
#define IEEE80211_DL_QOS           (1<<31)
J
Jeff Garzik 已提交
171 172 173 174 175 176 177 178 179 180 181 182 183

#define IEEE80211_ERROR(f, a...) printk(KERN_ERR "ieee80211: " f, ## a)
#define IEEE80211_WARNING(f, a...) printk(KERN_WARNING "ieee80211: " f, ## a)
#define IEEE80211_DEBUG_INFO(f, a...)   IEEE80211_DEBUG(IEEE80211_DL_INFO, f, ## a)

#define IEEE80211_DEBUG_WX(f, a...)     IEEE80211_DEBUG(IEEE80211_DL_WX, f, ## a)
#define IEEE80211_DEBUG_SCAN(f, a...)   IEEE80211_DEBUG(IEEE80211_DL_SCAN, f, ## a)
#define IEEE80211_DEBUG_STATE(f, a...)  IEEE80211_DEBUG(IEEE80211_DL_STATE, f, ## a)
#define IEEE80211_DEBUG_MGMT(f, a...)  IEEE80211_DEBUG(IEEE80211_DL_MGMT, f, ## a)
#define IEEE80211_DEBUG_FRAG(f, a...)  IEEE80211_DEBUG(IEEE80211_DL_FRAG, f, ## a)
#define IEEE80211_DEBUG_DROP(f, a...)  IEEE80211_DEBUG(IEEE80211_DL_DROP, f, ## a)
#define IEEE80211_DEBUG_TX(f, a...)  IEEE80211_DEBUG(IEEE80211_DL_TX, f, ## a)
#define IEEE80211_DEBUG_RX(f, a...)  IEEE80211_DEBUG(IEEE80211_DL_RX, f, ## a)
184
#define IEEE80211_DEBUG_QOS(f, a...)  IEEE80211_DEBUG(IEEE80211_DL_QOS, f, ## a)
J
Jeff Garzik 已提交
185
#include <linux/netdevice.h>
186
#include <linux/if_arp.h>	/* ARPHRD_ETHER */
J
Jeff Garzik 已提交
187 188

#ifndef WIRELESS_SPY
J
Jiri Benc 已提交
189
#define WIRELESS_SPY		/* enable iwspy support */
J
Jeff Garzik 已提交
190
#endif
J
Jiri Benc 已提交
191
#include <net/iw_handler.h>	/* new driver API */
J
Jeff Garzik 已提交
192 193

#ifndef ETH_P_PAE
194 195
#define ETH_P_PAE 0x888E	/* Port Access Entity (IEEE 802.1X) */
#endif				/* ETH_P_PAE */
J
Jeff Garzik 已提交
196

197
#define ETH_P_PREAUTH 0x88C7	/* IEEE 802.11i pre-authentication */
J
Jeff Garzik 已提交
198 199 200 201 202 203 204 205 206 207 208

#ifndef ETH_P_80211_RAW
#define ETH_P_80211_RAW (ETH_P_ECONET + 1)
#endif

/* IEEE 802.11 defines */

#define P80211_OUI_LEN 3

struct ieee80211_snap_hdr {

209 210 211 212
	u8 dsap;		/* always 0xAA */
	u8 ssap;		/* always 0xAA */
	u8 ctrl;		/* always 0x03 */
	u8 oui[P80211_OUI_LEN];	/* organizational universal id */
J
Jeff Garzik 已提交
213 214 215 216 217

} __attribute__ ((packed));

#define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)

218
#define WLAN_FC_GET_VERS(fc) ((fc) & IEEE80211_FCTL_VERS)
J
Jeff Garzik 已提交
219 220 221 222
#define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE)
#define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE)

#define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG)
223
#define WLAN_GET_SEQ_SEQ(seq)  (((seq) & IEEE80211_SCTL_SEQ) >> 4)
J
Jeff Garzik 已提交
224 225 226 227

/* Authentication algorithms */
#define WLAN_AUTH_OPEN 0
#define WLAN_AUTH_SHARED_KEY 1
228
#define WLAN_AUTH_LEAP 2
J
Jeff Garzik 已提交
229 230 231

#define WLAN_AUTH_CHALLENGE_LEN 128

232
#define WLAN_CAPABILITY_ESS (1<<0)
J
Jeff Garzik 已提交
233 234 235 236 237 238 239
#define WLAN_CAPABILITY_IBSS (1<<1)
#define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
#define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
#define WLAN_CAPABILITY_PRIVACY (1<<4)
#define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
#define WLAN_CAPABILITY_PBCC (1<<6)
#define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
240
#define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8)
241
#define WLAN_CAPABILITY_QOS (1<<9)
242
#define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10)
243
#define WLAN_CAPABILITY_DSSS_OFDM (1<<13)
J
Jeff Garzik 已提交
244

245 246 247 248 249
/* 802.11g ERP information element */
#define WLAN_ERP_NON_ERP_PRESENT (1<<0)
#define WLAN_ERP_USE_PROTECTION (1<<1)
#define WLAN_ERP_BARKER_PREAMBLE (1<<2)

J
Jeff Garzik 已提交
250
/* Status codes */
J
Jiri Benc 已提交
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282
enum ieee80211_statuscode {
	WLAN_STATUS_SUCCESS = 0,
	WLAN_STATUS_UNSPECIFIED_FAILURE = 1,
	WLAN_STATUS_CAPS_UNSUPPORTED = 10,
	WLAN_STATUS_REASSOC_NO_ASSOC = 11,
	WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12,
	WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13,
	WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14,
	WLAN_STATUS_CHALLENGE_FAIL = 15,
	WLAN_STATUS_AUTH_TIMEOUT = 16,
	WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17,
	WLAN_STATUS_ASSOC_DENIED_RATES = 18,
	/* 802.11b */
	WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19,
	WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20,
	WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21,
	/* 802.11h */
	WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22,
	WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23,
	WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24,
	/* 802.11g */
	WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25,
	WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26,
	/* 802.11i */
	WLAN_STATUS_INVALID_IE = 40,
	WLAN_STATUS_INVALID_GROUP_CIPHER = 41,
	WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42,
	WLAN_STATUS_INVALID_AKMP = 43,
	WLAN_STATUS_UNSUPP_RSN_VERSION = 44,
	WLAN_STATUS_INVALID_RSN_IE_CAP = 45,
	WLAN_STATUS_CIPHER_SUITE_REJECTED = 46,
};
J
Jeff Garzik 已提交
283 284

/* Reason codes */
J
Jiri Benc 已提交
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311
enum ieee80211_reasoncode {
	WLAN_REASON_UNSPECIFIED = 1,
	WLAN_REASON_PREV_AUTH_NOT_VALID = 2,
	WLAN_REASON_DEAUTH_LEAVING = 3,
	WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4,
	WLAN_REASON_DISASSOC_AP_BUSY = 5,
	WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6,
	WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7,
	WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8,
	WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9,
	/* 802.11h */
	WLAN_REASON_DISASSOC_BAD_POWER = 10,
	WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11,
	/* 802.11i */
	WLAN_REASON_INVALID_IE = 13,
	WLAN_REASON_MIC_FAILURE = 14,
	WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15,
	WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16,
	WLAN_REASON_IE_DIFFERENT = 17,
	WLAN_REASON_INVALID_GROUP_CIPHER = 18,
	WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19,
	WLAN_REASON_INVALID_AKMP = 20,
	WLAN_REASON_UNSUPP_RSN_VERSION = 21,
	WLAN_REASON_INVALID_RSN_IE_CAP = 22,
	WLAN_REASON_IEEE8021X_FAILED = 23,
	WLAN_REASON_CIPHER_SUITE_REJECTED = 24,
};
J
Jeff Garzik 已提交
312

313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329
/* Action categories - 802.11h */
enum ieee80211_actioncategories {
	WLAN_ACTION_SPECTRUM_MGMT = 0,
	/* Reserved 1-127  */
	/* Error    128-255 */
};

/* Action details - 802.11h */
enum ieee80211_actiondetails {
	WLAN_ACTION_CATEGORY_MEASURE_REQUEST = 0,
	WLAN_ACTION_CATEGORY_MEASURE_REPORT = 1,
	WLAN_ACTION_CATEGORY_TPC_REQUEST = 2,
	WLAN_ACTION_CATEGORY_TPC_REPORT = 3,
	WLAN_ACTION_CATEGORY_CHANNEL_SWITCH = 4,
	/* 5 - 255 Reserved */
};

J
Jeff Garzik 已提交
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393
#define IEEE80211_STATMASK_SIGNAL (1<<0)
#define IEEE80211_STATMASK_RSSI (1<<1)
#define IEEE80211_STATMASK_NOISE (1<<2)
#define IEEE80211_STATMASK_RATE (1<<3)
#define IEEE80211_STATMASK_WEMASK 0x7

#define IEEE80211_CCK_MODULATION    (1<<0)
#define IEEE80211_OFDM_MODULATION   (1<<1)

#define IEEE80211_24GHZ_BAND     (1<<0)
#define IEEE80211_52GHZ_BAND     (1<<1)

#define IEEE80211_CCK_RATE_1MB		        0x02
#define IEEE80211_CCK_RATE_2MB		        0x04
#define IEEE80211_CCK_RATE_5MB		        0x0B
#define IEEE80211_CCK_RATE_11MB		        0x16
#define IEEE80211_OFDM_RATE_6MB		        0x0C
#define IEEE80211_OFDM_RATE_9MB		        0x12
#define IEEE80211_OFDM_RATE_12MB		0x18
#define IEEE80211_OFDM_RATE_18MB		0x24
#define IEEE80211_OFDM_RATE_24MB		0x30
#define IEEE80211_OFDM_RATE_36MB		0x48
#define IEEE80211_OFDM_RATE_48MB		0x60
#define IEEE80211_OFDM_RATE_54MB		0x6C
#define IEEE80211_BASIC_RATE_MASK		0x80

#define IEEE80211_CCK_RATE_1MB_MASK		(1<<0)
#define IEEE80211_CCK_RATE_2MB_MASK		(1<<1)
#define IEEE80211_CCK_RATE_5MB_MASK		(1<<2)
#define IEEE80211_CCK_RATE_11MB_MASK		(1<<3)
#define IEEE80211_OFDM_RATE_6MB_MASK		(1<<4)
#define IEEE80211_OFDM_RATE_9MB_MASK		(1<<5)
#define IEEE80211_OFDM_RATE_12MB_MASK		(1<<6)
#define IEEE80211_OFDM_RATE_18MB_MASK		(1<<7)
#define IEEE80211_OFDM_RATE_24MB_MASK		(1<<8)
#define IEEE80211_OFDM_RATE_36MB_MASK		(1<<9)
#define IEEE80211_OFDM_RATE_48MB_MASK		(1<<10)
#define IEEE80211_OFDM_RATE_54MB_MASK		(1<<11)

#define IEEE80211_CCK_RATES_MASK	        0x0000000F
#define IEEE80211_CCK_BASIC_RATES_MASK	(IEEE80211_CCK_RATE_1MB_MASK | \
	IEEE80211_CCK_RATE_2MB_MASK)
#define IEEE80211_CCK_DEFAULT_RATES_MASK	(IEEE80211_CCK_BASIC_RATES_MASK | \
        IEEE80211_CCK_RATE_5MB_MASK | \
        IEEE80211_CCK_RATE_11MB_MASK)

#define IEEE80211_OFDM_RATES_MASK		0x00000FF0
#define IEEE80211_OFDM_BASIC_RATES_MASK	(IEEE80211_OFDM_RATE_6MB_MASK | \
	IEEE80211_OFDM_RATE_12MB_MASK | \
	IEEE80211_OFDM_RATE_24MB_MASK)
#define IEEE80211_OFDM_DEFAULT_RATES_MASK	(IEEE80211_OFDM_BASIC_RATES_MASK | \
	IEEE80211_OFDM_RATE_9MB_MASK  | \
	IEEE80211_OFDM_RATE_18MB_MASK | \
	IEEE80211_OFDM_RATE_36MB_MASK | \
	IEEE80211_OFDM_RATE_48MB_MASK | \
	IEEE80211_OFDM_RATE_54MB_MASK)
#define IEEE80211_DEFAULT_RATES_MASK (IEEE80211_OFDM_DEFAULT_RATES_MASK | \
                                IEEE80211_CCK_DEFAULT_RATES_MASK)

#define IEEE80211_NUM_OFDM_RATES	    8
#define IEEE80211_NUM_CCK_RATES	            4
#define IEEE80211_OFDM_SHIFT_MASK_A         4

/* NOTE: This data is for statistical purposes; not all hardware provides this
394 395 396
 *       information for frames received.
 *       For ieee80211_rx_mgt, you need to set at least the 'len' parameter.
 */
J
Jeff Garzik 已提交
397 398 399 400 401
struct ieee80211_rx_stats {
	u32 mac_time;
	s8 rssi;
	u8 signal;
	u8 noise;
402
	u16 rate;		/* in 100 kbps */
J
Jeff Garzik 已提交
403 404 405 406 407
	u8 received_channel;
	u8 control;
	u8 mask;
	u8 freq;
	u16 len;
408 409
	u64 tsf;
	u32 beacon_time;
J
Jeff Garzik 已提交
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454
};

/* IEEE 802.11 requires that STA supports concurrent reception of at least
 * three fragmented frames. This define can be increased to support more
 * concurrent frames, but it should be noted that each entry can consume about
 * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
#define IEEE80211_FRAG_CACHE_LEN 4

struct ieee80211_frag_entry {
	unsigned long first_frag_time;
	unsigned int seq;
	unsigned int last_frag;
	struct sk_buff *skb;
	u8 src_addr[ETH_ALEN];
	u8 dst_addr[ETH_ALEN];
};

struct ieee80211_stats {
	unsigned int tx_unicast_frames;
	unsigned int tx_multicast_frames;
	unsigned int tx_fragments;
	unsigned int tx_unicast_octets;
	unsigned int tx_multicast_octets;
	unsigned int tx_deferred_transmissions;
	unsigned int tx_single_retry_frames;
	unsigned int tx_multiple_retry_frames;
	unsigned int tx_retry_limit_exceeded;
	unsigned int tx_discards;
	unsigned int rx_unicast_frames;
	unsigned int rx_multicast_frames;
	unsigned int rx_fragments;
	unsigned int rx_unicast_octets;
	unsigned int rx_multicast_octets;
	unsigned int rx_fcs_errors;
	unsigned int rx_discards_no_buffer;
	unsigned int tx_discards_wrong_sa;
	unsigned int rx_discards_undecryptable;
	unsigned int rx_message_in_msg_fragments;
	unsigned int rx_message_in_bad_msg_fragments;
};

struct ieee80211_device;

#include "ieee80211_crypt.h"

455 456 457 458 459 460 461 462 463
#define SEC_KEY_1		(1<<0)
#define SEC_KEY_2		(1<<1)
#define SEC_KEY_3		(1<<2)
#define SEC_KEY_4		(1<<3)
#define SEC_ACTIVE_KEY		(1<<4)
#define SEC_AUTH_MODE		(1<<5)
#define SEC_UNICAST_GROUP	(1<<6)
#define SEC_LEVEL		(1<<7)
#define SEC_ENABLED		(1<<8)
464
#define SEC_ENCRYPT		(1<<9)
465 466 467 468 469 470 471

#define SEC_LEVEL_0		0	/* None */
#define SEC_LEVEL_1		1	/* WEP 40 and 104 bit */
#define SEC_LEVEL_2		2	/* Level 1 + TKIP */
#define SEC_LEVEL_2_CKIP	3	/* Level 1 + CKIP */
#define SEC_LEVEL_3		4	/* Level 2 + CCMP */

472 473 474 475 476
#define SEC_ALG_NONE		0
#define SEC_ALG_WEP		1
#define SEC_ALG_TKIP		2
#define SEC_ALG_CCMP		3

477 478 479 480
#define WEP_KEYS		4
#define WEP_KEY_LEN		13
#define SCM_KEY_LEN		32
#define SCM_TEMPORAL_KEY_LENGTH	16
J
Jeff Garzik 已提交
481 482 483

struct ieee80211_security {
	u16 active_key:2,
484 485
	    enabled:1,
	    auth_mode:2, auth_algo:4, unicast_uses_group:1, encrypt:1;
486
	u8 encode_alg[WEP_KEYS];
J
Jeff Garzik 已提交
487
	u8 key_sizes[WEP_KEYS];
488
	u8 keys[WEP_KEYS][SCM_KEY_LEN];
J
Jeff Garzik 已提交
489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510
	u8 level;
	u16 flags;
} __attribute__ ((packed));

/*

 802.11 data frame from AP

      ,-------------------------------------------------------------------.
Bytes |  2   |  2   |    6    |    6    |    6    |  2   | 0..2312 |   4  |
      |------|------|---------|---------|---------|------|---------|------|
Desc. | ctrl | dura |  DA/RA  |   TA    |    SA   | Sequ |  frame  |  fcs |
      |      | tion | (BSSID) |         |         | ence |  data   |      |
      `-------------------------------------------------------------------'

Total: 28-2340 bytes

*/

#define BEACON_PROBE_SSID_ID_POSITION 12

/* Management Frame Information Element Types */
J
Jiri Benc 已提交
511 512 513 514 515
enum ieee80211_mfie {
	MFIE_TYPE_SSID = 0,
	MFIE_TYPE_RATES = 1,
	MFIE_TYPE_FH_SET = 2,
	MFIE_TYPE_DS_SET = 3,
516
	MFIE_TYPE_CF_SET = 4,
J
Jiri Benc 已提交
517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537
	MFIE_TYPE_TIM = 5,
	MFIE_TYPE_IBSS_SET = 6,
	MFIE_TYPE_COUNTRY = 7,
	MFIE_TYPE_HOP_PARAMS = 8,
	MFIE_TYPE_HOP_TABLE = 9,
	MFIE_TYPE_REQUEST = 10,
	MFIE_TYPE_CHALLENGE = 16,
	MFIE_TYPE_POWER_CONSTRAINT = 32,
	MFIE_TYPE_POWER_CAPABILITY = 33,
	MFIE_TYPE_TPC_REQUEST = 34,
	MFIE_TYPE_TPC_REPORT = 35,
	MFIE_TYPE_SUPP_CHANNELS = 36,
	MFIE_TYPE_CSA = 37,
	MFIE_TYPE_MEASURE_REQUEST = 38,
	MFIE_TYPE_MEASURE_REPORT = 39,
	MFIE_TYPE_QUIET = 40,
	MFIE_TYPE_IBSS_DFS = 41,
	MFIE_TYPE_ERP_INFO = 42,
	MFIE_TYPE_RSN = 48,
	MFIE_TYPE_RATES_EX = 50,
	MFIE_TYPE_GENERIC = 221,
538
	MFIE_TYPE_QOS_PARAMETER = 222,
J
Jiri Benc 已提交
539
};
J
Jeff Garzik 已提交
540

541 542 543 544
/* Minimal header; can be used for passing 802.11 frames with sufficient
 * information to determine what type of underlying data type is actually
 * stored in the data. */
struct ieee80211_hdr {
545 546
	__le16 frame_ctl;
	__le16 duration_id;
547 548 549 550
	u8 payload[0];
} __attribute__ ((packed));

struct ieee80211_hdr_1addr {
551 552
	__le16 frame_ctl;
	__le16 duration_id;
553 554 555 556 557
	u8 addr1[ETH_ALEN];
	u8 payload[0];
} __attribute__ ((packed));

struct ieee80211_hdr_2addr {
558 559
	__le16 frame_ctl;
	__le16 duration_id;
560 561 562 563 564 565
	u8 addr1[ETH_ALEN];
	u8 addr2[ETH_ALEN];
	u8 payload[0];
} __attribute__ ((packed));

struct ieee80211_hdr_3addr {
566 567
	__le16 frame_ctl;
	__le16 duration_id;
568 569 570
	u8 addr1[ETH_ALEN];
	u8 addr2[ETH_ALEN];
	u8 addr3[ETH_ALEN];
571
	__le16 seq_ctl;
572 573 574 575
	u8 payload[0];
} __attribute__ ((packed));

struct ieee80211_hdr_4addr {
576 577
	__le16 frame_ctl;
	__le16 duration_id;
578 579 580
	u8 addr1[ETH_ALEN];
	u8 addr2[ETH_ALEN];
	u8 addr3[ETH_ALEN];
581
	__le16 seq_ctl;
582 583 584 585
	u8 addr4[ETH_ALEN];
	u8 payload[0];
} __attribute__ ((packed));

586
struct ieee80211_hdr_3addrqos {
587 588
	__le16 frame_ctl;
	__le16 duration_id;
589 590 591
	u8 addr1[ETH_ALEN];
	u8 addr2[ETH_ALEN];
	u8 addr3[ETH_ALEN];
592
	__le16 seq_ctl;
593
	u8 payload[0];
594
	__le16 qos_ctl;
595 596 597
} __attribute__ ((packed));

struct ieee80211_hdr_4addrqos {
598 599
	__le16 frame_ctl;
	__le16 duration_id;
600 601 602
	u8 addr1[ETH_ALEN];
	u8 addr2[ETH_ALEN];
	u8 addr3[ETH_ALEN];
603
	__le16 seq_ctl;
604 605
	u8 addr4[ETH_ALEN];
	u8 payload[0];
606
	__le16 qos_ctl;
607 608
} __attribute__ ((packed));

J
Jeff Garzik 已提交
609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631
struct ieee80211_info_element {
	u8 id;
	u8 len;
	u8 data[0];
} __attribute__ ((packed));

/*
 * These are the data types that can make up management packets
 *
	u16 auth_algorithm;
	u16 auth_sequence;
	u16 beacon_interval;
	u16 capability;
	u8 current_ap[ETH_ALEN];
	u16 listen_interval;
	struct {
		u16 association_id:14, reserved:2;
	} __attribute__ ((packed));
	u32 time_stamp[2];
	u16 reason;
	u16 status;
*/

632
struct ieee80211_auth {
J
Jiri Benc 已提交
633
	struct ieee80211_hdr_3addr header;
J
Jiri Benc 已提交
634 635 636
	__le16 algorithm;
	__le16 transaction;
	__le16 status;
637
	/* challenge */
638
	struct ieee80211_info_element info_element[0];
J
Jeff Garzik 已提交
639 640
} __attribute__ ((packed));

641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662
struct ieee80211_channel_switch {
	u8 id;
	u8 len;
	u8 mode;
	u8 channel;
	u8 count;
} __attribute__ ((packed));

struct ieee80211_action {
	struct ieee80211_hdr_3addr header;
	u8 category;
	u8 action;
	union {
		struct ieee80211_action_exchange {
			u8 token;
			struct ieee80211_info_element info_element[0];
		} exchange;
		struct ieee80211_channel_switch channel_switch;

	} format;
} __attribute__ ((packed));

663 664
struct ieee80211_disassoc {
	struct ieee80211_hdr_3addr header;
665
	__le16 reason;
666 667
} __attribute__ ((packed));

668
/* Alias deauth for disassoc */
669
#define ieee80211_deauth ieee80211_disassoc
670

671 672
struct ieee80211_probe_request {
	struct ieee80211_hdr_3addr header;
673
	/* SSID, supported rates */
674 675 676
	struct ieee80211_info_element info_element[0];
} __attribute__ ((packed));

J
Jeff Garzik 已提交
677
struct ieee80211_probe_response {
J
Jiri Benc 已提交
678
	struct ieee80211_hdr_3addr header;
A
Al Viro 已提交
679
	__le32 time_stamp[2];
J
Jiri Benc 已提交
680 681
	__le16 beacon_interval;
	__le16 capability;
682 683
	/* SSID, supported rates, FH params, DS params,
	 * CF params, IBSS params, TIM (if beacon), RSN */
684
	struct ieee80211_info_element info_element[0];
J
Jeff Garzik 已提交
685 686
} __attribute__ ((packed));

687 688 689 690 691
/* Alias beacon for probe_response */
#define ieee80211_beacon ieee80211_probe_response

struct ieee80211_assoc_request {
	struct ieee80211_hdr_3addr header;
692 693
	__le16 capability;
	__le16 listen_interval;
694
	/* SSID, supported rates, RSN */
695 696 697 698 699
	struct ieee80211_info_element info_element[0];
} __attribute__ ((packed));

struct ieee80211_reassoc_request {
	struct ieee80211_hdr_3addr header;
J
Jiri Benc 已提交
700 701
	__le16 capability;
	__le16 listen_interval;
J
Jeff Garzik 已提交
702
	u8 current_ap[ETH_ALEN];
703
	struct ieee80211_info_element info_element[0];
J
Jeff Garzik 已提交
704 705
} __attribute__ ((packed));

706
struct ieee80211_assoc_response {
J
Jeff Garzik 已提交
707
	struct ieee80211_hdr_3addr header;
J
Jiri Benc 已提交
708 709 710
	__le16 capability;
	__le16 status;
	__le16 aid;
711 712
	/* supported rates */
	struct ieee80211_info_element info_element[0];
J
Jeff Garzik 已提交
713 714 715 716 717
} __attribute__ ((packed));

struct ieee80211_txb {
	u8 nr_frags;
	u8 encrypted;
718 719
	u8 rts_included;
	u8 reserved;
A
Al Viro 已提交
720 721
	u16 frag_size;
	u16 payload_size;
J
Jeff Garzik 已提交
722 723 724
	struct sk_buff *fragments[0];
};

J
Jiri Benc 已提交
725
/* SWEEP TABLE ENTRIES NUMBER */
J
Jeff Garzik 已提交
726 727 728 729 730 731 732 733 734 735 736 737 738 739
#define MAX_SWEEP_TAB_ENTRIES		  42
#define MAX_SWEEP_TAB_ENTRIES_PER_PACKET  7
/* MAX_RATES_LENGTH needs to be 12.  The spec says 8, and many APs
 * only use 8, and then use extended rates for the remaining supported
 * rates.  Other APs, however, stick all of their supported rates on the
 * main rates information element... */
#define MAX_RATES_LENGTH                  ((u8)12)
#define MAX_RATES_EX_LENGTH               ((u8)16)
#define MAX_NETWORK_COUNT                  128

#define CRC_LENGTH                 4U

#define MAX_WPA_IE_LEN 64

740 741 742 743 744 745 746
#define NETWORK_EMPTY_ESSID    (1<<0)
#define NETWORK_HAS_OFDM       (1<<1)
#define NETWORK_HAS_CCK        (1<<2)

/* QoS structure */
#define NETWORK_HAS_QOS_PARAMETERS      (1<<3)
#define NETWORK_HAS_QOS_INFORMATION     (1<<4)
747 748 749 750 751 752 753 754 755
#define NETWORK_HAS_QOS_MASK            (NETWORK_HAS_QOS_PARAMETERS | \
					 NETWORK_HAS_QOS_INFORMATION)

/* 802.11h */
#define NETWORK_HAS_POWER_CONSTRAINT    (1<<5)
#define NETWORK_HAS_CSA                 (1<<6)
#define NETWORK_HAS_QUIET               (1<<7)
#define NETWORK_HAS_IBSS_DFS            (1<<8)
#define NETWORK_HAS_TPC_REPORT          (1<<9)
756

757 758
#define NETWORK_HAS_ERP_VALUE           (1<<10)

759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780
#define QOS_QUEUE_NUM                   4
#define QOS_OUI_LEN                     3
#define QOS_OUI_TYPE                    2
#define QOS_ELEMENT_ID                  221
#define QOS_OUI_INFO_SUB_TYPE           0
#define QOS_OUI_PARAM_SUB_TYPE          1
#define QOS_VERSION_1                   1
#define QOS_AIFSN_MIN_VALUE             2

struct ieee80211_qos_information_element {
	u8 elementID;
	u8 length;
	u8 qui[QOS_OUI_LEN];
	u8 qui_type;
	u8 qui_subtype;
	u8 version;
	u8 ac_info;
} __attribute__ ((packed));

struct ieee80211_qos_ac_parameter {
	u8 aci_aifsn;
	u8 ecw_min_max;
781
	__le16 tx_op_limit;
782 783 784 785 786 787 788 789 790
} __attribute__ ((packed));

struct ieee80211_qos_parameter_info {
	struct ieee80211_qos_information_element info_element;
	u8 reserved;
	struct ieee80211_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM];
} __attribute__ ((packed));

struct ieee80211_qos_parameters {
791 792
	__le16 cw_min[QOS_QUEUE_NUM];
	__le16 cw_max[QOS_QUEUE_NUM];
793 794
	u8 aifs[QOS_QUEUE_NUM];
	u8 flag[QOS_QUEUE_NUM];
795
	__le16 tx_op_limit[QOS_QUEUE_NUM];
796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811
} __attribute__ ((packed));

struct ieee80211_qos_data {
	struct ieee80211_qos_parameters parameters;
	int active;
	int supported;
	u8 param_count;
	u8 old_param_count;
};

struct ieee80211_tim_parameters {
	u8 tim_count;
	u8 tim_period;
} __attribute__ ((packed));

/*******************************************************/
J
Jeff Garzik 已提交
812

813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897
enum {				/* ieee80211_basic_report.map */
	IEEE80211_BASIC_MAP_BSS = (1 << 0),
	IEEE80211_BASIC_MAP_OFDM = (1 << 1),
	IEEE80211_BASIC_MAP_UNIDENTIFIED = (1 << 2),
	IEEE80211_BASIC_MAP_RADAR = (1 << 3),
	IEEE80211_BASIC_MAP_UNMEASURED = (1 << 4),
	/* Bits 5-7 are reserved */

};
struct ieee80211_basic_report {
	u8 channel;
	__le64 start_time;
	__le16 duration;
	u8 map;
} __attribute__ ((packed));

enum {				/* ieee80211_measurement_request.mode */
	/* Bit 0 is reserved */
	IEEE80211_MEASUREMENT_ENABLE = (1 << 1),
	IEEE80211_MEASUREMENT_REQUEST = (1 << 2),
	IEEE80211_MEASUREMENT_REPORT = (1 << 3),
	/* Bits 4-7 are reserved */
};

enum {
	IEEE80211_REPORT_BASIC = 0,	/* required */
	IEEE80211_REPORT_CCA = 1,	/* optional */
	IEEE80211_REPORT_RPI = 2,	/* optional */
	/* 3-255 reserved */
};

struct ieee80211_measurement_params {
	u8 channel;
	__le64 start_time;
	__le16 duration;
} __attribute__ ((packed));

struct ieee80211_measurement_request {
	struct ieee80211_info_element ie;
	u8 token;
	u8 mode;
	u8 type;
	struct ieee80211_measurement_params params[0];
} __attribute__ ((packed));

struct ieee80211_measurement_report {
	struct ieee80211_info_element ie;
	u8 token;
	u8 mode;
	u8 type;
	union {
		struct ieee80211_basic_report basic[0];
	} u;
} __attribute__ ((packed));

struct ieee80211_tpc_report {
	u8 transmit_power;
	u8 link_margin;
} __attribute__ ((packed));

struct ieee80211_channel_map {
	u8 channel;
	u8 map;
} __attribute__ ((packed));

struct ieee80211_ibss_dfs {
	struct ieee80211_info_element ie;
	u8 owner[ETH_ALEN];
	u8 recovery_interval;
	struct ieee80211_channel_map channel_map[0];
};

struct ieee80211_csa {
	u8 mode;
	u8 channel;
	u8 count;
} __attribute__ ((packed));

struct ieee80211_quiet {
	u8 count;
	u8 period;
	u8 duration;
	u8 offset;
} __attribute__ ((packed));

J
Jeff Garzik 已提交
898 899 900 901 902 903 904 905
struct ieee80211_network {
	/* These entries are used to identify a unique network */
	u8 bssid[ETH_ALEN];
	u8 channel;
	/* Ensure null-terminated for any debug msgs */
	u8 ssid[IW_ESSID_MAX_SIZE + 1];
	u8 ssid_len;

906 907
	struct ieee80211_qos_data qos_data;

J
Jeff Garzik 已提交
908 909 910 911 912 913 914 915 916
	/* These are network statistics */
	struct ieee80211_rx_stats stats;
	u16 capability;
	u8 rates[MAX_RATES_LENGTH];
	u8 rates_len;
	u8 rates_ex[MAX_RATES_EX_LENGTH];
	u8 rates_ex_len;
	unsigned long last_scanned;
	u8 mode;
917
	u32 flags;
J
Jeff Garzik 已提交
918 919 920 921 922
	u32 last_associate;
	u32 time_stamp[2];
	u16 beacon_interval;
	u16 listen_interval;
	u16 atim_window;
923
	u8 erp_value;
J
Jeff Garzik 已提交
924 925 926 927
	u8 wpa_ie[MAX_WPA_IE_LEN];
	size_t wpa_ie_len;
	u8 rsn_ie[MAX_WPA_IE_LEN];
	size_t rsn_ie_len;
928
	struct ieee80211_tim_parameters tim;
929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947

	/* 802.11h info */

	/* Power Constraint - mandatory if spctrm mgmt required */
	u8 power_constraint;

	/* TPC Report - mandatory if spctrm mgmt required */
	struct ieee80211_tpc_report tpc_report;

	/* IBSS DFS - mandatory if spctrm mgmt required and IBSS
	 * NOTE: This is variable length and so must be allocated dynamically */
	struct ieee80211_ibss_dfs *ibss_dfs;

	/* Channel Switch Announcement - optional if spctrm mgmt required */
	struct ieee80211_csa csa;

	/* Quiet - optional if spctrm mgmt required */
	struct ieee80211_quiet quiet;

J
Jeff Garzik 已提交
948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965
	struct list_head list;
};

enum ieee80211_state {
	IEEE80211_UNINITIALIZED = 0,
	IEEE80211_INITIALIZED,
	IEEE80211_ASSOCIATING,
	IEEE80211_ASSOCIATED,
	IEEE80211_AUTHENTICATING,
	IEEE80211_AUTHENTICATED,
	IEEE80211_SHUTDOWN
};

#define DEFAULT_MAX_SCAN_AGE (15 * HZ)
#define DEFAULT_FTS 2346

#define CFG_IEEE80211_RESERVE_FCS (1<<0)
#define CFG_IEEE80211_COMPUTE_FCS (1<<1)
966
#define CFG_IEEE80211_RTS (1<<2)
J
Jeff Garzik 已提交
967

968 969
#define IEEE80211_24GHZ_MIN_CHANNEL 1
#define IEEE80211_24GHZ_MAX_CHANNEL 14
970 971
#define IEEE80211_24GHZ_CHANNELS (IEEE80211_24GHZ_MAX_CHANNEL - \
				  IEEE80211_24GHZ_MIN_CHANNEL + 1)
972

973
#define IEEE80211_52GHZ_MIN_CHANNEL 34
974
#define IEEE80211_52GHZ_MAX_CHANNEL 165
975 976
#define IEEE80211_52GHZ_CHANNELS (IEEE80211_52GHZ_MAX_CHANNEL - \
				  IEEE80211_52GHZ_MIN_CHANNEL + 1)
977 978 979

enum {
	IEEE80211_CH_PASSIVE_ONLY = (1 << 0),
980
	IEEE80211_CH_80211H_RULES = (1 << 1),
981 982 983 984 985 986 987 988
	IEEE80211_CH_B_ONLY = (1 << 2),
	IEEE80211_CH_NO_IBSS = (1 << 3),
	IEEE80211_CH_UNIFORM_SPREADING = (1 << 4),
	IEEE80211_CH_RADAR_DETECT = (1 << 5),
	IEEE80211_CH_INVALID = (1 << 6),
};

struct ieee80211_channel {
989
	u32 freq;	/* in MHz */
990 991
	u8 channel;
	u8 flags;
992
	u8 max_power;	/* in dBm */
993 994 995 996 997 998 999 1000 1001 1002
};

struct ieee80211_geo {
	u8 name[4];
	u8 bg_channels;
	u8 a_channels;
	struct ieee80211_channel bg[IEEE80211_24GHZ_CHANNELS];
	struct ieee80211_channel a[IEEE80211_52GHZ_CHANNELS];
};

J
Jeff Garzik 已提交
1003 1004
struct ieee80211_device {
	struct net_device *dev;
1005
	struct ieee80211_security sec;
J
Jeff Garzik 已提交
1006 1007 1008 1009 1010

	/* Bookkeeping structures */
	struct net_device_stats stats;
	struct ieee80211_stats ieee_stats;

1011 1012
	struct ieee80211_geo geo;

J
Jeff Garzik 已提交
1013 1014 1015 1016 1017 1018 1019
	/* Probe / Beacon management */
	struct list_head network_free_list;
	struct list_head network_list;
	struct ieee80211_network *networks;
	int scans;
	int scan_age;

1020 1021
	int iw_mode;		/* operating mode (IW_MODE_*) */
	struct iw_spy_data spy_data;	/* iwspy support */
J
Jeff Garzik 已提交
1022 1023 1024

	spinlock_t lock;

1025 1026
	int tx_headroom;	/* Set to size of any additional room needed at front
				 * of allocated Tx SKBs */
J
Jeff Garzik 已提交
1027 1028 1029
	u32 config;

	/* WEP and other encryption related settings at the device level */
1030
	int open_wep;		/* Set to 1 to allow unencrypted frames */
J
Jeff Garzik 已提交
1031

1032
	int reset_on_keychange;	/* Set to 1 if the HW needs to be reset on
J
Jeff Garzik 已提交
1033 1034 1035 1036
				 * WEP key changes */

	/* If the host performs {en,de}cryption, then set to 1 */
	int host_encrypt;
1037
	int host_encrypt_msdu;
J
Jeff Garzik 已提交
1038
	int host_decrypt;
1039 1040 1041
	/* host performs multicast decryption */
	int host_mc_decrypt;

1042 1043 1044 1045
	/* host should strip IV and ICV from protected frames */
	/* meaningful only when hardware decryption is being used */
	int host_strip_iv_icv;

1046
	int host_open_frag;
1047
	int host_build_iv;
1048
	int ieee802_1x;		/* is IEEE 802.1X used */
J
Jeff Garzik 已提交
1049 1050 1051 1052 1053 1054 1055 1056 1057 1058

	/* WPA data */
	int wpa_enabled;
	int drop_unencrypted;
	int privacy_invoked;
	size_t wpa_ie_len;
	u8 *wpa_ie;

	struct list_head crypt_deinit_list;
	struct ieee80211_crypt_data *crypt[WEP_KEYS];
1059
	int tx_keyidx;		/* default TX key index (crypt[tx_keyidx]) */
J
Jeff Garzik 已提交
1060
	struct timer_list crypt_deinit_timer;
1061
	int crypt_quiesced;
J
Jeff Garzik 已提交
1062

1063 1064
	int bcrx_sta_key;	/* use individual keys to override default keys even
				 * with RX of broad/multicast frames */
J
Jeff Garzik 已提交
1065 1066 1067 1068

	/* Fragmentation structures */
	struct ieee80211_frag_entry frag_cache[IEEE80211_FRAG_CACHE_LEN];
	unsigned int frag_next_idx;
1069
	u16 fts;		/* Fragmentation Threshold */
1070
	u16 rts;		/* RTS threshold */
J
Jeff Garzik 已提交
1071 1072 1073 1074 1075 1076

	/* Association info */
	u8 bssid[ETH_ALEN];

	enum ieee80211_state state;

1077 1078 1079
	int mode;		/* A, B, G */
	int modulation;		/* CCK, OFDM */
	int freq_band;		/* 2.4Ghz, 5.2Ghz, Mixed */
1080
	int abg_true;		/* ABG flag              */
J
Jeff Garzik 已提交
1081

1082 1083 1084
	int perfect_rssi;
	int worst_rssi;

1085 1086
	u16 prev_seq_ctl;	/* used to drop duplicate frames */

J
Jeff Garzik 已提交
1087
	/* Callback functions */
1088 1089 1090
	void (*set_security) (struct net_device * dev,
			      struct ieee80211_security * sec);
	int (*hard_start_xmit) (struct ieee80211_txb * txb,
1091
				struct net_device * dev, int pri);
1092
	int (*reset_port) (struct net_device * dev);
1093 1094
	int (*is_queue_full) (struct net_device * dev, int pri);

1095 1096
	int (*handle_management) (struct net_device * dev,
				  struct ieee80211_network * network, u16 type);
1097
	int (*is_qos_active) (struct net_device *dev, struct sk_buff *skb);
1098

1099 1100 1101
	/* Typical STA methods */
	int (*handle_auth) (struct net_device * dev,
			    struct ieee80211_auth * auth);
1102
	int (*handle_deauth) (struct net_device * dev,
1103 1104 1105 1106
			      struct ieee80211_deauth * auth);
	int (*handle_action) (struct net_device * dev,
			      struct ieee80211_action * action,
			      struct ieee80211_rx_stats * stats);
1107 1108 1109 1110 1111 1112 1113 1114
	int (*handle_disassoc) (struct net_device * dev,
				struct ieee80211_disassoc * assoc);
	int (*handle_beacon) (struct net_device * dev,
			      struct ieee80211_beacon * beacon,
			      struct ieee80211_network * network);
	int (*handle_probe_response) (struct net_device * dev,
				      struct ieee80211_probe_response * resp,
				      struct ieee80211_network * network);
1115 1116 1117
	int (*handle_probe_request) (struct net_device * dev,
				     struct ieee80211_probe_request * req,
				     struct ieee80211_rx_stats * stats);
1118 1119 1120 1121 1122 1123 1124 1125
	int (*handle_assoc_response) (struct net_device * dev,
				      struct ieee80211_assoc_response * resp,
				      struct ieee80211_network * network);

	/* Typical AP methods */
	int (*handle_assoc_request) (struct net_device * dev);
	int (*handle_reassoc_request) (struct net_device * dev,
				       struct ieee80211_reassoc_request * req);
J
Jeff Garzik 已提交
1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136

	/* This must be the last item so that it points to the data
	 * allocated beyond this structure by alloc_ieee80211 */
	u8 priv[0];
};

#define IEEE_A            (1<<0)
#define IEEE_B            (1<<1)
#define IEEE_G            (1<<2)
#define IEEE_MODE_MASK    (IEEE_A|IEEE_B|IEEE_G)

1137
static inline void *ieee80211_priv(struct net_device *dev)
J
Jeff Garzik 已提交
1138 1139 1140 1141
{
	return ((struct ieee80211_device *)netdev_priv(dev))->priv;
}

1142
static inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
J
Jeff Garzik 已提交
1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157
{
	/* Single white space is for Linksys APs */
	if (essid_len == 1 && essid[0] == ' ')
		return 1;

	/* Otherwise, if the entire essid is 0, we assume it is hidden */
	while (essid_len) {
		essid_len--;
		if (essid[essid_len] != '\0')
			return 0;
	}

	return 1;
}

1158
static inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee,
1159
					  int mode)
J
Jeff Garzik 已提交
1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184
{
	/*
	 * It is possible for both access points and our device to support
	 * combinations of modes, so as long as there is one valid combination
	 * of ap/device supported modes, then return success
	 *
	 */
	if ((mode & IEEE_A) &&
	    (ieee->modulation & IEEE80211_OFDM_MODULATION) &&
	    (ieee->freq_band & IEEE80211_52GHZ_BAND))
		return 1;

	if ((mode & IEEE_G) &&
	    (ieee->modulation & IEEE80211_OFDM_MODULATION) &&
	    (ieee->freq_band & IEEE80211_24GHZ_BAND))
		return 1;

	if ((mode & IEEE_B) &&
	    (ieee->modulation & IEEE80211_CCK_MODULATION) &&
	    (ieee->freq_band & IEEE80211_24GHZ_BAND))
		return 1;

	return 0;
}

1185
static inline int ieee80211_get_hdrlen(u16 fc)
J
Jeff Garzik 已提交
1186
{
J
Jiri Benc 已提交
1187
	int hdrlen = IEEE80211_3ADDR_LEN;
1188
	u16 stype = WLAN_FC_GET_STYPE(fc);
J
Jeff Garzik 已提交
1189 1190 1191 1192

	switch (WLAN_FC_GET_TYPE(fc)) {
	case IEEE80211_FTYPE_DATA:
		if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
J
Jiri Benc 已提交
1193
			hdrlen = IEEE80211_4ADDR_LEN;
1194 1195
		if (stype & IEEE80211_STYPE_QOS_DATA)
			hdrlen += 2;
J
Jeff Garzik 已提交
1196 1197 1198 1199 1200
		break;
	case IEEE80211_FTYPE_CTL:
		switch (WLAN_FC_GET_STYPE(fc)) {
		case IEEE80211_STYPE_CTS:
		case IEEE80211_STYPE_ACK:
J
Jiri Benc 已提交
1201
			hdrlen = IEEE80211_1ADDR_LEN;
J
Jeff Garzik 已提交
1202 1203
			break;
		default:
J
Jiri Benc 已提交
1204
			hdrlen = IEEE80211_2ADDR_LEN;
J
Jeff Garzik 已提交
1205 1206 1207 1208 1209 1210 1211 1212
			break;
		}
		break;
	}

	return hdrlen;
}

1213
static inline u8 *ieee80211_get_payload(struct ieee80211_hdr *hdr)
1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224
{
	switch (ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl))) {
	case IEEE80211_1ADDR_LEN:
		return ((struct ieee80211_hdr_1addr *)hdr)->payload;
	case IEEE80211_2ADDR_LEN:
		return ((struct ieee80211_hdr_2addr *)hdr)->payload;
	case IEEE80211_3ADDR_LEN:
		return ((struct ieee80211_hdr_3addr *)hdr)->payload;
	case IEEE80211_4ADDR_LEN:
		return ((struct ieee80211_hdr_4addr *)hdr)->payload;
	}
1225
	return NULL;
1226 1227
}

1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255
static inline int ieee80211_is_ofdm_rate(u8 rate)
{
	switch (rate & ~IEEE80211_BASIC_RATE_MASK) {
	case IEEE80211_OFDM_RATE_6MB:
	case IEEE80211_OFDM_RATE_9MB:
	case IEEE80211_OFDM_RATE_12MB:
	case IEEE80211_OFDM_RATE_18MB:
	case IEEE80211_OFDM_RATE_24MB:
	case IEEE80211_OFDM_RATE_36MB:
	case IEEE80211_OFDM_RATE_48MB:
	case IEEE80211_OFDM_RATE_54MB:
		return 1;
	}
	return 0;
}

static inline int ieee80211_is_cck_rate(u8 rate)
{
	switch (rate & ~IEEE80211_BASIC_RATE_MASK) {
	case IEEE80211_CCK_RATE_1MB:
	case IEEE80211_CCK_RATE_2MB:
	case IEEE80211_CCK_RATE_5MB:
	case IEEE80211_CCK_RATE_11MB:
		return 1;
	}
	return 0;
}

J
Jeff Garzik 已提交
1256 1257 1258 1259 1260 1261 1262
/* ieee80211.c */
extern void free_ieee80211(struct net_device *dev);
extern struct net_device *alloc_ieee80211(int sizeof_priv);

extern int ieee80211_set_encryption(struct ieee80211_device *ieee);

/* ieee80211_tx.c */
1263
extern int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev);
J
Jeff Garzik 已提交
1264 1265 1266
extern void ieee80211_txb_free(struct ieee80211_txb *);

/* ieee80211_rx.c */
1267 1268
extern void ieee80211_rx_any(struct ieee80211_device *ieee,
		     struct sk_buff *skb, struct ieee80211_rx_stats *stats);
J
Jeff Garzik 已提交
1269 1270
extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
			struct ieee80211_rx_stats *rx_stats);
1271
/* make sure to set stats->len */
J
Jeff Garzik 已提交
1272
extern void ieee80211_rx_mgt(struct ieee80211_device *ieee,
1273
			     struct ieee80211_hdr_4addr *header,
J
Jeff Garzik 已提交
1274
			     struct ieee80211_rx_stats *stats);
1275
extern void ieee80211_network_reset(struct ieee80211_network *network);
J
Jeff Garzik 已提交
1276

1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287
/* ieee80211_geo.c */
extern const struct ieee80211_geo *ieee80211_get_geo(struct ieee80211_device
						     *ieee);
extern int ieee80211_set_geo(struct ieee80211_device *ieee,
			     const struct ieee80211_geo *geo);

extern int ieee80211_is_valid_channel(struct ieee80211_device *ieee,
				      u8 channel);
extern int ieee80211_channel_to_index(struct ieee80211_device *ieee,
				      u8 channel);
extern u8 ieee80211_freq_to_channel(struct ieee80211_device *ieee, u32 freq);
1288 1289 1290 1291 1292
extern u8 ieee80211_get_channel_flags(struct ieee80211_device *ieee,
				      u8 channel);
extern const struct ieee80211_channel *ieee80211_get_channel(struct
							     ieee80211_device
							     *ieee, u8 channel);
1293 1294
extern u32 ieee80211_channel_to_freq(struct ieee80211_device * ieee,
				      u8 channel);
1295

J
Jiri Benc 已提交
1296
/* ieee80211_wx.c */
J
Jeff Garzik 已提交
1297 1298 1299 1300 1301 1302 1303 1304 1305
extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
				 struct iw_request_info *info,
				 union iwreq_data *wrqu, char *key);
extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
				   struct iw_request_info *info,
				   union iwreq_data *wrqu, char *key);
extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
				   struct iw_request_info *info,
				   union iwreq_data *wrqu, char *key);
1306 1307 1308 1309 1310 1311
extern int ieee80211_wx_set_encodeext(struct ieee80211_device *ieee,
				      struct iw_request_info *info,
				      union iwreq_data *wrqu, char *extra);
extern int ieee80211_wx_get_encodeext(struct ieee80211_device *ieee,
				      struct iw_request_info *info,
				      union iwreq_data *wrqu, char *extra);
J
Jeff Garzik 已提交
1312

1313
static inline void ieee80211_increment_scans(struct ieee80211_device *ieee)
J
Jeff Garzik 已提交
1314 1315 1316 1317
{
	ieee->scans++;
}

1318
static inline int ieee80211_get_scans(struct ieee80211_device *ieee)
J
Jeff Garzik 已提交
1319 1320 1321 1322
{
	return ieee->scans;
}

1323
#endif				/* IEEE80211_H */