1*90634029Sdyoung /* $NetBSD: ieee80211.h,v 1.13 2005/06/22 06:16:02 dyoung Exp $ */ 240e261aaSdyoung /*- 340e261aaSdyoung * Copyright (c) 2001 Atsushi Onoe 4*90634029Sdyoung * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting 540e261aaSdyoung * All rights reserved. 640e261aaSdyoung * 740e261aaSdyoung * Redistribution and use in source and binary forms, with or without 840e261aaSdyoung * modification, are permitted provided that the following conditions 940e261aaSdyoung * are met: 1040e261aaSdyoung * 1. Redistributions of source code must retain the above copyright 1140e261aaSdyoung * notice, this list of conditions and the following disclaimer. 1240e261aaSdyoung * 2. Redistributions in binary form must reproduce the above copyright 1340e261aaSdyoung * notice, this list of conditions and the following disclaimer in the 1440e261aaSdyoung * documentation and/or other materials provided with the distribution. 1540e261aaSdyoung * 3. The name of the author may not be used to endorse or promote products 1640e261aaSdyoung * derived from this software without specific prior written permission. 1740e261aaSdyoung * 1840e261aaSdyoung * Alternatively, this software may be distributed under the terms of the 1940e261aaSdyoung * GNU General Public License ("GPL") version 2 as published by the Free 2040e261aaSdyoung * Software Foundation. 2140e261aaSdyoung * 2240e261aaSdyoung * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 2340e261aaSdyoung * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 2440e261aaSdyoung * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 2540e261aaSdyoung * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 2640e261aaSdyoung * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2740e261aaSdyoung * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2840e261aaSdyoung * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2940e261aaSdyoung * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3040e261aaSdyoung * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 3140e261aaSdyoung * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3240e261aaSdyoung * 33*90634029Sdyoung * $FreeBSD: src/sys/net80211/ieee80211.h,v 1.8 2004/12/31 22:44:26 sam Exp $ 3440e261aaSdyoung */ 3540e261aaSdyoung #ifndef _NET80211_IEEE80211_H_ 3640e261aaSdyoung #define _NET80211_IEEE80211_H_ 3740e261aaSdyoung 3840e261aaSdyoung /* 3940e261aaSdyoung * 802.11 protocol definitions. 4040e261aaSdyoung */ 4140e261aaSdyoung 4240e261aaSdyoung #define IEEE80211_ADDR_LEN 6 /* size of 802.11 address */ 4340e261aaSdyoung /* is 802.11 address multicast/broadcast? */ 4440e261aaSdyoung #define IEEE80211_IS_MULTICAST(_a) (*(_a) & 0x01) 4540e261aaSdyoung 4640e261aaSdyoung /* IEEE 802.11 PLCP header */ 4740e261aaSdyoung struct ieee80211_plcp_hdr { 4840e261aaSdyoung u_int16_t i_sfd; 4940e261aaSdyoung u_int8_t i_signal; 5040e261aaSdyoung u_int8_t i_service; 5140e261aaSdyoung u_int16_t i_length; 5240e261aaSdyoung u_int16_t i_crc; 53*90634029Sdyoung } __packed; 5440e261aaSdyoung 558a3890c6Sdyoung #define IEEE80211_PLCP_SFD 0xF3A0 56*90634029Sdyoung #define IEEE80211_PLCP_SERVICE 0x00 578a3890c6Sdyoung 5840e261aaSdyoung /* 5940e261aaSdyoung * generic definitions for IEEE 802.11 frames 6040e261aaSdyoung */ 6140e261aaSdyoung struct ieee80211_frame { 6240e261aaSdyoung u_int8_t i_fc[2]; 6340e261aaSdyoung u_int8_t i_dur[2]; 6440e261aaSdyoung u_int8_t i_addr1[IEEE80211_ADDR_LEN]; 6540e261aaSdyoung u_int8_t i_addr2[IEEE80211_ADDR_LEN]; 6640e261aaSdyoung u_int8_t i_addr3[IEEE80211_ADDR_LEN]; 6740e261aaSdyoung u_int8_t i_seq[2]; 6840e261aaSdyoung /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */ 6940e261aaSdyoung /* see below */ 70*90634029Sdyoung } __packed; 7140e261aaSdyoung 72bf300177Sdyoung struct ieee80211_qosframe { 73bf300177Sdyoung u_int8_t i_fc[2]; 74bf300177Sdyoung u_int8_t i_dur[2]; 75bf300177Sdyoung u_int8_t i_addr1[IEEE80211_ADDR_LEN]; 76bf300177Sdyoung u_int8_t i_addr2[IEEE80211_ADDR_LEN]; 77bf300177Sdyoung u_int8_t i_addr3[IEEE80211_ADDR_LEN]; 78bf300177Sdyoung u_int8_t i_seq[2]; 79bf300177Sdyoung u_int8_t i_qos[2]; 80bf300177Sdyoung /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */ 81bf300177Sdyoung /* see below */ 82*90634029Sdyoung } __packed; 83bf300177Sdyoung 84bf300177Sdyoung struct ieee80211_qoscntl { 85bf300177Sdyoung u_int8_t i_qos[2]; 86bf300177Sdyoung }; 87bf300177Sdyoung 8840e261aaSdyoung struct ieee80211_frame_addr4 { 8940e261aaSdyoung u_int8_t i_fc[2]; 9040e261aaSdyoung u_int8_t i_dur[2]; 9140e261aaSdyoung u_int8_t i_addr1[IEEE80211_ADDR_LEN]; 9240e261aaSdyoung u_int8_t i_addr2[IEEE80211_ADDR_LEN]; 9340e261aaSdyoung u_int8_t i_addr3[IEEE80211_ADDR_LEN]; 9440e261aaSdyoung u_int8_t i_seq[2]; 9540e261aaSdyoung u_int8_t i_addr4[IEEE80211_ADDR_LEN]; 96*90634029Sdyoung } __packed; 9740e261aaSdyoung 98bf300177Sdyoung 99bf300177Sdyoung struct ieee80211_qosframe_addr4 { 100bf300177Sdyoung u_int8_t i_fc[2]; 101bf300177Sdyoung u_int8_t i_dur[2]; 102bf300177Sdyoung u_int8_t i_addr1[IEEE80211_ADDR_LEN]; 103bf300177Sdyoung u_int8_t i_addr2[IEEE80211_ADDR_LEN]; 104bf300177Sdyoung u_int8_t i_addr3[IEEE80211_ADDR_LEN]; 105bf300177Sdyoung u_int8_t i_seq[2]; 106bf300177Sdyoung u_int8_t i_addr4[IEEE80211_ADDR_LEN]; 107bf300177Sdyoung u_int8_t i_qos[2]; 108*90634029Sdyoung } __packed; 109bf300177Sdyoung 11040e261aaSdyoung #define IEEE80211_FC0_VERSION_MASK 0x03 11140e261aaSdyoung #define IEEE80211_FC0_VERSION_SHIFT 0 11240e261aaSdyoung #define IEEE80211_FC0_VERSION_0 0x00 11340e261aaSdyoung #define IEEE80211_FC0_TYPE_MASK 0x0c 11440e261aaSdyoung #define IEEE80211_FC0_TYPE_SHIFT 2 11540e261aaSdyoung #define IEEE80211_FC0_TYPE_MGT 0x00 11640e261aaSdyoung #define IEEE80211_FC0_TYPE_CTL 0x04 11740e261aaSdyoung #define IEEE80211_FC0_TYPE_DATA 0x08 11840e261aaSdyoung 11940e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_MASK 0xf0 12040e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_SHIFT 4 12140e261aaSdyoung /* for TYPE_MGT */ 12240e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_ASSOC_REQ 0x00 12340e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_ASSOC_RESP 0x10 12440e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_REASSOC_REQ 0x20 12540e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_REASSOC_RESP 0x30 12640e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_PROBE_REQ 0x40 12740e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_PROBE_RESP 0x50 12840e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_BEACON 0x80 12940e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_ATIM 0x90 13040e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_DISASSOC 0xa0 13140e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_AUTH 0xb0 13240e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_DEAUTH 0xc0 13340e261aaSdyoung /* for TYPE_CTL */ 13440e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_PS_POLL 0xa0 13540e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_RTS 0xb0 13640e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_CTS 0xc0 13740e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_ACK 0xd0 13840e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_CF_END 0xe0 13940e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_CF_END_ACK 0xf0 14040e261aaSdyoung /* for TYPE_DATA (bit combination) */ 14140e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_DATA 0x00 14240e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_CF_ACK 0x10 14340e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_CF_POLL 0x20 14440e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_CF_ACPL 0x30 14540e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_NODATA 0x40 14640e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_CFACK 0x50 14740e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_CFPOLL 0x60 14840e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_CF_ACK_CF_ACK 0x70 149bf300177Sdyoung #define IEEE80211_FC0_SUBTYPE_QOS 0x80 150*90634029Sdyoung #define IEEE80211_FC0_SUBTYPE_QOS_NULL 0xc0 15140e261aaSdyoung 15240e261aaSdyoung #define IEEE80211_FC1_DIR_MASK 0x03 15340e261aaSdyoung #define IEEE80211_FC1_DIR_NODS 0x00 /* STA->STA */ 15440e261aaSdyoung #define IEEE80211_FC1_DIR_TODS 0x01 /* STA->AP */ 15540e261aaSdyoung #define IEEE80211_FC1_DIR_FROMDS 0x02 /* AP ->STA */ 15640e261aaSdyoung #define IEEE80211_FC1_DIR_DSTODS 0x03 /* AP ->AP */ 15740e261aaSdyoung 15840e261aaSdyoung #define IEEE80211_FC1_MORE_FRAG 0x04 15940e261aaSdyoung #define IEEE80211_FC1_RETRY 0x08 16040e261aaSdyoung #define IEEE80211_FC1_PWR_MGT 0x10 16140e261aaSdyoung #define IEEE80211_FC1_MORE_DATA 0x20 16240e261aaSdyoung #define IEEE80211_FC1_WEP 0x40 16340e261aaSdyoung #define IEEE80211_FC1_ORDER 0x80 16440e261aaSdyoung 16540e261aaSdyoung #define IEEE80211_SEQ_FRAG_MASK 0x000f 16640e261aaSdyoung #define IEEE80211_SEQ_FRAG_SHIFT 0 16740e261aaSdyoung #define IEEE80211_SEQ_SEQ_MASK 0xfff0 16840e261aaSdyoung #define IEEE80211_SEQ_SEQ_SHIFT 4 16940e261aaSdyoung 17040e261aaSdyoung #define IEEE80211_NWID_LEN 32 17140e261aaSdyoung 172bf300177Sdyoung #define IEEE80211_QOS_TXOP 0x00ff 173bf300177Sdyoung /* bit 8 is reserved */ 174*90634029Sdyoung #define IEEE80211_QOS_ACKPOLICY 0x60 175*90634029Sdyoung #define IEEE80211_QOS_ACKPOLICY_S 5 176*90634029Sdyoung #define IEEE80211_QOS_ESOP 0x10 177*90634029Sdyoung #define IEEE80211_QOS_ESOP_S 4 178*90634029Sdyoung #define IEEE80211_QOS_TID 0x0f 179*90634029Sdyoung 180*90634029Sdyoung /* does frame have QoS sequence control data */ 181*90634029Sdyoung #define IEEE80211_QOS_HAS_SEQ(wh) \ 182*90634029Sdyoung (((wh)->i_fc[0] & \ 183*90634029Sdyoung (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_QOS)) == \ 184*90634029Sdyoung (IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_QOS)) 185bf300177Sdyoung 18640e261aaSdyoung /* 187de64f03aSmycroft * WME/802.11e information element. 188de64f03aSmycroft */ 189*90634029Sdyoung struct ieee80211_wme_info { 190de64f03aSmycroft u_int8_t wme_id; /* IEEE80211_ELEMID_VENDOR */ 191de64f03aSmycroft u_int8_t wme_len; /* length in bytes */ 192de64f03aSmycroft u_int8_t wme_oui[3]; /* 0x00, 0x50, 0xf2 */ 193de64f03aSmycroft u_int8_t wme_type; /* OUI type */ 194de64f03aSmycroft u_int8_t wme_subtype; /* OUI subtype */ 195de64f03aSmycroft u_int8_t wme_version; /* spec revision */ 196*90634029Sdyoung u_int8_t wme_info; /* QoS info */ 197*90634029Sdyoung } __packed; 198de64f03aSmycroft 199de64f03aSmycroft /* 200de64f03aSmycroft * WME/802.11e Tspec Element 201de64f03aSmycroft */ 202de64f03aSmycroft struct ieee80211_wme_tspec { 203de64f03aSmycroft u_int8_t ts_id; 204de64f03aSmycroft u_int8_t ts_len; 205de64f03aSmycroft u_int8_t ts_oui[3]; 206de64f03aSmycroft u_int8_t ts_oui_type; 207de64f03aSmycroft u_int8_t ts_oui_subtype; 208de64f03aSmycroft u_int8_t ts_version; 209de64f03aSmycroft u_int8_t ts_tsinfo[3]; 210de64f03aSmycroft u_int8_t ts_nom_msdu[2]; 211de64f03aSmycroft u_int8_t ts_max_msdu[2]; 212de64f03aSmycroft u_int8_t ts_min_svc[4]; 213de64f03aSmycroft u_int8_t ts_max_svc[4]; 214de64f03aSmycroft u_int8_t ts_inactv_intv[4]; 215de64f03aSmycroft u_int8_t ts_susp_intv[4]; 216de64f03aSmycroft u_int8_t ts_start_svc[4]; 217de64f03aSmycroft u_int8_t ts_min_rate[4]; 218de64f03aSmycroft u_int8_t ts_mean_rate[4]; 219de64f03aSmycroft u_int8_t ts_max_burst[4]; 220de64f03aSmycroft u_int8_t ts_min_phy[4]; 221de64f03aSmycroft u_int8_t ts_peak_rate[4]; 222de64f03aSmycroft u_int8_t ts_delay[4]; 223de64f03aSmycroft u_int8_t ts_surplus[2]; 224de64f03aSmycroft u_int8_t ts_medium_time[2]; 225*90634029Sdyoung } __packed; 226*90634029Sdyoung 227*90634029Sdyoung /* 228*90634029Sdyoung * WME AC parameter field 229*90634029Sdyoung */ 230*90634029Sdyoung struct ieee80211_wme_acparams { 231*90634029Sdyoung u_int8_t acp_aci_aifsn; 232*90634029Sdyoung u_int8_t acp_logcwminmax; 233*90634029Sdyoung u_int16_t acp_txop; 234*90634029Sdyoung } __packed; 235*90634029Sdyoung 236*90634029Sdyoung #define WME_NUM_AC 4 /* 4 AC categories */ 237*90634029Sdyoung 238*90634029Sdyoung #define WME_PARAM_ACI 0x60 /* Mask for ACI field */ 239*90634029Sdyoung #define WME_PARAM_ACI_S 5 /* Shift for ACI field */ 240*90634029Sdyoung #define WME_PARAM_ACM 0x10 /* Mask for ACM bit */ 241*90634029Sdyoung #define WME_PARAM_ACM_S 4 /* Shift for ACM bit */ 242*90634029Sdyoung #define WME_PARAM_AIFSN 0x0f /* Mask for aifsn field */ 243*90634029Sdyoung #define WME_PARAM_AIFSN_S 0 /* Shift for aifsn field */ 244*90634029Sdyoung #define WME_PARAM_LOGCWMIN 0x0f /* Mask for CwMin field (in log) */ 245*90634029Sdyoung #define WME_PARAM_LOGCWMIN_S 0 /* Shift for CwMin field */ 246*90634029Sdyoung #define WME_PARAM_LOGCWMAX 0xf0 /* Mask for CwMax field (in log) */ 247*90634029Sdyoung #define WME_PARAM_LOGCWMAX_S 4 /* Shift for CwMax field */ 248*90634029Sdyoung 249*90634029Sdyoung #define WME_AC_TO_TID(_ac) ( \ 250*90634029Sdyoung ((_ac) == WME_AC_VO) ? 6 : \ 251*90634029Sdyoung ((_ac) == WME_AC_VI) ? 5 : \ 252*90634029Sdyoung ((_ac) == WME_AC_BK) ? 1 : \ 253*90634029Sdyoung 0) 254*90634029Sdyoung 255*90634029Sdyoung #define TID_TO_WME_AC(_tid) ( \ 256*90634029Sdyoung ((_tid) < 1) ? WME_AC_BE : \ 257*90634029Sdyoung ((_tid) < 3) ? WME_AC_BK : \ 258*90634029Sdyoung ((_tid) < 6) ? WME_AC_VI : \ 259*90634029Sdyoung WME_AC_VO) 260*90634029Sdyoung 261*90634029Sdyoung /* 262*90634029Sdyoung * WME Parameter Element 263*90634029Sdyoung */ 264*90634029Sdyoung struct ieee80211_wme_param { 265*90634029Sdyoung u_int8_t param_id; 266*90634029Sdyoung u_int8_t param_len; 267*90634029Sdyoung u_int8_t param_oui[3]; 268*90634029Sdyoung u_int8_t param_oui_type; 269*90634029Sdyoung u_int8_t param_oui_sybtype; 270*90634029Sdyoung u_int8_t param_version; 271*90634029Sdyoung u_int8_t param_qosInfo; 272*90634029Sdyoung #define WME_QOSINFO_COUNT 0x0f /* Mask for param count field */ 273*90634029Sdyoung u_int8_t param_reserved; 274*90634029Sdyoung struct ieee80211_wme_acparams params_acParams[WME_NUM_AC]; 275*90634029Sdyoung } __packed; 276de64f03aSmycroft 277de64f03aSmycroft /* 278de64f03aSmycroft * Management Notification Frame 279de64f03aSmycroft */ 280de64f03aSmycroft struct ieee80211_mnf { 281de64f03aSmycroft u_int8_t mnf_category; 282de64f03aSmycroft u_int8_t mnf_action; 283de64f03aSmycroft u_int8_t mnf_dialog; 284de64f03aSmycroft u_int8_t mnf_status; 285*90634029Sdyoung } __packed; 286de64f03aSmycroft #define MNF_SETUP_REQ 0 287de64f03aSmycroft #define MNF_SETUP_RESP 1 288de64f03aSmycroft #define MNF_TEARDOWN 2 289de64f03aSmycroft 290de64f03aSmycroft /* 2919280f4b4Sdyoung * Control frames. 2929280f4b4Sdyoung */ 2939280f4b4Sdyoung struct ieee80211_frame_min { 2949280f4b4Sdyoung u_int8_t i_fc[2]; 2959280f4b4Sdyoung u_int8_t i_dur[2]; 2969280f4b4Sdyoung u_int8_t i_addr1[IEEE80211_ADDR_LEN]; 2979280f4b4Sdyoung u_int8_t i_addr2[IEEE80211_ADDR_LEN]; 2989280f4b4Sdyoung /* FCS */ 299*90634029Sdyoung } __packed; 3009280f4b4Sdyoung 3019280f4b4Sdyoung struct ieee80211_frame_rts { 3029280f4b4Sdyoung u_int8_t i_fc[2]; 3039280f4b4Sdyoung u_int8_t i_dur[2]; 3049280f4b4Sdyoung u_int8_t i_ra[IEEE80211_ADDR_LEN]; 3059280f4b4Sdyoung u_int8_t i_ta[IEEE80211_ADDR_LEN]; 3069280f4b4Sdyoung /* FCS */ 307*90634029Sdyoung } __packed; 3089280f4b4Sdyoung 3099280f4b4Sdyoung struct ieee80211_frame_cts { 3109280f4b4Sdyoung u_int8_t i_fc[2]; 3119280f4b4Sdyoung u_int8_t i_dur[2]; 3129280f4b4Sdyoung u_int8_t i_ra[IEEE80211_ADDR_LEN]; 3139280f4b4Sdyoung /* FCS */ 314*90634029Sdyoung } __packed; 3159280f4b4Sdyoung 3169280f4b4Sdyoung struct ieee80211_frame_ack { 3179280f4b4Sdyoung u_int8_t i_fc[2]; 3189280f4b4Sdyoung u_int8_t i_dur[2]; 3199280f4b4Sdyoung u_int8_t i_ra[IEEE80211_ADDR_LEN]; 3209280f4b4Sdyoung /* FCS */ 321*90634029Sdyoung } __packed; 3229280f4b4Sdyoung 3239280f4b4Sdyoung struct ieee80211_frame_pspoll { 3249280f4b4Sdyoung u_int8_t i_fc[2]; 3259280f4b4Sdyoung u_int8_t i_aid[2]; 3269280f4b4Sdyoung u_int8_t i_bssid[IEEE80211_ADDR_LEN]; 3279280f4b4Sdyoung u_int8_t i_ta[IEEE80211_ADDR_LEN]; 3289280f4b4Sdyoung /* FCS */ 329*90634029Sdyoung } __packed; 3309280f4b4Sdyoung 3319280f4b4Sdyoung struct ieee80211_frame_cfend { /* NB: also CF-End+CF-Ack */ 3329280f4b4Sdyoung u_int8_t i_fc[2]; 3339280f4b4Sdyoung u_int8_t i_dur[2]; /* should be zero */ 3349280f4b4Sdyoung u_int8_t i_ra[IEEE80211_ADDR_LEN]; 3359280f4b4Sdyoung u_int8_t i_bssid[IEEE80211_ADDR_LEN]; 3369280f4b4Sdyoung /* FCS */ 337*90634029Sdyoung } __packed; 3389280f4b4Sdyoung 3399280f4b4Sdyoung /* 34040e261aaSdyoung * BEACON management packets 34140e261aaSdyoung * 34240e261aaSdyoung * octet timestamp[8] 34340e261aaSdyoung * octet beacon interval[2] 34440e261aaSdyoung * octet capability information[2] 34540e261aaSdyoung * information element 34640e261aaSdyoung * octet elemid 34740e261aaSdyoung * octet length 34840e261aaSdyoung * octet information[length] 34940e261aaSdyoung */ 35040e261aaSdyoung 351de64f03aSmycroft typedef u_int8_t *ieee80211_mgt_beacon_t; 35240e261aaSdyoung 35340e261aaSdyoung #define IEEE80211_BEACON_INTERVAL(beacon) \ 35440e261aaSdyoung ((beacon)[8] | ((beacon)[9] << 8)) 35540e261aaSdyoung #define IEEE80211_BEACON_CAPABILITY(beacon) \ 35640e261aaSdyoung ((beacon)[10] | ((beacon)[11] << 8)) 35740e261aaSdyoung 35840e261aaSdyoung #define IEEE80211_CAPINFO_ESS 0x0001 35940e261aaSdyoung #define IEEE80211_CAPINFO_IBSS 0x0002 36040e261aaSdyoung #define IEEE80211_CAPINFO_CF_POLLABLE 0x0004 36140e261aaSdyoung #define IEEE80211_CAPINFO_CF_POLLREQ 0x0008 36240e261aaSdyoung #define IEEE80211_CAPINFO_PRIVACY 0x0010 36340e261aaSdyoung #define IEEE80211_CAPINFO_SHORT_PREAMBLE 0x0020 36440e261aaSdyoung #define IEEE80211_CAPINFO_PBCC 0x0040 36540e261aaSdyoung #define IEEE80211_CAPINFO_CHNL_AGILITY 0x0080 36640e261aaSdyoung /* bits 8-9 are reserved */ 36740e261aaSdyoung #define IEEE80211_CAPINFO_SHORT_SLOTTIME 0x0400 368bf300177Sdyoung #define IEEE80211_CAPINFO_RSN 0x0800 369bf300177Sdyoung /* bit 12 is reserved */ 37040e261aaSdyoung #define IEEE80211_CAPINFO_DSSSOFDM 0x2000 37140e261aaSdyoung /* bits 14-15 are reserved */ 37240e261aaSdyoung 37340e261aaSdyoung /* 374bf300177Sdyoung * 802.11i/WPA information element (maximally sized). 375bf300177Sdyoung */ 376bf300177Sdyoung struct ieee80211_ie_wpa { 377de64f03aSmycroft u_int8_t wpa_id; /* IEEE80211_ELEMID_VENDOR */ 378de64f03aSmycroft u_int8_t wpa_len; /* length in bytes */ 379bf300177Sdyoung u_int8_t wpa_oui[3]; /* 0x00, 0x50, 0xf2 */ 380bf300177Sdyoung u_int8_t wpa_type; /* OUI type */ 381bf300177Sdyoung u_int16_t wpa_version; /* spec revision */ 382bf300177Sdyoung u_int32_t wpa_mcipher[1]; /* multicast/group key cipher */ 383bf300177Sdyoung u_int16_t wpa_uciphercnt; /* # pairwise key ciphers */ 384bf300177Sdyoung u_int32_t wpa_uciphers[8];/* ciphers */ 385bf300177Sdyoung u_int16_t wpa_authselcnt; /* authentication selector cnt*/ 386bf300177Sdyoung u_int32_t wpa_authsels[8];/* selectors */ 387de64f03aSmycroft u_int16_t wpa_caps; /* 802.11i capabilities */ 388de64f03aSmycroft u_int16_t wpa_pmkidcnt; /* 802.11i pmkid count */ 389de64f03aSmycroft u_int16_t wpa_pmkids[8]; /* 802.11i pmkids */ 390*90634029Sdyoung } __packed; 391bf300177Sdyoung 392bf300177Sdyoung /* 393*90634029Sdyoung * Management information element payloads. 39440e261aaSdyoung */ 39540e261aaSdyoung 39640e261aaSdyoung enum { 39740e261aaSdyoung IEEE80211_ELEMID_SSID = 0, 39840e261aaSdyoung IEEE80211_ELEMID_RATES = 1, 39940e261aaSdyoung IEEE80211_ELEMID_FHPARMS = 2, 40040e261aaSdyoung IEEE80211_ELEMID_DSPARMS = 3, 40140e261aaSdyoung IEEE80211_ELEMID_CFPARMS = 4, 40240e261aaSdyoung IEEE80211_ELEMID_TIM = 5, 40340e261aaSdyoung IEEE80211_ELEMID_IBSSPARMS = 6, 40440e261aaSdyoung IEEE80211_ELEMID_COUNTRY = 7, 40540e261aaSdyoung IEEE80211_ELEMID_CHALLENGE = 16, 406bf300177Sdyoung /* 17-31 reserved for challenge text extension */ 40740e261aaSdyoung IEEE80211_ELEMID_ERP = 42, 408de64f03aSmycroft IEEE80211_ELEMID_RSN = 48, 40940e261aaSdyoung IEEE80211_ELEMID_XRATES = 50, 410bf300177Sdyoung IEEE80211_ELEMID_TPC = 150, 411bf300177Sdyoung IEEE80211_ELEMID_CCKM = 156, 412bf300177Sdyoung IEEE80211_ELEMID_VENDOR = 221, /* vendor private */ 41340e261aaSdyoung }; 41440e261aaSdyoung 415*90634029Sdyoung struct ieee80211_tim_ie { 416*90634029Sdyoung u_int8_t tim_ie; /* IEEE80211_ELEMID_TIM */ 417*90634029Sdyoung u_int8_t tim_len; 418*90634029Sdyoung u_int8_t tim_count; /* DTIM count */ 419*90634029Sdyoung u_int8_t tim_period; /* DTIM period */ 420*90634029Sdyoung u_int8_t tim_bitctl; /* bitmap control */ 421*90634029Sdyoung u_int8_t tim_bitmap[1]; /* variable-length bitmap */ 422*90634029Sdyoung } __packed; 423*90634029Sdyoung 424*90634029Sdyoung struct ieee80211_country_ie { 425*90634029Sdyoung u_int8_t ie; /* IEEE80211_ELEMID_COUNTRY */ 426*90634029Sdyoung u_int8_t len; 427*90634029Sdyoung u_int8_t cc[3]; /* ISO CC+(I)ndoor/(O)utdoor */ 428*90634029Sdyoung struct { 429*90634029Sdyoung u_int8_t schan; /* starting channel */ 430*90634029Sdyoung u_int8_t nchan; /* number channels */ 431*90634029Sdyoung u_int8_t maxtxpwr; /* tx power cap */ 432*90634029Sdyoung } band[4] __packed; /* up to 4 sub bands */ 433*90634029Sdyoung } __packed; 434*90634029Sdyoung 435db0e43b2Sdyoung #define IEEE80211_CHALLENGE_LEN 128 436db0e43b2Sdyoung 43740e261aaSdyoung #define IEEE80211_RATE_BASIC 0x80 43840e261aaSdyoung #define IEEE80211_RATE_VAL 0x7f 43940e261aaSdyoung 44040e261aaSdyoung /* EPR information element flags */ 44140e261aaSdyoung #define IEEE80211_ERP_NON_ERP_PRESENT 0x01 44240e261aaSdyoung #define IEEE80211_ERP_USE_PROTECTION 0x02 443de64f03aSmycroft #define IEEE80211_ERP_LONG_PREAMBLE 0x04 44440e261aaSdyoung 445bf300177Sdyoung /* Atheros private advanced capabilities info */ 446bf300177Sdyoung #define ATHEROS_CAP_TURBO_PRIME 0x01 447bf300177Sdyoung #define ATHEROS_CAP_COMPRESSION 0x02 448bf300177Sdyoung #define ATHEROS_CAP_FAST_FRAME 0x04 449bf300177Sdyoung /* bits 3-6 reserved */ 450bf300177Sdyoung #define ATHEROS_CAP_BOOST 0x80 451bf300177Sdyoung 452bf300177Sdyoung #define ATH_OUI 0x7f0300 /* Atheros OUI */ 453bf300177Sdyoung #define ATH_OUI_TYPE 0x01 454bf300177Sdyoung #define ATH_OUI_VERSION 0x01 455bf300177Sdyoung 456bf300177Sdyoung #define WPA_OUI 0xf25000 457bf300177Sdyoung #define WPA_OUI_TYPE 0x01 458de64f03aSmycroft #define WPA_VERSION 1 /* current supported version */ 459bf300177Sdyoung 460bf300177Sdyoung #define WPA_CSE_NULL 0x00 461bf300177Sdyoung #define WPA_CSE_WEP40 0x01 462bf300177Sdyoung #define WPA_CSE_TKIP 0x02 463bf300177Sdyoung #define WPA_CSE_CCMP 0x04 464bf300177Sdyoung #define WPA_CSE_WEP104 0x05 465bf300177Sdyoung 466bf300177Sdyoung #define WPA_ASE_NONE 0x00 467bf300177Sdyoung #define WPA_ASE_8021X_UNSPEC 0x01 468bf300177Sdyoung #define WPA_ASE_8021X_PSK 0x02 469bf300177Sdyoung 470de64f03aSmycroft #define RSN_OUI 0xac0f00 471de64f03aSmycroft #define RSN_VERSION 1 /* current supported version */ 472de64f03aSmycroft 473de64f03aSmycroft #define RSN_CSE_NULL 0x00 474de64f03aSmycroft #define RSN_CSE_WEP40 0x01 475de64f03aSmycroft #define RSN_CSE_TKIP 0x02 476de64f03aSmycroft #define RSN_CSE_WRAP 0x03 477de64f03aSmycroft #define RSN_CSE_CCMP 0x04 478de64f03aSmycroft #define RSN_CSE_WEP104 0x05 479de64f03aSmycroft 480de64f03aSmycroft #define RSN_ASE_NONE 0x00 481de64f03aSmycroft #define RSN_ASE_8021X_UNSPEC 0x01 482de64f03aSmycroft #define RSN_ASE_8021X_PSK 0x02 483de64f03aSmycroft 484*90634029Sdyoung #define RSN_CAP_PREAUTH 0x01 485*90634029Sdyoung 486de64f03aSmycroft #define WME_OUI 0xf25000 487de64f03aSmycroft #define WME_OUI_TYPE 0x02 488*90634029Sdyoung #define WME_INFO_OUI_SUBTYPE 0x00 489*90634029Sdyoung #define WME_PARAM_OUI_SUBTYPE 0x01 490de64f03aSmycroft #define WME_VERSION 1 491de64f03aSmycroft 492de64f03aSmycroft /* WME stream classes */ 493de64f03aSmycroft #define WME_AC_BE 0 /* best effort */ 494de64f03aSmycroft #define WME_AC_BK 1 /* background */ 495de64f03aSmycroft #define WME_AC_VI 2 /* video */ 496de64f03aSmycroft #define WME_AC_VO 3 /* voice */ 497de64f03aSmycroft 49840e261aaSdyoung /* 49940e261aaSdyoung * AUTH management packets 50040e261aaSdyoung * 50140e261aaSdyoung * octet algo[2] 50240e261aaSdyoung * octet seq[2] 50340e261aaSdyoung * octet status[2] 50440e261aaSdyoung * octet chal.id 50540e261aaSdyoung * octet chal.length 50640e261aaSdyoung * octet chal.text[253] 50740e261aaSdyoung */ 50840e261aaSdyoung 50940e261aaSdyoung typedef u_int8_t *ieee80211_mgt_auth_t; 51040e261aaSdyoung 51140e261aaSdyoung #define IEEE80211_AUTH_ALGORITHM(auth) \ 51240e261aaSdyoung ((auth)[0] | ((auth)[1] << 8)) 51340e261aaSdyoung #define IEEE80211_AUTH_TRANSACTION(auth) \ 51440e261aaSdyoung ((auth)[2] | ((auth)[3] << 8)) 51540e261aaSdyoung #define IEEE80211_AUTH_STATUS(auth) \ 51640e261aaSdyoung ((auth)[4] | ((auth)[5] << 8)) 51740e261aaSdyoung 51840e261aaSdyoung #define IEEE80211_AUTH_ALG_OPEN 0x0000 51940e261aaSdyoung #define IEEE80211_AUTH_ALG_SHARED 0x0001 520bf300177Sdyoung #define IEEE80211_AUTH_ALG_LEAP 0x0080 52140e261aaSdyoung 52240e261aaSdyoung enum { 52340e261aaSdyoung IEEE80211_AUTH_OPEN_REQUEST = 1, 52440e261aaSdyoung IEEE80211_AUTH_OPEN_RESPONSE = 2, 52540e261aaSdyoung }; 52640e261aaSdyoung 52740e261aaSdyoung enum { 52840e261aaSdyoung IEEE80211_AUTH_SHARED_REQUEST = 1, 52940e261aaSdyoung IEEE80211_AUTH_SHARED_CHALLENGE = 2, 53040e261aaSdyoung IEEE80211_AUTH_SHARED_RESPONSE = 3, 53140e261aaSdyoung IEEE80211_AUTH_SHARED_PASS = 4, 53240e261aaSdyoung }; 53340e261aaSdyoung 53440e261aaSdyoung /* 53540e261aaSdyoung * Reason codes 53640e261aaSdyoung * 53740e261aaSdyoung * Unlisted codes are reserved 53840e261aaSdyoung */ 53940e261aaSdyoung 54040e261aaSdyoung enum { 54140e261aaSdyoung IEEE80211_REASON_UNSPECIFIED = 1, 54240e261aaSdyoung IEEE80211_REASON_AUTH_EXPIRE = 2, 54340e261aaSdyoung IEEE80211_REASON_AUTH_LEAVE = 3, 54440e261aaSdyoung IEEE80211_REASON_ASSOC_EXPIRE = 4, 54540e261aaSdyoung IEEE80211_REASON_ASSOC_TOOMANY = 5, 54640e261aaSdyoung IEEE80211_REASON_NOT_AUTHED = 6, 54740e261aaSdyoung IEEE80211_REASON_NOT_ASSOCED = 7, 54840e261aaSdyoung IEEE80211_REASON_ASSOC_LEAVE = 8, 54940e261aaSdyoung IEEE80211_REASON_ASSOC_NOT_AUTHED = 9, 55040e261aaSdyoung 551bf300177Sdyoung IEEE80211_REASON_RSN_REQUIRED = 11, 552bf300177Sdyoung IEEE80211_REASON_RSN_INCONSISTENT = 12, 553bf300177Sdyoung IEEE80211_REASON_IE_INVALID = 13, 554bf300177Sdyoung IEEE80211_REASON_MIC_FAILURE = 14, 555bf300177Sdyoung 55640e261aaSdyoung IEEE80211_STATUS_SUCCESS = 0, 55740e261aaSdyoung IEEE80211_STATUS_UNSPECIFIED = 1, 55840e261aaSdyoung IEEE80211_STATUS_CAPINFO = 10, 55940e261aaSdyoung IEEE80211_STATUS_NOT_ASSOCED = 11, 56040e261aaSdyoung IEEE80211_STATUS_OTHER = 12, 56140e261aaSdyoung IEEE80211_STATUS_ALG = 13, 56240e261aaSdyoung IEEE80211_STATUS_SEQUENCE = 14, 56340e261aaSdyoung IEEE80211_STATUS_CHALLENGE = 15, 56440e261aaSdyoung IEEE80211_STATUS_TIMEOUT = 16, 56540e261aaSdyoung IEEE80211_STATUS_TOOMANY = 17, 56640e261aaSdyoung IEEE80211_STATUS_BASIC_RATE = 18, 56740e261aaSdyoung IEEE80211_STATUS_SP_REQUIRED = 19, 56840e261aaSdyoung IEEE80211_STATUS_PBCC_REQUIRED = 20, 56940e261aaSdyoung IEEE80211_STATUS_CA_REQUIRED = 21, 57040e261aaSdyoung IEEE80211_STATUS_TOO_MANY_STATIONS = 22, 57140e261aaSdyoung IEEE80211_STATUS_RATES = 23, 57240e261aaSdyoung IEEE80211_STATUS_SHORTSLOT_REQUIRED = 25, 57340e261aaSdyoung IEEE80211_STATUS_DSSSOFDM_REQUIRED = 26, 57440e261aaSdyoung }; 57540e261aaSdyoung 57640e261aaSdyoung #define IEEE80211_WEP_KEYLEN 5 /* 40bit */ 57740e261aaSdyoung #define IEEE80211_WEP_IVLEN 3 /* 24bit */ 57840e261aaSdyoung #define IEEE80211_WEP_KIDLEN 1 /* 1 octet */ 57940e261aaSdyoung #define IEEE80211_WEP_CRCLEN 4 /* CRC-32 */ 58081eefc6fSdyoung #define IEEE80211_WEP_TOTLEN (IEEE80211_WEP_IVLEN + \ 58181eefc6fSdyoung IEEE80211_WEP_KIDLEN + \ 58281eefc6fSdyoung IEEE80211_WEP_CRCLEN) 583*90634029Sdyoung #define IEEE80211_WEP_NKID 4 /* number of key ids */ 584*90634029Sdyoung 585de64f03aSmycroft /* 586de64f03aSmycroft * 802.11i defines an extended IV for use with non-WEP ciphers. 587de64f03aSmycroft * When the EXTIV bit is set in the key id byte an additional 588de64f03aSmycroft * 4 bytes immediately follow the IV for TKIP. For CCMP the 589de64f03aSmycroft * EXTIV bit is likewise set but the 8 bytes represent the 590de64f03aSmycroft * CCMP header rather than IV+extended-IV. 591de64f03aSmycroft */ 592de64f03aSmycroft #define IEEE80211_WEP_EXTIV 0x20 593de64f03aSmycroft #define IEEE80211_WEP_EXTIVLEN 4 /* extended IV length */ 594de64f03aSmycroft #define IEEE80211_WEP_MICLEN 8 /* trailing MIC */ 595de64f03aSmycroft 59640e261aaSdyoung #define IEEE80211_CRC_LEN 4 59740e261aaSdyoung 598bf300177Sdyoung /* 599bf300177Sdyoung * Maximum acceptable MTU is: 600bf300177Sdyoung * IEEE80211_MAX_LEN - WEP overhead - CRC - 601bf300177Sdyoung * QoS overhead - RSN/WPA overhead 602bf300177Sdyoung * Min is arbitrarily chosen > IEEE80211_MIN_LEN. The default 603bf300177Sdyoung * mtu is Ethernet-compatible; it's set by ether_ifattach. 604bf300177Sdyoung */ 605bf300177Sdyoung #define IEEE80211_MTU_MAX 2290 606bf300177Sdyoung #define IEEE80211_MTU_MIN 32 607bf300177Sdyoung 60840e261aaSdyoung #define IEEE80211_MAX_LEN (2300 + IEEE80211_CRC_LEN + \ 60940e261aaSdyoung (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + IEEE80211_WEP_CRCLEN)) 610de64f03aSmycroft #define IEEE80211_ACK_LEN \ 611de64f03aSmycroft (sizeof(struct ieee80211_frame_ack) + IEEE80211_CRC_LEN) 6129280f4b4Sdyoung #define IEEE80211_MIN_LEN \ 6139280f4b4Sdyoung (sizeof(struct ieee80211_frame_min) + IEEE80211_CRC_LEN) 61440e261aaSdyoung 615de64f03aSmycroft /* 616de64f03aSmycroft * The 802.11 spec says at most 2007 stations may be 617de64f03aSmycroft * associated at once. For most AP's this is way more 618de64f03aSmycroft * than is feasible so we use a default of 128. This 619de64f03aSmycroft * number may be overridden by the driver and/or by 620de64f03aSmycroft * user configuration. 621de64f03aSmycroft */ 622de64f03aSmycroft #define IEEE80211_AID_MAX 2007 623de64f03aSmycroft #define IEEE80211_AID_DEF 128 6248a3890c6Sdyoung 625de64f03aSmycroft #define IEEE80211_AID(b) ((b) &~ 0xc000) 6268a3890c6Sdyoung #define IEEE80211_AID_SET(b, w) \ 627de64f03aSmycroft ((w)[IEEE80211_AID(b) / 32] |= (1 << (IEEE80211_AID(b) % 32))) 6288a3890c6Sdyoung #define IEEE80211_AID_CLR(b, w) \ 629de64f03aSmycroft ((w)[IEEE80211_AID(b) / 32] &= ~(1 << (IEEE80211_AID(b) % 32))) 6308a3890c6Sdyoung #define IEEE80211_AID_ISSET(b, w) \ 631de64f03aSmycroft ((w)[IEEE80211_AID(b) / 32] & (1 << (IEEE80211_AID(b) % 32))) 6328a3890c6Sdyoung 63340e261aaSdyoung /* 63440e261aaSdyoung * RTS frame length parameters. The default is specified in 63540e261aaSdyoung * the 802.11 spec. The max may be wrong for jumbo frames. 63640e261aaSdyoung */ 63740e261aaSdyoung #define IEEE80211_RTS_DEFAULT 512 63840e261aaSdyoung #define IEEE80211_RTS_MIN 1 63940e261aaSdyoung #define IEEE80211_RTS_MAX IEEE80211_MAX_LEN 64040e261aaSdyoung 64181eefc6fSdyoung /* 64281eefc6fSdyoung * 802.11 frame duration definitions. 64381eefc6fSdyoung */ 64481eefc6fSdyoung 64581eefc6fSdyoung struct ieee80211_duration { 64681eefc6fSdyoung uint16_t d_rts_dur; 64781eefc6fSdyoung uint16_t d_data_dur; 64881eefc6fSdyoung uint16_t d_plcp_len; 64906e4fe7fSmycroft uint8_t d_residue; /* unused octets in time slot */ 65081eefc6fSdyoung }; 65181eefc6fSdyoung 65281eefc6fSdyoung /* One Time Unit (TU) is 1Kus = 1024 microseconds. */ 65381eefc6fSdyoung #define IEEE80211_DUR_TU 1024 65481eefc6fSdyoung 65581eefc6fSdyoung /* IEEE 802.11b durations for DSSS PHY in microseconds */ 65681eefc6fSdyoung #define IEEE80211_DUR_DS_LONG_PREAMBLE 144 65781eefc6fSdyoung #define IEEE80211_DUR_DS_SHORT_PREAMBLE 72 6581989546aSmycroft 65981eefc6fSdyoung #define IEEE80211_DUR_DS_SLOW_PLCPHDR 48 6601989546aSmycroft #define IEEE80211_DUR_DS_FAST_PLCPHDR 24 66181eefc6fSdyoung #define IEEE80211_DUR_DS_SLOW_ACK 112 66281eefc6fSdyoung #define IEEE80211_DUR_DS_FAST_ACK 56 66381eefc6fSdyoung #define IEEE80211_DUR_DS_SLOW_CTS 112 66481eefc6fSdyoung #define IEEE80211_DUR_DS_FAST_CTS 56 6651989546aSmycroft 66681eefc6fSdyoung #define IEEE80211_DUR_DS_SLOT 20 66781eefc6fSdyoung #define IEEE80211_DUR_DS_SIFS 10 66881eefc6fSdyoung #define IEEE80211_DUR_DS_PIFS (IEEE80211_DUR_DS_SIFS + IEEE80211_DUR_DS_SLOT) 66981eefc6fSdyoung #define IEEE80211_DUR_DS_DIFS (IEEE80211_DUR_DS_SIFS + \ 67081eefc6fSdyoung 2 * IEEE80211_DUR_DS_SLOT) 67181eefc6fSdyoung #define IEEE80211_DUR_DS_EIFS (IEEE80211_DUR_DS_SIFS + \ 67281eefc6fSdyoung IEEE80211_DUR_DS_SLOW_ACK + \ 67381eefc6fSdyoung IEEE80211_DUR_DS_LONG_PREAMBLE + \ 67481eefc6fSdyoung IEEE80211_DUR_DS_SLOW_PLCPHDR + \ 67581eefc6fSdyoung IEEE80211_DUR_DIFS) 67681eefc6fSdyoung 67740e261aaSdyoung 67840e261aaSdyoung #endif /* _NET80211_IEEE80211_H_ */ 679