1/* $OpenBSD: ieee80211_ioctl.h,v 1.45 2026/03/26 12:15:01 kirill 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 */
41struct 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 u_int32_t is_ht_nego_no_mandatory_mcs;
99 u_int32_t is_ht_nego_no_basic_mcs;
100 u_int32_t is_ht_nego_bad_crypto;
101 u_int32_t is_ht_prot_change;
102 u_int32_t is_ht_rx_ba_agreements;
103 u_int32_t is_ht_tx_ba_agreements;
104 u_int32_t is_ht_rx_frame_below_ba_winstart;
105 u_int32_t is_ht_rx_frame_above_ba_winend;
106 u_int32_t is_ht_rx_ba_window_slide;
107 u_int32_t is_ht_rx_ba_window_jump;
108 u_int32_t is_ht_rx_ba_no_buf;
109 u_int32_t is_ht_rx_ba_frame_lost;
110 u_int32_t is_ht_rx_ba_window_gap_timeout;
111 u_int32_t is_ht_rx_ba_timeout;
112 u_int32_t is_ht_tx_ba_timeout;
113 u_int32_t is_vht_nego_no_mandatory_mcs;
114 u_int32_t is_vht_nego_no_basic_mcs;
115};
116
117#define SIOCG80211STATS _IOWR('i', 242, struct ifreq)
118
119/* network identifier (ESSID), nwid is pointed at by ifr.ifr_data */
120struct ieee80211_nwid {
121 u_int8_t i_len;
122 u_int8_t i_nwid[IEEE80211_NWID_LEN];
123};
124
125#define SIOCS80211NWID _IOWR('i', 230, struct ifreq)
126#define SIOCG80211NWID _IOWR('i', 231, struct ifreq)
127
128/* network key (WEP), the first member must be matched with struct ifreq */
129struct ieee80211_nwkey {
130 char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */
131 int i_wepon; /* wep enabled flag */
132 int i_defkid; /* default encrypt key id */
133 struct {
134 int i_keylen;
135 u_int8_t *i_keydat;
136 } i_key[IEEE80211_WEP_NKID];
137};
138
139#define IEEE80211_NWKEY_OPEN 0 /* No privacy */
140#define IEEE80211_NWKEY_WEP 1 /* WEP enabled */
141#define IEEE80211_NWKEY_EAP 2 /* EAP enabled */
142#define IEEE80211_NWKEY_PERSIST 0x100 /* designate persist keyset */
143
144#define SIOCS80211NWKEY _IOW('i', 232, struct ieee80211_nwkey)
145#define SIOCG80211NWKEY _IOWR('i', 233, struct ieee80211_nwkey)
146
147/* power management parameters */
148struct ieee80211_power {
149 char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */
150 int i_enabled; /* 1 == on, 0 == off */
151 int i_maxsleep; /* max sleep in ms */
152};
153#define SIOCS80211POWER _IOW('i', 234, struct ieee80211_power)
154#define SIOCG80211POWER _IOWR('i', 235, struct ieee80211_power)
155
156#define IEEE80211_AUTH_NONE 0
157#define IEEE80211_AUTH_OPEN 1
158#define IEEE80211_AUTH_SHARED 2
159
160/* channel request */
161struct ieee80211chanreq {
162 char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */
163 u_int16_t i_channel;
164};
165
166/*
167 * Channels are specified by frequency and attributes.
168 */
169struct ieee80211_chaninfo {
170 u_int16_t ic_freq; /* setting in MHz */
171 u_int16_t ic_flags; /* see below */
172};
173
174/*
175 * Channel attributes.
176 */
177#define IEEE80211_CHANINFO_2GHZ 0x0080 /* 2 GHz spectrum channel */
178#define IEEE80211_CHANINFO_5GHZ 0x0100 /* 5 GHz spectrum channel */
179#define IEEE80211_CHANINFO_PASSIVE 0x0200 /* Only passive scan allowed */
180
181struct ieee80211_chanreq_all {
182 char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */
183 struct ieee80211_chaninfo *i_chans; /* array of 256 elements */
184};
185
186#ifndef IEEE80211_CHAN_ANY
187#define IEEE80211_CHAN_ANY 0xffff
188#endif
189
190#define SIOCS80211CHANNEL _IOW('i', 238, struct ieee80211chanreq)
191#define SIOCG80211CHANNEL _IOWR('i', 239, struct ieee80211chanreq)
192#define SIOCG80211ALLCHANS _IOWR('i', 215, struct ieee80211_chanreq_all)
193
194/* BSS identifier */
195struct ieee80211_bssid {
196 char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */
197 u_int8_t i_bssid[IEEE80211_ADDR_LEN];
198};
199
200#define SIOCS80211BSSID _IOW('i', 240, struct ieee80211_bssid)
201#define SIOCG80211BSSID _IOWR('i', 241, struct ieee80211_bssid)
202
203/* transmit power */
204struct ieee80211_txpower {
205 char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */
206 int i_mode; /* auto, manual */
207 int16_t i_val; /* dBm */
208};
209
210#define SIOCS80211TXPOWER _IOW('i', 243, struct ieee80211_txpower)
211#define SIOCG80211TXPOWER _IOWR('i', 244, struct ieee80211_txpower)
212
213#define IEEE80211_TXPOWER_MODE_FIXED 0 /* fixed tx power value */
214#define IEEE80211_TXPOWER_MODE_AUTO 1 /* auto level control */
215
216struct ieee80211_wpapsk {
217 char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */
218 int i_enabled;
219 u_int8_t i_psk[32];
220};
221
222#define SIOCS80211WPAPSK _IOW('i', 245, struct ieee80211_wpapsk)
223#define SIOCG80211WPAPSK _IOWR('i', 246, struct ieee80211_wpapsk)
224
225#define IEEE80211_WPA_PROTO_WPA1 0x01
226#define IEEE80211_WPA_PROTO_WPA2 0x02
227
228#define IEEE80211_WPA_CIPHER_NONE 0x00
229#define IEEE80211_WPA_CIPHER_USEGROUP 0x01
230#define IEEE80211_WPA_CIPHER_WEP40 0x02
231#define IEEE80211_WPA_CIPHER_TKIP 0x04
232#define IEEE80211_WPA_CIPHER_CCMP 0x08
233#define IEEE80211_WPA_CIPHER_WEP104 0x10
234#define IEEE80211_WPA_CIPHER_BIP 0x20
235
236#define IEEE80211_WPA_AKM_PSK 0x01
237#define IEEE80211_WPA_AKM_8021X 0x02
238#define IEEE80211_WPA_AKM_SHA256_PSK 0x04
239#define IEEE80211_WPA_AKM_SHA256_8021X 0x08
240#define IEEE80211_WPA_AKM_SAE 0x10
241
242struct ieee80211_wpaparams {
243 char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */
244 int i_enabled;
245 u_int i_protos;
246 u_int i_akms;
247 u_int i_ciphers;
248 u_int i_groupcipher;
249};
250
251#define SIOCS80211WPAPARMS _IOW('i', 247, struct ieee80211_wpaparams)
252#define SIOCG80211WPAPARMS _IOWR('i', 248, struct ieee80211_wpaparams)
253
254struct ieee80211_keyavail {
255 char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */
256 u_int8_t i_macaddr[IEEE80211_ADDR_LEN];
257 u_int8_t i_key[32];
258 u_int32_t i_lifetime;
259};
260
261struct ieee80211_keyrun {
262 char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */
263 u_int8_t i_macaddr[IEEE80211_ADDR_LEN];
264};
265
266#define SIOCS80211KEYAVAIL _IOW('i', 251, struct ieee80211_keyavail)
267#define SIOCS80211KEYRUN _IOW('i', 252, struct ieee80211_keyrun)
268
269/* scan request (will block) */
270#define IEEE80211_SCAN_TIMEOUT 30 /* timeout in seconds */
271
272#define SIOCS80211SCAN _IOW('i', 210, struct ifreq)
273
274#define SIOCG80211JOINALL _IOWR('i', 218, struct ieee80211_joinreq_all)
275#define SIOCS80211JOIN _IOWR('i', 255, struct ifreq)
276#define SIOCG80211JOIN _IOWR('i', 0, struct ifreq)
277
278/* join is pointed at by ifr.ifr_data */
279struct ieee80211_join {
280 u_int8_t i_len; /* length of i_nwid */
281 u_int8_t i_nwid[IEEE80211_NWID_LEN];
282 u_int32_t i_flags;
283
284 struct ieee80211_wpaparams i_wpaparams;
285 struct ieee80211_wpapsk i_wpapsk;
286 struct ieee80211_nwkey i_nwkey;
287};
288
289struct ieee80211_joinreq_all {
290 char ja_ifname[IFNAMSIZ];
291 int ja_nodes; /* returned count */
292 size_t ja_size; /* size of node buffer */
293 struct ieee80211_join *ja_node; /* allocated node buffer */
294};
295
296
297#define IEEE80211_JOIN_SHOW 0x01
298#define IEEE80211_JOIN_FOUND 0x02
299#define IEEE80211_JOIN_DEL 0x04
300#define IEEE80211_JOIN_NWKEY 0x08
301#define IEEE80211_JOIN_WPA 0x10
302#define IEEE80211_JOIN_WPAPSK 0x20
303#define IEEE80211_JOIN_8021X 0x40
304#define IEEE80211_JOIN_ANY 0x80
305#define IEEE80211_JOIN_DEL_ALL 0x100
306
307/* node and requests */
308struct ieee80211_nodereq {
309 char nr_ifname[IFNAMSIZ]; /* e.g. "ath0" */
310
311 /* Node address and name information */
312 u_int8_t nr_macaddr[IEEE80211_ADDR_LEN]; /* node lladdr */
313 u_int8_t nr_bssid[IEEE80211_ADDR_LEN]; /* bssid */
314 u_int8_t nr_nwid_len; /* ESSID length */
315 u_int8_t nr_nwid[IEEE80211_NWID_LEN]; /* ESSID */
316
317 /* Channel and rates */
318 u_int16_t nr_channel; /* last channel */
319 u_int16_t nr_chan_flags; /* channel flags */
320 u_int8_t nr_nrates; /* rate count */
321 u_int8_t nr_rates[IEEE80211_RATE_MAXSIZE]; /* rate set */
322
323 /* Node status information */
324 int8_t nr_rssi; /* received signal strength */
325 int8_t nr_max_rssi; /* maximum rssi */
326 u_int8_t nr_tstamp[8]; /* from last received beacon */
327 u_int16_t nr_intval; /* beacon interval */
328 u_int16_t nr_capinfo; /* capabilities */
329 u_int8_t nr_erp; /* 11g only */
330 u_int8_t nr_pwrsave; /* power saving mode */
331 u_int16_t nr_associd; /* assoc response */
332 u_int16_t nr_txseq; /* seq to be transmitted */
333 u_int16_t nr_rxseq; /* seq previous received */
334 u_int32_t nr_fails; /* failure count to associate */
335 u_int32_t nr_inact; /* inactivity mark count */
336 u_int8_t nr_txrate; /* index to nr_rates[] */
337 u_int16_t nr_state; /* node state in the cache */
338
339 /* RSN */
340 u_int nr_rsnprotos;
341 u_int nr_rsnciphers;
342 u_int nr_rsnakms;
343
344 /* Node flags */
345 u_int8_t nr_flags;
346
347 /* HT */
348 uint16_t nr_htcaps;
349 uint8_t nr_rxmcs[howmany(80,NBBY)];
350 uint16_t nr_max_rxrate; /* in Mb/s, 0 <= rate <= 1023 */
351 uint8_t nr_tx_mcs_set;
352
353 /* HT / VHT */
354 uint8_t nr_txmcs;
355
356 /* VHT */
357 uint8_t nr_vht_ss;
358
359 u_int32_t nr_assoc_fail; /* association failure reasons */
360};
361
362#define IEEE80211_NODEREQ_STATE(_s) (1 << _s)
363#define IEEE80211_NODEREQ_STATE_BITS \
364 "\20\01CACHE\02BSS\03AUTH\04ASSOC\05COLLECT"
365
366#define IEEE80211_NODEREQ_RSSI(_nr) \
367 ((u_int)(((float)(_nr)->nr_rssi / (_nr)->nr_max_rssi) * 100))
368
369#define IEEE80211_NODEREQ_STA 0x00 /* station */
370#define IEEE80211_NODEREQ_AP 0x01 /* access point */
371#define IEEE80211_NODEREQ_AP_BSS 0x02 /* current bss access point */
372#define IEEE80211_NODEREQ_COPY 0x04 /* add node with flags */
373#define IEEE80211_NODEREQ_HT 0x08 /* HT negotiated */
374#define IEEE80211_NODEREQ_VHT 0x10 /* VHT negotiated */
375
376#define SIOCG80211NODE _IOWR('i', 211, struct ieee80211_nodereq)
377#define SIOCS80211NODE _IOW('i', 212, struct ieee80211_nodereq)
378#define SIOCS80211DELNODE _IOW('i', 213, struct ieee80211_nodereq)
379
380#define IEEE80211_NODEREQ_ASSOCFAIL_CHAN 0x01
381#define IEEE80211_NODEREQ_ASSOCFAIL_IBSS 0x02
382#define IEEE80211_NODEREQ_ASSOCFAIL_PRIVACY 0x04
383#define IEEE80211_NODEREQ_ASSOCFAIL_BASIC_RATE 0x08
384#define IEEE80211_NODEREQ_ASSOCFAIL_ESSID 0x10
385#define IEEE80211_NODEREQ_ASSOCFAIL_BSSID 0x20
386#define IEEE80211_NODEREQ_ASSOCFAIL_WPA_PROTO 0x40
387#define IEEE80211_NODEREQ_ASSOCFAIL_WPA_KEY 0x80
388#define IEEE80211_NODEREQ_ASSOCFAIL_CSA 0x100
389#define IEEE80211_NODEREQ_ASSOCFAIL_BITS \
390 "\20\1!CHAN\2!IBSS\3!PRIVACY\4!BASICRATE\5!ESSID\6!BSSID\7!WPAPROTO" \
391 "\10!WPAKEY\11!CSA"
392
393/* get the entire node cache */
394struct ieee80211_nodereq_all {
395 char na_ifname[IFNAMSIZ]; /* e.g. "ath0" */
396
397 int na_nodes; /* returned count */
398 size_t na_size; /* size of node buffer */
399 struct ieee80211_nodereq *na_node; /* allocated node buffer */
400
401 /* Match nodes by flag */
402 u_int8_t na_flags; /* IEEE80211_NODEREQ_* */
403};
404
405#define SIOCG80211ALLNODES _IOWR('i', 214, struct ieee80211_nodereq_all)
406
407/* net80211 specific interface flags */
408#define IEEE80211_F_HIDENWID 0x00000001 /* CONF: hidden ssid mode */
409#define IEEE80211_F_NOBRIDGE 0x00000002 /* CONF: no internal bridging */
410#define IEEE80211_F_HOSTAPMASK 0x00000003
411#define IEEE80211_F_STAYAUTH 0x00000004 /* CONF: ignore deauth */
412#define IEEE80211_F_NOMIMO 0x00000008 /* CONF: disable MIMO */
413#define IEEE80211_F_USERBITS "\20\01HIDENWID\02NOBRIDGE\03STAYAUTH\04NOMIMO"
414
415struct ieee80211_flags {
416 const char *f_name;
417 u_int f_flag;
418};
419
420#define IEEE80211_FLAGS { \
421 { "hidenwid", IEEE80211_F_HIDENWID }, \
422 { "nobridge", IEEE80211_F_NOBRIDGE }, \
423 { "stayauth", IEEE80211_F_STAYAUTH }, \
424 { "nomimo", IEEE80211_F_NOMIMO } \
425}
426
427#define SIOCG80211FLAGS _IOWR('i', 216, struct ifreq)
428#define SIOCS80211FLAGS _IOW('i', 217, struct ifreq)
429
430#endif /* _NET80211_IEEE80211_IOCTL_H_ */