1 /* $OpenBSD: ieee80211_ioctl.h,v 1.18 2011/03/04 23:48:15 fgsch Exp $ */ 2 /* $NetBSD: ieee80211_ioctl.h,v 1.7 2004/04/30 22:51:04 dyoung Exp $ */ 3 4 /*- 5 * Copyright (c) 2001 Atsushi Onoe 6 * Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 3. The name of the author may not be used to endorse or promote products 18 * derived from this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 * 31 * $FreeBSD: src/sys/net80211/ieee80211_ioctl.h,v 1.5 2004/03/30 22:57:57 sam Exp $ 32 */ 33 #ifndef _NET80211_IEEE80211_IOCTL_H_ 34 #define _NET80211_IEEE80211_IOCTL_H_ 35 36 /* 37 * IEEE 802.11 ioctls. 38 */ 39 40 /* per-interface statistics */ 41 struct ieee80211_stats { 42 u_int32_t is_rx_badversion; /* rx frame with bad version */ 43 u_int32_t is_rx_tooshort; /* rx frame too short */ 44 u_int32_t is_rx_wrongbss; /* rx from wrong bssid */ 45 u_int32_t is_rx_dup; /* rx discard 'cuz dup */ 46 u_int32_t is_rx_wrongdir; /* rx w/ wrong direction */ 47 u_int32_t is_rx_mcastecho; /* rx discard 'cuz mcast echo */ 48 u_int32_t is_rx_notassoc; /* rx discard 'cuz sta !assoc */ 49 u_int32_t is_rx_nowep; /* rx w/ wep but wep !config */ 50 u_int32_t is_rx_unencrypted; /* rx w/o wep but wep config */ 51 u_int32_t is_rx_wepfail; /* rx wep processing failed */ 52 u_int32_t is_rx_decap; /* rx decapsulation failed */ 53 u_int32_t is_rx_mgtdiscard; /* rx discard mgt frames */ 54 u_int32_t is_rx_ctl; /* rx discard ctrl frames */ 55 u_int32_t is_rx_rstoobig; /* rx rate set truncated */ 56 u_int32_t is_rx_elem_missing; /* rx required element missing*/ 57 u_int32_t is_rx_elem_toobig; /* rx element too big */ 58 u_int32_t is_rx_elem_toosmall; /* rx element too small */ 59 u_int32_t is_rx_badchan; /* rx frame w/ invalid chan */ 60 u_int32_t is_rx_chanmismatch; /* rx frame chan mismatch */ 61 u_int32_t is_rx_nodealloc; /* rx frame dropped */ 62 u_int32_t is_rx_ssidmismatch; /* rx frame ssid mismatch */ 63 u_int32_t is_rx_auth_unsupported; /* rx w/ unsupported auth alg */ 64 u_int32_t is_rx_auth_fail; /* rx sta auth failure */ 65 u_int32_t is_rx_assoc_bss; /* rx assoc from wrong bssid */ 66 u_int32_t is_rx_assoc_notauth; /* rx assoc w/o auth */ 67 u_int32_t is_rx_assoc_capmismatch;/* rx assoc w/ cap mismatch */ 68 u_int32_t is_rx_assoc_norate; /* rx assoc w/ no rate match */ 69 u_int32_t is_rx_deauth; /* rx deauthentication */ 70 u_int32_t is_rx_disassoc; /* rx disassociation */ 71 u_int32_t is_rx_badsubtype; /* rx frame w/ unknown subtype*/ 72 u_int32_t is_rx_nombuf; /* rx failed for lack of mbuf */ 73 u_int32_t is_rx_decryptcrc; /* rx decrypt failed on crc */ 74 u_int32_t is_rx_ahdemo_mgt; /* rx discard ahdemo mgt frame*/ 75 u_int32_t is_rx_bad_auth; /* rx bad auth request */ 76 u_int32_t is_tx_nombuf; /* tx failed for lack of mbuf */ 77 u_int32_t is_tx_nonode; /* tx failed for no node */ 78 u_int32_t is_tx_unknownmgt; /* tx of unknown mgt frame */ 79 u_int32_t is_scan_active; /* active scans started */ 80 u_int32_t is_scan_passive; /* passive scans started */ 81 u_int32_t is_node_timeout; /* nodes timed out inactivity */ 82 u_int32_t is_crypto_nomem; /* no memory for crypto ctx */ 83 u_int32_t is_rx_assoc_badrsnie; /* rx assoc w/ bad RSN IE */ 84 u_int32_t is_rx_unauth; /* rx port not valid */ 85 u_int32_t is_tx_noauth; /* tx port not valid */ 86 u_int32_t is_rx_eapol_key; /* rx eapol-key frames */ 87 u_int32_t is_rx_eapol_replay; /* rx replayed eapol frames */ 88 u_int32_t is_rx_eapol_badmic; /* rx eapol frames w/ bad mic */ 89 u_int32_t is_rx_remmicfail; /* rx tkip remote mic fails */ 90 u_int32_t is_rx_locmicfail; /* rx tkip local mic fails */ 91 u_int32_t is_tkip_replays; 92 u_int32_t is_tkip_icv_errs; 93 u_int32_t is_ccmp_replays; 94 u_int32_t is_ccmp_dec_errs; 95 u_int32_t is_cmac_replays; 96 u_int32_t is_cmac_icv_errs; 97 u_int32_t is_pbac_errs; 98 }; 99 100 #define SIOCG80211STATS _IOWR('i', 242, struct ifreq) 101 102 /* network identifier (ESSID), nwid is pointed at by ifr.ifr_data */ 103 struct ieee80211_nwid { 104 u_int8_t i_len; 105 u_int8_t i_nwid[IEEE80211_NWID_LEN]; 106 }; 107 108 #define SIOCS80211NWID _IOWR('i', 230, struct ifreq) 109 #define SIOCG80211NWID _IOWR('i', 231, struct ifreq) 110 111 /* network key (WEP), the first member must be matched with struct ifreq */ 112 struct ieee80211_nwkey { 113 char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */ 114 int i_wepon; /* wep enabled flag */ 115 int i_defkid; /* default encrypt key id */ 116 struct { 117 int i_keylen; 118 u_int8_t *i_keydat; 119 } i_key[IEEE80211_WEP_NKID]; 120 }; 121 122 #define IEEE80211_NWKEY_OPEN 0 /* No privacy */ 123 #define IEEE80211_NWKEY_WEP 1 /* WEP enabled */ 124 #define IEEE80211_NWKEY_EAP 2 /* EAP enabled */ 125 #define IEEE80211_NWKEY_PERSIST 0x100 /* designate persist keyset */ 126 127 #define SIOCS80211NWKEY _IOW('i', 232, struct ieee80211_nwkey) 128 #define SIOCG80211NWKEY _IOWR('i', 233, struct ieee80211_nwkey) 129 130 /* power management parameters */ 131 struct ieee80211_power { 132 char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */ 133 int i_enabled; /* 1 == on, 0 == off */ 134 int i_maxsleep; /* max sleep in ms */ 135 }; 136 #define SIOCS80211POWER _IOW('i', 234, struct ieee80211_power) 137 #define SIOCG80211POWER _IOWR('i', 235, struct ieee80211_power) 138 139 /* authentication type */ 140 struct ieee80211_auth { 141 char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */ 142 int i_authtype; 143 }; 144 145 #define IEEE80211_AUTH_NONE 0 146 #define IEEE80211_AUTH_OPEN 1 147 #define IEEE80211_AUTH_SHARED 2 148 149 #define SIOCS80211AUTH _IOW('i', 236, struct ieee80211_auth) 150 #define SIOCG80211AUTH _IOWR('i', 237, struct ieee80211_auth) 151 152 /* channel request */ 153 struct ieee80211chanreq { 154 char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */ 155 u_int16_t i_channel; 156 }; 157 158 #ifndef _KERNEL 159 /* 160 * Channels are specified by frequency and attributes. 161 */ 162 struct ieee80211_channel { 163 u_int16_t ic_freq; /* setting in MHz */ 164 u_int16_t ic_flags; /* see below */ 165 }; 166 167 /* 168 * Channel attributes (XXX must keep in sync with radiotap flags). 169 */ 170 #define IEEE80211_CHAN_TURBO 0x0010 /* Turbo channel */ 171 #define IEEE80211_CHAN_CCK 0x0020 /* CCK channel */ 172 #define IEEE80211_CHAN_OFDM 0x0040 /* OFDM channel */ 173 #define IEEE80211_CHAN_2GHZ 0x0080 /* 2 GHz spectrum channel */ 174 #define IEEE80211_CHAN_5GHZ 0x0100 /* 5 GHz spectrum channel */ 175 #define IEEE80211_CHAN_PASSIVE 0x0200 /* Only passive scan allowed */ 176 #define IEEE80211_CHAN_DYN 0x0400 /* Dynamic CCK-OFDM channel */ 177 #define IEEE80211_CHAN_XR 0x1000 /* Extended range OFDM channel */ 178 #endif /* !_KERNEL */ 179 180 struct ieee80211_chanreq_all { 181 char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */ 182 struct ieee80211_channel *i_chans; 183 }; 184 185 #ifndef IEEE80211_CHAN_ANY 186 #define IEEE80211_CHAN_ANY 0xffff 187 #endif 188 189 #define SIOCS80211CHANNEL _IOW('i', 238, struct ieee80211chanreq) 190 #define SIOCG80211CHANNEL _IOWR('i', 239, struct ieee80211chanreq) 191 #define SIOCG80211ALLCHANS _IOWR('i', 215, struct ieee80211_chanreq_all) 192 193 /* BSS identifier */ 194 struct ieee80211_bssid { 195 char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */ 196 u_int8_t i_bssid[IEEE80211_ADDR_LEN]; 197 }; 198 199 #define SIOCS80211BSSID _IOW('i', 240, struct ieee80211_bssid) 200 #define SIOCG80211BSSID _IOWR('i', 241, struct ieee80211_bssid) 201 202 /* transmit power */ 203 struct ieee80211_txpower { 204 char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */ 205 int i_mode; /* auto, manual */ 206 int16_t i_val; /* dBm */ 207 }; 208 209 #define SIOCS80211TXPOWER _IOW('i', 243, struct ieee80211_txpower) 210 #define SIOCG80211TXPOWER _IOWR('i', 244, struct ieee80211_txpower) 211 212 #define IEEE80211_TXPOWER_MODE_FIXED 0 /* fixed tx power value */ 213 #define IEEE80211_TXPOWER_MODE_AUTO 1 /* auto level control */ 214 215 struct ieee80211_wpapsk { 216 char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */ 217 int i_enabled; 218 u_int8_t i_psk[32]; 219 }; 220 221 #define SIOCS80211WPAPSK _IOW('i', 245, struct ieee80211_wpapsk) 222 #define SIOCG80211WPAPSK _IOWR('i', 246, struct ieee80211_wpapsk) 223 224 #define IEEE80211_WPA_PROTO_WPA1 0x01 225 #define IEEE80211_WPA_PROTO_WPA2 0x02 226 227 #define IEEE80211_WPA_CIPHER_NONE 0x00 228 #define IEEE80211_WPA_CIPHER_USEGROUP 0x01 229 #define IEEE80211_WPA_CIPHER_WEP40 0x02 230 #define IEEE80211_WPA_CIPHER_TKIP 0x04 231 #define IEEE80211_WPA_CIPHER_CCMP 0x08 232 #define IEEE80211_WPA_CIPHER_WEP104 0x10 233 234 #define IEEE80211_WPA_AKM_PSK 0x01 235 #define IEEE80211_WPA_AKM_8021X 0x02 236 #define IEEE80211_WPA_AKM_SHA256_PSK 0x04 237 #define IEEE80211_WPA_AKM_SHA256_8021X 0x08 238 239 struct ieee80211_wpaparams { 240 char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */ 241 int i_enabled; 242 u_int i_protos; 243 u_int i_akms; 244 u_int i_ciphers; 245 u_int i_groupcipher; 246 }; 247 248 #define SIOCS80211WPAPARMS _IOW('i', 247, struct ieee80211_wpaparams) 249 #define SIOCG80211WPAPARMS _IOWR('i', 248, struct ieee80211_wpaparams) 250 251 struct ieee80211_wmmparams { 252 char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */ 253 int i_enabled; 254 /* XXX more */ 255 }; 256 257 #define SIOCS80211WMMPARMS _IOW('i', 249, struct ieee80211_wmmparams) 258 #define SIOCG80211WMMPARMS _IOWR('i', 250, struct ieee80211_wmmparams) 259 260 struct ieee80211_keyavail { 261 char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */ 262 u_int8_t i_macaddr[IEEE80211_ADDR_LEN]; 263 u_int8_t i_key[32]; 264 u_int32_t i_lifetime; 265 }; 266 267 struct ieee80211_keyrun { 268 char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */ 269 u_int8_t i_macaddr[IEEE80211_ADDR_LEN]; 270 }; 271 272 #define SIOCS80211KEYAVAIL _IOW('i', 251, struct ieee80211_keyavail) 273 #define SIOCS80211KEYRUN _IOW('i', 252, struct ieee80211_keyrun) 274 275 /* scan request (will block) */ 276 #define IEEE80211_SCAN_TIMEOUT 30 /* timeout in seconds */ 277 278 #define SIOCS80211SCAN _IOW('i', 210, struct ifreq) 279 280 /* node and requests */ 281 struct ieee80211_nodereq { 282 char nr_ifname[IFNAMSIZ]; /* e.g. "ath0" */ 283 284 /* Node address and name information */ 285 u_int8_t nr_macaddr[IEEE80211_ADDR_LEN]; /* node lladdr */ 286 u_int8_t nr_bssid[IEEE80211_ADDR_LEN]; /* bssid */ 287 u_int8_t nr_nwid_len; /* ESSID length */ 288 u_int8_t nr_nwid[IEEE80211_NWID_LEN]; /* ESSID */ 289 290 /* Channel and rates */ 291 u_int16_t nr_channel; /* last channel */ 292 u_int16_t nr_chan_flags; /* channel flags */ 293 u_int8_t nr_nrates; /* rate count */ 294 u_int8_t nr_rates[IEEE80211_RATE_MAXSIZE]; /* rate set */ 295 296 /* Node status information */ 297 u_int8_t nr_rssi; /* received signal strength */ 298 u_int8_t nr_max_rssi; /* maximum rssi */ 299 u_int8_t nr_tstamp[8]; /* from last received beacon */ 300 u_int16_t nr_intval; /* beacon interval */ 301 u_int16_t nr_capinfo; /* capabilities */ 302 u_int16_t nr_fhdwell; /* FH only */ 303 u_int8_t nr_fhindex; /* FH only */ 304 u_int8_t nr_erp; /* 11g only */ 305 u_int8_t nr_pwrsave; /* power saving mode */ 306 u_int16_t nr_associd; /* assoc response */ 307 u_int16_t nr_txseq; /* seq to be transmitted */ 308 u_int16_t nr_rxseq; /* seq previous received */ 309 u_int32_t nr_fails; /* failure count to associate */ 310 u_int32_t nr_inact; /* inactivity mark count */ 311 u_int8_t nr_txrate; /* index to nr_rates[] */ 312 u_int16_t nr_state; /* node state in the cache */ 313 314 /* XXX RSN */ 315 316 /* Node flags */ 317 u_int8_t nr_flags; 318 }; 319 320 #define IEEE80211_NODEREQ_STATE(_s) (1 << _s) 321 #define IEEE80211_NODEREQ_STATE_BITS \ 322 "\20\01CACHE\02BSS\03AUTH\04ASSOC\05COLLECT" 323 324 #define IEEE80211_NODEREQ_RSSI(_nr) \ 325 ((u_int)(((float)(_nr)->nr_rssi / (_nr)->nr_max_rssi) * 100)) 326 327 #define IEEE80211_NODEREQ_STA 0x00 /* station */ 328 #define IEEE80211_NODEREQ_AP 0x01 /* access point */ 329 #define IEEE80211_NODEREQ_AP_BSS 0x02 /* current bss access point */ 330 #define IEEE80211_NODEREQ_COPY 0x04 /* add node with flags */ 331 332 #define SIOCG80211NODE _IOWR('i', 211, struct ieee80211_nodereq) 333 #define SIOCS80211NODE _IOW('i', 212, struct ieee80211_nodereq) 334 #define SIOCS80211DELNODE _IOW('i', 213, struct ieee80211_nodereq) 335 336 /* get the entire node cache */ 337 struct ieee80211_nodereq_all { 338 char na_ifname[IFNAMSIZ]; /* e.g. "ath0" */ 339 340 int na_nodes; /* returned count */ 341 size_t na_size; /* size of node buffer */ 342 struct ieee80211_nodereq *na_node; /* allocated node buffer */ 343 344 /* Match nodes by flag */ 345 u_int8_t na_flags; /* IEEE80211_NODEREQ_* */ 346 }; 347 348 #define SIOCG80211ALLNODES _IOWR('i', 214, struct ieee80211_nodereq) 349 350 /* net80211 specific interface flags */ 351 #define IEEE80211_F_HIDENWID 0x10000000 /* CONF: hidden ssid mode */ 352 #define IEEE80211_F_NOBRIDGE 0x20000000 /* CONF: no internal bridging */ 353 #define IEEE80211_F_HOSTAPMASK 0x30000000 354 #define IEEE80211_F_USERSHIFT 28 355 #define IEEE80211_F_USERBITS "\20\01HIDENWID\02NOBRIDGE" 356 357 struct ieee80211_flags { 358 const char *f_name; 359 u_int f_flag; 360 }; 361 362 #define IEEE80211_FLAGS { \ 363 { "hidenwid", IEEE80211_F_HIDENWID >> IEEE80211_F_USERSHIFT }, \ 364 { "nobridge", IEEE80211_F_NOBRIDGE >> IEEE80211_F_USERSHIFT } \ 365 } 366 367 #define SIOCG80211FLAGS _IOWR('i', 216, struct ifreq) 368 #define SIOCS80211FLAGS _IOW('i', 217, struct ifreq) 369 370 #endif /* _NET80211_IEEE80211_IOCTL_H_ */ 371