Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

wireless.h

Go to the documentation of this file.
00001 /*
00002  * This file define a set of standard wireless extensions
00003  *
00004  * Version :    9       16.10.99
00005  *
00006  * Authors :    Jean Tourrilhes - HPL - <jt@hpl.hp.com>
00007  */
00008 
00009 #ifndef _LINUX_WIRELESS_H
00010 #define _LINUX_WIRELESS_H
00011 
00012 /************************** DOCUMENTATION **************************/
00013 /*
00014  * Basically, the wireless extensions are for now a set of standard ioctl
00015  * call + /proc/net/wireless
00016  *
00017  * The entry /proc/net/wireless give statistics and information on the
00018  * driver.
00019  * This is better than having each driver having its entry because
00020  * its centralised and we may remove the driver module safely.
00021  *
00022  * Ioctl are used to configure the driver and issue commands.  This is
00023  * better than command line options of insmod because we may want to
00024  * change dynamically (while the driver is running) some parameters.
00025  *
00026  * The ioctl mechanimsm are copied from standard devices ioctl.
00027  * We have the list of command plus a structure descibing the
00028  * data exchanged...
00029  * Note that to add these ioctl, I was obliged to modify :
00030  *      net/core/dev.c (two place + add include)
00031  *      net/ipv4/af_inet.c (one place + add include)
00032  *
00033  * /proc/net/wireless is a copy of /proc/net/dev.
00034  * We have a structure for data passed from the driver to /proc/net/wireless
00035  * Too add this, I've modified :
00036  *      net/core/dev.c (two other places)
00037  *      include/linux/netdevice.h (one place)
00038  *      include/linux/proc_fs.h (one place)
00039  *
00040  * Do not add here things that are redundant with other mechanisms
00041  * (drivers init, ifconfig, /proc/net/dev, ...) and with are not
00042  * wireless specific.
00043  *
00044  * These wireless extensions are not magic : each driver has to provide
00045  * support for them...
00046  *
00047  * IMPORTANT NOTE : As everything in the kernel, this is very much a
00048  * work in progress. Contact me if you have ideas of improvements...
00049  */
00050 
00051 /***************************** INCLUDES *****************************/
00052 
00053 #include <linux/types.h>                /* for "caddr_t" et al          */
00054 #include <linux/socket.h>               /* for "struct sockaddr" et al  */
00055 #include <linux/if.h>                   /* for IFNAMSIZ and co... */
00056 
00057 /**************************** CONSTANTS ****************************/
00058 
00059 /* --------------------------- VERSION --------------------------- */
00060 /*
00061  * This constant is used to know the availability of the wireless
00062  * extensions and to know which version of wireless extensions it is
00063  * (there is some stuff that will be added in the future...)
00064  * I just plan to increment with each new version.
00065  */
00066 #define WIRELESS_EXT    10
00067 
00068 /*
00069  * Changes :
00070  *
00071  * V2 to V3
00072  * --------
00073  *      Alan Cox start some incompatibles changes. I've integrated a bit more.
00074  *      - Encryption renamed to Encode to avoid US regulation problems
00075  *      - Frequency changed from float to struct to avoid problems on old 386
00076  *
00077  * V3 to V4
00078  * --------
00079  *      - Add sensitivity
00080  *
00081  * V4 to V5
00082  * --------
00083  *      - Missing encoding definitions in range
00084  *      - Access points stuff
00085  *
00086  * V5 to V6
00087  * --------
00088  *      - 802.11 support (ESSID ioctls)
00089  *
00090  * V6 to V7
00091  * --------
00092  *      - define IW_ESSID_MAX_SIZE and IW_MAX_AP
00093  *
00094  * V7 to V8
00095  * --------
00096  *      - Changed my e-mail address
00097  *      - More 802.11 support (nickname, rate, rts, frag)
00098  *      - List index in frequencies
00099  *
00100  * V8 to V9
00101  * --------
00102  *      - Support for 'mode of operation' (ad-hoc, managed...)
00103  *      - Support for unicast and multicast power saving
00104  *      - Change encoding to support larger tokens (>64 bits)
00105  *      - Updated iw_params (disable, flags) and use it for NWID
00106  *      - Extracted iw_point from iwreq for clarity
00107  *
00108  * V9 to V10
00109  * ---------
00110  *      - Add PM capability to range structure
00111  *      - Add PM modifier : MAX/MIN/RELATIVE
00112  *      - Add encoding option : IW_ENCODE_NOKEY
00113  *      - Add TxPower ioctls (work like TxRate)
00114  */
00115 
00116 /* -------------------------- IOCTL LIST -------------------------- */
00117 
00118 /* Basic operations */
00119 #define SIOCSIWNAME     0x8B00          /* Unused */
00120 #define SIOCGIWNAME     0x8B01          /* get name == wireless protocol */
00121 #define SIOCSIWNWID     0x8B02          /* set network id (the cell) */
00122 #define SIOCGIWNWID     0x8B03          /* get network id */
00123 #define SIOCSIWFREQ     0x8B04          /* set channel/frequency (Hz) */
00124 #define SIOCGIWFREQ     0x8B05          /* get channel/frequency (Hz) */
00125 #define SIOCSIWMODE     0x8B06          /* set operation mode */
00126 #define SIOCGIWMODE     0x8B07          /* get operation mode */
00127 #define SIOCSIWSENS     0x8B08          /* set sensitivity (dBm) */
00128 #define SIOCGIWSENS     0x8B09          /* get sensitivity (dBm) */
00129 
00130 /* Informative stuff */
00131 #define SIOCSIWRANGE    0x8B0A          /* Unused */
00132 #define SIOCGIWRANGE    0x8B0B          /* Get range of parameters */
00133 #define SIOCSIWPRIV     0x8B0C          /* Unused */
00134 #define SIOCGIWPRIV     0x8B0D          /* get private ioctl interface info */
00135 
00136 /* Mobile IP support */
00137 #define SIOCSIWSPY      0x8B10          /* set spy addresses */
00138 #define SIOCGIWSPY      0x8B11          /* get spy info (quality of link) */
00139 
00140 /* Access Point manipulation */
00141 #define SIOCSIWAP       0x8B14          /* set access point MAC addresses */
00142 #define SIOCGIWAP       0x8B15          /* get access point MAC addresses */
00143 #define SIOCGIWAPLIST   0x8B17          /* get list of access point in range */
00144 
00145 /* 802.11 specific support */
00146 #define SIOCSIWESSID    0x8B1A          /* set ESSID (network name) */
00147 #define SIOCGIWESSID    0x8B1B          /* get ESSID */
00148 #define SIOCSIWNICKN    0x8B1C          /* set node name/nickname */
00149 #define SIOCGIWNICKN    0x8B1D          /* get node name/nickname */
00150 /* As the ESSID and NICKN are strings up to 32 bytes long, it doesn't fit
00151  * within the 'iwreq' structure, so we need to use the 'data' member to
00152  * point to a string in user space, like it is done for RANGE...
00153  * The "flags" member indicate if the ESSID is active or not (promiscuous).
00154  */
00155 
00156 /* Other parameters usefull in 802.11 and some other devices */
00157 #define SIOCSIWRATE     0x8B20          /* set default bit rate (bps) */
00158 #define SIOCGIWRATE     0x8B21          /* get default bit rate (bps) */
00159 #define SIOCSIWRTS      0x8B22          /* set RTS/CTS threshold (bytes) */
00160 #define SIOCGIWRTS      0x8B23          /* get RTS/CTS threshold (bytes) */
00161 #define SIOCSIWFRAG     0x8B24          /* set fragmentation thr (bytes) */
00162 #define SIOCGIWFRAG     0x8B25          /* get fragmentation thr (bytes) */
00163 #define SIOCSIWTXPOW    0x8B26          /* set transmit power (dBm) */
00164 #define SIOCGIWTXPOW    0x8B27          /* get transmit power (dBm) */
00165 
00166 /* Encoding stuff (scrambling, hardware security, WEP...) */
00167 #define SIOCSIWENCODE   0x8B2A          /* set encoding token & mode */
00168 #define SIOCGIWENCODE   0x8B2B          /* get encoding token & mode */
00169 /* Power saving stuff (power management, unicast and multicast) */
00170 #define SIOCSIWPOWER    0x8B2C          /* set Power Management settings */
00171 #define SIOCGIWPOWER    0x8B2D          /* get Power Management settings */
00172 
00173 /* ------------------------- IOCTL STUFF ------------------------- */
00174 
00175 /* The first and the last (range) */
00176 #define SIOCIWFIRST     0x8B00
00177 #define SIOCIWLAST      0x8B30
00178 
00179 /* Even : get (world access), odd : set (root access) */
00180 #define IW_IS_SET(cmd)  (!((cmd) & 0x1))
00181 #define IW_IS_GET(cmd)  ((cmd) & 0x1)
00182 
00183 /* ------------------------- PRIVATE INFO ------------------------- */
00184 /*
00185  * The following is used with SIOCGIWPRIV. It allow a driver to define
00186  * the interface (name, type of data) for its private ioctl.
00187  * Privates ioctl are SIOCDEVPRIVATE -> SIOCDEVPRIVATE + 0xF
00188  */
00189 
00190 #define IW_PRIV_TYPE_MASK       0x7000  /* Type of arguments */
00191 #define IW_PRIV_TYPE_NONE       0x0000
00192 #define IW_PRIV_TYPE_BYTE       0x1000  /* Char as number */
00193 #define IW_PRIV_TYPE_CHAR       0x2000  /* Char as character */
00194 #define IW_PRIV_TYPE_INT        0x4000  /* 32 bits int */
00195 #define IW_PRIV_TYPE_FLOAT      0x5000
00196 
00197 #define IW_PRIV_SIZE_FIXED      0x0800  /* Variable or fixed nuber of args */
00198 
00199 #define IW_PRIV_SIZE_MASK       0x07FF  /* Max number of those args */
00200 
00201 /*
00202  * Note : if the number of args is fixed and the size < 16 octets,
00203  * instead of passing a pointer we will put args in the iwreq struct...
00204  */
00205 
00206 /* ----------------------- OTHER CONSTANTS ----------------------- */
00207 
00208 /* Maximum frequencies in the range struct */
00209 #define IW_MAX_FREQUENCIES      16
00210 /* Note : if you have something like 80 frequencies,
00211  * don't increase this constant and don't fill the frequency list.
00212  * The user will be able to set by channel anyway... */
00213 
00214 /* Maximum bit rates in the range struct */
00215 #define IW_MAX_BITRATES         8
00216 
00217 /* Maximum tx powers in the range struct */
00218 #define IW_MAX_TXPOWER          8
00219 
00220 /* Maximum of address that you may set with SPY */
00221 #define IW_MAX_SPY              8
00222 
00223 /* Maximum of address that you may get in the
00224    list of access points in range */
00225 #define IW_MAX_AP               8
00226 
00227 /* Maximum size of the ESSID and NICKN strings */
00228 #define IW_ESSID_MAX_SIZE       32
00229 
00230 /* Modes of operation */
00231 #define IW_MODE_AUTO    0       /* Let the driver decides */
00232 #define IW_MODE_ADHOC   1       /* Single cell network */
00233 #define IW_MODE_INFRA   2       /* Multi cell network, roaming, ... */
00234 #define IW_MODE_MASTER  3       /* Synchronisation master or Access Point */
00235 #define IW_MODE_REPEAT  4       /* Wireless Repeater (forwarder) */
00236 #define IW_MODE_SECOND  5       /* Secondary master/repeater (backup) */
00237 
00238 /* Maximum number of size of encoding token available
00239  * they are listed in the range structure */
00240 #define IW_MAX_ENCODING_SIZES   8
00241 
00242 /* Maximum size of the encoding token in bytes */
00243 #define IW_ENCODING_TOKEN_MAX   32      /* 256 bits (for now) */
00244 
00245 /* Flags for encoding (along with the token) */
00246 #define IW_ENCODE_INDEX         0x00FF  /* Token index (if needed) */
00247 #define IW_ENCODE_FLAGS         0xFF00  /* Flags defined below */
00248 #define IW_ENCODE_MODE          0xF000  /* Modes defined below */
00249 #define IW_ENCODE_DISABLED      0x8000  /* Encoding disabled */
00250 #define IW_ENCODE_ENABLED       0x0000  /* Encoding enabled */
00251 #define IW_ENCODE_RESTRICTED    0x4000  /* Refuse non-encoded packets */
00252 #define IW_ENCODE_OPEN          0x2000  /* Accept non-encoded packets */
00253 #define IW_ENCODE_NOKEY         0x0800  /* Key is write only, so not present */
00254 
00255 /* Power management flags available (along with the value, if any) */
00256 #define IW_POWER_ON             0x0000  /* No details... */
00257 #define IW_POWER_TYPE           0xF000  /* Type of parameter */
00258 #define IW_POWER_PERIOD         0x1000  /* Value is a period/duration of  */
00259 #define IW_POWER_TIMEOUT        0x2000  /* Value is a timeout (to go asleep) */
00260 #define IW_POWER_MODE           0x0F00  /* Power Management mode */
00261 #define IW_POWER_UNICAST_R      0x0100  /* Receive only unicast messages */
00262 #define IW_POWER_MULTICAST_R    0x0200  /* Receive only multicast messages */
00263 #define IW_POWER_ALL_R          0x0300  /* Receive all messages though PM */
00264 #define IW_POWER_FORCE_S        0x0400  /* Force PM procedure for sending unicast */
00265 #define IW_POWER_REPEATER       0x0800  /* Repeat broadcast messages in PM period */
00266 #define IW_POWER_MODIFIER       0x000F  /* Modify a parameter */
00267 #define IW_POWER_MIN            0x0001  /* Value is a minimum  */
00268 #define IW_POWER_MAX            0x0002  /* Value is a maximum */
00269 #define IW_POWER_RELATIVE       0x0004  /* Value is not in seconds/ms/us */
00270 
00271 /* Transmit Power flags available */
00272 #define IW_TXPOW_DBM            0x0000  /* Value is in dBm */
00273 #define IW_TXPOW_MWATT          0x0001  /* Value is in mW */
00274 
00275 /****************************** TYPES ******************************/
00276 
00277 /* --------------------------- SUBTYPES --------------------------- */
00278 /*
00279  *      Generic format for most parameters that fit in an int
00280  */
00281 struct  iw_param
00282 {
00283   __s32         value;          /* The value of the parameter itself */
00284   __u8          fixed;          /* Hardware should not use auto select */
00285   __u8          disabled;       /* Disable the feature */
00286   __u16         flags;          /* Various specifc flags (if any) */
00287 };
00288 
00289 /*
00290  *      For all data larger than 16 octets, we need to use a
00291  *      pointer to memory alocated in user space.
00292  */
00293 struct  iw_point
00294 {
00295   caddr_t       pointer;        /* Pointer to the data  (in user space) */
00296   __u16         length;         /* number of fields or size in bytes */
00297   __u16         flags;          /* Optional params */
00298 };
00299 
00300 /*
00301  *      A frequency
00302  *      For numbers lower than 10^9, we encode the number in 'm' and
00303  *      set 'e' to 0
00304  *      For number greater than 10^9, we divide it by the lowest power
00305  *      of 10 to get 'm' lower than 10^9, with 'm'= f / (10^'e')...
00306  *      The power of 10 is in 'e', the result of the division is in 'm'.
00307  */
00308 struct  iw_freq
00309 {
00310         __u32           m;              /* Mantissa */
00311         __u16           e;              /* Exponent */
00312         __u8            i;              /* List index (when in range struct) */
00313 };
00314 
00315 /*
00316  *      Quality of the link
00317  */
00318 struct  iw_quality
00319 {
00320         __u8            qual;           /* link quality (%retries, SNR or better...) */
00321         __u8            level;          /* signal level */
00322         __u8            noise;          /* noise level */
00323         __u8            updated;        /* Flags to know if updated */
00324 };
00325 
00326 /*
00327  *      Packet discarded in the wireless adapter due to
00328  *      "wireless" specific problems...
00329  */
00330 struct  iw_discarded
00331 {
00332         __u32           nwid;           /* Wrong nwid */
00333         __u32           code;           /* Unable to code/decode */
00334         __u32           misc;           /* Others cases */
00335 };
00336 
00337 /* ------------------------ WIRELESS STATS ------------------------ */
00338 /*
00339  * Wireless statistics (used for /proc/net/wireless)
00340  */
00341 struct  iw_statistics
00342 {
00343         __u16           status;         /* Status
00344                                          * - device dependent for now */
00345 
00346         struct iw_quality       qual;           /* Quality of the link
00347                                                  * (instant/mean/max) */
00348         struct iw_discarded     discard;        /* Packet discarded counts */
00349 };
00350 
00351 /* ------------------------ IOCTL REQUEST ------------------------ */
00352 /*
00353  * The structure to exchange data for ioctl.
00354  * This structure is the same as 'struct ifreq', but (re)defined for
00355  * convenience...
00356  *
00357  * Note that it should fit on the same memory footprint !
00358  * You should check this when increasing the above structures (16 octets)
00359  * 16 octets = 128 bits. Warning, pointers might be 64 bits wide...
00360  */
00361 struct  iwreq 
00362 {
00363         union
00364         {
00365                 char    ifrn_name[IFNAMSIZ];    /* if name, e.g. "eth0" */
00366         } ifr_ifrn;
00367 
00368         /* Data part */
00369         union
00370         {
00371                 /* Config - generic */
00372                 char            name[IFNAMSIZ];
00373                 /* Name : used to verify the presence of  wireless extensions.
00374                  * Name of the protocol/provider... */
00375 
00376                 struct iw_point essid;  /* Extended network name */
00377                 struct iw_param nwid;   /* network id (or domain - the cell) */
00378                 struct iw_freq  freq;   /* frequency or channel :
00379                                          * 0-1000 = channel
00380                                          * > 1000 = frequency in Hz */
00381 
00382                 struct iw_param sens;           /* signal level threshold */
00383                 struct iw_param bitrate;        /* default bit rate */
00384                 struct iw_param txpower;        /* default transmit power */
00385                 struct iw_param rts;            /* RTS threshold threshold */
00386                 struct iw_param frag;           /* Fragmentation threshold */
00387                 __u32           mode;           /* Operation mode */
00388 
00389                 struct iw_point encoding;       /* Encoding stuff : tokens */
00390                 struct iw_param power;          /* PM duration/timeout */
00391 
00392                 struct sockaddr ap_addr;        /* Access point address */
00393 
00394                 struct iw_point data;           /* Other large parameters */
00395         }       u;
00396 };
00397 
00398 /* -------------------------- IOCTL DATA -------------------------- */
00399 /*
00400  *      For those ioctl which want to exchange mode data that what could
00401  *      fit in the above structure...
00402  */
00403 
00404 /*
00405  *      Range of parameters
00406  */
00407 
00408 struct  iw_range
00409 {
00410         /* Informative stuff (to choose between different interface) */
00411         __u32           throughput;     /* To give an idea... */
00412         /* In theory this value should be the maximum benchmarked
00413          * TCP/IP throughput, because with most of these devices the
00414          * bit rate is meaningless (overhead an co) to estimate how
00415          * fast the connection will go and pick the fastest one.
00416          * I suggest people to play with Netperf or any benchmark...
00417          */
00418 
00419         /* NWID (or domain id) */
00420         __u32           min_nwid;       /* Minimal NWID we are able to set */
00421         __u32           max_nwid;       /* Maximal NWID we are able to set */
00422 
00423         /* Frequency */
00424         __u16           num_channels;   /* Number of channels [0; num - 1] */
00425         __u8            num_frequency;  /* Number of entry in the list */
00426         struct iw_freq  freq[IW_MAX_FREQUENCIES];       /* list */
00427         /* Note : this frequency list doesn't need to fit channel numbers */
00428 
00429         /* signal level threshold range */
00430         __s32   sensitivity;
00431 
00432         /* Quality of link & SNR stuff */
00433         struct iw_quality       max_qual;       /* Quality of the link */
00434 
00435         /* Rates */
00436         __u8            num_bitrates;   /* Number of entries in the list */
00437         __s32           bitrate[IW_MAX_BITRATES];       /* list, in bps */
00438 
00439         /* RTS threshold */
00440         __s32           min_rts;        /* Minimal RTS threshold */
00441         __s32           max_rts;        /* Maximal RTS threshold */
00442 
00443         /* Frag threshold */
00444         __s32           min_frag;       /* Minimal frag threshold */
00445         __s32           max_frag;       /* Maximal frag threshold */
00446 
00447         /* Power Management duration & timeout */
00448         __s32           min_pmp;        /* Minimal PM period */
00449         __s32           max_pmp;        /* Maximal PM period */
00450         __s32           min_pmt;        /* Minimal PM timeout */
00451         __s32           max_pmt;        /* Maximal PM timeout */
00452         __u16           pmp_flags;      /* How to decode max/min PM period */
00453         __u16           pmt_flags;      /* How to decode max/min PM timeout */
00454         __u16           pm_capa;        /* What PM options are supported */
00455 
00456         /* Encoder stuff */
00457         __u16   encoding_size[IW_MAX_ENCODING_SIZES];   /* Different token sizes */
00458         __u8    num_encoding_sizes;     /* Number of entry in the list */
00459         __u8    max_encoding_tokens;    /* Max number of tokens */
00460 
00461         /* Transmit power */
00462         __u16           txpower_capa;   /* What options are supported */
00463         __u8            num_txpower;    /* Number of entries in the list */
00464         __s32           txpower[IW_MAX_TXPOWER];        /* list, in bps */
00465 };
00466 
00467 /*
00468  * Private ioctl interface information
00469  */
00470  
00471 struct  iw_priv_args
00472 {
00473         __u32           cmd;            /* Number of the ioctl to issue */
00474         __u16           set_args;       /* Type and number of args */
00475         __u16           get_args;       /* Type and number of args */
00476         char            name[IFNAMSIZ]; /* Name of the extension */
00477 };
00478 
00479 #endif  /* _LINUX_WIRELESS_H */