1*1989546aSmycroft /* $NetBSD: ieee80211.h,v 1.11 2004/12/27 05:36:08 mycroft Exp $ */ 240e261aaSdyoung /*- 340e261aaSdyoung * Copyright (c) 2001 Atsushi Onoe 4de64f03aSmycroft * Copyright (c) 2002-2004 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 * 33bf300177Sdyoung * $FreeBSD: src/sys/net80211/ieee80211.h,v 1.5 2004/04/05 17:47:40 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; 5340e261aaSdyoung } __attribute__((__packed__)); 5440e261aaSdyoung 558a3890c6Sdyoung #define IEEE80211_PLCP_SFD 0xF3A0 568a3890c6Sdyoung 5740e261aaSdyoung /* 5840e261aaSdyoung * generic definitions for IEEE 802.11 frames 5940e261aaSdyoung */ 6040e261aaSdyoung struct ieee80211_frame { 6140e261aaSdyoung u_int8_t i_fc[2]; 6240e261aaSdyoung u_int8_t i_dur[2]; 6340e261aaSdyoung u_int8_t i_addr1[IEEE80211_ADDR_LEN]; 6440e261aaSdyoung u_int8_t i_addr2[IEEE80211_ADDR_LEN]; 6540e261aaSdyoung u_int8_t i_addr3[IEEE80211_ADDR_LEN]; 6640e261aaSdyoung u_int8_t i_seq[2]; 6740e261aaSdyoung /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */ 6840e261aaSdyoung /* see below */ 6940e261aaSdyoung } __attribute__((__packed__)); 7040e261aaSdyoung 71bf300177Sdyoung struct ieee80211_qosframe { 72bf300177Sdyoung u_int8_t i_fc[2]; 73bf300177Sdyoung u_int8_t i_dur[2]; 74bf300177Sdyoung u_int8_t i_addr1[IEEE80211_ADDR_LEN]; 75bf300177Sdyoung u_int8_t i_addr2[IEEE80211_ADDR_LEN]; 76bf300177Sdyoung u_int8_t i_addr3[IEEE80211_ADDR_LEN]; 77bf300177Sdyoung u_int8_t i_seq[2]; 78bf300177Sdyoung u_int8_t i_qos[2]; 79bf300177Sdyoung /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */ 80bf300177Sdyoung /* see below */ 81bf300177Sdyoung } __attribute__((__packed__)); 82bf300177Sdyoung 83bf300177Sdyoung struct ieee80211_qoscntl { 84bf300177Sdyoung u_int8_t i_qos[2]; 85bf300177Sdyoung }; 86bf300177Sdyoung 8740e261aaSdyoung struct ieee80211_frame_addr4 { 8840e261aaSdyoung u_int8_t i_fc[2]; 8940e261aaSdyoung u_int8_t i_dur[2]; 9040e261aaSdyoung u_int8_t i_addr1[IEEE80211_ADDR_LEN]; 9140e261aaSdyoung u_int8_t i_addr2[IEEE80211_ADDR_LEN]; 9240e261aaSdyoung u_int8_t i_addr3[IEEE80211_ADDR_LEN]; 9340e261aaSdyoung u_int8_t i_seq[2]; 9440e261aaSdyoung u_int8_t i_addr4[IEEE80211_ADDR_LEN]; 9540e261aaSdyoung } __attribute__((__packed__)); 9640e261aaSdyoung 97bf300177Sdyoung 98bf300177Sdyoung struct ieee80211_qosframe_addr4 { 99bf300177Sdyoung u_int8_t i_fc[2]; 100bf300177Sdyoung u_int8_t i_dur[2]; 101bf300177Sdyoung u_int8_t i_addr1[IEEE80211_ADDR_LEN]; 102bf300177Sdyoung u_int8_t i_addr2[IEEE80211_ADDR_LEN]; 103bf300177Sdyoung u_int8_t i_addr3[IEEE80211_ADDR_LEN]; 104bf300177Sdyoung u_int8_t i_seq[2]; 105bf300177Sdyoung u_int8_t i_addr4[IEEE80211_ADDR_LEN]; 106bf300177Sdyoung u_int8_t i_qos[2]; 107bf300177Sdyoung } __attribute__((__packed__)); 108bf300177Sdyoung 10940e261aaSdyoung #define IEEE80211_FC0_VERSION_MASK 0x03 11040e261aaSdyoung #define IEEE80211_FC0_VERSION_SHIFT 0 11140e261aaSdyoung #define IEEE80211_FC0_VERSION_0 0x00 11240e261aaSdyoung #define IEEE80211_FC0_TYPE_MASK 0x0c 11340e261aaSdyoung #define IEEE80211_FC0_TYPE_SHIFT 2 11440e261aaSdyoung #define IEEE80211_FC0_TYPE_MGT 0x00 11540e261aaSdyoung #define IEEE80211_FC0_TYPE_CTL 0x04 11640e261aaSdyoung #define IEEE80211_FC0_TYPE_DATA 0x08 11740e261aaSdyoung 11840e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_MASK 0xf0 11940e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_SHIFT 4 12040e261aaSdyoung /* for TYPE_MGT */ 12140e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_ASSOC_REQ 0x00 12240e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_ASSOC_RESP 0x10 12340e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_REASSOC_REQ 0x20 12440e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_REASSOC_RESP 0x30 12540e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_PROBE_REQ 0x40 12640e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_PROBE_RESP 0x50 12740e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_BEACON 0x80 12840e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_ATIM 0x90 12940e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_DISASSOC 0xa0 13040e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_AUTH 0xb0 13140e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_DEAUTH 0xc0 13240e261aaSdyoung /* for TYPE_CTL */ 13340e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_PS_POLL 0xa0 13440e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_RTS 0xb0 13540e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_CTS 0xc0 13640e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_ACK 0xd0 13740e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_CF_END 0xe0 13840e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_CF_END_ACK 0xf0 13940e261aaSdyoung /* for TYPE_DATA (bit combination) */ 14040e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_DATA 0x00 14140e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_CF_ACK 0x10 14240e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_CF_POLL 0x20 14340e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_CF_ACPL 0x30 14440e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_NODATA 0x40 14540e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_CFACK 0x50 14640e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_CFPOLL 0x60 14740e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_CF_ACK_CF_ACK 0x70 148bf300177Sdyoung #define IEEE80211_FC0_SUBTYPE_QOS 0x80 14940e261aaSdyoung 15040e261aaSdyoung #define IEEE80211_FC1_DIR_MASK 0x03 15140e261aaSdyoung #define IEEE80211_FC1_DIR_NODS 0x00 /* STA->STA */ 15240e261aaSdyoung #define IEEE80211_FC1_DIR_TODS 0x01 /* STA->AP */ 15340e261aaSdyoung #define IEEE80211_FC1_DIR_FROMDS 0x02 /* AP ->STA */ 15440e261aaSdyoung #define IEEE80211_FC1_DIR_DSTODS 0x03 /* AP ->AP */ 15540e261aaSdyoung 15640e261aaSdyoung #define IEEE80211_FC1_MORE_FRAG 0x04 15740e261aaSdyoung #define IEEE80211_FC1_RETRY 0x08 15840e261aaSdyoung #define IEEE80211_FC1_PWR_MGT 0x10 15940e261aaSdyoung #define IEEE80211_FC1_MORE_DATA 0x20 16040e261aaSdyoung #define IEEE80211_FC1_WEP 0x40 16140e261aaSdyoung #define IEEE80211_FC1_ORDER 0x80 16240e261aaSdyoung 16340e261aaSdyoung #define IEEE80211_SEQ_FRAG_MASK 0x000f 16440e261aaSdyoung #define IEEE80211_SEQ_FRAG_SHIFT 0 16540e261aaSdyoung #define IEEE80211_SEQ_SEQ_MASK 0xfff0 16640e261aaSdyoung #define IEEE80211_SEQ_SEQ_SHIFT 4 16740e261aaSdyoung 16840e261aaSdyoung #define IEEE80211_NWID_LEN 32 16940e261aaSdyoung 170bf300177Sdyoung #define IEEE80211_QOS_TXOP 0x00ff 171bf300177Sdyoung /* bit 8 is reserved */ 172bf300177Sdyoung #define IEEE80211_QOS_ACKPOLICY 0x0600 173bf300177Sdyoung #define IEEE80211_QOS_ESOP 0x0800 174bf300177Sdyoung #define IEEE80211_QOS_TID 0xf000 175bf300177Sdyoung 17640e261aaSdyoung /* 177de64f03aSmycroft * WME/802.11e information element. 178de64f03aSmycroft */ 179de64f03aSmycroft struct ieee80211_ie_wme { 180de64f03aSmycroft u_int8_t wme_id; /* IEEE80211_ELEMID_VENDOR */ 181de64f03aSmycroft u_int8_t wme_len; /* length in bytes */ 182de64f03aSmycroft u_int8_t wme_oui[3]; /* 0x00, 0x50, 0xf2 */ 183de64f03aSmycroft u_int8_t wme_type; /* OUI type */ 184de64f03aSmycroft u_int8_t wme_subtype; /* OUI subtype */ 185de64f03aSmycroft u_int8_t wme_version; /* spec revision */ 186de64f03aSmycroft u_int8_t wme_info; /* AC info */ 187de64f03aSmycroft } __attribute__((__packed__)); 188de64f03aSmycroft 189de64f03aSmycroft /* 190de64f03aSmycroft * WME/802.11e Tspec Element 191de64f03aSmycroft */ 192de64f03aSmycroft struct ieee80211_wme_tspec { 193de64f03aSmycroft u_int8_t ts_id; 194de64f03aSmycroft u_int8_t ts_len; 195de64f03aSmycroft u_int8_t ts_oui[3]; 196de64f03aSmycroft u_int8_t ts_oui_type; 197de64f03aSmycroft u_int8_t ts_oui_subtype; 198de64f03aSmycroft u_int8_t ts_version; 199de64f03aSmycroft u_int8_t ts_tsinfo[3]; 200de64f03aSmycroft u_int8_t ts_nom_msdu[2]; 201de64f03aSmycroft u_int8_t ts_max_msdu[2]; 202de64f03aSmycroft u_int8_t ts_min_svc[4]; 203de64f03aSmycroft u_int8_t ts_max_svc[4]; 204de64f03aSmycroft u_int8_t ts_inactv_intv[4]; 205de64f03aSmycroft u_int8_t ts_susp_intv[4]; 206de64f03aSmycroft u_int8_t ts_start_svc[4]; 207de64f03aSmycroft u_int8_t ts_min_rate[4]; 208de64f03aSmycroft u_int8_t ts_mean_rate[4]; 209de64f03aSmycroft u_int8_t ts_max_burst[4]; 210de64f03aSmycroft u_int8_t ts_min_phy[4]; 211de64f03aSmycroft u_int8_t ts_peak_rate[4]; 212de64f03aSmycroft u_int8_t ts_delay[4]; 213de64f03aSmycroft u_int8_t ts_surplus[2]; 214de64f03aSmycroft u_int8_t ts_medium_time[2]; 215de64f03aSmycroft } __attribute__((__packed__)); 216de64f03aSmycroft 217de64f03aSmycroft /* 218de64f03aSmycroft * Management Notification Frame 219de64f03aSmycroft */ 220de64f03aSmycroft struct ieee80211_mnf { 221de64f03aSmycroft u_int8_t mnf_category; 222de64f03aSmycroft u_int8_t mnf_action; 223de64f03aSmycroft u_int8_t mnf_dialog; 224de64f03aSmycroft u_int8_t mnf_status; 225de64f03aSmycroft } __attribute__((__packed__)); 226de64f03aSmycroft #define MNF_SETUP_REQ 0 227de64f03aSmycroft #define MNF_SETUP_RESP 1 228de64f03aSmycroft #define MNF_TEARDOWN 2 229de64f03aSmycroft 230de64f03aSmycroft /* 2319280f4b4Sdyoung * Control frames. 2329280f4b4Sdyoung */ 2339280f4b4Sdyoung struct ieee80211_frame_min { 2349280f4b4Sdyoung u_int8_t i_fc[2]; 2359280f4b4Sdyoung u_int8_t i_dur[2]; 2369280f4b4Sdyoung u_int8_t i_addr1[IEEE80211_ADDR_LEN]; 2379280f4b4Sdyoung u_int8_t i_addr2[IEEE80211_ADDR_LEN]; 2389280f4b4Sdyoung /* FCS */ 2399280f4b4Sdyoung } __attribute__((__packed__)); 2409280f4b4Sdyoung 2419280f4b4Sdyoung struct ieee80211_frame_rts { 2429280f4b4Sdyoung u_int8_t i_fc[2]; 2439280f4b4Sdyoung u_int8_t i_dur[2]; 2449280f4b4Sdyoung u_int8_t i_ra[IEEE80211_ADDR_LEN]; 2459280f4b4Sdyoung u_int8_t i_ta[IEEE80211_ADDR_LEN]; 2469280f4b4Sdyoung /* FCS */ 2479280f4b4Sdyoung } __attribute__((__packed__)); 2489280f4b4Sdyoung 2499280f4b4Sdyoung struct ieee80211_frame_cts { 2509280f4b4Sdyoung u_int8_t i_fc[2]; 2519280f4b4Sdyoung u_int8_t i_dur[2]; 2529280f4b4Sdyoung u_int8_t i_ra[IEEE80211_ADDR_LEN]; 2539280f4b4Sdyoung /* FCS */ 2549280f4b4Sdyoung } __attribute__((__packed__)); 2559280f4b4Sdyoung 2569280f4b4Sdyoung struct ieee80211_frame_ack { 2579280f4b4Sdyoung u_int8_t i_fc[2]; 2589280f4b4Sdyoung u_int8_t i_dur[2]; 2599280f4b4Sdyoung u_int8_t i_ra[IEEE80211_ADDR_LEN]; 2609280f4b4Sdyoung /* FCS */ 2619280f4b4Sdyoung } __attribute__((__packed__)); 2629280f4b4Sdyoung 2639280f4b4Sdyoung struct ieee80211_frame_pspoll { 2649280f4b4Sdyoung u_int8_t i_fc[2]; 2659280f4b4Sdyoung u_int8_t i_aid[2]; 2669280f4b4Sdyoung u_int8_t i_bssid[IEEE80211_ADDR_LEN]; 2679280f4b4Sdyoung u_int8_t i_ta[IEEE80211_ADDR_LEN]; 2689280f4b4Sdyoung /* FCS */ 2699280f4b4Sdyoung } __attribute__((__packed__)); 2709280f4b4Sdyoung 2719280f4b4Sdyoung struct ieee80211_frame_cfend { /* NB: also CF-End+CF-Ack */ 2729280f4b4Sdyoung u_int8_t i_fc[2]; 2739280f4b4Sdyoung u_int8_t i_dur[2]; /* should be zero */ 2749280f4b4Sdyoung u_int8_t i_ra[IEEE80211_ADDR_LEN]; 2759280f4b4Sdyoung u_int8_t i_bssid[IEEE80211_ADDR_LEN]; 2769280f4b4Sdyoung /* FCS */ 2779280f4b4Sdyoung } __attribute__((__packed__)); 2789280f4b4Sdyoung 2799280f4b4Sdyoung /* 28040e261aaSdyoung * BEACON management packets 28140e261aaSdyoung * 28240e261aaSdyoung * octet timestamp[8] 28340e261aaSdyoung * octet beacon interval[2] 28440e261aaSdyoung * octet capability information[2] 28540e261aaSdyoung * information element 28640e261aaSdyoung * octet elemid 28740e261aaSdyoung * octet length 28840e261aaSdyoung * octet information[length] 28940e261aaSdyoung */ 29040e261aaSdyoung 291de64f03aSmycroft typedef u_int8_t *ieee80211_mgt_beacon_t; 29240e261aaSdyoung 29340e261aaSdyoung #define IEEE80211_BEACON_INTERVAL(beacon) \ 29440e261aaSdyoung ((beacon)[8] | ((beacon)[9] << 8)) 29540e261aaSdyoung #define IEEE80211_BEACON_CAPABILITY(beacon) \ 29640e261aaSdyoung ((beacon)[10] | ((beacon)[11] << 8)) 29740e261aaSdyoung 29840e261aaSdyoung #define IEEE80211_CAPINFO_ESS 0x0001 29940e261aaSdyoung #define IEEE80211_CAPINFO_IBSS 0x0002 30040e261aaSdyoung #define IEEE80211_CAPINFO_CF_POLLABLE 0x0004 30140e261aaSdyoung #define IEEE80211_CAPINFO_CF_POLLREQ 0x0008 30240e261aaSdyoung #define IEEE80211_CAPINFO_PRIVACY 0x0010 30340e261aaSdyoung #define IEEE80211_CAPINFO_SHORT_PREAMBLE 0x0020 30440e261aaSdyoung #define IEEE80211_CAPINFO_PBCC 0x0040 30540e261aaSdyoung #define IEEE80211_CAPINFO_CHNL_AGILITY 0x0080 30640e261aaSdyoung /* bits 8-9 are reserved */ 30740e261aaSdyoung #define IEEE80211_CAPINFO_SHORT_SLOTTIME 0x0400 308bf300177Sdyoung #define IEEE80211_CAPINFO_RSN 0x0800 309bf300177Sdyoung /* bit 12 is reserved */ 31040e261aaSdyoung #define IEEE80211_CAPINFO_DSSSOFDM 0x2000 31140e261aaSdyoung /* bits 14-15 are reserved */ 31240e261aaSdyoung 31340e261aaSdyoung /* 314bf300177Sdyoung * 802.11i/WPA information element (maximally sized). 315bf300177Sdyoung */ 316bf300177Sdyoung struct ieee80211_ie_wpa { 317de64f03aSmycroft u_int8_t wpa_id; /* IEEE80211_ELEMID_VENDOR */ 318de64f03aSmycroft u_int8_t wpa_len; /* length in bytes */ 319bf300177Sdyoung u_int8_t wpa_oui[3]; /* 0x00, 0x50, 0xf2 */ 320bf300177Sdyoung u_int8_t wpa_type; /* OUI type */ 321bf300177Sdyoung u_int16_t wpa_version; /* spec revision */ 322bf300177Sdyoung u_int32_t wpa_mcipher[1]; /* multicast/group key cipher */ 323bf300177Sdyoung u_int16_t wpa_uciphercnt; /* # pairwise key ciphers */ 324bf300177Sdyoung u_int32_t wpa_uciphers[8];/* ciphers */ 325bf300177Sdyoung u_int16_t wpa_authselcnt; /* authentication selector cnt*/ 326bf300177Sdyoung u_int32_t wpa_authsels[8];/* selectors */ 327de64f03aSmycroft u_int16_t wpa_caps; /* 802.11i capabilities */ 328de64f03aSmycroft u_int16_t wpa_pmkidcnt; /* 802.11i pmkid count */ 329de64f03aSmycroft u_int16_t wpa_pmkids[8]; /* 802.11i pmkids */ 330bf300177Sdyoung } __attribute__((__packed__)); 331bf300177Sdyoung 332bf300177Sdyoung /* 333de64f03aSmycroft * Management information element payloads 33440e261aaSdyoung */ 335de64f03aSmycroft union ieee80211_information { 33640e261aaSdyoung char ssid[IEEE80211_NWID_LEN+1]; 33740e261aaSdyoung struct rates { 33840e261aaSdyoung u_int8_t *p; 33940e261aaSdyoung } rates; 34040e261aaSdyoung struct fh { 34140e261aaSdyoung u_int16_t dwell; 34240e261aaSdyoung u_int8_t set; 34340e261aaSdyoung u_int8_t pattern; 34440e261aaSdyoung u_int8_t index; 34540e261aaSdyoung } fh; 34640e261aaSdyoung struct ds { 34740e261aaSdyoung u_int8_t channel; 34840e261aaSdyoung } ds; 34940e261aaSdyoung struct cf { 35040e261aaSdyoung u_int8_t count; 35140e261aaSdyoung u_int8_t period; 35240e261aaSdyoung u_int8_t maxdur[2]; 35340e261aaSdyoung u_int8_t dur[2]; 35440e261aaSdyoung } cf; 35540e261aaSdyoung struct tim { 35640e261aaSdyoung u_int8_t count; 35740e261aaSdyoung u_int8_t period; 35840e261aaSdyoung u_int8_t bitctl; 35940e261aaSdyoung /* u_int8_t pvt[251]; The driver needs to use this. */ 36040e261aaSdyoung } tim; 36140e261aaSdyoung struct ibss { 36240e261aaSdyoung u_int16_t atim; 36340e261aaSdyoung } ibss; 36440e261aaSdyoung struct challenge { 36540e261aaSdyoung u_int8_t *p; 36640e261aaSdyoung u_int8_t len; 36740e261aaSdyoung } challenge; 36840e261aaSdyoung struct erp { 36940e261aaSdyoung u_int8_t flags; 37040e261aaSdyoung } erp; 371bf300177Sdyoung struct country { 372bf300177Sdyoung u_int8_t cc[3]; /* ISO CC+(I)ndoor/(O)utdoor */ 373bf300177Sdyoung struct { 374bf300177Sdyoung u_int8_t schan; /* starting channel */ 375bf300177Sdyoung u_int8_t nchan; /* number channels */ 376bf300177Sdyoung u_int8_t maxtxpwr; 377bf300177Sdyoung } band[4]; /* up to 4 sub bands */ 378bf300177Sdyoung } country; 379bf300177Sdyoung struct ath { 380bf300177Sdyoung u_int8_t flags; 381bf300177Sdyoung } ath; 38240e261aaSdyoung }; 38340e261aaSdyoung 38440e261aaSdyoung enum { 38540e261aaSdyoung IEEE80211_ELEMID_SSID = 0, 38640e261aaSdyoung IEEE80211_ELEMID_RATES = 1, 38740e261aaSdyoung IEEE80211_ELEMID_FHPARMS = 2, 38840e261aaSdyoung IEEE80211_ELEMID_DSPARMS = 3, 38940e261aaSdyoung IEEE80211_ELEMID_CFPARMS = 4, 39040e261aaSdyoung IEEE80211_ELEMID_TIM = 5, 39140e261aaSdyoung IEEE80211_ELEMID_IBSSPARMS = 6, 39240e261aaSdyoung IEEE80211_ELEMID_COUNTRY = 7, 39340e261aaSdyoung IEEE80211_ELEMID_CHALLENGE = 16, 394bf300177Sdyoung /* 17-31 reserved for challenge text extension */ 39540e261aaSdyoung IEEE80211_ELEMID_ERP = 42, 396de64f03aSmycroft IEEE80211_ELEMID_RSN = 48, 39740e261aaSdyoung IEEE80211_ELEMID_XRATES = 50, 398bf300177Sdyoung IEEE80211_ELEMID_TPC = 150, 399bf300177Sdyoung IEEE80211_ELEMID_CCKM = 156, 400bf300177Sdyoung IEEE80211_ELEMID_VENDOR = 221, /* vendor private */ 40140e261aaSdyoung }; 40240e261aaSdyoung 403db0e43b2Sdyoung #define IEEE80211_CHALLENGE_LEN 128 404db0e43b2Sdyoung 40540e261aaSdyoung #define IEEE80211_RATE_BASIC 0x80 40640e261aaSdyoung #define IEEE80211_RATE_VAL 0x7f 40740e261aaSdyoung 40840e261aaSdyoung /* EPR information element flags */ 40940e261aaSdyoung #define IEEE80211_ERP_NON_ERP_PRESENT 0x01 41040e261aaSdyoung #define IEEE80211_ERP_USE_PROTECTION 0x02 411de64f03aSmycroft #define IEEE80211_ERP_LONG_PREAMBLE 0x04 41240e261aaSdyoung 413bf300177Sdyoung /* Atheros private advanced capabilities info */ 414bf300177Sdyoung #define ATHEROS_CAP_TURBO_PRIME 0x01 415bf300177Sdyoung #define ATHEROS_CAP_COMPRESSION 0x02 416bf300177Sdyoung #define ATHEROS_CAP_FAST_FRAME 0x04 417bf300177Sdyoung /* bits 3-6 reserved */ 418bf300177Sdyoung #define ATHEROS_CAP_BOOST 0x80 419bf300177Sdyoung 420bf300177Sdyoung #define ATH_OUI 0x7f0300 /* Atheros OUI */ 421bf300177Sdyoung #define ATH_OUI_TYPE 0x01 422bf300177Sdyoung #define ATH_OUI_VERSION 0x01 423bf300177Sdyoung 424bf300177Sdyoung #define WPA_OUI 0xf25000 425bf300177Sdyoung #define WPA_OUI_TYPE 0x01 426de64f03aSmycroft #define WPA_VERSION 1 /* current supported version */ 427bf300177Sdyoung 428bf300177Sdyoung #define WPA_CSE_NULL 0x00 429bf300177Sdyoung #define WPA_CSE_WEP40 0x01 430bf300177Sdyoung #define WPA_CSE_TKIP 0x02 431bf300177Sdyoung #define WPA_CSE_CCMP 0x04 432bf300177Sdyoung #define WPA_CSE_WEP104 0x05 433bf300177Sdyoung 434bf300177Sdyoung #define WPA_ASE_NONE 0x00 435bf300177Sdyoung #define WPA_ASE_8021X_UNSPEC 0x01 436bf300177Sdyoung #define WPA_ASE_8021X_PSK 0x02 437bf300177Sdyoung 438de64f03aSmycroft #define RSN_OUI 0xac0f00 439de64f03aSmycroft #define RSN_VERSION 1 /* current supported version */ 440de64f03aSmycroft 441de64f03aSmycroft #define RSN_CSE_NULL 0x00 442de64f03aSmycroft #define RSN_CSE_WEP40 0x01 443de64f03aSmycroft #define RSN_CSE_TKIP 0x02 444de64f03aSmycroft #define RSN_CSE_WRAP 0x03 445de64f03aSmycroft #define RSN_CSE_CCMP 0x04 446de64f03aSmycroft #define RSN_CSE_WEP104 0x05 447de64f03aSmycroft 448de64f03aSmycroft #define RSN_ASE_NONE 0x00 449de64f03aSmycroft #define RSN_ASE_8021X_UNSPEC 0x01 450de64f03aSmycroft #define RSN_ASE_8021X_PSK 0x02 451de64f03aSmycroft 452de64f03aSmycroft #define WME_OUI 0xf25000 453de64f03aSmycroft #define WME_OUI_TYPE 0x02 454de64f03aSmycroft #define WME_VERSION 1 455de64f03aSmycroft 456de64f03aSmycroft /* WME stream classes */ 457de64f03aSmycroft #define WME_AC_BE 0 /* best effort */ 458de64f03aSmycroft #define WME_AC_BK 1 /* background */ 459de64f03aSmycroft #define WME_AC_VI 2 /* video */ 460de64f03aSmycroft #define WME_AC_VO 3 /* voice */ 461de64f03aSmycroft 46240e261aaSdyoung /* 46340e261aaSdyoung * AUTH management packets 46440e261aaSdyoung * 46540e261aaSdyoung * octet algo[2] 46640e261aaSdyoung * octet seq[2] 46740e261aaSdyoung * octet status[2] 46840e261aaSdyoung * octet chal.id 46940e261aaSdyoung * octet chal.length 47040e261aaSdyoung * octet chal.text[253] 47140e261aaSdyoung */ 47240e261aaSdyoung 47340e261aaSdyoung typedef u_int8_t *ieee80211_mgt_auth_t; 47440e261aaSdyoung 47540e261aaSdyoung #define IEEE80211_AUTH_ALGORITHM(auth) \ 47640e261aaSdyoung ((auth)[0] | ((auth)[1] << 8)) 47740e261aaSdyoung #define IEEE80211_AUTH_TRANSACTION(auth) \ 47840e261aaSdyoung ((auth)[2] | ((auth)[3] << 8)) 47940e261aaSdyoung #define IEEE80211_AUTH_STATUS(auth) \ 48040e261aaSdyoung ((auth)[4] | ((auth)[5] << 8)) 48140e261aaSdyoung 48240e261aaSdyoung #define IEEE80211_AUTH_ALG_OPEN 0x0000 48340e261aaSdyoung #define IEEE80211_AUTH_ALG_SHARED 0x0001 484bf300177Sdyoung #define IEEE80211_AUTH_ALG_LEAP 0x0080 48540e261aaSdyoung 48640e261aaSdyoung enum { 48740e261aaSdyoung IEEE80211_AUTH_OPEN_REQUEST = 1, 48840e261aaSdyoung IEEE80211_AUTH_OPEN_RESPONSE = 2, 48940e261aaSdyoung }; 49040e261aaSdyoung 49140e261aaSdyoung enum { 49240e261aaSdyoung IEEE80211_AUTH_SHARED_REQUEST = 1, 49340e261aaSdyoung IEEE80211_AUTH_SHARED_CHALLENGE = 2, 49440e261aaSdyoung IEEE80211_AUTH_SHARED_RESPONSE = 3, 49540e261aaSdyoung IEEE80211_AUTH_SHARED_PASS = 4, 49640e261aaSdyoung }; 49740e261aaSdyoung 49840e261aaSdyoung /* 49940e261aaSdyoung * Reason codes 50040e261aaSdyoung * 50140e261aaSdyoung * Unlisted codes are reserved 50240e261aaSdyoung */ 50340e261aaSdyoung 50440e261aaSdyoung enum { 50540e261aaSdyoung IEEE80211_REASON_UNSPECIFIED = 1, 50640e261aaSdyoung IEEE80211_REASON_AUTH_EXPIRE = 2, 50740e261aaSdyoung IEEE80211_REASON_AUTH_LEAVE = 3, 50840e261aaSdyoung IEEE80211_REASON_ASSOC_EXPIRE = 4, 50940e261aaSdyoung IEEE80211_REASON_ASSOC_TOOMANY = 5, 51040e261aaSdyoung IEEE80211_REASON_NOT_AUTHED = 6, 51140e261aaSdyoung IEEE80211_REASON_NOT_ASSOCED = 7, 51240e261aaSdyoung IEEE80211_REASON_ASSOC_LEAVE = 8, 51340e261aaSdyoung IEEE80211_REASON_ASSOC_NOT_AUTHED = 9, 51440e261aaSdyoung 515bf300177Sdyoung IEEE80211_REASON_RSN_REQUIRED = 11, 516bf300177Sdyoung IEEE80211_REASON_RSN_INCONSISTENT = 12, 517bf300177Sdyoung IEEE80211_REASON_IE_INVALID = 13, 518bf300177Sdyoung IEEE80211_REASON_MIC_FAILURE = 14, 519bf300177Sdyoung 52040e261aaSdyoung IEEE80211_STATUS_SUCCESS = 0, 52140e261aaSdyoung IEEE80211_STATUS_UNSPECIFIED = 1, 52240e261aaSdyoung IEEE80211_STATUS_CAPINFO = 10, 52340e261aaSdyoung IEEE80211_STATUS_NOT_ASSOCED = 11, 52440e261aaSdyoung IEEE80211_STATUS_OTHER = 12, 52540e261aaSdyoung IEEE80211_STATUS_ALG = 13, 52640e261aaSdyoung IEEE80211_STATUS_SEQUENCE = 14, 52740e261aaSdyoung IEEE80211_STATUS_CHALLENGE = 15, 52840e261aaSdyoung IEEE80211_STATUS_TIMEOUT = 16, 52940e261aaSdyoung IEEE80211_STATUS_TOOMANY = 17, 53040e261aaSdyoung IEEE80211_STATUS_BASIC_RATE = 18, 53140e261aaSdyoung IEEE80211_STATUS_SP_REQUIRED = 19, 53240e261aaSdyoung IEEE80211_STATUS_PBCC_REQUIRED = 20, 53340e261aaSdyoung IEEE80211_STATUS_CA_REQUIRED = 21, 53440e261aaSdyoung IEEE80211_STATUS_TOO_MANY_STATIONS = 22, 53540e261aaSdyoung IEEE80211_STATUS_RATES = 23, 53640e261aaSdyoung IEEE80211_STATUS_SHORTSLOT_REQUIRED = 25, 53740e261aaSdyoung IEEE80211_STATUS_DSSSOFDM_REQUIRED = 26, 53840e261aaSdyoung }; 53940e261aaSdyoung 54040e261aaSdyoung #define IEEE80211_WEP_KEYLEN 5 /* 40bit */ 54181eefc6fSdyoung #define IEEE80211_WEP_NKID 4 /* number of key ids */ 54281eefc6fSdyoung 54381eefc6fSdyoung /* WEP header constants */ 54440e261aaSdyoung #define IEEE80211_WEP_IVLEN 3 /* 24bit */ 54540e261aaSdyoung #define IEEE80211_WEP_KIDLEN 1 /* 1 octet */ 54640e261aaSdyoung #define IEEE80211_WEP_CRCLEN 4 /* CRC-32 */ 54781eefc6fSdyoung #define IEEE80211_WEP_TOTLEN (IEEE80211_WEP_IVLEN + \ 54881eefc6fSdyoung IEEE80211_WEP_KIDLEN + \ 54981eefc6fSdyoung IEEE80211_WEP_CRCLEN) 550de64f03aSmycroft /* 551de64f03aSmycroft * 802.11i defines an extended IV for use with non-WEP ciphers. 552de64f03aSmycroft * When the EXTIV bit is set in the key id byte an additional 553de64f03aSmycroft * 4 bytes immediately follow the IV for TKIP. For CCMP the 554de64f03aSmycroft * EXTIV bit is likewise set but the 8 bytes represent the 555de64f03aSmycroft * CCMP header rather than IV+extended-IV. 556de64f03aSmycroft */ 557de64f03aSmycroft #define IEEE80211_WEP_EXTIV 0x20 558de64f03aSmycroft #define IEEE80211_WEP_EXTIVLEN 4 /* extended IV length */ 559de64f03aSmycroft #define IEEE80211_WEP_MICLEN 8 /* trailing MIC */ 560de64f03aSmycroft 56140e261aaSdyoung #define IEEE80211_CRC_LEN 4 56240e261aaSdyoung 563bf300177Sdyoung /* 564bf300177Sdyoung * Maximum acceptable MTU is: 565bf300177Sdyoung * IEEE80211_MAX_LEN - WEP overhead - CRC - 566bf300177Sdyoung * QoS overhead - RSN/WPA overhead 567bf300177Sdyoung * Min is arbitrarily chosen > IEEE80211_MIN_LEN. The default 568bf300177Sdyoung * mtu is Ethernet-compatible; it's set by ether_ifattach. 569bf300177Sdyoung */ 570bf300177Sdyoung #define IEEE80211_MTU_MAX 2290 571bf300177Sdyoung #define IEEE80211_MTU_MIN 32 572bf300177Sdyoung 57340e261aaSdyoung #define IEEE80211_MAX_LEN (2300 + IEEE80211_CRC_LEN + \ 57440e261aaSdyoung (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + IEEE80211_WEP_CRCLEN)) 575de64f03aSmycroft #define IEEE80211_ACK_LEN \ 576de64f03aSmycroft (sizeof(struct ieee80211_frame_ack) + IEEE80211_CRC_LEN) 5779280f4b4Sdyoung #define IEEE80211_MIN_LEN \ 5789280f4b4Sdyoung (sizeof(struct ieee80211_frame_min) + IEEE80211_CRC_LEN) 57940e261aaSdyoung 580de64f03aSmycroft /* 581de64f03aSmycroft * The 802.11 spec says at most 2007 stations may be 582de64f03aSmycroft * associated at once. For most AP's this is way more 583de64f03aSmycroft * than is feasible so we use a default of 128. This 584de64f03aSmycroft * number may be overridden by the driver and/or by 585de64f03aSmycroft * user configuration. 586de64f03aSmycroft */ 587de64f03aSmycroft #define IEEE80211_AID_MAX 2007 588de64f03aSmycroft #define IEEE80211_AID_DEF 128 5898a3890c6Sdyoung 590de64f03aSmycroft #define IEEE80211_AID(b) ((b) &~ 0xc000) 5918a3890c6Sdyoung #define IEEE80211_AID_SET(b, w) \ 592de64f03aSmycroft ((w)[IEEE80211_AID(b) / 32] |= (1 << (IEEE80211_AID(b) % 32))) 5938a3890c6Sdyoung #define IEEE80211_AID_CLR(b, w) \ 594de64f03aSmycroft ((w)[IEEE80211_AID(b) / 32] &= ~(1 << (IEEE80211_AID(b) % 32))) 5958a3890c6Sdyoung #define IEEE80211_AID_ISSET(b, w) \ 596de64f03aSmycroft ((w)[IEEE80211_AID(b) / 32] & (1 << (IEEE80211_AID(b) % 32))) 5978a3890c6Sdyoung 59840e261aaSdyoung /* 59940e261aaSdyoung * RTS frame length parameters. The default is specified in 60040e261aaSdyoung * the 802.11 spec. The max may be wrong for jumbo frames. 60140e261aaSdyoung */ 60240e261aaSdyoung #define IEEE80211_RTS_DEFAULT 512 60340e261aaSdyoung #define IEEE80211_RTS_MIN 1 60440e261aaSdyoung #define IEEE80211_RTS_MAX IEEE80211_MAX_LEN 60540e261aaSdyoung 60681eefc6fSdyoung /* 60781eefc6fSdyoung * 802.11 frame duration definitions. 60881eefc6fSdyoung */ 60981eefc6fSdyoung 61081eefc6fSdyoung struct ieee80211_duration { 61181eefc6fSdyoung uint16_t d_rts_dur; 61281eefc6fSdyoung uint16_t d_data_dur; 61381eefc6fSdyoung uint16_t d_plcp_len; 61406e4fe7fSmycroft uint8_t d_residue; /* unused octets in time slot */ 61581eefc6fSdyoung }; 61681eefc6fSdyoung 61781eefc6fSdyoung /* One Time Unit (TU) is 1Kus = 1024 microseconds. */ 61881eefc6fSdyoung #define IEEE80211_DUR_TU 1024 61981eefc6fSdyoung 62081eefc6fSdyoung /* IEEE 802.11b durations for DSSS PHY in microseconds */ 62181eefc6fSdyoung #define IEEE80211_DUR_DS_LONG_PREAMBLE 144 62281eefc6fSdyoung #define IEEE80211_DUR_DS_SHORT_PREAMBLE 72 623*1989546aSmycroft 62481eefc6fSdyoung #define IEEE80211_DUR_DS_SLOW_PLCPHDR 48 625*1989546aSmycroft #define IEEE80211_DUR_DS_FAST_PLCPHDR 24 62681eefc6fSdyoung #define IEEE80211_DUR_DS_SLOW_ACK 112 62781eefc6fSdyoung #define IEEE80211_DUR_DS_FAST_ACK 56 62881eefc6fSdyoung #define IEEE80211_DUR_DS_SLOW_CTS 112 62981eefc6fSdyoung #define IEEE80211_DUR_DS_FAST_CTS 56 630*1989546aSmycroft 63181eefc6fSdyoung #define IEEE80211_DUR_DS_SLOT 20 63281eefc6fSdyoung #define IEEE80211_DUR_DS_SIFS 10 63381eefc6fSdyoung #define IEEE80211_DUR_DS_PIFS (IEEE80211_DUR_DS_SIFS + IEEE80211_DUR_DS_SLOT) 63481eefc6fSdyoung #define IEEE80211_DUR_DS_DIFS (IEEE80211_DUR_DS_SIFS + \ 63581eefc6fSdyoung 2 * IEEE80211_DUR_DS_SLOT) 63681eefc6fSdyoung #define IEEE80211_DUR_DS_EIFS (IEEE80211_DUR_DS_SIFS + \ 63781eefc6fSdyoung IEEE80211_DUR_DS_SLOW_ACK + \ 63881eefc6fSdyoung IEEE80211_DUR_DS_LONG_PREAMBLE + \ 63981eefc6fSdyoung IEEE80211_DUR_DS_SLOW_PLCPHDR + \ 64081eefc6fSdyoung IEEE80211_DUR_DIFS) 64181eefc6fSdyoung 64240e261aaSdyoung enum { 64340e261aaSdyoung IEEE80211_AUTH_NONE = 0, 644de64f03aSmycroft IEEE80211_AUTH_OPEN = 1, /* open */ 645de64f03aSmycroft IEEE80211_AUTH_SHARED = 2, /* shared-key */ 646de64f03aSmycroft IEEE80211_AUTH_8021X = 3, /* 802.1x */ 647de64f03aSmycroft IEEE80211_AUTH_AUTO = 4, /* auto-select/accept */ 648de64f03aSmycroft /* NB: these are used only for ioctls */ 649de64f03aSmycroft IEEE80211_AUTH_WPA = 5, /* WPA w/ 802.1x */ 650de64f03aSmycroft IEEE80211_AUTH_WPA_PSK = 6, /* WPA w/ preshared key */ 651de64f03aSmycroft IEEE80211_AUTH_WPA2 = 7, /* WPA2 w/ 802.1x */ 652de64f03aSmycroft IEEE80211_AUTH_WPA2_PSK = 8, /* WPA2 w/ preshared key */ 65340e261aaSdyoung }; 65440e261aaSdyoung 65540e261aaSdyoung #endif /* _NET80211_IEEE80211_H_ */ 656