1 /******************************************************************************
2   *
3   * This module is a confidential and proprietary property of RealTek and
4   * possession or use of this module requires written permission of RealTek.
5   *
6   * Copyright(c) 2016, Realtek Semiconductor Corporation. All rights reserved.
7   *
8 ******************************************************************************/
9 
10 #ifndef _LINUX_WIRELESS_H
11 #define _LINUX_WIRELESS_H
12 
13 /************************** DOCUMENTATION **************************/
14 /*
15  * Initial APIs (1996 -> onward) :
16  * -----------------------------
17  * Basically, the wireless extensions are for now a set of standard ioctl
18  * call + /proc/net/wireless
19  *
20  * The entry /proc/net/wireless give statistics and information on the
21  * driver.
22  * This is better than having each driver having its entry because
23  * its centralised and we may remove the driver module safely.
24  *
25  * Ioctl are used to configure the driver and issue commands.  This is
26  * better than command line options of insmod because we may want to
27  * change dynamically (while the driver is running) some parameters.
28  *
29  * The ioctl mechanimsm are copied from standard devices ioctl.
30  * We have the list of command plus a structure descibing the
31  * data exchanged...
32  * Note that to add these ioctl, I was obliged to modify :
33  *	# net/core/dev.c (two place + add include)
34  *	# net/ipv4/af_inet.c (one place + add include)
35  *
36  * /proc/net/wireless is a copy of /proc/net/dev.
37  * We have a structure for data passed from the driver to /proc/net/wireless
38  * Too add this, I've modified :
39  *	# net/core/dev.c (two other places)
40  *	# include/linux/netdevice.h (one place)
41  *	# include/linux/proc_fs.h (one place)
42  *
43  * New driver API (2002 -> onward) :
44  * -------------------------------
45  * This file is only concerned with the user space API and common definitions.
46  * The new driver API is defined and documented in :
47  *	# include/net/iw_handler.h
48  *
49  * Note as well that /proc/net/wireless implementation has now moved in :
50  *	# net/core/wireless.c
51  *
52  * Wireless Events (2002 -> onward) :
53  * --------------------------------
54  * Events are defined at the end of this file, and implemented in :
55  *	# net/core/wireless.c
56  *
57  * Other comments :
58  * --------------
59  * Do not add here things that are redundant with other mechanisms
60  * (drivers init, ifconfig, /proc/net/dev, ...) and with are not
61  * wireless specific.
62  *
63  * These wireless extensions are not magic : each driver has to provide
64  * support for them...
65  *
66  * IMPORTANT NOTE : As everything in the kernel, this is very much a
67  * work in progress. Contact me if you have ideas of improvements...
68  */
69 
70 /***************************** INCLUDES *****************************/
71 
72 /* This header is used in user-space, therefore need to be sanitised
73  * for that purpose. Those includes are usually not compatible with glibc.
74  * To know which includes to use in user-space, check iwlib.h. */
75 #ifdef __KERNEL__
76 #include <linux/types.h>		/* for "caddr_t" et al		*/
77 #include <linux/socket.h>		/* for "struct sockaddr" et al	*/
78 #include <linux/if.h>			/* for IFNAMSIZ and co... */
79 #endif	/* __KERNEL__ */
80 
81 //#include <sockets.h>
82 #define IFNAMSIZ	16
83 #define	ARPHRD_ETHER	1	/* ethernet hardware format */
84 
85 /***************************** VERSION *****************************/
86 /*
87  * This constant is used to know the availability of the wireless
88  * extensions and to know which version of wireless extensions it is
89  * (there is some stuff that will be added in the future...)
90  * I just plan to increment with each new version.
91  */
92 #define WIRELESS_EXT	22
93 
94 /*
95  * Changes :
96  *
97  * V2 to V3
98  * --------
99  *	Alan Cox start some incompatibles changes. I've integrated a bit more.
100  *	- Encryption renamed to Encode to avoid US regulation problems
101  *	- Frequency changed from float to struct to avoid problems on old 386
102  *
103  * V3 to V4
104  * --------
105  *	- Add sensitivity
106  *
107  * V4 to V5
108  * --------
109  *	- Missing encoding definitions in range
110  *	- Access points stuff
111  *
112  * V5 to V6
113  * --------
114  *	- 802.11 support (ESSID ioctls)
115  *
116  * V6 to V7
117  * --------
118  *	- define IW_ESSID_MAX_SIZE and IW_MAX_AP
119  *
120  * V7 to V8
121  * --------
122  *	- Changed my e-mail address
123  *	- More 802.11 support (nickname, rate, rts, frag)
124  *	- List index in frequencies
125  *
126  * V8 to V9
127  * --------
128  *	- Support for 'mode of operation' (ad-hoc, managed...)
129  *	- Support for unicast and multicast power saving
130  *	- Change encoding to support larger tokens (>64 bits)
131  *	- Updated iw_params (disable, flags) and use it for NWID
132  *	- Extracted iw_point from iwreq for clarity
133  *
134  * V9 to V10
135  * ---------
136  *	- Add PM capability to range structure
137  *	- Add PM modifier : MAX/MIN/RELATIVE
138  *	- Add encoding option : IW_ENCODE_NOKEY
139  *	- Add TxPower ioctls (work like TxRate)
140  *
141  * V10 to V11
142  * ----------
143  *	- Add WE version in range (help backward/forward compatibility)
144  *	- Add retry ioctls (work like PM)
145  *
146  * V11 to V12
147  * ----------
148  *	- Add SIOCSIWSTATS to get /proc/net/wireless programatically
149  *	- Add DEV PRIVATE IOCTL to avoid collisions in SIOCDEVPRIVATE space
150  *	- Add new statistics (frag, retry, beacon)
151  *	- Add average quality (for user space calibration)
152  *
153  * V12 to V13
154  * ----------
155  *	- Document creation of new driver API.
156  *	- Extract union iwreq_data from struct iwreq (for new driver API).
157  *	- Rename SIOCSIWNAME as SIOCSIWCOMMIT
158  *
159  * V13 to V14
160  * ----------
161  *	- Wireless Events support : define struct iw_event
162  *	- Define additional specific event numbers
163  *	- Add "addr" and "param" fields in union iwreq_data
164  *	- AP scanning stuff (SIOCSIWSCAN and friends)
165  *
166  * V14 to V15
167  * ----------
168  *	- Add IW_PRIV_TYPE_ADDR for struct sockaddr private arg
169  *	- Make struct iw_freq signed (both m & e), add explicit padding
170  *	- Add IWEVCUSTOM for driver specific event/scanning token
171  *	- Add IW_MAX_GET_SPY for driver returning a lot of addresses
172  *	- Add IW_TXPOW_RANGE for range of Tx Powers
173  *	- Add IWEVREGISTERED & IWEVEXPIRED events for Access Points
174  *	- Add IW_MODE_MONITOR for passive monitor
175  *
176  * V15 to V16
177  * ----------
178  *	- Increase the number of bitrates in iw_range to 32 (for 802.11g)
179  *	- Increase the number of frequencies in iw_range to 32 (for 802.11b+a)
180  *	- Reshuffle struct iw_range for increases, add filler
181  *	- Increase IW_MAX_AP to 64 for driver returning a lot of addresses
182  *	- Remove IW_MAX_GET_SPY because conflict with enhanced spy support
183  *	- Add SIOCSIWTHRSPY/SIOCGIWTHRSPY and "struct iw_thrspy"
184  *	- Add IW_ENCODE_TEMP and iw_range->encoding_login_index
185  *
186  * V16 to V17
187  * ----------
188  *	- Add flags to frequency -> auto/fixed
189  *	- Document (struct iw_quality *)->updated, add new flags (INVALID)
190  *	- Wireless Event capability in struct iw_range
191  *	- Add support for relative TxPower (yick !)
192  *
193  * V17 to V18 (From Jouni Malinen <jkmaline@cc.hut.fi>)
194  * ----------
195  *	- Add support for WPA/WPA2
196  *	- Add extended encoding configuration (SIOCSIWENCODEEXT and
197  *	  SIOCGIWENCODEEXT)
198  *	- Add SIOCSIWGENIE/SIOCGIWGENIE
199  *	- Add SIOCSIWMLME
200  *	- Add SIOCSIWPMKSA
201  *	- Add struct iw_range bit field for supported encoding capabilities
202  *	- Add optional scan request parameters for SIOCSIWSCAN
203  *	- Add SIOCSIWAUTH/SIOCGIWAUTH for setting authentication and WPA
204  *	  related parameters (extensible up to 4096 parameter values)
205  *	- Add wireless events: IWEVGENIE, IWEVMICHAELMICFAILURE,
206  *	  IWEVASSOCREQIE, IWEVASSOCRESPIE, IWEVPMKIDCAND
207  *
208  * V18 to V19
209  * ----------
210  *	- Remove (struct iw_point *)->pointer from events and streams
211  *	- Remove header includes to help user space
212  *	- Increase IW_ENCODING_TOKEN_MAX from 32 to 64
213  *	- Add IW_QUAL_ALL_UPDATED and IW_QUAL_ALL_INVALID macros
214  *	- Add explicit flag to tell stats are in dBm : IW_QUAL_DBM
215  *	- Add IW_IOCTL_IDX() and IW_EVENT_IDX() macros
216  *
217  * V19 to V20
218  * ----------
219  *	- RtNetlink requests support (SET/GET)
220  *
221  * V20 to V21
222  * ----------
223  *	- Remove (struct net_device *)->get_wireless_stats()
224  *	- Change length in ESSID and NICK to strlen() instead of strlen()+1
225  *	- Add IW_RETRY_SHORT/IW_RETRY_LONG retry modifiers
226  *	- Power/Retry relative values no longer * 100000
227  *	- Add explicit flag to tell stats are in 802.11k RCPI : IW_QUAL_RCPI
228  *
229  * V21 to V22
230  * ----------
231  *	- Prevent leaking of kernel space in stream on 64 bits.
232  */
233 
234 /**************************** CONSTANTS ****************************/
235 typedef unsigned char __u8;
236 typedef char __s8;
237 typedef unsigned short __u16;
238 typedef short __s16;
239 typedef unsigned int __u32;
240 typedef int __s32;
241 typedef	unsigned long long __u64;
242 typedef	long long __i64;
243 
244 #define	E2BIG		 7	/* Argument list too long */
245 
246 #define ETH_ALEN	6		/* Octets in one ethernet addr	 */
247 
248 /* Device private ioctl calls */
249 
250 /*
251  *	These 16 ioctls are available to devices via the do_ioctl() device
252  *	vector. Each device should include this file and redefine these names
253  *	as their own. Because these are device dependent it is a good idea
254  *	_NOT_ to issue them to random objects and hope.
255  *
256  *	THESE IOCTLS ARE _DEPRECATED_ AND WILL DISAPPEAR IN 2.5.X -DaveM
257  */
258 
259 #define SIOCDEVPRIVATE	0x89F0	/* to 89FF */
260 
261 /*
262  *	These 16 ioctl calls are protocol private
263  */
264 
265 #define SIOCPROTOPRIVATE 0x89E0 /* to 89EF */
266 
267 /* -------------------------- IOCTL LIST -------------------------- */
268 
269 /* Wireless Identification */
270 #define SIOCSIWCOMMIT	0x8B00		/* Commit pending changes to driver */
271 #define SIOCGIWNAME	0x8B01		/* get name == wireless protocol */
272 /* SIOCGIWNAME is used to verify the presence of Wireless Extensions.
273  * Common values : "IEEE 802.11-DS", "IEEE 802.11-FH", "IEEE 802.11b"...
274  * Don't put the name of your driver there, it's useless. */
275 
276 /* Basic operations */
277 #define SIOCSIWNWID	0x8B02		/* set network id (pre-802.11) */
278 #define SIOCGIWNWID	0x8B03		/* get network id (the cell) */
279 #define SIOCSIWFREQ	0x8B04		/* set channel/frequency (Hz) */
280 #define SIOCGIWFREQ	0x8B05		/* get channel/frequency (Hz) */
281 #define SIOCSIWMODE	0x8B06		/* set operation mode */
282 #define SIOCGIWMODE	0x8B07		/* get operation mode */
283 #define SIOCSIWSENS	0x8B08		/* set sensitivity (dBm) */
284 #define SIOCGIWSENS	0x8B09		/* get sensitivity (dBm) */
285 
286 /* Informative stuff */
287 #define SIOCSIWRANGE	0x8B0A		/* Unused */
288 #define SIOCGIWRANGE	0x8B0B		/* Get range of parameters */
289 #define SIOCSIWPRIV	0x8B0C		/* Unused */
290 #define SIOCGIWPRIV	0x8B0D		/* get private ioctl interface info */
291 #define SIOCSIWSTATS	0x8B0E		/* Unused */
292 #define SIOCGIWSTATS	0x8B0F		/* Get /proc/net/wireless stats */
293 /* SIOCGIWSTATS is strictly used between user space and the kernel, and
294  * is never passed to the driver (i.e. the driver will never see it). */
295 
296 /* Spy support (statistics per MAC address - used for Mobile IP support) */
297 #define SIOCSIWSPY	0x8B10		/* set spy addresses */
298 #define SIOCGIWSPY	0x8B11		/* get spy info (quality of link) */
299 #define SIOCSIWTHRSPY	0x8B12		/* set spy threshold (spy event) */
300 #define SIOCGIWTHRSPY	0x8B13		/* get spy threshold */
301 
302 /* Access Point manipulation */
303 #define SIOCSIWAP	0x8B14		/* set access point MAC addresses */
304 #define SIOCGIWAP	0x8B15		/* get access point MAC addresses */
305 #define SIOCGIWAPLIST	0x8B17		/* Deprecated in favor of scanning */
306 #define SIOCSIWSCAN	0x8B18		/* trigger scanning (list cells) */
307 #define SIOCGIWSCAN	0x8B19		/* get scanning results */
308 
309 /* 802.11 specific support */
310 #define SIOCSIWESSID	0x8B1A		/* set ESSID (network name) */
311 #define SIOCGIWESSID	0x8B1B		/* get ESSID */
312 #define SIOCSIWNICKN	0x8B1C		/* set node name/nickname */
313 #define SIOCGIWNICKN	0x8B1D		/* get node name/nickname */
314 /* As the ESSID and NICKN are strings up to 32 bytes long, it doesn't fit
315  * within the 'iwreq' structure, so we need to use the 'data' member to
316  * point to a string in user space, like it is done for RANGE... */
317 
318 /* Other parameters useful in 802.11 and some other devices */
319 #define SIOCSIWRATE	0x8B20		/* set default bit rate (bps) */
320 #define SIOCGIWRATE	0x8B21		/* get default bit rate (bps) */
321 #define SIOCSIWRTS	0x8B22		/* set RTS/CTS threshold (bytes) */
322 #define SIOCGIWRTS	0x8B23		/* get RTS/CTS threshold (bytes) */
323 #define SIOCSIWFRAG	0x8B24		/* set fragmentation thr (bytes) */
324 #define SIOCGIWFRAG	0x8B25		/* get fragmentation thr (bytes) */
325 #define SIOCSIWTXPOW	0x8B26		/* set transmit power (dBm) */
326 #define SIOCGIWTXPOW	0x8B27		/* get transmit power (dBm) */
327 #define SIOCSIWRETRY	0x8B28		/* set retry limits and lifetime */
328 #define SIOCGIWRETRY	0x8B29		/* get retry limits and lifetime */
329 
330 /* Encoding stuff (scrambling, hardware security, WEP...) */
331 #define SIOCSIWENCODE	0x8B2A		/* set encoding token & mode */
332 #define SIOCGIWENCODE	0x8B2B		/* get encoding token & mode */
333 /* Power saving stuff (power management, unicast and multicast) */
334 #define SIOCSIWPOWER	0x8B2C		/* set Power Management settings */
335 #define SIOCGIWPOWER	0x8B2D		/* get Power Management settings */
336 /* Modulation bitmask */
337 #define SIOCSIWMODUL	0x8B2E		/* set Modulations settings */
338 #define SIOCGIWMODUL	0x8B2F		/* get Modulations settings */
339 
340 /* WPA : Generic IEEE 802.11 informatiom element (e.g., for WPA/RSN/WMM).
341  * This ioctl uses struct iw_point and data buffer that includes IE id and len
342  * fields. More than one IE may be included in the request. Setting the generic
343  * IE to empty buffer (len=0) removes the generic IE from the driver. Drivers
344  * are allowed to generate their own WPA/RSN IEs, but in these cases, drivers
345  * are required to report the used IE as a wireless event, e.g., when
346  * associating with an AP. */
347 #define SIOCSIWGENIE	0x8B30		/* set generic IE */
348 #define SIOCGIWGENIE	0x8B31		/* get generic IE */
349 
350 /* WPA : IEEE 802.11 MLME requests */
351 #define SIOCSIWMLME	0x8B16		/* request MLME operation; uses
352 					 * struct iw_mlme */
353 /* WPA : Authentication mode parameters */
354 #define SIOCSIWAUTH	0x8B32		/* set authentication mode params */
355 #define SIOCGIWAUTH	0x8B33		/* get authentication mode params */
356 
357 /* WPA : Extended version of encoding configuration */
358 #define SIOCSIWENCODEEXT 0x8B34		/* set encoding token & mode */
359 #define SIOCGIWENCODEEXT 0x8B35		/* get encoding token & mode */
360 
361 /* WPA2/WPA3 : Set PMKSA Cache Management Enable */
362 #define SIOCSIWPMKSA	0x8B36		/* PMKSA cache operation */
363 
364 /* Send Mgnt Frame or Action Frame */
365 #define SIOCSIWMGNTSEND	0x8B37		/* Send Mgnt Frame or Action Frame */
366 
367 /* Send WPS EAPOL Frame */
368 #define SIOCSIWEAPOLSEND	0x8B38		/* Send WPS EAPOL Frame */
369 
370 /* Set MailBox Info */
371 #define SIOCSIMAILBOX	0x8B39		/* Set MailBox Info */
372 
373 /* Set Management Frame Protection Support */
374 #define SIOCSIWMFP	0x8B3A		/* Set Management Frame Protection Support */
375 
376 /* Set Finite cyclic groups id for SAE  */
377 #define SIOCSIWGRPID	0x8B3B		/* Set Finite cyclic groups id for SAE  */
378 
379 /* Get rssiBCN */
380 #define SIOCGIWBCNSENS	0x8B40 		/* Get beacon average rssi */
381 
382 /* -------------------- DEV PRIVATE IOCTL LIST -------------------- */
383 
384 /* These 32 ioctl are wireless device private, for 16 commands.
385  * Each driver is free to use them for whatever purpose it chooses,
386  * however the driver *must* export the description of those ioctls
387  * with SIOCGIWPRIV and *must* use arguments as defined below.
388  * If you don't follow those rules, DaveM is going to hate you (reason :
389  * it make mixed 32/64bit operation impossible).
390  */
391 #define SIOCIWFIRSTPRIV	0x8BE0
392 #define SIOCIWLASTPRIV	0x8BFF
393 
394 #define SIOCSIWPRIVADAPTIVITY	0x8BFB
395 #define SIOCGIWPRIVPASSPHRASE	0x8BFC
396 #define SIOCSIWPRIVCOUNTRY		0x8BFD
397 #define SIOCSIWPRIVAPESSID		0x8BFE
398 #define SIOCSIWPRIVPASSPHRASE	0x8BFF
399 /* Previously, we were using SIOCDEVPRIVATE, but we now have our
400  * separate range because of collisions with other tools such as
401  * 'mii-tool'.
402  * We now have 32 commands, so a bit more space ;-).
403  * Also, all 'even' commands are only usable by root and don't return the
404  * content of ifr/iwr to user (but you are not obliged to use the set/get
405  * convention, just use every other two command). More details in iwpriv.c.
406  * And I repeat : you are not forced to use them with iwpriv, but you
407  * must be compliant with it.
408  */
409 
410 /* ------------------------- IOCTL STUFF ------------------------- */
411 
412 /* The first and the last (range) */
413 #define SIOCIWFIRST	0x8B00
414 #define SIOCIWLAST	SIOCIWLASTPRIV		/* 0x8BFF */
415 #define IW_IOCTL_IDX(cmd)	((cmd) - SIOCIWFIRST)
416 
417 /* Odd : get (world access), even : set (root access) */
418 #define IW_IS_SET(cmd)	(!((cmd) & 0x1))
419 #define IW_IS_GET(cmd)	((cmd) & 0x1)
420 
421 /* ----------------------- WIRELESS EVENTS ----------------------- */
422 /* Those are *NOT* ioctls, do not issue request on them !!! */
423 /* Most events use the same identifier as ioctl requests */
424 
425 #define IWEVTXDROP	0x8C00		/* Packet dropped to excessive retry */
426 #define IWEVQUAL	0x8C01		/* Quality part of statistics (scan) */
427 #define IWEVCUSTOM	0x8C02		/* Driver specific ascii string */
428 #define IWEVREGISTERED	0x8C03		/* Discovered a new node (AP mode) */
429 #define IWEVEXPIRED	0x8C04		/* Expired a node (AP mode) */
430 #define IWEVGENIE	0x8C05		/* Generic IE (WPA, RSN, WMM, ..)
431 					 * (scan results); This includes id and
432 					 * length fields. One IWEVGENIE may
433 					 * contain more than one IE. Scan
434 					 * results may contain one or more
435 					 * IWEVGENIE events. */
436 #define IWEVMICHAELMICFAILURE 0x8C06	/* Michael MIC failure
437 					 * (struct iw_michaelmicfailure)
438 					 */
439 #define IWEVASSOCREQIE	0x8C07		/* IEs used in (Re)Association Request.
440 					 * The data includes id and length
441 					 * fields and may contain more than one
442 					 * IE. This event is required in
443 					 * Managed mode if the driver
444 					 * generates its own WPA/RSN IE. This
445 					 * should be sent just before
446 					 * IWEVREGISTERED event for the
447 					 * association. */
448 #define IWEVASSOCRESPIE	0x8C08		/* IEs used in (Re)Association
449 					 * Response. The data includes id and
450 					 * length fields and may contain more
451 					 * than one IE. This may be sent
452 					 * between IWEVASSOCREQIE and
453 					 * IWEVREGISTERED events for the
454 					 * association. */
455 #define IWEVPMKIDCAND	0x8C09		/* PMKID candidate for RSN
456 					 * pre-authentication
457 					 * (struct iw_pmkid_cand) */
458 
459 #define IWEVFIRST	0x8C00
460 #define IW_EVENT_IDX(cmd)	((cmd) - IWEVFIRST)
461 
462 /* Indicate Mgnt Frame and Action Frame to uplayer*/
463 #define IWEVMGNTRECV	0x8C10		/* Indicate Mgnt Frame to uplayer */
464 
465 /* ------------------------- PRIVATE INFO ------------------------- */
466 /*
467  * The following is used with SIOCGIWPRIV. It allow a driver to define
468  * the interface (name, type of data) for its private ioctl.
469  * Privates ioctl are SIOCIWFIRSTPRIV -> SIOCIWLASTPRIV
470  */
471 
472 #define IW_PRIV_TYPE_MASK	0x7000	/* Type of arguments */
473 #define IW_PRIV_TYPE_NONE	0x0000
474 #define IW_PRIV_TYPE_BYTE	0x1000	/* Char as number */
475 #define IW_PRIV_TYPE_CHAR	0x2000	/* Char as character */
476 #define IW_PRIV_TYPE_INT	0x4000	/* 32 bits int */
477 #define IW_PRIV_TYPE_FLOAT	0x5000	/* struct iw_freq */
478 #define IW_PRIV_TYPE_ADDR	0x6000	/* struct sockaddr */
479 
480 #define IW_PRIV_SIZE_FIXED	0x0800	/* Variable or fixed number of args */
481 
482 #define IW_PRIV_SIZE_MASK	0x07FF	/* Max number of those args */
483 
484 /*
485  * Note : if the number of args is fixed and the size < 16 octets,
486  * instead of passing a pointer we will put args in the iwreq struct...
487  */
488 
489 /* ----------------------- OTHER CONSTANTS ----------------------- */
490 
491 /* Maximum frequencies in the range struct */
492 #define IW_MAX_FREQUENCIES	32
493 /* Note : if you have something like 80 frequencies,
494  * don't increase this constant and don't fill the frequency list.
495  * The user will be able to set by channel anyway... */
496 
497 /* Maximum bit rates in the range struct */
498 #define IW_MAX_BITRATES		32
499 
500 /* Maximum tx powers in the range struct */
501 #define IW_MAX_TXPOWER		8
502 /* Note : if you more than 8 TXPowers, just set the max and min or
503  * a few of them in the struct iw_range. */
504 
505 /* Maximum of address that you may set with SPY */
506 #define IW_MAX_SPY		8
507 
508 /* Maximum of address that you may get in the
509    list of access points in range */
510 #define IW_MAX_AP		64
511 
512 /* Maximum size of the ESSID and NICKN strings */
513 #define IW_ESSID_MAX_SIZE	32
514 
515 /* Modes of operation */
516 #define IW_MODE_AUTO	0	/* Let the driver decides */
517 #define IW_MODE_ADHOC	1	/* Single cell network */
518 #define IW_MODE_INFRA	2	/* Multi cell network, roaming, ... */
519 #define IW_MODE_MASTER	3	/* Synchronisation master or Access Point */
520 #define IW_MODE_REPEAT	4	/* Wireless Repeater (forwarder) */
521 #define IW_MODE_SECOND	5	/* Secondary master/repeater (backup) */
522 #define IW_MODE_MONITOR	6	/* Passive monitor (listen only) */
523 
524 /* Statistics flags (bitmask in updated) */
525 #define IW_QUAL_QUAL_UPDATED	0x01	/* Value was updated since last read */
526 #define IW_QUAL_LEVEL_UPDATED	0x02
527 #define IW_QUAL_NOISE_UPDATED	0x04
528 #define IW_QUAL_ALL_UPDATED	0x07
529 #define IW_QUAL_DBM		0x08	/* Level + Noise are dBm */
530 #define IW_QUAL_QUAL_INVALID	0x10	/* Driver doesn't provide value */
531 #define IW_QUAL_LEVEL_INVALID	0x20
532 #define IW_QUAL_NOISE_INVALID	0x40
533 #define IW_QUAL_RCPI		0x80	/* Level + Noise are 802.11k RCPI */
534 #define IW_QUAL_ALL_INVALID	0x70
535 
536 /* Frequency flags */
537 #define IW_FREQ_AUTO		0x00	/* Let the driver decides */
538 #define IW_FREQ_FIXED		0x01	/* Force a specific value */
539 
540 /* Maximum number of size of encoding token available
541  * they are listed in the range structure */
542 #define IW_MAX_ENCODING_SIZES	8
543 
544 /* Maximum size of the encoding token in bytes */
545 #define IW_ENCODING_TOKEN_MAX	64	/* 512 bits (for now) */
546 
547 /* Flags for encoding (along with the token) */
548 #define IW_ENCODE_INDEX		0x00FF	/* Token index (if needed) */
549 #define IW_ENCODE_FLAGS		0xFF00	/* Flags defined below */
550 #define IW_ENCODE_MODE		0xF000	/* Modes defined below */
551 #define IW_ENCODE_DISABLED	0x8000	/* Encoding disabled */
552 #define IW_ENCODE_ENABLED	0x0000	/* Encoding enabled */
553 #define IW_ENCODE_RESTRICTED	0x4000	/* Refuse non-encoded packets */
554 #define IW_ENCODE_OPEN		0x2000	/* Accept non-encoded packets */
555 #define IW_ENCODE_NOKEY		0x0800  /* Key is write only, so not present */
556 #define IW_ENCODE_TEMP		0x0400  /* Temporary key */
557 
558 /* Power management flags available (along with the value, if any) */
559 #define IW_POWER_ON		0x0000	/* No details... */
560 #define IW_POWER_TYPE		0xF000	/* Type of parameter */
561 #define IW_POWER_PERIOD		0x1000	/* Value is a period/duration of  */
562 #define IW_POWER_TIMEOUT	0x2000	/* Value is a timeout (to go asleep) */
563 #define IW_POWER_SAVING		0x4000	/* Value is relative (how aggressive)*/
564 #define IW_POWER_MODE		0x0F00	/* Power Management mode */
565 #define IW_POWER_UNICAST_R	0x0100	/* Receive only unicast messages */
566 #define IW_POWER_MULTICAST_R	0x0200	/* Receive only multicast messages */
567 #define IW_POWER_ALL_R		0x0300	/* Receive all messages though PM */
568 #define IW_POWER_FORCE_S	0x0400	/* Force PM procedure for sending unicast */
569 #define IW_POWER_REPEATER	0x0800	/* Repeat broadcast messages in PM period */
570 #define IW_POWER_MODIFIER	0x000F	/* Modify a parameter */
571 #define IW_POWER_MIN		0x0001	/* Value is a minimum  */
572 #define IW_POWER_MAX		0x0002	/* Value is a maximum */
573 #define IW_POWER_RELATIVE	0x0004	/* Value is not in seconds/ms/us */
574 
575 /* Transmit Power flags available */
576 #define IW_TXPOW_TYPE		0x00FF	/* Type of value */
577 #define IW_TXPOW_DBM		0x0000	/* Value is in dBm */
578 #define IW_TXPOW_MWATT		0x0001	/* Value is in mW */
579 #define IW_TXPOW_RELATIVE	0x0002	/* Value is in arbitrary units */
580 #define IW_TXPOW_RANGE		0x1000	/* Range of value between min/max */
581 
582 /* Retry limits and lifetime flags available */
583 #define IW_RETRY_ON		0x0000	/* No details... */
584 #define IW_RETRY_TYPE		0xF000	/* Type of parameter */
585 #define IW_RETRY_LIMIT		0x1000	/* Maximum number of retries*/
586 #define IW_RETRY_LIFETIME	0x2000	/* Maximum duration of retries in us */
587 #define IW_RETRY_MODIFIER	0x00FF	/* Modify a parameter */
588 #define IW_RETRY_MIN		0x0001	/* Value is a minimum  */
589 #define IW_RETRY_MAX		0x0002	/* Value is a maximum */
590 #define IW_RETRY_RELATIVE	0x0004	/* Value is not in seconds/ms/us */
591 #define IW_RETRY_SHORT		0x0010	/* Value is for short packets  */
592 #define IW_RETRY_LONG		0x0020	/* Value is for long packets */
593 
594 /* Scanning request flags */
595 #define IW_SCAN_DEFAULT		0x0000	/* Default scan of the driver */
596 #define IW_SCAN_ALL_ESSID	0x0001	/* Scan all ESSIDs */
597 #define IW_SCAN_THIS_ESSID	0x0002	/* Scan only this ESSID */
598 #define IW_SCAN_ALL_FREQ	0x0004	/* Scan all Frequencies */
599 #define IW_SCAN_THIS_FREQ	0x0008	/* Scan only this Frequency */
600 #define IW_SCAN_ALL_MODE	0x0010	/* Scan all Modes */
601 #define IW_SCAN_THIS_MODE	0x0020	/* Scan only this Mode */
602 #define IW_SCAN_ALL_RATE	0x0040	/* Scan all Bit-Rates */
603 #define IW_SCAN_THIS_RATE	0x0080	/* Scan only this Bit-Rate */
604 /* struct iw_scan_req scan_type */
605 #define IW_SCAN_TYPE_ACTIVE 0
606 #define IW_SCAN_TYPE_PASSIVE 1
607 /* Maximum size of returned data */
608 #define IW_SCAN_MAX_DATA	4096	/* In bytes */
609 
610 /* Max number of char in custom event - use multiple of them if needed */
611 #define IW_CUSTOM_MAX		256	/* In bytes */
612 
613 /* Generic information element */
614 #define IW_GENERIC_IE_MAX	1024
615 
616 /* MLME requests (SIOCSIWMLME / struct iw_mlme) */
617 #define IW_MLME_DEAUTH		0
618 #define IW_MLME_DISASSOC	1
619 #define IW_MLME_AUTH		2
620 #define IW_MLME_ASSOC		3
621 
622 /* SIOCSIWAUTH/SIOCGIWAUTH struct iw_param flags */
623 #define IW_AUTH_INDEX		0x0FFF
624 #define IW_AUTH_FLAGS		0xF000
625 /* SIOCSIWAUTH/SIOCGIWAUTH parameters (0 .. 4095)
626  * (IW_AUTH_INDEX mask in struct iw_param flags; this is the index of the
627  * parameter that is being set/get to; value will be read/written to
628  * struct iw_param value field) */
629 #define IW_AUTH_WPA_VERSION		0
630 #define IW_AUTH_CIPHER_PAIRWISE		1
631 #define IW_AUTH_CIPHER_GROUP		2
632 #define IW_AUTH_KEY_MGMT		3
633 #define IW_AUTH_TKIP_COUNTERMEASURES	4
634 #define IW_AUTH_DROP_UNENCRYPTED	5
635 #define IW_AUTH_80211_AUTH_ALG		6
636 #define IW_AUTH_WPA_ENABLED		7
637 #define IW_AUTH_RX_UNENCRYPTED_EAPOL	8
638 #define IW_AUTH_ROAMING_CONTROL		9
639 #define IW_AUTH_PRIVACY_INVOKED		10
640 
641 /* IW_AUTH_WPA_VERSION values (bit field) */
642 #define IW_AUTH_WPA_VERSION_DISABLED	0x00000001
643 #define IW_AUTH_WPA_VERSION_WPA		0x00000002
644 #define IW_AUTH_WPA_VERSION_WPA2	0x00000004
645 
646 /* IW_AUTH_PAIRWISE_CIPHER and IW_AUTH_GROUP_CIPHER values (bit field) */
647 #define IW_AUTH_CIPHER_NONE	0x00000001
648 #define IW_AUTH_CIPHER_WEP40	0x00000002
649 #define IW_AUTH_CIPHER_TKIP	0x00000004
650 #define IW_AUTH_CIPHER_CCMP	0x00000008
651 #define IW_AUTH_CIPHER_WEP104	0x00000010
652 
653 /* IW_AUTH_KEY_MGMT values (bit field) */
654 #define IW_AUTH_KEY_MGMT_802_1X	1
655 #define IW_AUTH_KEY_MGMT_PSK	2
656 
657 /* IW_AUTH_80211_AUTH_ALG values (bit field) */
658 #define IW_AUTH_ALG_OPEN_SYSTEM	0x00000001
659 #define IW_AUTH_ALG_SHARED_KEY	0x00000002
660 #define IW_AUTH_ALG_LEAP	0x00000004
661 #define IW_AUTH_ALG_SAE			0x00000008
662 
663 /* IW_AUTH_ROAMING_CONTROL values */
664 #define IW_AUTH_ROAMING_ENABLE	0	/* driver/firmware based roaming */
665 #define IW_AUTH_ROAMING_DISABLE	1	/* user space program used for roaming
666 					 * control */
667 
668 /* SIOCSIWENCODEEXT definitions */
669 #define IW_ENCODE_SEQ_MAX_SIZE	8
670 /* struct iw_encode_ext ->alg */
671 #define IW_ENCODE_ALG_NONE	0
672 #define IW_ENCODE_ALG_WEP	1
673 #define IW_ENCODE_ALG_TKIP	2
674 #define IW_ENCODE_ALG_CCMP	3
675 #define IW_ENCODE_ALG_PMK   4
676 #define IW_ENCODE_ALG_AES_CMAC  5 //IGTK
677 
678 /* struct iw_encode_ext ->ext_flags */
679 #define IW_ENCODE_EXT_TX_SEQ_VALID	0x00000001
680 #define IW_ENCODE_EXT_RX_SEQ_VALID	0x00000002
681 #define IW_ENCODE_EXT_GROUP_KEY		0x00000004
682 #define IW_ENCODE_EXT_SET_TX_KEY	0x00000008
683 
684 /* IWEVMICHAELMICFAILURE : struct iw_michaelmicfailure ->flags */
685 #define IW_MICFAILURE_KEY_ID	0x00000003 /* Key ID 0..3 */
686 #define IW_MICFAILURE_GROUP	0x00000004
687 #define IW_MICFAILURE_PAIRWISE	0x00000008
688 #define IW_MICFAILURE_STAKEY	0x00000010
689 #define IW_MICFAILURE_COUNT	0x00000060 /* 1 or 2 (0 = count not supported)
690 					    */
691 
692 /* Bit field values for enc_capa in struct iw_range */
693 #define IW_ENC_CAPA_WPA		0x00000001
694 #define IW_ENC_CAPA_WPA2	0x00000002
695 #define IW_ENC_CAPA_CIPHER_TKIP	0x00000004
696 #define IW_ENC_CAPA_CIPHER_CCMP	0x00000008
697 
698 /* Event capability macros - in (struct iw_range *)->event_capa
699  * Because we have more than 32 possible events, we use an array of
700  * 32 bit bitmasks. Note : 32 bits = 0x20 = 2^5. */
701 #define IW_EVENT_CAPA_BASE(cmd)		((cmd >= SIOCIWFIRSTPRIV) ? \
702 					 (cmd - SIOCIWFIRSTPRIV + 0x60) : \
703 					 (cmd - SIOCSIWCOMMIT))
704 #define IW_EVENT_CAPA_INDEX(cmd)	(IW_EVENT_CAPA_BASE(cmd) >> 5)
705 #define IW_EVENT_CAPA_MASK(cmd)		(1 << (IW_EVENT_CAPA_BASE(cmd) & 0x1F))
706 /* Event capability constants - event autogenerated by the kernel
707  * This list is valid for most 802.11 devices, customise as needed... */
708 #define IW_EVENT_CAPA_K_0	(IW_EVENT_CAPA_MASK(0x8B04) | \
709 				 IW_EVENT_CAPA_MASK(0x8B06) | \
710 				 IW_EVENT_CAPA_MASK(0x8B1A))
711 #define IW_EVENT_CAPA_K_1	(IW_EVENT_CAPA_MASK(0x8B2A))
712 /* "Easy" macro to set events in iw_range (less efficient) */
713 #define IW_EVENT_CAPA_SET(event_capa, cmd) (event_capa[IW_EVENT_CAPA_INDEX(cmd)] |= IW_EVENT_CAPA_MASK(cmd))
714 #define IW_EVENT_CAPA_SET_KERNEL(event_capa) {event_capa[0] |= IW_EVENT_CAPA_K_0; event_capa[1] |= IW_EVENT_CAPA_K_1; }
715 
716 /* Modulations bitmasks */
717 #define IW_MODUL_ALL		0x00000000	/* Everything supported */
718 #define IW_MODUL_FH		0x00000001	/* Frequency Hopping */
719 #define IW_MODUL_DS		0x00000002	/* Original Direct Sequence */
720 #define IW_MODUL_CCK		0x00000004	/* 802.11b : 5.5 + 11 Mb/s */
721 #define IW_MODUL_11B		(IW_MODUL_DS | IW_MODUL_CCK)
722 #define IW_MODUL_PBCC		0x00000008	/* TI : 5.5 + 11 + 22 Mb/s */
723 #define IW_MODUL_OFDM_A		0x00000010	/* 802.11a : 54 Mb/s */
724 #define IW_MODUL_11A		(IW_MODUL_OFDM_A)
725 #define IW_MODUL_11AB		(IW_MODUL_11B | IW_MODUL_11A)
726 #define IW_MODUL_OFDM_G		0x00000020	/* 802.11g : 54 Mb/s */
727 #define IW_MODUL_11G		(IW_MODUL_11B | IW_MODUL_OFDM_G)
728 #define IW_MODUL_11AG		(IW_MODUL_11G | IW_MODUL_11A)
729 #define IW_MODUL_TURBO		0x00000040	/* ATH : bonding, 108 Mb/s */
730 /* In here we should define MIMO stuff. Later... */
731 #define IW_MODUL_CUSTOM		0x40000000	/* Driver specific */
732 
733 /* Bitrate flags available */
734 #define IW_BITRATE_TYPE		0x00FF	/* Type of value */
735 #define IW_BITRATE_UNICAST	0x0001	/* Maximum/Fixed unicast bitrate */
736 #define IW_BITRATE_BROADCAST	0x0002	/* Fixed broadcast bitrate */
737 
738 /****************************** TYPES ******************************/
739 
740 /* --------------------------- SUBTYPES --------------------------- */
741 
742 struct sockaddr_t {
743   __u8 sa_len;
744   __u8 sa_family;
745   char sa_data[14];
746 };
747 
748 /*
749  *	Generic format for most parameters that fit in an int
750  */
751 struct	iw_param
752 {
753   __s32		value;		/* The value of the parameter itself */
754   __u8		fixed;		/* Hardware should not use auto select */
755   __u8		disabled;	/* Disable the feature */
756   __u16		flags;		/* Various specifc flags (if any) */
757 };
758 
759 /*
760  *	For all data larger than 16 octets, we need to use a
761  *	pointer to memory allocated in user space.
762  */
763 struct	iw_point
764 {
765   void		*pointer;	/* Pointer to the data  (in user space) */
766   __u16		length;		/* number of fields or size in bytes */
767   __u16		flags;		/* Optional params */
768 };
769 
770 /*
771  *	A frequency
772  *	For numbers lower than 10^9, we encode the number in 'm' and
773  *	set 'e' to 0
774  *	For number greater than 10^9, we divide it by the lowest power
775  *	of 10 to get 'm' lower than 10^9, with 'm'= f / (10^'e')...
776  *	The power of 10 is in 'e', the result of the division is in 'm'.
777  */
778 struct	iw_freq
779 {
780 	__s32		m;		/* Mantissa */
781 	__s16		e;		/* Exponent */
782 	__u8		i;		/* List index (when in range struct) */
783 	__u8		flags;		/* Flags (fixed/auto) */
784 };
785 
786 /*
787  *	Quality of the link
788  */
789 struct	iw_quality
790 {
791 	__u8		qual;		/* link quality (%retries, SNR,
792 					   %missed beacons or better...) */
793 	__u8		level;		/* signal level (dBm) */
794 	__u8		noise;		/* noise level (dBm) */
795 	__u8		updated;	/* Flags to know if updated */
796 };
797 
798 /*
799  *	Packet discarded in the wireless adapter due to
800  *	"wireless" specific problems...
801  *	Note : the list of counter and statistics in net_device_stats
802  *	is already pretty exhaustive, and you should use that first.
803  *	This is only additional stats...
804  */
805 struct	iw_discarded
806 {
807 	__u32		nwid;		/* Rx : Wrong nwid/essid */
808 	__u32		code;		/* Rx : Unable to code/decode (WEP) */
809 	__u32		fragment;	/* Rx : Can't perform MAC reassembly */
810 	__u32		retries;	/* Tx : Max MAC retries num reached */
811 	__u32		misc;		/* Others cases */
812 };
813 
814 /*
815  *	Packet/Time period missed in the wireless adapter due to
816  *	"wireless" specific problems...
817  */
818 struct	iw_missed
819 {
820 	__u32		beacon;		/* Missed beacons/superframe */
821 };
822 
823 /*
824  *	Quality range (for spy threshold)
825  */
826 struct	iw_thrspy
827 {
828 	struct sockaddr_t		addr;		/* Source address (hw/mac) */
829 	struct iw_quality	qual;		/* Quality of the link */
830 	struct iw_quality	low;		/* Low threshold */
831 	struct iw_quality	high;		/* High threshold */
832 };
833 
834 /*
835  *	Optional data for scan request
836  *
837  *	Note: these optional parameters are controlling parameters for the
838  *	scanning behavior, these do not apply to getting scan results
839  *	(SIOCGIWSCAN). Drivers are expected to keep a local BSS table and
840  *	provide a merged results with all BSSes even if the previous scan
841  *	request limited scanning to a subset, e.g., by specifying an SSID.
842  *	Especially, scan results are required to include an entry for the
843  *	current BSS if the driver is in Managed mode and associated with an AP.
844  */
845 struct	iw_scan_req
846 {
847 	__u8		scan_type; /* IW_SCAN_TYPE_{ACTIVE,PASSIVE} */
848 	__u8		essid_len;
849 	__u8		num_channels; /* num entries in channel_list;
850 				       * 0 = scan all allowed channels */
851 	__u8		flags; /* reserved as padding; use zero, this may
852 				* be used in the future for adding flags
853 				* to request different scan behavior */
854 	struct sockaddr_t	bssid; /* ff:ff:ff:ff:ff:ff for broadcast BSSID or
855 				* individual address of a specific BSS */
856 
857 	/*
858 	 * Use this ESSID if IW_SCAN_THIS_ESSID flag is used instead of using
859 	 * the current ESSID. This allows scan requests for specific ESSID
860 	 * without having to change the current ESSID and potentially breaking
861 	 * the current association.
862 	 */
863 	__u8		essid[IW_ESSID_MAX_SIZE];
864 
865 	/*
866 	 * Optional parameters for changing the default scanning behavior.
867 	 * These are based on the MLME-SCAN.request from IEEE Std 802.11.
868 	 * TU is 1.024 ms. If these are set to 0, driver is expected to use
869 	 * reasonable default values. min_channel_time defines the time that
870 	 * will be used to wait for the first reply on each channel. If no
871 	 * replies are received, next channel will be scanned after this. If
872 	 * replies are received, total time waited on the channel is defined by
873 	 * max_channel_time.
874 	 */
875 	__u32		min_channel_time; /* in TU */
876 	__u32		max_channel_time; /* in TU */
877 
878 	struct iw_freq	channel_list[IW_MAX_FREQUENCIES];
879 };
880 
881 /* ------------------------- WPA SUPPORT ------------------------- */
882 
883 /*
884  *	Extended data structure for get/set encoding (this is used with
885  *	SIOCSIWENCODEEXT/SIOCGIWENCODEEXT. struct iw_point and IW_ENCODE_*
886  *	flags are used in the same way as with SIOCSIWENCODE/SIOCGIWENCODE and
887  *	only the data contents changes (key data -> this structure, including
888  *	key data).
889  *
890  *	If the new key is the first group key, it will be set as the default
891  *	TX key. Otherwise, default TX key index is only changed if
892  *	IW_ENCODE_EXT_SET_TX_KEY flag is set.
893  *
894  *	Key will be changed with SIOCSIWENCODEEXT in all cases except for
895  *	special "change TX key index" operation which is indicated by setting
896  *	key_len = 0 and ext_flags |= IW_ENCODE_EXT_SET_TX_KEY.
897  *
898  *	tx_seq/rx_seq are only used when respective
899  *	IW_ENCODE_EXT_{TX,RX}_SEQ_VALID flag is set in ext_flags. Normal
900  *	TKIP/CCMP operation is to set RX seq with SIOCSIWENCODEEXT and start
901  *	TX seq from zero whenever key is changed. SIOCGIWENCODEEXT is normally
902  *	used only by an Authenticator (AP or an IBSS station) to get the
903  *	current TX sequence number. Using TX_SEQ_VALID for SIOCSIWENCODEEXT and
904  *	RX_SEQ_VALID for SIOCGIWENCODEEXT are optional, but can be useful for
905  *	debugging/testing.
906  */
907 struct	iw_encode_ext
908 {
909 	__u32		ext_flags; /* IW_ENCODE_EXT_* */
910 	__u8		tx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
911 	__u8		rx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
912 	struct sockaddr_t	addr; /* ff:ff:ff:ff:ff:ff for broadcast/multicast
913 			       * (group) keys or unicast address for
914 			       * individual keys */
915 	__u16		alg; /* IW_ENCODE_ALG_* */
916 	__u16		key_len;
917 #ifdef __CC_ARM	//Fix Keil compile error, must modify sizeof iw_encode_ext - Alex Fang
918 	__u8		key[1];
919 #else
920 	__u8		key[0];
921 #endif
922 };
923 
924 /* SIOCSIWMLME data */
925 struct	iw_mlme
926 {
927 	__u16		cmd; /* IW_MLME_* */
928 	__u16		reason_code;
929 	struct sockaddr_t	addr;
930 };
931 
932 /* SIOCSIWPMKSA data */
933 #define IW_PMKSA_ADD		1
934 #define IW_PMKSA_REMOVE		2
935 #define IW_PMKSA_FLUSH		3
936 
937 #define IW_PMKID_LEN	16
938 
939 struct	iw_pmksa
940 {
941 	__u32		cmd; /* IW_PMKSA_* */
942 	struct sockaddr_t	bssid;
943 	__u8		pmkid[IW_PMKID_LEN];
944 };
945 
946 /* IWEVMICHAELMICFAILURE data */
947 struct	iw_michaelmicfailure
948 {
949 	__u32		flags;
950 	struct sockaddr_t	src_addr;
951 	__u8		tsc[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
952 };
953 
954 /* IWEVPMKIDCAND data */
955 #define IW_PMKID_CAND_PREAUTH	0x00000001 /* RNS pre-authentication enabled */
956 struct	iw_pmkid_cand
957 {
958 	__u32		flags; /* IW_PMKID_CAND_* */
959 	__u32		index; /* the smaller the index, the higher the
960 				* priority */
961 	struct sockaddr_t	bssid;
962 };
963 
964 /* ------------------------ WIRELESS STATS ------------------------ */
965 /*
966  * Wireless statistics (used for /proc/net/wireless)
967  */
968 struct	iw_statistics
969 {
970 	__u16		status;		/* Status
971 					 * - device dependent for now */
972 
973 	struct iw_quality	qual;		/* Quality of the link
974 						 * (instant/mean/max) */
975 	struct iw_discarded	discard;	/* Packet discarded counts */
976 	struct iw_missed	miss;		/* Packet missed counts */
977 };
978 
979 /* ------------------------ IOCTL REQUEST ------------------------ */
980 /*
981  * This structure defines the payload of an ioctl, and is used
982  * below.
983  *
984  * Note that this structure should fit on the memory footprint
985  * of iwreq (which is the same as ifreq), which mean a max size of
986  * 16 octets = 128 bits. Warning, pointers might be 64 bits wide...
987  * You should check this when increasing the structures defined
988  * above in this file...
989  */
990 union	iwreq_data
991 {
992 	/* Config - generic */
993 	char		name[IFNAMSIZ];
994 	/* Name : used to verify the presence of  wireless extensions.
995 	 * Name of the protocol/provider... */
996 
997 	struct iw_point	essid;		/* Extended network name */
998 	struct iw_param	nwid;		/* network id (or domain - the cell) */
999 	struct iw_freq	freq;		/* frequency or channel :
1000 					 * 0-1000 = channel
1001 					 * > 1000 = frequency in Hz */
1002 
1003 	struct iw_param	sens;		/* signal level threshold */
1004 	struct iw_param	bcnsens;	/* signal level threshold */
1005 	struct iw_param	bitrate;	/* default bit rate */
1006 	struct iw_param	txpower;	/* default transmit power */
1007 	struct iw_param	rts;		/* RTS threshold threshold */
1008 	struct iw_param	frag;		/* Fragmentation threshold */
1009 	__u32		mode;		/* Operation mode */
1010 	struct iw_param	retry;		/* Retry limits & lifetime */
1011 
1012 	struct iw_point	encoding;	/* Encoding stuff : tokens */
1013 	struct iw_param	power;		/* PM duration/timeout */
1014 	struct iw_quality qual;		/* Quality part of statistics */
1015 
1016 	struct sockaddr_t	ap_addr;	/* Access point address */
1017 	struct sockaddr_t	addr;		/* Destination address (hw/mac) */
1018 
1019 	struct iw_param	param;		/* Other small parameters */
1020 	struct iw_point	data;		/* Other large parameters */
1021 	struct iw_point	passphrase;		/* Extended network name */
1022 };
1023 
1024 /*
1025  * The structure to exchange data for ioctl.
1026  * This structure is the same as 'struct ifreq', but (re)defined for
1027  * convenience...
1028  * Do I need to remind you about structure size (32 octets) ?
1029  */
1030 struct	iwreq
1031 {
1032 #if 0
1033 	union
1034 	{
1035 		char	ifrn_name[IFNAMSIZ];	/* if name, e.g. "eth0" */
1036 	} ifr_ifrn;
1037 #endif
1038 	char	ifr_name[IFNAMSIZ];	/* if name, e.g. "eth0" */
1039 
1040 	/* Data part (defined just above) */
1041 	union	iwreq_data	u;
1042 };
1043 
1044 /* -------------------------- IOCTL DATA -------------------------- */
1045 /*
1046  *	For those ioctl which want to exchange mode data that what could
1047  *	fit in the above structure...
1048  */
1049 
1050 /*
1051  *	Range of parameters
1052  */
1053 
1054 struct	iw_range
1055 {
1056 	/* Informative stuff (to choose between different interface) */
1057 	__u32		throughput;	/* To give an idea... */
1058 	/* In theory this value should be the maximum benchmarked
1059 	 * TCP/IP throughput, because with most of these devices the
1060 	 * bit rate is meaningless (overhead an co) to estimate how
1061 	 * fast the connection will go and pick the fastest one.
1062 	 * I suggest people to play with Netperf or any benchmark...
1063 	 */
1064 
1065 	/* NWID (or domain id) */
1066 	__u32		min_nwid;	/* Minimal NWID we are able to set */
1067 	__u32		max_nwid;	/* Maximal NWID we are able to set */
1068 
1069 	/* Old Frequency (backward compat - moved lower ) */
1070 	__u16		old_num_channels;
1071 	__u8		old_num_frequency;
1072 
1073 	/* Wireless event capability bitmasks */
1074 	__u32		event_capa[6];
1075 
1076 	/* signal level threshold range */
1077 	__s32		sensitivity;
1078 
1079 	/* Quality of link & SNR stuff */
1080 	/* Quality range (link, level, noise)
1081 	 * If the quality is absolute, it will be in the range [0 ; max_qual],
1082 	 * if the quality is dBm, it will be in the range [max_qual ; 0].
1083 	 * Don't forget that we use 8 bit arithmetics... */
1084 	struct iw_quality	max_qual;	/* Quality of the link */
1085 	/* This should contain the average/typical values of the quality
1086 	 * indicator. This should be the threshold between a "good" and
1087 	 * a "bad" link (example : monitor going from green to orange).
1088 	 * Currently, user space apps like quality monitors don't have any
1089 	 * way to calibrate the measurement. With this, they can split
1090 	 * the range between 0 and max_qual in different quality level
1091 	 * (using a geometric subdivision centered on the average).
1092 	 * I expect that people doing the user space apps will feedback
1093 	 * us on which value we need to put in each driver... */
1094 	struct iw_quality	avg_qual;	/* Quality of the link */
1095 
1096 	/* Rates */
1097 	__u8		num_bitrates;	/* Number of entries in the list */
1098 	__s32		bitrate[IW_MAX_BITRATES];	/* list, in bps */
1099 
1100 	/* RTS threshold */
1101 	__s32		min_rts;	/* Minimal RTS threshold */
1102 	__s32		max_rts;	/* Maximal RTS threshold */
1103 
1104 	/* Frag threshold */
1105 	__s32		min_frag;	/* Minimal frag threshold */
1106 	__s32		max_frag;	/* Maximal frag threshold */
1107 
1108 	/* Power Management duration & timeout */
1109 	__s32		min_pmp;	/* Minimal PM period */
1110 	__s32		max_pmp;	/* Maximal PM period */
1111 	__s32		min_pmt;	/* Minimal PM timeout */
1112 	__s32		max_pmt;	/* Maximal PM timeout */
1113 	__u16		pmp_flags;	/* How to decode max/min PM period */
1114 	__u16		pmt_flags;	/* How to decode max/min PM timeout */
1115 	__u16		pm_capa;	/* What PM options are supported */
1116 
1117 	/* Encoder stuff */
1118 	__u16	encoding_size[IW_MAX_ENCODING_SIZES];	/* Different token sizes */
1119 	__u8	num_encoding_sizes;	/* Number of entry in the list */
1120 	__u8	max_encoding_tokens;	/* Max number of tokens */
1121 	/* For drivers that need a "login/passwd" form */
1122 	__u8	encoding_login_index;	/* token index for login token */
1123 
1124 	/* Transmit power */
1125 	__u16		txpower_capa;	/* What options are supported */
1126 	__u8		num_txpower;	/* Number of entries in the list */
1127 	__s32		txpower[IW_MAX_TXPOWER];	/* list, in bps */
1128 
1129 	/* Wireless Extension version info */
1130 	__u8		we_version_compiled;	/* Must be WIRELESS_EXT */
1131 	__u8		we_version_source;	/* Last update of source */
1132 
1133 	/* Retry limits and lifetime */
1134 	__u16		retry_capa;	/* What retry options are supported */
1135 	__u16		retry_flags;	/* How to decode max/min retry limit */
1136 	__u16		r_time_flags;	/* How to decode max/min retry life */
1137 	__s32		min_retry;	/* Minimal number of retries */
1138 	__s32		max_retry;	/* Maximal number of retries */
1139 	__s32		min_r_time;	/* Minimal retry lifetime */
1140 	__s32		max_r_time;	/* Maximal retry lifetime */
1141 
1142 	/* Frequency */
1143 	__u16		num_channels;	/* Number of channels [0; num - 1] */
1144 	__u8		num_frequency;	/* Number of entry in the list */
1145 	struct iw_freq	freq[IW_MAX_FREQUENCIES];	/* list */
1146 	/* Note : this frequency list doesn't need to fit channel numbers,
1147 	 * because each entry contain its channel index */
1148 
1149 	__u32		enc_capa;	/* IW_ENC_CAPA_* bit field */
1150 
1151 	/* More power management stuff */
1152 	__s32		min_pms;	/* Minimal PM saving */
1153 	__s32		max_pms;	/* Maximal PM saving */
1154 	__u16		pms_flags;	/* How to decode max/min PM saving */
1155 
1156 	/* All available modulations for driver (hw may support less) */
1157 	__s32		modul_capa;	/* IW_MODUL_* bit field */
1158 
1159 	/* More bitrate stuff */
1160 	__u32		bitrate_capa;	/* Types of bitrates supported */
1161 };
1162 
1163 /*
1164  * Private ioctl interface information
1165  */
1166 
1167 struct	iw_priv_args
1168 {
1169 	__u32		cmd;		/* Number of the ioctl to issue */
1170 	__u16		set_args;	/* Type and number of args */
1171 	__u16		get_args;	/* Type and number of args */
1172 	char		name[IFNAMSIZ];	/* Name of the extension */
1173 };
1174 
1175 /* ----------------------- WIRELESS EVENTS ----------------------- */
1176 /*
1177  * Wireless events are carried through the rtnetlink socket to user
1178  * space. They are encapsulated in the IFLA_WIRELESS field of
1179  * a RTM_NEWLINK message.
1180  */
1181 
1182 /*
1183  * A Wireless Event. Contains basically the same data as the ioctl...
1184  */
1185 struct iw_event
1186 {
1187 	__u16		len;			/* Real lenght of this stuff */
1188 	__u16		cmd;			/* Wireless IOCTL */
1189 	union iwreq_data	u;		/* IOCTL fixed payload */
1190 };
1191 
1192 /* Size of the Event prefix (including padding and alignement junk) */
1193 #define IW_EV_LCP_LEN	(sizeof(struct iw_event) - sizeof(union iwreq_data))
1194 /* Size of the various events */
1195 #define IW_EV_CHAR_LEN	(IW_EV_LCP_LEN + IFNAMSIZ)
1196 #define IW_EV_UINT_LEN	(IW_EV_LCP_LEN + sizeof(__u32))
1197 #define IW_EV_FREQ_LEN	(IW_EV_LCP_LEN + sizeof(struct iw_freq))
1198 #define IW_EV_PARAM_LEN	(IW_EV_LCP_LEN + sizeof(struct iw_param))
1199 #define IW_EV_ADDR_LEN	(IW_EV_LCP_LEN + sizeof(struct sockaddr_t))
1200 #define IW_EV_QUAL_LEN	(IW_EV_LCP_LEN + sizeof(struct iw_quality))
1201 
1202 /* iw_point events are special. First, the payload (extra data) come at
1203  * the end of the event, so they are bigger than IW_EV_POINT_LEN. Second,
1204  * we omit the pointer, so start at an offset. */
1205 #define IW_EV_POINT_OFF (((char *) &(((struct iw_point *) NULL)->length)) - \
1206 			  (char *) NULL)
1207 #define IW_EV_POINT_LEN	(IW_EV_LCP_LEN + sizeof(struct iw_point) - \
1208 			 IW_EV_POINT_OFF)
1209 
1210 /* Size of the Event prefix when packed in stream */
1211 #define IW_EV_LCP_PK_LEN	(4)
1212 /* Size of the various events when packed in stream */
1213 #define IW_EV_CHAR_PK_LEN	(IW_EV_LCP_PK_LEN + IFNAMSIZ)
1214 #define IW_EV_UINT_PK_LEN	(IW_EV_LCP_PK_LEN + sizeof(__u32))
1215 #define IW_EV_FREQ_PK_LEN	(IW_EV_LCP_PK_LEN + sizeof(struct iw_freq))
1216 #define IW_EV_PARAM_PK_LEN	(IW_EV_LCP_PK_LEN + sizeof(struct iw_param))
1217 #define IW_EV_ADDR_PK_LEN	(IW_EV_LCP_PK_LEN + sizeof(struct sockaddr_t))
1218 #define IW_EV_QUAL_PK_LEN	(IW_EV_LCP_PK_LEN + sizeof(struct iw_quality))
1219 #define IW_EV_POINT_PK_LEN	(IW_EV_LCP_LEN + 4)
1220 
1221 #define IW_EXT_STR_FOURWAY_DONE  "WPA/WPA2 handshake done"
1222 #define IW_EXT_STR_RECONNECTION_FAIL  "RECONNECTION FAILURE"
1223 #define IW_EVT_STR_STA_ASSOC	"STA Assoc"
1224 #define IW_EVT_STR_STA_DISASSOC	"STA Disassoc"
1225 #define IW_EVT_STR_SEND_ACTION_DONE	"Send Action Done"
1226 #define IW_EVT_STR_NO_NETWORK "No Assoc Network After Scan Done"
1227 #define IW_EVT_STR_ICV_ERROR "ICV Eror"
1228 #define IW_EVT_STR_CHALLENGE_FAIL "Auth Challenge Fail"
1229 #define IW_EVT_STR_SOFTAP_START "Softap Start"
1230 #define IW_EVT_STR_SOFTAP_STOP "Softap Stop"
1231 #endif	/* _LINUX_WIRELESS_H */
1232