/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
* This file define a set of standard wireless extensions
* Authors : Jean Tourrilhes - HPL - <jt@hpl.hp.com>
* Copyright (c) 1997-2007 Jean Tourrilhes, All Rights Reserved.
#ifndef _LINUX_WIRELESS_H
#define _LINUX_WIRELESS_H
/************************** DOCUMENTATION **************************/
* Initial APIs (1996 -> onward) :
* -----------------------------
* Basically, the wireless extensions are for now a set of standard ioctl
* call + /proc/net/wireless
* The entry /proc/net/wireless give statistics and information on the
* This is better than having each driver having its entry because
* its centralised and we may remove the driver module safely.
* Ioctl are used to configure the driver and issue commands. This is
* better than command line options of insmod because we may want to
* change dynamically (while the driver is running) some parameters.
* The ioctl mechanimsm are copied from standard devices ioctl.
* We have the list of command plus a structure descibing the
* Note that to add these ioctl, I was obliged to modify :
* # net/core/dev.c (two place + add include)
* # net/ipv4/af_inet.c (one place + add include)
* /proc/net/wireless is a copy of /proc/net/dev.
* We have a structure for data passed from the driver to /proc/net/wireless
* Too add this, I've modified :
* # net/core/dev.c (two other places)
* # include/linux/netdevice.h (one place)
* # include/linux/proc_fs.h (one place)
* New driver API (2002 -> onward) :
* -------------------------------
* This file is only concerned with the user space API and common definitions.
* The new driver API is defined and documented in :
* # include/net/iw_handler.h
* Note as well that /proc/net/wireless implementation has now moved in :
* Wireless Events (2002 -> onward) :
* --------------------------------
* Events are defined at the end of this file, and implemented in :
* Do not add here things that are redundant with other mechanisms
* (drivers init, ifconfig, /proc/net/dev, ...) and with are not
* These wireless extensions are not magic : each driver has to provide
* IMPORTANT NOTE : As everything in the kernel, this is very much a
* work in progress. Contact me if you have ideas of improvements...
/***************************** INCLUDES *****************************/
#include <linux/types.h> /* for __u* and __s* typedefs */
#include <linux/socket.h> /* for "struct sockaddr" et al */
#include <linux/if.h> /* for IFNAMSIZ and co... */
/***************************** VERSION *****************************/
* This constant is used to know the availability of the wireless
* extensions and to know which version of wireless extensions it is
* (there is some stuff that will be added in the future...)
* I just plan to increment with each new version.
* Alan Cox start some incompatibles changes. I've integrated a bit more.
* - Encryption renamed to Encode to avoid US regulation problems
* - Frequency changed from float to struct to avoid problems on old 386
* - Missing encoding definitions in range
* - 802.11 support (ESSID ioctls)
* - define IW_ESSID_MAX_SIZE and IW_MAX_AP
* - Changed my e-mail address
* - More 802.11 support (nickname, rate, rts, frag)
* - List index in frequencies
* - Support for 'mode of operation' (ad-hoc, managed...)
* - Support for unicast and multicast power saving
* - Change encoding to support larger tokens (>64 bits)
* - Updated iw_params (disable, flags) and use it for NWID
* - Extracted iw_point from iwreq for clarity
* - Add PM capability to range structure
* - Add PM modifier : MAX/MIN/RELATIVE
* - Add encoding option : IW_ENCODE_NOKEY
* - Add TxPower ioctls (work like TxRate)
* - Add WE version in range (help backward/forward compatibility)
* - Add retry ioctls (work like PM)
* - Add SIOCSIWSTATS to get /proc/net/wireless programatically
* - Add DEV PRIVATE IOCTL to avoid collisions in SIOCDEVPRIVATE space
* - Add new statistics (frag, retry, beacon)
* - Add average quality (for user space calibration)
* - Document creation of new driver API.
* - Extract union iwreq_data from struct iwreq (for new driver API).
* - Rename SIOCSIWNAME as SIOCSIWCOMMIT
* - Wireless Events support : define struct iw_event
* - Define additional specific event numbers
* - Add "addr" and "param" fields in union iwreq_data
* - AP scanning stuff (SIOCSIWSCAN and friends)
* - Add IW_PRIV_TYPE_ADDR for struct sockaddr private arg
* - Make struct iw_freq signed (both m & e), add explicit padding
* - Add IWEVCUSTOM for driver specific event/scanning token
* - Add IW_MAX_GET_SPY for driver returning a lot of addresses
* - Add IW_TXPOW_RANGE for range of Tx Powers
* - Add IWEVREGISTERED & IWEVEXPIRED events for Access Points
* - Add IW_MODE_MONITOR for passive monitor
* - Increase the number of bitrates in iw_range to 32 (for 802.11g)
* - Increase the number of frequencies in iw_range to 32 (for 802.11b+a)
* - Reshuffle struct iw_range for increases, add filler
* - Increase IW_MAX_AP to 64 for driver returning a lot of addresses
* - Remove IW_MAX_GET_SPY because conflict with enhanced spy support
* - Add SIOCSIWTHRSPY/SIOCGIWTHRSPY and "struct iw_thrspy"
* - Add IW_ENCODE_TEMP and iw_range->encoding_login_index
* - Add flags to frequency -> auto/fixed
* - Document (struct iw_quality *)->updated, add new flags (INVALID)
* - Wireless Event capability in struct iw_range
* - Add support for relative TxPower (yick !)
* V17 to V18 (From Jouni Malinen <j@w1.fi>)
* - Add support for WPA/WPA2
* - Add extended encoding configuration (SIOCSIWENCODEEXT and
* - Add SIOCSIWGENIE/SIOCGIWGENIE
* - Add struct iw_range bit field for supported encoding capabilities
* - Add optional scan request parameters for SIOCSIWSCAN
* - Add SIOCSIWAUTH/SIOCGIWAUTH for setting authentication and WPA
* related parameters (extensible up to 4096 parameter values)
* - Add wireless events: IWEVGENIE, IWEVMICHAELMICFAILURE,
* IWEVASSOCREQIE, IWEVASSOCRESPIE, IWEVPMKIDCAND
* - Remove (struct iw_point *)->pointer from events and streams
* - Remove header includes to help user space
* - Increase IW_ENCODING_TOKEN_MAX from 32 to 64
* - Add IW_QUAL_ALL_UPDATED and IW_QUAL_ALL_INVALID macros
* - Add explicit flag to tell stats are in dBm : IW_QUAL_DBM
* - Add IW_IOCTL_IDX() and IW_EVENT_IDX() macros
* - RtNetlink requests support (SET/GET)
* - Remove (struct net_device *)->get_wireless_stats()
* - Change length in ESSID and NICK to strlen() instead of strlen()+1
* - Add IW_RETRY_SHORT/IW_RETRY_LONG retry modifiers
* - Power/Retry relative values no longer * 100000
* - Add explicit flag to tell stats are in 802.11k RCPI : IW_QUAL_RCPI
* - Prevent leaking of kernel space in stream on 64 bits.
/**************************** CONSTANTS ****************************/
/* -------------------------- IOCTL LIST -------------------------- */
/* Wireless Identification */
#define SIOCSIWCOMMIT 0x8B00 /* Commit pending changes to driver */
#define SIOCGIWNAME 0x8B01 /* get name == wireless protocol */
/* SIOCGIWNAME is used to verify the presence of Wireless Extensions.
* Common values : "IEEE 802.11-DS", "IEEE 802.11-FH", "IEEE 802.11b"...
* Don't put the name of your driver there, it's useless. */
#define SIOCSIWNWID 0x8B02 /* set network id (pre-802.11) */
#define SIOCGIWNWID 0x8B03 /* get network id (the cell) */
#define SIOCSIWFREQ 0x8B04 /* set channel/frequency (Hz) */
#define SIOCGIWFREQ 0x8B05 /* get channel/frequency (Hz) */
#define SIOCSIWMODE 0x8B06 /* set operation mode */
#define SIOCGIWMODE 0x8B07 /* get operation mode */
#define SIOCSIWSENS 0x8B08 /* set sensitivity (dBm) */
#define SIOCGIWSENS 0x8B09 /* get sensitivity (dBm) */
#define SIOCSIWRANGE 0x8B0A /* Unused */
#define SIOCGIWRANGE 0x8B0B /* Get range of parameters */
#define SIOCSIWPRIV 0x8B0C /* Unused */
#define SIOCGIWPRIV 0x8B0D /* get private ioctl interface info */
#define SIOCSIWSTATS 0x8B0E /* Unused */
#define SIOCGIWSTATS 0x8B0F /* Get /proc/net/wireless stats */
/* SIOCGIWSTATS is strictly used between user space and the kernel, and
* is never passed to the driver (i.e. the driver will never see it). */
/* Spy support (statistics per MAC address - used for Mobile IP support) */
#define SIOCSIWSPY 0x8B10 /* set spy addresses */
#define SIOCGIWSPY 0x8B11 /* get spy info (quality of link) */
#define SIOCSIWTHRSPY 0x8B12 /* set spy threshold (spy event) */
#define SIOCGIWTHRSPY 0x8B13 /* get spy threshold */
/* Access Point manipulation */
#define SIOCSIWAP 0x8B14 /* set access point MAC addresses */
#define SIOCGIWAP 0x8B15 /* get access point MAC addresses */
#define SIOCGIWAPLIST 0x8B17 /* Deprecated in favor of scanning */
#define SIOCSIWSCAN 0x8B18 /* trigger scanning (list cells) */
#define SIOCGIWSCAN 0x8B19 /* get scanning results */
/* 802.11 specific support */
#define SIOCSIWESSID 0x8B1A /* set ESSID (network name) */
#define SIOCGIWESSID 0x8B1B /* get ESSID */
#define SIOCSIWNICKN 0x8B1C /* set node name/nickname */
#define SIOCGIWNICKN 0x8B1D /* get node name/nickname */
/* As the ESSID and NICKN are strings up to 32 bytes long, it doesn't fit
* within the 'iwreq' structure, so we need to use the 'data' member to
* point to a string in user space, like it is done for RANGE... */
/* Other parameters useful in 802.11 and some other devices */
#define SIOCSIWRATE 0x8B20 /* set default bit rate (bps) */
#define SIOCGIWRATE 0x8B21 /* get default bit rate (bps) */
#define SIOCSIWRTS 0x8B22 /* set RTS/CTS threshold (bytes) */
#define SIOCGIWRTS 0x8B23 /* get RTS/CTS threshold (bytes) */
#define SIOCSIWFRAG 0x8B24 /* set fragmentation thr (bytes) */
#define SIOCGIWFRAG 0x8B25 /* get fragmentation thr (bytes) */
#define SIOCSIWTXPOW 0x8B26 /* set transmit power (dBm) */
#define SIOCGIWTXPOW 0x8B27 /* get transmit power (dBm) */
#define SIOCSIWRETRY 0x8B28 /* set retry limits and lifetime */
#define SIOCGIWRETRY 0x8B29 /* get retry limits and lifetime */
/* Encoding stuff (scrambling, hardware security, WEP...) */
#define SIOCSIWENCODE 0x8B2A /* set encoding token & mode */
#define SIOCGIWENCODE 0x8B2B /* get encoding token & mode */
/* Power saving stuff (power management, unicast and multicast) */
#define SIOCSIWPOWER 0x8B2C /* set Power Management settings */
#define SIOCGIWPOWER 0x8B2D /* get Power Management settings */
/* WPA : Generic IEEE 802.11 informatiom element (e.g., for WPA/RSN/WMM).
* This ioctl uses struct iw_point and data buffer that includes IE id and len
* fields. More than one IE may be included in the request. Setting the generic
* IE to empty buffer (len=0) removes the generic IE from the driver. Drivers
* are allowed to generate their own WPA/RSN IEs, but in these cases, drivers
* are required to report the used IE as a wireless event, e.g., when
* associating with an AP. */
#define SIOCSIWGENIE 0x8B30 /* set generic IE */
#define SIOCGIWGENIE 0x8B31 /* get generic IE */
/* WPA : IEEE 802.11 MLME requests */
#define SIOCSIWMLME 0x8B16 /* request MLME operation; uses
/* WPA : Authentication mode parameters */
#define SIOCSIWAUTH 0x8B32 /* set authentication mode params */
#define SIOCGIWAUTH 0x8B33 /* get authentication mode params */
/* WPA : Extended version of encoding configuration */
#define SIOCSIWENCODEEXT 0x8B34 /* set encoding token & mode */
#define SIOCGIWENCODEEXT 0x8B35 /* get encoding token & mode */
/* WPA2 : PMKSA cache management */
#define SIOCSIWPMKSA 0x8B36 /* PMKSA cache operation */
/* -------------------- DEV PRIVATE IOCTL LIST -------------------- */
/* These 32 ioctl are wireless device private, for 16 commands.
* Each driver is free to use them for whatever purpose it chooses,
* however the driver *must* export the description of those ioctls
* with SIOCGIWPRIV and *must* use arguments as defined below.
* If you don't follow those rules, DaveM is going to hate you (reason :
* it make mixed 32/64bit operation impossible).
#define SIOCIWFIRSTPRIV 0x8BE0
#define SIOCIWLASTPRIV 0x8BFF
/* Previously, we were using SIOCDEVPRIVATE, but we now have our
* separate range because of collisions with other tools such as
* We now have 32 commands, so a bit more space ;-).
* Also, all 'even' commands are only usable by root and don't return the
* content of ifr/iwr to user (but you are not obliged to use the set/get
* convention, just use every other two command). More details in iwpriv.c.
* And I repeat : you are not forced to use them with iwpriv, but you
* must be compliant with it.
/* ------------------------- IOCTL STUFF ------------------------- */
/* The first and the last (range) */
#define SIOCIWFIRST 0x8B00
#define SIOCIWLAST SIOCIWLASTPRIV /* 0x8BFF */
#define IW_IOCTL_IDX(cmd) ((cmd) - SIOCIWFIRST)
#define IW_HANDLER(id, func) \
[IW_IOCTL_IDX(id)] = func
/* Odd : get (world access), even : set (root access) */
#define IW_IS_SET(cmd) (!((cmd) & 0x1))
#define IW_IS_GET(cmd) ((cmd) & 0x1)
/* ----------------------- WIRELESS EVENTS ----------------------- */
/* Those are *NOT* ioctls, do not issue request on them !!! */
/* Most events use the same identifier as ioctl requests */
#define IWEVTXDROP 0x8C00 /* Packet dropped to excessive retry */
#define IWEVQUAL 0x8C01 /* Quality part of statistics (scan) */
#define IWEVCUSTOM 0x8C02 /* Driver specific ascii string */
#define IWEVREGISTERED 0x8C03 /* Discovered a new node (AP mode) */
#define IWEVEXPIRED 0x8C04 /* Expired a node (AP mode) */
#define IWEVGENIE 0x8C05 /* Generic IE (WPA, RSN, WMM, ..)
* (scan results); This includes id and
* length fields. One IWEVGENIE may
* contain more than one IE. Scan
* results may contain one or more
#define IWEVMICHAELMICFAILURE 0x8C06 /* Michael MIC failure
* (struct iw_michaelmicfailure)
#define IWEVASSOCREQIE 0x8C07 /* IEs used in (Re)Association Request.
* The data includes id and length
* fields and may contain more than one
* IE. This event is required in
* Managed mode if the driver
* generates its own WPA/RSN IE. This
* should be sent just before
* IWEVREGISTERED event for the
#define IWEVASSOCRESPIE 0x8C08 /* IEs used in (Re)Association
* Response. The data includes id and
* length fields and may contain more
* than one IE. This may be sent
* between IWEVASSOCREQIE and
* IWEVREGISTERED events for the
#define IWEVPMKIDCAND 0x8C09 /* PMKID candidate for RSN
* (struct iw_pmkid_cand) */
#define IW_EVENT_IDX(cmd) ((cmd) - IWEVFIRST)
/* ------------------------- PRIVATE INFO ------------------------- */
* The following is used with SIOCGIWPRIV. It allow a driver to define
* the interface (name, type of data) for its private ioctl.
* Privates ioctl are SIOCIWFIRSTPRIV -> SIOCIWLASTPRIV
#define IW_PRIV_TYPE_MASK 0x7000 /* Type of arguments */
#define IW_PRIV_TYPE_NONE 0x0000
#define IW_PRIV_TYPE_BYTE 0x1000 /* Char as number */
#define IW_PRIV_TYPE_CHAR 0x2000 /* Char as character */
#define IW_PRIV_TYPE_INT 0x4000 /* 32 bits int */
#define IW_PRIV_TYPE_FLOAT 0x5000 /* struct iw_freq */
#define IW_PRIV_TYPE_ADDR 0x6000 /* struct sockaddr */
#define IW_PRIV_SIZE_FIXED 0x0800 /* Variable or fixed number of args */
#define IW_PRIV_SIZE_MASK 0x07FF /* Max number of those args */
* Note : if the number of args is fixed and the size < 16 octets,
* instead of passing a pointer we will put args in the iwreq struct...
/* ----------------------- OTHER CONSTANTS ----------------------- */
/* Maximum frequencies in the range struct */
#define IW_MAX_FREQUENCIES 32
/* Note : if you have something like 80 frequencies,
* don't increase this constant and don't fill the frequency list.
* The user will be able to set by channel anyway... */
/* Maximum bit rates in the range struct */
#define IW_MAX_BITRATES 32
/* Maximum tx powers in the range struct */
/* Note : if you more than 8 TXPowers, just set the max and min or
* a few of them in the struct iw_range. */
/* Maximum of address that you may set with SPY */
/* Maximum of address that you may get in the
list of access points in range */
/* Maximum size of the ESSID and NICKN strings */
#define IW_ESSID_MAX_SIZE 32
#define IW_MODE_AUTO 0 /* Let the driver decides */
#define IW_MODE_ADHOC 1 /* Single cell network */
#define IW_MODE_INFRA 2 /* Multi cell network, roaming, ... */
#define IW_MODE_MASTER 3 /* Synchronisation master or Access Point */
#define IW_MODE_REPEAT 4 /* Wireless Repeater (forwarder) */
#define IW_MODE_SECOND 5 /* Secondary master/repeater (backup) */
#define IW_MODE_MONITOR 6 /* Passive monitor (listen only) */
#define IW_MODE_MESH 7 /* Mesh (IEEE 802.11s) network */
/* Statistics flags (bitmask in updated) */
#define IW_QUAL_QUAL_UPDATED 0x01 /* Value was updated since last read */
#define IW_QUAL_LEVEL_UPDATED 0x02
#define IW_QUAL_NOISE_UPDATED 0x04
#define IW_QUAL_ALL_UPDATED 0x07
#define IW_QUAL_DBM 0x08 /* Level + Noise are dBm */
#define IW_QUAL_QUAL_INVALID 0x10 /* Driver doesn't provide value */
#define IW_QUAL_LEVEL_INVALID 0x20
#define IW_QUAL_NOISE_INVALID 0x40
#define IW_QUAL_RCPI 0x80 /* Level + Noise are 802.11k RCPI */
#define IW_QUAL_ALL_INVALID 0x70
#define IW_FREQ_AUTO 0x00 /* Let the driver decides */
#define IW_FREQ_FIXED 0x01 /* Force a specific value */
/* Maximum number of size of encoding token available
* they are listed in the range structure */
#define IW_MAX_ENCODING_SIZES 8
/* Maximum size of the encoding token in bytes */
#define IW_ENCODING_TOKEN_MAX 64 /* 512 bits (for now) */
/* Flags for encoding (along with the token) */
#define IW_ENCODE_INDEX 0x00FF /* Token index (if needed) */
#define IW_ENCODE_FLAGS 0xFF00 /* Flags defined below */
#define IW_ENCODE_MODE 0xF000 /* Modes defined below */
#define IW_ENCODE_DISABLED 0x8000 /* Encoding disabled */
#define IW_ENCODE_ENABLED 0x0000 /* Encoding enabled */
#define IW_ENCODE_RESTRICTED 0x4000 /* Refuse non-encoded packets */
#define IW_ENCODE_OPEN 0x2000 /* Accept non-encoded packets */
#define IW_ENCODE_NOKEY 0x0800 /* Key is write only, so not present */
#define IW_ENCODE_TEMP 0x0400 /* Temporary key */
/* Power management flags available (along with the value, if any) */
#define IW_POWER_ON 0x0000 /* No details... */
#define IW_POWER_TYPE 0xF000 /* Type of parameter */
#define IW_POWER_PERIOD 0x1000 /* Value is a period/duration of */
#define IW_POWER_TIMEOUT 0x2000 /* Value is a timeout (to go asleep) */
#define IW_POWER_MODE 0x0F00 /* Power Management mode */
#define IW_POWER_UNICAST_R 0x0100 /* Receive only unicast messages */
#define IW_POWER_MULTICAST_R 0x0200 /* Receive only multicast messages */
#define IW_POWER_ALL_R 0x0300 /* Receive all messages though PM */