diff options
author | xc151355 <none@none> | 2006-11-20 22:51:46 -0800 |
---|---|---|
committer | xc151355 <none@none> | 2006-11-20 22:51:46 -0800 |
commit | 0ba2cbe97e0678a691742f98d2532caed0a2c4aa (patch) | |
tree | 999e927888ff26967f593246afc931402e17b50e /usr/src/uts/common/sys | |
parent | 0c64a9b435314788e185507d40ef9fae71507f5a (diff) | |
download | illumos-joyent-0ba2cbe97e0678a691742f98d2532caed0a2c4aa.tar.gz |
PSARC/2006/406 WiFi for GLDv3
PSARC/2006/517 WiFi for GLDv3 Addendum
PSARC/2006/623 WiFi for GLDv3 Addendum #2
6253476 dladm exec_attr entry doesn't allow show-link to work
6362391 ath driver needs to be updated to use the latest HAL
6364198 system crashes if multiple ath driver instances are modunload'ed
6367259 ath driver needs to support GLDv3
6407181 ath driver panics in ath_rate_update function
6421983 ath driver needs shared_key authmode support
6472427 ath driver causes watchdog timeout error
6484943 integrate WiFi/GLDv3
--HG--
rename : usr/src/uts/common/io/ath/ath_ieee80211.c => deleted_files/usr/src/uts/common/io/ath/ath_ieee80211.c
rename : usr/src/uts/common/io/ath/ath_ieee80211.h => deleted_files/usr/src/uts/common/io/ath/ath_ieee80211.h
rename : usr/src/uts/common/io/ath/ath_wificonfig.c => deleted_files/usr/src/uts/common/io/ath/ath_wificonfig.c
Diffstat (limited to 'usr/src/uts/common/sys')
-rw-r--r-- | usr/src/uts/common/sys/dld.h | 34 | ||||
-rw-r--r-- | usr/src/uts/common/sys/dld_impl.h | 5 | ||||
-rw-r--r-- | usr/src/uts/common/sys/dlpi.h | 2 | ||||
-rw-r--r-- | usr/src/uts/common/sys/mac.h | 2 | ||||
-rw-r--r-- | usr/src/uts/common/sys/mac_impl.h | 1 | ||||
-rw-r--r-- | usr/src/uts/common/sys/mac_wifi.h | 116 | ||||
-rw-r--r-- | usr/src/uts/common/sys/net80211.h | 528 | ||||
-rw-r--r-- | usr/src/uts/common/sys/net80211_crypto.h | 218 | ||||
-rw-r--r-- | usr/src/uts/common/sys/net80211_proto.h | 541 |
9 files changed, 1447 insertions, 0 deletions
diff --git a/usr/src/uts/common/sys/dld.h b/usr/src/uts/common/sys/dld.h index 4e32398c21..783f581e68 100644 --- a/usr/src/uts/common/sys/dld.h +++ b/usr/src/uts/common/sys/dld.h @@ -108,6 +108,40 @@ typedef struct dld_vlan_info { char dvi_name[IFNAMSIZ]; } dld_vlan_info_t; +/* + * Secure objects ioctls + */ +typedef enum { + DLD_SECOBJ_CLASS_WEP = 1 +} dld_secobj_class_t; + +#define DLD_SECOBJ_OPT_CREATE 0x00000001 +#define DLD_SECOBJ_NAME_MAX 32 +#define DLD_SECOBJ_VAL_MAX 256 +typedef struct dld_secobj { + char so_name[DLD_SECOBJ_NAME_MAX]; + dld_secobj_class_t so_class; + uint8_t so_val[DLD_SECOBJ_VAL_MAX]; + uint_t so_len; +} dld_secobj_t; + +#define DLDIOCSECOBJSET (DLDIOC | 0x05) +typedef struct dld_ioc_secobj_set { + dld_secobj_t ss_obj; + uint_t ss_flags; +} dld_ioc_secobj_set_t; + +#define DLDIOCSECOBJGET (DLDIOC | 0x06) +typedef struct dld_ioc_secobj_get { + dld_secobj_t sg_obj; + uint_t sg_count; +} dld_ioc_secobj_get_t; + +#define DLDIOCSECOBJUNSET (DLDIOC | 0x07) +typedef struct dld_ioc_secobj_unset { + char su_name[DLD_SECOBJ_NAME_MAX]; +} dld_ioc_secobj_unset_t; + #ifdef _KERNEL int dld_getinfo(dev_info_t *, ddi_info_cmd_t, void *, void **); int dld_open(queue_t *, dev_t *, int, int, cred_t *); diff --git a/usr/src/uts/common/sys/dld_impl.h b/usr/src/uts/common/sys/dld_impl.h index bd61db8dc4..356bd4dd1b 100644 --- a/usr/src/uts/common/sys/dld_impl.h +++ b/usr/src/uts/common/sys/dld_impl.h @@ -164,6 +164,11 @@ struct dld_str { dld_str_mode_t ds_mode; /* + * Native mode state. + */ + boolean_t ds_native; + + /* * IP polling is operational if this flag is set. */ boolean_t ds_polling; diff --git a/usr/src/uts/common/sys/dlpi.h b/usr/src/uts/common/sys/dlpi.h index 3ffb8b5762..b8ff186a95 100644 --- a/usr/src/uts/common/sys/dlpi.h +++ b/usr/src/uts/common/sys/dlpi.h @@ -49,6 +49,7 @@ extern "C" { */ #define DLIOC ('D' << 8) #define DLIOCRAW (DLIOC|1) /* M_DATA "raw" mode */ +#define DLIOCNATIVE (DLIOC|2) /* Native traffic mode */ #define DLIOCHDRINFO (DLIOC|10) /* IP fast-path */ #define DL_IOC_HDR_INFO DLIOCHDRINFO @@ -261,6 +262,7 @@ extern "C" { #define DL_IPV4 0x80000001ul /* IPv4 Tunnel Link */ #define DL_IPV6 0x80000002ul /* IPv6 Tunnel Link */ #define SUNW_DL_VNI 0x80000003ul /* Virtual network interface */ +#define DL_WIFI 0x80000004ul /* IEEE 802.11 */ /* * DLPI provider service supported. diff --git a/usr/src/uts/common/sys/mac.h b/usr/src/uts/common/sys/mac.h index ed11df7e4a..fd4c89150c 100644 --- a/usr/src/uts/common/sys/mac.h +++ b/usr/src/uts/common/sys/mac.h @@ -154,6 +154,7 @@ enum mac_driver_stat { */ typedef struct mac_info_s { uint_t mi_media; + uint_t mi_nativemedia; uint_t mi_sdu_min; uint_t mi_sdu_max; uint_t mi_addr_length; @@ -462,6 +463,7 @@ typedef struct mactype_register_s { const char *mtr_ident; mactype_ops_t *mtr_ops; uint_t mtr_mactype; + uint_t mtr_nativetype; uint_t mtr_addrlen; uint8_t *mtr_brdcst_addr; mac_stat_info_t *mtr_stats; diff --git a/usr/src/uts/common/sys/mac_impl.h b/usr/src/uts/common/sys/mac_impl.h index bc4bea80de..06e6b8244c 100644 --- a/usr/src/uts/common/sys/mac_impl.h +++ b/usr/src/uts/common/sys/mac_impl.h @@ -80,6 +80,7 @@ typedef struct mactype_s { const char *mt_ident; uint32_t mt_ref; uint_t mt_type; + uint_t mt_nativetype; size_t mt_addr_length; uint8_t *mt_brdcst_addr; mactype_ops_t mt_ops; diff --git a/usr/src/uts/common/sys/mac_wifi.h b/usr/src/uts/common/sys/mac_wifi.h new file mode 100644 index 0000000000..7ed4a9c0a1 --- /dev/null +++ b/usr/src/uts/common/sys/mac_wifi.h @@ -0,0 +1,116 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_MAC_WIFI_H +#define _SYS_MAC_WIFI_H + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * WiFi MAC-Type Plugin + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <sys/types.h> +#include <sys/net80211_proto.h> + +#ifdef _KERNEL + +#define MAC_PLUGIN_IDENT_WIFI "mac_wifi" + +/* + * Maximum size of a WiFi header based on current implementation. + * May change in the future as new features are added. + */ +#define WIFI_HDRSIZE (sizeof (struct ieee80211_frame) + \ + IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + sizeof (struct ieee80211_llc)) + +enum wifi_stat { + /* statistics described in ieee802.11(5) */ + WIFI_STAT_TX_FRAGS = MACTYPE_STAT_MIN, + WIFI_STAT_MCAST_TX, + WIFI_STAT_TX_FAILED, + WIFI_STAT_TX_RETRANS, + WIFI_STAT_TX_RERETRANS, + WIFI_STAT_RTS_SUCCESS, + WIFI_STAT_RTS_FAILURE, + WIFI_STAT_ACK_FAILURE, + WIFI_STAT_RX_FRAGS, + WIFI_STAT_MCAST_RX, + WIFI_STAT_FCS_ERRORS, + WIFI_STAT_WEP_ERRORS, + WIFI_STAT_RX_DUPS +}; + +/* + * WiFi security modes recognized by the plugin. + */ +enum wifi_secmode { + WIFI_SEC_NONE, + WIFI_SEC_WEP +}; + +/* + * WiFi data passed between the drivers and the plugin. + * + * Field definitions: + * + * wd_opts Currently set to 0. If new features require the + * introduction of new wifi_data_t fields, then the + * presence of those fields must be indicated to the + * plugin via wd_opts flags. This allows the drivers + * and the plugin to evolve independently. + * + * wd_bssid Current associated BSSID (or IBSSID), used when + * generating data packet headers for transmission. + * + * wd_opmode Current operation mode; any ieee80211_opmode is + * supported. + * + * wd_secalloc Current allocation policy for security-related + * WiFi headers, used when generating packets for + * transmission. The plugin will allocate header + * space for the security portion, and fill in any + * fixed-contents fields. + */ +typedef struct wifi_data { + uint_t wd_opts; + uint8_t wd_bssid[IEEE80211_ADDR_LEN]; + enum ieee80211_opmode wd_opmode; + enum wifi_secmode wd_secalloc; +} wifi_data_t; + +extern uint8_t wifi_bcastaddr[]; + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MAC_WIFI_H */ diff --git a/usr/src/uts/common/sys/net80211.h b/usr/src/uts/common/sys/net80211.h new file mode 100644 index 0000000000..539e0a3e10 --- /dev/null +++ b/usr/src/uts/common/sys/net80211.h @@ -0,0 +1,528 @@ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright (c) 2001 Atsushi Onoe + * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#ifndef _SYS_NET80211_H +#define _SYS_NET80211_H + +#include <sys/mac.h> +#include <sys/ethernet.h> +#include <sys/net80211_proto.h> +#include <sys/net80211_crypto.h> + +/* + * IEEE802.11 kernel support module + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* ic_caps */ +#define IEEE80211_C_WEP 0x00000001 /* CAPABILITY: WEP available */ +#define IEEE80211_C_TKIP 0x00000002 /* CAPABILITY: TKIP available */ +#define IEEE80211_C_AES 0x00000004 /* CAPABILITY: AES OCB avail */ +#define IEEE80211_C_AES_CCM 0x00000008 /* CAPABILITY: AES CCM avail */ +#define IEEE80211_C_CKIP 0x00000010 /* CAPABILITY: CKIP available */ +#define IEEE80211_C_FF 0x00000040 /* CAPABILITY: ATH FF avail */ +#define IEEE80211_C_TURBOP 0x00000080 + /* CAPABILITY: ATH Turbo available */ +#define IEEE80211_C_IBSS 0x00000100 /* CAPABILITY: IBSS available */ +#define IEEE80211_C_PMGT 0x00000200 /* CAPABILITY: Power mgmt */ +#define IEEE80211_C_HOSTAP 0x00000400 /* CAPABILITY: HOSTAP avail */ +#define IEEE80211_C_AHDEMO 0x00000800 /* CAPABILITY: Old Adhoc Demo */ +#define IEEE80211_C_SWRETRY 0x00001000 /* CAPABILITY: sw tx retry */ +#define IEEE80211_C_TXPMGT 0x00002000 /* CAPABILITY: tx power mgmt */ +#define IEEE80211_C_SHSLOT 0x00004000 /* CAPABILITY: short slottime */ +#define IEEE80211_C_SHPREAMBLE 0x00008000 /* CAPABILITY: short preamble */ +#define IEEE80211_C_MONITOR 0x00010000 /* CAPABILITY: monitor mode */ +#define IEEE80211_C_TKIPMIC 0x00020000 /* CAPABILITY: TKIP MIC avail */ +#define IEEE80211_C_WPA1 0x00800000 /* CAPABILITY: WPA1 avail */ +#define IEEE80211_C_WPA2 0x01000000 /* CAPABILITY: WPA2 avail */ +#define IEEE80211_C_WPA 0x01800000 + /* CAPABILITY: WPA1+WPA2 avail */ +#define IEEE80211_C_BURST 0x02000000 /* CAPABILITY: frame bursting */ +#define IEEE80211_C_WME 0x04000000 /* CAPABILITY: WME avail */ +#define IEEE80211_C_WDS 0x08000000 /* CAPABILITY: 4-addr support */ +/* 0x10000000 reserved */ +#define IEEE80211_C_BGSCAN 0x20000000 /* CAPABILITY: bg scanning */ +#define IEEE80211_C_TXFRAG 0x40000000 /* CAPABILITY: tx fragments */ +/* XXX protection/barker? */ + +#define IEEE80211_C_CRYPTO 0x0000001f /* CAPABILITY: crypto alg's */ + +/* ic_flags */ +/* NB: bits 0x4c available */ +#define IEEE80211_F_FF 0x00000001 /* CONF: ATH FF enabled */ +#define IEEE80211_F_TURBOP 0x00000002 /* CONF: ATH Turbo enabled */ +#define IEEE80211_F_BURST 0x00000004 /* CONF: bursting enabled */ +/* NB: this is intentionally setup to be IEEE80211_CAPINFO_PRIVACY */ +#define IEEE80211_F_PRIVACY 0x00000010 /* CONF: privacy enabled */ +#define IEEE80211_F_PUREG 0x00000020 /* CONF: 11g w/o 11b sta's */ +#define IEEE80211_F_SCANONLY 0x00000040 /* CONF: scan only */ +#define IEEE80211_F_SCAN 0x00000080 /* STATUS: scanning */ +#define IEEE80211_F_ASCAN 0x00000100 /* STATUS: active scan */ +#define IEEE80211_F_SIBSS 0x00000200 /* STATUS: start IBSS */ +/* NB: this is intentionally setup to be IEEE80211_CAPINFO_SHORT_SLOTTIME */ +#define IEEE80211_F_SHSLOT 0x00000400 + /* STATUS: use short slot time */ +#define IEEE80211_F_PMGTON 0x00000800 /* CONF: Power mgmt enable */ +#define IEEE80211_F_DESBSSID 0x00001000 /* CONF: des_bssid is set */ +#define IEEE80211_F_WME 0x00002000 /* CONF: enable WME use */ +#define IEEE80211_F_BGSCAN 0x00004000 + /* CONF: bg scan enabled (???) */ +#define IEEE80211_F_SWRETRY 0x00008000 /* CONF: sw tx retry enabled */ +#define IEEE80211_F_TXPOW_FIXED 0x00010000 /* TX Power: fixed rate */ +#define IEEE80211_F_IBSSON 0x00020000 /* CONF: IBSS creation enable */ +#define IEEE80211_F_SHPREAMBLE 0x00040000 /* STATUS: use short preamble */ +#define IEEE80211_F_DATAPAD 0x00080000 /* CONF: do alignment pad */ +#define IEEE80211_F_USEPROT 0x00100000 /* STATUS: protection enabled */ +#define IEEE80211_F_USEBARKER 0x00200000 + /* STATUS: use barker preamble */ +#define IEEE80211_F_TIMUPDATE 0x00400000 /* STATUS: update beacon tim */ +#define IEEE80211_F_WPA1 0x00800000 /* CONF: WPA enabled */ +#define IEEE80211_F_WPA2 0x01000000 /* CONF: WPA2 enabled */ +#define IEEE80211_F_WPA 0x01800000 /* CONF: WPA/WPA2 enabled */ +#define IEEE80211_F_DROPUNENC 0x02000000 /* CONF: drop unencrypted */ +#define IEEE80211_F_COUNTERM 0x04000000 /* CONF: TKIP countermeasures */ +#define IEEE80211_F_HIDESSID 0x08000000 /* CONF: hide SSID in beacon */ +#define IEEE80211_F_NOBRIDGE 0x10000000 /* CONF: dis. internal bridge */ +#define IEEE80211_F_WMEUPDATE 0x20000000 /* STATUS: update beacon wme */ + +/* ic_flags_ext */ +#define IEEE80211_FEXT_WDS 0x00000001 /* CONF: 4 addr allowed */ +/* 0x00000006 reserved */ +#define IEEE80211_FEXT_BGSCAN 0x00000008 + /* STATUS: enable full bgscan completion */ +#define IEEE80211_FEXT_ERPUPDATE 0x00000200 /* STATUS: update ERP element */ +#define IEEE80211_FEXT_SWBMISS 0x00000400 /* CONF: do bmiss in s/w */ + +/* + * Channel attributes (ich_flags) + * bits 0-3 are for private use by drivers + */ +#define IEEE80211_CHAN_TURBO 0x0010 /* Turbo channel */ +#define IEEE80211_CHAN_CCK 0x0020 /* CCK channel */ +#define IEEE80211_CHAN_OFDM 0x0040 /* OFDM channel */ +#define IEEE80211_CHAN_2GHZ 0x0080 /* 2 GHz spectrum channel. */ +#define IEEE80211_CHAN_5GHZ 0x0100 /* 5 GHz spectrum channel */ +#define IEEE80211_CHAN_PASSIVE 0x0200 /* Only passive scan allowed */ +#define IEEE80211_CHAN_DYN 0x0400 /* Dynamic CCK-OFDM channel */ +#define IEEE80211_CHAN_GFSK 0x0800 /* GFSK channel (FHSS PHY) */ + +#define IEEE80211_CHAN_MAX 255 +#define IEEE80211_CHAN_BYTES 32 /* howmany(IEEE80211_CHAN_MAX, NBBY) */ +#define IEEE80211_CHAN_ANY 0xffff /* token for ``any channel'' */ +#define IEEE80211_CHAN_ANYC \ + ((struct ieee80211_channel *)IEEE80211_CHAN_ANY) + +#define IEEE80211_IS_CHAN_2GHZ(_c) \ + (((_c)->ich_flags & IEEE80211_CHAN_2GHZ) != 0) +#define IEEE80211_IS_CHAN_5GHZ(_c) \ + (((_c)->ich_flags & IEEE80211_CHAN_5GHZ) != 0) + +#define IEEE80211_NODE_HASHSIZE 32 + +#define IEEE80211_FIXED_RATE_NONE 0 +#define IEEE80211_MCAST_RATE_DEFAULT (2*1) /* default mcast rate (1M) */ + +/* WME stream classes */ +#define WME_AC_BE 0 /* best effort */ +#define WME_AC_BK 1 /* background */ +#define WME_AC_VI 2 /* video */ +#define WME_AC_VO 3 /* voice */ + +/* + * Authentication mode. + */ +enum ieee80211_authmode { + IEEE80211_AUTH_NONE = 0, + IEEE80211_AUTH_OPEN = 1, /* open */ + IEEE80211_AUTH_SHARED = 2, /* shared-key */ + IEEE80211_AUTH_8021X = 3, /* 802.1x */ + IEEE80211_AUTH_AUTO = 4, /* auto-select/accept */ + /* NB: these are used only for ioctls */ + IEEE80211_AUTH_WPA = 5 /* WPA/RSN w/ 802.1x/PSK */ +}; + +enum ieee80211_state { + IEEE80211_S_INIT = 0, /* default state */ + IEEE80211_S_SCAN = 1, /* scanning */ + IEEE80211_S_AUTH = 2, /* try to authenticate */ + IEEE80211_S_ASSOC = 3, /* try to assoc */ + IEEE80211_S_RUN = 4 /* associated */ +}; +#define IEEE80211_S_MAX (IEEE80211_S_RUN+1) + +/* + * 802.11 rate set. + */ +#define IEEE80211_RATE_MAXSIZE 15 /* max rates we'll handle */ +#define IEEE80211_RATE_SIZE 8 /* 802.11 standard */ +#define IEEE80211_XRATE_SIZE (IEEE80211_RATE_MAXSIZE - IEEE80211_RATE_SIZE) + /* size of extended supported rates */ +struct ieee80211_rateset { + uint8_t ir_nrates; + uint8_t ir_rates[IEEE80211_RATE_MAXSIZE]; +}; + +/* + * Channels are specified by frequency and attributes. + */ +struct ieee80211_channel { + uint16_t ich_freq; /* setting in Mhz */ + uint16_t ich_flags; /* see below */ +}; + +struct ieee80211_device_stats { + uint32_t is_tx_frags; + uint32_t is_tx_bytes; + uint32_t is_tx_mcast; + uint32_t is_tx_failed; + uint32_t is_tx_retries; + uint32_t is_rts_success; + uint32_t is_rts_failure; + uint32_t is_ack_failure; + uint32_t is_rx_frags; + uint32_t is_rx_bytes; + uint32_t is_rx_mcast; + uint32_t is_rx_dups; + uint32_t is_fcs_errors; + uint32_t is_wep_errors; + uint32_t is_tx_nobuf; + uint32_t is_tx_unknownmgt; +}; + +struct ieee80211_crypto_state; +typedef struct ieee80211_node_table ieee80211_node_table_t; +typedef struct ieee80211_node ieee80211_node_t; +typedef struct ieee80211com ieee80211com_t; + +struct ieee80211_node_table { + struct ieee80211com *nt_ic; /* back reference */ + + const char *nt_name; /* for debugging */ + /* For node inactivity processing */ + int nt_inact_timer; /* inactivity timer */ + int nt_inact_init; /* initial node inact setting */ + void (*nt_timeout)(struct ieee80211_node_table *); + uint32_t nt_scangen; /* gen# for timeout scan */ + kmutex_t nt_scanlock; /* on nt_scangen */ + kmutex_t nt_nodelock; /* on node table */ + + int nt_keyixmax; /* keyixmap size */ + struct ieee80211_node **nt_keyixmap; /* key ix -> node map */ + + list_t nt_node; /* information of all nodes */ + list_t nt_hash[IEEE80211_NODE_HASHSIZE]; +}; + +/* + * Node specific information. Note that drivers are expected + * to derive from this structure to add device-specific per-node + * state. This is done by overriding the ic_node_* methods in + * the ieee80211com structure. + */ +struct ieee80211_node { + struct ieee80211com *in_ic; + struct ieee80211_node_table *in_table; + + uint8_t in_authmode; /* authentication algorithm */ + uint16_t in_flags; /* special purpose state */ + uint16_t in_associd; /* assoc response */ + uint16_t in_txpower; /* current transmit power */ + uint16_t in_vlan; /* vlan tag */ + /* + * Tx/Rx sequence number. + * index 0 is used when QoS is not enabled. index 1-16 is used + * when QoS is enabled. 1-16 corresponds to TID 0-15. + */ + uint16_t in_txseqs[17]; /* tx seq per-tid */ + uint16_t in_rxseqs[17]; /* rx seq previous per-tid */ + clock_t in_rxfragstamp; /* time stamp of last rx frag */ + mblk_t *in_rxfrag; /* rx frag reassembly */ + uint32_t in_scangen; /* gen# for timeout scan */ + uint32_t in_refcnt; + + /* hardware */ + uint32_t in_rstamp; /* recv timestamp */ + uint8_t in_rssi; /* recv ssi */ + + /* header */ + uint8_t in_macaddr[IEEE80211_ADDR_LEN]; + uint8_t in_bssid[IEEE80211_ADDR_LEN]; + + /* beacon, probe response */ + union { + uint8_t data[8]; + uint64_t tsf; + } in_tstamp; /* from last rcv'd beacon */ + uint16_t in_intval; /* beacon interval */ + uint16_t in_capinfo; /* capabilities */ + uint8_t in_esslen; + uint8_t in_essid[IEEE80211_NWID_LEN]; + struct ieee80211_rateset in_rates; /* negotiated rate set */ + struct ieee80211_channel *in_chan; /* XXX multiple uses */ + enum ieee80211_phytype in_phytype; + uint16_t in_fhdwell; /* FH only */ + uint8_t in_fhindex; /* FH only */ + uint8_t in_erp; /* ERP from beacon/probe resp */ + uint16_t in_tim_off; /* byte offset to TIM ie */ + uint8_t in_dtim_period; /* DTIM period */ + uint8_t in_dtim_count; /* DTIM count for last bcn */ + + uint32_t *in_challenge; /* shared-key challenge */ + struct ieee80211_key in_ucastkey; /* unicast key */ + + /* others */ + int32_t in_fails; /* failure count to associate */ + int16_t in_inact; /* inactivity mark count */ + int16_t in_inact_reload; /* inactivity reload value */ + int32_t in_txrate; /* index to ni_rates[] */ + + list_node_t in_node; /* element of nt->nt_node */ + list_node_t in_hash; /* element of nt->nt_hash */ +}; + +struct ieee80211com { + mac_handle_t ic_mach; + + /* Initialized by driver */ + uint8_t ic_macaddr[IEEE80211_ADDR_LEN]; + uint32_t ic_caps; /* capabilities */ + enum ieee80211_phytype ic_phytype; /* XXX wrong for multi-mode */ + enum ieee80211_opmode ic_opmode; /* current operation mode */ + enum ieee80211_state ic_state; /* current 802.11 state */ + struct ieee80211_channel ic_sup_channels[IEEE80211_CHAN_MAX+1]; + struct ieee80211_rateset ic_sup_rates[IEEE80211_MODE_MAX]; + enum ieee80211_phymode ic_curmode; /* OPT current mode */ + struct ieee80211_channel *ic_curchan; /* OPT current channel */ + struct ieee80211_channel *ic_ibss_chan; /* OPT bss channel */ + uint8_t ic_maxrssi; /* maximum hardware RSSI */ + + /* INITIALIZED by IEEE80211, used/overridden by driver */ + uint16_t ic_modecaps; /* set of mode capabilities */ + uint8_t ic_chan_active[IEEE80211_CHAN_BYTES]; + enum ieee80211_protmode ic_protmode; /* 802.11g protection mode */ + uint16_t ic_bintval; /* beacon interval */ + uint16_t ic_lintval; /* listen interval */ + uint16_t ic_txpowlimit; /* global tx power limit */ + uint8_t ic_bmissthreshold; + uint16_t ic_rtsthreshold; + uint16_t ic_fragthreshold; + int32_t ic_mcast_rate; /* rate for mcast frames */ + uint8_t ic_fixed_rate; /* value of fixed rate */ + int32_t ic_des_esslen; /* length of desired essid */ + uint8_t ic_des_essid[IEEE80211_NWID_LEN]; + uint8_t ic_des_bssid[IEEE80211_ADDR_LEN]; + struct ieee80211_channel *ic_des_chan; /* desired channel */ + void *ic_opt_ie; /* user-specified IE's */ + uint16_t ic_opt_ie_len; /* length of ic_opt_ie */ + uint8_t ic_nickname[IEEE80211_NWID_LEN]; + uint16_t ic_tim_len; /* ic_tim_bitmap size (bytes) */ + uint8_t *ic_tim_bitmap; /* powersave stations w/ data */ + timeout_id_t ic_watchdog_timer; /* watchdog timer */ + /* Cipher state/configuration. */ + struct ieee80211_crypto_state ic_crypto; + + /* Runtime states */ + uint32_t ic_flags; /* state/conf flags */ + uint32_t ic_flags_ext; /* extended state flags */ + struct ieee80211_node *ic_bss; /* information for this node */ + struct ieee80211_device_stats ic_stats; + struct ieee80211_node_table ic_scan; /* STA: scan candidates */ + struct ieee80211_node_table ic_sta; /* AP:stations/IBSS:neighbors */ + + /* callback functions */ + /* + * Functions initialized by driver before calling ieee80211_attach() + * Those must be initialized are marked with M(andatory) + * + * ic_xmit - [M] transmit a management or null data frame + * return 0 on success, non-zero on error + * ic_watchdog - [O] periodic run function, enabled by + * ieee80211_start_watchdog() + * ic_set_tim - [O] set/clear traffic indication map + * ic_set_shortslot - [O] enable/disable short slot timing + * ic_node_newassoc - [O] driver specific operation on a newly + * associated or re-assoced node + */ + int (*ic_xmit)(ieee80211com_t *, mblk_t *, uint8_t); + void (*ic_watchdog)(void *); + void (*ic_set_tim)(ieee80211com_t *, + ieee80211_node_t *, int); + void (*ic_set_shortslot)(ieee80211com_t *, int); + void (*ic_node_newassoc)(ieee80211_node_t *, int); + /* + * Functions initialized by ieee80211_attach(), driver could + * override these functions after calling ieee80211_attach() + * + * ic_reset - reset + * ic_recv_mgmt - handle received management frames + * ic_send_mgmt - construct and transmit management frames + * ic_newstate - handle state transition + * ic_node_alloc - allocate a new BSS info node + * ic_node_cleanup - cleanup or free memory spaces of a node + * ic_node_free - free a node + * ic_node_getrssi - get node's rssi + */ + int (*ic_reset)(ieee80211com_t *); + void (*ic_recv_mgmt)(ieee80211com_t *, + mblk_t *, ieee80211_node_t *, + int, int, uint32_t); + int (*ic_send_mgmt)(ieee80211com_t *, + ieee80211_node_t *, int, int); + int (*ic_newstate)(ieee80211com_t *, + enum ieee80211_state, int); + struct ieee80211_node *(*ic_node_alloc)(ieee80211com_t *); + void (*ic_node_cleanup)(ieee80211_node_t *); + void (*ic_node_free)(ieee80211_node_t *); + uint8_t (*ic_node_getrssi)(const ieee80211_node_t *); + + kmutex_t ic_genlock; + void *ic_private; /* ieee80211 private data */ +}; +#define ic_nw_keys ic_crypto.cs_nw_keys +#define ic_def_txkey ic_crypto.cs_def_txkey + +extern const char *ieee80211_state_name[IEEE80211_S_MAX]; + +#define IEEE80211_RATE(_ix) \ + (in->in_rates.ir_rates[(_ix)] & IEEE80211_RATE_VAL) + +#define ieee80211_new_state(_ic, _nstate, _arg) \ + (((_ic)->ic_newstate)((_ic), (_nstate), (_arg))) + +#define ieee80211_macaddr_sprintf(_addr) \ + ether_sprintf((struct ether_addr *)(_addr)) + +/* + * Node reference counting definitions. + * + * ieee80211_node_initref initialize the reference count to 1 + * ieee80211_node_incref add a reference + * ieee80211_node_decref remove a reference + * ieee80211_node_decref_nv remove a reference and return new value + * ieee80211_node_refcnt reference count for printing (only) + */ +#include <sys/atomic.h> +#define ieee80211_node_initref(_in) \ + ((_in)->in_refcnt = 1) +#define ieee80211_node_incref(_in) \ + atomic_inc_uint(&(_in)->in_refcnt) +#define ieee80211_node_decref(_in) \ + atomic_dec_uint(&(_in)->in_refcnt) +#define ieee80211_node_decref_nv(_in) \ + atomic_dec_uint_nv(&(_in)->in_refcnt) +#define ieee80211_node_refcnt(_in) \ + (_in)->in_refcnt + +typedef void ieee80211_iter_func(void *, ieee80211_node_t *); + +/* Initialization */ +void ieee80211_attach(ieee80211com_t *); +void ieee80211_detach(ieee80211com_t *); +void ieee80211_media_init(ieee80211com_t *); +int ieee80211_ioctl(ieee80211com_t *, queue_t *, mblk_t *); + +/* Protocol Processing */ +int ieee80211_input(ieee80211com_t *, mblk_t *, ieee80211_node_t *, + int32_t, uint32_t); +mblk_t *ieee80211_encap(ieee80211com_t *, mblk_t *, ieee80211_node_t *); + +mblk_t *ieee80211_beacon_alloc(ieee80211com_t *, ieee80211_node_t *, + struct ieee80211_beacon_offsets *); +int ieee80211_beacon_update(ieee80211com_t *, ieee80211_node_t *, + struct ieee80211_beacon_offsets *, mblk_t *, int); +void ieee80211_beacon_miss(ieee80211com_t *); + +void ieee80211_begin_scan(ieee80211com_t *, boolean_t); +void ieee80211_next_scan(ieee80211com_t *); +void ieee80211_end_scan(ieee80211com_t *); +void ieee80211_cancel_scan(ieee80211com_t *); + +void ieee80211_sta_join(ieee80211com_t *, ieee80211_node_t *); +void ieee80211_sta_leave(ieee80211com_t *, ieee80211_node_t *); +boolean_t ieee80211_ibss_merge(ieee80211_node_t *); + +/* Node Operation */ +ieee80211_node_t *ieee80211_ref_node(ieee80211_node_t *); +void ieee80211_unref_node(ieee80211_node_t **); +void ieee80211_node_authorize(ieee80211_node_t *); +void ieee80211_node_unauthorize(ieee80211_node_t *); +ieee80211_node_t *ieee80211_alloc_node(ieee80211com_t *, + ieee80211_node_table_t *, const uint8_t *); +void ieee80211_free_node(ieee80211_node_t *); +void ieee80211_node_table_reset(ieee80211_node_table_t *); +void ieee80211_iterate_nodes(ieee80211_node_table_t *, ieee80211_iter_func *, + void *); +ieee80211_node_t *ieee80211_find_node(ieee80211_node_table_t *, + const uint8_t *); +ieee80211_node_t *ieee80211_find_txnode(ieee80211com_t *, + const uint8_t daddr[IEEE80211_ADDR_LEN]); +ieee80211_node_t *ieee80211_find_rxnode(ieee80211com_t *, + const struct ieee80211_frame *); + + +/* Crypto */ +extern struct ieee80211_key *ieee80211_crypto_encap(ieee80211com_t *, mblk_t *); +extern struct ieee80211_key *ieee80211_crypto_decap(ieee80211com_t *, mblk_t *, + int); +extern int ieee80211_crypto_newkey(ieee80211com_t *, int, int, + struct ieee80211_key *); +extern int ieee80211_crypto_delkey(ieee80211com_t *, struct ieee80211_key *); +extern int ieee80211_crypto_setkey(ieee80211com_t *, struct ieee80211_key *, + const uint8_t macaddr[IEEE80211_ADDR_LEN]); + +/* Helper Functions */ +int ieee80211_stat(ieee80211com_t *ic, uint_t stat, uint64_t *val); +uint32_t ieee80211_chan2ieee(ieee80211com_t *, struct ieee80211_channel *); +enum ieee80211_phymode ieee80211_chan2mode(ieee80211com_t *, + struct ieee80211_channel *); +uint32_t ieee80211_ieee2mhz(uint32_t, uint32_t); +void ieee80211_reset_chan(ieee80211com_t *); +void ieee80211_dump_pkt(const uint8_t *, int32_t, int32_t, int32_t); +void ieee80211_watchdog(void *); +void ieee80211_start_watchdog(ieee80211com_t *, uint32_t); +void ieee80211_stop_watchdog(ieee80211com_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_NET80211_H */ diff --git a/usr/src/uts/common/sys/net80211_crypto.h b/usr/src/uts/common/sys/net80211_crypto.h new file mode 100644 index 0000000000..89cd81095b --- /dev/null +++ b/usr/src/uts/common/sys/net80211_crypto.h @@ -0,0 +1,218 @@ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright (c) 2001 Atsushi Onoe + * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#ifndef _SYS_NET80211_CRYPTO_H +#define _SYS_NET80211_CRYPTO_H + +#include <sys/types.h> +#include <sys/mac.h> +#include <sys/net80211_proto.h> + +/* + * 802.11 protocol crypto-related definitions. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * NB: these values are ordered carefully; there are lots of + * of implications in any reordering. + */ +#define IEEE80211_CIPHER_WEP 0 +#define IEEE80211_CIPHER_TKIP 1 +#define IEEE80211_CIPHER_AES_OCB 2 +#define IEEE80211_CIPHER_AES_CCM 3 +#define IEEE80211_CIPHER_CKIP 4 +#define IEEE80211_CIPHER_NONE 5 /* pseudo value */ + +#define IEEE80211_CIPHER_MAX (IEEE80211_CIPHER_NONE+1) + +/* + * Maxmium length of key in bytes + * WEP key length present in the 802.11 standard is 40-bit. + * Many implementations also support 104-bit WEP keys. + * 802.11i standardize TKIP/CCMP use 128-bit key + */ +#define IEEE80211_KEYBUF_SIZE 16 +#define IEEE80211_MICBUF_SIZE (8+8) /* space for both tx+rx keys */ + +/* Key Flags */ +#define IEEE80211_KEY_XMIT 0x01 /* key used for xmit */ +#define IEEE80211_KEY_RECV 0x02 /* key used for recv */ +#define IEEE80211_KEY_GROUP /* key used for WPA group operation */ \ + 0x04 +#define IEEE80211_KEY_SWCRYPT 0x10 /* host-based encrypt/decrypt */ +#define IEEE80211_KEY_SWMIC 0x20 /* host-based enmic/demic */ +#define IEEE80211_KEY_COMMON /* common flags passed in by apps */ \ + (IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV | IEEE80211_KEY_GROUP) + +/* WEP */ +#define IEEE80211_WEP_KEYLEN 5 /* 40bit */ +#define IEEE80211_WEP_IVLEN 3 /* 24bit */ +#define IEEE80211_WEP_KIDLEN 1 /* 1 octet */ +#define IEEE80211_WEP_CRCLEN 4 /* CRC-32 */ +#define IEEE80211_WEP_NKID 4 /* number of key ids */ + +#define IEEE80211_WEP_HDRLEN \ + (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN) +#define IEEE80211_WEP_MINLEN \ + (sizeof (struct ieee80211_frame) + \ + IEEE80211_WEP_HDRLEN + IEEE80211_WEP_CRCLEN) + +/* Maximum number of keys */ +#define IEEE80211_KEY_MAX IEEE80211_WEP_NKID + +struct ieee80211com; +struct ieee80211_node; +struct ieee80211_key; +typedef uint16_t ieee80211_keyix; /* h/w key index */ + +#define IEEE80211_KEYIX_NONE ((ieee80211_keyix) -1) + +/* + * Template for a supported cipher. Ciphers register with the + * crypto code. + * + * ic_attach - Initialize cipher. The return value is set to wk_private + * ic_detach - Destruct a cipher. + * ic_setkey - Validate key contents + * ic_encap - Encrypt the 802.11 MAC payload + * ic_decap - Decrypt the 802.11 MAC payload + * ic_enmic - Add MIC + * ic_demic - Check and remove MIC + */ +struct ieee80211_cipher { + const char *ic_name; /* printable name */ + uint32_t ic_cipher; /* IEEE80211_CIPHER_* */ + uint32_t ic_header; /* size of privacy header (bytes) */ + uint32_t ic_trailer; /* size of privacy trailer (bytes) */ + uint32_t ic_miclen; /* size of mic trailer (bytes) */ + void *(*ic_attach)(struct ieee80211com *, + struct ieee80211_key *); + void (*ic_detach)(struct ieee80211_key *); + int32_t (*ic_setkey)(struct ieee80211_key *); + int32_t (*ic_encap)(struct ieee80211_key *, mblk_t *, + uint8_t keyid); + int32_t (*ic_decap)(struct ieee80211_key *, mblk_t *, int); + int32_t (*ic_enmic)(struct ieee80211_key *, mblk_t *, int); + int32_t (*ic_demic)(struct ieee80211_key *, mblk_t *, int); +}; +extern const struct ieee80211_cipher ieee80211_cipher_none; + +struct ieee80211_key { + uint8_t wk_keylen; /* key length in bytes */ + uint8_t wk_pad; + uint16_t wk_flags; + uint8_t wk_key[IEEE80211_KEYBUF_SIZE+IEEE80211_MICBUF_SIZE]; + ieee80211_keyix wk_keyix; /* h/w key index */ + ieee80211_keyix wk_rxkeyix; /* optional h/w rx key index */ + uint64_t wk_keyrsc; /* key receive sequence counter */ + uint64_t wk_keytsc; /* key transmit sequence counter */ + const struct ieee80211_cipher *wk_cipher; + void *wk_private; /* private cipher state */ +}; +#define wk_txmic wk_key+IEEE80211_KEYBUF_SIZE+0 +#define wk_rxmic wk_key+IEEE80211_KEYBUF_SIZE+8 + +/* + * Crypto state kept in each ieee80211com. + */ +struct ieee80211_crypto_state { + struct ieee80211_key cs_nw_keys[IEEE80211_KEY_MAX]; + ieee80211_keyix cs_def_txkey; /* default/group tx key index */ + uint16_t cs_max_keyix; /* max h/w key index */ + + int (*cs_key_alloc)(struct ieee80211com *, + const struct ieee80211_key *, + ieee80211_keyix *, ieee80211_keyix *); + int (*cs_key_delete)(struct ieee80211com *, + const struct ieee80211_key *); + int (*cs_key_set)(struct ieee80211com *, + const struct ieee80211_key *, + const uint8_t mac[IEEE80211_ADDR_LEN]); + void (*cs_key_update_begin)(struct ieee80211com *); + void (*cs_key_update_end)(struct ieee80211com *); +}; + +/* + * Key update synchronization methods. + */ +#define KEY_UPDATE_BEGIN(ic) \ + (ic)->ic_crypto.cs_key_update_begin(ic) +#define KEY_UPDATE_END(ic) \ + (ic)->ic_crypto.cs_key_update_end(ic) +#define KEY_UNDEFINED(k) \ + ((k).wk_cipher == &ieee80211_cipher_none) + +#define DEV_KEY_ALLOC(ic, k, kix, rkix) \ + (ic)->ic_crypto.cs_key_alloc(ic, k, kix, rkix) +#define DEV_KEY_DELETE(ic, k) \ + (ic)->ic_crypto.cs_key_delete(ic, k) +#define DEV_KEY_SET(ic, k, m) \ + (ic)->ic_crypto.cs_key_set(ic, k, m) + +#define CIPHER_DETACH(k) \ + (k)->wk_cipher->ic_detach(k) +#define CIPHER_ATTACH(k) \ + (k)->wk_cipher->ic_attach(k) + +#define ieee80211_crypto_demic(ic, k, m, force) \ + (((k)->wk_cipher->ic_miclen > 0) ? \ + (k)->wk_cipher->ic_demic(k, m, force) : \ + 1) + +#define ieee80211_crypto_enmic(ic, k, m, force) \ + ((k)->wk_cipher->ic_miclen > 0 ? \ + (k)->wk_cipher->ic_enmic(k, m, force) : \ + 1) + +void ieee80211_crypto_attach(struct ieee80211com *ic); +void ieee80211_crypto_detach(struct ieee80211com *ic); +void ieee80211_crypto_register(const struct ieee80211_cipher *); +void ieee80211_crypto_unregister(const struct ieee80211_cipher *); +void ieee80211_crypto_resetkey(struct ieee80211com *, struct ieee80211_key *, + ieee80211_keyix); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_NET80211_CRYPTO_H */ diff --git a/usr/src/uts/common/sys/net80211_proto.h b/usr/src/uts/common/sys/net80211_proto.h new file mode 100644 index 0000000000..6842798445 --- /dev/null +++ b/usr/src/uts/common/sys/net80211_proto.h @@ -0,0 +1,541 @@ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright (c) 2001 Atsushi Onoe + * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#ifndef _SYS_NET80211_PROTO_H +#define _SYS_NET80211_PROTO_H + +/* + * 802.11 protocol definitions + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define IEEE80211_ADDR_LEN 6 /* size of 802.11 address */ +#define IEEE80211_ADDR_COPY(dst, src) \ + ((void) bcopy(src, dst, IEEE80211_ADDR_LEN)) +#define IEEE80211_ADDR_EQ(a1, a2) \ + (bcmp(a1, a2, IEEE80211_ADDR_LEN) == 0) +/* is 802.11 address multicast/broadcast? */ +#define IEEE80211_IS_MULTICAST(addr) \ + ((((uint8_t *)addr)[0]) & 0x01) + +/* + * Size of an ACK control frame in bytes. + */ +#define IEEE80211_ACK_SIZE (2 + 2 + IEEE80211_ADDR_LEN + 4) + +#define WME_NUM_AC 4 /* 4 AC categories */ + +/* + * Protocol Physical Layer + */ + +/* XXX not really a mode; there are really multiple PHY's */ +enum ieee80211_phymode { + IEEE80211_MODE_AUTO = 0, /* autoselect */ + IEEE80211_MODE_11A = 1, /* 5GHz, OFDM */ + IEEE80211_MODE_11B = 2, /* 2GHz, CCK */ + IEEE80211_MODE_11G = 3, /* 2GHz, OFDM */ + IEEE80211_MODE_FH = 4, /* 2GHz, GFSK */ + IEEE80211_MODE_TURBO_A = 5, /* 5GHz, OFDM, 2x clock */ + IEEE80211_MODE_TURBO_G = 6 /* 2GHz, OFDM, 2x clock */ +}; +#define IEEE80211_MODE_MAX (IEEE80211_MODE_TURBO_G+1) + +enum ieee80211_phytype { + IEEE80211_T_DS, /* direct sequence spread spectrum */ + IEEE80211_T_FH, /* frequency hopping */ + IEEE80211_T_OFDM, /* frequency division multiplexing */ + IEEE80211_T_TURBO /* high rate OFDM, aka turbo mode */ +}; +#define IEEE80211_T_CCK IEEE80211_T_DS /* more common nomenclature */ + +enum ieee80211_opmode { + IEEE80211_M_STA = 1, /* infrastructure station */ + IEEE80211_M_IBSS = 0, /* IBSS (adhoc) station */ + IEEE80211_M_AHDEMO = 3, /* Old lucent compatible adhoc demo */ + IEEE80211_M_HOSTAP = 6, /* Software Access Point */ + IEEE80211_M_MONITOR = 8 /* Monitor mode */ +}; + +/* + * 802.11g protection mode. + */ +enum ieee80211_protmode { + IEEE80211_PROT_NONE = 0, /* no protection */ + IEEE80211_PROT_CTSONLY = 1, /* CTS to self */ + IEEE80211_PROT_RTSCTS = 2 /* RTS-CTS */ +}; + +/* + * generic definitions for IEEE 802.11 frames + */ +#pragma pack(1) +struct ieee80211_frame { + uint8_t i_fc[2]; /* [0]-protocol version, [1]-type & subtype */ + uint8_t i_dur[2]; + uint8_t i_addr1[IEEE80211_ADDR_LEN]; + uint8_t i_addr2[IEEE80211_ADDR_LEN]; + uint8_t i_addr3[IEEE80211_ADDR_LEN]; + uint8_t i_seq[2]; + /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */ + /* see below */ +}; + +struct ieee80211_frame_addr4 { + uint8_t i_fc[2]; + uint8_t i_dur[2]; + uint8_t i_addr1[IEEE80211_ADDR_LEN]; + uint8_t i_addr2[IEEE80211_ADDR_LEN]; + uint8_t i_addr3[IEEE80211_ADDR_LEN]; + uint8_t i_seq[2]; + uint8_t i_addr4[IEEE80211_ADDR_LEN]; +}; + +/* Start part(LLC and SNAP) of payload of IEEE80211 frame */ +struct ieee80211_llc { + /* LLC */ + uint8_t illc_dsap; + uint8_t illc_ssap; + uint8_t illc_control; + /* SNAP */ + uint8_t illc_oc[3]; /* protocol ID or organization code */ + uint16_t illc_ether_type; /* ethernet type */ +}; + +/* + * Management Notification Frame + */ +struct ieee80211_mnf { + uint8_t mnf_category; + uint8_t mnf_action; + uint8_t mnf_dialog; + uint8_t mnf_status; +}; +#define IEEE80211_MNF_SETUP_REQ 0 +#define IEEE80211_MNF_SETUP_RESP 1 +#define IEEE80211_MNF_TEARDOWN 2 + +/* + * Control frames. + */ +struct ieee80211_frame_min { + uint8_t i_fc[2]; + uint8_t i_dur[2]; + uint8_t i_addr1[IEEE80211_ADDR_LEN]; + uint8_t i_addr2[IEEE80211_ADDR_LEN]; + /* FCS */ +}; + +struct ieee80211_frame_rts { + uint8_t i_fc[2]; + uint8_t i_dur[2]; + uint8_t i_ra[IEEE80211_ADDR_LEN]; + uint8_t i_ta[IEEE80211_ADDR_LEN]; + /* FCS */ +}; + +struct ieee80211_frame_cts { + uint8_t i_fc[2]; + uint8_t i_dur[2]; + uint8_t i_ra[IEEE80211_ADDR_LEN]; + /* FCS */ +}; + +struct ieee80211_frame_ack { + uint8_t i_fc[2]; + uint8_t i_dur[2]; + uint8_t i_ra[IEEE80211_ADDR_LEN]; + /* FCS */ +}; + +struct ieee80211_frame_pspoll { + uint8_t i_fc[2]; + uint8_t i_aid[2]; + uint8_t i_bssid[IEEE80211_ADDR_LEN]; + uint8_t i_ta[IEEE80211_ADDR_LEN]; + /* FCS */ +}; + +struct ieee80211_frame_cfend { /* NB: also CF-End+CF-Ack */ + uint8_t i_fc[2]; + uint8_t i_dur[2]; /* should be zero */ + uint8_t i_ra[IEEE80211_ADDR_LEN]; + uint8_t i_bssid[IEEE80211_ADDR_LEN]; + /* FCS */ +}; + +struct ieee80211_tim_ie { + uint8_t tim_ie; /* IEEE80211_ELEMID_TIM */ + uint8_t tim_len; + uint8_t tim_count; /* DTIM count */ + uint8_t tim_period; /* DTIM period */ + uint8_t tim_bitctl; /* bitmap control */ + uint8_t tim_bitmap[1]; /* variable-length bitmap */ +}; + +/* + * 802.11i/WPA information element (maximally sized). + */ +struct ieee80211_ie_wpa { + uint8_t wpa_id; /* IEEE80211_ELEMID_VENDOR */ + uint8_t wpa_len; /* length in bytes */ + uint8_t wpa_oui[3]; /* 0x00, 0x50, 0xf2 */ + uint8_t wpa_type; /* OUI type */ + uint16_t wpa_version; /* spec revision */ + uint32_t wpa_mcipher[1]; /* multicast/group key cipher */ + uint16_t wpa_uciphercnt; /* # pairwise key ciphers */ + uint32_t wpa_uciphers[8]; /* ciphers */ + uint16_t wpa_authselcnt; /* authentication selector cnt */ + uint32_t wpa_authsels[8]; /* selectors */ + uint16_t wpa_caps; /* 802.11i capabilities */ + uint16_t wpa_pmkidcnt; /* 802.11i pmkid count */ + uint16_t wpa_pmkids[8]; /* 802.11i pmkids */ +}; + +/* + * WME AC parameter field + */ +struct ieee80211_wme_acparams { + uint8_t acp_aci_aifsn; + uint8_t acp_logcwminmax; + uint16_t acp_txop; +}; + +/* + * WME Parameter Element + */ +struct ieee80211_wme_param { + uint8_t wme_id; + uint8_t wme_len; + uint8_t wme_oui[3]; + uint8_t wme_oui_type; + uint8_t wme_oui_sybtype; + uint8_t wme_version; + uint8_t wme_qosInfo; + uint8_t wme_reserved; + struct ieee80211_wme_acparams wme_acParams[WME_NUM_AC]; +}; +#pragma pack() + +#define IEEE80211_FC0_VERSION_MASK 0x03 +#define IEEE80211_FC0_VERSION_SHIFT 0 +#define IEEE80211_FC0_VERSION_0 0x00 +#define IEEE80211_FC0_TYPE_MASK 0x0c +#define IEEE80211_FC0_TYPE_SHIFT 2 +#define IEEE80211_FC0_TYPE_MGT 0x00 +#define IEEE80211_FC0_TYPE_CTL 0x04 +#define IEEE80211_FC0_TYPE_DATA 0x08 +#define IEEE80211_FC0_SUBTYPE_MASK 0xf0 +#define IEEE80211_FC0_SUBTYPE_SHIFT 4 +/* for TYPE_MGT */ +#define IEEE80211_FC0_SUBTYPE_ASSOC_REQ 0x00 +#define IEEE80211_FC0_SUBTYPE_ASSOC_RESP 0x10 +#define IEEE80211_FC0_SUBTYPE_REASSOC_REQ 0x20 +#define IEEE80211_FC0_SUBTYPE_REASSOC_RESP 0x30 +#define IEEE80211_FC0_SUBTYPE_PROBE_REQ 0x40 +#define IEEE80211_FC0_SUBTYPE_PROBE_RESP 0x50 +#define IEEE80211_FC0_SUBTYPE_BEACON 0x80 +#define IEEE80211_FC0_SUBTYPE_ATIM 0x90 +#define IEEE80211_FC0_SUBTYPE_DISASSOC 0xa0 +#define IEEE80211_FC0_SUBTYPE_AUTH 0xb0 +#define IEEE80211_FC0_SUBTYPE_DEAUTH 0xc0 +/* for TYPE_CTL */ +#define IEEE80211_FC0_SUBTYPE_PS_POLL 0xa0 +#define IEEE80211_FC0_SUBTYPE_RTS 0xb0 +#define IEEE80211_FC0_SUBTYPE_CTS 0xc0 +#define IEEE80211_FC0_SUBTYPE_ACK 0xd0 +#define IEEE80211_FC0_SUBTYPE_CF_END 0xe0 +#define IEEE80211_FC0_SUBTYPE_CF_END_ACK 0xf0 +/* for TYPE_DATA (bit combination) */ +#define IEEE80211_FC0_SUBTYPE_DATA 0x00 +#define IEEE80211_FC0_SUBTYPE_CF_ACK 0x10 +#define IEEE80211_FC0_SUBTYPE_CF_POLL 0x20 +#define IEEE80211_FC0_SUBTYPE_CF_ACPL 0x30 +#define IEEE80211_FC0_SUBTYPE_NODATA 0x40 +#define IEEE80211_FC0_SUBTYPE_CFACK 0x50 +#define IEEE80211_FC0_SUBTYPE_CFPOLL 0x60 +#define IEEE80211_FC0_SUBTYPE_CF_ACK_CF_ACK 0x70 +#define IEEE80211_FC0_SUBTYPE_QOS 0x80 +#define IEEE80211_FC0_SUBTYPE_QOS_NULL 0xc0 + +#define IEEE80211_FC1_DIR_MASK 0x03 +#define IEEE80211_FC1_DIR_NODS 0x00 /* STA->STA */ +#define IEEE80211_FC1_DIR_TODS 0x01 /* STA->AP */ +#define IEEE80211_FC1_DIR_FROMDS 0x02 /* AP ->STA */ +#define IEEE80211_FC1_DIR_DSTODS 0x03 /* AP ->AP */ +#define IEEE80211_FC1_MORE_FRAG 0x04 +#define IEEE80211_FC1_RETRY 0x08 +#define IEEE80211_FC1_PWR_MGT 0x10 +#define IEEE80211_FC1_MORE_DATA 0x20 +#define IEEE80211_FC1_WEP 0x40 +#define IEEE80211_FC1_ORDER 0x80 + +#define IEEE80211_SEQ_FRAG_MASK 0x000f +#define IEEE80211_SEQ_FRAG_SHIFT 0 +#define IEEE80211_SEQ_SEQ_MASK 0xfff0 +#define IEEE80211_SEQ_SEQ_SHIFT 4 /* 4bit frag number */ + +/* Length of management frame variable-length components in bytes */ +#define IEEE80211_NWID_LEN 32 /* SSID */ +#define IEEE80211_FH_LEN 5 /* FH parameters */ +#define IEEE80211_DS_LEN 1 /* DS parameters */ +#define IEEE80211_IBSS_LEN 4 /* IBSS parameters */ +#define IEEE80211_ERP_LEN 1 /* ERP information */ + +/* + * Length of management frame information elements containing + * a variable-length component is: + * element_id(1 byte) + length(1 byte) + component(variable bytes) + */ +#define IEEE80211_ELEM_LEN(complen) (2 + (complen)) + +/* + * minimal length of beacon/probe response frame elements + * time stamp[8] + beacon interval[2] + capability[2] + */ +#define IEEE80211_BEACON_ELEM_MIN 12 +/* + * Minimal length of authentication frame elements + * algorithm[2] + sequence[2] + status[2] + */ +#define IEEE80211_AUTH_ELEM_MIN 6 +/* + * Minimal length of association response frame elements + * capability[2] + status[2] + association ID[2] + */ +#define IEEE80211_ASSOC_RESP_ELEM_MIN 6 + +#define IEEE80211_CAPINFO_ESS 0x0001 +#define IEEE80211_CAPINFO_IBSS 0x0002 +#define IEEE80211_CAPINFO_CF_POLLABLE 0x0004 +#define IEEE80211_CAPINFO_CF_POLLREQ 0x0008 +#define IEEE80211_CAPINFO_PRIVACY 0x0010 +#define IEEE80211_CAPINFO_SHORT_PREAMBLE 0x0020 +#define IEEE80211_CAPINFO_PBCC 0x0040 +#define IEEE80211_CAPINFO_CHNL_AGILITY 0x0080 +/* bits 8-9 are reserved */ +#define IEEE80211_CAPINFO_SHORT_SLOTTIME 0x0400 +#define IEEE80211_CAPINFO_RSN 0x0800 +/* bit 12 is reserved */ +#define IEEE80211_CAPINFO_DSSSOFDM 0x2000 +/* bits 14-15 are reserved */ + +/* + * Management information element payloads. + */ + +enum { + IEEE80211_ELEMID_SSID = 0, + IEEE80211_ELEMID_RATES = 1, + IEEE80211_ELEMID_FHPARMS = 2, + IEEE80211_ELEMID_DSPARMS = 3, + IEEE80211_ELEMID_CFPARMS = 4, + IEEE80211_ELEMID_TIM = 5, + IEEE80211_ELEMID_IBSSPARMS = 6, + IEEE80211_ELEMID_COUNTRY = 7, + IEEE80211_ELEMID_CHALLENGE = 16, + /* 17-31 reserved for challenge text extension */ + IEEE80211_ELEMID_ERP = 42, + IEEE80211_ELEMID_RSN = 48, + IEEE80211_ELEMID_XRATES = 50, + /* 128-129 proprietary elements used by Agere chipsets */ + IEEE80211_ELEMID_AGERE1 = 128, + IEEE80211_ELEMID_AGERE2 = 129, + IEEE80211_ELEMID_TPC = 150, + IEEE80211_ELEMID_CCKM = 156, + IEEE80211_ELEMID_VENDOR = 221 /* vendor private */ +}; + +#define IEEE80211_CHALLENGE_LEN 128 + +#define IEEE80211_RATE_BASIC 0x80 +#define IEEE80211_RATE_VAL 0x7f + +/* EPR information element flags */ +#define IEEE80211_ERP_NON_ERP_PRESENT 0x01 +#define IEEE80211_ERP_USE_PROTECTION 0x02 +#define IEEE80211_ERP_LONG_PREAMBLE 0x04 + +#define IEEE80211_AUTH_ALG_OPEN 0x0000 +#define IEEE80211_AUTH_ALG_SHARED 0x0001 +#define IEEE80211_AUTH_ALG_LEAP 0x0080 + + +enum { + IEEE80211_AUTH_OPEN_REQUEST = 1, + IEEE80211_AUTH_OPEN_RESPONSE = 2 +}; + +enum { + IEEE80211_AUTH_SHARED_REQUEST = 1, + IEEE80211_AUTH_SHARED_CHALLENGE = 2, + IEEE80211_AUTH_SHARED_RESPONSE = 3, + IEEE80211_AUTH_SHARED_PASS = 4 +}; + +/* + * Reason codes + * + * Unlisted codes are reserved + */ +enum { + IEEE80211_REASON_UNSPECIFIED = 1, + IEEE80211_REASON_AUTH_EXPIRE = 2, + IEEE80211_REASON_AUTH_LEAVE = 3, + IEEE80211_REASON_ASSOC_EXPIRE = 4, + IEEE80211_REASON_ASSOC_TOOMANY = 5, + IEEE80211_REASON_NOT_AUTHED = 6, + IEEE80211_REASON_NOT_ASSOCED = 7, + IEEE80211_REASON_ASSOC_LEAVE = 8, + IEEE80211_REASON_ASSOC_NOT_AUTHED = 9, + IEEE80211_REASON_INVALID_POWER = 10, + IEEE80211_REASON_RSN_REQUIRED = 11, + IEEE80211_REASON_RSN_INCONSISTENT = 12, + IEEE80211_REASON_IE_INVALID = 13, + IEEE80211_REASON_MIC_FAILURE = 14 +}; + +/* + * Status codes + * + * Unlisted codes are reserved and unused + */ +enum { + IEEE80211_STATUS_SUCCESS = 0, + IEEE80211_STATUS_UNSPECIFIED = 1, + IEEE80211_STATUS_CAPINFO = 10, + IEEE80211_STATUS_NOT_ASSOCED = 11, + IEEE80211_STATUS_OTHER = 12, + IEEE80211_STATUS_ALG = 13, + IEEE80211_STATUS_SEQUENCE = 14, + IEEE80211_STATUS_CHALLENGE = 15, + IEEE80211_STATUS_TIMEOUT = 16, + IEEE80211_STATUS_TOOMANY = 17, + IEEE80211_STATUS_BASIC_RATE = 18, + IEEE80211_STATUS_SP_REQUIRED = 19, + IEEE80211_STATUS_PBCC_REQUIRED = 20, + IEEE80211_STATUS_CA_REQUIRED = 21, + IEEE80211_STATUS_TOO_MANY_STATIONS = 22, + IEEE80211_STATUS_RATES = 23, + IEEE80211_STATUS_SHORTSLOT_REQUIRED = 25, + IEEE80211_STATUS_DSSSOFDM_REQUIRED = 26 +}; + +#define IEEE80211_WEP_KEYLEN 5 /* 40bit */ +#define IEEE80211_WEP_IVLEN 3 /* 24bit */ +#define IEEE80211_WEP_KIDLEN 1 /* 1 octet */ +#define IEEE80211_WEP_CRCLEN 4 /* CRC-32 */ +#define IEEE80211_WEP_NKID 4 /* number of key ids */ + +#define IEEE80211_CRC_LEN 4 + +/* + * Maximum acceptable MTU is defined by 802.11 + * Min is arbitrarily chosen > IEEE80211_MIN_LEN. + */ +#define IEEE80211_MTU_MAX 2304 +#define IEEE80211_MTU_MIN 32 +#define IEEE80211_MTU 1500 + +#define IEEE80211_MAX_LEN \ + (sizeof (struct ieee80211_frame_addr4) + \ + (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + IEEE80211_WEP_CRCLEN) + \ + IEEE80211_MTU_MAX + IEEE80211_CRC_LEN) +#define IEEE80211_ACK_LEN \ + (sizeof (struct ieee80211_frame_ack) + IEEE80211_CRC_LEN) +#define IEEE80211_MIN_LEN \ + (sizeof (struct ieee80211_frame_min) + IEEE80211_CRC_LEN) + +/* + * The 802.11 spec says at most 2007 stations may be + * associated at once. For most AP's this is way more + * than is feasible so we use a default of 128. This + * number may be overridden by the driver and/or by + * user configuration. + */ +#define IEEE80211_AID_MAX 2007 +#define IEEE80211_AID_DEF 128 + +#define IEEE80211_AID(b) ((b) &~ 0xc000) + +/* + * RTS frame length parameters. The default is specified in + * the 802.11 spec as 512; we treat it as implementation-dependent + * so it's defined in ieee80211_var.h. The max may be wrong + * for jumbo frames. + */ +#define IEEE80211_RTS_MIN 1 +#define IEEE80211_RTS_MAX 2346 + +/* + * TX fragmentation parameters. As above for RTS, we treat + * default as implementation-dependent so define it elsewhere. + */ +#define IEEE80211_FRAG_MIN 256 +#define IEEE80211_FRAG_MAX 2346 + +/* flags for ieee80211_fix_rate() */ +#define IEEE80211_F_DOSORT 0x00000001 /* sort rate list */ +#define IEEE80211_F_DOFRATE 0x00000002 /* use fixed rate */ +#define IEEE80211_F_DONEGO 0x00000004 /* calc negotiated rate */ +#define IEEE80211_F_DODEL 0x00000008 /* delete ignore rate */ + +/* + * Beacon frames constructed by ieee80211_beacon_alloc + * have the following structure filled in so drivers + * can update the frame later w/ minimal overhead. + */ +struct ieee80211_beacon_offsets { + uint16_t *bo_caps; /* capabilities */ + uint8_t *bo_tim; /* start of atim/dtim */ + uint8_t *bo_wme; /* start of WME parameters */ + uint8_t *bo_trailer; /* start of fixed-size trailer */ + uint16_t bo_tim_len; /* atim/dtim length in bytes */ + uint16_t bo_trailer_len; /* trailer length in bytes */ + uint8_t *bo_erp; /* start of ERP element */ +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_NET80211_PROTO_H */ |