ieee80211.h revision 116742
1/*- 2 * Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 * $FreeBSD: head/sys/net80211/ieee80211.h 116742 2003-06-23 16:55:01Z sam $ 27 */ 28#ifndef _NET80211_IEEE80211_H_ 29#define _NET80211_IEEE80211_H_ 30 31/* 32 * 802.11 protocol definitions. 33 */ 34 35#define IEEE80211_ADDR_LEN 6 /* size of 802.11 address */ 36/* is 802.11 address multicast/broadcast? */ 37#define IEEE80211_IS_MULTICAST(_a) (*(_a) & 0x01) 38 39/* IEEE 802.11 PLCP header */ 40struct ieee80211_plcp_hdr { 41 u_int16_t i_sfd; 42 u_int8_t i_signal; 43 u_int8_t i_service; 44 u_int16_t i_length; 45 u_int16_t i_crc; 46} __attribute__((__packed__)); 47 48/* 49 * generic definitions for IEEE 802.11 frames 50 */ 51struct ieee80211_frame { 52 u_int8_t i_fc[2]; 53 u_int8_t i_dur[2]; 54 u_int8_t i_addr1[IEEE80211_ADDR_LEN]; 55 u_int8_t i_addr2[IEEE80211_ADDR_LEN]; 56 u_int8_t i_addr3[IEEE80211_ADDR_LEN]; 57 u_int8_t i_seq[2]; 58 /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */ 59 /* see below */ 60} __attribute__((__packed__)); 61 62struct ieee80211_frame_addr4 { 63 u_int8_t i_fc[2]; 64 u_int8_t i_dur[2]; 65 u_int8_t i_addr1[IEEE80211_ADDR_LEN]; 66 u_int8_t i_addr2[IEEE80211_ADDR_LEN]; 67 u_int8_t i_addr3[IEEE80211_ADDR_LEN]; 68 u_int8_t i_seq[2]; 69 u_int8_t i_addr4[IEEE80211_ADDR_LEN]; 70} __attribute__((__packed__)); 71 72#define IEEE80211_FC0_VERSION_MASK 0x03 73#define IEEE80211_FC0_VERSION_SHIFT 0 74#define IEEE80211_FC0_VERSION_0 0x00 75#define IEEE80211_FC0_TYPE_MASK 0x0c 76#define IEEE80211_FC0_TYPE_SHIFT 2 77#define IEEE80211_FC0_TYPE_MGT 0x00 78#define IEEE80211_FC0_TYPE_CTL 0x04 79#define IEEE80211_FC0_TYPE_DATA 0x08 80 81#define IEEE80211_FC0_SUBTYPE_MASK 0xf0 82#define IEEE80211_FC0_SUBTYPE_SHIFT 4 83/* for TYPE_MGT */ 84#define IEEE80211_FC0_SUBTYPE_ASSOC_REQ 0x00 85#define IEEE80211_FC0_SUBTYPE_ASSOC_RESP 0x10 86#define IEEE80211_FC0_SUBTYPE_REASSOC_REQ 0x20 87#define IEEE80211_FC0_SUBTYPE_REASSOC_RESP 0x30 88#define IEEE80211_FC0_SUBTYPE_PROBE_REQ 0x40 89#define IEEE80211_FC0_SUBTYPE_PROBE_RESP 0x50 90#define IEEE80211_FC0_SUBTYPE_BEACON 0x80 91#define IEEE80211_FC0_SUBTYPE_ATIM 0x90 92#define IEEE80211_FC0_SUBTYPE_DISASSOC 0xa0 93#define IEEE80211_FC0_SUBTYPE_AUTH 0xb0 94#define IEEE80211_FC0_SUBTYPE_DEAUTH 0xc0 95/* for TYPE_CTL */ 96#define IEEE80211_FC0_SUBTYPE_PS_POLL 0xa0 97#define IEEE80211_FC0_SUBTYPE_RTS 0xb0 98#define IEEE80211_FC0_SUBTYPE_CTS 0xc0 99#define IEEE80211_FC0_SUBTYPE_ACK 0xd0 100#define IEEE80211_FC0_SUBTYPE_CF_END 0xe0 101#define IEEE80211_FC0_SUBTYPE_CF_END_ACK 0xf0 102/* for TYPE_DATA (bit combination) */ 103#define IEEE80211_FC0_SUBTYPE_DATA 0x00 104#define IEEE80211_FC0_SUBTYPE_CF_ACK 0x10 105#define IEEE80211_FC0_SUBTYPE_CF_POLL 0x20 106#define IEEE80211_FC0_SUBTYPE_CF_ACPL 0x30 107#define IEEE80211_FC0_SUBTYPE_NODATA 0x40 108#define IEEE80211_FC0_SUBTYPE_CFACK 0x50 109#define IEEE80211_FC0_SUBTYPE_CFPOLL 0x60 110#define IEEE80211_FC0_SUBTYPE_CF_ACK_CF_ACK 0x70 111 112#define IEEE80211_FC1_DIR_MASK 0x03 113#define IEEE80211_FC1_DIR_NODS 0x00 /* STA->STA */ 114#define IEEE80211_FC1_DIR_TODS 0x01 /* STA->AP */ 115#define IEEE80211_FC1_DIR_FROMDS 0x02 /* AP ->STA */ 116#define IEEE80211_FC1_DIR_DSTODS 0x03 /* AP ->AP */ 117 118#define IEEE80211_FC1_MORE_FRAG 0x04 119#define IEEE80211_FC1_RETRY 0x08 120#define IEEE80211_FC1_PWR_MGT 0x10 121#define IEEE80211_FC1_MORE_DATA 0x20 122#define IEEE80211_FC1_WEP 0x40 123#define IEEE80211_FC1_ORDER 0x80 124 125#define IEEE80211_SEQ_FRAG_MASK 0x000f 126#define IEEE80211_SEQ_FRAG_SHIFT 0 127#define IEEE80211_SEQ_SEQ_MASK 0xfff0 128#define IEEE80211_SEQ_SEQ_SHIFT 4 129 130#define IEEE80211_NWID_LEN 32 131 132/* 133 * BEACON management packets 134 * 135 * octet timestamp[8] 136 * octet beacon interval[2] 137 * octet capability information[2] 138 * information element 139 * octet elemid 140 * octet length 141 * octet information[length] 142 */ 143 144typedef uint8_t *ieee80211_mgt_beacon_t; 145 146#define IEEE80211_BEACON_INTERVAL(beacon) \ 147 ((beacon)[8] | ((beacon)[9] << 8)) 148#define IEEE80211_BEACON_CAPABILITY(beacon) \ 149 ((beacon)[10] | ((beacon)[11] << 8)) 150 151#define IEEE80211_CAPINFO_ESS 0x0001 152#define IEEE80211_CAPINFO_IBSS 0x0002 153#define IEEE80211_CAPINFO_CF_POLLABLE 0x0004 154#define IEEE80211_CAPINFO_CF_POLLREQ 0x0008 155#define IEEE80211_CAPINFO_PRIVACY 0x0010 156#define IEEE80211_CAPINFO_SHORT_PREAMBLE 0x0020 157#define IEEE80211_CAPINFO_PBCC 0x0040 158#define IEEE80211_CAPINFO_CHNL_AGILITY 0x0080 159/* bits 8-9 are reserved */ 160#define IEEE80211_CAPINFO_SHORT_SLOTTIME 0x0400 161/* bits 11-12 are reserved */ 162#define IEEE80211_CAPINFO_DSSSOFDM 0x2000 163/* bits 14-15 are reserved */ 164 165/* 166 * Management information elements 167 */ 168struct ieee80211_information { 169 char ssid[IEEE80211_NWID_LEN+1]; 170 struct rates { 171 u_int8_t *p; 172 } rates; 173 struct fh { 174 u_int16_t dwell; 175 u_int8_t set; 176 u_int8_t pattern; 177 u_int8_t index; 178 } fh; 179 struct ds { 180 u_int8_t channel; 181 } ds; 182 struct cf { 183 u_int8_t count; 184 u_int8_t period; 185 u_int8_t maxdur[2]; 186 u_int8_t dur[2]; 187 } cf; 188 struct tim { 189 u_int8_t count; 190 u_int8_t period; 191 u_int8_t bitctl; 192 /* u_int8_t pvt[251]; The driver needs to use this. */ 193 } tim; 194 struct ibss { 195 u_int16_t atim; 196 } ibss; 197 struct challenge { 198 u_int8_t *p; 199 u_int8_t len; 200 } challenge; 201 struct erp { 202 u_int8_t flags; 203 } erp; 204}; 205 206enum { 207 IEEE80211_ELEMID_SSID = 0, 208 IEEE80211_ELEMID_RATES = 1, 209 IEEE80211_ELEMID_FHPARMS = 2, 210 IEEE80211_ELEMID_DSPARMS = 3, 211 IEEE80211_ELEMID_CFPARMS = 4, 212 IEEE80211_ELEMID_TIM = 5, 213 IEEE80211_ELEMID_IBSSPARMS = 6, 214 IEEE80211_ELEMID_COUNTRY = 7, 215 IEEE80211_ELEMID_CHALLENGE = 16, 216 IEEE80211_ELEMID_ERP = 42, 217 IEEE80211_ELEMID_XRATES = 50, 218}; 219 220#define IEEE80211_RATE_BASIC 0x80 221#define IEEE80211_RATE_VAL 0x7f 222 223/* EPR information element flags */ 224#define IEEE80211_ERP_NON_ERP_PRESENT 0x01 225#define IEEE80211_ERP_USE_PROTECTION 0x02 226#define IEEE80211_ERP_BARKER_MODE 0x04 227 228/* 229 * AUTH management packets 230 * 231 * octet algo[2] 232 * octet seq[2] 233 * octet status[2] 234 * octet chal.id 235 * octet chal.length 236 * octet chal.text[253] 237 */ 238 239typedef u_int8_t *ieee80211_mgt_auth_t; 240 241#define IEEE80211_AUTH_ALGORITHM(auth) \ 242 ((auth)[0] | ((auth)[1] << 8)) 243#define IEEE80211_AUTH_TRANSACTION(auth) \ 244 ((auth)[2] | ((auth)[3] << 8)) 245#define IEEE80211_AUTH_STATUS(auth) \ 246 ((auth)[4] | ((auth)[5] << 8)) 247 248#define IEEE80211_AUTH_ALG_OPEN 0x0000 249#define IEEE80211_AUTH_ALG_SHARED 0x0001 250 251enum { 252 IEEE80211_AUTH_OPEN_REQUEST = 1, 253 IEEE80211_AUTH_OPEN_RESPONSE = 2, 254}; 255 256enum { 257 IEEE80211_AUTH_SHARED_REQUEST = 1, 258 IEEE80211_AUTH_SHARED_CHALLENGE = 2, 259 IEEE80211_AUTH_SHARED_RESPONSE = 3, 260 IEEE80211_AUTH_SHARED_PASS = 4, 261}; 262 263/* 264 * Reason codes 265 * 266 * Unlisted codes are reserved 267 */ 268 269enum { 270 IEEE80211_REASON_UNSPECIFIED = 1, 271 IEEE80211_REASON_AUTH_EXPIRE = 2, 272 IEEE80211_REASON_AUTH_LEAVE = 3, 273 IEEE80211_REASON_ASSOC_EXPIRE = 4, 274 IEEE80211_REASON_ASSOC_TOOMANY = 5, 275 IEEE80211_REASON_NOT_AUTHED = 6, 276 IEEE80211_REASON_NOT_ASSOCED = 7, 277 IEEE80211_REASON_ASSOC_LEAVE = 8, 278 IEEE80211_REASON_ASSOC_NOT_AUTHED = 9, 279 280 IEEE80211_STATUS_SUCCESS = 0, 281 IEEE80211_STATUS_UNSPECIFIED = 1, 282 IEEE80211_STATUS_CAPINFO = 10, 283 IEEE80211_STATUS_NOT_ASSOCED = 11, 284 IEEE80211_STATUS_OTHER = 12, 285 IEEE80211_STATUS_ALG = 13, 286 IEEE80211_STATUS_SEQUENCE = 14, 287 IEEE80211_STATUS_CHALLENGE = 15, 288 IEEE80211_STATUS_TIMEOUT = 16, 289 IEEE80211_STATUS_TOOMANY = 17, 290 IEEE80211_STATUS_BASIC_RATE = 18, 291 IEEE80211_STATUS_SP_REQUIRED = 19, 292 IEEE80211_STATUS_PBCC_REQUIRED = 20, 293 IEEE80211_STATUS_CA_REQUIRED = 21, 294 IEEE80211_STATUS_TOO_MANY_STATIONS = 22, 295 IEEE80211_STATUS_RATES = 23, 296 IEEE80211_STATUS_SHORTSLOT_REQUIRED = 25, 297 IEEE80211_STATUS_DSSSOFDM_REQUIRED = 26, 298}; 299 300#define IEEE80211_WEP_KEYLEN 5 /* 40bit */ 301#define IEEE80211_WEP_IVLEN 3 /* 24bit */ 302#define IEEE80211_WEP_KIDLEN 1 /* 1 octet */ 303#define IEEE80211_WEP_CRCLEN 4 /* CRC-32 */ 304#define IEEE80211_WEP_NKID 4 /* number of key ids */ 305 306#define IEEE80211_CRC_LEN 4 307 308#define IEEE80211_MTU 1500 309#define IEEE80211_MAX_LEN (2300 + IEEE80211_CRC_LEN + \ 310 (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + IEEE80211_WEP_CRCLEN)) 311 312/* 313 * RTS frame length parameters. The default is specified in 314 * the 802.11 spec. The max may be wrong for jumbo frames. 315 */ 316#define IEEE80211_RTS_DEFAULT 512 317#define IEEE80211_RTS_MIN 1 318#define IEEE80211_RTS_MAX IEEE80211_MAX_LEN 319 320enum { 321 IEEE80211_AUTH_NONE = 0, 322 IEEE80211_AUTH_OPEN = 1, 323 IEEE80211_AUTH_SHARED = 2, 324}; 325 326#endif /* _NET80211_IEEE80211_H_ */ 327