1/* 2 * Merged with mainline ieee80211.h in Aug 2004. Original ieee802_11 3 * remains copyright by the original authors 4 * 5 * Portions of the merged code are based on Host AP (software wireless 6 * LAN access point) driver for Intersil Prism2/2.5/3. 7 * 8 * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen 9 * <j@w1.fi> 10 * Copyright (c) 2002-2003, Jouni Malinen <j@w1.fi> 11 * 12 * Adaption to a generic IEEE 802.11 stack by James Ketrenos 13 * <jketreno@linux.intel.com> 14 * Copyright (c) 2004-2005, Intel Corporation 15 * 16 * This program is free software; you can redistribute it and/or modify 17 * it under the terms of the GNU General Public License version 2 as 18 * published by the Free Software Foundation. See README and COPYING for 19 * more details. 20 * 21 * API Version History 22 * 1.0.x -- Initial version 23 * 1.1.x -- Added radiotap, QoS, TIM, ieee80211_geo APIs, 24 * various structure changes, and crypto API init method 25 */ 26#ifndef IEEE80211_H 27#define IEEE80211_H 28#include <linux/if_ether.h> /* ETH_ALEN */ 29#include <linux/kernel.h> /* ARRAY_SIZE */ 30#include <linux/wireless.h> 31 32#define IEEE80211_VERSION "git-1.1.13" 33 34#define IEEE80211_DATA_LEN 2304 35/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section 36 6.2.1.1.2. 37 38 The figure in section 7.1.2 suggests a body size of up to 2312 39 bytes is allowed, which is a bit confusing, I suspect this 40 represents the 2304 bytes of real data, plus a possible 8 bytes of 41 WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */ 42 43#define IEEE80211_1ADDR_LEN 10 44#define IEEE80211_2ADDR_LEN 16 45#define IEEE80211_3ADDR_LEN 24 46#define IEEE80211_4ADDR_LEN 30 47#define IEEE80211_FCS_LEN 4 48#define IEEE80211_HLEN (IEEE80211_4ADDR_LEN) 49#define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN) 50 51#define MIN_FRAG_THRESHOLD 256U 52#define MAX_FRAG_THRESHOLD 2346U 53 54/* Frame control field constants */ 55#define IEEE80211_FCTL_VERS 0x0003 56#define IEEE80211_FCTL_FTYPE 0x000c 57#define IEEE80211_FCTL_STYPE 0x00f0 58#define IEEE80211_FCTL_TODS 0x0100 59#define IEEE80211_FCTL_FROMDS 0x0200 60#define IEEE80211_FCTL_MOREFRAGS 0x0400 61#define IEEE80211_FCTL_RETRY 0x0800 62#define IEEE80211_FCTL_PM 0x1000 63#define IEEE80211_FCTL_MOREDATA 0x2000 64#define IEEE80211_FCTL_PROTECTED 0x4000 65#define IEEE80211_FCTL_ORDER 0x8000 66 67#define IEEE80211_FTYPE_MGMT 0x0000 68#define IEEE80211_FTYPE_CTL 0x0004 69#define IEEE80211_FTYPE_DATA 0x0008 70 71/* management */ 72#define IEEE80211_STYPE_ASSOC_REQ 0x0000 73#define IEEE80211_STYPE_ASSOC_RESP 0x0010 74#define IEEE80211_STYPE_REASSOC_REQ 0x0020 75#define IEEE80211_STYPE_REASSOC_RESP 0x0030 76#define IEEE80211_STYPE_PROBE_REQ 0x0040 77#define IEEE80211_STYPE_PROBE_RESP 0x0050 78#define IEEE80211_STYPE_BEACON 0x0080 79#define IEEE80211_STYPE_ATIM 0x0090 80#define IEEE80211_STYPE_DISASSOC 0x00A0 81#define IEEE80211_STYPE_AUTH 0x00B0 82#define IEEE80211_STYPE_DEAUTH 0x00C0 83#define IEEE80211_STYPE_ACTION 0x00D0 84 85/* control */ 86#define IEEE80211_STYPE_PSPOLL 0x00A0 87#define IEEE80211_STYPE_RTS 0x00B0 88#define IEEE80211_STYPE_CTS 0x00C0 89#define IEEE80211_STYPE_ACK 0x00D0 90#define IEEE80211_STYPE_CFEND 0x00E0 91#define IEEE80211_STYPE_CFENDACK 0x00F0 92 93/* data */ 94#define IEEE80211_STYPE_DATA 0x0000 95#define IEEE80211_STYPE_DATA_CFACK 0x0010 96#define IEEE80211_STYPE_DATA_CFPOLL 0x0020 97#define IEEE80211_STYPE_DATA_CFACKPOLL 0x0030 98#define IEEE80211_STYPE_NULLFUNC 0x0040 99#define IEEE80211_STYPE_CFACK 0x0050 100#define IEEE80211_STYPE_CFPOLL 0x0060 101#define IEEE80211_STYPE_CFACKPOLL 0x0070 102#define IEEE80211_STYPE_QOS_DATA 0x0080 103 104#define IEEE80211_SCTL_FRAG 0x000F 105#define IEEE80211_SCTL_SEQ 0xFFF0 106 107/* QOS control */ 108#define IEEE80211_QCTL_TID 0x000F 109 110/* debug macros */ 111 112#ifdef CONFIG_IEEE80211_DEBUG 113extern u32 ieee80211_debug_level; 114#define IEEE80211_DEBUG(level, fmt, args...) \ 115do { if (ieee80211_debug_level & (level)) \ 116 printk(KERN_DEBUG "ieee80211: %c %s " fmt, \ 117 in_interrupt() ? 'I' : 'U', __FUNCTION__ , ## args); } while (0) 118#else 119#define IEEE80211_DEBUG(level, fmt, args...) do {} while (0) 120#endif /* CONFIG_IEEE80211_DEBUG */ 121 122/* debug macros not dependent on CONFIG_IEEE80211_DEBUG */ 123 124#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x" 125#define MAC_ARG(x) ((u8*)(x))[0],((u8*)(x))[1],((u8*)(x))[2],((u8*)(x))[3],((u8*)(x))[4],((u8*)(x))[5] 126 127/* escape_essid() is intended to be used in debug (and possibly error) 128 * messages. It should never be used for passing essid to user space. */ 129const char *escape_essid(const char *essid, u8 essid_len); 130 131 132#define IEEE80211_DL_INFO (1<<0) 133#define IEEE80211_DL_WX (1<<1) 134#define IEEE80211_DL_SCAN (1<<2) 135#define IEEE80211_DL_STATE (1<<3) 136#define IEEE80211_DL_MGMT (1<<4) 137#define IEEE80211_DL_FRAG (1<<5) 138#define IEEE80211_DL_DROP (1<<7) 139 140#define IEEE80211_DL_TX (1<<8) 141#define IEEE80211_DL_RX (1<<9) 142#define IEEE80211_DL_QOS (1<<31) 143 144#define IEEE80211_ERROR(f, a...) printk(KERN_ERR "ieee80211: " f, ## a) 145#define IEEE80211_WARNING(f, a...) printk(KERN_WARNING "ieee80211: " f, ## a) 146#define IEEE80211_DEBUG_INFO(f, a...) IEEE80211_DEBUG(IEEE80211_DL_INFO, f, ## a) 147 148#define IEEE80211_DEBUG_WX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_WX, f, ## a) 149#define IEEE80211_DEBUG_SCAN(f, a...) IEEE80211_DEBUG(IEEE80211_DL_SCAN, f, ## a) 150#define IEEE80211_DEBUG_STATE(f, a...) IEEE80211_DEBUG(IEEE80211_DL_STATE, f, ## a) 151#define IEEE80211_DEBUG_MGMT(f, a...) IEEE80211_DEBUG(IEEE80211_DL_MGMT, f, ## a) 152#define IEEE80211_DEBUG_FRAG(f, a...) IEEE80211_DEBUG(IEEE80211_DL_FRAG, f, ## a) 153#define IEEE80211_DEBUG_DROP(f, a...) IEEE80211_DEBUG(IEEE80211_DL_DROP, f, ## a) 154#define IEEE80211_DEBUG_TX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_TX, f, ## a) 155#define IEEE80211_DEBUG_RX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_RX, f, ## a) 156#define IEEE80211_DEBUG_QOS(f, a...) IEEE80211_DEBUG(IEEE80211_DL_QOS, f, ## a) 157#include <linux/netdevice.h> 158#include <linux/wireless.h> 159#include <linux/if_arp.h> /* ARPHRD_ETHER */ 160 161#ifndef WIRELESS_SPY 162#define WIRELESS_SPY /* enable iwspy support */ 163#endif 164#include <net/iw_handler.h> /* new driver API */ 165 166#ifndef ETH_P_PAE 167#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */ 168#endif /* ETH_P_PAE */ 169 170#define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */ 171 172#ifndef ETH_P_80211_RAW 173#define ETH_P_80211_RAW (ETH_P_ECONET + 1) 174#endif 175 176/* IEEE 802.11 defines */ 177 178#define P80211_OUI_LEN 3 179 180struct ieee80211_snap_hdr { 181 182 u8 dsap; /* always 0xAA */ 183 u8 ssap; /* always 0xAA */ 184 u8 ctrl; /* always 0x03 */ 185 u8 oui[P80211_OUI_LEN]; /* organizational universal id */ 186 187} __attribute__ ((packed)); 188 189#define SNAP_SIZE sizeof(struct ieee80211_snap_hdr) 190 191#define WLAN_FC_GET_VERS(fc) ((fc) & IEEE80211_FCTL_VERS) 192#define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE) 193#define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE) 194 195#define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG) 196#define WLAN_GET_SEQ_SEQ(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4) 197 198/* Authentication algorithms */ 199#define WLAN_AUTH_OPEN 0 200#define WLAN_AUTH_SHARED_KEY 1 201#define WLAN_AUTH_LEAP 2 202 203#define WLAN_AUTH_CHALLENGE_LEN 128 204 205#define WLAN_CAPABILITY_ESS (1<<0) 206#define WLAN_CAPABILITY_IBSS (1<<1) 207#define WLAN_CAPABILITY_CF_POLLABLE (1<<2) 208#define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3) 209#define WLAN_CAPABILITY_PRIVACY (1<<4) 210#define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5) 211#define WLAN_CAPABILITY_PBCC (1<<6) 212#define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7) 213#define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8) 214#define WLAN_CAPABILITY_QOS (1<<9) 215#define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10) 216#define WLAN_CAPABILITY_DSSS_OFDM (1<<13) 217 218/* 802.11g ERP information element */ 219#define WLAN_ERP_NON_ERP_PRESENT (1<<0) 220#define WLAN_ERP_USE_PROTECTION (1<<1) 221#define WLAN_ERP_BARKER_PREAMBLE (1<<2) 222 223/* Status codes */ 224enum ieee80211_statuscode { 225 WLAN_STATUS_SUCCESS = 0, 226 WLAN_STATUS_UNSPECIFIED_FAILURE = 1, 227 WLAN_STATUS_CAPS_UNSUPPORTED = 10, 228 WLAN_STATUS_REASSOC_NO_ASSOC = 11, 229 WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12, 230 WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13, 231 WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14, 232 WLAN_STATUS_CHALLENGE_FAIL = 15, 233 WLAN_STATUS_AUTH_TIMEOUT = 16, 234 WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17, 235 WLAN_STATUS_ASSOC_DENIED_RATES = 18, 236 /* 802.11b */ 237 WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19, 238 WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20, 239 WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21, 240 /* 802.11h */ 241 WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22, 242 WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23, 243 WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24, 244 /* 802.11g */ 245 WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25, 246 WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26, 247 /* 802.11i */ 248 WLAN_STATUS_INVALID_IE = 40, 249 WLAN_STATUS_INVALID_GROUP_CIPHER = 41, 250 WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42, 251 WLAN_STATUS_INVALID_AKMP = 43, 252 WLAN_STATUS_UNSUPP_RSN_VERSION = 44, 253 WLAN_STATUS_INVALID_RSN_IE_CAP = 45, 254 WLAN_STATUS_CIPHER_SUITE_REJECTED = 46, 255}; 256 257/* Reason codes */ 258enum ieee80211_reasoncode { 259 WLAN_REASON_UNSPECIFIED = 1, 260 WLAN_REASON_PREV_AUTH_NOT_VALID = 2, 261 WLAN_REASON_DEAUTH_LEAVING = 3, 262 WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4, 263 WLAN_REASON_DISASSOC_AP_BUSY = 5, 264 WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6, 265 WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7, 266 WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8, 267 WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9, 268 /* 802.11h */ 269 WLAN_REASON_DISASSOC_BAD_POWER = 10, 270 WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11, 271 /* 802.11i */ 272 WLAN_REASON_INVALID_IE = 13, 273 WLAN_REASON_MIC_FAILURE = 14, 274 WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15, 275 WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16, 276 WLAN_REASON_IE_DIFFERENT = 17, 277 WLAN_REASON_INVALID_GROUP_CIPHER = 18, 278 WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19, 279 WLAN_REASON_INVALID_AKMP = 20, 280 WLAN_REASON_UNSUPP_RSN_VERSION = 21, 281 WLAN_REASON_INVALID_RSN_IE_CAP = 22, 282 WLAN_REASON_IEEE8021X_FAILED = 23, 283 WLAN_REASON_CIPHER_SUITE_REJECTED = 24, 284}; 285 286/* Action categories - 802.11h */ 287enum ieee80211_actioncategories { 288 WLAN_ACTION_SPECTRUM_MGMT = 0, 289 /* Reserved 1-127 */ 290 /* Error 128-255 */ 291}; 292 293/* Action details - 802.11h */ 294enum ieee80211_actiondetails { 295 WLAN_ACTION_CATEGORY_MEASURE_REQUEST = 0, 296 WLAN_ACTION_CATEGORY_MEASURE_REPORT = 1, 297 WLAN_ACTION_CATEGORY_TPC_REQUEST = 2, 298 WLAN_ACTION_CATEGORY_TPC_REPORT = 3, 299 WLAN_ACTION_CATEGORY_CHANNEL_SWITCH = 4, 300 /* 5 - 255 Reserved */ 301}; 302 303#define IEEE80211_STATMASK_SIGNAL (1<<0) 304#define IEEE80211_STATMASK_RSSI (1<<1) 305#define IEEE80211_STATMASK_NOISE (1<<2) 306#define IEEE80211_STATMASK_RATE (1<<3) 307#define IEEE80211_STATMASK_WEMASK 0x7 308 309#define IEEE80211_CCK_MODULATION (1<<0) 310#define IEEE80211_OFDM_MODULATION (1<<1) 311 312#define IEEE80211_24GHZ_BAND (1<<0) 313#define IEEE80211_52GHZ_BAND (1<<1) 314 315#define IEEE80211_CCK_RATE_1MB 0x02 316#define IEEE80211_CCK_RATE_2MB 0x04 317#define IEEE80211_CCK_RATE_5MB 0x0B 318#define IEEE80211_CCK_RATE_11MB 0x16 319#define IEEE80211_OFDM_RATE_6MB 0x0C 320#define IEEE80211_OFDM_RATE_9MB 0x12 321#define IEEE80211_OFDM_RATE_12MB 0x18 322#define IEEE80211_OFDM_RATE_18MB 0x24 323#define IEEE80211_OFDM_RATE_24MB 0x30 324#define IEEE80211_OFDM_RATE_36MB 0x48 325#define IEEE80211_OFDM_RATE_48MB 0x60 326#define IEEE80211_OFDM_RATE_54MB 0x6C 327#define IEEE80211_BASIC_RATE_MASK 0x80 328 329#define IEEE80211_CCK_RATE_1MB_MASK (1<<0) 330#define IEEE80211_CCK_RATE_2MB_MASK (1<<1) 331#define IEEE80211_CCK_RATE_5MB_MASK (1<<2) 332#define IEEE80211_CCK_RATE_11MB_MASK (1<<3) 333#define IEEE80211_OFDM_RATE_6MB_MASK (1<<4) 334#define IEEE80211_OFDM_RATE_9MB_MASK (1<<5) 335#define IEEE80211_OFDM_RATE_12MB_MASK (1<<6) 336#define IEEE80211_OFDM_RATE_18MB_MASK (1<<7) 337#define IEEE80211_OFDM_RATE_24MB_MASK (1<<8) 338#define IEEE80211_OFDM_RATE_36MB_MASK (1<<9) 339#define IEEE80211_OFDM_RATE_48MB_MASK (1<<10) 340#define IEEE80211_OFDM_RATE_54MB_MASK (1<<11) 341 342#define IEEE80211_CCK_RATES_MASK 0x0000000F 343#define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \ 344 IEEE80211_CCK_RATE_2MB_MASK) 345#define IEEE80211_CCK_DEFAULT_RATES_MASK (IEEE80211_CCK_BASIC_RATES_MASK | \ 346 IEEE80211_CCK_RATE_5MB_MASK | \ 347 IEEE80211_CCK_RATE_11MB_MASK) 348 349#define IEEE80211_OFDM_RATES_MASK 0x00000FF0 350#define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \ 351 IEEE80211_OFDM_RATE_12MB_MASK | \ 352 IEEE80211_OFDM_RATE_24MB_MASK) 353#define IEEE80211_OFDM_DEFAULT_RATES_MASK (IEEE80211_OFDM_BASIC_RATES_MASK | \ 354 IEEE80211_OFDM_RATE_9MB_MASK | \ 355 IEEE80211_OFDM_RATE_18MB_MASK | \ 356 IEEE80211_OFDM_RATE_36MB_MASK | \ 357 IEEE80211_OFDM_RATE_48MB_MASK | \ 358 IEEE80211_OFDM_RATE_54MB_MASK) 359#define IEEE80211_DEFAULT_RATES_MASK (IEEE80211_OFDM_DEFAULT_RATES_MASK | \ 360 IEEE80211_CCK_DEFAULT_RATES_MASK) 361 362#define IEEE80211_NUM_OFDM_RATES 8 363#define IEEE80211_NUM_CCK_RATES 4 364#define IEEE80211_OFDM_SHIFT_MASK_A 4 365 366/* NOTE: This data is for statistical purposes; not all hardware provides this 367 * information for frames received. 368 * For ieee80211_rx_mgt, you need to set at least the 'len' parameter. 369 */ 370struct ieee80211_rx_stats { 371 u32 mac_time; 372 s8 rssi; 373 u8 signal; 374 u8 noise; 375 u16 rate; /* in 100 kbps */ 376 u8 received_channel; 377 u8 control; 378 u8 mask; 379 u8 freq; 380 u16 len; 381 u64 tsf; 382 u32 beacon_time; 383}; 384 385/* IEEE 802.11 requires that STA supports concurrent reception of at least 386 * three fragmented frames. This define can be increased to support more 387 * concurrent frames, but it should be noted that each entry can consume about 388 * 2 kB of RAM and increasing cache size will slow down frame reassembly. */ 389#define IEEE80211_FRAG_CACHE_LEN 4 390 391struct ieee80211_frag_entry { 392 unsigned long first_frag_time; 393 unsigned int seq; 394 unsigned int last_frag; 395 struct sk_buff *skb; 396 u8 src_addr[ETH_ALEN]; 397 u8 dst_addr[ETH_ALEN]; 398}; 399 400struct ieee80211_stats { 401 unsigned int tx_unicast_frames; 402 unsigned int tx_multicast_frames; 403 unsigned int tx_fragments; 404 unsigned int tx_unicast_octets; 405 unsigned int tx_multicast_octets; 406 unsigned int tx_deferred_transmissions; 407 unsigned int tx_single_retry_frames; 408 unsigned int tx_multiple_retry_frames; 409 unsigned int tx_retry_limit_exceeded; 410 unsigned int tx_discards; 411 unsigned int rx_unicast_frames; 412 unsigned int rx_multicast_frames; 413 unsigned int rx_fragments; 414 unsigned int rx_unicast_octets; 415 unsigned int rx_multicast_octets; 416 unsigned int rx_fcs_errors; 417 unsigned int rx_discards_no_buffer; 418 unsigned int tx_discards_wrong_sa; 419 unsigned int rx_discards_undecryptable; 420 unsigned int rx_message_in_msg_fragments; 421 unsigned int rx_message_in_bad_msg_fragments; 422}; 423 424struct ieee80211_device; 425 426#include "ieee80211_crypt.h" 427 428#define SEC_KEY_1 (1<<0) 429#define SEC_KEY_2 (1<<1) 430#define SEC_KEY_3 (1<<2) 431#define SEC_KEY_4 (1<<3) 432#define SEC_ACTIVE_KEY (1<<4) 433#define SEC_AUTH_MODE (1<<5) 434#define SEC_UNICAST_GROUP (1<<6) 435#define SEC_LEVEL (1<<7) 436#define SEC_ENABLED (1<<8) 437#define SEC_ENCRYPT (1<<9) 438 439#define SEC_LEVEL_0 0 /* None */ 440#define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */ 441#define SEC_LEVEL_2 2 /* Level 1 + TKIP */ 442#define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */ 443#define SEC_LEVEL_3 4 /* Level 2 + CCMP */ 444 445#define SEC_ALG_NONE 0 446#define SEC_ALG_WEP 1 447#define SEC_ALG_TKIP 2 448#define SEC_ALG_CCMP 3 449 450#define WEP_KEYS 4 451#define WEP_KEY_LEN 13 452#define SCM_KEY_LEN 32 453#define SCM_TEMPORAL_KEY_LENGTH 16 454 455struct ieee80211_security { 456 u16 active_key:2, 457 enabled:1, 458 auth_mode:2, auth_algo:4, unicast_uses_group:1, encrypt:1; 459 u8 encode_alg[WEP_KEYS]; 460 u8 key_sizes[WEP_KEYS]; 461 u8 keys[WEP_KEYS][SCM_KEY_LEN]; 462 u8 level; 463 u16 flags; 464} __attribute__ ((packed)); 465 466/* 467 468 802.11 data frame from AP 469 470 ,-------------------------------------------------------------------. 471Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 | 472 |------|------|---------|---------|---------|------|---------|------| 473Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs | 474 | | tion | (BSSID) | | | ence | data | | 475 `-------------------------------------------------------------------' 476 477Total: 28-2340 bytes 478 479*/ 480 481#define BEACON_PROBE_SSID_ID_POSITION 12 482 483/* Management Frame Information Element Types */ 484enum ieee80211_mfie { 485 MFIE_TYPE_SSID = 0, 486 MFIE_TYPE_RATES = 1, 487 MFIE_TYPE_FH_SET = 2, 488 MFIE_TYPE_DS_SET = 3, 489 MFIE_TYPE_CF_SET = 4, 490 MFIE_TYPE_TIM = 5, 491 MFIE_TYPE_IBSS_SET = 6, 492 MFIE_TYPE_COUNTRY = 7, 493 MFIE_TYPE_HOP_PARAMS = 8, 494 MFIE_TYPE_HOP_TABLE = 9, 495 MFIE_TYPE_REQUEST = 10, 496 MFIE_TYPE_CHALLENGE = 16, 497 MFIE_TYPE_POWER_CONSTRAINT = 32, 498 MFIE_TYPE_POWER_CAPABILITY = 33, 499 MFIE_TYPE_TPC_REQUEST = 34, 500 MFIE_TYPE_TPC_REPORT = 35, 501 MFIE_TYPE_SUPP_CHANNELS = 36, 502 MFIE_TYPE_CSA = 37, 503 MFIE_TYPE_MEASURE_REQUEST = 38, 504 MFIE_TYPE_MEASURE_REPORT = 39, 505 MFIE_TYPE_QUIET = 40, 506 MFIE_TYPE_IBSS_DFS = 41, 507 MFIE_TYPE_ERP_INFO = 42, 508 MFIE_TYPE_RSN = 48, 509 MFIE_TYPE_RATES_EX = 50, 510 MFIE_TYPE_GENERIC = 221, 511 MFIE_TYPE_QOS_PARAMETER = 222, 512}; 513 514/* Minimal header; can be used for passing 802.11 frames with sufficient 515 * information to determine what type of underlying data type is actually 516 * stored in the data. */ 517struct ieee80211_hdr { 518 __le16 frame_ctl; 519 __le16 duration_id; 520 u8 payload[0]; 521} __attribute__ ((packed)); 522 523struct ieee80211_hdr_1addr { 524 __le16 frame_ctl; 525 __le16 duration_id; 526 u8 addr1[ETH_ALEN]; 527 u8 payload[0]; 528} __attribute__ ((packed)); 529 530struct ieee80211_hdr_2addr { 531 __le16 frame_ctl; 532 __le16 duration_id; 533 u8 addr1[ETH_ALEN]; 534 u8 addr2[ETH_ALEN]; 535 u8 payload[0]; 536} __attribute__ ((packed)); 537 538struct ieee80211_hdr_3addr { 539 __le16 frame_ctl; 540 __le16 duration_id; 541 u8 addr1[ETH_ALEN]; 542 u8 addr2[ETH_ALEN]; 543 u8 addr3[ETH_ALEN]; 544 __le16 seq_ctl; 545 u8 payload[0]; 546} __attribute__ ((packed)); 547 548struct ieee80211_hdr_4addr { 549 __le16 frame_ctl; 550 __le16 duration_id; 551 u8 addr1[ETH_ALEN]; 552 u8 addr2[ETH_ALEN]; 553 u8 addr3[ETH_ALEN]; 554 __le16 seq_ctl; 555 u8 addr4[ETH_ALEN]; 556 u8 payload[0]; 557} __attribute__ ((packed)); 558 559struct ieee80211_hdr_3addrqos { 560 __le16 frame_ctl; 561 __le16 duration_id; 562 u8 addr1[ETH_ALEN]; 563 u8 addr2[ETH_ALEN]; 564 u8 addr3[ETH_ALEN]; 565 __le16 seq_ctl; 566 u8 payload[0]; 567 __le16 qos_ctl; 568} __attribute__ ((packed)); 569 570struct ieee80211_hdr_4addrqos { 571 __le16 frame_ctl; 572 __le16 duration_id; 573 u8 addr1[ETH_ALEN]; 574 u8 addr2[ETH_ALEN]; 575 u8 addr3[ETH_ALEN]; 576 __le16 seq_ctl; 577 u8 addr4[ETH_ALEN]; 578 u8 payload[0]; 579 __le16 qos_ctl; 580} __attribute__ ((packed)); 581 582struct ieee80211_info_element { 583 u8 id; 584 u8 len; 585 u8 data[0]; 586} __attribute__ ((packed)); 587 588/* 589 * These are the data types that can make up management packets 590 * 591 u16 auth_algorithm; 592 u16 auth_sequence; 593 u16 beacon_interval; 594 u16 capability; 595 u8 current_ap[ETH_ALEN]; 596 u16 listen_interval; 597 struct { 598 u16 association_id:14, reserved:2; 599 } __attribute__ ((packed)); 600 u32 time_stamp[2]; 601 u16 reason; 602 u16 status; 603*/ 604 605struct ieee80211_auth { 606 struct ieee80211_hdr_3addr header; 607 __le16 algorithm; 608 __le16 transaction; 609 __le16 status; 610 /* challenge */ 611 struct ieee80211_info_element info_element[0]; 612} __attribute__ ((packed)); 613 614struct ieee80211_channel_switch { 615 u8 id; 616 u8 len; 617 u8 mode; 618 u8 channel; 619 u8 count; 620} __attribute__ ((packed)); 621 622struct ieee80211_action { 623 struct ieee80211_hdr_3addr header; 624 u8 category; 625 u8 action; 626 union { 627 struct ieee80211_action_exchange { 628 u8 token; 629 struct ieee80211_info_element info_element[0]; 630 } exchange; 631 struct ieee80211_channel_switch channel_switch; 632 633 } format; 634} __attribute__ ((packed)); 635 636struct ieee80211_disassoc { 637 struct ieee80211_hdr_3addr header; 638 __le16 reason; 639} __attribute__ ((packed)); 640 641/* Alias deauth for disassoc */ 642#define ieee80211_deauth ieee80211_disassoc 643 644struct ieee80211_probe_request { 645 struct ieee80211_hdr_3addr header; 646 /* SSID, supported rates */ 647 struct ieee80211_info_element info_element[0]; 648} __attribute__ ((packed)); 649 650struct ieee80211_probe_response { 651 struct ieee80211_hdr_3addr header; 652 u32 time_stamp[2]; 653 __le16 beacon_interval; 654 __le16 capability; 655 /* SSID, supported rates, FH params, DS params, 656 * CF params, IBSS params, TIM (if beacon), RSN */ 657 struct ieee80211_info_element info_element[0]; 658} __attribute__ ((packed)); 659 660/* Alias beacon for probe_response */ 661#define ieee80211_beacon ieee80211_probe_response 662 663struct ieee80211_assoc_request { 664 struct ieee80211_hdr_3addr header; 665 __le16 capability; 666 __le16 listen_interval; 667 /* SSID, supported rates, RSN */ 668 struct ieee80211_info_element info_element[0]; 669} __attribute__ ((packed)); 670 671struct ieee80211_reassoc_request { 672 struct ieee80211_hdr_3addr header; 673 __le16 capability; 674 __le16 listen_interval; 675 u8 current_ap[ETH_ALEN]; 676 struct ieee80211_info_element info_element[0]; 677} __attribute__ ((packed)); 678 679struct ieee80211_assoc_response { 680 struct ieee80211_hdr_3addr header; 681 __le16 capability; 682 __le16 status; 683 __le16 aid; 684 /* supported rates */ 685 struct ieee80211_info_element info_element[0]; 686} __attribute__ ((packed)); 687 688struct ieee80211_txb { 689 u8 nr_frags; 690 u8 encrypted; 691 u8 rts_included; 692 u8 reserved; 693 __le16 frag_size; 694 __le16 payload_size; 695 struct sk_buff *fragments[0]; 696}; 697 698/* SWEEP TABLE ENTRIES NUMBER */ 699#define MAX_SWEEP_TAB_ENTRIES 42 700#define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7 701/* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs 702 * only use 8, and then use extended rates for the remaining supported 703 * rates. Other APs, however, stick all of their supported rates on the 704 * main rates information element... */ 705#define MAX_RATES_LENGTH ((u8)12) 706#define MAX_RATES_EX_LENGTH ((u8)16) 707#define MAX_NETWORK_COUNT 128 708 709#define CRC_LENGTH 4U 710 711#define MAX_WPA_IE_LEN 64 712 713#define NETWORK_EMPTY_ESSID (1<<0) 714#define NETWORK_HAS_OFDM (1<<1) 715#define NETWORK_HAS_CCK (1<<2) 716 717/* QoS structure */ 718#define NETWORK_HAS_QOS_PARAMETERS (1<<3) 719#define NETWORK_HAS_QOS_INFORMATION (1<<4) 720#define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \ 721 NETWORK_HAS_QOS_INFORMATION) 722 723/* 802.11h */ 724#define NETWORK_HAS_POWER_CONSTRAINT (1<<5) 725#define NETWORK_HAS_CSA (1<<6) 726#define NETWORK_HAS_QUIET (1<<7) 727#define NETWORK_HAS_IBSS_DFS (1<<8) 728#define NETWORK_HAS_TPC_REPORT (1<<9) 729 730#define NETWORK_HAS_ERP_VALUE (1<<10) 731 732#define QOS_QUEUE_NUM 4 733#define QOS_OUI_LEN 3 734#define QOS_OUI_TYPE 2 735#define QOS_ELEMENT_ID 221 736#define QOS_OUI_INFO_SUB_TYPE 0 737#define QOS_OUI_PARAM_SUB_TYPE 1 738#define QOS_VERSION_1 1 739#define QOS_AIFSN_MIN_VALUE 2 740 741struct ieee80211_qos_information_element { 742 u8 elementID; 743 u8 length; 744 u8 qui[QOS_OUI_LEN]; 745 u8 qui_type; 746 u8 qui_subtype; 747 u8 version; 748 u8 ac_info; 749} __attribute__ ((packed)); 750 751struct ieee80211_qos_ac_parameter { 752 u8 aci_aifsn; 753 u8 ecw_min_max; 754 __le16 tx_op_limit; 755} __attribute__ ((packed)); 756 757struct ieee80211_qos_parameter_info { 758 struct ieee80211_qos_information_element info_element; 759 u8 reserved; 760 struct ieee80211_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM]; 761} __attribute__ ((packed)); 762 763struct ieee80211_qos_parameters { 764 __le16 cw_min[QOS_QUEUE_NUM]; 765 __le16 cw_max[QOS_QUEUE_NUM]; 766 u8 aifs[QOS_QUEUE_NUM]; 767 u8 flag[QOS_QUEUE_NUM]; 768 __le16 tx_op_limit[QOS_QUEUE_NUM]; 769} __attribute__ ((packed)); 770 771struct ieee80211_qos_data { 772 struct ieee80211_qos_parameters parameters; 773 int active; 774 int supported; 775 u8 param_count; 776 u8 old_param_count; 777}; 778 779struct ieee80211_tim_parameters { 780 u8 tim_count; 781 u8 tim_period; 782} __attribute__ ((packed)); 783 784/*******************************************************/ 785 786enum { /* ieee80211_basic_report.map */ 787 IEEE80211_BASIC_MAP_BSS = (1 << 0), 788 IEEE80211_BASIC_MAP_OFDM = (1 << 1), 789 IEEE80211_BASIC_MAP_UNIDENTIFIED = (1 << 2), 790 IEEE80211_BASIC_MAP_RADAR = (1 << 3), 791 IEEE80211_BASIC_MAP_UNMEASURED = (1 << 4), 792 /* Bits 5-7 are reserved */ 793 794}; 795struct ieee80211_basic_report { 796 u8 channel; 797 __le64 start_time; 798 __le16 duration; 799 u8 map; 800} __attribute__ ((packed)); 801 802enum { /* ieee80211_measurement_request.mode */ 803 /* Bit 0 is reserved */ 804 IEEE80211_MEASUREMENT_ENABLE = (1 << 1), 805 IEEE80211_MEASUREMENT_REQUEST = (1 << 2), 806 IEEE80211_MEASUREMENT_REPORT = (1 << 3), 807 /* Bits 4-7 are reserved */ 808}; 809 810enum { 811 IEEE80211_REPORT_BASIC = 0, /* required */ 812 IEEE80211_REPORT_CCA = 1, /* optional */ 813 IEEE80211_REPORT_RPI = 2, /* optional */ 814 /* 3-255 reserved */ 815}; 816 817struct ieee80211_measurement_params { 818 u8 channel; 819 __le64 start_time; 820 __le16 duration; 821} __attribute__ ((packed)); 822 823struct ieee80211_measurement_request { 824 struct ieee80211_info_element ie; 825 u8 token; 826 u8 mode; 827 u8 type; 828 struct ieee80211_measurement_params params[0]; 829} __attribute__ ((packed)); 830 831struct ieee80211_measurement_report { 832 struct ieee80211_info_element ie; 833 u8 token; 834 u8 mode; 835 u8 type; 836 union { 837 struct ieee80211_basic_report basic[0]; 838 } u; 839} __attribute__ ((packed)); 840 841struct ieee80211_tpc_report { 842 u8 transmit_power; 843 u8 link_margin; 844} __attribute__ ((packed)); 845 846struct ieee80211_channel_map { 847 u8 channel; 848 u8 map; 849} __attribute__ ((packed)); 850 851struct ieee80211_ibss_dfs { 852 struct ieee80211_info_element ie; 853 u8 owner[ETH_ALEN]; 854 u8 recovery_interval; 855 struct ieee80211_channel_map channel_map[0]; 856}; 857 858struct ieee80211_csa { 859 u8 mode; 860 u8 channel; 861 u8 count; 862} __attribute__ ((packed)); 863 864struct ieee80211_quiet { 865 u8 count; 866 u8 period; 867 u8 duration; 868 u8 offset; 869} __attribute__ ((packed)); 870 871struct ieee80211_network { 872 /* These entries are used to identify a unique network */ 873 u8 bssid[ETH_ALEN]; 874 u8 channel; 875 /* Ensure null-terminated for any debug msgs */ 876 u8 ssid[IW_ESSID_MAX_SIZE + 1]; 877 u8 ssid_len; 878 879 struct ieee80211_qos_data qos_data; 880 881 /* These are network statistics */ 882 struct ieee80211_rx_stats stats; 883 u16 capability; 884 u8 rates[MAX_RATES_LENGTH]; 885 u8 rates_len; 886 u8 rates_ex[MAX_RATES_EX_LENGTH]; 887 u8 rates_ex_len; 888 unsigned long last_scanned; 889 u8 mode; 890 u32 flags; 891 u32 last_associate; 892 u32 time_stamp[2]; 893 u16 beacon_interval; 894 u16 listen_interval; 895 u16 atim_window; 896 u8 erp_value; 897 u8 wpa_ie[MAX_WPA_IE_LEN]; 898 size_t wpa_ie_len; 899 u8 rsn_ie[MAX_WPA_IE_LEN]; 900 size_t rsn_ie_len; 901 struct ieee80211_tim_parameters tim; 902 903 /* 802.11h info */ 904 905 /* Power Constraint - mandatory if spctrm mgmt required */ 906 u8 power_constraint; 907 908 /* TPC Report - mandatory if spctrm mgmt required */ 909 struct ieee80211_tpc_report tpc_report; 910 911 /* IBSS DFS - mandatory if spctrm mgmt required and IBSS 912 * NOTE: This is variable length and so must be allocated dynamically */ 913 struct ieee80211_ibss_dfs *ibss_dfs; 914 915 /* Channel Switch Announcement - optional if spctrm mgmt required */ 916 struct ieee80211_csa csa; 917 918 /* Quiet - optional if spctrm mgmt required */ 919 struct ieee80211_quiet quiet; 920 921 struct list_head list; 922}; 923 924enum ieee80211_state { 925 IEEE80211_UNINITIALIZED = 0, 926 IEEE80211_INITIALIZED, 927 IEEE80211_ASSOCIATING, 928 IEEE80211_ASSOCIATED, 929 IEEE80211_AUTHENTICATING, 930 IEEE80211_AUTHENTICATED, 931 IEEE80211_SHUTDOWN 932}; 933 934#define DEFAULT_MAX_SCAN_AGE (15 * HZ) 935#define DEFAULT_FTS 2346 936 937#define CFG_IEEE80211_RESERVE_FCS (1<<0) 938#define CFG_IEEE80211_COMPUTE_FCS (1<<1) 939#define CFG_IEEE80211_RTS (1<<2) 940 941#define IEEE80211_24GHZ_MIN_CHANNEL 1 942#define IEEE80211_24GHZ_MAX_CHANNEL 14 943#define IEEE80211_24GHZ_CHANNELS (IEEE80211_24GHZ_MAX_CHANNEL - \ 944 IEEE80211_24GHZ_MIN_CHANNEL + 1) 945 946#define IEEE80211_52GHZ_MIN_CHANNEL 34 947#define IEEE80211_52GHZ_MAX_CHANNEL 165 948#define IEEE80211_52GHZ_CHANNELS (IEEE80211_52GHZ_MAX_CHANNEL - \ 949 IEEE80211_52GHZ_MIN_CHANNEL + 1) 950 951enum { 952 IEEE80211_CH_PASSIVE_ONLY = (1 << 0), 953 IEEE80211_CH_80211H_RULES = (1 << 1), 954 IEEE80211_CH_B_ONLY = (1 << 2), 955 IEEE80211_CH_NO_IBSS = (1 << 3), 956 IEEE80211_CH_UNIFORM_SPREADING = (1 << 4), 957 IEEE80211_CH_RADAR_DETECT = (1 << 5), 958 IEEE80211_CH_INVALID = (1 << 6), 959}; 960 961struct ieee80211_channel { 962 u32 freq; /* in MHz */ 963 u8 channel; 964 u8 flags; 965 u8 max_power; /* in dBm */ 966}; 967 968struct ieee80211_geo { 969 u8 name[4]; 970 u8 bg_channels; 971 u8 a_channels; 972 struct ieee80211_channel bg[IEEE80211_24GHZ_CHANNELS]; 973 struct ieee80211_channel a[IEEE80211_52GHZ_CHANNELS]; 974}; 975 976struct ieee80211_device { 977 struct net_device *dev; 978 struct ieee80211_security sec; 979 980 /* Bookkeeping structures */ 981 struct net_device_stats stats; 982 struct ieee80211_stats ieee_stats; 983 984 struct ieee80211_geo geo; 985 986 /* Probe / Beacon management */ 987 struct list_head network_free_list; 988 struct list_head network_list; 989 struct ieee80211_network *networks; 990 int scans; 991 int scan_age; 992 993 int iw_mode; /* operating mode (IW_MODE_*) */ 994 struct iw_spy_data spy_data; /* iwspy support */ 995 996 spinlock_t lock; 997 998 int tx_headroom; /* Set to size of any additional room needed at front 999 * of allocated Tx SKBs */ 1000 u32 config; 1001 1002 /* WEP and other encryption related settings at the device level */ 1003 int open_wep; /* Set to 1 to allow unencrypted frames */ 1004 1005 int reset_on_keychange; /* Set to 1 if the HW needs to be reset on 1006 * WEP key changes */ 1007 1008 /* If the host performs {en,de}cryption, then set to 1 */ 1009 int host_encrypt; 1010 int host_encrypt_msdu; 1011 int host_decrypt; 1012 /* host performs multicast decryption */ 1013 int host_mc_decrypt; 1014 1015 /* host should strip IV and ICV from protected frames */ 1016 /* meaningful only when hardware decryption is being used */ 1017 int host_strip_iv_icv; 1018 1019 int host_open_frag; 1020 int host_build_iv; 1021 int ieee802_1x; /* is IEEE 802.1X used */ 1022 1023 /* WPA data */ 1024 int wpa_enabled; 1025 int drop_unencrypted; 1026 int privacy_invoked; 1027 size_t wpa_ie_len; 1028 u8 *wpa_ie; 1029 1030 struct list_head crypt_deinit_list; 1031 struct ieee80211_crypt_data *crypt[WEP_KEYS]; 1032 int tx_keyidx; /* default TX key index (crypt[tx_keyidx]) */ 1033 struct timer_list crypt_deinit_timer; 1034 int crypt_quiesced; 1035 1036 int bcrx_sta_key; /* use individual keys to override default keys even 1037 * with RX of broad/multicast frames */ 1038 1039 /* Fragmentation structures */ 1040 struct ieee80211_frag_entry frag_cache[IEEE80211_FRAG_CACHE_LEN]; 1041 unsigned int frag_next_idx; 1042 u16 fts; /* Fragmentation Threshold */ 1043 u16 rts; /* RTS threshold */ 1044 1045 /* Association info */ 1046 u8 bssid[ETH_ALEN]; 1047 1048 enum ieee80211_state state; 1049 1050 int mode; /* A, B, G */ 1051 int modulation; /* CCK, OFDM */ 1052 int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */ 1053 int abg_true; /* ABG flag */ 1054 1055 int perfect_rssi; 1056 int worst_rssi; 1057 1058 u16 prev_seq_ctl; /* used to drop duplicate frames */ 1059 1060 /* Callback functions */ 1061 void (*set_security) (struct net_device * dev, 1062 struct ieee80211_security * sec); 1063 int (*hard_start_xmit) (struct ieee80211_txb * txb, 1064 struct net_device * dev, int pri); 1065 int (*reset_port) (struct net_device * dev); 1066 int (*is_queue_full) (struct net_device * dev, int pri); 1067 1068 int (*handle_management) (struct net_device * dev, 1069 struct ieee80211_network * network, u16 type); 1070 int (*is_qos_active) (struct net_device *dev, struct sk_buff *skb); 1071 1072 /* Typical STA methods */ 1073 int (*handle_auth) (struct net_device * dev, 1074 struct ieee80211_auth * auth); 1075 int (*handle_deauth) (struct net_device * dev, 1076 struct ieee80211_deauth * auth); 1077 int (*handle_action) (struct net_device * dev, 1078 struct ieee80211_action * action, 1079 struct ieee80211_rx_stats * stats); 1080 int (*handle_disassoc) (struct net_device * dev, 1081 struct ieee80211_disassoc * assoc); 1082 int (*handle_beacon) (struct net_device * dev, 1083 struct ieee80211_beacon * beacon, 1084 struct ieee80211_network * network); 1085 int (*handle_probe_response) (struct net_device * dev, 1086 struct ieee80211_probe_response * resp, 1087 struct ieee80211_network * network); 1088 int (*handle_probe_request) (struct net_device * dev, 1089 struct ieee80211_probe_request * req, 1090 struct ieee80211_rx_stats * stats); 1091 int (*handle_assoc_response) (struct net_device * dev, 1092 struct ieee80211_assoc_response * resp, 1093 struct ieee80211_network * network); 1094 1095 /* Typical AP methods */ 1096 int (*handle_assoc_request) (struct net_device * dev); 1097 int (*handle_reassoc_request) (struct net_device * dev, 1098 struct ieee80211_reassoc_request * req); 1099 1100 /* This must be the last item so that it points to the data 1101 * allocated beyond this structure by alloc_ieee80211 */ 1102 u8 priv[0]; 1103}; 1104 1105#define IEEE_A (1<<0) 1106#define IEEE_B (1<<1) 1107#define IEEE_G (1<<2) 1108#define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G) 1109 1110static inline void *ieee80211_priv(struct net_device *dev) 1111{ 1112 return ((struct ieee80211_device *)netdev_priv(dev))->priv; 1113} 1114 1115static inline int ieee80211_is_empty_essid(const char *essid, int essid_len) 1116{ 1117 /* Single white space is for Linksys APs */ 1118 if (essid_len == 1 && essid[0] == ' ') 1119 return 1; 1120 1121 /* Otherwise, if the entire essid is 0, we assume it is hidden */ 1122 while (essid_len) { 1123 essid_len--; 1124 if (essid[essid_len] != '\0') 1125 return 0; 1126 } 1127 1128 return 1; 1129} 1130 1131static inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, 1132 int mode) 1133{ 1134 /* 1135 * It is possible for both access points and our device to support 1136 * combinations of modes, so as long as there is one valid combination 1137 * of ap/device supported modes, then return success 1138 * 1139 */ 1140 if ((mode & IEEE_A) && 1141 (ieee->modulation & IEEE80211_OFDM_MODULATION) && 1142 (ieee->freq_band & IEEE80211_52GHZ_BAND)) 1143 return 1; 1144 1145 if ((mode & IEEE_G) && 1146 (ieee->modulation & IEEE80211_OFDM_MODULATION) && 1147 (ieee->freq_band & IEEE80211_24GHZ_BAND)) 1148 return 1; 1149 1150 if ((mode & IEEE_B) && 1151 (ieee->modulation & IEEE80211_CCK_MODULATION) && 1152 (ieee->freq_band & IEEE80211_24GHZ_BAND)) 1153 return 1; 1154 1155 return 0; 1156} 1157 1158static inline int ieee80211_get_hdrlen(u16 fc) 1159{ 1160 int hdrlen = IEEE80211_3ADDR_LEN; 1161 u16 stype = WLAN_FC_GET_STYPE(fc); 1162 1163 switch (WLAN_FC_GET_TYPE(fc)) { 1164 case IEEE80211_FTYPE_DATA: 1165 if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS)) 1166 hdrlen = IEEE80211_4ADDR_LEN; 1167 if (stype & IEEE80211_STYPE_QOS_DATA) 1168 hdrlen += 2; 1169 break; 1170 case IEEE80211_FTYPE_CTL: 1171 switch (WLAN_FC_GET_STYPE(fc)) { 1172 case IEEE80211_STYPE_CTS: 1173 case IEEE80211_STYPE_ACK: 1174 hdrlen = IEEE80211_1ADDR_LEN; 1175 break; 1176 default: 1177 hdrlen = IEEE80211_2ADDR_LEN; 1178 break; 1179 } 1180 break; 1181 } 1182 1183 return hdrlen; 1184} 1185 1186static inline u8 *ieee80211_get_payload(struct ieee80211_hdr *hdr) 1187{ 1188 switch (ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl))) { 1189 case IEEE80211_1ADDR_LEN: 1190 return ((struct ieee80211_hdr_1addr *)hdr)->payload; 1191 case IEEE80211_2ADDR_LEN: 1192 return ((struct ieee80211_hdr_2addr *)hdr)->payload; 1193 case IEEE80211_3ADDR_LEN: 1194 return ((struct ieee80211_hdr_3addr *)hdr)->payload; 1195 case IEEE80211_4ADDR_LEN: 1196 return ((struct ieee80211_hdr_4addr *)hdr)->payload; 1197 } 1198 return NULL; 1199} 1200 1201static inline int ieee80211_is_ofdm_rate(u8 rate) 1202{ 1203 switch (rate & ~IEEE80211_BASIC_RATE_MASK) { 1204 case IEEE80211_OFDM_RATE_6MB: 1205 case IEEE80211_OFDM_RATE_9MB: 1206 case IEEE80211_OFDM_RATE_12MB: 1207 case IEEE80211_OFDM_RATE_18MB: 1208 case IEEE80211_OFDM_RATE_24MB: 1209 case IEEE80211_OFDM_RATE_36MB: 1210 case IEEE80211_OFDM_RATE_48MB: 1211 case IEEE80211_OFDM_RATE_54MB: 1212 return 1; 1213 } 1214 return 0; 1215} 1216 1217static inline int ieee80211_is_cck_rate(u8 rate) 1218{ 1219 switch (rate & ~IEEE80211_BASIC_RATE_MASK) { 1220 case IEEE80211_CCK_RATE_1MB: 1221 case IEEE80211_CCK_RATE_2MB: 1222 case IEEE80211_CCK_RATE_5MB: 1223 case IEEE80211_CCK_RATE_11MB: 1224 return 1; 1225 } 1226 return 0; 1227} 1228 1229/* ieee80211.c */ 1230extern void free_ieee80211(struct net_device *dev); 1231extern struct net_device *alloc_ieee80211(int sizeof_priv); 1232 1233extern int ieee80211_set_encryption(struct ieee80211_device *ieee); 1234 1235/* ieee80211_tx.c */ 1236extern int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev); 1237extern void ieee80211_txb_free(struct ieee80211_txb *); 1238extern int ieee80211_tx_frame(struct ieee80211_device *ieee, 1239 struct ieee80211_hdr *frame, int hdr_len, 1240 int total_len, int encrypt_mpdu); 1241 1242/* ieee80211_rx.c */ 1243extern void ieee80211_rx_any(struct ieee80211_device *ieee, 1244 struct sk_buff *skb, struct ieee80211_rx_stats *stats); 1245extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, 1246 struct ieee80211_rx_stats *rx_stats); 1247/* make sure to set stats->len */ 1248extern void ieee80211_rx_mgt(struct ieee80211_device *ieee, 1249 struct ieee80211_hdr_4addr *header, 1250 struct ieee80211_rx_stats *stats); 1251extern void ieee80211_network_reset(struct ieee80211_network *network); 1252 1253/* ieee80211_geo.c */ 1254extern const struct ieee80211_geo *ieee80211_get_geo(struct ieee80211_device 1255 *ieee); 1256extern int ieee80211_set_geo(struct ieee80211_device *ieee, 1257 const struct ieee80211_geo *geo); 1258 1259extern int ieee80211_is_valid_channel(struct ieee80211_device *ieee, 1260 u8 channel); 1261extern int ieee80211_channel_to_index(struct ieee80211_device *ieee, 1262 u8 channel); 1263extern u8 ieee80211_freq_to_channel(struct ieee80211_device *ieee, u32 freq); 1264extern u8 ieee80211_get_channel_flags(struct ieee80211_device *ieee, 1265 u8 channel); 1266extern const struct ieee80211_channel *ieee80211_get_channel(struct 1267 ieee80211_device 1268 *ieee, u8 channel); 1269extern u32 ieee80211_channel_to_freq(struct ieee80211_device * ieee, 1270 u8 channel); 1271 1272/* ieee80211_wx.c */ 1273extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee, 1274 struct iw_request_info *info, 1275 union iwreq_data *wrqu, char *key); 1276extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee, 1277 struct iw_request_info *info, 1278 union iwreq_data *wrqu, char *key); 1279extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee, 1280 struct iw_request_info *info, 1281 union iwreq_data *wrqu, char *key); 1282extern int ieee80211_wx_set_encodeext(struct ieee80211_device *ieee, 1283 struct iw_request_info *info, 1284 union iwreq_data *wrqu, char *extra); 1285extern int ieee80211_wx_get_encodeext(struct ieee80211_device *ieee, 1286 struct iw_request_info *info, 1287 union iwreq_data *wrqu, char *extra); 1288extern int ieee80211_wx_set_auth(struct net_device *dev, 1289 struct iw_request_info *info, 1290 union iwreq_data *wrqu, 1291 char *extra); 1292extern int ieee80211_wx_get_auth(struct net_device *dev, 1293 struct iw_request_info *info, 1294 union iwreq_data *wrqu, 1295 char *extra); 1296 1297static inline void ieee80211_increment_scans(struct ieee80211_device *ieee) 1298{ 1299 ieee->scans++; 1300} 1301 1302static inline int ieee80211_get_scans(struct ieee80211_device *ieee) 1303{ 1304 return ieee->scans; 1305} 1306 1307#endif /* IEEE80211_H */ 1308