wireless-6.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. /*
  2. * This file define a set of standard wireless extensions
  3. *
  4. * Version : 7 23.4.99
  5. *
  6. * Authors : Jean Tourrilhes - HPLB - <jt@hplb.hpl.hp.com>
  7. */
  8. #ifndef _LINUX_WIRELESS_H
  9. #define _LINUX_WIRELESS_H
  10. /************************** DOCUMENTATION **************************/
  11. /*
  12. * Basically, the wireless extensions are for now a set of standard ioctl
  13. * call + /proc/net/wireless
  14. *
  15. * The entry /proc/net/wireless give statistics and information on the
  16. * driver.
  17. * This is better than having each driver having its entry because
  18. * its centralised and we may remove the driver module safely.
  19. *
  20. * Ioctl are used to configure the driver and issue commands. This is
  21. * better than command line options of insmod because we may want to
  22. * change dynamically (while the driver is running) some parameters.
  23. *
  24. * The ioctl mechanimsm are copied from standard devices ioctl.
  25. * We have the list of command plus a structure descibing the
  26. * data exchanged...
  27. * Note that to add these ioctl, I was obliged to modify :
  28. * net/core/dev.c (two place + add include)
  29. * net/ipv4/af_inet.c (one place + add include)
  30. *
  31. * /proc/net/wireless is a copy of /proc/net/dev.
  32. * We have a structure for data passed from the driver to /proc/net/wireless
  33. * Too add this, I've modified :
  34. * net/core/dev.c (two other places)
  35. * include/linux/netdevice.h (one place)
  36. * include/linux/proc_fs.h (one place)
  37. *
  38. * Do not add here things that are redundant with other mechanisms
  39. * (drivers init, ifconfig, /proc/net/dev, ...) and with are not
  40. * wireless specific.
  41. *
  42. * These wireless extensions are not magic : each driver has to provide
  43. * support for them...
  44. *
  45. * IMPORTANT NOTE : As everything in the kernel, this is very much a
  46. * work in progress. Contact me if you have ideas of improvements...
  47. */
  48. /***************************** INCLUDES *****************************/
  49. #if 0
  50. #include <linux/types.h> /* for "caddr_t" et al */
  51. #include <linux/socket.h> /* for "struct sockaddr" et al */
  52. #include <linux/if.h> /* for IFNAMSIZ and co... */
  53. #endif
  54. /**************************** CONSTANTS ****************************/
  55. /* --------------------------- VERSION --------------------------- */
  56. /*
  57. * This constant is used to know the availability of the wireless
  58. * extensions and to know which version of wireless extensions it is
  59. * (there is some stuff that will be added in the future...)
  60. * I just plan to increment with each new version.
  61. */
  62. #define WIRELESS_EXT 6
  63. /*
  64. * Changes :
  65. *
  66. * V2 to V3
  67. * --------
  68. * Alan Cox start some incompatibles changes. I've integrated a bit more.
  69. * - Encryption renamed to Encode to avoid US regulation problems
  70. * - Frequency changed from float to struct to avoid problems on old 386
  71. *
  72. * V3 to V4
  73. * --------
  74. * - Add sensitivity
  75. *
  76. * V4 to V5
  77. * --------
  78. * - Missing encoding definitions in range
  79. * - Access points stuff
  80. *
  81. * V5 to V6
  82. * --------
  83. * - 802.11 support (ESSID ioctls)
  84. *
  85. * V6 to V7
  86. * --------
  87. * - define IW_ESSID_MAX_SIZE and IW_MAX_AP
  88. */
  89. /* -------------------------- IOCTL LIST -------------------------- */
  90. /* Basic operations */
  91. #define SIOCSIWNAME 0x8B00 /* Unused ??? */
  92. #define SIOCGIWNAME 0x8B01 /* get name */
  93. #define SIOCSIWNWID 0x8B02 /* set network id */
  94. #define SIOCGIWNWID 0x8B03 /* get network id */
  95. #define SIOCSIWFREQ 0x8B04 /* set channel/frequency */
  96. #define SIOCGIWFREQ 0x8B05 /* get channel/frequency */
  97. #define SIOCSIWENCODE 0x8B06 /* set encoding info */
  98. #define SIOCGIWENCODE 0x8B07 /* get encoding info */
  99. #define SIOCSIWSENS 0x8B08 /* set sensitivity */
  100. #define SIOCGIWSENS 0x8B09 /* get sensitivity */
  101. /* Informative stuff */
  102. #define SIOCSIWRANGE 0x8B0A /* Unused ??? */
  103. #define SIOCGIWRANGE 0x8B0B /* Get range of parameters */
  104. #define SIOCSIWPRIV 0x8B0C /* Unused ??? */
  105. #define SIOCGIWPRIV 0x8B0D /* get private ioctl interface info */
  106. /* Mobile IP support */
  107. #define SIOCSIWSPY 0x8B10 /* set spy addresses */
  108. #define SIOCGIWSPY 0x8B11 /* get spy info (quality of link) */
  109. /* Access Point manipulation */
  110. #define SIOCSIWAP 0x8B14 /* set access point hardware addresses */
  111. #define SIOCGIWAP 0x8B15 /* get access point hardware addresses */
  112. #define SIOCGIWAPLIST 0x8B17 /* get list of access point in range */
  113. /* 802.11 specific support */
  114. #define SIOCSIWESSID 0x8B1A /* set ESSID (network name) */
  115. #define SIOCGIWESSID 0x8B1B /* get ESSID */
  116. /* As the ESSID is a string up to 32 bytes long, it doesn't fit within the
  117. * 'iwreq' structure, so we need to use the 'data' member to point to a
  118. * string in user space, like it is done for RANGE...
  119. * The "flags" member indicate if the ESSID is active or not.
  120. */
  121. /* ------------------------- IOCTL STUFF ------------------------- */
  122. /* The first and the last (range) */
  123. #define SIOCIWFIRST 0x8B00
  124. #define SIOCIWLAST 0x8B1B
  125. /* Even : get (world access), odd : set (root access) */
  126. #define IW_IS_SET(cmd) (!((cmd) & 0x1))
  127. #define IW_IS_GET(cmd) ((cmd) & 0x1)
  128. /* ------------------------- PRIVATE INFO ------------------------- */
  129. /*
  130. * The following is used with SIOCGIWPRIV. It allow a driver to define
  131. * the interface (name, type of data) for its private ioctl.
  132. * Privates ioctl are SIOCDEVPRIVATE -> SIOCDEVPRIVATE + 0xF
  133. */
  134. #define IW_PRIV_TYPE_MASK 0x7000 /* Type of arguments */
  135. #define IW_PRIV_TYPE_NONE 0x0000
  136. #define IW_PRIV_TYPE_BYTE 0x1000 /* Char as number */
  137. #define IW_PRIV_TYPE_CHAR 0x2000 /* Char as character */
  138. #define IW_PRIV_TYPE_INT 0x4000 /* 32 bits int */
  139. #define IW_PRIV_TYPE_FLOAT 0x5000
  140. #define IW_PRIV_SIZE_FIXED 0x0800 /* Variable or fixed nuber of args */
  141. #define IW_PRIV_SIZE_MASK 0x07FF /* Max number of those args */
  142. /*
  143. * Note : if the number of args is fixed and the size < 16 octets,
  144. * instead of passing a pointer we will put args in the iwreq struct...
  145. */
  146. /* ----------------------- OTHER CONSTANTS ----------------------- */
  147. /* Maximum frequencies in the range struct */
  148. #define IW_MAX_FREQUENCIES 16
  149. /* Note : if you have something like 80 frequencies,
  150. * don't increase this constant and don't fill the frequency list.
  151. * The user will be able to set by channel anyway... */
  152. /* Maximum of address that you may set with SPY */
  153. #define IW_MAX_SPY 8
  154. /* Maximum of address that you may get in the
  155. list of access points in range */
  156. #define IW_MAX_AP 8
  157. /* Maximum size of the ESSID string */
  158. #define IW_ESSID_MAX_SIZE 32
  159. /****************************** TYPES ******************************/
  160. /* --------------------------- SUBTYPES --------------------------- */
  161. /*
  162. * A frequency
  163. * For numbers lower than 10^9, we encode the number in 'mant' and
  164. * set 'exp' to 0
  165. * For number greater than 10^9, we divide it by a power of 10.
  166. * The power of 10 is in 'exp', the result is in 'mant'.
  167. */
  168. struct iw_freq
  169. {
  170. __u32 m; /* Mantissa */
  171. __u16 e; /* Exponent */
  172. };
  173. /*
  174. * Quality of the link
  175. */
  176. struct iw_quality
  177. {
  178. __u8 qual; /* link quality (SNR or better...) */
  179. __u8 level; /* signal level */
  180. __u8 noise; /* noise level */
  181. __u8 updated; /* Flags to know if updated */
  182. };
  183. /*
  184. * Packet discarded in the wireless adapter due to
  185. * "wireless" specific problems...
  186. */
  187. struct iw_discarded
  188. {
  189. __u32 nwid; /* Wrong nwid */
  190. __u32 code; /* Unable to code/decode */
  191. __u32 misc; /* Others cases */
  192. };
  193. /*
  194. * Encoding information (setting and so on)
  195. * Encoding might be hardware encryption, scrambing or others
  196. */
  197. struct iw_encoding
  198. {
  199. __u8 method; /* Algorithm number / key used */
  200. __u64 code; /* Data/key used for algorithm */
  201. };
  202. /* ------------------------ WIRELESS STATS ------------------------ */
  203. /*
  204. * Wireless statistics (used for /proc/net/wireless)
  205. */
  206. struct iw_statistics
  207. {
  208. __u8 status; /* Status
  209. * - device dependent for now */
  210. struct iw_quality qual; /* Quality of the link
  211. * (instant/mean/max) */
  212. struct iw_discarded discard; /* Packet discarded counts */
  213. };
  214. /* ------------------------ IOCTL REQUEST ------------------------ */
  215. /*
  216. * The structure to exchange data for ioctl.
  217. * This structure is the same as 'struct ifreq', but (re)defined for
  218. * convenience...
  219. *
  220. * Note that it should fit on the same memory footprint !
  221. * You should check this when increasing the above structures (16 octets)
  222. * 16 octets = 128 bits. Warning, pointers might be 64 bits wide...
  223. */
  224. struct iwreq
  225. {
  226. union
  227. {
  228. char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */
  229. } ifr_ifrn;
  230. /* Data part */
  231. union
  232. {
  233. /* Config - generic */
  234. char name[IFNAMSIZ];
  235. /* Name : used to verify the presence of wireless extensions.
  236. * Name of the protocol/provider... */
  237. struct /* network id (or domain) : used to to */
  238. { /* create logical channels on the air */
  239. __u32 nwid; /* value */
  240. __u8 on; /* active/unactive nwid */
  241. } nwid;
  242. struct iw_freq freq; /* frequency or channel :
  243. * 0-1000 = channel
  244. * > 1000 = frequency in Hz */
  245. struct iw_encoding encoding; /* Encoding stuff */
  246. __u32 sensitivity; /* signal level threshold */
  247. struct sockaddr ap_addr; /* Access point address */
  248. struct /* For all data bigger than 16 octets */
  249. {
  250. caddr_t pointer; /* Pointer to the data
  251. * (in user space) */
  252. __u16 length; /* fields or byte size */
  253. __u16 flags; /* Optional params */
  254. } data;
  255. } u;
  256. };
  257. /* -------------------------- IOCTL DATA -------------------------- */
  258. /*
  259. * For those ioctl which want to exchange mode data that what could
  260. * fit in the above structure...
  261. */
  262. /*
  263. * Range of parameters
  264. */
  265. struct iw_range
  266. {
  267. /* Informative stuff (to choose between different interface) */
  268. __u32 throughput; /* To give an idea... */
  269. /* NWID (or domain id) */
  270. __u32 min_nwid; /* Minimal NWID we are able to set */
  271. __u32 max_nwid; /* Maximal NWID we are able to set */
  272. /* Frequency */
  273. __u16 num_channels; /* Number of channels [0; num - 1] */
  274. __u8 num_frequency; /* Number of entry in the list */
  275. struct iw_freq freq[IW_MAX_FREQUENCIES]; /* list */
  276. /* Note : this frequency list doesn't need to fit channel numbers */
  277. /* signal level threshold range */
  278. __u32 sensitivity;
  279. /* Quality of link & SNR stuff */
  280. struct iw_quality max_qual; /* Quality of the link */
  281. /* Encoder stuff */
  282. struct iw_encoding max_encoding; /* Encoding max range */
  283. };
  284. /*
  285. * Private ioctl interface information
  286. */
  287. struct iw_priv_args
  288. {
  289. __u32 cmd; /* Number of the ioctl to issue */
  290. __u16 set_args; /* Type and number of args */
  291. __u16 get_args; /* Type and number of args */
  292. char name[IFNAMSIZ]; /* Name of the extension */
  293. };
  294. #endif /* _LINUX_WIRELESS_H */