OSDN Git Service

v28
authorchris-kirby <chris.kirby@hpe.com>
Tue, 11 Oct 2016 21:13:40 +0000 (15:13 -0600)
committerchris-kirby <chris.kirby@hpe.com>
Tue, 11 Oct 2016 21:13:40 +0000 (15:13 -0600)
36 files changed:
wireless_tools/CHANGELOG.h
wireless_tools/HOTPLUG.txt
wireless_tools/IFRENAME-VS-XXX.txt [new file with mode: 0644]
wireless_tools/INSTALL
wireless_tools/Makefile
wireless_tools/PCMCIA.txt
wireless_tools/README
wireless_tools/cs/ifrename.8 [new file with mode: 0644]
wireless_tools/cs/iftab.5 [new file with mode: 0644]
wireless_tools/cs/iwconfig.8 [new file with mode: 0644]
wireless_tools/cs/iwevent.8 [new file with mode: 0644]
wireless_tools/cs/iwgetid.8 [new file with mode: 0644]
wireless_tools/cs/iwlist.8 [new file with mode: 0644]
wireless_tools/cs/iwpriv.8 [new file with mode: 0644]
wireless_tools/cs/iwspy.8 [new file with mode: 0644]
wireless_tools/cs/wireless.7 [new file with mode: 0644]
wireless_tools/ifrename.8
wireless_tools/ifrename.c
wireless_tools/iftab.5
wireless_tools/iwconfig.8
wireless_tools/iwconfig.c
wireless_tools/iwevent.8
wireless_tools/iwevent.c
wireless_tools/iwgetid.8
wireless_tools/iwgetid.c
wireless_tools/iwlib.c
wireless_tools/iwlib.h
wireless_tools/iwlist.c
wireless_tools/iwmulticall.c [new file with mode: 0644]
wireless_tools/iwpriv.c
wireless_tools/iwspy.8
wireless_tools/iwspy.c
wireless_tools/macaddr.c
wireless_tools/wireless.18.h [new file with mode: 0644]
wireless_tools/wireless.19.h [new file with mode: 0644]
wireless_tools/wireless.20.h [new file with mode: 0644]

index 9fbbd36..94855c1 100644 (file)
  *     o Make sure gcc inline stuff properly [iwlib.h]
  *     o Update Hotplug documentation [HOTPLUG.txt]
  *     o Add support for new selector firmware [ifrename]
+ *
+ * wireless 28 :
+ * -----------
+ *     o Fix gcc inline hack when using kernel headers [iwlib.h]
+ *             (From Denis Ovsienko <pilot@altlinux.ru>)
+ *     o Allow '-n' without '-i', even though inefficient [ifrename]
+ *             (From Thomas Hood <jdthood@aglu.demon.nl>)
+ *     o Fix technical and spelling errors in Hotplug doc [HOTPLUG.txt]
+ *     ---
+ *     o Include wireless.h as a local file, not a system file [iwlib.h]
+ *     o Split install targets [Makefile]
+ *             (Suggested by Jost Diederichs <jost@qdusa.com>)
+ *     o Increase scanning timeout for MadWifi [iwlib/iwlist]
+ *             (Suggested by Ned Ludd <solar@gentoo.org>)
+ *     o Multicall version of the tools for embedded [iwmulticall]
+ *     ---
+ *     o Fix some install Makefile targets broken in pre2 [Makefile]
+ *     ---
+ *     o Add option for stripping symbols on tools [Makefile]
+ *     o Add escaping of essid keyworks with -- in manpage [iwconfig.8]
+ *     o Update sensitivity description [iwconfig.8]
+ *     o Fix iw_print_timeval() for timezone [iwlib/iwevent]
+ *             (Suggested by Jan Minar <jjminar@FastMail.FM>)
+ *     o Escape interface name for --help/--version with -- [iwconfig]
+ *     o Allow --help/--version to be interface names [iwlist]
+ *             (From Martynas Dubauskis <martynas@gemtek.lt>)
+ *     o Fix invalid sizeof for stat memcpy in easy scanning API [iwlib.c]
+ *             (From Andreas Mohr <andi@rhlx01.fht-esslingen.de>)
+ *     o Fix my horrendous spelling [HOTPLUG.txt/PCMCIA.txt/README/*.8]
+ *     ---
+ *     o Make static lib use PIC objects [Makefile]
+ *     o Add SYSFS selector support to ifrename [ifrename]
+ *     o Fix a fd leak in pcmciaslot selector [ifrename]
+ *     o Don't complain about eth0/wlan0 if takeover enabled [ifrename]
+ *     o Update man pages for sysfs and eth0/wlan0 [ifrename.8]
+ *     o Update man pages for frequ auto/off [iwconfig.8]
+ *     o More clever manual loading and docking tricks [HOTPLUG.txt]
+ *             (From Pavel Heimlich tropikhajma@seznam.cz)
+ *     o Czech (cs) man pages [cs/*]
+ *     ---
+ *     o Fudge patch below for better integration [iwconfig/iwevent/iwlist]
+ *             (From Jouni Malinen <jkmaline@cc.hut.fi>)
+ *     o WE-18/WPA event display [iwevent]
+ *     o WE-18/WPA parameter display [iwconfig]
+ *     ---
+ *     o Replace iw_pr_ether() with iw_saether_ntop() [iwlib]
+ *     o Replace iw_in_ether() with iw_saether_aton() [iwlib]
+ *     o Remove iw_get_mac_addr() -> unused and bad API [iwlib]
+ *     o Add iw_mac_ntop() and iw_mac_aton() for any-len mac addr [iwlib]
+ *     o Slim down iw_ether_aton() using iw_mac_ntop() [iwlib]
+ *     o Slim down iw_in_key(), avoid memcpy [iwlib]
+ *     o Add support for any-len mac addr selector [ifrename]
+ *     ---
+ *     o Re-add temp output buffer in iw_in_key() to avoid corruptions [iwlib]
+ *     ---
+ *     o Add WE-19 headers, compile with that as default
+ *     o IW_EV_POINT_LEN has shrunk, so invert IW_EV_POINT_OFF fixup [iwlib]
+ *     o Remove WE backward compat from iwlib.h header [iwlib]
+ *     o Add support for IW_QUAL_DBM in iw_print_stats() [iwlib]
+ *     o Add support for ARPHRD_IEEE80211 in iw_check_mac_addr_type() [iwlib]
+ *             -> iwspy work on wifi0 netdev from airo.c
+ *     ---
+ *     o Set flags to 0 before asking old power settings for 'on' [iwconfig]
+ *             (Suggested by Denis Ovsienko <pilot@altlinux.ru>)
+ *     o Ignore empty lines in iface enumeration iw_enum_devices() [iwlib]
+ *             (From Pavel Roskin <proski@gnu.org>)
+ *     o Fix invalid buffer size in 'iwlist power' [iwlist]
+ *             (Suggested by Francesco Potorti` <pot@gnu.org>)
+ *     o Remove kernel headers, use glibc headers [iwlib]
+ *     ---
+ *     o Show explicit state for SIOCSIWAP, not numbers [iwconfig/iwevent] 
+ *     o Add WE-18 ioctls to the stream parser in standard_ioctl_hdr [iwlib]
+ *             (From Chris Hessing <Chris.Hessing@utah.edu>)
+ *     o Add GENIE parsing support in scan resuls [iwlist]
+ *     ---
+ *     o Change iw_extract_event_stream() API to add value index [iwlib]
+ *     o Scan : display bitrate values on a single line [iwlist]
+ *     ---
+ *     o Revert to previous iw_extract_event_stream() API, debloat [iwlib]
+ *     o Keep track of value index in [iwlist]
+ *     ---
+ *     o Check event stream 'point' payload size to avoid overflow [iwlib]
+ *     o Make all users of event stream 'point' safe to NULL [iwlist/iwevent]
+ *     o 'iwconfig txpower 1dBm' should not be 'mW' [iwconfig]
+ *     o Forward compat. to WE-21 : essid len is strlen, not +1 [iwconfig]
+ *     ---
+ *     o Forgot one place where essid len was strlen+1 [iwlib]
+ *     o Update definition of 'ap' and 'sens' to reflect reality [man]
+ *     ---
+ *     o Introduce WE_MAX_VERSION to take into account forward compat [iwlib]
+ *     o Add WE-20 headers, compile with that as default
+ *     ---
+ *     o Fix 'inline' for gcc-4 as well. Grrr... [iwlib]
  */
 
 /* ----------------------------- TODO ----------------------------- */
  * ifrename :
  * --------
  *     Link Type should use readable form instead of numeric value
- *     Support non MAC/Eth addresses ?
  *
  * Doc & man pages :
  * ---------------
  *     Update main doc.
- *
- * Other :
- * -----
- *     What about some graphical tools ?
  */
index 12a3d7a..d22a1f0 100644 (file)
@@ -1,20 +1,19 @@
-               Sane Hotplug network interface management
-               -----------------------------------------
+               Sane network interface management with Hotplug
+               ----------------------------------------------
 
 INTRODUCTION
 ------------
-       In the old day, all Wireless cards were managed by the
+       In the old days all wireless cards were managed by the
 excellent Pcmcia subsystem and its rich configuration scripts, and
-life was happy. Then came the wireless PCI cards, then the wireless
+life was good. Then came the wireless PCI cards, then the wireless
 USB dongles. Some unification was needed, and rather than adapt the
 Pcmcia subsystem for PCI and USB, it was decided to create the much
-simpler Hotplug systems.
-       The USB subsystem already use Hotplug, and the Pcmcia
-subsystem is migrating to it, CardBus cards (32 bits) already use
-Hotplug, whereas Pcmcia cards (16 bits) still use the old Pcmcia
-scripts.
-       The Hotplug system is still in its infancy, but already show
-some good promises. Most users are disapointed at first by its
+simpler Hotplug system.
+       The USB subsystem already uses Hotplug. The Pcmcia subsystem
+is migrating to it : CardBus cards (32 bits) already use Hotplug,
+whereas Pcmcia cards (16 bits) still use the old Pcmcia scripts.
+       The Hotplug system is still in its infancy, but already shows
+some good promise. Most users are disappointed at first by its
 apparent lack of features compared to the Pcmcia scripts. In this
 document, we will show how to fully exploit the Hotplug system and try
 to implement the equivalent of all the functionality of the Pcmcia
@@ -27,39 +26,39 @@ distribution maintainers, but it should give enough clues to help
 newbies. You should have read and understood DISTRIBUTIONS.txt. The
 procedures described here are more advanced than the simple
 configuration described in DISTRIBUTIONS.txt.
-       The main focus is of course removable wireless interfaces, but
-we will try to keep things generic and talk of the whole network
-interface management, so this should apply also to built-in Ethernet
-cards.
+       The main focus is of course on removable wireless interfaces,
+but we will to talk about network interface management in general, so
+this should apply also to built-in Ethernet cards.
 
 PROBLEM STATEMENT
 -----------------
-       Let assume a Linux system and two or more network devices,
+       Let's assume a Linux system and two or more network devices,
 Device A and Device B. Those devices may be built-in or removable,
-they may be present or absent from the system at any time, and
-activated in any particular order.
+they may be present or absent from the system at any time, and they
+may activated in any particular order.
        The user wants to assign Configuration A to Device A and
-Configuration B to Device B, without the possibility that Device A get
-assigned Configuration B.
-       Different users may have different definition of what is
+Configuration B to Device B, without the possibility that Device A
+gets assigned Configuration B.
+       Different users may have different definitions of what is
 Device A. For some, it's a specific instance of a specific hardware,
-for others any hardware that meet some criteria (a wireless card, an
+for others any hardware that meets some criteria (a wireless card, an
 Ethernet card).
-       The user may also want to have multiple configurations
-depending on various factors (like the old Pcmcia schemes). Device A
-may get Configuration A1 or Configuration A2 depending on those
-factors.
-       By default, all network interfaces are created using default
-interface name (starting at "eth0" and going up). I call that problem
-"all my cards are eth0". And by default, "eth0" point to a single
-fixed configuration in the configuration database. Clearly, this won't
-satisfy our requirements.
+       The user may also want to have multiple configurations for a
+given device such that the chosen configuration depends on various
+factors, just as with the old Pcmcia schemes. Device A may need
+Configuration A1 or Configuration A2 depending on those factors.
+       By default, all network interfaces are created using default
+interface names (starting at "eth0" and going up). I call that the
+"all my cards are eth0" problem : im most distributions, "eth0" points
+to a single fixed configuration in the configuration
+database. Clearly, this won't satisfy our requirements.
 
 EXAMPLE SYSTEM
 --------------
-       The distribution I use is Debian 3.0, and some parts will be
-specific to it. However, it should be easy to translate to other
-distributions and I welcome additions to this document.
+       The distribution I use is Debian 3.0, and some parts of what I
+say here will be specific to it. However, it should be easy to
+translate this material to other distributions and I welcome additions
+to this document.
 
        The example system is as follows :
                o Linux 2.6.X SMP kernel with hotplug support
@@ -73,26 +72,26 @@ distributions and I welcome additions to this document.
                o Pcmcia 802.11 card : Lucent Orinoco (orinoco_cs - eth0)
                o CardBus 802.11 card : SMC 2835W (prism54 - prism0)
 
-       This system just happen to be my Linux development box, and
-has enough interfaces to make it interesting. All the example I quote
-in this document are extracted from this fully working system.
+       This system just happens to be my Linux development box. It
+has enough interfaces to make it interesting. All the examples I
+present in this document are extracted from this system.
 
 BASIC CONCEPTS
 --------------
        Most of the concept and tricks presented here are not really
-new, the main contribution is to integrate them together and make them
-work.
+new. The main contribution is to integrate them.
 
        1) Removable network interfaces are managed by Hotplug
 (Pcmcia, CardBus, USB...). We can't assume that those interfaces are
 always present in this system and available at boot time (Pcmcia cards
-are not made to be soldered in the Pcmcia slot), therefore Hotplug is
-the only way to go.
+were not made to be soldered in the Pcmcia slot). Therefore Hotplug is
+the way to go.
        2) Built-in PCI and ISA cards are managed by the init scripts,
-like they have always been. The ISA subsystem will never have Hotplug
+as they have always been. The ISA subsystem will never have Hotplug
 support, and hotplug is not necessary for PCI cards.
        3) Built-in devices that are disable most of the time should
-be enabled manually.
+be enabled manually by the user. Therefore both Hotplug and the init
+scripts should ignore those devices by default.
        4) (1), (2) and (3) must be compatible on the same system and
 play nice with each other.
 
@@ -101,72 +100,74 @@ assigned to each network hardware interface using 'ifrename'. Device A
 is always named 'ethA' (or whatever name you like such as
 'mynetworkcard').
        6) No interface is called 'eth0' (or 'wlan0'). Any unknown
-device would be 'eth0', thefore known device should avoid using it
-because it might be already taken.
+device would be 'eth0', so known devices should be called something
+else.
        7) Multiple configurations for a single interface (schemes)
 are managed by the ifup/ifdown subsystem.
 
 CONFIGURATION FROM INIT SCRIPTS
 -------------------------------
-       It may seems paradoxal, but before setting up Hotplug, we need
-to make sure that the initialisation of network cards via init
-scripts is done properly and doesn't get in our way.
+       It may seem paradoxical, but before setting up Hotplug, we
+need to make sure that the initialisation of network cards via init
+scripts is done properly and doesn't get in the way of the Hotplug
+subsystem.
        The configuration of network cards via init scripts is the
-traditional way network is initialised in Linux. The advantage of this
-method is that it's very well documented and understood, and has not
-changed much over the years. Unfortunately, it doesn't support
-properly removable cards.
-       The init scripts perform the following 3 functions in that
-order :
-               1) load necessary driver modules
-               2) rename interface to name chosen by the user
-               3) configure those interfaces
+traditional way networking is initialised in Linux. The advantage of
+this method is that it's very well documented and understood, and has
+not changed much over the years. Unfortunately, it doesn't adequately
+support removable cards.
+
+       The init scripts perform the following 3 functions in order :
+               1) Load necessary driver modules
+               2) Rename interface to name chosen by the user
+               3) Configure those network interfaces
 
        1) Applicability
        ----------------
        Configuration from init scripts is applicable to any built-in
-network interface (ISA, PCI...), i.e. interfaces availalble at boot
+network interface (ISA, PCI...), i.e., interfaces available at boot
 time and that will never be removed from the system.
-       The Hotplug subsystem has also the ability to configure some
+       The Hotplug subsystem also has the ability to configure some
 of the built-in network interfaces, such as PCI cards. However, there
 is a class of devices that will never have Hotplug support, such as
-ISA and EISA cards, and for those Hotplug won't work.
-       The advantage of using the init script method is that you are
-probably already familiar with it and you have the ability to select
-which interfaces should be configured at boot and which interface
-should only be enabled manually (whereas Hotplug just configures
-everything).
+ISA and EISA cards.
 
        2) Loading driver modules (if/as needed)
        ----------------------------------------
        Most distributions build the kernel drivers as modules. This
-modular setup allow to minimise the amount of memory used by the
+modular setup allows to minimise the amount of memory used by the
 system and the flexible loading/unloading of drivers.
        You can also compile your kernel with static drivers
 (non-modular). In that case, the driver will always be available in
-your kernel, you don't need to configure the module subsystem, so you
+the kernel, you don't need to configure the module subsystem, so you
 can skip directly to the next section.
 
        There are 3 alternatives to manage device drivers as
-modules. Some distribution have explicit list of modules that are
-loaded at boot time, if you want to use that feature you need to check
-your distribution. Some system, such as hotplug or kudzu, can scan the
-various buses of the PC and load the appropriate drivers, and this is
-mostly configuration-free, but may not support all devices. The module
-subsystem also allow to load modules 'on-demand'.
+modules.
+               1) Some distributions have an explicit list of modules
+that are loaded at boot time. If you want to use that feature you need
+to check the documentation of your distribution.
+               2) Some system, such as Hotplug, Discover or Kudzu,
+can scan the various buses of the PC and load the appropriate
+drivers. This is mostly configuration-free, but may not support all
+devices and may load unnecessary modules.
+               3) The module subsystem also allows to load modules
+'on-demand'. When an application try to access or configure a network
+interface, the corresponding module is loaded.
 
        I personally prefer to use the 'on-demand' feature of the
-module subsystem has, as it allows you to not have to specify the list
-of modules that need to be loaded, and only modules really necessary
-are loaded which save kernel memory. You can also choose which module
-to load when there are multiple altenate modules valid for your
+module subsystem, as this allow you to not have to specify a static
+list of modules that need to be loaded, and only modules really needed
+are loaded which saves kernel memory. You can also choose which module
+to load when there are multiple modules available that support your
 hardware (which happens quite often).
 
-       With kernel 2.6.X, the module subsystem is configured in
-/etc/modprobe.conf. To configure 'on-demand' module loading, I need to
-add to this file the following lines :
+       With kernel 2.6.X the module subsystem is configured in the
+file /etc/modprobe.conf or files in the directory /etc/modprobe.d/. To
+configure 'on-demand' module loading, on my test system I need to add
+to the following lines to the configuration :
 
---------- /etc/modprobe.conf ----------------
+--------- /etc/modprobe.d/local or /etc/modprobe.conf ------
 # HP 100VG J2585B PCI card
 alias eth2 hp100
 
@@ -176,32 +177,32 @@ alias eth4 pcnet32
 # Old AT&T Wavelan ISA card
 alias eth3 wavelan
 options wavelan io=0x390 irq=15
----------------------------------------------
+------------------------------------------------------------
 
        Your distribution may already have lines for your interfaces,
-either replace them or make sure they are correct (some distro are
-notorious for picking the wrong driver name). This file also contains
-configuration for lot of other subsystems, obviously you don't want to
-touch that.
+either replace these or make sure they are correct (some distributions
+are notorious for picking the wrong driver name in some cases). This
+file also contains configuration for lot of other subsystems,
+obviously you don't want to touch that.
        In this file, you put the name you would like the interface to
-have (we'll fix that in a minute). You note that for modern PCI cards,
-this is much more straightforward than for old ISA cards.
+have (we'll fix that in a minute). Note that for modern PCI cards this
+is much more straightforward than for old ISA cards.
 
        3) Installing 'ifrename'
        ------------------------
        You will need to install ifrename on your system. 'ifrename'
 is part of the Wireless Tools package (version 27 and later) and is a
 complete rewrite of the now obsolete 'nameif'.
-       Some distributions, such as Debian Sarge, offer a specific
+       Some distributions, such as Debian Sarge, offer a separate
 package for 'ifrename', and in this case you should just install this
 package. Other distributions may include ifrename as part of their
-'wireless tools' package (this should be the case for Geentoo and
-Mandrake). Other distributions, such as Debian 3.0, don't include
-ifrename at all, and you should compile yourself a recent version of
+'wireless-tools' package (this should be the case for Gentoo, Fedora
+and Mandrake). Other distributions, such as Debian 3.0, don't include
+ifrename at all, so you should compile yourself a recent version of
 Wireless Tools (v27 or later) and install it.
 
-       In any case, you should verify if 'ifrename' is properly
-installed, and what is the path to call it.
+       In any case, you should verify that 'ifrename' is properly
+installed and check the path needed to call it :
 --------------------------
 > which ifrename
 /sbin/ifrename
@@ -213,12 +214,14 @@ you compile your own wireless tools, it will be in '/usr/local/sbin'.
        ------------------------------------------
        You need to make sure 'ifrename' is run at boot time. Most
 distributions don't do that yet by default.
-       This is a part that is distribution specific, so you will need
-to look into your init files. It will need to run just before the call
-to 'ifup' or 'ifconfig' command.
+       This is a part that is distribution-specific, so you will need
+to look into your own init files, or ask people familiar with your
+distribution. It will need to run just before the call to 'ifup' or
+'ifconfig' command.
 
-       In Debian 3.0, it needs to be run from /etc/init.d/networking,
-which is not the default. The necessary patch is below :
+       In Debian 3.0 and Debian Sarge, it needs to be run from
+/etc/init.d/networking, which is not the default. The necessary patch
+is below :
 
 ----------------------------------------------------------------
 --- networking-orig     Wed Feb 18 13:56:23 2004
@@ -240,13 +243,13 @@ which is not the default. The necessary patch is below :
          ifup -a
         echo "done."
 ----------------------------------------------------------------
-       Don't forget to set the appropriate path to call ifrename (see
-step (3) above).
+       Don't forget to set the appropriate path to the ifrename
+command (see step (3) above).
 
-       You may want to also set the proper options for ifrename
+       You may also want to also set the proper options for ifrename
 (check the man page).
-       The option '-p' enable module autoloading compatibility.
-       The default version of 'ifrename' also includes some specific
+       The option '-p' enables module autoloading compatibility.
+       The default version of 'ifrename' also includes some special
 Debian support : using "ifrename -p -d", only the proper modules are
 loaded. If you are using Debian, you should use this option.
 
@@ -255,14 +258,15 @@ loaded. If you are using Debian, you should use this option.
        As stated above, we use 'ifrename' to assign names to
 interfaces.
 
-       First, you need to get the MAC address of each of you
-interface. You can read it on the label on the card or display it
-using the 'ifconfig' command. Remember that the interface won't load
-yet with the proper name, so you may need to do a bit looking around :
+       First, you need to get the MAC address of each of your
+interfaces. You can read the MAC address on the label of the card, or
+display it using the 'ifconfig -a' command. Remember that the
+interface won't load yet with the proper name, so you may need to do a
+bit looking around :
 
 -----------------------------
-> modprobe pcnet32
-> ifconfig eth0
+# modprobe pcnet32
+# ifconfig eth0
 eth0      Link encap:Ethernet  HWaddr 00:10:83:34:BA:E5  
 [...]
 -----------------------------
@@ -282,33 +286,33 @@ eth3              mac 08:00:0E:*
 eth4           mac 00:10:83:*
 ---------------------------------------------
 
-       The '*' in the MAC address is a wildcard and allow me to
+       The '*' in the MAC address is a wildcard and allows me to
 replicate my configuration between multiple identical computers. If
-you have to manage large number of computers (like a rack of server or
-clusters), you may want to look at other selectors offered by
-'ifrename', such as the ability to base interface name on Bus
-Information.
+you have to manage large number of computers (like a rack of servers
+or clusters), then you may want to look at other selectors offered by
+'ifrename'.
 
        To test that ifrename works, do the following :
-               o load all your drivers, see section (2)
-               o check /proc/net/dev to see which interface exist
-               o bring all interfaces down : ifconfig ethX down
-               o run ifrename
-               o check each interface with ifconfig
+               o Load all your drivers, see section (2)
+               o Check /proc/net/dev to see which interface exist
+               o Bring all interfaces down : ifconfig ethX down
+               o Run ifrename
+               o Check each interface with ifconfig
+               o Bring all interfaces up : ifconfig ethX up
 
        6) Configuring interfaces
        -------------------------
        Most likely, your distribution is already doing this part
 properly. Just assign the proper IP and wireless configuration to each
-of the interface name you have chosen.
+of the interface names you have chosen.
        This part is distribution specific, and I already document it
 in the file DISTRIBUTIONS.txt.
 
        In Debian, you would need to modify the file
-/etc/network/interfaces like this :
+/etc/network/interfaces so that it looks something like this :
 
 --------- /etc/network/interfaces -----------
-# AMD AMD PCnet LANCE PCI card
+# AMD PCnet LANCE PCI card
 auto eth4
 iface eth4 inet dhcp
 
@@ -316,23 +320,22 @@ iface eth4 inet dhcp
 auto eth2
 iface eth2 inet static
     address 10.0.0.2
-    network 10.0.0.0
     netmask 255.255.255.0
     broadcast 10.0.0.255
     gateway 10.0.0.1
 ---------------------------------------------
 
        This was the last part. Now, at your next boot, all your
-interfaces should be assigned the proper name and proper
+interfaces should be assigned the proper name and the proper
 configuration.
 
 CONFIGURATION VIA HOTPLUG
 -------------------------
-       Dealing with removable interfaces is similar to built-in
-interfaces, the only difference is that we will use the Hotplug
-scripts instead of the init scripts. Another difference is that it
-will require more work on your part because most distributions are not
-fully ready for it.
+       Dealing with removable interfaces is similar to dealing with
+built-in interfaces, the main difference is that we will use the
+Hotplug scripts instead of the init scripts. Another difference is
+that it will likely require more work on your part because most
+distributions are not fully ready for it.
 
        1) Applicability
        ----------------
@@ -349,8 +352,8 @@ interfaces, although it may not be the best choice for them.
        --------------------
        Conceptually, Hotplug is very simple. When something
 interesting happens, the Linux kernel generates an Hotplug event. This
-run the proper script from the /etc/hotplug directory.
-       There is 3 types of Hotplug events we care about :
+runs the proper script from the /etc/hotplug directory.
+       There are 3 types of Hotplug events we care about :
                o PCI event : a CardBus device is added or removed
 from the system. The script /etc/hotplug/pci.agent is run.
                o USB event : a USB device is added or removed
@@ -362,41 +365,42 @@ removed from the system. The script /etc/hotplug/net.agent is run.
 following happens :
                1) Kernel detects new CardBus device
                2) Kernel generates PCI Hotplug event
-               3) /etc/hotplug/pci.agent runs, find proper driver module
+               3) /etc/hotplug/pci.agent runs, finds proper driver module
                4) /etc/hotplug/pci.agent loads driver module
                5) Driver module initialises, creates new network device
                6) Kernel detects new network device
                7) Kernel generates Network Hotplug event
-               8) /etc/hotplug/net.agent runs, configure network device
+               8) /etc/hotplug/net.agent runs, configures network device
        The sequence of events is similar for removals and USB devices.
 
-       3) Make ifup reentrant
-       ----------------------
+       3) Make sure ifup does not deadlock
+       -----------------------------------
        <Most people should ignore this part>
        The first problem is that we need to make sure the command
-'ifup' is fully reentrant. If the system has built-in interfaces, the
-'ifup' may reenter itself at boot time :
+'ifup' does not deadlock by calling itself re-entrantly. If the system
+has built-in interfaces, the 'ifup' may reenter itself at boot time
+via Hotplug :
                1) Init scripts start running
-               2) Init script calls 'ifup -a' to initialise built-in network
-                       interfaces
+               2) Init script calls 'ifup -a' to initialise built-in
+                       network interfaces
                3) 'ifup' auto-loads driver module for built-in network
                        interface 'eth4'
                4) Driver module initialises, creates new network device
                5) Kernel generates Network hotplug event
                6) /etc/hotplug/net.agent runs, call 'ifup eth4'
-       You can produce the same reentrancy if want to manually load
-module with the ifup command.
+       Note that you can produce the same reentrancy if you call ifup
+manually on an interface which module is not yet loaded.
 
-       The default version of 'ifup' for Debian 3.0 is not reentrant and
-may deadlock during boot or if you use it manually. The patch to make
-'ifup' properly reentrant is available here :
+       The default version of 'ifup' for Debian 3.0 and Debian Sarge
+is not reentrant and can therefore deadlock if not used properly. The
+patch to make 'ifup' properly reentrant is available here :
                http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=231197
-       Later version of Debian (Sarge and later) have some workaround
-that prevent deadlock in most case (but not fully eliminate them), so
-for normal use the default 'ifup' should work fine.
+       Contemporary versions of Debian (Sarge and later) have a
+net.agent script that contains workarounds to prevents deadlock
+situations, so for normal use the default 'ifup' should work fine.
 
-       Other distributions have very different version of ifup, and I
-have not tried those (tell me about it).
+       Other distributions have very different ifup programs and I
+have not tried those (tell me about it !).
 
        4) Installing Hotplug for Debian Sarge (testing/unstable)
        ---------------------------------------------------------
@@ -408,41 +412,53 @@ of the box'.
                o ifrename
 
        While the installation of Hotplug is simple, its configuration
-may seem complex. The current network Hotplug script has 3 modes,
-'all', 'auto' and 'hotplug', however for our purpose they all produce
-the same results when configured. This is controlled by the variable
-NET_AGENT_POLICY in /etc/default/hotplug.
-
-       In the mode "all", all interfaces are processed by
-'ifup'. This will work without further configuration.
-
-       In the mode "auto", only interfaces listed in a auto statement
-in /etc/network/interfaces will be processed by 'ifup'. If you choose
-this mode, you need to put in /etc/network/interfaces a statement auto
-with the complete list of all interfaces.
+may seem complex. The current network Hotplug script has 3 modes :
+'all', 'auto' and 'hotplug'. However for our purpose they all produce
+the same results when configured. This mode is controlled by the
+variable NET_AGENT_POLICY in /etc/default/hotplug.
+
+       In the mode "all", Hotplug will run ifup for all network
+events. This will result in failure messages if some interfaces have
+already been configured by the init scripts. This mode is not
+recommended.
+
+       In the mode "auto", Hotplug will run ifup only for those
+interfaces listed in a auto stanza in /etc/network/interfaces. If
+you choose this mode, you need to put in /etc/network/interfaces a
+"auto" line for the interfaces you want to control with hotplug.
 --------- /etc/network/interfaces -----------
 # Enable Hotplug support for "auto" mode (Sarge and later)
 auto eth0 eth1 eth2 eth3 eth4 wlan0 wlan1 prism0 prism1 airo0 airo1
 ---------------------------------------------
-       Unfortunately, this will make 'ifup' complain at boot time
-that it can't find those interfaces. This is why I don't recommend
-this mode.
+       This will result in some failure message at boot time, the
+init script will attempt to enable all those interfaces, and generate
+an error for all those not available at this time. It will also
+generate an error messages for interface which have already been
+configured by the init scripts. This mode is also not recommended.
 
        In the mode "hotplug", hotplug network events are ignored by
-ifup by default. To enable them, therefore making this mode equal to
-"all", you will need to add the following lines to
-/etc/network/interfaces :
+ifup by default. To enable them you will need to add the following
+lines to /etc/network/interfaces :
 --------- /etc/network/interfaces -----------
 # Enable Hotplug support for "hotplug" mode (Sarge and later)
 mapping hotplug
     script echo
 ---------------------------------------------
 
+       To enable them for only selected interfaces, e.g., ethA, make
+/etc/network/interfaces look like this :
+--------- /etc/network/interfaces -----------
+# Enable Hotplug support for "hotplug" mode (Sarge and later)
+mapping hotplug
+    script grep
+    map ethA
+---------------------------------------------
+
        5) Installing Hotplug for Debian 3.0
        ------------------------------------
        Debian 3.0 doesn't come by default with hotplug, but the
 hotplug package is available as regular Debian package (on the CD or
-downloadable via apt-get), so you can just install that.
+downloadable in Debian archive), so you can just install that.
 
        Unfortunately, this version of hotplug is not fully compatible
 with kernel 2.6.X. You will need to do the following modifications to
@@ -475,71 +491,67 @@ the file /etc/hotplug/net.agent.
 hotplug is much more basic, and doesn't have any scanning at boot time
 and doesn't need to be enabled in /etc/network/interfaces.
 
-       6) Installing hotplug, other cases
-       ----------------------------------
+       6) Installing hotplug on other distributions
+       --------------------------------------------
        The canonical version of hotplug is available at :
                http://linux-hotplug.sourceforge.net/
 
-       Most distributions have various version of hotplug with
-various modifications on top of the canonical version, and chances are
-that the canonical version won't completely work on your system.
-       All these various changing versions make it difficult for me
-to tell what exactly need to be changed in the hotplug scripts to make
-them work.
-
-       Some version of hotplug will do scan at boot time, see section
-(4) for my comments on this.
+       Most distributions have customized hotplug packages and
+chances are that the canonical version won't completely work on your
+system. All these various changing versions make it difficult for me
+to tell what exactly needs to be changed in the hotplug scripts to
+make them work. However, most should work out of the box.
 
-       My guess is that in a few release, all these problems will
+       My guess is that in a few releases, all these problems will
 sort themselves out. Just be patient.
 
        7) Dealing with 'init' hotplug
        ------------------------------
        In addition to the standard kernel Hotplug events, modern
 versions of the Hotplug scripts add init scripts that scan the system
-buses and generate pseudo Hotplug events. For the PCI buses, the
-script /etc/hotplug/pci.rc is run after the boot, for the USB bus,
+buses and generate pseudo Hotplug events at boot time. For the PCI
+buses, the script /etc/hotplug/pci.rc is run, for the USB bus,
 /etc/hotplug/usb.rc is run.
        The end result is that the Hotplug subsystem will also attempt
 to configure built-in devices :
                1) Kernel boots
                2) Init runs, start to initialise the OS
-               3) /etc/hotplug/pci.rc runs, generate pseudo Hotplug event
+               3) /etc/hotplug/pci.rc runs, generates pseudo Hotplug event
                4) /etc/hotplug/pci.agent loads driver module
                5) Driver module initialises, creates new network device
                6) Kernel generates Network Hotplug event
-               7) /etc/hotplug/net.agent runs, configure network device
+               7) /etc/hotplug/net.agent runs, configures network device
 
        At this point, you realise that at initialisation, both
 Hotplug and the regular init scripts (see "CONFIGURATION FROM INIT
 SCRIPTS") are trying to configure the same devices in parallel. This
-may create problem, and it is totally redundant.
+may create problems and is totally redundant.
        Another reason I don't like this mechanism is that it blindly
-attempt to load drivers for all hardware present on the system, and
-don't use the configuration in /etc/modules.conf to select the proper
-driver. It's fairly common to have multiple driver for some hardware,
-and because of Murphy's law, Hotplug will usually load the wrong
-one. It's also fairly common to have hardware on the system that
+attempts to load drivers for all hardware present on the system and
+doesn't use the module loader configuration files to select preferred
+drivers. It's fairly common to have multiple drivers for a given
+hardware, and because of Murphy's law, Hotplug will usually load the
+wrong one. It's also fairly common to have hardware on the system that
 doesn't need enabling (for example, the IDE controller on my SCSI
 machine), not loading the driver makes your kernel smaller and boot
 faster.
-       Unfortunately, Hotplug did not provide a simple way to disable
-such a feature. More importantly, there is no way to selectively
-disable it (let say, disabled for network, enabled for sound).
 
-       One way to disable this functionality is to delete or rename
-the files /etc/hotplug/pci.rc and /etc/hotplug/usb.rc.
+       Hotplug does have a way of disabling the loading of drivers
+on a case by case basis. Drivers listed in /etc/hotplug/blacklist
+will not be loaded.
+       Hotplug can be disabled for a whole subsystem by editing the
+appropriate .rc script in /etc/hotplug, or just deleting/renaming
+those files.
 
        8) Making hotplug scripts call ifrename
        ---------------------------------------
        The last hotplug step is to make sure that 'ifrename' is run
 by the hotplug subsystem at the right time. As before, we want to run
 it just before calling 'ifup'.
-       The latest version of the hotplug scripts have this
-integrated. However, you need to check that the path they use for
-calling 'ifrename' is the proper one on your system. And, for older
-versions of hotplug scripts, you will need to add this support
-yourself.
+       The latest version of the hotplug scripts have this feature
+integrated. However, you need to check that the path used for calling
+'ifrename' is the proper one on your system. And, for older versions
+of hotplug scripts, you will need to add this support yourself.
 
        Check the path for ifrename :
 --------------------------
@@ -557,10 +569,10 @@ yourself.
             # such as whether/how to invoke DHCP, set up bridging, etc.
  
 +           # Run ifrename as needed - Jean II
-+           # Remap interface names based on MAC address. This workaround
++           # Remap interface names based on MAC address. This workaround
 +           # the dreaded configuration problem "all my cards are 'eth0'"...
-+           # This needs to be done before ifup otherwise ifup will get
-+           # confused by the name changed and because iface need to be
++           # This needs to be done before ifup, otherwise ifup will get
++           # confused by the name change and because iface needs to be
 +           # down to change its name.
 +           if [ -x /sbin/ifrename ] && [ -r /etc/iftab ]; then
 +               debug_mesg invoke ifrename for $INTERFACE
@@ -576,11 +588,12 @@ yourself.
             if [ -x /sbin/ifup ]; then
 -------------------------------------------------
 
-       If your hotplug scrips already include ifrename support, you
-should find a section in /etc/hotplug/net.agent looking like the patch
-above. Otherwise, just cut'n'paste the patch above in the right place.
+       If your hotplug scripts already include ifrename support then
+you should find a section in /etc/hotplug/net.agent looking like the
+patch above. Otherwise, just cut'n'paste the patch above in the right
+place.
        The path for 'ifrename' is used twice above, so don't forget
-to modify both occurences...
+to modify both occurences.
 
 
        9) Loading driver modules
@@ -589,11 +602,11 @@ to modify both occurences...
        In theory, you don't need to do any specific configuration for
 the driver modules to be loaded. The 'pci.agent' and 'usb.agent'
 should load the right driver module for you.
-       Also, you don't need to define aliases in /etc/modprobe.conf,
-it's useless (and may be counter productive).
+       Also, you don't need to define aliases in /etc/modprobe.d/* or
+in /etc/modprobe.conf, it's useless and may be counterproductive.
 
-       If you use driver compiled statically in the kernel, you also
-have nothing to do.
+       If you use a driver compiled statically in the kernel, you
+also have nothing to do.
 
        10) Renaming interfaces
        -----------------------
@@ -609,8 +622,8 @@ prism*              mac 00:30:B4:*
 
        If you insert two cards, they would be named prism0 and
 prism1. Note that 'name wildcarding' is a feature only available in
-2.6.X, so if you use 2.4.X you will need to be explicit and list each
-card separatly :
+2.6.X and 2.4.30 and later, so if you use older version of 2.4.X you
+will need to be explicit and list each card separatly :
 
 --------- /etc/iftab -----------------------
 # SMC 2835W wireless CardBus card
@@ -622,7 +635,7 @@ prism1              mac 00:30:B4:64:27:8D
        -------------------------
        At this point, configuration of Hotplug interfaces is done
 just like their built-in counterparts. This part is still distribution
-specific, and still already document in the file DISTRIBUTIONS.txt..
+specific, and still already documented in the file DISTRIBUTIONS.txt.
 
        In Debian, you would need to modify the file
 /etc/network/interfaces like this :
@@ -630,12 +643,12 @@ specific, and still already document in the file DISTRIBUTIONS.txt..
 --------- /etc/network/interfaces -----------
 # Enable Hotplug support (Sarge and later)
 mapping hotplug
-    script echo
+    script grep
+    map prism0
 
 # SMC 2835W wireless CardBus card
 iface prism0 inet static
     address 10.0.1.2
-    network 10.0.1.0
     netmask 255.255.255.0
     broadcast 10.0.1.255
     wireless-essid THE_ESSID
@@ -643,53 +656,57 @@ iface prism0 inet static
     wireless-channel 5
 ---------------------------------------------
 
-       Now, just cross your finger and plug the card in the slot...
+       Note that you should not have wireless-* lines if you are
+using waproamd to set these parameters.
+
+       Now, just cross your fingers and plug the card in the slot...
 
 PCMCIA INTERFACES (16 bits)
 ---------------------------
        The Pcmcia subsystem has quite some legacy, and can use
-various configuration procedure. The Pcmcia subsystem fully use
-hotplug for 32 bits card (if you are using the kernel Pcmcia modules,
-which is the only option for 2.6.X). For 16 bits cards, we can't make
-them fully hotplug yet and need the cardmgr and /etc/pcmcia directory,
-however we can make their network configuration use hotplug.
+various configuration procedures. The Pcmcia subsystem exclusively
+uses hotplug for 32 bits cards (if you are using the kernel Pcmcia
+modules, which is the only option for 2.6.X). For 16 bit cards cardmgr
+is still required for managing the sockets and loading
+modules. Cardmgr is configured by files in the /etc/pcmcia directory.
 
        To use Hotplug network configuration with 16 bits Pcmcia
 cards, first make sure the Pcmcia subsystem is properly configured and
-that cardmgr load the right module (in most case, it should). Then,
-make sure that you don't have any configuration entries in
-/etc/pcmcia/network.opts and /etc/pcmcia/wireless.opts. Make sure that
-none of entries in your system network configuration use 'eth0' or
-'wlan0' (in /etc/network/interfaces for Debian users).
+that cardmgr loads the right driver module (in most case, it
+should). Then, make sure that you don't have any configuration entries
+in /etc/pcmcia/network.opts and /etc/pcmcia/wireless.opts. Make sure
+that none of the entries in your system network configuration use
+'eth0' or 'wlan0' (in /etc/network/interfaces for Debian users).
        Then, just follow the procedure described above for
 "Configuration Using Hotplug" to configure your network cards.
 
        You might want a little bit of explanation on why this magic
 will work (which would help in case it doesn't work).
-       There is two types of Pcmcia network configuration scripts,
-available as /etc/pcmcia/network. The original Pcmcia script configure
-network cards using options found in /etc/pcmcia/network.opts and
-/etc/pcmcia/wireless.opts. Most distributions replace it with a script
-calling 'ifup'. By making sure that network.opts and wireless.opts are
-"empty", we neutralise the first set of scripts. By making sure no
-system configuration uses 'eth0' or 'wlan0', we neutralise the second
-set of scripts, the script would call 'ifup' with the default
-interface name, which is usually 'eth0', ifup would not find a
-configuration for it and would just ignores it.
+       There are two types of Pcmcia network configuration scripts,
+available as /etc/pcmcia/network. The original Pcmcia script
+configures network cards using options found in
+/etc/pcmcia/network.opts and /etc/pcmcia/wireless.opts. Most
+distributions replace it with a script calling 'ifup'. By making sure
+that network.opts and wireless.opts are "empty", we neutralise the
+first set of scripts. By making sure no system configuration uses
+'eth0' or 'wlan0', we neutralise the second set of scripts, the script
+would call 'ifup' with the default interface name, which is usually
+'eth0', ifup would not find a configuration for it and would just
+ignore it.
        The card would still be configured because hotplug network
 events are generated for every interfaces, not only for devices
 managed by hotplug. So, net.agent would receive an event and perform
 the necessary steps to configure it.
 
        Personally, I'm still using the original Pcmcia scripts for my
-Pcmcia cards as described in the file PCMCIA.txt, because I will
-migrate my complex configurations over time.
+Pcmcia cards as described in the file PCMCIA.txt, because it still
+works and I will migrate my complex configurations over time.
        You can also decide to not use Hotplug for Pcmcia cards and
 modify the distribution Pcmcia scripts in /etc/pcmcia/* to handle
-Pcmcia cards properly. You would need to modify /etc/pcmcia/network to
-add 'ifrename' before 'ifup' the same way it was done for
-/etc/hotplug/net.agent. But, as in the long term Pcmcia will migrate
-to Hotplug, I would not bother...
+Pcmcia cards with ifrename. You would need to modify
+/etc/pcmcia/network to add 'ifrename' before 'ifup' the same way it
+was done for /etc/hotplug/net.agent. But, as in the long term Pcmcia
+will migrate to Hotplug, I would not bother...
 
 MANUAL LOADING, DOCKING STATIONS
 --------------------------------
@@ -705,18 +722,65 @@ not be enabled at boot time. It's also a good idea to disable Hotplug
 init scripts.
        With Debian, you just need to make sure that the 'auto"
 keyword doesn't apply to this interface.
+
+       If you use drivers statically built in the kernel, make sure
+that ifrename runs at boot time (see CONFIGURATION FROM INIT
+SCRIPTS). Once it's done, you can just enable and disable those
+interfaces with 'ifup ethX' and 'ifdown ethX'.
+
+       If you use both a modular system, make sure that the
+'on-demand' module loading is properly configured :
+
+--------- /etc/modprobe.d/local or /etc/modprobe.conf ------
+# HP 100VG J2585B PCI card
+alias eth2 hp100
+
+# AMD AMD PCnet LANCE PCI card
+alias eth4 pcnet32
+------------------------------------------------------------
+
+       Then, you should instruct 'ifup' to load module and use
+ifrename prior to configuring the interface, and remove the module
+when going down. With Debian, this is done with :
+
 --------- /etc/network/interfaces -----------
 # AMD AMD PCnet LANCE PCI card
+# noauto
 iface eth4 inet dhcp
+    pre-up /sbin/ifrename -p -n eth4
+    post-down /sbin/modprobe -r eth4
+
+# HP 100VG J2585B PCI card
+# noauto
+iface eth2 inet static
+    address 10.0.0.2
+    netmask 255.255.255.0
+    broadcast 10.0.0.255
+    gateway 10.0.0.1
+    pre-up /sbin/ifrename -p -n eth2
+    post-down /sbin/modprobe -r eth2
 ---------------------------------------------
 
-       If you use driver statically built in the kernel, you can just
-enable and disable those interfaces with 'ifup ethX' and 'ifdown ethX'.
+       We use the '-n' option of ifrename to specify the name of the
+interface after renaming. This assume that the mapping for those
+interfaces don't use wildcards. The '-p' option make sure ifrename
+probes the module prior to using it.
+       Using "modprobe -r" make sure that if the driver is composed
+of multiple module all the modules are unloaded.
+       
+       To enable the interface, just use :
+-----------------------------------
+ifup eth4
+-----------------------------------
+       And to disable the interface :
+-----------------------------------
+ifdown eth4
+-----------------------------------
 
-       If you use both a modular system and 'ifrename', you will need
-to change your habits when enabling those devices. The classical 'ifup
-ethX' won't work.
-       If you don't use Hotplug, you need to do :
+       This solution is obviously Debian specific, but could be
+adapted to other distributions. If you can't manage to get your
+distributions to use those tricks, you can do things manually.
+       If you don't use Hotplug, you enable an interface with :
 -----------------------------------
 modprobe eth4
 ifrename
@@ -726,19 +790,24 @@ ifup eth4
 -----------------------------------
 modprobe eth4
 -----------------------------------
-
-       On the other hand, disabling the interface has not changed :
+       On the other hand, disabling the interface is done with :
 -----------------------------------
 ifdown eth4
 modprobe -r eth4
 -----------------------------------
-       Using "modprobe -r" make sure that if the driver is composed
-of multiple module all the modules are unloaded.
+
 
        Docking stations for laptops may contain built-in
 interfaces. My previous laptop had one, and Linux had no support for
-it. To be able to simply manage my docking station, I had created two
-little scripts to enable and disable my network interface.
+it. After docking, I was able to bring up the network ISA card in the
+docking station.
+       However, with most laptops and version of Linux, the issue is
+that after docking, the new devices are not seen. The solutions is to
+force a rescan of the PCI bus. Documentation is unclear on that, maybe
+'scanpci' may help.
+
+       To be able to simply manage my docking station, I had created
+two little scripts to enable and disable my network interface.
        After docking, you would run :
 -------- /sbin/dock ----------------------------
 #!/bin/sh
@@ -756,6 +825,7 @@ modprobe -r eth4
 always be properly configured regardless of if you have a Pcmcia
 network card in the Pcmcia slot or not.
 
+
 SCHEMES (MULTI-CONFIG)
 ----------------------
        Most Ethernet cards will only connect to a single network, or
@@ -769,8 +839,8 @@ offer "overall" schemes changing the whole configuration. I document
 the support for schemes in various distributions in the file
 DISTRIBUTIONS.txt.
 
-       You can also use tools such as IfPlugd, WapRoamd or
-Wlandetect. Those tools are a kind of "wireless-DHCP", they attempt to
+       You can also use tools such as ifplugd, waproamd or
+wlandetect. Those tools are a kind of "wireless-DHCP", they attempt to
 automatically detect the proper wireless configuration and apply
 it. Most will also attempt to detect network changes.
        The main limitation of those tools is that they offer very
@@ -825,12 +895,14 @@ iface prism0-other inet static
 FIRMWARE LOADING
 ----------------
        A lot of modern wireless card don't have built in firmware and
-need firmware loading. Recent kernel (2.6.X) have a firmware
+need firmware loading. Recent kernels (2.6.X) have a firmware
 loader. These are a few notes on how to use it.
 
        First, read the documentation coming with your driver, because
 each driver has specificities (like the name of the firmware file it
-requires).
+requires). Some drivers may offer additional ways to load the
+firmware, but in the long term things should be standardised around
+the hotplug method to simplify packaging in distributions.
 
        You need to compile your kernel with firmware loading
 (CONFIG_FW_LOADER in "Generic Driver Options"). If your driver was
@@ -859,12 +931,12 @@ it into your /etc/hotplug directory (make sure it's executable).
        Note that firmware loading will usually only work with
 interfaces that are fully managed by Hotplug. This is the only way to
 ensure the that proper sequence of action is happening in the right
-order every time. Firmware loading will usually not work properly for
+order every time. Firmware loading may not work properly for
 interfaces configured in the init scripts.
        This means that if you have a built-in interface that require
 firmware loading, you should just use manage those interfaces like
 removable interfaces (see section above). However, interface
-configuration need to be explicitely triggered at boot time.
+configuration need to be explicitly triggered at boot time.
 
        One possibility is to set-up Hotplug to be run from the init
 script at boot time. This is usually an option for recent
@@ -874,9 +946,9 @@ have seen that this has some issues.
 script method and the hotplug method. First, you need to add an alias
 for the driver in /etc/modprobe.conf. Then, you need to specify a
 mapping for this interface in /etc/iftab, and specify a configuration
-for this interface and that that it is enabled at boot time. Lastly,
+for this interface and that it is enabled at boot time. Lastly,
 you make sure that the network init scripts run 'ifrename
--p'. 'Ifrename' will trigger the module to load, and all the Hotplug
+-p'. 'ifrename' will trigger the module to load, and all the Hotplug
 events will be generated properly to configure the interface.
 
 DEVICES WITH MULTIPLE NAMES
@@ -885,7 +957,7 @@ DEVICES WITH MULTIPLE NAMES
 the same device. A classical example is the Aironet driver that
 creates a 'ethX' and 'wifiY' for each card.
 
-       'ifrename' allow you a finer selection of interfaces than
+       'ifrename' allows you a finer selection of interfaces than
 'nameif'. For example, to only rename the pseudo-Ethernet network
 interface name of the Aironet driver, you would do :
 
@@ -898,16 +970,16 @@ airo*             mac 00:07:0E:* arp 1
 'wifi0'.
 
        You can rename both interfaces. You just need to remember that
-'ifrename' start matching from the last line of the file, so you would
-do :
+'ifrename' starts matching from the last line of the file, so you
+would do :
 --------- /etc/iftab -----------------------
 # Cisco Aironet 350 wireless Pcmcia card
 wifi*          mac 00:07:0E:*
 airo*          mac 00:07:0E:* arp 1
 ---------------------------------------------
 
-       The current version of 'ifrename' support only the most useful
-selectors, and is architectured such as adding selectors is relatively
+       The current version of 'ifrename' supports only the most useful
+selectors, but it is architectured such as adding selectors is relatively
 trivial. If you find a case that 'ifrename' can't handle, you should
 just extend it.
 
@@ -915,20 +987,20 @@ DEVICES WITHOUT MAC ADDRESSES
 -----------------------------
        Most Ethernet and Wireless devices have a fixed and unique MAC
 address, and it is therefore advised to name them based on this
-criteria. However, there is also network interfaces that don't have a
+criteria. However, there are also network interfaces that don't have a
 fixed and unique MAC address, for example Ethernet over USB, IP over
 FireWire, PPP and tunnel interfaces.
-       The driver for those devices create the interface with a name
+       The driver for those devices creates the interface with a name
 specific to the driver, such as ppp* for PPP interfaces and usb* for
 Ethernet over USB, and therefore they are easy to identify and
 configure, and few users feel the need to rename them. Moreover, some
 of them, such as PPP, have their own configuration scripts and
 methodology addressing their unique needs.
 
-       There is a few cases where you might want to rename interfaces
-withour MAC addresses. One example is two Ethernet over USB
+       There are a few cases where you might want to rename
+interfaces without MAC addresses. One example is two Ethernet over USB
 dongles. The way to do this is to use alternate ifrename
-selectors. Choosing the right selector depend on what you want to
+selectors. Choosing the right selector depends on what you want to
 achieve.
        A quick theoretical example to illustrate :
 --------- /etc/iftab -----------------------
@@ -945,14 +1017,14 @@ TROUBLESHOOTING
 you will need to find out why. First, you need to be familiar with the
 sequence of actions in the system and find which one did not happen.
 
-       You need to check if the driver module(s) was loaded using
+       You need to check that the driver module(s) was loaded using
 'lsmod'.
 
        You need to check if the interface was properly renamed with
 'ifrename'. You can use 'ifrename -D -V' to debug your /etc/iftab.
-       Get the the list of interfaces on your system with 'cat
-/proc/net/dev', and check if an interface is using the name you
-assigned or 'eth0'. Check any suspicious interfaces with 'ifconfig
+       Get the list of interfaces on your system with 'ifconfig -a'
+or 'cat /proc/net/dev', and check if an interface is using the name
+you assigned or 'eth0'. Check any suspicious interfaces with 'ifconfig
 eth0', and check its MAC address. Note that some rare drivers don't
 have a proper MAC address before brought up, which fools ifrename.
        Verify that no line in /etc/iftab matches the all-zero MAC
diff --git a/wireless_tools/IFRENAME-VS-XXX.txt b/wireless_tools/IFRENAME-VS-XXX.txt
new file mode 100644 (file)
index 0000000..3e6b8a0
--- /dev/null
@@ -0,0 +1,139 @@
+               Network interface renaming comparison
+               -------------------------------------
+
+INTRODUCTION
+------------
+       The Wireless Tools package includes 'ifrename', a tool to
+rename network interfaces. However, this is not the only solution to
+the problem of renaming network interfaces. This document explain the
+differences between ifrename and the various alternatives.
+           The subject of interface renaming may look simple at first
+glance, and is simple in 95% of the cases, however there are many
+complex scenario and those tools have many features, which explain why
+we need to go in more details than just saying 'tool X is better'.
+
+NAMEIF
+------
+       The tool 'nameif' was designed to rename network
+interfaces. It either loads mapping from the file /etc/mactab or
+accept mapping on the command line.
+       It is part of the net-tools package :
+               http://www.tazenda.demon.co.uk/phil/net-tools/
+
+       Advantages over 'ifrename' :
+               + More widespread, available in very old distributions
+               + simpler/smaller
+       Drawbacks compared to 'ifrename' :
+               - Only support MAC address selector
+               - Does not support hotplug invocation
+               - Does not support module on-demand loading
+       Comments :
+               o The fact that nameif does not support selector other
+than the MAC address is problematic, as USB-NET devices may not have
+MAC addresses and some ethernet/wireless drivers can't query the MAC
+address before 'ifconfig up'.
+               o 'ifrename' was designed as a better 'nameif', and
+its concept is very similar.
+
+IPROUTE
+-------
+       The tool 'ip' can rename network interfaces with the following
+syntax :
+               > ip link set <oldname> name <newname>
+       It is part of the 'iproute' package :
+               http://developer.osdl.org/dev/iproute2/
+
+       Advantages over 'ifrename' :
+               + integrated in 'iproute', which most people need anyway
+       Drawbacks compared to 'ifrename' :
+               - Do not support any selector, must use old interface name
+               - No 'batch' mode, must rename each interface manually
+       Comments :
+               o 'ip' only provide the most basic facility. To use it
+automatically, like in init/hotplug scripts, wrappers adding some
+rules/selector must be written.
+
+DRIVER MODULE PARAMETERS
+------------------------
+       Some network driver have module parameters enabling to specify
+the network name of all the devices created by the driver. This is
+driver specific, so you will need to check your driver.
+
+       Advantages over 'ifrename' :
+               + very simple to get configured and running
+       Drawbacks compared to 'ifrename' :
+               - Not universally supported : few drivers do it
+               - Fragmented : each driver does it differently
+               - The only selector available is the driver
+       Comments :
+               o This method was never popular with the kernel
+people, and this feature is being removed from driver that use to
+include it.
+
+UDEV
+----
+       The package 'udev' include facility to rename network
+interfaces, with rules such as :
+               KERNEL="eth*", SYSFS{address}="00:52:8b:d5:04:48", NAME="lan"
+       This is part of the udev package :
+               http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html
+
+       Advantages over 'ifrename' :
+               + integrated into 'udev'
+               + simpler to setup if 'udev' is already properly setup
+       Drawbacks compared to 'ifrename' :
+               - Less selectors that 'ifrename'
+               - Require kernel 2.6.X or later with sysfs support
+               - Do no support non-hotplug interfaces
+               - Require 'udev', not everybody uses it (static /dev, devfs)
+               - Does not support module on-demand loading
+       Comments :
+               o 'udev' support many selectors, basically all those
+present in 'sysfs', even if the documentation only show instructions
+to use the MAC address (which is problematic with virtual devices some
+drivers - see above). 'ifrename' can also use all selectors present in
+'sysfs' (like 'udev'), plus some other selectors not present in sysfs
+that were found to be useful.
+               o Not all interfaces are managed by hotplug. All
+virtual devices, such as tunnels and loopbacks, are not associated
+with a hardware bus, and therefore are not managed by hotplug. All
+driver compiled statically into the kernel are not managed by
+hotplug. 'udev' can't deal with those devices.
+               o It is common practice on embedded system to use a
+static /dev and not 'udev' to save space and boot time. And to not use
+hotplug for the same reasons.
+               o 'ifrename' could be better integrated in 'udev', I don't foresee any technical issues.
+
+SELECTOR AWARE NETWORK SCRIPTS
+------------------------------
+       Another method is to not rename the interface at all, and make
+the various network script selector aware. The basic idea is to simply
+ignore the interface name and have all the network scripts based on
+selectors.
+       The main example is the original Pcmcia network scripts. They
+allow you to configure an interface directly based on MAC address and
+Pcmcia socket. Another example is the script get-mac-address.sh used
+as a mapping in some Debian configuration. On the other hand, Red-Hat
+and Fedora scripts don't apply, as they wrap around 'nameif'.
+
+       Advantages over 'ifrename' :
+               + usually simpler to setup and understand
+       Drawbacks compared to 'ifrename' :
+               - Less selectors that 'ifrename'
+               - Only work for the scripts, other tools left confused
+       Comments :
+               o This method is conceptually simpler, and works
+well. It eliminates the two steps process of other methods (renaming ;
+configuring).
+               o Unfortunately, this method only apply to the
+specific scripts, and not to the majority of the networking tools
+which are still based on interface name. This means that when the user
+use those other tools, he is left guessing which interface is which.
+               o Distributions never never really embraced this
+method, as they all replaced the original Pcmcia scripts with one
+using the interfacename.
+
+       Have fun...
+
+       Jean
+
index b938fa6..9a1b980 100644 (file)
@@ -71,6 +71,10 @@ Other useful Makefile options :
        Note that you should pass the same command line options for
 all invocations of make ("make" and "make install").
 
+       If you want the absolute minimal footprint, you may want to
+look into the multicall version of the tools. You can build it with
+"make iwmulticall" and install it with "make install-iwmulticall".
+
 Old kernel with older Wireless Extensions :
 -----------------------------------------
        Kernel prior to 2.2.14 : Those kernels include Wireless
index a34aa31..bc4fbd6 100644 (file)
@@ -23,6 +23,10 @@ RANLIB = ranlib
 ## This is mostly useful for embedded platforms without maths.
 # BUILD_NOLIBM = y
 
+## Uncomment this to strip binary from symbols. This reduce binary size
+## by a few percent but make debug worse...
+# BUILD_STRIPPING = y
+
 # ***************************************************************************
 # ***** Most users should not need to change anything beyond this point *****
 # ***************************************************************************
@@ -43,7 +47,7 @@ PROGS= iwconfig iwlist iwpriv iwspy iwgetid iwevent ifrename
 MANPAGES8=iwconfig.8 iwlist.8 iwpriv.8 iwspy.8 iwgetid.8 iwevent.8 ifrename.8
 MANPAGES7=wireless.7
 MANPAGES5=iftab.5
-EXTRAPROGS= macaddr
+EXTRAPROGS= macaddr iwmulticall
 
 # Composition of the library :
 OBJS = iwlib.o
@@ -75,11 +79,18 @@ LDCONFIG = ldconfig
 # Do we want to build with or without libm ?
 ifdef BUILD_NOLIBM
   LIBS=
-  WELIB_FLAG = -DWE_NOLIBM=y
+  WELIB_FLAG= -DWE_NOLIBM=y
 else
   LIBS= -lm
 endif
 
+# Stripping or not ?
+ifdef BUILD_STRIPPING
+  STRIPFLAGS= -Wl,-s
+else
+  STRIPFLAGS=
+endif
+
 # Other flags
 CFLAGS=-Os -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow \
        -Wpointer-arith -Wcast-qual -Winline -I.
@@ -92,7 +103,7 @@ PICFLAG=-fPIC
 all:: $(IWLIB) $(PROGS)
 
 %: %.o
-       $(CC) $(LDFLAGS) $(XCFLAGS) -o $@ $^ $(LIBS)
+       $(CC) $(LDFLAGS) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LIBS)
 %.o: %.c wireless.h
        $(CC) $(XCFLAGS) -c $<
 %.so: %.c wireless.h
@@ -114,34 +125,27 @@ ifrename: ifrename.o $(IWLIB)
 
 macaddr: macaddr.o $(IWLIB)
 
+# Always do symbol stripping here
+iwmulticall: iwmulticall.o
+       $(CC) $(LDFLAGS) -Wl,-s $(XCFLAGS) -o $@ $^ $(LIBS)
+
 # It's a kind of magic...
 wireless.h:
        cp $(WEXT_HEADER) wireless.h
 
 # Compilation of the dynamic library
 $(DYNAMIC): $(OBJS:.o=.so)
-       $(CC) -shared -o $@ -Wl,-soname,$@ $(LIBS) -lc $^
+       $(CC) -shared -o $@ -Wl,-soname,$@ $(STRIPFLAGS) $(LIBS) -lc $^
 
 # Compilation of the static library
-$(STATIC): $(OBJS)
+$(STATIC): $(OBJS:.o=.so)
        $(RM) $@
        $(AR) cru $@ $^
        $(RANLIB) $@
 
-# So crude but so effective ;-)
+# Installation : So crude but so effective ;-)
 # Less crude thanks to many contributions ;-)
-install:: all $(IWLIB_INSTALL)
-       install -m 755 -d $(INSTALL_DIR)
-       install -m 755 $(PROGS) $(INSTALL_DIR)
-       install -m 755 -d $(INSTALL_INC)
-       install -m 644 iwlib.h $(INSTALL_INC)
-       install -m 644 wireless.h $(INSTALL_INC)
-       install -m 755 -d $(INSTALL_MAN)/man8/
-       install -m 644 $(MANPAGES8) $(INSTALL_MAN)/man8/
-       install -m 755 -d $(INSTALL_MAN)/man7/
-       install -m 644 $(MANPAGES7) $(INSTALL_MAN)/man7/
-       install -m 755 -d $(INSTALL_MAN)/man5/
-       install -m 644 $(MANPAGES5) $(INSTALL_MAN)/man5/
+install:: $(IWLIB_INSTALL) install-bin install-hdr install-man
 
 # Install the dynamic library
 install-dynamic:: $(DYNAMIC)
@@ -156,6 +160,35 @@ install-static:: $(STATIC)
        install -m 755 -d $(INSTALL_LIB)
        install -m 644 $(STATIC) $(INSTALL_LIB)
 
+# All the binaries. Careful, no dependancy on install-dynamic
+install-bin:: all
+       install -m 755 -d $(INSTALL_DIR)
+       install -m 755 $(PROGS) $(INSTALL_DIR)
+
+# Headers to go with the wireless lib (dev)
+install-hdr:: wireless.h
+       install -m 755 -d $(INSTALL_INC)
+       install -m 644 iwlib.h $(INSTALL_INC)
+       install -m 644 wireless.h $(INSTALL_INC)
+
+# How could you live without those manapages ?
+install-man::
+       install -m 755 -d $(INSTALL_MAN)/man8/
+       install -m 644 $(MANPAGES8) $(INSTALL_MAN)/man8/
+       install -m 755 -d $(INSTALL_MAN)/man7/
+       install -m 644 $(MANPAGES7) $(INSTALL_MAN)/man7/
+       install -m 755 -d $(INSTALL_MAN)/man5/
+       install -m 644 $(MANPAGES5) $(INSTALL_MAN)/man5/
+
+install-iwmulticall:: iwmulticall
+       install -m 755 -d $(INSTALL_DIR)
+       install -m 755 $< $(INSTALL_DIR)/iwconfig
+       ( cd $(INSTALL_DIR) ; \
+         ln -f -s iwconfig iwlist ; \
+         ln -f -s iwconfig iwspy ; \
+         ln -f -s iwconfig iwpriv ; \
+         ln -f -s iwconfig iwgetid )
+
 clean::
        $(RM_CMD) 
 
index 9225585..32a478a 100644 (file)
@@ -1,8 +1,8 @@
        Pcmcia Wireless configuration
        -----------------------------
 
-       One of the most exciting thing having happen after release 20
-is the addition of Wireless Extension support in the Pcmcia init
+       One of the most exciting things having happen after release 20
+is the addition of Wireless Tools support in the Pcmcia init
 scripts. Here is a quick intro on the subject...
 
 Pre-requisite :
@@ -14,11 +14,11 @@ Pre-requisite :
 
 Raylink driver :
 --------------
-       The Raylink driver as of 1.70 doesn't support yet writable
+       The Raylink driver as of 1.70 doesn't support writable
 Wireless Extensions, so enabling wireless.opts on this driver will
-make thing worse.
+make things worse.
        On the other hand, the latest version of the Raylink driver
-accept Wireless Extensions at boot time, so the procedure described
+accepts Wireless Extensions at boot time, so the procedure described
 below will work.
 
 Distribution specific notes :
@@ -36,7 +36,7 @@ proper init scripts and those instructions will apply.
 
 Basic support :
 -------------
-       The file /etc/pcmcia/wireless.opts contain some templates for
+       The file /etc/pcmcia/wireless.opts contains some templates for
 the most common drivers. Just fill in your card configuration in the
 template corresponding to your driver configuration.
        Then, to activate it, you just need to remove or comment the 4
@@ -75,13 +75,13 @@ esac
 
 Scheme support :
 --------------
-       The file wireless.opts fully support schemes. This allow you
+       The file wireless.opts fully supports schemes. This allow you
 to define different configurations (home, work...) and to switch on
 the fly between them.
        The best way to explain it is to show an example.
        Let's say you have an infrastructured setup at work (MY_WORK)
-and an adhoc network at home (MY_HOME). Moreover, when a specific card
-is inserted, you want it to be in adhoc mode (TEST). The work setup
+and an Ad-Hoc network at home (MY_HOME). Moreover, when a specific card
+is inserted, you want it to be in Ad-Hoc mode (TEST). The work setup
 will be the default...
 
        Each Wireless LAN will have the following configuration :
index b4bb19b..55341bf 100644 (file)
@@ -16,7 +16,7 @@ Precompiled version :
 -------------------
        Most Linux distributions offer precompiled package containing
 these tools. And many of them preinstall them by default. On the other
-hand, installation of this package is (now) easy and allow you to get
+hand, installation of this package is (now) easy and allows you to get
 a more up-to-date version.
 
 INSTALL
@@ -26,7 +26,7 @@ INSTALL
 
 DISTRIBUTION.txt
 ----------------
-       This file will document how to configure wireless cards at
+       This file documents how to configure wireless cards at
 boot time with various Linux distributions (using Wireless
 Extensions). Please read it carefully before asking questions.
        In this file, I try to collect all the specifics of Wireless
@@ -35,7 +35,7 @@ your help to complete this file.
 
 HOTPLUG.txt
 -----------
-       This file document how to manage and configure removable
+       This file documents how to manage and configure removable
 wireless cards using Hotplug. This is more advanced than the simple
 procedures of DISTRIBUTION.txt. This is currently mostly Debian
 specific, but I hope you will contribute for other distributions.
@@ -65,8 +65,8 @@ read locally with the command :
 localised man pages (fr/*)
 -------------------
        Localised man pages are not made by me, therefore the only
-localisations available are those sent to me by courageous volonteers
-and are expect those man pages to 'lag' compared to the english
+localisations available are those sent to me by courageous volonteers,
+and I expect those man pages to 'lag' compared to the english
 version (i.e. not have all the latest updates). Translating man pages
 is not a very gratifying task, especially due to my broken english,
 and many technical terms don't translate well to other languages, so
@@ -84,7 +84,7 @@ iwlist.c
 
 iwspy.c
 -------
-       Mobile IP support test and allows get get stats per MAC
+       Mobile IP support test and allows to get stats per MAC
 address (instead of globally). Also, for some drivers/devices, this is
 the only way to get stats in Ad-Hoc mode.
 
@@ -100,8 +100,8 @@ iwgetid.c
 
 iwevent.c
 ---------
-       Display Wireless Events. This is new, so there is not much support
-in drivers for it yet...
+       Display Wireless Events. Most recent drivers will support this
+relatively new feature, but some older drivers may not support it.
 
 ifrename.c :
 ----------
@@ -131,7 +131,7 @@ your kernel/drivers are old, you may want to try the older releases...
 sample_xxx.c :
 ------------
        Various samples of code showing how to implement some of the
-more tricky feature of Wireless Extensions in your driver.
+more tricky features of Wireless Extensions in your driver.
        Note that there is no guarantee that this code compiles, let
 alone works, but it should point you in the proper direction.
        Also, have a look at existing drivers in the Linux kernel.
diff --git a/wireless_tools/cs/ifrename.8 b/wireless_tools/cs/ifrename.8
new file mode 100644 (file)
index 0000000..b524c47
--- /dev/null
@@ -0,0 +1,158 @@
+.\" Jean II - HPL - 2004
+.\" ifrename.8
+.\"
+.TH IFRENAME 8 "1.bøezen 2004" "wireless-tools" "Linux - Manuál programátora"
+.\"
+.\" NAME part
+.\"
+.SH JMÉNO
+ifrename \- Pøejmenuje sí»ová rozhraní v závislosti na rùzných statických kritériích
+.\"
+.\" SYNOPSIS part
+.\"
+.SH SYNTAXE
+.B "ifrename [-c configfile] [-p] [-d] [-v] [-V] [-D]"
+.br
+.B "ifrename [-c configfile] [-i interface] [-n newname]"
+.\"
+.\" DESCRIPTION part
+.\"
+.SH POPIS
+.B Ifrename 
+je nástroj, který umo¾òuje pøiøadit stálý název pro ka¾dé
+sí»ové rozhraní.
+.PP
+Ve výchozím stavu jsou názvy rozhraní dynamické a ka¾dému sí»ovému rozhraní
+je pøiøazen první dostupný název
+.RI ( eth0 ", " eth1 "...)."
+Poøadí, v kterém jsou sí»ová rozhraní vytváøena, se mù¾e li¹it. U zabudovaných
+rozhraní závisí na jejich rozpoznání kernelem pøi spou¹tìní. Výmìnná zaøízení mù¾e
+u¾ivatel pøipojit v jakémkoliv poøadí.
+.PP
+.B Ifrename
+umo¾òuje u¾ivateli rozhodnout, jaký název bude sí»ové rozhraní mít.
+.B Ifrename 
+mù¾e vyu¾ít celou øadu
+.IR voleb ", "
+aby urèil, jak jsou názvy rozhraní pøiøazovány sí»ovým rozhraním v systému.
+Nejbì¾nìj¹í volbou je  
+.IR "MAC adresa" 
+rozhraní.
+.PP
+.B Ifrename
+musí být spu¹tìn pøedtím, ne¾ jsou rozhraní aktivována, proto je vìt¹inou pou¾íván
+v rùzných skriptech (init, hotplug), ale jen zøídka pøímo u¾ivatelem.
+Jako výchozí,
+.B ifrename 
+pøejmenuje v¹echna rozhraní pøítomná v  systému pou¾itím namapování definovaného v
+.IR /etc/iftab .
+.\"
+.\" PARAMETER part
+.\"
+.SH PARAMETRY
+.TP
+.BI "-c " konfiguracni_soubor
+Nastaví konfiguraèní soubor, který bude pou¾it (výchozí je 
+.IR /etc/iftab ).
+Konfiguraèní soubor definuje namapování voleb a názvù rozhraní
+a je popsán v
+.IR iftab (5).
+.br
+Pokud je
+.I konfiguracni_soubor
+urèen jako "-", je konfigurace naètena ze stdin.
+.TP
+.B -p
+Pokusí se zavést moduly jádra pøed pøejmenováním rozhraní. Jako výchozí 
+prochází
+.B ifrename 
+pouze rozhraní, která jsou ji¾ zavedena a nezavádí automaticky po¾adované
+jaderné moduly. Tento pøepínaè umo¾òuje hladkou integraci se systémem, který
+nezavádí moduly pøed voláním
+.BR ifrename .
+.TP
+.B -d
+Povolí rùzné úpravy specifické pro
+.B Debian. 
+V kombinaci s
+.BR -p
+budou zavedeny pouze moduly pro rozhraní urèená v
+.I /etc/network/interface
+.
+.TP
+.BI "-i " rozhraní
+Pøejmenuje pouze urèené
+.IR rozhraní ,
+místo v¹ech rozhraní v systému. Vypí¹e nový název rozhraní.
+.TP
+.BI "-n " novy_nazev
+Kdy¾ je pou¾ito spolu s 
+.IR -i ,
+urèí nový název rozhraní. Seznam namapování z konfiguraèního
+souboru je ignorován, rozhraní urèené pomocí 
+.I -i
+je rovnou pøejmenováno na
+.IR novy_nazev 
+Nový název mù¾e být ¾olík (wildcard), ale mù¾e obsahovat pouze jedinou "*".
+.br
+Pokud je pou¾it bez
+.IR -i ,
+pøejmenuje rozhraní s pou¾itím pouze tìch namapování, která by je pøejmenovala na
+.IR novy_nazev .
+Nový název nesmí být ¾olík. Tento zpùsob pou¾ití ifrename 
+.RI ( -n " bez " -i )
+není doporuèen, proto¾e je neefektivní. Musejí být zpracována v¹echna rozhraní systému, 
+a proto není ve vìt¹inì pøípadù rychlej¹í ne¾ kdyby je ifrename pøejmenovalo v¹echny (bez
+.IR -n " a zároveò bez " -i ).
+.TP
+.B -t
+Povolí podporu pøevzetí názvù. To umo¾ní výmìnu názvù rozhraní
+mezi dvìma èi více rozhraními.
+.br
+Pøevzetí umo¾òuje rozhraní "ukrást" název jinému rozhraní.
+To funguje pouze s jádrem 2.6.x a pokud druhé rozhraní nebì¾í.
+Tímpádem není kompatibilní s Hotplug. Druhému rozhraní je pøiøazen
+náhodný název, který lze pozdìji pomocí "ifrename" zmìnit.
+.br
+Poèet pøevzetí je omezen, aby se zabránilo nekoneèným smyèkám,
+a proto nemusejí být nìkteré komplexní vícecestné situace správnì zpracovány.
+.br
+V ka¾dém pøípadì není pøevod názvù a ani pou¾ívání této mo¾nosti doporuèeno,
+je lep¹í zvolit pro rozhraní jedineèné a jednoznaèné názvy...
+.TP
+.B -D
+Re¾im dry-run ("naneèisto"). Ifrename nezmìní ¾ádné rozhraní, pouze vypí¹e
+nový název rozhraní, pokud je to mo¾né, a skonèí.
+.br
+V re¾imu dry-run nejsou øe¹eny wildcards. Nový název rozhraní je vyti¹tìn
+i v pøípadì, ¾e je stejný jako pùvodní název.
+.TP
+.B -V
+U¾vanìný re¾im. Ifrename zobrazí interní výsledky prùchodu svým
+konfiguraèním souborem a dotazy na volby rozhraní. V kombinaci s
+pøepínaèem
+.I dry-run
+pøedstavuje dobrý zpùsob debugování komplexních nastavení nebo triviálních
+problémù.
+.\"
+.\" AUTHOR part
+.\"
+.SH AUTOR
+Jean Tourrilhes \- jt@hpl.hp.com
+.\"
+.\" TRANSLATION part
+.\"
+.SH PØEKLAD
+Pavel Heimlich \- tropikhajma@seznam.cz, bøezen 2005 (wireless_tools.28pre4).
+.\"
+.\" FILES part
+.\"
+.SH SOUBORY
+.I /etc/iftab
+.\"
+.\" SEE ALSO part
+.\"
+.SH DAL©Í INFORMACE
+.BR ifconfig (8),
+.BR ip (8),
+.BR iftab (5).
diff --git a/wireless_tools/cs/iftab.5 b/wireless_tools/cs/iftab.5
new file mode 100644 (file)
index 0000000..869b7c7
--- /dev/null
@@ -0,0 +1,189 @@
+.\" Jean II - HPL - 2004
+.\" iftab.5
+.\"
+.TH IFTAB 5 "1.bøezen 2004" "wireless-tools" "Linux - Manuál programátora"
+.\"
+.\" NAME part
+.\"
+.SH JMÉNO
+iftab \- statické informace o sí»ových rozhraních
+.\"
+.\" DESCRIPTION part
+.\"
+.SH POPIS
+Soubor
+.B /etc/iftab
+obsahuje popisnou informaci o rùzných sí»ových rozhraních.
+.B iftab
+je pou¾íván pouze programem
+.IR ifrename (8)
+k pøiøazení stálých názvù sí»ových rozhraní ka¾dému sí»ovému rozhraní.
+.PP
+.B /etc/iftab
+definuje sadu
+.IR namapování .
+Ka¾dé namapování obsahuje název rozhraní a sadu deskriptorù.
+Deskriptory umo¾òují
+.B ifrename
+identifikovat ka¾dé sí»ové rozhraní v  systému. Pokud sí»ové rozhraní odpovídá
+v¹em deskriptorùm z namapování,
+.B ifrename
+se pokusí zmìnit název rozhraní na název urèený v namapování.
+.\"
+.\" MAPPINGS part
+.\"
+.SH NAMAPOVÁNÍ
+Ka¾dé namapování je popsáno na zvlá¹tní øádce, zaèínající
+.IR "interface name" ,
+(názvem rozhraní) a obsahuje sadu
+.IR deskriptorù ,
+oddìlených mezerami nebo tabulátory.
+.PP
+Vztah mezi deskriptory v namapování je
+.IR "logické a" .
+Namapování odpovídá sí»ovému rozhraní, pouze kdy¾ odpovídají v¹echny deskriptory.
+Pokud sí»ové rozhraní nepodporuje urèitý deskriptor, nebude vyhovovat ¾ádnému
+namapování pou¾ívajícímu tento deskriptor.
+.PP
+Pokud je potøeba pou¾ít alternativní deskriptory pro název rozhraní
+(logické nebo), vytvoøte dvì rùzná namapování se stejným názvem rozhraní
+(na ka¾dém øádku jednu).
+.B Ifrename
+v¾dycky pou¾ije první odpovídající namapování od
+.I konce
+.BR iftab ,
+proto by restriktivnìj¹í namapování mìla být uvedena naposled.
+.\"
+.\" INTERFACE NAME part
+.\"
+.SH NÁZEV ROZHRANÍ
+První èástí ka¾dého namapování je název rozhraní. Pokud sí»ové rozhraní
+odpovídá v¹em deskriptorùm v namapování,
+.B ifrename
+se pokusí zmìnit název rozhraní na název urèený v namapování.
+.PP
+Název rozhraní v namapování je buïto pouhý název rozhraní (jako tøeba
+.IR eth2 " nebo " wlan0 )
+nebo ¹ablona obsahující jediného ¾olíka (wildcard) (napø.
+.IR eth* " nebo " wlan* ).
+V pøípadì ¾olíka nahradí jádro znak "*" za nejni¾¹í dostupné
+celé èíslo, které zajistí jedineènost názvu rozhraní.
+.\"
+.\" DESCRIPTORS part
+.\"
+.SH DESKRIPTORY
+Ka¾dý deskriptor je slo¾en z názvu deskriptoru a hodnoty deskriptoru.
+Deskriptory urèují statické vlastnosti sí»ového rozhraní, jejich
+cílem je jednoznaènì identifikovat ka¾dý kus hardware.
+.PP
+Vìt¹ina u¾ivatelù pou¾ije pouze volbu
+.B mac
+, ostatní volby jsou urèeny k zvlá¹tním nastavením.
+.TP
+.BI mac " MAC adresa"
+Porovná MAC adresu rozhraní se zadanou MAC adresou. MAC adresu
+rozhraní je mo¾né zobrazit pomocí
+.IR ifconfig (8)
+nebo
+.IR ip (8).
+Zadaná MAC adresa mù¾e 
+obsahovat "*" pro výbìr ¾olíkù (wildcards).
+.br
+Je to nejbì¾nìj¹í volba, proto¾e vìt¹ina rozhraní má unikátní MAC
+adresu, která umo¾òuje sí»ové rozhraní jednoznaènì identifikovat.
+Nicménì nìkterá rozhraní nemají MAC adresu, dokud nejsou aktivována
+a v takovém pøípadì je u¾ití tohoto selektoru o¹idné.
+.TP
+.BI arp " typ arp"
+Porovná typ ARP (ARP Type)(také zvané "Link Type") rozhraní se zadaným typem ARP.
+Typ ARP u rozhraní je mo¾né zobrazit pomocí
+.IR ifconfig (8)
+nebo
+.IR ip (8).
+.br
+Tento selektor je u¾iteèný pokud ovladaè vytváøí více sí»ových rozhraní
+pro jedinou sí»ovou kartu.
+.TP
+.BI driver " název ovladaèe"
+Porovná název ovladaèe rozhraní se zadaným názvem ovladaèe.
+Název ovladaèe rozhraní je mo¾né zobrazit pomocí
+.IR "ethtool -i" (8).
+.TP
+.BI businfo " informace o sbìrnici"
+Porovná informaci o sbìrnici rozhraní rozhraní se zadanou informací
+o sbìrnici. Informaci o sbìrnici rozhraní je mo¾né zobrazit pomocí
+.IR "ethtool -i" (8).
+.TP
+.BI firmware " verze firmware"
+Porovná verzi firmware rozhraní s informací o verzi firmware.
+Revizi firmware rozhraní je mo¾né zobrazit pomocí
+.IR "ethtool -i" (8).
+.TP
+.BI baseaddress " port"
+Porovná port rozhraní se zadaným portem. Port rozhraní je mo¾né zobrazit pomocí
+.IR ifconfig (8).
+.br
+Proto¾e vìt¹ina karet pou¾ívá dynamické pøidìlování portù, je
+tato volba u¾iteèná pouze pro ISA a EISA karty.
+.TP
+.BI irq " èíslo pøeru¹ení"
+Porovná èíslo pøeru¹ení (IRQ) rozhraní se zadaným
+èíslem pøeru¹ení. Èíslo pøeru¹ení rozhraní je mo¾né zobrazit pomocí
+.IR ifconfig (8).
+.br
+Proto¾e pøeru¹ení mohou být sdílená, obvykle tento selektor nestaèí
+k jednoznaèné identifikaci rozhraní.
+.TP
+.BI iwproto " bezdrátový protokol"
+Porovná bezdrátový protokol rozhraní se zadaným
+bezdrátovým protokolem. Bezdrátový protokol rozhraní je mo¾né zobrazit pomocí
+.IR iwconfig (8).
+.br
+Tato volba je podporována pouze na bezdrátových rozhraních a nestaèí
+k jednoznaèné identifikaci rozhraní.
+.TP
+.BI pcmciaslot " pcmcia slot"
+Porovná èíslo Pcmcia socketu rozhraní se zadaným èíslem slotu. Èíslo Pcmcia socketu
+rozhraní je mo¾né zobrazit pomocí
+.IR "cardctl ident" (8).
+.br
+Tato volba je obvykle podporována pouze na 16 bitových kartách, pro 32 bitové
+karty je lep¹í pou¾ít selektor
+.BR businfo .
+.\"
+.\" EXAMPLE part
+.\"
+.SH PØÍKLAD
+# Toto je komentáø
+.br
+eth2           mac 08:00:09:DE:82:0E
+.br
+eth3           driver wavelan irq 15 baseaddress 0x390
+.br
+eth4           driver pcnet32 businfo 0000:02:05.0
+.br
+air*           mac 00:07:0E:* arp 1
+.\"
+.\" AUTHOR part
+.\"
+.SH AUTOR
+Jean Tourrilhes \- jt@hpl.hp.com
+.\"
+.\" TRANSLATION part
+.\"
+.SH PØEKLAD
+Pavel Heimlich \- tropikhajma@seznam.cz, bøezen 2005 (wireless_tools.28pre4).
+.\"
+.\" FILES part
+.\"
+.SH SOUBORY
+.I /etc/iftab
+.\"
+.\" SEE ALSO part
+.\"
+.SH DAL©Í INFORMACE
+.BR ifrename (8),
+.BR ifconfig (8),
+.BR ip (8),
+.BR ethtool (8),
+.BR iwconfig (8).
diff --git a/wireless_tools/cs/iwconfig.8 b/wireless_tools/cs/iwconfig.8
new file mode 100644 (file)
index 0000000..712eacd
--- /dev/null
@@ -0,0 +1,535 @@
+.\" Jean II - HPLB - 1996 => HPL - 2004
+.\" iwconfig.8
+.\"
+.TH IWCONFIG 8 "22.èervna 2004" "wireless-tools" "Linux - Manuál programátora"
+.\"
+.\" NAME part
+.\"
+.SH JMÉNO
+iwconfig \- nastavuje rozhraní bezdrátové sítì
+.\"
+.\" SYNOPSIS part
+.\"
+.SH SYNTAXE
+.BI "iwconfig [" rozhraní ]
+.br
+.BI "iwconfig " rozhraní " [essid " X "] [nwid " N "] [mode " M "] [freq " F "]
+.br
+.BI "                   [channel " C ] [sens " S "] [ap " A "] [nick " NN ]
+.br
+.BI "                   [rate " R "] [rts " RT "] [frag " FT "] [txpower " T ]
+.br
+.BI "                   [enc " E "] [key " K "] [power " P "] [retry " R ]
+.br
+.BI "                   [commit]
+.br
+.BI "iwconfig --help"
+.br
+.BI "iwconfig --version"
+.\"
+.\" DESCRIPTION part
+.\"
+.SH POPIS
+.B Iwconfig
+je podobný pøíkazu
+.IR ifconfig (8),
+ale je vìnovaný bezdrátovým rozhraním. Je pou¾íván k nastavení tìch parametrù 
+sí»ových rozhraní, které jsou specifické pro bezdrátový provoz (napø. frekvence).
+.B Iwconfig
+mù¾e být také pou¾it k zobrazení tìchto parametrù a bezdrátových
+statistik (získaných z
+.IR /proc/net/wireless ).
+.PP
+V¹echny tyto parametry a statistiky jsou závislé na zaøízení. Ka¾dý ovladaè
+poskytuje, v závislosti na hardwarové podpoøe, jen nìkteré z nich
+a rozsah hodnot se mù¾e mìnit. Prosím obracejte se na manuálové stránky
+jednotlivých zaøízení pro dal¹í detaily.
+.\"
+.\" PARAMETER part
+.\"
+.SH PARAMETRY
+.TP
+.B essid
+Nastaví ESSID (nebo Network Name - u nìkterých produktù mù¾e být nazváno
+Domain ID). ESSID se pou¾ívá k identifikaci bunìk, které jsou
+souèástí stejné virtuální sítì.
+.br
+Na rozdíl od adresy AP nebo NWID, která urèuje jedinou buòku, ESSID
+urèuje skupinu bunìk, spojených opakovaèi (repeater) nebo infrastrukturou,
+mezi kterými mù¾e u¾ivatel transparentnì pøecházet.
+.br
+U nìkterých karet je mo¾né vypnout kontrolu ESSID (promiskuitní ESSID)
+pomocí
+.IR off " nebo " any " (a " on
+k opìtovnému zapnutí).
+.br
+Pokud je ESSID sítì jedním z klíèových slov
+.RI ( off ", " on " nebo " any ),
+pou¾ije se
+.I --
+.br 
+.B Pøíklady:
+.br
+.I "   iwconfig eth0 essid any"
+.br
+.I "   iwconfig eth0 essid ""Moje sit""
+.br
+.I "   iwconfig eth0 essid -- ""ANY""
+.TP
+.BR nwid / domain
+Nastaví Network ID (u nìkterých produktù mù¾e být nazváno Domain ID).
+Proto¾e v¹echny sousedící bezdrátové sítì sdílejí stejné médium, je
+tento parametr pou¾íván k jejich rozli¹ení (tvorbì logických kolokovaných
+sítí) a identifikaci nodù patøících do stejné buòky.
+.br
+Tento parametr se pou¾ívá pouze u pre-802.11 zaøízení. Protokol 802.11
+pou¾ívá pro tuto funkci ESSID a adresu AP.
+.br
+U nìkterých karet je mo¾né vypnout kontrolu Network ID (promiskuitní NWID)
+pomocí 
+.IR off " (a " on
+k opìtovnému zapnutí).
+.br
+.B Pøíklady:
+.br
+.I "   iwconfig eth0 nwid AB34
+.br
+.I "   iwconfig eth0 nwid off"
+.TP
+.BR freq / channel
+Nastaví pracovní frekvenci nebo kanál zaøízení. Hodnota ni¾¹í ne¾ 1000
+znamená èíslo kanálu, hodnota vy¹¹í ne¾ 1000 je frekvence v Hz.
+Je mo¾né pøipojit k hodnotì pøíponu k, M nebo G (napøíklad "2.46G" pro
+frekvenci 2,46 GHz), nebo doplnit dostateèný poèet nul.
+.br
+Kanály jsou obvykle èíslovány od 1, je mo¾né pou¾ít
+.IR iwlist (8)
+k získání celkového poètu kanálù, seznamu dostupných frekvencí a zobrazení souèasné
+frekvence jako kanálu. V závislosti na pøedpisech mohou být nìkteré frekvence/kanály
+nedostupné.
+.br
+.B Pøíklady:
+.br
+.I "   iwconfig eth0 freq 2422000000"
+.br
+.I "   iwconfig eth0 freq 2.422G"
+.br
+.I "   iwconfig eth0 channel 3"
+.TP
+.B sens
+Nastaví práh citlivosti. To je nejni¾¹í úroveò síly signálu pøi které
+hardware pova¾uje pøijaté pakety za pou¾itelné. Kladné hodnoty jsou
+interpretovány jako hodnota pou¾ívaná hardwarem nebo jako procenta,
+negativní hodnoty jako dBm. V závislosti na hardwarové implementaci mù¾e
+mít tento parametr dal¹í funkce.
+.br
+Tento parametr mù¾e ovládat práh pøíjmu (receive threshold) - nejni¾¹í úroveò signálu
+pøi které se hardware pokusí o pøíjem paketu, slab¹í signál je ignorován. Mù¾e také
+nastavovat práh ústupu (defer threshold) - nejni¾¹í úroveò signálu, od které hardware 
+pova¾uje kanál za obsazený. Pøi správném nastavení tìchto prahù karta neztrácí èas 
+pøíjmen ¹umu. U moderních zaøízení se zdá, ¾e tyto prahy regulují automaticky.
+.br
+U moderních karet mù¾e tento parametr ovládat práh pøedání (handover/roaming
+threshold) - nejni¾¹í úroveò signálu pøi které hardware je¹tì zùstane asociováno se
+souèasným pøístupovým bodem. Pokud úroveò signálu poklesne pod tuto hodnotu, 
+zaène karta hledat nový/lep¹í pøístupový bod.
+.br
+.B Pøíklad:
+.br
+.I "   iwconfig eth0 sens -80"
+.TP
+.B mode
+nastaví pracovní re¾im zaøízení, co¾ závisí na topologii sítì.
+Re¾im mù¾e být
+.I Ad-Hoc
+(sí» slo¾ená pouze z jedné buòky a bez pøístupového bodu),
+.I Managed
+(node se pøipojuje do sítì slo¾ené z mnoha pøístupových bodù, s roamingem),
+.I Master
+(node je synchronisation master nebo slou¾í jako pøístupový bod),
+.I Repeater
+(node pøedává pakety mezi ostatními bezdrátovými nody),
+.I Secondary
+(node slou¾í jako zálo¾ní master/repeater),
+.I Monitor
+(node není asociován s ¾ádnou buòkou a pasivnì monitoruje pakety na frekvenci) nebo
+.IR Auto .
+.br
+.B pøíklad:
+.br
+.I "   iwconfig eth0 mode Managed"
+.br
+.I "   iwconfig eth0 mode Ad-Hoc"
+.TP
+.B ap
+Naøídí kartì pøipojit se k pøístupovému bodu urèenému adresou,
+pokud je to mo¾né. Pokud se kvalita spojení pøíli¹ sní¾í,
+mù¾e se ovladaè vrátit do automatického módu (karta vybere
+nejlep¹í pøístupový bod v dosahu).
+.br
+Je také mo¾né pou¾ít
+.I off
+k opìtovnému zapnutí automatického módu beze zmìny souèasného pøístupového bodu
+nebo
+.I any
+èi
+.I auto
+k vynucení opìtovné asociace karty s momentálnì nejlep¹ím pøístupovým bodem.
+.br
+.B Pøíklad :
+.br
+.I "   iwconfig eth0 ap 00:60:1D:01:23:45"
+.br
+.I "   iwconfig eth0 ap any"
+.br
+.I "   iwconfig eth0 ap off"
+.TP
+.BR nick [name]
+Nastaví pøezdívku neboli station name. Nìkteré 802.11 produkty ji definují,
+ale co se týká protokolù (MAC, IP, TCP), není pou¾ívána a pøi konfiguraci je
+zcela nepotøebná. Pou¾ívají ji pouze nìkteré diagnostické nástroje.
+.br
+.B Pøíklad:
+.br
+.I "   iwconfig eth0 nickname ""Muj linuxovy node""
+.TP
+.BR rate / bit [rate]
+U karet, které podporují více pøenosových rychlostí, nastaví rychlost pøenosu v b/s.
+Rychlost pøenosu je rychlost, kterou jsou bity pøená¹eny médiem,
+rychlost pro u¾ivatele je ni¾¹í kvùli sdílení média a rùzné re¾ii.
+.br
+Je mo¾né pøipojit k hodnotì pøíponu k, M nebo G (dekadický násobitel:
+10^3, 10^6 a 10^9 b/s), nebo doplnit dostateèný poèet nul. Význam hodnoty ni¾¹í ne¾
+1000 závisí na pou¾ité kartì, obvykle znamená index v seznamu pøenosových rychlostí.
+Je mo¾né pou¾ít
+.I auto
+ke zvolení re¾imu automatické pøenosové rychlosti (ústup na ni¾¹í rychlost v za¹umìných
+kanálech), co¾ je u vìt¹iny karet výchozí nastavení, a
+.I fixed
+k návratu k pevnému nastavení. Pokud je urèena pøenosová rychlost a 
+.IR auto ,
+mù¾e ovladaè pou¾ít v¹echny pøenosové rychlosti rovné této hodnotì a ni¾¹í.
+.br
+.B Pøíklady:
+.br
+.I "   iwconfig eth0 rate 11M"
+.br
+.I "   iwconfig eth0 rate auto"
+.br
+.I "   iwconfig eth0 rate 5.5M auto"
+.TP
+.BR rts [_threshold]
+RTS/CTS pøidá handshake pøed ka¾dým pøenosem paketù, aby se zajistilo,
+¾e je kanál volný. To zvý¹í re¾ii, ale také výkon v pøípadì skrytých nodù
+nebo velkého poètu aktivních nodù. Tento parametr nastavuje velikost nejmen¹ího 
+paketu, pro který node vysílá RTS; hodnota rovná maximální velikosti paketu
+tento mechanismus vypne. Je také mo¾né nastavit tento parametr na
+.IR auto ", " fixed " nebo " off .
+.br
+.B Pøíklady:
+.br
+.I "   iwconfig eth0 rts 250"
+.br
+.I "   iwconfig eth0 rts off"
+.TP
+.BR frag [mentation_threshold]
+Fragmentace dovoluje rozdìlit IP paket na dávku nìkolika men¹ích èástí
+pøenesených médiem. To ve vìt¹inì pøípadù zvìt¹í re¾ii, ale ve velmi za¹umìnìm
+prostøedí sní¾í ztráty zpùsobené chybami a umo¾ní paketùm projít
+pøi zaru¹ení. Tento parametr nastaví maximální velikost fragmentu; hodnota
+rovná maximální velikosti paketu tento mechanismus vypne. Je také
+mo¾né nastavit tento mechanismus na
+.IR auto ", " fixed " nebo " off .
+.br
+.B Pøíklady:
+.br
+.I "   iwconfig eth0 frag 512"
+.br
+.I "   iwconfig eth0 frag off"
+.TP
+.BR key / enc [ryption]
+Pou¾ívá se k nastavení ¹ifrovacích klíèù a bezpeènostního re¾imu.
+.br
+Pro nastavení aktuálního ¹ifrovacího klíèe se pouze zadá klíè v hexadecimální podobì jako
+.IR XXXX-XXXX-XXXX-XXXX " nebo " XXXXXXXX .
+Pro nastavení jiného ne¾ aktuálního klíèe pøidejte pøed nebo za vlastní klíè
+.I [index]
+(tím se nezmìní aktuální klíè). Je také mo¾né zadat klíè
+jako øetìzec ASCII znakù pomocí pøedpony
+.I s:
+. Passphrase není v souèasnosti podporovaná.
+.br
+Pro urèení, který klíè má být aktivní, se vlo¾í
+.I [index]
+(bez zadání hodnoty klíèe).
+.br
+.IR off " a " on
+Vypnou a znovu zapnou ¹ifrování.
+.br
+Bezpeènostní re¾im mù¾e být
+.I open
+(otevøený) nebo
+.IR restricted ,
+(uzavøený) a jeho význam závisí na pou¾ité kartì. Vìt¹ina karet nepou¾ívá v
+.I open
+(otevøeném) re¾imu ¾ádnou autentizaci a karta mù¾e také pøijímat
+neza¹ifrované relace, zatímco v
+.I restricted
+(uzavøeném) re¾imu jsou akceptovány pouze za¹ifrované relace a karta pou¾ije autentizaci,
+pokud je k dispozici.
+.br
+Pokud je tøeba nastavit více klíèù, nebo nastavit klíè a urèit aktivní klíè,
+je nutné pou¾ít více pøepínaèù
+.B key
+. Parametry mohou být v jakémkoliv poøadí, poslední má pøednost.
+.br
+.B Pøíklady:
+.br
+.I "   iwconfig eth0 key 0123-4567-89"
+.br
+.I "   iwconfig eth0 key [3] 0123-4567-89"
+.br
+.I "   iwconfig eth0 key s:password [2]"
+.br
+.I "   iwconfig eth0 key [2]"
+.br
+.I "   iwconfig eth0 key open"
+.br
+.I "   iwconfig eth0 key off"
+.br
+.I "   iwconfig eth0 key restricted [3] 0123456789"
+.br
+.I "   iwconfig eth0 key 01-23 key 45-67 [4] key [4]"
+.TP
+.BR power
+Nastavuje re¾im øízení spotøeby a jeho parametry.
+.br
+Pro nastavení èasu mezi probuzeními se vlo¾í
+.IR "period `hodnota'" .
+Pro nastavení prodlevy pøed návratem do spánku se vlo¾í
+.IR "timeout `hodnota'" .
+Je také mo¾né pøidat modifikátory
+.IR min " a " max
+. Hodnoty znamenají poèet sekund, pro urèení v milisekundách
+nebo mikrosekundách se pou¾ije pøípona m nebo u. Nìkdy jsou
+tyto hodnoty bez jednotek (poèet období mezi beacons a podobnì).
+.br
+.IR off " a " on
+vypne a novu zapne øízení spotøeby. Je také mo¾né nastavit
+re¾im øízení spotøeby na
+.I all
+(pøijímá v¹echny pakety),
+.I unicast
+(pøijímá pouze unicast pakety, zahazuje multicast a broadcast) a
+.I multicast
+(pøijímá pouze multicast a broadcast, zahazuje unicast pakety).
+.br
+.B Pøíklady:
+.br
+.I "   iwconfig eth0 power period 2"
+.br
+.I "   iwconfig eth0 power 500m unicast"
+.br
+.I "   iwconfig eth0 power timeout 300u all"
+.br
+.I "   iwconfig eth0 power off"
+.br
+.I "   iwconfig eth0 power min period 2 power max period 4"
+.TP
+.BR txpower
+U karet podporujících rozdílné vysílací výkony nastavuje vysílací výkon v dBm. Je-li dán výkon 
+.I W
+ve Wattech, je výkon v dBm roven
+.IR "P = 30 + 10.log(W)" .
+Pokud je hodnota doplnìna pøíponou
+.IR mW ,
+je automaticky pøevedena na dBm.
+.br
+Navíc volby 
+.IR on " a " off
+povolí a zaká¾ou vysílání, 
+.IR auto " a " fixed
+povolí a zaká¾ou mo¾nost mìnit výkon (pokud je tato vlastnost k dispozici).
+.br
+.B Pøíklady:
+.br
+.I "   iwconfig eth0 txpower 15"
+.br
+.I "   iwconfig eth0 txpower 30mW"
+.br
+.I "   iwconfig eth0 txpower auto"
+.br
+.I "   iwconfig eth0 txpower off"
+.TP
+.BR retry
+Vìt¹ina karet umí MAC retransmisi a nìkteré umo¾òují nastavit
+chování tohoto mechanismu.
+.br
+pro nastavení maximálního poètu pokusù o zaslání se zadá
+.IR "limit `hodnota'" .
+Toto je absolutní hodnota (bez jednotky).
+Pro nastavení nejdel¹ího období, ve kterém se má MAC pokou¹et o zaslání, se zadá
+.IR "lifetime `hodnota'" .
+Hodnoty znamenají poèet sekund, pro urèení v milisekundách
+nebo mikrosekundách se pou¾ije pøípona m nebo u.
+.br
+je také mo¾né pøidat modifikátory
+.IR min " a " max
+. Pokud karta podporuje automatický re¾im, urèují tyto modifikátory rozmezí pro limit nebo lifetime.
+Nìkteré karty definují rùzné hodnoty v závislosti na velikosti
+paketù, napø. v 802.11 urèuje
+.I min limit
+tzv. "short retry limit" - limit pro pakety, na které není aplikováno RTS/CTS.
+.br
+.B Pøíklady:
+.br
+.I "   iwconfig eth0 retry 16"
+.br
+.I "   iwconfig eth0 retry lifetime 300m"
+.br
+.I "   iwconfig eth0 retry min limit 8"
+.TP
+.BR commit
+Nìkteré karty nemusí provést zmìny zadané pøes Wireless Extensions
+okam¾itì (mohou èekat na nashromá¾dìní zmìn a pøijmout je
+a¾ kdy¾ je karta aktivována pomocí ifconfig). Tento pøíkaz (pokud
+je dostupný) pøinutí kartu k pøijetí v¹ech nevyøízených zmìn.
+.br
+To není vìt¹inou potøeba, proto¾e karta èasem zmìny pøijme, ale mù¾e to
+být u¾iteèné pøi ladìní.
+.\"
+.\" DISPLAY part
+.\"
+.SH ZOBRAZENÍ
+Pro ka¾dé zaøízení, které podporuje wireless extensions, zobrazí
+.I iwconfig
+název pou¾itého
+.B MAC protokolu
+ (název zaøízení u proprietárních protokolù),
+.B ESSID
+(Network Name),
+.BR NWID ,
+.B frekvenci
+(nebo kanál),
+.BR sensitivity 
+(citlivost),
+.B mode
+(pracovní re¾im), 
+.B Access Point
+(adresu pøístupového bodu),
+.B bit-rate
+(pøenosovou rychlost),
+.BR "RTS threshold"
+(práh RTS), 
+.BR "fragmentation threshold"
+(práh fragmentace),
+.B encryption key
+(¹ifrovací klíè) a nastavení
+.B power management
+(øízení spotøeby)(pokud je k dispozici).
+.PP
+Zobrazené parametry mají stejný význam a hodnoty jako parametry, 
+které mohou být nastaveny, pro jejich podrobnìj¹í vysvìtlení se prosím 
+obra»te se na pøedchozí èást.
+.br
+Nìkteré parametry jsou zobrazeny pouze ve své krátké/zkrácené podobì
+(napø. ¹ifrování). Je mo¾né pou¾ít
+.IR iwlist (8)
+k získání detailù.
+.br
+Nìkteré parametry mají dva re¾imy (napø. pøenosová rychlost). Pokud
+hodnotu uvozuje
+.RB ` = ',
+znamená to, ¾e parametr je pevný a daný touto hodnotou, pokud
+ji uvozuje
+.RB ` : ',
+je parametr v automatickém re¾imu a je zobrazena aktuální hodnota (a
+mù¾e se zmìnit).
+.TP
+.BR "Access Point" / Cell
+Adresa rovná 00:00:00:00:00:00 znamená, ¾e se karta nedokázala asociovat
+s pøístupovým bodem (nejspí¹e problém v nastavení).
+Parametr
+.B Access Point
+bude zobrazen jako
+.B Cell
+v re¾imu ad-hoc (ze zøejmých dùvodù), ale jinak znamená to samé.
+.PP
+Pokud existuje
+.IR "/proc/net/wireless" ,
+.I iwconfig
+se také pokusí zobrazit jeho obsah. Nicménì tyto hodnoty závisí na
+ovladaèi a zvlá¹tnostech hardware, tak¾e pro jejich správnou interpretaci je nutné obrátit se na
+dokumentaci ovladaèe.
+.TP
+.B Link quality
+Celková kvalita spoje. Mù¾e být zalo¾ena na úrovni ru¹ení 
+èi interference, poètu chyb na úrovni bitù nebo rámcù, síle pøijímaného
+signálu, synchronizaci èasování nebo dal¹ích hardwarových mìøeních. Je to
+celková hodnota a zcela zále¾í na ovladaèi a hardware.
+.TP
+.B Signal level
+Received signal strength (RSSI - indikátor síly pøijímaného signálu). 
+Mù¾e být v libovolných jednotkách nebo dBm,
+.I iwconfig
+pou¾ívá informace z ovladaèe k interpretaci surových dat v
+.I /proc/net/wireless
+a zobrazení správné jednotky nebo maximální hodnoty (pomocí 8 bitových výpoètù). V
+.I Ad-Hoc
+re¾imu mù¾e být nedefinovaná a mìl by být pou¾it 
+.IR iwspy .
+.TP
+.B Noise level
+Úroveò ¹umu pozadí (kdy¾ není pøená¹en ¾ádný paket). Platí stejné poznámky 
+jako pro
+.BR "Signal level" .
+.TP
+.B Rx invalid nwid
+Poèet pøijatých paketù s odli¹ným NWID nebo ESSID. Pou¾ívá se 
+k detekci problémù v nastavení nebo existence sousední sítì
+(na stejné frekvuenci).
+.TP
+.B Rx invalid crypt
+Poèet paketù, které hardware nedokázal de¹ifrovat. Mù¾e indikovat
+neplatné nastavení ¹ifrování.
+.TP
+.B Rx invalid frag
+Poèet paketù, pro které hardware nedokázal správnì znovu sestavit
+jednotlivé fragmenty na fyzické vrstvì (nejspí¹e jeden chybìl).
+.TP
+.B Tx excessive retries
+Poèet paketù, které hardware nedokázal odeslat. Vìt¹ina MAC
+protokolù zkusí poslat paket nìkolikrát, ne¾ to vzdá.
+.TP
+.B Invalid misc
+Ostatní pakety ztracené v souvislosti s urèitými bezdrátovými operacemi.
+.TP
+.B Missed beacon
+Poèet pravidelných beacons z buòky nebo pøístupového bodu, které nebyly zachyceny.
+Beacons jsou vysílány v pravidelných intervalech pro udr¾ení koordinace a
+pokud nejsou zachyceny, vìt¹inou to znamená, ¾e je karta mimo dosah.
+.\"
+.\" AUTHOR part
+.\"
+.SH AUTOR
+Jean Tourrilhes \- jt@hpl.hp.com
+.\"
+.\" TRANSLATION part
+.\"
+.SH PØEKLAD
+Pavel Heimlich \- tropikhajma@seznam.cz, bøezen 2005 (wireless_tools.28pre4).
+.\"
+.\" FILES part
+.\"
+.SH SOUBORY
+.I /proc/net/wireless
+.\"
+.\" SEE ALSO part
+.\"
+.SH DAL©Í INFORMACE
+.BR ifconfig (8),
+.BR iwspy (8),
+.BR iwlist (8),
+.BR iwevent (8),
+.BR iwpriv (8),
+.BR wireless (7).
diff --git a/wireless_tools/cs/iwevent.8 b/wireless_tools/cs/iwevent.8
new file mode 100644 (file)
index 0000000..2dcc580
--- /dev/null
@@ -0,0 +1,118 @@
+.\" Jean Tourrilhes - HPL - 2002 - 2004
+.\" iwevent.8
+.\"
+.TH IWEVENT 8 "23.èerven 2004" "net-tools" "Linux - Manuál programátora"
+.\"
+.\" NAME part
+.\"
+.SH JMÉNO
+iwevent \- Zobrazí bezdrátové události vyvolané ovladaèi a zmìnami nastavení
+.\"
+.\" SYNOPSIS part
+.\"
+.SH SYNTAXE
+.BI "iwevent "
+.br
+.\"
+.\" DESCRIPTION part
+.\"
+.SH POPIS
+.B iwevent
+zobrazí bezdrátové události pøijaté prostøednictvím socketu RTNetlink. Ka¾dý
+øádek zobrazuje jednotlivou bezdrátovou událost popisující, co se stalo
+na urèeném bezdrátovém rozhraní.
+.br
+Tento pøíkaz nemá ¾ádné parametry.
+.\"
+.\" DISPLAY part
+.\"
+.SH ZOBRAZENÍ
+Jsou dva typy bezdrátových událostí.
+.PP
+První typ jsou události vztahující se ke zmìnì bezdrátových nastavení na
+rozhraní (typicky prostøednictvím
+.B iwconfig
+nebo skriptu volajícího
+.BR iwconfig ).
+Jsou oznamována pouze nastavení, která mohou vést k naru¹ení spojení.
+V souèasnosti jsou oznamovány události mìnící jedno z následujících
+nastavení:
+.br
+.I "   Network ID"
+.br
+.I "   ESSID"
+.br
+.I "   Frequency"
+.br
+.I "   Mode"
+.br
+.I "   Encryption"
+.br
+V¹echny tyto události jsou generovány na v¹ech bezdrátových rozhraních
+bezdrátovým subsystémem jádra (ale jen kdy¾ byl ovladaè pøeveden na
+nové API ovladaèù).
+.PP
+Dal¹ím typem jsou události generované hardwarem, kdy¾ se nìco stane
+nebo byl byla dokonèena úloha. Tyto události zahrnují:
+.TP
+.B New Access Point/Cell address
+(nová adresa pøístupového bodu/buòky) Rozhraní se pøipojilo k novému
+pøístupovému bodu èi AD-Hoc buòce nebo s ním ztratilo spojení. Je to 
+stejná MAC adresa, jako hlásí
+.BR iwconfig .
+.TP
+.B Scan request completed
+(po¾adavek na skenování dokonèen) Po¾adavek na skenování byl dokonèen,
+výsledek je k dispozici (viz
+.BR iwlist 
+).
+.TP
+.B Tx packet dropped
+(vyslaný paket zahozen) Paket smìrovaný na tuto adresu byl zahozen, proto¾e rozhraní se
+domnívá, ¾e tento node u¾ neodpovídá (obvykle pokud bylo pøekroèeno maximum
+pokusù na úrovni MAC). Toto je obvykle prvotní známka toho, ¾e
+node mohl opustit buòku nebo se ocitl mimo dosah, ale mù¾e to být i 
+zeslabením signálu nebo nadmìrným ru¹ením.
+.TP
+.B Custom driver event
+(Zvlá¹tní událost ovladaèe) Událost specifická pro ovladaè. Prosím prozkoumejte dokumentaci ovladaèe.
+.TP
+.B Registered node
+Rozhraní úspì¹nì zaregistrovalo nového bezdrátového klienta/peer.
+Vìt¹inou je generována, pokud rozhraní pracuje jako pøístupový bod
+(re¾im master).
+.TP
+.B Expired node
+Registrace klienta/peer na tomto rozhraní vypr¹ela. 
+Vìt¹inou je generována, pokud rozhraní pracuje jako pøístupový bod
+(re¾im master).
+.TP
+.B Spy threshold crossed
+(pøekroèen práh pro sledování) Síla signálu u jedné z adres v seznamu iwspy poklesla pod spodní práh nebo
+pøekroèila horní práh.
+.PP
+Vìt¹ina bezdrátových ovladaèù generuje pouze èást z tìchto událostí, nikoli
+v¹echny. Jejich seznam zále¾í na konkrétní kombinaci hardware a ovladaèe.
+Pro více informací o vytváøení událostí prosím prozkoumejte dokumentaci
+ovladaèe a pou¾ijte
+.IR iwlist (8)
+k zji¹tìní, co ovladaè podporuje.
+.\"
+.\" AUTHOR part
+.\"
+.SH AUTOR
+Jean Tourrilhes \- jt@hpl.hp.com
+.\"
+.\" TRANSLATION part
+.\"
+.SH PØEKLAD
+Pavel Heimlich \- tropikhajma@seznam.cz, bøezen 2005 (wireless_tools.28pre4).
+.\"
+.\" SEE ALSO part
+.\"
+.SH DAL©Í INFORMACE
+.BR iwconfig (8),
+.BR iwlist (8),
+.BR iwspy (8),
+.BR iwpriv (8),
+.BR wireless (7).
diff --git a/wireless_tools/cs/iwgetid.8 b/wireless_tools/cs/iwgetid.8
new file mode 100644 (file)
index 0000000..332363e
--- /dev/null
@@ -0,0 +1,118 @@
+.\" Guus Sliepen - 2001
+.\" Doplnil a opravil Jean Tourrilhes - 2002-2003
+.\" iwgetid.8
+.\"
+.TH IWGETID 8 "2.prosinec 2003" "wireless-tools" "Linux - Manuál programátora"
+.\"
+.\" NAME part
+.\"
+.SH JMÉNO
+iwgetid \- Zobrazí ESSID, NWID nebo adresu AP/Cell (pøístupového bodu/buòky) v bezdrátové síti
+.\"
+.\" SYNOPSIS part
+.\"
+.SH SYNTAXE
+.BI "iwgetid " [interface] " [--raw] [--scheme] [--ap] [--freq]"
+.br
+.BI "                   [--mode] [--protocol] [--channel]
+.br
+.\"
+.\" DESCRIPTION part
+.\"
+.SH POPIS
+.B iwgetid
+se pou¾ívá k zji¹tìní NWID, ESSID nebo adresy AP/Cell (pøístupového bodu/buòky)
+v bezdrátové síti, která je právì vyu¾ívána. Zobrazená informace je stejná jako
+ta, kterou ukazuje
+.BR iwconfig ", ale " iwgetid
+se snadnìji integruje do skriptù.
+.br
+Jako výchozí,
+.B iwgetid
+vypí¹e 
+.I ESSID
+zaøízení, pokud zaøízení nemá ¾ádné ESSID, vytiskne jeho
+.IR NWID .
+.br
+Výchozí formát pro výstup je pretty-printing (èlovìkem èitelný).
+.\"
+.\" OPTIONS part
+.\"
+.SH VOLBY
+.TP
+.B --raw
+Tento pøepínaè vypne pretty-printing.
+Je mo¾né jej kombinovat s ostatními pøepínaèi (s výjimkou
+.BR --scheme ),
+tak¾e se správnou kombinací pøepínaèù lze vytisknout surové
+ESSID, adresu AP nebo Mode.
+.br
+Tento formát je ideální pro ulo¾ení výsledku iwgetid jako promìnné ve skriptech
+.I Shellu
+nebo
+.I Perlu
+nebo pro pøedání výsledku jako parametru pøíkazové øádky pro
+.BR iwconfig .
+.TP
+.B --scheme
+Tento pøepínaè je podobný pøedchozímu, vypne pretty-printing 
+a odstraní v¹echny znaky, které nejsou alfanumerické
+(jako mezery, interpunkci a kontrolní znaky).
+.br
+Výsledný výstup je validní <<\ Pcmcia scheme identifer\ >> (který mù¾e být
+pou¾it jako parametr pøíkazu
+.BR "cardctl scheme" ).
+Tento formát je také ideální, pokud je výsledek iwgetid pou¾it jako volba ve skriptech
+.I Shellu
+nebo
+.I Perlu
+nebo jako název souboru.
+.TP
+.B --ap
+Zobrazí MAC adresu bezdrátového
+.I Access Point
+(pøístupového bodu) nebo
+.IR Cell .
+(buòky)
+.TP
+.B --freq
+Zobrazí aktuální
+.I frequency
+(frekvenci) nebo
+.I channel
+(kanál), pou¾ívaný rozhraním.
+.TP
+.B --channel
+Zobrazí aktuální
+.I channel
+(kanál), pou¾ívaný rozhraním. Kanál je získán z aktuální frekvence
+a seznamu frekvencí dodaného rozhraním.
+.TP
+.B --mode
+Zobrazí aktuální
+.I mode
+(re¾im) rozhraní.
+.TP
+.B --protocol
+Zobrazí
+.I protocol name
+(název protokolu) rozhraní. Tak je mo¾né identifikovat v¹echny karty, které
+jsou vzájemnì kompatibilní a akceptují stejný typ nastavení.
+.br
+Je to také mo¾nost jak 
+.I ovìøit podporu Wireless Extensions
+na rozhraní, proto¾e je to jediný atribut,
+který v¹echny ovladaèe podporující Wireless Extensions musejí podporovat.
+.\"
+.\" TRANSLATION part
+.\"
+.SH PØEKLAD
+Pavel Heimlich \- tropikhajma@seznam.cz, bøezen 2005 (wireless_tools.28pre4).
+.\"
+.\" SEE ALSO part
+.\"
+.SH DAL©Í INFORMACE
+.BR iwconfig (8),
+.BR ifconfig (8),
+.BR iwspy (8),
+.BR iwpriv (8).
diff --git a/wireless_tools/cs/iwlist.8 b/wireless_tools/cs/iwlist.8
new file mode 100644 (file)
index 0000000..01f238d
--- /dev/null
@@ -0,0 +1,120 @@
+.\" Jean II - HPLB - 96
+.\" iwlist.8
+.\"
+.TH IWLIST 8 "23.èerven 2004" "wireless-tools" "Linux - Manuál programátora"
+.\"
+.\" NAME part
+.\"
+.SH JMÉNO
+iwlist \- Získá podrobnìj¹í bezdrátové informace o bezdrátovém rozhraní
+.\"
+.\" SYNOPSIS part
+.\"
+.SH SYNTAXE
+.BI "iwlist " rozhraní " scanning"
+.br
+.BI "iwlist " rozhraní " frequency"
+.br
+.BI "iwlist " rozhraní " rate"
+.br
+.BI "iwlist " rozhraní " key"
+.br
+.BI "iwlist " rozhraní " power"
+.br
+.BI "iwlist " rozhraní " txpower"
+.br
+.BI "iwlist " rozhraní " retry"
+.br
+.BI "iwlist " rozhraní " event"
+.br
+.BI "iwlist --help"
+.br
+.BI "iwlist --version"
+.\"
+.\" DESCRIPTION part
+.\"
+.SH POPIS
+.B Iwlist
+se pou¾ívá k zobrazení doplòujících informací o bezdrátovém sí»ovém
+rozhraní, které nejsou zobrazovány pøíkazem
+.IR iwconfig (8).
+Hlavní parametr urèuje typ informace, kterou
+.B iwlist
+zobrazí v detailní podobì, vèetnì informace, kterou poskytuje
+.IR iwconfig (8).
+.\"
+.\" PARAMETER part
+.\"
+.SH PARAMETRY
+.TP
+.BR scan [ning]
+Vypí¹e seznam pøístupových bodù a Ad-Hoc buòek v dosahu a 
+volitelnì i spoustu informací o nich (ESSID, kvalita,
+frekvence, re¾im...). Typ zobrazené informace závisí na mo¾nostech karty.
+.br
+Spu¹tìní skenování je privilegovaná operace (mù¾e ji provést pouze
+.RI root
+) a normální u¾ivatel mù¾e pouze èíst zbylé výsledky skenování. 
+Jako výchozí je zpùsob, kterým je skenování provedeno (jeho rozsah)
+ovlivnìn aktuálním nastavením ovladaèe. U tohoto pøíkazu se poèítá s dodateènými parametry
+pro kontrolu zpùsobu skenování, to ale zatím není implementováno.
+.TP
+.BR freq [uency]/ channel
+Vypí¹e seznam dostupných frekvencí pro zaøízení a poèet definovaných kanálù
+Prosím vìnujte pozornost tomu, ¾e ovladaè obvykle vrací
+celkový poèet kanálù a pouze frekvence dostupné v aktuálním locale,
+tak¾e mezi zobrazenými frekvencemi a èísly kanálù není vztah "jedna k jedné".
+.TP
+.BR rate / bit [rate]
+Vypí¹e pøenosové rychlosti podporované zaøízením.
+.TP
+.BR key / enc [ryption]
+Vypí¹e podporované velikosti ¹ifrovacích klíèù a zobrazí v¹echny ¹ifrovací
+klíèe dostupné v zaøízení.
+.TP
+.B power
+Vypí¹e rùzné atributy a re¾imy øízení spotøeby zaøízení.
+.TP
+.B txpower
+vypí¹e dostupné vysílací výkony zaøízení.
+.TP
+.B retry
+vypí¹e limity pro transmit retry a retry lifetime na zaøízení.
+.TP
+.BR ap / accesspoint / peers
+Vypí¹e pøístupové body v dosahu a volitelnì i kvalitu spoje
+Tato volba je 
+.B zastaralá
+a je nyní opu¹tìna ve prospìch skenování (viz vý¹e), vìt¹ina
+ovladaèù ji nepodporuje.
+.br
+Nìkteré ovladaèe mohou s tímto pøíkazem vracet zvlá¹tní seznam peerù
+nebo pøístupových bodù, jako napø. seznam peerù asociovaních s/registrovaných s
+kartou. Více informací obsahuje dokumentace ovladaèù.
+.TP
+.B event
+Vypí¹e bezdrátové události podporované zaøízením.
+.TP
+.B --version
+Zobrazí verzi wireless tools a doporuèenou a aktuální verzi Wireless Extensions
+s ohledem na bezdrátové rozhraní.
+.\"
+.\" TRANSLATION part
+.\"
+.SH PØEKLAD
+Pavel Heimlich \- tropikhajma@seznam.cz, bøezen 2005 (wireless_tools.28pre4).
+.\"
+.\" FILES part
+.\"
+.SH SOUBORY
+.I /proc/net/wireless
+.\"
+.\" SEE ALSO part
+.\"
+.SH DAL©Í INFORMACE
+.BR iwconfig (8),
+.BR iwspy (8).
+.BR iwevent (8),
+.BR iwpriv (8),
+.BR wireless (7).
+
diff --git a/wireless_tools/cs/iwpriv.8 b/wireless_tools/cs/iwpriv.8
new file mode 100644 (file)
index 0000000..72ad4da
--- /dev/null
@@ -0,0 +1,136 @@
+.\" Jean II - HPLB - 96
+.\" iwpriv.8
+.\"
+.TH IWPRIV 8 "31.øíjen 1996" "net-tools" "Linux - Manuál programátora"
+.\"
+.\" NAME part
+.\"
+.SH JMÉNO
+iwpriv \- konfiguruje doplòkové (specifické) parametry bezdrátového
+sí»ového rozhraní
+.\"
+.\" SYNOPSIS part
+.\"
+.SH SYNTAXE
+.BI "iwpriv [" rozhraní ]
+.br
+.BI "iwpriv " "rozhraní specifický-pøíkaz " "[" specifické-parametry ]
+.br
+.BI "iwpriv " "rozhraní specifický-pøíkaz [I] " "[" specifické-parametry ]
+.br
+.BI "iwpriv " rozhraní " --all"
+.br
+.BI "iwpriv " rozhraní " roam " {on,off}
+.br
+.BI "iwpriv " rozhraní " port " {ad-hoc,managed,N}
+.\"
+.\" DESCRIPTION part
+.\"
+.SH POPIS
+.B Iwpriv
+je doprovodným nástrojem k
+.IR iwconfig (8).
+.B Iwpriv
+pracuje s parametry a nastaveními specifickými pro ka¾dý ovladaè (na rozdíl od
+.IR "iwconfig" ,
+který pracuje s obecnými).
+.PP
+Bez uvedení parametru
+.B iwpriv
+vypí¹e specifické pøikazy dostupné na ka¾dém rozhraní a 
+parametry, které vy¾adují. Pomocí této informace mù¾e u¾ivatel
+pou¾ít tyto specifické pøíkazy na urèeném rozhraní.
+.PP
+Teoreticky by dokumentace ka¾dého ovladaèe mìla uvádìt, jak
+pou¾ívat tyto pro rozhraní specifické pøíkazy a jejich úèinek.
+.\"
+.\" PARAMETER part
+.\"
+.SH PARAMETRY
+.TP
+.IR specifický-pøíkaz " [" specifické-parametry ]
+Vykoná urèený
+.I specifický-pøíkaz
+na rozhraní.
+.br
+Pøíkaz mù¾e pou¾ít nebo vy¾adovat parametry a mù¾e zobrazit informaci.
+Parametry tedy mohou i nemusejí být vy¾adovány a mìly by odpovídat tomu, co
+pøíkaz oèekává. Seznam pøíkazù, které
+.B iwpriv
+zobrazí (kdy¾ je volán bez parametrù), by mìl napovìdìt, jak s parametry zacházet.
+.br
+Nicménì pro informaci o pøíkazech a jejich správném pou¾ití je nejlep¹í
+se obrátit na dokumnetaci k ovladaèi zaøízení.
+.TP
+.I "specifický-pøíkaz [I]" "[" specifické-parametry ]
+Viz vý¹e, pouze
+.I I
+(celé èíslo) je pøedáno pøíkazu jako
+.IR "Token Index" .
+Token Index pou¾ívají jen nìkteré pøíkazy (vìt¹ina jej ignoruje), kdy jej pou¾ít by
+mìla øíci dokumnetace ovladaèe.
+.TP
+.BR -a / --all
+Vykoná a zobrazí v¹echny specifické pøíkazy, které nemají ¾ádné parametry
+(tj. pouze ètou).
+.TP
+.B roam
+Povolí nebo zaká¾e roaming, je-li podporován. Volá specifický pøíkaz
+.IR setroam ,
+který je obsa¾en v ovladaèi
+.IR "wavelan_cs".
+.TP
+.B port
+Pøeète nebo nastaví druh portu. Volá specifický pøíkaz
+.IR gport_type ", " sport_type ", " get_port " nebo " set_port ","
+obsa¾ený v ovladaèích
+.IR wavelan2_cs " a " wvlan_cs "."
+.\"
+.\" DISPLAY part
+.\"
+.SH ZOBRAZENÍ
+Pro ka¾dé zaøízení, které podporuje specifické pøíkazy, zobrazí
+.I iwpriv
+seznam dostupných specifických pøíkazù.
+.PP
+To zahrnuje název specifického pøíkazu, parametry, které mohou být nastaveny a jejich typ
+a parametry které mohou být zobrazeny a jejich typ.
+.PP
+Napøíklad mù¾e zobrazit :
+.br
+.B "eth0      Available specific ioctl :"
+.br
+.B "          setqualthr (89F0) : set   1 byte & get   0"
+.br
+.B "          gethisto (89F7) : set   0      & get  16 int"
+.PP
+To znamená, ¾e je mo¾né nastavit quality threshold a zobrazit
+histogram s a¾ 16 hodnotami pomocí tìchto pøíkazù:
+.br
+.I "  iwpriv eth0 setqualthr 20"
+.br
+.I "  iwpriv eth0 gethisto"
+.\"
+.\" AUTHOR part
+.\"
+.SH AUTOR
+Jean Tourrilhes \- jt@hpl.hp.com
+.\"
+.\" TRANSLATION part
+.\"
+.SH PØEKLAD
+Pavel Heimlich \- tropikhajma@seznam.cz, bøezen 2005 (wireless_tools.28pre4).
+.\"
+.\" FILES part
+.\"
+.SH SOUBORY
+.I /proc/net/wireless
+.\"
+.\" SEE ALSO part
+.\"
+.SH DAL©Í INFORMACE
+.BR iwconfig (8),
+.BR iwlist (8),
+.BR iwevent (8),
+.BR iwspy (8),
+.BR wireless (7).
diff --git a/wireless_tools/cs/iwspy.8 b/wireless_tools/cs/iwspy.8
new file mode 100644 (file)
index 0000000..101b129
--- /dev/null
@@ -0,0 +1,111 @@
+.\" Jean II - HPLB - 96
+.\" iwspy.8
+.\"
+.TH IWSPY 8 "31.øíjen 1996" "net-tools" "Linux - Manuál programátora"
+.\"
+.\" NAME part
+.\"
+.SH JMÉNO
+iwspy \- Získá bezdrátové statistiky o urèených nodech
+.\"
+.\" SYNOPSIS part
+.\"
+.SH SYNTYXE
+.BI "iwspy " rozhraní 
+.br
+.BI "iwspy " rozhraní " [+] " DNSNAME " | " IPADDR " | " HWADDR " [...]"
+.br
+.BI "iwspy " rozhraní " off"
+.br
+.BI "iwspy " rozhraní " setthr " "low high"
+.br
+.BI "iwspy " rozhraní " getthr"
+.\"
+.\" DESCRIPTION part
+.\"
+.SH POPIS
+.B Iwspy
+se pou¾ívá k nastavení seznamu sledovaných adres na bezdrátovém sí»ovém rozhraní a
+k zpìtnému ètení informací o kvalitì spoje pro ka¾dou z nich. Tyto
+informace jsou stejné jako ty uvedené v
+.IR "/proc/net/wireless":
+kvalita spoje, síla signálu, hladina ¹umu.
+.PP
+Tyto informace jsou aktualizovány poka¾dé, kdy¾ je pøijat nový paket, tak¾e
+ka¾dá adresa na seznamu zvy¹uje zátì¾ ovladaèe.
+.PP
+Tato funkcionalita platí pouze pro nody v aktuální bezdrátové buòce, není mo¾né 
+sledovat pøístupové body, se kterými není zaøízení asociováno (k tomu slou¾í skenování)
+, ani nody v jiných buòkách. V re¾imu Managed procházejí pakety vìt¹inou pøes pøístupový
+bod a v tom pøípadì je získána síla signálu pøístupového bodu. Proto je tato funkce 
+u¾iteèná víceménì jen v re¾imu Ad-Hoc nebo Master.
+.\"
+.\" PARAMETER part
+.\"
+.SH PARAMETRY
+Je mo¾né nastavit a¾ 8 adres.
+.TP
+.BR DNSNAME " | " IPADDR
+Nastaví IP adresu nebo, v nìkterých pøípadech, DNS název (pomocí name
+resolveru). Proto¾e hardware pracuje s hardwarovými adresami,
+.B iwspy
+pøelo¾í IP adresu pomocí
+.IR ARP .
+Mù¾e se stát, ¾e adresa není v ARP cache a
+.B iwspy
+neuspìje. V tom pøípadì pou¾ijte
+.IR ping (8)
+na toto jméno/adresu a zkuste to znovu.
+.TP
+.B HWADDR
+Nastaví hardwarovou (MAC) adresu (tato adresa se nepøekládá ani nekontroluje,
+na rozdíl od IP adresy). Adresa musí obsahuvat dvojteèky
+.RB ( : )
+aby byla uznána za hardwarovou adresu.
+.TP
+.B +
+Pøidá novou sadu adres na konec stávajícího seznamu, místo aby jej nahradil.
+Seznam adres je pro ka¾dé zaøízení jedineèný, proto by tato volba mìla být u¾ívána, aby
+se zabránilo konfliktùm.
+.TP
+.B off
+Odstraní souèasný seznam adres a vypne sledovací funkci.
+.TP
+.B setthr
+Nastaví
+.I low
+(spodní) a
+.I high
+(horní) práh síly signálu, pro spu¹tìní události iwspy (podporuje-li to ovladaè).
+.br
+Poka¾dé, kdy¾ síla signálu jakékoliv z adres sledované iwspy
+poklesne pod spodní práh nebo pøehroèí horní práh, je vygenerována bezdrátová událost.
+.br
+To je mo¾né pou¾ít ke sledování výpadkù spoje bez nutnosti pravidelného spou¹tìní iwspy.
+.TP
+.B getthr
+Získá aktuální
+.I low
+(spodní) a 
+.I high
+(horní) práh síly signálu pro událost iwspy.
+.\"
+.\" TRANSLATION part
+.\"
+.SH PØEKLAD
+Pavel Heimlich \- tropikhajma@seznam.cz, bøezen 2005 (wireless_tools.28pre4).
+\"
+.\" FILES part
+.\"
+.SH SOUBORY
+.I /proc/net/wireless
+.\"
+.\" SEE ALSO part
+.\"
+.SH DAL©Í INFORMACE
+.BR iwconfig (8),
+.BR iwlist (8),
+.BR iwevent (8),
+.BR iwpriv (8),
+.BR wireless (7).
+
diff --git a/wireless_tools/cs/wireless.7 b/wireless_tools/cs/wireless.7
new file mode 100644 (file)
index 0000000..d11c083
--- /dev/null
@@ -0,0 +1,129 @@
+.\" Jean Tourrilhes - HPL - 2002 - 2004
+.\" wireless.7
+.\"
+.TH WIRELESS 7 "4.duben 2004" "wireless-tools" "Linux - Manuál programátora"
+.\"
+.\" NAME part
+.\"
+.SH JMÉNO
+wireless \- Wireless Tools a Wireless Extensions
+.\"
+.\" SYNOPSIS part
+.\"
+.SH SYNTAXE
+.B iwconfig
+.br
+.B iwpriv \-a
+.br
+.\"
+.\" DESCRIPTION part
+.\"
+.SH POPIS
+.B Wireless Extensions
+jsou API, které umo¾òují manipulovat s bezdrátovými sí»ovými rozhraními.
+Skládají se ze souboru nástrojù a konfiguraèních souborù. Podrobnìji
+jsou popsány v Linux Wireless LAN Howto.
+.br
+.B Wireless Tools
+se pou¾ívají ke zmìnì konfigurace bezdrátových sí»ových rozhraní za bìhu,
+k získání jejich aktuální konfigurace, statistik a diagnostice.
+Popisují je jejich vlastní manuálové stránky, viz odkazy ní¾e.
+.br
+.B Nastavení bezdrátového pøipojení
+se v ka¾dé distribuci linuxu li¹í. Tato manuálová stránka bude obsahovat
+postup nastavení pro nìkolik bì¾ných distribucí. Prozatím se podívejte do 
+souboru DISTRIBUTIONS.txt, který je souèástí balíèku Wireless Tools.
+.\"
+.\" DEBIAN 3.0 part
+.\"
+.SH DEBIAN 3.0
+V Debianu 3.0 (a vy¹¹ím) je mo¾né nastavit bezdrátová sí»ová zaøízení
+nástrojem pro nastavení sítì
+.BR ifupdown (8).
+.TP
+.B Soubor:
+.I /etc/network/interfaces
+.TP
+.B Forma:
+.RI wireless\- "<funkce> <hodnota>"
+.br
+wireless\-essid Home
+.br
+wireless\-mode Ad\-Hoc
+.TP
+.B Dal¹í informace:
+.I /etc/network/if\-pre\-up.d/wireless\-tools
+.br
+.I /usr/share/doc/wireless\-tools/README.Debian
+.\"
+.\" SuSE 8.0 part
+.\"
+.SH SuSE 8.0
+SuSE 8.0 (a vy¹¹í) integrovalo nastavení bezdrátového pøipojení do svých
+sí»ových skriptù.
+.TP
+.B Nástroj:
+.B Yast2
+.TP
+.B Soubor:
+.I /etc/sysconfig/network/wireless
+.br
+.I /etc/sysconfig/network/ifcfg\-*
+.TP
+.B Forma:
+.RI WIRELESS_ "<funkce>" = "<hodnota>"
+.br
+WIRELESS_ESSID="Home"
+.br
+WIRELESS_MODE=Ad\-Hoc
+.TP
+.B Dal¹í informace:
+man ifup
+.br
+info scpm
+.\"
+.\" PCMCIA part
+.\"
+.SH PÙVODNÍ PCMCIA SKRIPTY
+Pokud pou¾íváte pùvodní konfiguraèní skripty z balíèku Pcmcia,
+Mù¾ete pou¾ít tuto metodu.
+.TP
+.B Soubor:
+.I /etc/pcmcia/wireless.opts
+.TP
+.B Forma:
+*,*,*,*)
+.br
+ESSID="Home"
+.br
+MODE="Ad-Hoc"
+.br
+;;
+.TP
+.B Dal¹í informace:
+.I /etc/pcmcia/wireless
+.br
+Soubor
+.IR "PCMCIA.txt" ,
+který je souèástí balíèku Wireless Tools
+.\"
+.\" AUTHOR part
+.\"
+.SH AUTOR
+Jean Tourrilhes \- jt@hpl.hp.com
+.br
+.I http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/
+.\"
+.\" TRANSLATION part
+.\"
+.SH PØEKLAD
+Pavel Heimlich \- tropikhajma@seznam.cz, bøezen 2005 (wireless_tools.28pre4).
+.\"
+.\" SEE ALSO part
+.\"
+.SH DAL©Í INFORMACE
+.BR iwconfig (8),
+.BR iwlist (8),
+.BR iwspy (8),
+.BR iwpriv (8),
+.BR iwevent (8).
index 28d5f11..376c58d 100644 (file)
@@ -88,8 +88,23 @@ printed.
 When used with
 .IR -i ,
 specify the new name of the interface. The list of mappings from the
-configuration file is bypassed. The new name may be a wildcard
-containing a single '*'.
+configuration file is bypassed, the interface specified with
+.I -i
+is renamed directly to
+.IR newname .
+The new name may be a wildcard containing a single '*'.
+.br
+When used without 
+.IR -i ,
+rename interfaces by using only mappings that would rename them to
+.IR newname .
+The new name may not be a wildcard. This use of ifrename is
+discouraged, because inefficient
+.RI ( -n " without " -i ).
+All the interfaces of the system need to be processed at each
+invocation, therefore in most case it is not faster than just letting
+ifrename renaming all of them (without both 
+.IR -n " and " -i ).
 .TP
 .B -t
 Enable name takeover support. This allow interface name swapping
index 7d4ab5b..047eb18 100644 (file)
  * Subject to the Gnu Public License, version 2.  
  * TODO: make it support token ring etc.
  * $Id: nameif.c,v 1.3 2003/03/06 23:26:52 ecki Exp $
- * Add hotplug compatibility : ifname -i eth0. Jean II - 03.12.03
- * Add MAC address wildcard : 01:23:45:*. Jean II - 03.12.03
- * Add interface name wildcard : wlan*. Jean II - 03.12.03
- * Add interface name probing for modular systems. Jean II - 18.02.03
  * -------------------------------------------------------
  *
- *     The last 4 patches never made it into the regular version of
- * 'nameif', and had some 'issues', which is the reason of this rewrite.
+ *     It started with a series of patches to nameif which never made
+ * into the regular version, and had some architecural 'issues' with
+ * those patches, which is the reason of this rewrite.
  *     Difference with standard 'nameif' :
  *     o 'nameif' has only a single selector, the interface MAC address.
  *     o Modular selector architecture, easily add new selectors.
+ *     o Wide range of selector, including sysfs...
  *     o hotplug invocation support.
  *     o module loading support.
  *     o MAC address wildcard.
  *     o Interface name wildcard ('eth*' or 'wlan*').
+ *     o Non-Ethernet MAC addresses (any size, not just 48 bits)
  */
 
 /***************************** INCLUDES *****************************/
@@ -81,11 +80,13 @@ const int SELECT_BASEADDR   = 7;    /* Select by HW Base Address */
 const int SELECT_IRQ           = 8;    /* Select by HW Irq line */
 const int SELECT_INTERRUPT     = 9;    /* Select by HW Irq line */
 const int SELECT_IWPROTO       = 10;   /* Select by Wireless Protocol */
-const int SELECT_PCMCIASLOT    = 11;   /* Select by Wireless Protocol */
-#define SELECT_NUM             12
+const int SELECT_PCMCIASLOT    = 11;   /* Select by Pcmcia Slot */
+const int SELECT_SYSFS         = 12;   /* Select by sysfs file */
+#define SELECT_NUM             13
 
 #define HAS_MAC_EXACT  1
 #define HAS_MAC_FILTER 2
+#define MAX_MAC_LEN    16      /* Maximum lenght of MAC address */
 
 const struct ether_addr        zero_mac = {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};
 
@@ -107,6 +108,29 @@ const struct option long_opt[] =
 #define PCMCIA_STAB1   "/var/lib/pcmcia/stab"
 #define PCMCIA_STAB2   "/var/run/stab"
 
+/* Max number of sysfs file we support */
+#define SYSFS_MAX_FILE 5
+
+/* Userspace headers lag, fix that... */
+#ifndef ARPHRD_IEEE1394
+#define ARPHRD_IEEE1394 24
+#endif
+#ifndef ARPHRD_EUI64
+#define ARPHRD_EUI64 27
+#endif
+#ifndef ARPHRD_IRDA
+#define ARPHRD_IRDA 783
+#endif
+
+/* Length of various non-standard MAC addresses */
+const int      weird_mac_len[][2] =
+{
+  { ARPHRD_IEEE1394, 8 },
+  { ARPHRD_EUI64, 8 },
+  { ARPHRD_IRDA, 4 },
+};
+const int weird_mac_len_num = sizeof(weird_mac_len) / sizeof(weird_mac_len[0]);
+
 /****************************** TYPES ******************************/
 
 /* Cut'n'paste from ethtool.h */
@@ -141,8 +165,9 @@ typedef struct if_mapping
   int                  active[SELECT_NUM];     /* Selectors active */
 
   /* Selector data */
-  struct ether_addr    mac;                    /* Exact MAC address, hex */
-  char                 mac_filter[6*3 + 1];    /* WildCard, ascii */
+  unsigned char                mac[MAX_MAC_LEN];       /* Exact MAC address, hex */
+  int                  mac_len;                /* Length (usually 6) */
+  char                 mac_filter[16*3 + 1];   /* WildCard, ascii */
   unsigned short       hw_type;                /* Link/ARP type */
   char                 driver[32];             /* driver short name */
   char         bus_info[ETHTOOL_BUSINFO_LEN];  /* Bus info for this IF. */
@@ -151,13 +176,22 @@ typedef struct if_mapping
   unsigned char                irq;                    /* HW irq line */
   char                 iwproto[IFNAMSIZ + 1];  /* Wireless/protocol name */
   int                  pcmcia_slot;            /* Pcmcia slot */
-} if_mapping; 
+  char *               sysfs[SYSFS_MAX_FILE];  /* sysfs selectors */
+} if_mapping;
+
+/* Extra parsing information when adding a mapping */
+typedef struct add_extra
+{ 
+  char *               modif_pos;              /* Descriptor modifier */
+  size_t               modif_len;
+} parsing_extra;
 
 /* Prototype for adding a selector to a mapping. Return -1 if invalid value. */
 typedef int (*mapping_add)(struct if_mapping * ifnode,
                           int *                active,
                           char *               pos,
                           size_t               len,
+                          struct add_extra *   extra,
                           int                  linenum);
 
 /* Prototype for comparing the selector of two mapping. Return 0 if matches. */
@@ -178,6 +212,15 @@ typedef struct mapping_selector
   mapping_get  get_fn;
 } mapping_selector;
 
+/* sysfs global data */
+typedef struct sysfs_metadata
+{
+  char *               root;                   /* Root of the sysfs */
+  int                  rlen;                   /* Size of it */
+  int                  filenum;                /* Number of files */
+  char *               filename[SYSFS_MAX_FILE];       /* Name of files */
+} sysfs_metadata;
+
 /**************************** PROTOTYPES ****************************/
 
 static int
@@ -185,6 +228,7 @@ static int
                       int *                    active,
                       char *                   pos,
                       size_t                   len,
+                      struct add_extra *       extra,
                       int                      linenum);
 static int
        mapping_cmpmac(struct if_mapping *      ifnode,
@@ -199,6 +243,7 @@ static int
                       int *                    active,
                       char *                   pos,
                       size_t                   len,
+                      struct add_extra *       extra,
                       int                      linenum);
 static int
        mapping_cmparp(struct if_mapping *      ifnode,
@@ -213,6 +258,7 @@ static int
                          int *                 active,
                          char *                pos,
                          size_t                len,
+                         struct add_extra *    extra,
                          int                   linenum);
 static int
        mapping_cmpdriver(struct if_mapping *   ifnode,
@@ -222,6 +268,7 @@ static int
                           int *                active,
                           char *               pos,
                           size_t               len,
+                          struct add_extra *   extra,
                           int                  linenum);
 static int
        mapping_cmpbusinfo(struct if_mapping *  ifnode,
@@ -231,6 +278,7 @@ static int
                            int *               active,
                            char *              pos,
                            size_t              len,
+                           struct add_extra *  extra,
                            int                 linenum);
 static int
        mapping_cmpfirmware(struct if_mapping * ifnode,
@@ -245,6 +293,7 @@ static int
                            int *               active,
                            char *              pos,
                            size_t              len,
+                           struct add_extra *  extra,
                            int                 linenum);
 static int
        mapping_cmpbaseaddr(struct if_mapping * ifnode,
@@ -254,6 +303,7 @@ static int
                       int *                    active,
                       char *                   pos,
                       size_t                   len,
+                      struct add_extra *       extra,
                       int                      linenum);
 static int
        mapping_cmpirq(struct if_mapping *      ifnode,
@@ -268,6 +318,7 @@ static int
                           int *                active,
                           char *               pos,
                           size_t               len,
+                          struct add_extra *   extra,
                           int                  linenum);
 static int
        mapping_cmpiwproto(struct if_mapping *  ifnode,
@@ -282,6 +333,7 @@ static int
                              int *                     active,
                              char *                    pos,
                              size_t                    len,
+                             struct add_extra *        extra,
                              int                       linenum);
 static int
        mapping_cmppcmciaslot(struct if_mapping *       ifnode,
@@ -291,6 +343,21 @@ static int
                              const char *              ifname,
                              struct if_mapping *       target,
                              int                       flag);
+static int
+       mapping_addsysfs(struct if_mapping *    ifnode,
+                        int *                  active,
+                        char *                 pos,
+                        size_t                 len,
+                        struct add_extra *     extra,
+                        int                    linenum);
+static int
+       mapping_cmpsysfs(struct if_mapping *    ifnode,
+                        struct if_mapping *    target);
+static int
+       mapping_getsysfs(int                    skfd,
+                        const char *           ifname,
+                        struct if_mapping *    target,
+                        int                    flag);
 
 /**************************** VARIABLES ****************************/
 
@@ -321,6 +388,8 @@ const struct mapping_selector       selector_list[] =
   { "iwproto", &mapping_addiwproto, &mapping_cmpiwproto, &mapping_getiwproto },
   /* Pcmcia slot from cardmgr */
   { "pcmciaslot", &mapping_addpcmciaslot, &mapping_cmppcmciaslot, &mapping_getpcmciaslot },
+  /* sysfs file (udev emulation) */
+  { "sysfs", &mapping_addsysfs, &mapping_cmpsysfs, &mapping_getsysfs },
   /* The Terminator */
   { NULL, NULL, NULL, NULL },
 };
@@ -329,6 +398,17 @@ const int selector_num = sizeof(selector_list)/sizeof(selector_list[0]);
 /* List of active selectors */
 int    selector_active[SELECT_NUM];    /* Selectors active */
 
+/*
+ * All the following flags are controlled by the command line switches...
+ * It's a bit hackish to have them all as global, so maybe we should pass
+ * them in a big struct as function arguments... More complex and
+ * probably not worth it ?
+ */
+
+/* Invocation type */
+int    print_newname = 0;
+char * new_name = NULL;
+
 /* Takeover support */
 int    force_takeover = 0;     /* Takeover name from other interface */
 int    num_takeover = 0;       /* Number of takeover done */
@@ -339,6 +419,13 @@ int        dry_run = 0;            /* Just print new name, don't rename */
 /* Verbose support (i.e. debugging) */
 int    verbose = 0;
 
+/* sysfs global data */
+struct sysfs_metadata  sysfs_global =
+{
+  NULL, 0,
+  0, { NULL, NULL, NULL, NULL, NULL },
+};
+
 /******************** INTERFACE NAME MANAGEMENT ********************/
 /*
  * Bunch of low level function for managing interface names.
@@ -515,10 +602,14 @@ mapping_addmac(struct if_mapping *        ifnode,
               int *                    active,
               char *                   string,
               size_t                   len,
+              struct add_extra *       extra,
               int                      linenum)
 {
   size_t       n;
 
+  /* Avoid "Unused parameter" warning */
+  extra = extra;
+
   /* Verify validity of string */
   if(len >= sizeof(ifnode->mac_filter))
     { 
@@ -547,7 +638,9 @@ mapping_addmac(struct if_mapping *  ifnode,
   else
     {
       /* Not a wildcard : "01:23:45:67:89:AB" */
-      if(iw_ether_aton(ifnode->mac_filter, &ifnode->mac) != 1)
+      ifnode->mac_len = iw_mac_aton(ifnode->mac_filter,
+                                   ifnode->mac, MAX_MAC_LEN);
+      if(ifnode->mac_len == 0)
        {
          fprintf(stderr, "Error: Invalid MAC address `%s' at line %d\n",
                  ifnode->mac_filter, linenum);
@@ -555,7 +648,7 @@ mapping_addmac(struct if_mapping *  ifnode,
        }
 
       /* Check that it's not NULL */
-      if(!memcmp(&ifnode->mac, &zero_mac, 6))
+      if((ifnode->mac_len == 6) && (!memcmp(&ifnode->mac, &zero_mac, 6)))
        {
          fprintf(stderr,
                  "Warning: MAC address is null at line %d, this is dangerous...\n",
@@ -590,8 +683,8 @@ mapping_cmpmac(struct if_mapping *  ifnode,
     return(fnmatch(ifnode->mac_filter, target->mac_filter, FNM_CASEFOLD));
   else
     /* Exact matching, in hex */
-    return(memcmp(&ifnode->mac.ether_addr_octet, &target->mac.ether_addr_octet,
-                 6));
+    return((ifnode->mac_len != target->mac_len) ||
+          memcmp(ifnode->mac, target->mac, ifnode->mac_len));
 }
 
 /*------------------------------------------------------------------*/
@@ -604,10 +697,14 @@ mapping_getmac(int                        skfd,
               struct if_mapping *      target,
               int                      flag)
 {
-  int  ret;
+  struct ifreq ifr;
+  int          ret;
+  int          i;
 
-  /* Extract MAC address */
-  ret = iw_get_mac_addr(skfd, ifname, &target->mac, &target->hw_type);
+  /* Get MAC address */
+  bzero(&ifr, sizeof(struct ifreq));
+  strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
+  ret = ioctl(skfd, SIOCGIFHWADDR, &ifr);
   if(ret < 0)
     {
       fprintf(stderr, "Error: Can't read MAC address on interface `%s' : %s\n",
@@ -615,11 +712,25 @@ mapping_getmac(int                        skfd,
       return(-1);
     }
 
+  /* Extract ARP type */
+  target->hw_type = ifr.ifr_hwaddr.sa_family;
+  /* Calculate address length */
+  target->mac_len = 6;
+  for(i = 0; i < weird_mac_len_num; i++)
+    if(weird_mac_len[i][0] == ifr.ifr_hwaddr.sa_family)
+      {
+       target->mac_len = weird_mac_len[i][1];
+       break;
+      }
+  /* Extract MAC address bytes */
+  memcpy(target->mac, ifr.ifr_hwaddr.sa_data, target->mac_len);
+
   /* Check the type of comparison */
   if((flag == HAS_MAC_FILTER) || verbose)
     {
       /* Convert to ASCII */
-      iw_ether_ntop(&target->mac, target->mac_filter);
+      iw_mac_ntop(target->mac, target->mac_len,
+                 target->mac_filter, sizeof(target->mac_filter));
     }
 
   target->active[SELECT_MAC] = flag;
@@ -642,11 +753,15 @@ mapping_addarp(struct if_mapping *        ifnode,
               int *                    active,
               char *                   string,
               size_t                   len,
+              struct add_extra *       extra,
               int                      linenum)
 {
   size_t       n;
   unsigned int type;
 
+  /* Avoid "Unused parameter" warning */
+  extra = extra;
+
   /* Verify validity of string, convert to int */
   n = strspn(string, "0123456789"); 
   if((n < len) || (sscanf(string, "%d", &type) != 1))
@@ -705,12 +820,16 @@ mapping_adddriver(struct if_mapping *     ifnode,
                  int *                 active,
                  char *                string,
                  size_t                len,
+                 struct add_extra *    extra,
                  int                   linenum)
 {
+  /* Avoid "Unused parameter" warning */
+  extra = extra;
+
   /* Plain string, minimal verification */
   if(len >= sizeof(ifnode->driver))
     { 
-      fprintf(stderr, "Driver name too long at line %d\n", linenum);  
+      fprintf(stderr, "Error: Driver name too long at line %d\n", linenum);  
       return(-1);
     }
 
@@ -750,12 +869,16 @@ mapping_addbusinfo(struct if_mapping *    ifnode,
                   int *                active,
                   char *               string,
                   size_t               len,
+                  struct add_extra *   extra,
                   int                  linenum)
 {
 #if 0
   size_t       n;
 #endif
 
+  /* Avoid "Unused parameter" warning */
+  extra = extra;
+
   /* Verify validity of string */
   if(len >= sizeof(ifnode->bus_info))
     { 
@@ -809,8 +932,12 @@ mapping_addfirmware(struct if_mapping *    ifnode,
                    int *               active,
                    char *              string,
                    size_t              len,
+                   struct add_extra *  extra,
                    int                 linenum)
 {
+  /* Avoid "Unused parameter" warning */
+  extra = extra;
+
   /* Verify validity of string */
   if(len >= sizeof(ifnode->fw_version))
     { 
@@ -913,11 +1040,15 @@ mapping_addbaseaddr(struct if_mapping *  ifnode,
                    int *               active,
                    char *              string,
                    size_t              len,
+                   struct add_extra *  extra,
                    int                 linenum)
 {
   size_t       n;
   unsigned int address;
 
+  /* Avoid "Unused parameter" warning */
+  extra = extra;
+
   /* Verify validity of string */
   n = strspn(string, "0123456789ABCDEFabcdefx"); 
   if((n < len) || (sscanf(string, "0x%X", &address) != 1))
@@ -963,11 +1094,15 @@ mapping_addirq(struct if_mapping *       ifnode,
               int *                    active,
               char *                   string,
               size_t                   len,
+              struct add_extra *       extra,
               int                      linenum)
 {
   size_t       n;
   unsigned int irq;
 
+  /* Avoid "Unused parameter" warning */
+  extra = extra;
+
   /* Verify validity of string */
   n = strspn(string, "0123456789"); 
   if((n < len) || (sscanf(string, "%d", &irq) != 1))
@@ -1068,8 +1203,12 @@ mapping_addiwproto(struct if_mapping *   ifnode,
                   int *                active,
                   char *               string,
                   size_t               len,
+                  struct add_extra *   extra,
                   int                  linenum)
 {
+  /* Avoid "Unused parameter" warning */
+  extra = extra;
+
   /* Verify validity of string */
   if(len >= sizeof(ifnode->iwproto))
     { 
@@ -1144,13 +1283,17 @@ mapping_getiwproto(int                  skfd,
  */
 static int
 mapping_addpcmciaslot(struct if_mapping *      ifnode,
-              int *                    active,
-              char *                   string,
-              size_t                   len,
-              int                      linenum)
+                     int *                     active,
+                     char *                    string,
+                     size_t                    len,
+                     struct add_extra *        extra,
+                     int                       linenum)
 {
   size_t       n;
 
+  /* Avoid "Unused parameter" warning */
+  extra = extra;
+
   /* Verify validity of string, convert to int */
   n = strspn(string, "0123456789"); 
   if((n < len) || (sscanf(string, "%d", &ifnode->pcmcia_slot) != 1))
@@ -1176,7 +1319,7 @@ mapping_addpcmciaslot(struct if_mapping * ifnode,
  */
 static int
 mapping_cmppcmciaslot(struct if_mapping *      ifnode,
-              struct if_mapping *      target)
+                     struct if_mapping *       target)
 {
   return(!(ifnode->pcmcia_slot == target->pcmcia_slot));
 }
@@ -1290,10 +1433,259 @@ mapping_getpcmciaslot(int                      skfd,
 
   /* Cleanup */
   free(linebuf);
+  fclose(stream);
 
   return(target->active[SELECT_PCMCIASLOT] ? 0 : -1);
 }
 
+/*------------------------------------------------------------------*/
+/*
+ * Add a sysfs selector to a mapping
+ */
+static int
+mapping_addsysfs(struct if_mapping *   ifnode,
+                int *                  active,
+                char *                 string,
+                size_t                 len,
+                struct add_extra *     extra,
+                int                    linenum)
+{
+  int          findex; /* filename index */
+  char *       sdup;
+
+  /* Check if we have a modifier */
+  if((extra == NULL) || (extra->modif_pos == NULL))
+    { 
+      fprintf(stderr, "Error: No SYSFS filename at line %d\n", linenum);  
+      return(-1);
+    }
+
+  /* Search if the filename already exist */
+  for(findex = 0; findex < sysfs_global.filenum; findex++)
+    {
+      if(!strcmp(extra->modif_pos, sysfs_global.filename[findex]))
+       break;
+    }
+
+  /* If filename does not exist, creates it */
+  if(findex == sysfs_global.filenum)
+    {
+      if(findex == SYSFS_MAX_FILE)
+       {
+         fprintf(stderr, "Error: Too many SYSFS filenames at line %d\n", linenum);  
+         return(-1);
+       }
+      sdup = strndup(extra->modif_pos, extra->modif_len);
+      if(sdup == NULL)
+       {
+         fprintf(stderr, "Error: Can't allocate SYSFS file\n");  
+         return(-1);
+       }
+      sysfs_global.filename[findex] = sdup;
+      sysfs_global.filenum++;
+    }
+
+  /* Store value */
+  sdup = strndup(string, len);
+  if(sdup == NULL)
+    {
+      fprintf(stderr, "Error: Can't allocate SYSFS value\n");  
+      return(-1);
+    }
+  ifnode->sysfs[findex] = sdup;
+
+  /* Activate */
+  ifnode->active[SELECT_SYSFS] = 1;
+  active[SELECT_SYSFS] = 1;
+
+  if(verbose)
+    fprintf(stderr,
+           "Parsing : Added SYSFS filename `%s' value `%s' from line %d.\n",
+           sysfs_global.filename[findex], ifnode->sysfs[findex], linenum);
+
+  return(0);
+}
+
+/*------------------------------------------------------------------*/
+/*
+ * Compare all the sysfs values of two mappings
+ */
+static int
+mapping_cmpsysfs(struct if_mapping *   ifnode,
+                struct if_mapping *    target)
+{
+  int          findex; /* filename index */
+  int          match = 1;
+
+  /* Loop on all sysfs selector */
+  for(findex = 0; findex < sysfs_global.filenum; findex++)
+    {
+      /* If the mapping defines this sysfs selector.. */
+      if(ifnode->sysfs[findex] != NULL)
+       /* And if the sysfs values don't match */
+       if((target->sysfs[findex] == NULL) ||
+          (fnmatch(ifnode->sysfs[findex], target->sysfs[findex],
+                   FNM_CASEFOLD)))
+         /* Then the sysfs selector doesn't match */
+         match = 0;
+    }
+
+  return(!match);
+}
+
+/*------------------------------------------------------------------*/
+/*
+ * Extract all the sysfs values of an interface
+ */
+static int
+mapping_getsysfs(int                   skfd,
+                const char *           ifname,
+                struct if_mapping *    target,
+                int                    flag)
+{
+  FILE *       stream;
+  char *       linebuf = NULL;
+  size_t       linelen = 0; 
+  char *       sdup;
+  int          findex; /* filename index */
+
+  /* Avoid "Unused parameter" warning */
+  skfd = skfd;
+  flag = flag;
+
+  /* Check if we know the root of the sysfs filesystem */
+  if(sysfs_global.root == NULL)
+    {
+      /* Open the mount file for reading */
+      stream = fopen("/proc/mounts", "r");
+      if(!stream) 
+       {
+         fprintf(stderr, "Error: Can't open /proc/mounts file: %s\n",
+                 strerror(errno)); 
+         return(-1);
+       }
+
+      /* Read each line of file
+       * getline is a GNU extension :-( The buffer is recycled and increased
+       * as needed by getline. */
+      while(getline(&linebuf, &linelen, stream) > 0)
+       {
+         char *        p;
+         size_t        n;
+
+         /* Get the line starting with sysfs */
+         p = linebuf;
+         while(isspace(*p))
+           ++p; 
+         if(!strncasecmp(p, "sysfs ", 6))
+           {
+             /* Find the mount point */
+             p += 6;
+             while(isspace(*p))
+               ++p;
+             n = strcspn(p, " \t\n");
+             sdup = strndup(p, n);
+             if((n == 0) || (sdup == NULL))
+               {
+                 fprintf(stderr, "Error: Can't parse /proc/mounts file: %s\n",
+                         strerror(errno)); 
+                 return(-1);
+               }
+             /* Store it */
+             sysfs_global.root = sdup;
+             sysfs_global.rlen = n;
+             break;
+           }
+         /* Finished -> next line */
+       }
+
+      /* Cleanup */
+      fclose(stream);
+
+      /* Check if we found it */
+      if(sysfs_global.root == NULL)
+       {
+         fprintf(stderr, "Error: Can't find sysfs in /proc/mounts file\n");
+         free(linebuf);
+         return(-1);
+       }
+    }
+
+  /* Loop on all sysfs selector */
+  for(findex = 0; findex < sysfs_global.filenum; findex++)
+    {
+      char *   fname;
+      int      flen;
+      char *   p;
+      ssize_t  n;
+
+      /* Construct complete filename for the sysfs selector */
+      flen = (sysfs_global.rlen + 11 + strlen(ifname) + 1 +
+             strlen(sysfs_global.filename[findex]) + 1);
+      fname = malloc(flen);
+      if(fname == NULL)
+       {
+         fprintf(stderr, "Error: Can't allocate SYSFS filename\n");  
+         free(linebuf);
+         return(-1);
+       }
+      sprintf(fname, "%s/class/net/%s/%s", sysfs_global.root, ifname,
+             sysfs_global.filename[findex]);
+
+      /* Open the sysfs file for reading */
+      stream = fopen(fname, "r");
+      if(!stream) 
+       {
+         /* Some sysfs attribute may no exist for some interface */
+         if(verbose)
+           fprintf(stderr, "Error: Can't open file `%s': %s\n", fname,
+                   strerror(errno)); 
+         /* Next sysfs selector */
+         continue;
+       }
+
+      /* Read file. Only one line in file. */
+      n = getline(&linebuf, &linelen, stream);
+      fclose(stream);
+      if(n <= 0)
+       {
+         /* Some sysfs attribute are void for some interface */
+         if(verbose)
+           fprintf(stderr, "Error: Can't read file `%s'\n", fname);
+         /* Next sysfs selector */
+         continue;
+       }
+
+      /* Get content, remove trailing '/n', save it */
+      p = linebuf;
+      if(p[n - 1] == '\n')
+       n--;
+      sdup = strndup(p, n);
+      if(sdup == NULL)
+       {
+         fprintf(stderr, "Error: Can't allocate SYSFS value\n"); 
+         free(linebuf);
+         return(-1);
+       }
+      target->sysfs[findex] = sdup;
+
+      /* Activate */
+      target->active[SELECT_SYSFS] = 1;
+
+      if(verbose)
+       fprintf(stderr,
+               "Querying %s : Got SYSFS filename `%s' value `%s'.\n",
+               ifname, sysfs_global.filename[findex], target->sysfs[findex]);
+
+      /* Finished : Next sysfs selector */
+    }
+
+  /* Cleanup */
+  free(linebuf);
+
+  return(target->active[SELECT_SYSFS] ? 0 : -1);
+}
+
 
 /*********************** MAPPING MANAGEMENTS ***********************/
 /*
@@ -1334,8 +1726,11 @@ mapping_create(char *    pos,
   memcpy(ifnode->ifname, pos, len); 
   ifnode->ifname[len] = '\0'; 
 
-  /* Check the interface name and issue various pedantic warnings */
-  if((!strcmp(ifnode->ifname, "eth0")) || (!strcmp(ifnode->ifname, "wlan0")))
+  /* Check the interface name and issue various pedantic warnings.
+   * We assume people using takeover want to force interfaces to those
+   * names and know what they are doing, so don't bother them... */
+  if((!force_takeover) &&
+     ((!strcmp(ifnode->ifname, "eth0")) || (!strcmp(ifnode->ifname, "wlan0"))))
     fprintf(stderr,
            "Warning: Interface name is `%s' at line %d, can't be mapped reliably.\n",
            ifnode->ifname, linenum);
@@ -1433,10 +1828,11 @@ selector_find(const char *      string,
 static int
 mapping_readfile(const char *  filename)
 {
-  FILE *       stream;
-  char *       linebuf = NULL;
-  size_t       linelen = 0; 
-  int          linenum = 0; 
+  FILE *               stream;
+  char *               linebuf = NULL;
+  size_t               linelen = 0; 
+  int                  linenum = 0; 
+  struct add_extra     extrainfo;
 
   /* Reset the list of filters */
   bzero(selector_active, sizeof(selector_active));
@@ -1497,9 +1893,10 @@ mapping_readfile(const char *    filename)
       while(*p != '\0')
        {
          const struct mapping_selector *       selector = NULL;
+         struct add_extra *                    extra = NULL;
 
-         /* Selector name length */
-         n = strcspn(p, " \t\n");
+         /* Selector name length - stop at modifier start */
+         n = strcspn(p, " \t\n{");
 
          /* Find it */
          selector = selector_find(p, n, linenum);
@@ -1508,9 +1905,33 @@ mapping_readfile(const char *    filename)
              ret = -1;
              break;
            }
+         p += n;
+
+         /* Check for modifier */
+         if(*p == '{')
+           {
+             p++;
+             /* Find end of modifier */
+             e = strchr(p, '}');
+             if(e == NULL)
+               {
+                 fprintf(stderr,
+                         "Error: unterminated selector modifier value on line %d\n",
+                         linenum);
+                 ret = -1;
+                 break;        /* Line ended */
+               }
+             /* Fill in struct and hook it */
+             extrainfo.modif_pos = p;
+             extrainfo.modif_len = e - p;
+             extra = &extrainfo;
+             /* Terminate modifier value */
+             e[0] = '\0';
+             /* Skip it */
+             p = e + 1;
+           }
 
          /* Get to selector value */
-         p += n;
          p += strspn(p, " \t\n"); 
          if(*p == '\0')
            {
@@ -1548,7 +1969,8 @@ mapping_readfile(const char *     filename)
          p[n] = '\0';
 
          /* Add it to the mapping */
-         ret = selector->add_fn(ifnode, selector_active, p, n, linenum);
+         ret = selector->add_fn(ifnode, selector_active, p, n,
+                                extra, linenum);
          if(ret < 0)
            break;
 
@@ -1683,8 +2105,7 @@ static void
 probe_mappings(int             skfd)
 {
   struct if_mapping *  ifnode;
-  struct ether_addr    mac;                    /* Exact MAC address, hex */
-  unsigned short       hw_type;
+  struct ifreq         ifr;
 
   /* Look over all our mappings */
   for(ifnode = mapping_list; ifnode != NULL; ifnode = ifnode->next)
@@ -1703,7 +2124,8 @@ probe_mappings(int                skfd)
        * Obviously, we expect this command to 'fail', as
        * the interface will load with the old/wrong name.
        */
-      iw_get_mac_addr(skfd, ifnode->ifname, &mac, &hw_type);
+      strncpy(ifr.ifr_name, ifnode->ifname, IFNAMSIZ);
+      ioctl(skfd, SIOCGIFHWADDR, &ifr);
     }
 }
 
@@ -1720,8 +2142,7 @@ probe_debian(int          skfd)
   FILE *               stream;
   char *               linebuf = NULL;
   size_t               linelen = 0; 
-  struct ether_addr    mac;                    /* Exact MAC address, hex */
-  unsigned short       hw_type;
+  struct ifreq         ifr;
 
   /* Open Debian config file */
   stream = fopen(DEBIAN_CONFIG_FILE, "r");
@@ -1769,8 +2190,9 @@ probe_debian(int          skfd)
                fprintf(stderr, "Probing : Trying to load interface [%s]\n",
                        p);
 
-             /* Do it ! */
-             iw_get_mac_addr(skfd, p, &mac, &hw_type);
+             /* Load interface */
+             strncpy(ifr.ifr_name, p, IFNAMSIZ);
+             ioctl(skfd, SIOCGIFHWADDR, &ifr);
 
              /* Go to next interface name */
              p = e;
@@ -1824,7 +2246,6 @@ process_rename(int        skfd,
       star[1] = 'd';
     }
 
-
   /* Change the name of the interface */
   if(if_set_name(skfd, ifname, newname, retname) < 0)
     {
@@ -1869,6 +2290,11 @@ process_ifname(int       skfd,
   if(mapping == NULL)
     return(-1);
 
+  /* If user specified a new name, keep only interfaces that would
+   * match the new name... */
+  if((new_name != NULL) && (if_match_ifname(mapping->ifname, new_name) != 0))
+    return(-1);
+
   /* Check if user want only dry-run.
    * Note that, in the case of wildcard, we don't resolve the wildcard.
    * That would be tricky to do... */
@@ -1888,7 +2314,7 @@ process_ifname(int        skfd,
     }
 
   /* Check if called with an explicit interface name */
-  if(!count)
+  if(print_newname)
     {
       /* Always print out the *new* interface name so that
        * the calling script can pick it up and know where its interface
@@ -1953,7 +2379,6 @@ main(int  argc,
 {
   const char * conf_file = DEFAULT_CONF;
   char *       ifname = NULL;
-  char *       newname = NULL;
   int          use_probe = 0;
   int          is_debian = 0;
   int          skfd;
@@ -1984,7 +2409,7 @@ main(int  argc,
          ifname = optarg;
          break;
        case 'n':
-         newname = optarg;
+         new_name = optarg;
          break;
        case 'p':
          use_probe = 1;
@@ -2013,13 +2438,13 @@ main(int        argc,
     }
 
   /* Check if interface name was specified with -i. */
-  if(ifname)
+  if(ifname != NULL)
     {
       /* Check is target name specified */
-      if(newname != NULL)
+      if(new_name != NULL)
        {
          /* User want to simply rename an interface to a specified name */
-         ret = process_rename(skfd, ifname, newname);
+         ret = process_rename(skfd, ifname, new_name);
        }
       else
        {
@@ -2028,6 +2453,7 @@ main(int  argc,
           * Process the network interface specified on the command line,
           * and return the new name on stdout.
           */
+         print_newname = 1;
          ret = process_ifname(skfd, ifname, NULL, 0);
        }
     }
@@ -2045,7 +2471,7 @@ main(int  argc,
       /* Rename all system interfaces
        * Mostly used for boot time processing (from init scripts).
        */
-      ret = process_iflist(skfd, &newname, 1);
+      ret = process_iflist(skfd, NULL, 0);
     }
 
   /* Cleanup */
index ca6ef69..c264f74 100644 (file)
@@ -66,11 +66,28 @@ attempt to change the name of the interface to the interface name
 given by the mapping.
 .PP
 The interface name of a mapping is either a plain interface name (such as
-.IR eth2 " or " wlan0 )
+.IR eth2 " or " wlan1 )
 or a interface name pattern containing a single wildcard (such as
 .IR eth* " or " wlan* ).
 In case of wildcard, the kernel replace the '*' with the lowest
-available integer making this interface name unique.
+available integer making this interface name unique. Note that
+wildcard is only supported for kernel 2.6.1 and 2.4.30 and later.
+.PP
+It is discouraged to try to map interfaces to default interfaces names
+such as
+.IR eth0 ", " wlan0 " or " ppp0 .
+The kernel use those as the default name for any new interface,
+therefore most likely an interface will already use this name and
+prevent ifrename to use it. Even if you use takeover, the interface
+may already be up in some cases. Not using those name will allow you
+to immediately spot unconfigured or new interfaces.
+.br
+Good names are either totally unique and meaningfull,
+such as
+.IR mydsl " or " privatehub ,
+or use larger integer, such as
+.IR eth5 " or " wlan5 .
+The second type is usually easier to integrate in various network utilities.
 .\"
 .\" DESCRIPTORS part
 .\"
@@ -156,6 +173,18 @@ using
 This selector is usually only supported on 16 bits cards, for 32 bits
 cards it is advised to use the selector
 .BR businfo .
+.TP
+.BI SYSFS{ filename } " value"
+Matches the sysfs attribute given by filename to the specified value. sysfs attributes of the interface can be read in one of the directory in the directory 
+.IR /sys/class/net/ .
+For example, the filename
+.I address
+is the MAC address of the device and should be identical to the selector
+.BR mac .
+.br
+The sysfs filesystem is only supported with 2.6.X kernel and need to
+be mounted. sysfs selectors are not as efficient as other selectors,
+therefore they should be avoided for maximum performance.
 .\"
 .\" EXAMPLE part
 .\"
@@ -169,6 +198,8 @@ eth3                driver wavelan interrupt 15 baseaddress 0x390
 eth4           driver pcnet32 businfo 0000:02:05.0
 .br
 air*           mac 00:07:0E:* arp 1
+.br
+myvpn  SYSFS{address} 00:10:83:*
 .\"
 .\" AUTHOR part
 .\"
index a6a7a89..d03710e 100644 (file)
@@ -1,7 +1,7 @@
 .\" Jean II - HPLB - 1996 => HPL - 2004
 .\" iwconfig.8
 .\"
-.TH IWCONFIG 8 "22 June 2004" "wireless-tools" "Linux Programmer's Manual"
+.TH IWCONFIG 8 "09 March 2006" "wireless-tools" "Linux Programmer's Manual"
 .\"
 .\" NAME part
 .\"
@@ -13,9 +13,9 @@ iwconfig \- configure a wireless network interface
 .SH SYNOPSIS
 .BI "iwconfig [" interface ]
 .br
-.BI "iwconfig " interface " [essid " X "] [nwid " N "] [freq " F "] [channel " C ]
+.BI "iwconfig " interface " [essid " X "] [nwid " N "] [mode " M "] [freq " F "]
 .br
-.BI "                   [sens " S "] [mode " M "] [ap " A "] [nick " NN ]
+.BI "                   [channel " C ] [sens " S "] [ap " A "] [nick " NN ]
 .br
 .BI "                   [rate " R "] [rts " RT "] [frag " FT "] [txpower " T ]
 .br
@@ -64,11 +64,19 @@ promiscuous) with
 .IR off " or " any " (and " on
 to reenable it).
 .br
+If the ESSID of your network is one of the special keywords
+.RI ( off ", " on " or " any ),
+you should use
+.I --
+to escape it.
+.br
 .B Examples :
 .br
 .I "   iwconfig eth0 essid any"
 .br
 .I "   iwconfig eth0 essid ""My Network""
+.br
+.I "   iwconfig eth0 essid -- ""ANY""
 .TP
 .BR nwid / domain
 Set the Network ID (in some products it may also be called Domain
@@ -90,42 +98,15 @@ to reenable it).
 .br
 .I "   iwconfig eth0 nwid off"
 .TP
-.BR freq / channel
-Set the operating frequency or channel in the device. A value below
-1000 indicates a channel number, a value greater than 1000 is a
-frequency in Hz. You may append the suffix k, M or G to the value (for
-example, "2.46G" for 2.46 GHz frequency), or add enough '0'.
-.br
-Channels are usually numbered starting at 1, and you may use
-.IR iwlist (8)
-to get the total number of channels, list the available frequencies,
-and display the current frequency as a channel. Depending on
-regulations, some frequencies/channels may not be available.
-.br
-.B Examples :
-.br
-.I "   iwconfig eth0 freq 2422000000"
-.br
-.I "   iwconfig eth0 freq 2.422G"
-.br
-.I "   iwconfig eth0 channel 3"
-.TP
-.B sens
-Set the sensitivity threshold. This is the lowest signal level for
-which the hardware attempt packet reception, signals weaker than this
-are ignored. This is used to avoid receiving background noise, so you
-should set it according to the average noise level. Positive values
-are assumed to be the raw value used by the hardware or a percentage,
-negative values are assumed to be dBm.
-.br
-With some hardware, this parameter also controls the defer threshold
-(lowest signal level for which the hardware consider the channel busy)
-and the handover threshold (signal level where the hardware start
-looking for a new access point).
+.BR nick [name]
+Set the nickname, or the station name. Some 802.11 products do define
+it, but this is not used as far as the protocols (MAC, IP, TCP) are
+concerned and completely useless as far as configuration goes. Only
+some wireless diagnostic tools may use it.
 .br
 .B Example :
 .br
-.I "   iwconfig eth0 sens -80"
+.I "   iwconfig eth0 nickname ""My Linux Node""
 .TP
 .B mode
 Set the operating mode of the device, which depends on the network
@@ -141,7 +122,8 @@ topology. The mode can be
 .I Secondary
 (the node acts as a backup master/repeater),
 .I Monitor
-(the node acts as a passive monitor and only receives packets) or
+(the node is not associated with any cell and passively monitor all
+packets on the frequency) or
 .IR Auto .
 .br
 .B Example :
@@ -150,11 +132,50 @@ topology. The mode can be
 .br
 .I "   iwconfig eth0 mode Ad-Hoc"
 .TP
+.BR freq / channel
+Set the operating frequency or channel in the device. A value below
+1000 indicates a channel number, a value greater than 1000 is a
+frequency in Hz. You may append the suffix k, M or G to the value (for
+example, "2.46G" for 2.46 GHz frequency), or add enough '0'.
+.br
+Channels are usually numbered starting at 1, and you may use
+.IR iwlist (8)
+to get the total number of channels, list the available frequencies,
+and display the current frequency as a channel. Depending on
+regulations, some frequencies/channels may not be available.
+.br
+When using Managed mode, most often the Access Point dictates the
+channel and the driver may refuse the setting of the frequency. In
+Ad-Hoc mode, the frequency setting may only be used at initial cell
+creation, and may be ignored when joining an existing cell.
+.br
+You may also use
+.I off
+or
+.I auto
+to let the card pick up the best channel (when supported).
+.br
+.B Examples :
+.br
+.I "   iwconfig eth0 freq 2422000000"
+.br
+.I "   iwconfig eth0 freq 2.422G"
+.br
+.I "   iwconfig eth0 channel 3"
+.br
+.I "   iwconfig eth0 channel auto"
+.TP
 .B ap
 Force the card to register to the Access Point given by the address,
-if it is possible. When the quality of the connection goes too low,
-the driver may revert back to automatic mode (the card selects the
-best Access Point in range).
+if it is possible. This address is the cell identity of the Access
+Point, as reported by wireless scanning, which may be different from
+its network MAC address. If the wireless link is point to point, set
+the address of the other end of the link. If the link is ad-hoc, set
+the cell identity of the ad-hoc network.
+.br
+When the quality of the connection goes too low, the driver may revert
+back to automatic mode (the card selects the best Access Point in
+range).
 .br
 You may also use
 .I off
@@ -173,16 +194,6 @@ to force the card to reassociate with the currently best Access Point.
 .br
 .I "   iwconfig eth0 ap off"
 .TP
-.BR nick [name]
-Set the nickname, or the station name. Some 802.11 products do define
-it, but this is not used as far as the protocols (MAC, IP, TCP) are
-concerned and completely useless as far as configuration goes. Only
-some diagnostic tools may use it.
-.br
-.B Example :
-.br
-.I "   iwconfig eth0 nickname ""My Linux Node""
-.TP
 .BR rate / bit [rate]
 For cards supporting multiple bit rates, set the bit-rate in b/s. The
 bit-rate is the speed at which bits are transmitted over the medium,
@@ -208,12 +219,100 @@ the driver will use all bit-rates lower and equal than this value.
 .br
 .I "   iwconfig eth0 rate 5.5M auto"
 .TP
+.BR txpower
+For cards supporting multiple transmit powers, sets the transmit power
+in dBm. If
+.I W
+is the power in Watt, the power in dBm is
+.IR "P = 30 + 10.log(W)" .
+If the value is postfixed by
+.IR mW ,
+it will be automatically converted to dBm.
+.br
+In addition, 
+.IR on " and " off
+enable and disable the radio, and
+.IR auto " and " fixed
+enable and disable power control (if those features are available).
+.br
+.B Examples :
+.br
+.I "   iwconfig eth0 txpower 15"
+.br
+.I "   iwconfig eth0 txpower 30mW"
+.br
+.I "   iwconfig eth0 txpower auto"
+.br
+.I "   iwconfig eth0 txpower off"
+.TP
+.B sens
+Set the sensitivity threshold. This define how sensitive is the card
+to poor operating conditions (low signal, interference). Positive
+values are assumed to be the raw value used by the hardware or a
+percentage, negative values are assumed to be dBm. Depending on the
+hardware implementation, this parameter may control various functions.
+.br
+On modern cards, this parameter usually control handover/roaming
+threshold, the lowest signal level for which the hardware remains
+associated with the current Access Point. When the signal level goes
+below this threshold the card starts looking for a new/better Access
+Point. Some cards may use the number of missed beacons to trigger
+this. For high density of Access Points, a higher threshold make sure
+the card is always associated with the best AP, for low density of
+APs, a lower threshold minimise the number of failed handoffs.
+.br
+On more ancient card this parameter usually controls the defer
+threshold, the lowest signal level for which the hardware considers
+the channel busy. Signal levels above this threshold make the hardware
+inhibits its own transmission whereas signals weaker than this are
+ignored and the hardware is free to transmit. This is usually strongly
+linked to the receive threshold, the lowest signal level for which the
+hardware attempts packet reception. Proper setting of these thresholds
+prevent the card to waste time on background noise while still
+receiving weak transmissions. Modern designs seems to control those
+thresholds automatically.
+.br
+.br
+.B Example :
+.br
+.I "   iwconfig eth0 sens -80"
+.br
+.I "   iwconfig eth0 sens 2"
+.TP
+.BR retry
+Most cards have MAC retransmissions, and some allow to set the
+behaviour of the retry mechanism.
+.br
+To set the maximum number of retries, enter
+.IR "limit `value'" .
+This is an absolute value (without unit).
+To set the maximum length of time the MAC should retry, enter
+.IR "lifetime `value'" .
+By defaults, this value in in seconds, append the suffix m or u to
+specify values in milliseconds or microseconds.
+.br
+You can also add the
+.IR min " and " max
+modifiers. If the card supports automatic mode, they define the bounds
+of the limit or lifetime. Some other cards define different values
+depending on packet size, for example in 802.11
+.I min limit
+is the short retry limit (non RTS/CTS packets).
+.br
+.B Examples :
+.br
+.I "   iwconfig eth0 retry 16"
+.br
+.I "   iwconfig eth0 retry lifetime 300m"
+.br
+.I "   iwconfig eth0 retry min limit 8"
+.TP
 .BR rts [_threshold]
 RTS/CTS adds a handshake before each packet transmission to make sure
 that the channel is clear. This adds overhead, but increases
 performance in case of hidden nodes or a large number of active
 nodes. This parameter sets the size of the smallest packet for which
-the node sends RTS ; a value equal to the maximum packet size disable
+the node sends RTS ; a value equal to the maximum packet size disables
 the mechanism. You may also set this parameter to
 .IR auto ", " fixed " or " off .
 .br
@@ -228,8 +327,15 @@ Fragmentation allows to split an IP packet in a burst of smaller
 fragments transmitted on the medium. In most cases this adds overhead,
 but in a very noisy environment this reduces the error penalty and
 allow packets to get through interference bursts. This parameter sets
-the maximum fragment size ; a value equal to the maximum packet size
-disable the mechanism. You may also set this parameter to
+the maximum fragment size which is always lower than the maximum
+packet size.
+.br
+This parameter may also control Frame Bursting available on some
+cards, the ability to send multiple IP packets together. This
+mechanism would be enabled if the fragment size is larger than the
+maximum packet size.
+.br
+You may also set this parameter to
 .IR auto ", " fixed " or " off .
 .br
 .B Examples :
@@ -329,62 +435,9 @@ management mode to
 .br
 .I "   iwconfig eth0 power min period 2 power max period 4"
 .TP
-.BR txpower
-For cards supporting multiple transmit powers, set the transmit power in dBm. If 
-.I W
-is the power in Watt, the power in dBm is
-.IR "P = 30 + 10.log(W)" .
-If the value is postfixed by
-.IR mW ,
-it will be automatically converted to dBm.
-.br
-In addition, 
-.IR on " and " off
-enable and disable the radio, and
-.IR auto " and " fixed
-enable and disable power control (if those features are available).
-.br
-.B Examples :
-.br
-.I "   iwconfig eth0 txpower 15"
-.br
-.I "   iwconfig eth0 txpower 30mW"
-.br
-.I "   iwconfig eth0 txpower auto"
-.br
-.I "   iwconfig eth0 txpower off"
-.TP
-.BR retry
-Most cards have MAC retransmissions, and some allow to set the
-behaviour of the retry mechanism.
-.br
-To set the maximum number of retries, enter
-.IR "limit `value'" .
-This is an absolute value (without unit).
-The set the maximum length of time the MAC should retry, enter
-.IR "lifetime `value'" .
-By defaults, this value in in seconds, append the suffix m or u to
-specify values in milliseconds or microseconds.
-.br
-You can also add the
-.IR min " and " max
-modifiers. If the card supports automatic mode, they define the bounds
-of the limit or lifetime. Some other cards define different values
-depending on packet size, for example in 802.11
-.I min limit
-is the short retry limit (non RTS/CTS packets).
-.br
-.B Examples :
-.br
-.I "   iwconfig eth0 retry 16"
-.br
-.I "   iwconfig eth0 retry lifetime 300m"
-.br
-.I "   iwconfig eth0 retry min limit 8"
-.TP
 .BR commit
 Some cards may not apply changes done through Wireless Extensions
-immediately (they may wait to agregate the changes or apply it only
+immediately (they may wait to aggregate the changes or apply it only
 when the card is brought up via ifconfig). This command (when
 available) forces the card to apply all pending changes.
 .br
@@ -411,7 +464,7 @@ the
 of operation, the
 .B Access Point
 address, the
-.B bit-rate
+.BR bit-rate ,
 the
 .BR "RTS threshold" ", the " "fragmentation threshold" ,
 the
@@ -421,10 +474,10 @@ and the
 settings (depending on availability).
 .PP
 The parameters displayed have the same meaning and values as the
-parameter you can set, please refer to the previous part for a
+parameters you can set, please refer to the previous part for a
 detailed explanation of them.
 .br
-Some parameters are only displayed in short/abreviated form (such as
+Some parameters are only displayed in short/abbreviated form (such as
 encryption). You may use
 .IR iwlist (8)
 to get all the details.
index ace3f8c..03093e6 100644 (file)
 static void
 iw_usage(void)
 {
-  fprintf(stderr, "Usage: iwconfig interface [essid {NN|on|off}]\n");
-  fprintf(stderr, "                          [nwid {NN|on|off}]\n");
-  fprintf(stderr, "                          [mode {managed|ad-hoc|...}\n");
-  fprintf(stderr, "                          [freq N.NNNN[k|M|G]]\n");
-  fprintf(stderr, "                          [channel N]\n");
-  fprintf(stderr, "                          [ap {N|off|auto}]\n");
-  fprintf(stderr, "                          [sens N]\n");
-  fprintf(stderr, "                          [nick N]\n");
-  fprintf(stderr, "                          [rate {N|auto|fixed}]\n");
-  fprintf(stderr, "                          [rts {N|auto|fixed|off}]\n");
-  fprintf(stderr, "                          [frag {N|auto|fixed|off}]\n");
-  fprintf(stderr, "                          [enc {NNNN-NNNN|off}]\n");
-  fprintf(stderr, "                          [power {period N|timeout N}]\n");
-  fprintf(stderr, "                          [txpower N {mW|dBm}]\n");
-  fprintf(stderr, "                          [commit]\n");
-  fprintf(stderr, "       Check man pages for more details.\n\n");
+  fprintf(stderr,
+       "Usage: iwconfig interface [essid {NN|on|off}]\n"
+       "                          [nwid {NN|on|off}]\n"
+       "                          [mode {managed|ad-hoc|...}\n"
+       "                          [freq N.NNNN[k|M|G]]\n"
+       "                          [channel N]\n"
+       "                          [ap {N|off|auto}]\n"
+       "                          [sens N]\n"
+       "                          [nick N]\n"
+       "                          [rate {N|auto|fixed}]\n"
+       "                          [rts {N|auto|fixed|off}]\n"
+       "                          [frag {N|auto|fixed|off}]\n"
+       "                          [enc {NNNN-NNNN|off}]\n"
+       "                          [power {period N|timeout N}]\n"
+       "                          [retry {limit N|lifetime N}]\n"
+       "                          [txpower N {mW|dBm}]\n"
+       "                          [commit]\n"
+       "       Check man pages for more details.\n\n"
+  );
 }
 
 
@@ -154,6 +157,38 @@ get_info(int                       skfd,
       info->has_stats = 1;
     }
 
+#ifdef DISPLAY_WPA
+  /* Note : currently disabled to not bloat iwconfig output. Also,
+   * if does not make total sense to display parameters that we
+   * don't allow (yet) to configure.
+   * For now, use iwlist instead... Jean II */
+
+  /* Get WPA/802.1x/802.11i security parameters */
+  if((info->has_range) && (info->range.we_version_compiled > 17))
+    {
+      wrq.u.param.flags = IW_AUTH_KEY_MGMT;
+      if(iw_get_ext(skfd, ifname, SIOCGIWAUTH, &wrq) >= 0)
+       {
+         info->has_auth_key_mgmt = 1;
+         info->auth_key_mgmt = wrq.u.param.value;
+       }
+
+      wrq.u.param.flags = IW_AUTH_CIPHER_PAIRWISE;
+      if(iw_get_ext(skfd, ifname, SIOCGIWAUTH, &wrq) >= 0)
+       {
+         info->has_auth_cipher_pairwise = 1;
+         info->auth_cipher_pairwise = wrq.u.param.value;
+       }
+
+      wrq.u.param.flags = IW_AUTH_CIPHER_GROUP;
+      if(iw_get_ext(skfd, ifname, SIOCGIWAUTH, &wrq) >= 0)
+       {
+         info->has_auth_cipher_group = 1;
+         info->auth_cipher_group = wrq.u.param.value;
+       }
+    }
+#endif
+
   return(0);
 }
 
@@ -204,7 +239,7 @@ display_info(struct wireless_info * info,
   /* Display Network ID */
   if(info->b.has_nwid)
     {
-      /* Note : should display proper number of digit according to info
+      /* Note : should display proper number of digits according to info
        * in range structure */
       if(info->b.nwid.disabled)
        printf("NWID:off/any  ");
@@ -225,7 +260,7 @@ display_info(struct wireless_info * info,
     {
       double           freq = info->b.freq;    /* Frequency/channel */
       int              channel = -1;           /* Converted to channel */
-      /* Some driver insist of returning channel instead of frequency.
+      /* Some drivers insist of returning channel instead of frequency.
        * This fixes them up. Note that, driver should still return
        * frequency, because other tools depend on it. */
       if(info->has_range && (freq < KILO))
@@ -252,7 +287,7 @@ display_info(struct wireless_info * info,
        printf("Cell:");
       else
        printf("Access Point:");
-      printf(" %s   ", iw_pr_ether(buffer, info->ap_addr.sa_data));
+      printf(" %s   ", iw_sawap_ntop(&info->ap_addr, buffer));
     }
 
   /* Display the currently used/set bit-rate */
@@ -397,7 +432,7 @@ display_info(struct wireless_info * info,
     {
       printf("Encryption key:");
       if((info->b.key_flags & IW_ENCODE_DISABLED) || (info->b.key_size == 0))
-       printf("off\n          ");
+       printf("off");
       else
        {
          /* Display the key */
@@ -412,9 +447,25 @@ display_info(struct wireless_info *        info,
            printf("   Security mode:restricted");
          if(info->b.key_flags & IW_ENCODE_OPEN)
            printf("   Security mode:open");
-         printf("\n          ");
        }
+      printf("\n          ");
+    }
+
+#ifdef DISPLAY_WPA
+  /* Display WPA/802.1x/802.11i security parameters */
+  if(info->has_auth_key_mgmt || info->has_auth_cipher_pairwise ||
+     info->has_auth_cipher_group)
+    {
+      printf("Auth params:");
+      if(info->has_auth_key_mgmt)
+       printf(" key_mgmt:0x%X ", info->auth_key_mgmt);
+      if(info->has_auth_cipher_pairwise)
+       printf(" cipher_pairwise:0x%X ", info->auth_cipher_pairwise);
+      if(info->has_auth_cipher_group)
+       printf(" cipher_group:0x%X ", info->auth_cipher_group);
+      printf("\n          ");
     }
+#endif
 
   /* Display Power Management information */
   /* Note : we display only one parameter, period or timeout. If a device
@@ -424,7 +475,7 @@ display_info(struct wireless_info * info,
       printf("Power Management");
       /* Disabled ? */
       if(info->power.disabled)
-       printf(":off\n          ");
+       printf(":off");
       else
        {
          /* Let's check the value and its type */
@@ -442,8 +493,8 @@ display_info(struct wireless_info * info,
          /* Let's check if nothing (simply on) */
          if(info->power.flags == IW_POWER_ON)
            printf(":on");
-         printf("\n          ");
        }
+      printf("\n          ");
     }
 
   /* Display statistics */
@@ -812,6 +863,7 @@ set_info(int                skfd,           /* The socket */
       if(!strcasecmp(args[i], "essid"))
        {
          char          essid[IW_ESSID_MAX_SIZE + 1];
+         int           we_kernel_version;
 
          i++;
          if(i >= count)
@@ -826,6 +878,7 @@ set_info(int                skfd,           /* The socket */
            if(!strcasecmp(args[i], "on"))
              {
                /* Get old essid */
+               memset(essid, '\0', sizeof(essid));
                wrq.u.essid.pointer = (caddr_t) essid;
                wrq.u.essid.length = IW_ESSID_MAX_SIZE + 1;
                wrq.u.essid.flags = 0;
@@ -835,10 +888,10 @@ set_info(int              skfd,           /* The socket */
              }
            else
              {
-               /* '-' allow to escape the ESSID string, allowing
+               /* '-' or '--' allow to escape the ESSID string, allowing
                 * to set it to the string "any" or "off".
                 * This is a big ugly, but it will do for now */
-               if(!strcmp(args[i], "-"))
+               if((!strcmp(args[i], "-")) || (!strcmp(args[i], "--")))
                  {
                    i++;
                    if(i >= count)
@@ -867,8 +920,14 @@ set_info(int               skfd,           /* The socket */
                  }
              }
 
+         /* Get version from kernel, device may not have range... */
+         we_kernel_version = iw_get_kernel_we_version();
+
+         /* Finally set the ESSID value */
          wrq.u.essid.pointer = (caddr_t) essid;
          wrq.u.essid.length = strlen(essid) + 1;
+         if(we_kernel_version > 20)
+           wrq.u.essid.length--;
          IW_SET_EXT_ERR(skfd, ifname, SIOCSIWESSID, &wrq,
                         "Set ESSID");
          continue;
@@ -909,14 +968,20 @@ set_info(int              skfd,           /* The socket */
       /* ---------- Set NickName ---------- */
       if(!strncmp(args[i], "nick", 4))
        {
+         int           we_kernel_version;
+
          i++;
          if(i >= count)
            ABORT_ARG_NUM("Set Nickname", SIOCSIWNICKN);
          if(strlen(args[i]) > IW_ESSID_MAX_SIZE)
            ABORT_ARG_SIZE("Set Nickname", SIOCSIWNICKN, IW_ESSID_MAX_SIZE);
 
+         we_kernel_version = iw_get_kernel_we_version();
+
          wrq.u.essid.pointer = (caddr_t) args[i];
          wrq.u.essid.length = strlen(args[i]) + 1;
+         if(we_kernel_version > 20)
+           wrq.u.essid.length--;
          IW_SET_EXT_ERR(skfd, ifname, SIOCSIWNICKN, &wrq,
                         "Set Nickname");
          continue;
@@ -1082,6 +1147,7 @@ set_info(int              skfd,           /* The socket */
            if(!strcasecmp(args[i], "on"))
              {
                /* Get old Power info */
+               wrq.u.power.flags = 0;
                IW_GET_EXT_ERR(skfd, ifname, SIOCGIWPOWER, &wrq,
                               "Set Power Management");
                wrq.u.power.disabled = 0;
@@ -1218,8 +1284,13 @@ set_info(int             skfd,           /* The socket */
                          ABORT_ARG_TYPE("Set Tx Power", SIOCSIWTXPOW,
                                         args[i]);
 
-                       /* Check if milliwatt */
-                       ismwatt = (index(args[i], 'm') != NULL);
+                       /* Check if milliWatt
+                        * We authorise a single 'm' as a shorthand for 'mW',
+                        * on the other hand a 'd' probably means 'dBm'... */
+                       ismwatt = ((index(args[i], 'm') != NULL)
+                                  && (index(args[i], 'd') == NULL));
+
+                       /* We could check 'W' alone... Another time... */
 
                        /* Convert */
                        if(range.txpower_capa & IW_TXPOW_RELATIVE)
@@ -1374,15 +1445,24 @@ main(int        argc,
       iw_usage();
     else
       /* Special case for version... */
-      if (!strcmp(argv[1], "-v") || !strcmp(argv[1], "--version"))
+      if(!strcmp(argv[1], "-v") || !strcmp(argv[1], "--version"))
        goterr = iw_print_version_info("iwconfig");
       else
-       /* The device name must be the first argument */
-       if(argc == 2)
-         print_info(skfd, argv[1], NULL, 0);
-       else
-         /* The other args on the line specify options to be set... */
-         goterr = set_info(skfd, argv + 2, argc - 2, argv[1]);
+       {
+         /* '--' escape device name */
+         if((argc > 2) && !strcmp(argv[1], "--"))
+           {
+             argv++;
+             argc--;
+           }
+
+         /* The device name must be the first argument */
+         if(argc == 2)
+           print_info(skfd, argv[1], NULL, 0);
+         else
+           /* The other args on the line specify options to be set... */
+           goterr = set_info(skfd, argv + 2, argc - 2, argv[1]);
+       }
 
   /* Close the socket. */
   iw_sockets_close(skfd);
index 7251361..02a98e0 100644 (file)
@@ -18,8 +18,8 @@ iwevent \- Display Wireless Events generated by drivers and setting changes
 .\"
 .SH DESCRIPTION
 .B iwevent
-display Wireless Events received through the RTNetlink socket. Each
-line display the specific Wireless Event which describe what has
+displays Wireless Events received through the RTNetlink socket. Each
+line displays the specific Wireless Event which describes what has
 happened on the specified wireless interface.
 .br
 This command doesn't take any arguments.
@@ -27,7 +27,7 @@ This command doesn't take any arguments.
 .\" DISPLAY part
 .\"
 .SH DISPLAY
-There is two classes of Wireless Events.
+There are two classes of Wireless Events.
 .PP
 The first class is events related to a change of wireless settings on
 the interface (typically done through
@@ -57,7 +57,7 @@ something happens or a task has been finished. Those events include :
 .TP
 .B New Access Point/Cell address
 The interface has joined a new Access Point or Ad-Hoc Cell, or lost
-its association with it. This is the same MAC address that is reported
+its association with it. This is the same address that is reported
 by
 .BR iwconfig .
 .TP
@@ -78,17 +78,17 @@ Event specific to the driver. Please check the driver documentation.
 .TP
 .B Registered node
 The interface has successfully registered a new wireless
-client/peer. Will be generated mostly when the interface act as an
-Access Point (mode master).
+client/peer. Will be generated mostly when the interface acts as an
+Access Point (mode Master).
 .TP
 .B Expired node
 The registration of the client/peer on this interface has
-expired. Will be generated mostly when the interface act as an Access
-Point (mode master).
+expired. Will be generated mostly when the interface acts as an Access
+Point (mode Master).
 .TP
 .B Spy threshold crossed
-The signal strength for one of the address in the spy list went under
-the low threshold or went above than the high threshold.
+The signal strength for one of the addresses in the spy list went
+under the low threshold or went above the high threshold.
 .PP
 Most wireless drivers generate only a subset of those events, not all
 of them, the exact list depends on the specific hardware/driver
index 525cb68..c31964b 100644 (file)
@@ -106,7 +106,8 @@ static inline int rtnl_open(struct rtnl_handle *rth, unsigned subscriptions)
                return -1;
        }
        addr_len = sizeof(rth->local);
-       if (getsockname(rth->fd, (struct sockaddr*)&rth->local, &addr_len) < 0) {
+       if (getsockname(rth->fd, (struct sockaddr*)&rth->local,
+                       (socklen_t *) &addr_len) < 0) {
                perror("Cannot getsockname");
                return -1;
        }
@@ -271,6 +272,26 @@ iw_del_interface_data(int  ifindex)
 
 /*------------------------------------------------------------------*/
 /*
+ * Dump a buffer as a serie of hex
+ * Maybe should go in iwlib...
+ * Maybe we should have better formatting like iw_print_key...
+ */
+static char *
+iw_hexdump(char *              buf,
+          size_t               buflen,
+          const unsigned char *data,
+          size_t               datalen)
+{
+  size_t       i;
+  char *       pos = buf;
+
+  for(i = 0; i < datalen; i++)
+    pos += snprintf(pos, buf + buflen - pos, "%02X", data[i]);
+  return buf;
+}
+
+/*------------------------------------------------------------------*/
+/*
  * Print one element from the scanning results
  */
 static inline int
@@ -279,6 +300,7 @@ print_event_token(struct iw_event * event,          /* Extracted token */
                  int                   has_range)
 {
   char         buffer[128];    /* Temporary buffer */
+  char         buffer2[30];    /* Temporary buffer */
   char *       prefix = (IW_IS_GET(event->cmd) ? "New" : "Set");
 
   /* Now, let's decode the event */
@@ -320,9 +342,9 @@ print_event_token(struct iw_event * event,          /* Extracted token */
     case SIOCGIWESSID:
       {
        char essid[IW_ESSID_MAX_SIZE+1];
+       memset(essid, '\0', sizeof(essid));
        if((event->u.essid.pointer) && (event->u.essid.length))
          memcpy(essid, event->u.essid.pointer, event->u.essid.length);
-       essid[event->u.essid.length] = '\0';
        if(event->u.essid.flags)
          {
            /* Does it have an ESSID index ? */
@@ -340,7 +362,7 @@ print_event_token(struct iw_event * event,          /* Extracted token */
       {
        unsigned char   key[IW_ENCODING_TOKEN_MAX];
        if(event->u.data.pointer)
-         memcpy(key, event->u.essid.pointer, event->u.data.length);
+         memcpy(key, event->u.data.pointer, event->u.data.length);
        else
          event->u.data.flags |= IW_ENCODE_NOKEY;
        printf("Set Encryption key:");
@@ -368,31 +390,31 @@ print_event_token(struct iw_event *       event,          /* Extracted token */
       /* Events generated by the driver when something important happens */
     case SIOCGIWAP:
       printf("New Access Point/Cell address:%s\n",
-            iw_pr_ether(buffer, event->u.ap_addr.sa_data));
+            iw_sawap_ntop(&event->u.ap_addr, buffer));
       break;
     case SIOCGIWSCAN:
       printf("Scan request completed\n");
       break;
     case IWEVTXDROP:
       printf("Tx packet dropped:%s\n",
-            iw_pr_ether(buffer, event->u.addr.sa_data));
+            iw_saether_ntop(&event->u.addr, buffer));
       break;
     case IWEVCUSTOM:
       {
        char custom[IW_CUSTOM_MAX+1];
+       memset(custom, '\0', sizeof(custom));
        if((event->u.data.pointer) && (event->u.data.length))
          memcpy(custom, event->u.data.pointer, event->u.data.length);
-       custom[event->u.data.length] = '\0';
        printf("Custom driver event:%s\n", custom);
       }
       break;
     case IWEVREGISTERED:
       printf("Registered node:%s\n",
-            iw_pr_ether(buffer, event->u.addr.sa_data));
+            iw_saether_ntop(&event->u.addr, buffer));
       break;
     case IWEVEXPIRED:
       printf("Expired node:%s\n",
-            iw_pr_ether(buffer, event->u.addr.sa_data));
+            iw_saether_ntop(&event->u.addr, buffer));
       break;
     case SIOCGIWTHRSPY:
       {
@@ -402,7 +424,7 @@ print_event_token(struct iw_event * event,          /* Extracted token */
            memcpy(&threshold, event->u.data.pointer,
                   sizeof(struct iw_thrspy));
            printf("Spy threshold crossed on address:%s\n",
-                  iw_pr_ether(buffer, threshold.addr.sa_data));
+                  iw_saether_ntop(&threshold.addr, buffer));
            iw_print_stats(buffer, sizeof(buffer),
                           &threshold.qual, iw_range, has_range);
            printf("                            Link %s\n", buffer);
@@ -411,6 +433,40 @@ print_event_token(struct iw_event *        event,          /* Extracted token */
          printf("Invalid Spy Threshold event\n");
       }
       break;
+      /* ----- driver WPA events ----- */
+      /* Events generated by the driver, used for WPA operation */
+    case IWEVMICHAELMICFAILURE:
+      if(event->u.data.length >= sizeof(struct iw_michaelmicfailure))
+       {
+         struct iw_michaelmicfailure mf;
+         memcpy(&mf, event->u.data.pointer, sizeof(mf));
+         printf("Michael MIC failure flags:0x%X src_addr:%s tsc:%s\n",
+                mf.flags,
+                iw_saether_ntop(&mf.src_addr, buffer2),
+                iw_hexdump(buffer, sizeof(buffer),
+                           mf.tsc, IW_ENCODE_SEQ_MAX_SIZE));
+       }
+      break;
+    case IWEVASSOCREQIE:
+      printf("Association Request IEs:%s\n",
+            iw_hexdump(buffer, sizeof(buffer),
+                       event->u.data.pointer, event->u.data.length));
+      break;
+    case IWEVASSOCRESPIE:
+      printf("Association Response IEs:%s\n",
+            iw_hexdump(buffer, sizeof(buffer),
+                       event->u.data.pointer, event->u.data.length));
+      break;
+    case IWEVPMKIDCAND:
+      if(event->u.data.length >= sizeof(struct iw_pmkid_cand))
+       {
+         struct iw_pmkid_cand cand;
+         memcpy(&cand, event->u.data.pointer, sizeof(cand));
+         printf("PMKID candidate flags:0x%X index:%d bssid:%s\n",
+                cand.flags, cand.index,
+                iw_saether_ntop(&cand.bssid, buffer));
+       }
+      break;
       /* ----- junk ----- */
       /* other junk not currently in use */
     case SIOCGIWRATE:
@@ -452,6 +508,7 @@ print_event_stream(int              ifindex,
   int                  ret;
   char                 buffer[64];
   struct timeval       recv_time;
+  struct timezone      tz;
   struct wireless_iface *      wireless_data;
 
   /* Get data from cache */
@@ -460,8 +517,8 @@ print_event_stream(int              ifindex,
     return(-1);
 
   /* Print received time in readable form */
-  gettimeofday(&recv_time, NULL);
-  iw_print_timeval(buffer, sizeof(buffer), &recv_time);
+  gettimeofday(&recv_time, &tz);
+  iw_print_timeval(buffer, sizeof(buffer), &recv_time, &tz);
 
   iw_init_event_stream(&stream, data, len);
   do
index bb9d279..4d4090a 100644 (file)
@@ -42,7 +42,7 @@ The default formatting output is pretty-print.
 .SH OPTIONS
 .TP
 .B --raw
-This option disables pretty-printing of the information. This options
+This option disables pretty-printing of the information. This option
 is orthogonal to the other options (except
 .BR --scheme ),
 so with the appropriate combination of options you can print the raw
@@ -58,7 +58,7 @@ scripts or to pass the result as an argument on the command line of
 .TP
 .B --scheme
 This option is similar to the previous one, it disables
-pretty-printing of the information and remove all characters that are
+pretty-printing of the information and removes all characters that are
 not alphanumerics (like space, punctuation and control characters).
 .br
 The resulting output is a valid Pcmcia scheme identifier (that may be
@@ -98,9 +98,8 @@ of the interface.
 .B --protocol
 Display the
 .I protocol name
-of the interface. This allow to identify all the cards that are
-compatible with each other and accept the same type of
-configuration.
+of the interface. This allows to identify all the cards that are
+compatible with each other and accept the same type of configuration.
 .br
 This can also be used to
 .I check Wireless Extension support
index f7c5a6d..bbd48a1 100644 (file)
@@ -89,7 +89,7 @@ print_essid(int                       skfd,
   unsigned int         i;
   unsigned int         j;
 
-  /* Make shure ESSID is NULL terminated */
+  /* Make sure ESSID is always NULL terminated */
   memset(essid, 0, sizeof(essid));
 
   /* Get ESSID */
index b78882f..7d5f1a4 100644 (file)
@@ -177,7 +177,8 @@ iw_get_ifname(char *        name,   /* Where to store the name */
   memcpy(name, buf, (end - buf));
   name[end - buf] = '\0';
 
-  return(end + 2);
+  /* Return value currently unused, just make sure it's non-NULL */
+  return(end);
 }
 
 /*------------------------------------------------------------------*/
@@ -201,7 +202,7 @@ iw_enum_devices(int         skfd,
   int          i;
 
 #ifndef IW_RESTRIC_ENUM
-  /* Check if /proc/net/wireless is available */
+  /* Check if /proc/net/dev is available */
   fh = fopen(PROC_NET_DEV, "r");
 #else
   /* Check if /proc/net/wireless is available */
@@ -222,16 +223,23 @@ iw_enum_devices(int               skfd,
          char  name[IFNAMSIZ + 1];
          char *s;
 
+         /* Skip empty or almost empty lines. It seems that in some
+          * cases fgets return a line with only a newline. */
+         if((buff[0] == '\0') || (buff[1] == '\0'))
+           continue;
+
          /* Extract interface name */
          s = iw_get_ifname(name, sizeof(name), buff);
 
          if(!s)
-           /* Failed to parse, complain and continue */
+           {
+             /* Failed to parse, complain and continue */
 #ifndef IW_RESTRIC_ENUM
-           fprintf(stderr, "Cannot parse " PROC_NET_DEV "\n");
+             fprintf(stderr, "Cannot parse " PROC_NET_DEV "\n");
 #else
-           fprintf(stderr, "Cannot parse " PROC_NET_WIRELESS "\n");
+             fprintf(stderr, "Cannot parse " PROC_NET_WIRELESS "\n");
 #endif
+           }
          else
            /* Got it, print info about this interface */
            (*fn)(skfd, name, args, count);
@@ -510,7 +518,7 @@ iw_get_range_info(int               skfd,
 
       /* We don't like future versions of WE, because we can't cope with
        * the unknown */
-      if(range->we_version_compiled > WE_VERSION)
+      if(range->we_version_compiled > WE_MAX_VERSION)
        {
          fprintf(stderr, "Warning: Driver for device %s has been compiled with version %d\n", ifname, range->we_version_compiled);
          fprintf(stderr, "of Wireless Extension, while this program supports up to version %d.\n", WE_VERSION);
@@ -790,9 +798,14 @@ iw_set_basic_config(int                    skfd,
    */
   if(info->has_essid)
     {
+      int              we_kernel_version;
+      we_kernel_version = iw_get_kernel_we_version();
+
       wrq.u.essid.pointer = (caddr_t) info->essid;
       wrq.u.essid.length = strlen(info->essid) + 1;
       wrq.u.data.flags = info->essid_on;
+      if(we_kernel_version > 20)
+       wrq.u.essid.length--;
 
       if(iw_set_ext(skfd, ifname, SIOCSIWESSID, &wrq) < 0)
        {
@@ -1203,6 +1216,7 @@ iw_print_txpower(char *                   buffer,
 /*------------------------------------------------------------------*/
 /*
  * Read /proc/net/wireless to get the latest statistics
+ * Note : strtok not thread safe, not used in WE-12 and later.
  */
 int
 iw_get_stats(int               skfd,
@@ -1308,10 +1322,12 @@ iw_print_stats(char *           buffer,
    * Relative/percent values are always encoded unsigned, between 0 and 255.
    * Absolute/dBm values are always encoded negative, between -255 and 0.
    *
-   * How do we separate relative from absolute values ? We use the
-   * range to do that. The range allow to specify the real min/max
-   * of the value. As the range struct only specify one bound of the
-   * value, we assume that the other bound is 0 (zero).
+   * How do we separate relative from absolute values ?
+   * The old way is to use the range to do that. As of WE-19, we have
+   * an explicit IW_QUAL_DBM flag in updated...
+   * The range allow to specify the real min/max of the value. As the
+   * range struct only specify one bound of the value, we assume that
+   * the other bound is 0 (zero).
    * For relative values, range is [0 ; range->max].
    * For absolute values, range is [range->max ; 0].
    *
@@ -1323,8 +1339,11 @@ iw_print_stats(char *            buffer,
    * Jean II
    */
 
-  /* Just do it */
-  if(has_range && (qual->level != 0))
+  /* Just do it...
+   * The old way to detect dBm require both the range and a non-null
+   * level (which confuse the test). The new way can deal with level of 0
+   * because it does an explicit test on the flag. */
+  if(has_range && ((qual->level != 0) || (qual->updated & IW_QUAL_DBM)))
     {
       /* Deal with quality : always a relative value */
       if(!(qual->updated & IW_QUAL_QUAL_INVALID))
@@ -1336,8 +1355,9 @@ iw_print_stats(char *             buffer,
          buflen -= len;
        }
 
-      /* If the statistics are in dBm or relative */
-      if(qual->level > range->max_qual.level)
+      /* Check if the statistics are in dBm or relative */
+      if((qual->updated & IW_QUAL_DBM)
+        || (qual->level > range->max_qual.level))
        {
          /* Deal with signal level in dBm  (absolute power measurement) */
          if(!(qual->updated & IW_QUAL_LEVEL_INVALID))
@@ -1462,6 +1482,7 @@ iw_pass_key(const char *  input,
 /*
  * Parse a key from the command line.
  * Return size of the key, or 0 (no key) or -1 (error)
+ * If the key is too long, it's simply truncated...
  */
 int
 iw_in_key(const char *         input,
@@ -1476,7 +1497,7 @@ iw_in_key(const char *            input,
       keylen = strlen(input + 2);              /* skip "s:" */
       if(keylen > IW_ENCODING_TOKEN_MAX)
        keylen = IW_ENCODING_TOKEN_MAX;
-      strncpy(key, input + 2, keylen);
+      memcpy(key, input + 2, keylen);
     }
   else
     if(!strncmp(input, "p:", 2))
@@ -1486,56 +1507,66 @@ iw_in_key(const char *          input,
       }
     else
       {
-       char *  buff;
-       char *  hex;
-       char *  out;
-       char *  p;
+       const char *    p;
+       int             dlen;   /* Digits sequence length */
+       unsigned char   out[IW_ENCODING_TOKEN_MAX];
 
        /* Third case : as hexadecimal digits */
-       buff = malloc(IW_ENCODING_TOKEN_MAX + strlen(input) + 1);
-       if(buff == NULL)
-         {
-           fprintf(stderr, "Malloc failed (string too long ?)\n");
-           return(-1);
-         }
-       /* Preserve original buffers (both in & out) */
-       hex = buff + IW_ENCODING_TOKEN_MAX;
-       strcpy(hex, input);                             /* Size checked */
-       out = buff;
-
-       /* Parse */
-       p = strtok(hex, "-:;.,");
-       while((p != (char *) NULL) && (keylen < IW_ENCODING_TOKEN_MAX))
+       p = input;
+       dlen = -1;
+
+       /* Loop until we run out of chars in input or overflow the output */
+       while(*p != '\0')
          {
            int temph;
            int templ;
            int count;
-           int len;
+           /* No more chars in this sequence */
+           if(dlen <= 0)
+             {
+               /* Skip separator */
+               if(dlen == 0)
+                 p++;
+               /* Calculate num of char to next separator */
+               dlen = strcspn(p, "-:;.,");
+             }
            /* Get each char separatly (and not by two) so that we don't
             * get confused by 'enc' (=> '0E'+'0C') and similar */
            count = sscanf(p, "%1X%1X", &temph, &templ);
            if(count < 1)
              return(-1);               /* Error -> non-hex char */
            /* Fixup odd strings such as '123' is '01'+'23' and not '12'+'03'*/
-           len = strlen(p);
-           if(len % 2)
+           if(dlen % 2)
              count = 1;
-           /* Put back two chars as one byte */
+           /* Put back two chars as one byte and output */
            if(count == 2)
              templ |= temph << 4;
            else
              templ = temph;
            out[keylen++] = (unsigned char) (templ & 0xFF);
-           /* Check where to get next char from */
-           if(len > count)     /* Token not finished yet */
-             p += count;
-           else
-             p = strtok((char *) NULL, "-:;.,");
+           /* Check overflow in output */
+           if(keylen >= IW_ENCODING_TOKEN_MAX)
+             break;
+           /* Move on to next chars */
+           p += count;
+           dlen -= count;
          }
+       /* We use a temporary output buffer 'out' so that if there is
+        * an error, we don't overwrite the original key buffer.
+        * Because of the way iwconfig loop on multiple key/enc arguments
+        * until it finds an error in here, this is necessary to avoid
+        * silently corrupting the encryption key... */
        memcpy(key, out, keylen);
-       free(buff);
       }
 
+#ifdef DEBUG
+  {
+    char buf[IW_ENCODING_TOKEN_MAX * 3];
+    iw_print_key(buf, sizeof(buf), key, keylen, 0);
+    printf("Got key : %d [%s]\n", keylen, buf);
+  }
+#endif
+
   return(keylen);
 }
 
@@ -1566,7 +1597,7 @@ iw_in_key_full(int                skfd,
       memcpy(key, input + 2, keylen);
 
       /* Separate the two strings */
-      p = strchr(key, ':');
+      p = strchr((char *) key, ':');
       if(p == NULL)
        {
          fprintf(stderr, "Error: Invalid login format\n");
@@ -1768,16 +1799,17 @@ iw_print_retry_value(char *     buffer,
  * Inspired from irdadump...
  */
 void
-iw_print_timeval(char *                        buffer,
-                int                    buflen,
-                const struct timeval * time)
+iw_print_timeval(char *                                buffer,
+                int                            buflen,
+                const struct timeval *         timev,
+                const struct timezone *        tz)
 {
         int s;
 
-       s = (time->tv_sec) % 86400;
-       snprintf(buffer, buflen, "%02d:%02d:%02d.%06u ", 
+       s = (timev->tv_sec - tz->tz_minuteswest * 60) % 86400;
+       snprintf(buffer, buflen, "%02d:%02d:%02d.%06u", 
                s / 3600, (s % 3600) / 60, 
-               s % 60, (u_int32_t) time->tv_usec);
+               s % 60, (u_int32_t) timev->tv_usec);
 }
 
 /*********************** ADDRESS SUBROUTINES ************************/
@@ -1793,14 +1825,15 @@ iw_print_timeval(char *                 buffer,
  */
 int
 iw_check_mac_addr_type(int             skfd,
-                      char *           ifname)
+                      const char *     ifname)
 {
   struct ifreq         ifr;
 
   /* Get the type of hardware address */
   strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
   if((ioctl(skfd, SIOCGIFHWADDR, &ifr) < 0) ||
-     (ifr.ifr_hwaddr.sa_family != ARPHRD_ETHER))
+     ((ifr.ifr_hwaddr.sa_family != ARPHRD_ETHER)
+      && (ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211)))
     {
       /* Deep trouble... */
       fprintf(stderr, "Interface %s doesn't support MAC addresses\n",
@@ -1809,8 +1842,11 @@ iw_check_mac_addr_type(int               skfd,
     }
 
 #ifdef DEBUG
-  printf("Hardware : %d - %s\n", ifr.ifr_hwaddr.sa_family,
-        iw_ether_ntoa((struct ether_addr *) ifr.ifr_hwaddr.sa_data));
+  {
+    char buf[20];
+    printf("Hardware : %d - %s\n", ifr.ifr_hwaddr.sa_family,
+          iw_saether_ntop(&ifr.ifr_hwaddr, buf));
+  }
 #endif
 
   return(0);
@@ -1823,7 +1859,7 @@ iw_check_mac_addr_type(int                skfd,
  */
 int
 iw_check_if_addr_type(int              skfd,
-                     char *            ifname)
+                     const char *      ifname)
 {
   struct ifreq         ifr;
 
@@ -1866,6 +1902,7 @@ iw_check_addr_type(int            skfd,
 }
 #endif
 
+#if 0
 /*------------------------------------------------------------------*/
 /*
  * Ask the kernel for the MAC address of an interface.
@@ -1890,13 +1927,40 @@ iw_get_mac_addr(int                     skfd,
   *ptype = ifr.ifr_hwaddr.sa_family;
   return(ret);
 }
+#endif
+
+/*------------------------------------------------------------------*/
+/*
+ * Display an arbitrary length MAC address in readable format.
+ */
+char *
+iw_mac_ntop(const unsigned char *      mac,
+           int                         maclen,
+           char *                      buf,
+           int                         buflen)
+{
+  int  i;
+
+  /* Overflow check (don't forget '\0') */
+  if(buflen < (maclen * 3 - 1 + 1))
+    return(NULL);
+
+  /* First byte */
+  sprintf(buf, "%02X", mac[0]);
+
+  /* Other bytes */
+  for(i = 1; i < maclen; i++)
+    sprintf(buf + (i * 3) - 1, ":%02X", mac[i]);
+  return(buf);
+}
 
 /*------------------------------------------------------------------*/
 /*
  * Display an Ethernet address in readable format.
  */
 void
-iw_ether_ntop(const struct ether_addr* eth, char* buf)
+iw_ether_ntop(const struct ether_addr *        eth,
+             char *                    buf)
 {
   sprintf(buf, "%02X:%02X:%02X:%02X:%02X:%02X",
          eth->ether_addr_octet[0], eth->ether_addr_octet[1],
@@ -1906,70 +1970,111 @@ iw_ether_ntop(const struct ether_addr* eth, char* buf)
 
 /*------------------------------------------------------------------*/
 /*
- * Display an Ethernet address in readable format.
- * Same with a static buffer
+ * Display an Wireless Access Point Socket Address in readable format.
+ * Note : 0x44 is an accident of history, that's what the Orinoco/PrismII
+ * chipset report, and the driver doesn't filter it.
  */
 char *
-iw_ether_ntoa(const struct ether_addr* eth)
+iw_sawap_ntop(const struct sockaddr *  sap,
+             char *                    buf)
 {
-  static char buf[20];
-  iw_ether_ntop(eth, buf);
-  return buf;
+  const struct ether_addr ether_zero = {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }};
+  const struct ether_addr ether_bcast = {{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }};
+  const struct ether_addr ether_hack = {{ 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 }};
+  const struct ether_addr * ether_wap = (const struct ether_addr *) sap->sa_data;
+
+  if(!iw_ether_cmp(ether_wap, &ether_zero))
+    sprintf(buf, "Not-Associated");
+  else
+    if(!iw_ether_cmp(ether_wap, &ether_bcast))
+      sprintf(buf, "Invalid");
+    else
+      if(!iw_ether_cmp(ether_wap, &ether_hack))
+       sprintf(buf, "None");
+      else
+       iw_ether_ntop(ether_wap, buf);
+  return(buf);
 }
 
 /*------------------------------------------------------------------*/
 /*
- * Input an Ethernet address and convert to binary.
+ * Input an arbitrary length MAC address and convert to binary.
+ * Return address size.
  */
 int
-iw_ether_aton(const char *orig, struct ether_addr *eth)
+iw_mac_aton(const char *       orig,
+           unsigned char *     mac,
+           int                 macmax)
 {
-  const char *bufp;
-  int i;
-
-  i = 0;
-  for(bufp = orig; *bufp != '\0'; ++bufp) {
-       unsigned int val;
-       unsigned char c = *bufp++;
-       if (isdigit(c)) val = c - '0';
-       else if (c >= 'a' && c <= 'f') val = c - 'a' + 10;
-       else if (c >= 'A' && c <= 'F') val = c - 'A' + 10;
-       else break;
-
-       val <<= 4;
-       c = *bufp++;
-       if (isdigit(c)) val |= c - '0';
-       else if (c >= 'a' && c <= 'f') val |= c - 'a' + 10;
-       else if (c >= 'A' && c <= 'F') val |= c - 'A' + 10;
-       else break;
-
-       eth->ether_addr_octet[i] = (unsigned char) (val & 0377);
-       if(++i == ETH_ALEN) {
-               /* That's it.  Any trailing junk? */
-               if (*bufp != '\0') {
+  const char * p = orig;
+  int          maclen = 0;
+
+  /* Loop on all bytes of the string */
+  while(*p != '\0')
+    {
+      int      temph;
+      int      templ;
+      int      count;
+      /* Extract one byte as two chars */
+      count = sscanf(p, "%1X%1X", &temph, &templ);
+      if(count != 2)
+       break;                  /* Error -> non-hex chars */
+      /* Output two chars as one byte */
+      templ |= temph << 4;
+      mac[maclen++] = (unsigned char) (templ & 0xFF);
+
+      /* Check end of string */
+      p += 2;
+      if(*p == '\0')
+       {
 #ifdef DEBUG
-                       fprintf(stderr, "iw_ether_aton(%s): trailing junk!\n", orig);
-                       errno = EINVAL;
-                       return(0);
+         char buf[20];
+         iw_ether_ntop((const struct ether_addr *) mac, buf);
+         fprintf(stderr, "iw_mac_aton(%s): %s\n", orig, buf);
 #endif
-               }
+         return(maclen);               /* Normal exit */
+       }
+
+      /* Check overflow */
+      if(maclen >= macmax)
+       {
 #ifdef DEBUG
-               fprintf(stderr, "iw_ether_aton(%s): %s\n",
-                       orig, ether_ntoa(eth));
+         fprintf(stderr, "iw_mac_aton(%s): trailing junk!\n", orig);
 #endif
-               return(1);
+         errno = E2BIG;
+         return(0);                    /* Error -> overflow */
        }
-       if (*bufp != ':')
-               break;
-  }
 
+      /* Check separator */
+      if(*p != ':')
+       break;
+      p++;
+    }
+
+  /* Error... */
 #ifdef DEBUG
-  fprintf(stderr, "iw_ether_aton(%s): invalid ether address!\n", orig);
+  fprintf(stderr, "iw_mac_aton(%s): invalid ether address!\n", orig);
 #endif
   errno = EINVAL;
   return(0);
 }
 
+/*------------------------------------------------------------------*/
+/*
+ * Input an Ethernet address and convert to binary.
+ */
+int
+iw_ether_aton(const char *orig, struct ether_addr *eth)
+{
+  int  maclen;
+  maclen = iw_mac_aton(orig, (unsigned char *) eth, ETH_ALEN);
+  if((maclen > 0) && (maclen < ETH_ALEN))
+    {
+      errno = EINVAL;
+      maclen = 0;
+    }
+  return(maclen);
+}
 
 /*------------------------------------------------------------------*/
 /*
@@ -2015,7 +2120,7 @@ iw_in_inet(char *name, struct sockaddr *sap)
  */
 int
 iw_in_addr(int         skfd,
-          char *       ifname,
+          const char * ifname,
           char *       bufp,
           struct sockaddr *sap)
 {
@@ -2062,8 +2167,11 @@ iw_in_addr(int           skfd,
             sizeof(struct sockaddr));
 
 #ifdef DEBUG
-      printf("IP Address %s => Hw Address = %s\n",
-            bufp, iw_ether_ntoa((struct ether_addr *) sap->sa_data));
+      {
+       char buf[20];
+       printf("IP Address %s => Hw Address = %s\n",
+              bufp, iw_saether_ntop(sap, buf));
+      }
 #endif
     }
   else /* If it's an hardware address */
@@ -2076,7 +2184,7 @@ iw_in_addr(int            skfd,
        }
 
       /* Get the hardware address */
-      if(iw_in_ether(bufp, sap) < 0)
+      if(iw_saether_aton(bufp, sap) == 0)
        {
          fprintf(stderr, "Invalid hardware address %s\n", bufp);
          return(-1);
@@ -2084,7 +2192,10 @@ iw_in_addr(int           skfd,
     }
 
 #ifdef DEBUG
-  printf("Hw Address = %s\n", iw_ether_ntoa((struct ether_addr *) sap->sa_data));
+  {
+    char buf[20];
+    printf("Hw Address = %s\n", iw_saether_ntop(sap, buf));
+  }
 #endif
 
   return(0);
@@ -2125,6 +2236,8 @@ iw_get_priv_size(int      args)
  * this case.
  */
 
+/* -------------------------- CONSTANTS -------------------------- */
+
 /* Type of headers we know about (basically union iwreq_data) */
 #define IW_HEADER_TYPE_NULL    0       /* Not available */
 #define IW_HEADER_TYPE_CHAR    2       /* char [IFNAMSIZ] */
@@ -2135,69 +2248,315 @@ iw_get_priv_size(int   args)
 #define IW_HEADER_TYPE_PARAM   9       /* struct iw_param */
 #define IW_HEADER_TYPE_QUAL    10      /* struct iw_quality */
 
-/* Headers for the various requests */
-static const char standard_ioctl_hdr[] = {
-       IW_HEADER_TYPE_NULL,    /* SIOCSIWCOMMIT */
-       IW_HEADER_TYPE_CHAR,    /* SIOCGIWNAME */
-       IW_HEADER_TYPE_PARAM,   /* SIOCSIWNWID */
-       IW_HEADER_TYPE_PARAM,   /* SIOCGIWNWID */
-       IW_HEADER_TYPE_FREQ,    /* SIOCSIWFREQ */
-       IW_HEADER_TYPE_FREQ,    /* SIOCGIWFREQ */
-       IW_HEADER_TYPE_UINT,    /* SIOCSIWMODE */
-       IW_HEADER_TYPE_UINT,    /* SIOCGIWMODE */
-       IW_HEADER_TYPE_PARAM,   /* SIOCSIWSENS */
-       IW_HEADER_TYPE_PARAM,   /* SIOCGIWSENS */
-       IW_HEADER_TYPE_NULL,    /* SIOCSIWRANGE */
-       IW_HEADER_TYPE_POINT,   /* SIOCGIWRANGE */
-       IW_HEADER_TYPE_NULL,    /* SIOCSIWPRIV */
-       IW_HEADER_TYPE_POINT,   /* SIOCGIWPRIV */
-       IW_HEADER_TYPE_NULL,    /* SIOCSIWSTATS */
-       IW_HEADER_TYPE_POINT,   /* SIOCGIWSTATS */
-       IW_HEADER_TYPE_POINT,   /* SIOCSIWSPY */
-       IW_HEADER_TYPE_POINT,   /* SIOCGIWSPY */
-       IW_HEADER_TYPE_POINT,   /* SIOCSIWTHRSPY */
-       IW_HEADER_TYPE_POINT,   /* SIOCGIWTHRSPY */
-       IW_HEADER_TYPE_ADDR,    /* SIOCSIWAP */
-       IW_HEADER_TYPE_ADDR,    /* SIOCGIWAP */
-       IW_HEADER_TYPE_NULL,    /* -- hole -- */
-       IW_HEADER_TYPE_POINT,   /* SIOCGIWAPLIST */
-       IW_HEADER_TYPE_PARAM,   /* SIOCSIWSCAN */
-       IW_HEADER_TYPE_POINT,   /* SIOCGIWSCAN */
-       IW_HEADER_TYPE_POINT,   /* SIOCSIWESSID */
-       IW_HEADER_TYPE_POINT,   /* SIOCGIWESSID */
-       IW_HEADER_TYPE_POINT,   /* SIOCSIWNICKN */
-       IW_HEADER_TYPE_POINT,   /* SIOCGIWNICKN */
-       IW_HEADER_TYPE_NULL,    /* -- hole -- */
-       IW_HEADER_TYPE_NULL,    /* -- hole -- */
-       IW_HEADER_TYPE_PARAM,   /* SIOCSIWRATE */
-       IW_HEADER_TYPE_PARAM,   /* SIOCGIWRATE */
-       IW_HEADER_TYPE_PARAM,   /* SIOCSIWRTS */
-       IW_HEADER_TYPE_PARAM,   /* SIOCGIWRTS */
-       IW_HEADER_TYPE_PARAM,   /* SIOCSIWFRAG */
-       IW_HEADER_TYPE_PARAM,   /* SIOCGIWFRAG */
-       IW_HEADER_TYPE_PARAM,   /* SIOCSIWTXPOW */
-       IW_HEADER_TYPE_PARAM,   /* SIOCGIWTXPOW */
-       IW_HEADER_TYPE_PARAM,   /* SIOCSIWRETRY */
-       IW_HEADER_TYPE_PARAM,   /* SIOCGIWRETRY */
-       IW_HEADER_TYPE_POINT,   /* SIOCSIWENCODE */
-       IW_HEADER_TYPE_POINT,   /* SIOCGIWENCODE */
-       IW_HEADER_TYPE_PARAM,   /* SIOCSIWPOWER */
-       IW_HEADER_TYPE_PARAM,   /* SIOCGIWPOWER */
+/* Handling flags */
+/* Most are not implemented. I just use them as a reminder of some
+ * cool features we might need one day ;-) */
+#define IW_DESCR_FLAG_NONE     0x0000  /* Obvious */
+/* Wrapper level flags */
+#define IW_DESCR_FLAG_DUMP     0x0001  /* Not part of the dump command */
+#define IW_DESCR_FLAG_EVENT    0x0002  /* Generate an event on SET */
+#define IW_DESCR_FLAG_RESTRICT 0x0004  /* GET : request is ROOT only */
+                               /* SET : Omit payload from generated iwevent */
+#define IW_DESCR_FLAG_NOMAX    0x0008  /* GET : no limit on request size */
+/* Driver level flags */
+#define IW_DESCR_FLAG_WAIT     0x0100  /* Wait for driver event */
+
+/* ---------------------------- TYPES ---------------------------- */
+
+/*
+ * Describe how a standard IOCTL looks like.
+ */
+struct iw_ioctl_description
+{
+       __u8    header_type;            /* NULL, iw_point or other */
+       __u8    token_type;             /* Future */
+       __u16   token_size;             /* Granularity of payload */
+       __u16   min_tokens;             /* Min acceptable token number */
+       __u16   max_tokens;             /* Max acceptable token number */
+       __u32   flags;                  /* Special handling of the request */
+};
+
+/* -------------------------- VARIABLES -------------------------- */
+
+/*
+ * Meta-data about all the standard Wireless Extension request we
+ * know about.
+ */
+static const struct iw_ioctl_description standard_ioctl_descr[] = {
+       [SIOCSIWCOMMIT  - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_NULL,
+       },
+       [SIOCGIWNAME    - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_CHAR,
+               .flags          = IW_DESCR_FLAG_DUMP,
+       },
+       [SIOCSIWNWID    - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_PARAM,
+               .flags          = IW_DESCR_FLAG_EVENT,
+       },
+       [SIOCGIWNWID    - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_PARAM,
+               .flags          = IW_DESCR_FLAG_DUMP,
+       },
+       [SIOCSIWFREQ    - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_FREQ,
+               .flags          = IW_DESCR_FLAG_EVENT,
+       },
+       [SIOCGIWFREQ    - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_FREQ,
+               .flags          = IW_DESCR_FLAG_DUMP,
+       },
+       [SIOCSIWMODE    - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_UINT,
+               .flags          = IW_DESCR_FLAG_EVENT,
+       },
+       [SIOCGIWMODE    - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_UINT,
+               .flags          = IW_DESCR_FLAG_DUMP,
+       },
+       [SIOCSIWSENS    - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_PARAM,
+       },
+       [SIOCGIWSENS    - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_PARAM,
+       },
+       [SIOCSIWRANGE   - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_NULL,
+       },
+       [SIOCGIWRANGE   - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_POINT,
+               .token_size     = 1,
+               .max_tokens     = sizeof(struct iw_range),
+               .flags          = IW_DESCR_FLAG_DUMP,
+       },
+       [SIOCSIWPRIV    - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_NULL,
+       },
+       [SIOCGIWPRIV    - SIOCIWFIRST] = { /* (handled directly by us) */
+               .header_type    = IW_HEADER_TYPE_NULL,
+       },
+       [SIOCSIWSTATS   - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_NULL,
+       },
+       [SIOCGIWSTATS   - SIOCIWFIRST] = { /* (handled directly by us) */
+               .header_type    = IW_HEADER_TYPE_NULL,
+               .flags          = IW_DESCR_FLAG_DUMP,
+       },
+       [SIOCSIWSPY     - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_POINT,
+               .token_size     = sizeof(struct sockaddr),
+               .max_tokens     = IW_MAX_SPY,
+       },
+       [SIOCGIWSPY     - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_POINT,
+               .token_size     = sizeof(struct sockaddr) +
+                                 sizeof(struct iw_quality),
+               .max_tokens     = IW_MAX_SPY,
+       },
+       [SIOCSIWTHRSPY  - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_POINT,
+               .token_size     = sizeof(struct iw_thrspy),
+               .min_tokens     = 1,
+               .max_tokens     = 1,
+       },
+       [SIOCGIWTHRSPY  - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_POINT,
+               .token_size     = sizeof(struct iw_thrspy),
+               .min_tokens     = 1,
+               .max_tokens     = 1,
+       },
+       [SIOCSIWAP      - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_ADDR,
+       },
+       [SIOCGIWAP      - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_ADDR,
+               .flags          = IW_DESCR_FLAG_DUMP,
+       },
+       [SIOCSIWMLME    - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_POINT,
+               .token_size     = 1,
+               .min_tokens     = sizeof(struct iw_mlme),
+               .max_tokens     = sizeof(struct iw_mlme),
+       },
+       [SIOCGIWAPLIST  - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_POINT,
+               .token_size     = sizeof(struct sockaddr) +
+                                 sizeof(struct iw_quality),
+               .max_tokens     = IW_MAX_AP,
+               .flags          = IW_DESCR_FLAG_NOMAX,
+       },
+       [SIOCSIWSCAN    - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_POINT,
+               .token_size     = 1,
+               .min_tokens     = 0,
+               .max_tokens     = sizeof(struct iw_scan_req),
+       },
+       [SIOCGIWSCAN    - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_POINT,
+               .token_size     = 1,
+               .max_tokens     = IW_SCAN_MAX_DATA,
+               .flags          = IW_DESCR_FLAG_NOMAX,
+       },
+       [SIOCSIWESSID   - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_POINT,
+               .token_size     = 1,
+               .max_tokens     = IW_ESSID_MAX_SIZE + 1,
+               .flags          = IW_DESCR_FLAG_EVENT,
+       },
+       [SIOCGIWESSID   - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_POINT,
+               .token_size     = 1,
+               .max_tokens     = IW_ESSID_MAX_SIZE + 1,
+               .flags          = IW_DESCR_FLAG_DUMP,
+       },
+       [SIOCSIWNICKN   - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_POINT,
+               .token_size     = 1,
+               .max_tokens     = IW_ESSID_MAX_SIZE + 1,
+       },
+       [SIOCGIWNICKN   - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_POINT,
+               .token_size     = 1,
+               .max_tokens     = IW_ESSID_MAX_SIZE + 1,
+       },
+       [SIOCSIWRATE    - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_PARAM,
+       },
+       [SIOCGIWRATE    - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_PARAM,
+       },
+       [SIOCSIWRTS     - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_PARAM,
+       },
+       [SIOCGIWRTS     - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_PARAM,
+       },
+       [SIOCSIWFRAG    - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_PARAM,
+       },
+       [SIOCGIWFRAG    - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_PARAM,
+       },
+       [SIOCSIWTXPOW   - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_PARAM,
+       },
+       [SIOCGIWTXPOW   - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_PARAM,
+       },
+       [SIOCSIWRETRY   - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_PARAM,
+       },
+       [SIOCGIWRETRY   - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_PARAM,
+       },
+       [SIOCSIWENCODE  - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_POINT,
+               .token_size     = 1,
+               .max_tokens     = IW_ENCODING_TOKEN_MAX,
+               .flags          = IW_DESCR_FLAG_EVENT | IW_DESCR_FLAG_RESTRICT,
+       },
+       [SIOCGIWENCODE  - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_POINT,
+               .token_size     = 1,
+               .max_tokens     = IW_ENCODING_TOKEN_MAX,
+               .flags          = IW_DESCR_FLAG_DUMP | IW_DESCR_FLAG_RESTRICT,
+       },
+       [SIOCSIWPOWER   - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_PARAM,
+       },
+       [SIOCGIWPOWER   - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_PARAM,
+       },
+       [SIOCSIWGENIE   - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_POINT,
+               .token_size     = 1,
+               .max_tokens     = IW_GENERIC_IE_MAX,
+       },
+       [SIOCGIWGENIE   - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_POINT,
+               .token_size     = 1,
+               .max_tokens     = IW_GENERIC_IE_MAX,
+       },
+       [SIOCSIWAUTH    - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_PARAM,
+       },
+       [SIOCGIWAUTH    - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_PARAM,
+       },
+       [SIOCSIWENCODEEXT - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_POINT,
+               .token_size     = 1,
+               .min_tokens     = sizeof(struct iw_encode_ext),
+               .max_tokens     = sizeof(struct iw_encode_ext) +
+                                 IW_ENCODING_TOKEN_MAX,
+       },
+       [SIOCGIWENCODEEXT - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_POINT,
+               .token_size     = 1,
+               .min_tokens     = sizeof(struct iw_encode_ext),
+               .max_tokens     = sizeof(struct iw_encode_ext) +
+                                 IW_ENCODING_TOKEN_MAX,
+       },
+       [SIOCSIWPMKSA - SIOCIWFIRST] = {
+               .header_type    = IW_HEADER_TYPE_POINT,
+               .token_size     = 1,
+               .min_tokens     = sizeof(struct iw_pmksa),
+               .max_tokens     = sizeof(struct iw_pmksa),
+       },
 };
-static const unsigned int standard_ioctl_num = sizeof(standard_ioctl_hdr);
+static const unsigned int standard_ioctl_num = (sizeof(standard_ioctl_descr) /
+                                               sizeof(struct iw_ioctl_description));
 
 /*
  * Meta-data about all the additional standard Wireless Extension events
  * we know about.
  */
-static const char      standard_event_hdr[] = {
-       IW_HEADER_TYPE_ADDR,    /* IWEVTXDROP */
-       IW_HEADER_TYPE_QUAL,    /* IWEVQUAL */
-       IW_HEADER_TYPE_POINT,   /* IWEVCUSTOM */
-       IW_HEADER_TYPE_ADDR,    /* IWEVREGISTERED */
-       IW_HEADER_TYPE_ADDR,    /* IWEVEXPIRED */
+static const struct iw_ioctl_description standard_event_descr[] = {
+       [IWEVTXDROP     - IWEVFIRST] = {
+               .header_type    = IW_HEADER_TYPE_ADDR,
+       },
+       [IWEVQUAL       - IWEVFIRST] = {
+               .header_type    = IW_HEADER_TYPE_QUAL,
+       },
+       [IWEVCUSTOM     - IWEVFIRST] = {
+               .header_type    = IW_HEADER_TYPE_POINT,
+               .token_size     = 1,
+               .max_tokens     = IW_CUSTOM_MAX,
+       },
+       [IWEVREGISTERED - IWEVFIRST] = {
+               .header_type    = IW_HEADER_TYPE_ADDR,
+       },
+       [IWEVEXPIRED    - IWEVFIRST] = {
+               .header_type    = IW_HEADER_TYPE_ADDR, 
+       },
+       [IWEVGENIE      - IWEVFIRST] = {
+               .header_type    = IW_HEADER_TYPE_POINT,
+               .token_size     = 1,
+               .max_tokens     = IW_GENERIC_IE_MAX,
+       },
+       [IWEVMICHAELMICFAILURE  - IWEVFIRST] = {
+               .header_type    = IW_HEADER_TYPE_POINT, 
+               .token_size     = 1,
+               .max_tokens     = sizeof(struct iw_michaelmicfailure),
+       },
+       [IWEVASSOCREQIE - IWEVFIRST] = {
+               .header_type    = IW_HEADER_TYPE_POINT,
+               .token_size     = 1,
+               .max_tokens     = IW_GENERIC_IE_MAX,
+       },
+       [IWEVASSOCRESPIE        - IWEVFIRST] = {
+               .header_type    = IW_HEADER_TYPE_POINT,
+               .token_size     = 1,
+               .max_tokens     = IW_GENERIC_IE_MAX,
+       },
+       [IWEVPMKIDCAND  - IWEVFIRST] = {
+               .header_type    = IW_HEADER_TYPE_POINT,
+               .token_size     = 1,
+               .max_tokens     = sizeof(struct iw_pmkid_cand),
+       },
 };
-static const unsigned int standard_event_num = sizeof(standard_event_hdr);
+static const unsigned int standard_event_num = (sizeof(standard_event_descr) /
+                                               sizeof(struct iw_ioctl_description));
 
 /* Size (in bytes) of various events */
 static const int event_type_size[] = {
@@ -2214,10 +2573,6 @@ static const int event_type_size[] = {
        IW_EV_QUAL_LEN,         /* IW_HEADER_TYPE_QUAL */
 };
 
-/* Forward compatibility with WE-19 */
-#define IW_EV_POINT_OFF (((char *) &(((struct iw_point *) NULL)->length)) - \
-                         (char *) NULL)
-
 /*------------------------------------------------------------------*/
 /*
  * Initialise the struct stream_descr so that we can extract
@@ -2245,6 +2600,7 @@ iw_extract_event_stream(struct stream_descr *     stream, /* Stream of events */
                        struct iw_event *       iwe,    /* Extracted event */
                        int                     we_version)
 {
+  const struct iw_ioctl_description *  descr = NULL;
   int          event_type = 0;
   unsigned int event_len = 1;          /* Invalid */
   char *       pointer;
@@ -2258,7 +2614,7 @@ iw_extract_event_stream(struct stream_descr *     stream, /* Stream of events */
   if((stream->current + IW_EV_LCP_LEN) > stream->end)
     return(0);
 
-#if 0
+#if DEBUG
   printf("DBG - stream->current = %p, stream->value = %p, stream->end = %p\n",
         stream->current, stream->value, stream->end);
 #endif
@@ -2267,7 +2623,7 @@ iw_extract_event_stream(struct stream_descr *     stream, /* Stream of events */
    * Note : the event may be unaligned, therefore copy... */
   memcpy((char *) iwe, stream->current, IW_EV_LCP_LEN);
 
-#if 0
+#if DEBUG
   printf("DBG - iwe->cmd = 0x%X, iwe->len = %d\n",
         iwe->cmd, iwe->len);
 #endif
@@ -2281,19 +2637,21 @@ iw_extract_event_stream(struct stream_descr *   stream, /* Stream of events */
     {
       cmd_index = iwe->cmd - SIOCIWFIRST;
       if(cmd_index < standard_ioctl_num)
-       event_type = standard_ioctl_hdr[cmd_index];
+       descr = &(standard_ioctl_descr[cmd_index]);
     }
   else
     {
       cmd_index = iwe->cmd - IWEVFIRST;
       if(cmd_index < standard_event_num)
-       event_type = standard_event_hdr[cmd_index];
+       descr = &(standard_event_descr[cmd_index]);
     }
+  if(descr != NULL)
+    event_type = descr->header_type;
   /* Unknown events -> event_type=0 => IW_EV_LCP_LEN */
   event_len = event_type_size[event_type];
-  /* Fixup for later version of WE */
-  if((we_version > 18) && (event_type == IW_HEADER_TYPE_POINT))
-    event_len -= IW_EV_POINT_OFF;
+  /* Fixup for earlier version of WE */
+  if((we_version <= 18) && (event_type == IW_HEADER_TYPE_POINT))
+    event_len += IW_EV_POINT_OFF;
 
   /* Check if we know about this event */
   if(event_len <= IW_EV_LCP_LEN)
@@ -2310,7 +2668,7 @@ iw_extract_event_stream(struct stream_descr *     stream, /* Stream of events */
   else
     pointer = stream->current + IW_EV_LCP_LEN; /* First value in event */
 
-#if 0
+#if DEBUG
   printf("DBG - event_type = %d, event_len = %d, pointer = %p\n",
         event_type, event_len, pointer);
 #endif
@@ -2322,7 +2680,7 @@ iw_extract_event_stream(struct stream_descr *     stream, /* Stream of events */
       stream->current += iwe->len;
       return(-2);
     }
-  /* Fixup for later version of WE */
+  /* Fixup for WE-19 and later : pointer no longer in the stream */
   if((we_version > 18) && (event_type == IW_HEADER_TYPE_POINT))
     memcpy((char *) iwe + IW_EV_LCP_LEN + IW_EV_POINT_OFF,
           pointer, event_len);
@@ -2336,9 +2694,40 @@ iw_extract_event_stream(struct stream_descr *    stream, /* Stream of events */
   if(event_type == IW_HEADER_TYPE_POINT)
     {
       /* Check the length of the payload */
-      if((iwe->len - (event_len + IW_EV_LCP_LEN)) > 0)
-       /* Set pointer on variable part (warning : non aligned) */
-       iwe->u.data.pointer = pointer;
+      unsigned int     extra_len = iwe->len - (event_len + IW_EV_LCP_LEN);
+      if(extra_len > 0)
+       {
+         /* Set pointer on variable part (warning : non aligned) */
+         iwe->u.data.pointer = pointer;
+
+         /* Check that we have a descriptor for the command */
+         if(descr == NULL)
+           /* Can't check payload -> unsafe... */
+           iwe->u.data.pointer = NULL; /* Discard paylod */
+         else
+           {
+             /* Those checks are actually pretty hard to trigger,
+              * because of the checks done in the kernel... */
+
+             /* Discard bogus events which advertise more tokens than
+              * what they carry... */
+             unsigned int      token_len = iwe->u.data.length * descr->token_size;
+             if(token_len > extra_len)
+               iwe->u.data.pointer = NULL;     /* Discard paylod */
+             /* Check that the advertised token size is not going to
+              * produce buffer overflow to our caller... */
+             if((iwe->u.data.length > descr->max_tokens)
+                && !(descr->flags & IW_DESCR_FLAG_NOMAX))
+               iwe->u.data.pointer = NULL;     /* Discard paylod */
+             /* Same for underflows... */
+             if(iwe->u.data.length < descr->min_tokens)
+               iwe->u.data.pointer = NULL;     /* Discard paylod */
+#if DEBUG
+             printf("DBG - extra_len = %d, token_len = %d, token = %d, max = %d, min = %d\n",
+                    extra_len, token_len, iwe->u.data.length, descr->max_tokens, descr->min_tokens);
+#endif
+           }
+       }
       else
        /* No data */
        iwe->u.data.pointer = NULL;
@@ -2439,9 +2828,9 @@ iw_process_scanning_token(struct iw_event *               event,
     case SIOCGIWESSID:
       wscan->b.has_essid = 1;
       wscan->b.essid_on = event->u.data.flags;
+      memset(wscan->b.essid, '\0', IW_ESSID_MAX_SIZE+1);
       if((event->u.essid.pointer) && (event->u.essid.length))
        memcpy(wscan->b.essid, event->u.essid.pointer, event->u.essid.length);
-      wscan->b.essid[event->u.essid.length] = '\0';
       break;
     case SIOCGIWENCODE:
       wscan->b.has_key = 1;
@@ -2455,7 +2844,7 @@ iw_process_scanning_token(struct iw_event *               event,
     case IWEVQUAL:
       /* We don't get complete stats, only qual */
       wscan->has_stats = 1;
-      memcpy(&wscan->stats.qual, &event->u.qual, sizeof(iwstats));
+      memcpy(&wscan->stats.qual, &event->u.qual, sizeof(struct iw_quality));
       break;
     case SIOCGIWRATE:
       /* Scan may return a list of bitrates. Should we really bother with
@@ -2489,9 +2878,9 @@ iw_process_scan(int                       skfd,
   int                  buflen = IW_SCAN_MAX_DATA; /* Min for compat WE<17 */
   unsigned char *      newbuf;
 
-  /* Don't waste too much time on interfaces (50 * 100 = 5s) */
+  /* Don't waste too much time on interfaces (150 * 100 = 15s) */
   context->retry++;
-  if(context->retry > 50)
+  if(context->retry > 150)
     {
       errno = ETIME;
       return(-1);
@@ -2570,7 +2959,7 @@ iw_process_scan(int                       skfd,
       struct stream_descr      stream;
       struct wireless_scan *   wscan = NULL;
       int                      ret;
-#if 0
+#if DEBUG
       /* Debugging code. In theory useless, because it's debugged ;-) */
       int      i;
       printf("Scan result [%02X", buffer[0]);
@@ -2580,7 +2969,7 @@ iw_process_scan(int                       skfd,
 #endif
 
       /* Init */
-      iw_init_event_stream(&stream, buffer, wrq.u.data.length);
+      iw_init_event_stream(&stream, (char *) buffer, wrq.u.data.length);
       /* This is dangerous, we may leak user data... */
       context->result = NULL;
 
index 67d6ff1..6730621 100644 (file)
@@ -45,8 +45,7 @@
     && __GLIBC__ == 2 \
     && __GLIBC_MINOR__ >= 2 \
     && LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
-//#define GLIBC22_HEADERS
-#define GENERIC_HEADERS
+#define HEADERS_GENERIC
 
 /* Kernel headers 2.4.X + Glibc 2.1 - Debian 2.2 upgraded, RH 7.0
  * Kernel headers 2.2.X + Glibc 2.1 - Debian 2.2, RH 6.1 */
       && __GLIBC__ == 2 \
       && __GLIBC_MINOR__ == 1 \
       && LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
-//#define GLIBC_HEADERS
-#define GENERIC_HEADERS
-
-/* Kernel headers 2.2.X + Glibc 2.0 - Debian 2.1 */
-#elif defined(__GLIBC__) \
-      && __GLIBC__ == 2 \
-      && __GLIBC_MINOR__ == 0 \
-      && LINUX_VERSION_CODE >= KERNEL_VERSION(2,0,0) \
-      && LINUX_VERSION_CODE < KERNEL_VERSION(2,1,0)
-#define GLIBC_HEADERS
-#define KLUDGE_HEADERS
-
-/* Note : is it really worth supporting kernel 2.0.X, knowing that
- * we require WE v9, which is only available in 2.2.X and higher ?
- * I guess one could use 2.0.x with an upgraded wireless.h... */
-
-/* Kernel headers 2.0.X + Glibc 2.0 - Debian 2.0, RH 5 */
-#elif defined(__GLIBC__) \
-      && __GLIBC__ == 2 \
-      && __GLIBC_MINOR__ == 0 \
-      && LINUX_VERSION_CODE < KERNEL_VERSION(2,1,0) \
-      && LINUX_VERSION_CODE >= KERNEL_VERSION(2,0,0)
-#define GLIBC_HEADERS
-
-/* Kernel headers 2.0.X + libc5 - old systems */
-#elif defined(_LINUX_C_LIB_VERSION_MAJOR) \
-      && _LINUX_C_LIB_VERSION_MAJOR == 5 \
-      && LINUX_VERSION_CODE >= KERNEL_VERSION(2,0,0) \
-      && LINUX_VERSION_CODE < KERNEL_VERSION(2,1,0)
-#define LIBC5_HEADERS
+#define HEADERS_GENERIC
+#define HEADERS_KERNEL
 
 /* Unsupported combination */
 #else
 #error "Your kernel/libc combination is not supported"
 #endif
 
-#ifdef GENERIC_HEADERS 
+#ifdef HEADERS_GENERIC 
 /* Proposed by Dr. Michael Rietz <rietz@mail.amps.de>, 27.3.2 */
-/* If this works for all, it might be more stable on the long term - Jean II */
 #include <net/if_arp.h>                /* For ARPHRD_ETHER */
 #include <sys/socket.h>                /* For AF_INET & struct sockaddr */
 #include <netinet/in.h>         /* For struct sockaddr_in */
 #include <netinet/if_ether.h>
-#endif /* GENERIC_HEADERS */    
-
-#ifdef GLIBC22_HEADERS 
-/* Added by Ross G. Miller <Ross_Miller@baylor.edu>, 3/28/01 */
-#include <linux/if_arp.h>      /* For ARPHRD_ETHER */
-#include <linux/socket.h>      /* For AF_INET & struct sockaddr */
-#include <sys/socket.h>
-#endif /* GLIBC22_HEADERS */    
-
-#ifdef KLUDGE_HEADERS
-#include <socketbits.h>
-#endif /* KLUDGE_HEADERS */
-
-#ifdef GLIBC_HEADERS
-#include <linux/if_arp.h>      /* For ARPHRD_ETHER */
-#include <linux/socket.h>      /* For AF_INET & struct sockaddr */
-#include <linux/in.h>          /* For struct sockaddr_in */
-#endif /* KLUDGE_HEADERS || GLIBC_HEADERS */
-
-#ifdef LIBC5_HEADERS
-#include <sys/socket.h>                /* For AF_INET & struct sockaddr & socket() */
-#include <linux/if_arp.h>      /* For ARPHRD_ETHER */
-#include <linux/in.h>          /* For struct sockaddr_in */
-#endif /* LIBC5_HEADERS */
-
-/* Those 3 headers were previously included in wireless.h */
+#endif /* HEADERS_GENERIC */    
+
+/* Fixup to be able to include kernel includes in userspace.
+ * Basically, kill the sparse annotations... Jean II */
+#ifndef __user
+#define __user
+#endif
+
 #include <linux/types.h>               /* for "caddr_t" et al          */
+
+#ifdef HEADERS_KERNEL
+/* Traditionally we have used kernel headers, included in wireless.h */
 #include <linux/socket.h>              /* for "struct sockaddr" et al  */
 #include <linux/if.h>                  /* for IFNAMSIZ and co... */
+#else  /* !HEADERS_KERNEL */
+/* Glibc systems headers are supposedly less problematic than kernel ones */
+#include <sys/socket.h>                        /* for "struct sockaddr" et al  */
+#include <net/if.h>                    /* for IFNAMSIZ and co... */
+#endif /* !HEADERS_KERNEL */
 
-/* Private copy of Wireless extensions */
-#include <wireless.h>
+/* Private copy of Wireless extensions (in this directoty) */
+#include "wireless.h"
 
 /* Make gcc understant that when we say inline, we mean it.
  * I really hate when the compiler is trying to be more clever than me,
  * Fortunately, in gcc 3.4, they now automatically inline static functions
  * with a single call site. Hurrah !
  * Jean II */
+#undef IW_GCC_HAS_BROKEN_INLINE
 #if __GNUC__ == 3
 #if __GNUC_MINOR__ >= 1 && __GNUC_MINOR__ < 4
+#define IW_GCC_HAS_BROKEN_INLINE       1
+#endif /* __GNUC_MINOR__ */
+#endif /* __GNUC__ */
+/* However, gcc 4.0 has introduce a new "feature", when compiling with
+ * '-Os', it does not want to inline iw_ether_cmp() and friends.
+ * So, we need to fix inline again !
+ * Jean II */
+#if __GNUC__ == 4
+#define IW_GCC_HAS_BROKEN_INLINE       1
+#endif /* __GNUC__ */
+/* Now, really fix the inline */
+#ifdef IW_GCC_HAS_BROKEN_INLINE
+#ifdef inline
+#undef inline
+#endif /* inline */
 #define inline         inline          __attribute__((always_inline))
-#endif
-#endif /* __GNUC__ */
+#endif /* IW_GCC_HAS_BROKEN_INLINE */
 
 #ifdef __cplusplus
 extern "C" {
@@ -156,9 +131,11 @@ extern "C" {
 
 /* Various versions information */
 /* Recommended Wireless Extension version */
-#define WE_VERSION     17
+#define WE_VERSION     20
+/* Maximum forward compatibility built in this version of WT */
+#define WE_MAX_VERSION 21
 /* Version of Wireless Tools */
-#define WT_VERSION     27
+#define WT_VERSION     28
 
 /* Paths */
 #define PROC_NET_WIRELESS      "/proc/net/wireless"
@@ -171,31 +148,10 @@ extern "C" {
 /* For doing log10/exp10 without libm */
 #define LOG10_MAGIC    1.25892541179
 
-/* Backward compatibility for Wireless Extension 9 */
-#ifndef IW_POWER_MODIFIER
-#define IW_POWER_MODIFIER      0x000F  /* Modify a parameter */
-#define IW_POWER_MIN           0x0001  /* Value is a minimum  */
-#define IW_POWER_MAX           0x0002  /* Value is a maximum */
-#define IW_POWER_RELATIVE      0x0004  /* Value is not in seconds/ms/us */
-#endif /* IW_POWER_MODIFIER */
-
-#ifndef IW_ENCODE_NOKEY
-#define IW_ENCODE_NOKEY         0x0800  /* Key is write only, so not here */
-#define IW_ENCODE_MODE         0xF000  /* Modes defined below */
-#endif /* IW_ENCODE_NOKEY */
-#ifndef IW_ENCODE_TEMP
-#define IW_ENCODE_TEMP         0x0400  /* Temporary key */
-#endif /* IW_ENCODE_TEMP */
-
-/* More backward compatibility */
-#ifndef SIOCSIWCOMMIT
-#define SIOCSIWCOMMIT  SIOCSIWNAME
-#endif /* SIOCSIWCOMMIT */
-
-/* Still more backward compatibility */
-#ifndef IW_FREQ_FIXED
-#define IW_FREQ_FIXED  0x01
-#endif /* IW_FREQ_FIXED */
+/* Backward compatibility for network headers */
+#ifndef ARPHRD_IEEE80211
+#define ARPHRD_IEEE80211 801           /* IEEE 802.11                  */
+#endif /* ARPHRD_IEEE80211 */
 
 /****************************** TYPES ******************************/
 
@@ -261,6 +217,14 @@ typedef struct wireless_info
   int          has_stats;
   iwrange      range;
   int          has_range;
+
+  /* Auth params for WPA/802.1x/802.11i */
+  int          auth_key_mgmt;
+  int          has_auth_key_mgmt;
+  int          auth_cipher_pairwise;
+  int          has_auth_cipher_pairwise;
+  int          auth_cipher_group;
+  int          has_auth_cipher_group;
 } wireless_info;
 
 /* Structure for storing an entry of a wireless scan.
@@ -428,37 +392,51 @@ void
                             int        flags);
 /* ----------------------- TIME SUBROUTINES ----------------------- */
 void
-       iw_print_timeval(char *                 buffer,
-                        int                    buflen,
-                        const struct timeval * time);
+       iw_print_timeval(char *                         buffer,
+                        int                            buflen,
+                        const struct timeval *         time,
+                        const struct timezone *        tz);
 /* --------------------- ADDRESS SUBROUTINES ---------------------- */
 int
-       iw_check_mac_addr_type(int      skfd,
-                              char *   ifname);
+       iw_check_mac_addr_type(int              skfd,
+                              const char *     ifname);
 int
-       iw_check_if_addr_type(int       skfd,
-                             char *    ifname);
+       iw_check_if_addr_type(int               skfd,
+                             const char *      ifname);
 #if 0
 int
        iw_check_addr_type(int          skfd,
-                          char *       ifname);
+                          const char * ifname);
 #endif
+#if 0
 int
        iw_get_mac_addr(int                     skfd,
                        const char *            name,
                        struct ether_addr *     eth,
                        unsigned short *        ptype);
+#endif
+char *
+       iw_mac_ntop(const unsigned char *       mac,
+                   int                         maclen,
+                   char *                      buf,
+                   int                         buflen);
 void
-       iw_ether_ntop(const struct ether_addr* eth, char* buf);
-char*
-       iw_ether_ntoa(const struct ether_addr* eth);
+       iw_ether_ntop(const struct ether_addr * eth,
+                     char *                    buf);
+char *
+       iw_sawap_ntop(const struct sockaddr *   sap,
+                     char *                    buf);
+int
+       iw_mac_aton(const char *        orig,
+                   unsigned char *     mac,
+                   int                 macmax);
 int
        iw_ether_aton(const char* bufp, struct ether_addr* eth);
 int
        iw_in_inet(char *bufp, struct sockaddr *sap);
 int
        iw_in_addr(int                  skfd,
-                  char *               ifname,
+                  const char *         ifname,
                   char *               bufp,
                   struct sockaddr *    sap);
 /* ----------------------- MISC SUBROUTINES ------------------------ */
@@ -545,21 +523,24 @@ iw_sockets_close(int      skfd)
 }
 
 /*------------------------------------------------------------------*/
-/* Backwards compatability
- * Actually, those form are much easier to use when dealing with
- * struct sockaddr... */
-static inline char*
-iw_pr_ether(char* bufp, const unsigned char* addr)
+/*
+ * Display an Ethernet Socket Address in readable format.
+ */
+static inline char *
+iw_saether_ntop(const struct sockaddr *sap, char* bufp)
 {
-  iw_ether_ntop((const struct ether_addr *) addr, bufp);
+  iw_ether_ntop((const struct ether_addr *) sap->sa_data, bufp);
   return bufp;
 }
-/* Backwards compatability */
+/*------------------------------------------------------------------*/
+/*
+ * Input an Ethernet Socket Address and convert to binary.
+ */
 static inline int
-iw_in_ether(const char *bufp, struct sockaddr *sap)
+iw_saether_aton(const char *bufp, struct sockaddr *sap)
 {
   sap->sa_family = ARPHRD_ETHER;
-  return iw_ether_aton(bufp, (struct ether_addr *) sap->sa_data) ? 0 : -1;
+  return iw_ether_aton(bufp, (struct ether_addr *) sap->sa_data);
 }
 
 /*------------------------------------------------------------------*/
@@ -584,6 +565,16 @@ iw_null_ether(struct sockaddr *sap)
   memset((char *) sap->sa_data, 0x00, ETH_ALEN);
 }
 
+/*------------------------------------------------------------------*/
+/*
+ * Compare two ethernet addresses
+ */
+static inline int
+iw_ether_cmp(const struct ether_addr* eth1, const struct ether_addr* eth2)
+{
+  return memcmp(eth1, eth2, sizeof(*eth1));
+}
+
 #ifdef __cplusplus
 }
 #endif
index d567afa..f59ab1e 100644 (file)
 #include "iwlib.h"             /* Header */
 #include <sys/time.h>
 
+/****************************** TYPES ******************************/
+
+/*
+ * Scan state and meta-information, used to decode events...
+ */
+typedef struct iwscan_state
+{
+  /* State */
+  int                  ap_num;         /* Access Point number 1->N */
+  int                  val_index;      /* Value in table 0->(N-1) */
+} iwscan_state;
+
+
 /*********************** FREQUENCIES/CHANNELS ***********************/
 
 /*------------------------------------------------------------------*/
@@ -143,13 +156,13 @@ print_ap_info(int skfd,
       if(has_qual)
        {
          /* Print stats for this address */
-         printf("    %s : ", iw_pr_ether(temp, hwa[i].sa_data));
+         printf("    %s : ", iw_saether_ntop(&hwa[i], temp));
          iw_print_stats(temp, sizeof(buffer), &qual[i], &range, has_range);
          printf("%s\n", temp);
        }
       else
        /* Only print the address */
-       printf("    %s\n", iw_pr_ether(temp, hwa[i].sa_data));
+       printf("    %s\n", iw_saether_ntop(&hwa[i], temp));
     }
   printf("\n");
   return(0);
@@ -255,7 +268,7 @@ print_keys_info(int         skfd,
          wrq.u.data.flags = k;
          if(iw_get_ext(skfd, ifname, SIOCGIWENCODE, &wrq) < 0)
            {
-             fprintf(stderr, "SIOCGIWENCODE: %s\n", strerror(errno));
+             fprintf(stderr, "Error reading wireless keys (SIOCGIWENCODE): %s\n", strerror(errno));
              break;
            }
          if((wrq.u.data.flags & IW_ENCODE_DISABLED) ||
@@ -277,19 +290,60 @@ print_keys_info(int               skfd,
       wrq.u.data.pointer = (caddr_t) key;
       wrq.u.data.length = IW_ENCODING_TOKEN_MAX;
       wrq.u.data.flags = 0;    /* Set index to zero to get current */
-      if(iw_get_ext(skfd, ifname, SIOCGIWENCODE, &wrq) < 0)
+      if(iw_get_ext(skfd, ifname, SIOCGIWENCODE, &wrq) >= 0)
        {
-         fprintf(stderr, "SIOCGIWENCODE: %s\n", strerror(errno));
-         return(-1);
+         /* Note : if above fails, we have already printed an error
+          * message int the loop above */
+         printf("          Current Transmit Key: [%d]\n",
+                wrq.u.data.flags & IW_ENCODE_INDEX);
+         if(wrq.u.data.flags & IW_ENCODE_RESTRICTED)
+           printf("          Security mode:restricted\n");
+         if(wrq.u.data.flags & IW_ENCODE_OPEN)
+           printf("          Security mode:open\n");
+       }
+
+      /* Print WPA/802.1x/802.11i security parameters */
+      if(range.we_version_compiled > 17)
+       {
+         /* Display advance encryption capabilities */
+         if(range.enc_capa)
+           {
+             const char *      auth_string[] = { "WPA",
+                                                 "WPA2",
+                                                 "CIPHER TKIP",
+                                                 "CIPHER CCMP" };
+             const int         auth_num = (sizeof(auth_string) /
+                                           sizeof(auth_string[1]));
+             int               i;
+             int               mask = 0x1;
+
+             printf("          Authentication capabilities :\n");
+             for(i = 0; i < auth_num; i++)
+               {
+                 if(range.enc_capa & mask)
+                   printf("\t\t%s\n", auth_string[i]);
+                 mask <<= 1;
+               }
+           }
+
+         /* Current values for authentication */
+         wrq.u.param.flags = IW_AUTH_KEY_MGMT;
+         if(iw_get_ext(skfd, ifname, SIOCGIWAUTH, &wrq) >= 0)
+             printf("          Current key_mgmt:0x%X\n",
+                    wrq.u.param.value);
+
+         wrq.u.param.flags = IW_AUTH_CIPHER_PAIRWISE;
+         if(iw_get_ext(skfd, ifname, SIOCGIWAUTH, &wrq) >= 0)
+             printf("          Current cipher_pairwise:0x%X\n",
+                    wrq.u.param.value);
+
+         wrq.u.param.flags = IW_AUTH_CIPHER_GROUP;
+         if(iw_get_ext(skfd, ifname, SIOCGIWAUTH, &wrq) >= 0)
+           printf("          Current cipher_group:0x%X\n",
+                  wrq.u.param.value);
        }
-      printf("          Current Transmit Key: [%d]\n",
-            wrq.u.data.flags & IW_ENCODE_INDEX);
-      if(wrq.u.data.flags & IW_ENCODE_RESTRICTED)
-       printf("          Security mode:restricted\n");
-      if(wrq.u.data.flags & IW_ENCODE_OPEN)
-       printf("          Security mode:open\n");
-
-      printf("\n\n");
+
+     printf("\n\n");
     }
   return(0);
 }
@@ -305,7 +359,8 @@ get_pm_value(int            skfd,
             char *             ifname,
             struct iwreq *     pwrq,
             int                flags,
-            char *             buffer)
+            char *             buffer,
+            int                buflen)
 {
   /* Get Another Power Management value */
   pwrq->u.power.flags = flags;
@@ -314,7 +369,7 @@ get_pm_value(int            skfd,
       /* Let's check the value and its type */
       if(pwrq->u.power.flags & IW_POWER_TYPE)
        {
-         iw_print_pm_value(buffer, sizeof(buffer),
+         iw_print_pm_value(buffer, buflen,
                            pwrq->u.power.value, pwrq->u.power.flags);
          printf("\n                 %s", buffer);
        }
@@ -436,7 +491,8 @@ print_pm_info(int           skfd,
                pm_mask = IW_POWER_MIN;
              /* If we have something to ask for... */
              if(pm_mask)
-               get_pm_value(skfd, ifname, &wrq, pm_mask, buffer);
+               get_pm_value(skfd, ifname, &wrq, pm_mask,
+                            buffer, sizeof(buffer));
 
              /* And if we have both a period and a timeout, ask the other */
              pm_mask = (range.pm_capa & (~(wrq.u.power.flags) &
@@ -444,7 +500,8 @@ print_pm_info(int           skfd,
              if(pm_mask)
                {
                  int   base_mask = pm_mask;
-                 flags = get_pm_value(skfd, ifname, &wrq, pm_mask, buffer);
+                 flags = get_pm_value(skfd, ifname, &wrq, pm_mask,
+                                      buffer, sizeof(buffer));
                  pm_mask = 0;
 
                  /* If we have been returned a MIN value, ask for the MAX */
@@ -455,7 +512,8 @@ print_pm_info(int           skfd,
                    pm_mask = IW_POWER_MIN | base_mask;
                  /* If we have something to ask for... */
                  if(pm_mask)
-                   get_pm_value(skfd, ifname, &wrq, pm_mask, buffer);
+                   get_pm_value(skfd, ifname, &wrq, pm_mask,
+                                buffer, sizeof(buffer));
                }
            }
        }
@@ -734,11 +792,279 @@ print_retry_info(int             skfd,
 
 /*------------------------------------------------------------------*/
 /*
+ * Parse, and display the results of a WPA or WPA2 IE.
+ *
+ */
+static void 
+iw_print_ie_unknown(unsigned char *    iebuf,
+                   int                 buflen)
+{
+  int  ielen = iebuf[1] + 2;
+  int  i;
+
+  if(ielen > buflen)
+    ielen = buflen;
+
+  printf("Unknown: ");
+  for(i = 0; i < ielen; i++)
+    printf("%02X", iebuf[i]);
+  printf("\n");
+}
+
+/*-----------------------------------------------------------------*/
+/*
+ * Display the cipher type for the value passed in.
+ *
+ */
+static inline void 
+iw_print_ie_cipher(unsigned char       csuite)
+{
+  switch (csuite)
+    {
+    case 0x00:
+      printf("None or same as Group ");
+      break;
+    case 0x01:
+      printf("WEP-40 ");
+      break;
+    case 0x02:
+      printf("TKIP ");
+      break;
+    case 0x03:
+      printf("WRAP ");
+      break;
+    case 0x04:
+      printf("CCMP ");
+      break;
+    case 0x05:
+      printf("WEP-104 ");
+      break;
+    default:
+      printf("Unknown ");
+      break;
+    }
+ }
+/*------------------------------------------------------------------*/
+/*
+ * Parse, and display the results of a WPA or WPA2 IE.
+ *
+ */
+static inline void 
+iw_print_ie_wpa(unsigned char *        iebuf,
+               int             buflen)
+{
+  int                  ielen = iebuf[1] + 2;
+  int                  offset = 2;     /* Skip the IE id, and the length. */
+  unsigned char                wpa1_oui[3] = {0x00, 0x50, 0xf2};
+  unsigned char                wpa2_oui[3] = {0x00, 0x0f, 0xac};
+  unsigned char *      wpa_oui;
+  int                  i;
+  uint16_t             ver = 0;
+  uint16_t             cnt = 0;
+
+  if(ielen > buflen)
+    ielen = buflen;
+
+  switch(iebuf[0])
+    {
+    case 0x30:         /* WPA2 */
+      /* Check if we have enough data */
+      if(ielen < 4)
+       {
+         iw_print_ie_unknown(iebuf, buflen);
+         return;
+       }
+
+      wpa_oui = wpa2_oui;
+      break;
+
+    case 0xdd:         /* WPA or else */
+      wpa_oui = wpa1_oui;
+      /* Not all IEs that start with 0xdd are WPA. 
+       * So check that the OUI is valid. */
+      if((ielen < 8)
+        || ((memcmp(&iebuf[offset], wpa_oui, 3) != 0)
+            && (iebuf[offset+3] == 0x01)))
+       {
+         iw_print_ie_unknown(iebuf, buflen);
+         return;
+       }
+
+       offset += 4;
+       break;
+
+    default:
+      return;
+    }
+  
+  /* Pick version number (little endian) */
+  ver = iebuf[offset] | (iebuf[offset + 1] << 8);
+  offset += 2;
+
+  if(iebuf[0] == 0xdd)
+    printf("WPA Version %d\n", ver);
+  if(iebuf[0] == 0x30)
+    printf("IEEE 802.11i/WPA2 Version %d\n", ver);
+
+  /* From here, everything is technically optional. */
+
+  /* Check if we are done */
+  if(ielen < (offset + 4))
+    {
+      /* We have a short IE.  So we should assume TKIP/TKIP. */
+      printf("                        Group Cipher : TKIP\n");
+      printf("                        Pairwise Cipher : TKIP\n");
+      return;
+    }
+  /* Next we have our group cipher. */
+  if(memcmp(&iebuf[offset], wpa_oui, 3) != 0)
+    {
+      printf("                        Group Cipher : Proprietary\n");
+    }
+  else
+    {
+      printf("                        Group Cipher : ");
+      iw_print_ie_cipher(iebuf[offset+3]);
+      printf("\n");
+    }
+  offset += 4;
+
+  /* Check if we are done */
+  if(ielen < (offset + 2))
+    {
+      /* We don't have a pairwise cipher, or auth method. Assume TKIP. */
+      printf("                        Pairwise Ciphers (1) : TKIP\n");
+      return;
+    }
+
+  /* Otherwise, we have some number of pairwise ciphers. */
+  cnt = iebuf[offset] | (iebuf[offset + 1] << 8);
+  offset += 2;
+  printf("                        Pairwise Ciphers (%d) : ", cnt);
+
+  if(ielen < (offset + 4*cnt))
+    return;
+
+  for(i = 0; i < cnt; i++)
+    {
+      if(memcmp(&iebuf[offset], wpa_oui, 3) != 0)
+       {
+         printf("Proprietary  ");
+       }
+      else
+       {
+         iw_print_ie_cipher(iebuf[offset+3]);
+       }
+      offset+=4;
+    }
+  printf("\n");
+  /* Check if we are done */
+  if(ielen < (offset + 2))
+    return;
+
+  /* Now, we have authentication suites. */
+  cnt = iebuf[offset] | (iebuf[offset + 1] << 8);
+  offset += 2;
+  printf("                        Authentication Suites (%d) : ", cnt);
+
+  if(ielen < (offset + 4*cnt))
+    return;
+
+  for(i = 0; i < cnt; i++)
+    {
+      if(memcmp(&iebuf[offset], wpa_oui, 3) != 0)
+       {
+         printf("Proprietary  ");
+       }
+      else
+       {
+         switch(iebuf[offset+3])
+           {
+           case 0x00:
+             printf("Reserved  ");
+             break;
+
+           case 0x01:
+             printf("802.1X  ");
+             break;
+
+           case 0x02:
+             printf("PSK  ");
+             break;
+
+           default:
+             printf("Unknown  ");
+             break;
+           }
+       }
+       offset+=4;
+     }
+  printf("\n");
+  /* Check if we are done */
+  if(ielen < (offset + 1))
+    return;
+
+  /* Otherwise, we have capabilities bytes.
+   * For now, we only care about preauth which is in bit position 1 of the
+   * first byte.  (But, preauth with WPA version 1 isn't supposed to be 
+   * allowed.) 8-) */
+  if(iebuf[offset] & 0x01)
+    {
+      printf("                       Preauthentication Supported\n");
+    }
+}
+/*------------------------------------------------------------------*/
+/*
+ * Process a generic IE and display the info in human readable form
+ * for some of the most interesting ones.
+ * For now, we only decode the WPA IEs.
+ */
+static inline void
+iw_print_gen_ie(unsigned char *        buffer,
+               int             buflen)
+{
+  int offset = 0;
+
+  /* Loop on each IE, each IE is minimum 2 bytes */
+  while(offset <= (buflen - 2))
+    {
+      printf("                    IE: ");
+
+      /* Check IE type */
+      switch(buffer[offset])
+       {
+       case 0xdd:      /* WPA1 (and other) */
+       case 0x30:      /* WPA2 */
+         iw_print_ie_wpa(buffer + offset, buflen);
+         break;
+       default:
+         iw_print_ie_unknown(buffer + offset, buflen);
+       }
+      /* Skip over this IE to the next one in the list. */
+      offset += buffer[offset+1] + 2;
+    }
+}
+
+/*------------------------------------------------------------------*/
+/*
  * Print one element from the scanning results
  */
-static inline int
-print_scanning_token(struct iw_event * event,  /* Extracted token */
-                    int                ap_num, /* AP number */
+static inline void
+print_scanning_token(struct stream_descr *     stream, /* Stream of events */
+                    struct iw_event *          event,  /* Extracted token */
+                    struct iwscan_state *      state,
                     struct iw_range *  iw_range,       /* Range info */
                     int                has_range)
 {
@@ -748,9 +1074,9 @@ print_scanning_token(struct iw_event *     event,  /* Extracted token */
   switch(event->cmd)
     {
     case SIOCGIWAP:
-      printf("          Cell %02d - Address: %s\n", ap_num,
-            iw_pr_ether(buffer, event->u.ap_addr.sa_data));
-      ap_num++;
+      printf("          Cell %02d - Address: %s\n", state->ap_num,
+            iw_saether_ntop(&event->u.ap_addr, buffer));
+      state->ap_num++;
       break;
     case SIOCGIWNWID:
       if(event->u.nwid.disabled)
@@ -781,9 +1107,9 @@ print_scanning_token(struct iw_event *     event,  /* Extracted token */
     case SIOCGIWESSID:
       {
        char essid[IW_ESSID_MAX_SIZE+1];
+       memset(essid, '\0', sizeof(essid));
        if((event->u.essid.pointer) && (event->u.essid.length))
          memcpy(essid, event->u.essid.pointer, event->u.essid.length);
-       essid[event->u.essid.length] = '\0';
        if(event->u.essid.flags)
          {
            /* Does it have an ESSID index ? */
@@ -794,14 +1120,14 @@ print_scanning_token(struct iw_event *   event,  /* Extracted token */
              printf("                    ESSID:\"%s\"\n", essid);
          }
        else
-         printf("                    ESSID:off/any\n");
+         printf("                    ESSID:off/any/hidden\n");
       }
       break;
     case SIOCGIWENCODE:
       {
        unsigned char   key[IW_ENCODING_TOKEN_MAX];
        if(event->u.data.pointer)
-         memcpy(key, event->u.essid.pointer, event->u.data.length);
+         memcpy(key, event->u.data.pointer, event->u.data.length);
        else
          event->u.data.flags |= IW_ENCODE_NOKEY;
        printf("                    Encryption key:");
@@ -826,8 +1152,23 @@ print_scanning_token(struct iw_event *    event,  /* Extracted token */
       }
       break;
     case SIOCGIWRATE:
+      if(state->val_index == 0)
+       printf("                    Bit Rates:");
+      else
+       if((state->val_index % 5) == 0)
+         printf("\n                              ");
+       else
+         printf("; ");
       iw_print_bitrate(buffer, sizeof(buffer), event->u.bitrate.value);
-      printf("                    Bit Rate:%s\n", buffer);
+      printf("%s", buffer);
+      /* Check for termination */
+      if(stream->value == NULL)
+       {
+         printf("\n");
+         state->val_index = 0;
+       }
+      else
+       state->val_index++;
       break;
     case IWEVQUAL:
       {
@@ -836,6 +1177,10 @@ print_scanning_token(struct iw_event *    event,  /* Extracted token */
        printf("                    %s\n", buffer);
        break;
       }
+    case IWEVGENIE:
+      /* Informations Elements are complex, let's do only some of them */
+      iw_print_gen_ie(event->u.data.pointer, event->u.data.length);
+      break;
     case IWEVCUSTOM:
       {
        char custom[IW_CUSTOM_MAX+1];
@@ -849,9 +1194,6 @@ print_scanning_token(struct iw_event *     event,  /* Extracted token */
       printf("                    (Unknown Wireless Token 0x%04X)\n",
             event->cmd);
    }   /* switch(event->cmd) */
-
-  /* May have changed */
-  return(ap_num);
 }
 
 /*------------------------------------------------------------------*/
@@ -870,7 +1212,7 @@ print_scanning_info(int            skfd,
   struct iw_range      range;
   int                  has_range;
   struct timeval       tv;                             /* Select timeout */
-  int                  timeout = 5000000;              /* 5s */
+  int                  timeout = 15000000;             /* 15s */
 
   /* Avoid "Unused parameter" warning */
   args = args; count = count;
@@ -1017,8 +1359,9 @@ print_scanning_info(int           skfd,
     {
       struct iw_event          iwe;
       struct stream_descr      stream;
-      int                      ap_num = 1;
+      struct iwscan_state      state = { .ap_num = 1, .val_index = 0 };
       int                      ret;
+      
 #if 0
       /* Debugging code. In theory useless, because it's debugged ;-) */
       int      i;
@@ -1028,14 +1371,15 @@ print_scanning_info(int         skfd,
       printf("]\n");
 #endif
       printf("%-8.16s  Scan completed :\n", ifname);
-      iw_init_event_stream(&stream, buffer, wrq.u.data.length);
+      iw_init_event_stream(&stream, (char *) buffer, wrq.u.data.length);
       do
        {
          /* Extract an event and print it */
          ret = iw_extract_event_stream(&stream, &iwe,
                                        range.we_version_compiled);
          if(ret > 0)
-           ap_num = print_scanning_token(&iwe, ap_num, &range, has_range);
+           print_scanning_token(&stream, &iwe, &state,
+                                &range, has_range);
        }
       while(ret > 0);
       printf("\n");
@@ -1131,11 +1475,14 @@ print_event_capa_info(int               skfd,
 
 /************************* COMMON UTILITIES *************************/
 /*
- * This section was written by Michael Tokarev <mjt@tls.msk.ru>
- * But modified by me ;-)
+ * This section was initially written by Michael Tokarev <mjt@tls.msk.ru>
+ * but heavily modified by me ;-)
  */
 
-/* command list */
+/*------------------------------------------------------------------*/
+/*
+ * Map command line arguments to the proper procedure...
+ */
 typedef struct iwlist_entry {
   const char *cmd;
   iw_enum_handler fn;
@@ -1244,14 +1591,13 @@ main(int        argc,
   if(argc == 1 || argc > 3)
     iw_usage(1);
 
-  if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help"))
+  /* Those don't apply to all interfaces */
+  if((argc == 2) && (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")))
     iw_usage(0);
-
-  /* This is also handled slightly differently */
-  if (!strcmp(argv[1], "-v") || !strcmp(argv[1], "--version"))
+  if((argc == 2) && (!strcmp(argv[1], "-v") || !strcmp(argv[1], "--version")))
     return(iw_print_version_info("iwlist"));
 
-  if (argc == 2)
+  if(argc == 2)
     {
       cmd = argv[1];
       dev = NULL;
diff --git a/wireless_tools/iwmulticall.c b/wireless_tools/iwmulticall.c
new file mode 100644 (file)
index 0000000..6e3ee58
--- /dev/null
@@ -0,0 +1,135 @@
+/*
+ *     Wireless Tools
+ *
+ *             Jean II - HPL 04
+ *
+ * Main code for "iwmulticall". This is a wrapper for the multicall version
+ * of the wireless tools.
+ * You need to link this code against "-lm".
+ * Thanks to Ned Ludd <solar@gentoo.org> for the inspiration...
+ *
+ * This file is released under the GPL license.
+ *     Copyright (c) 1997-2004 Jean Tourrilhes <jt@hpl.hp.com>
+ */
+
+/***************************** INCLUDES *****************************/
+
+#include <libgen.h>    /* Basename */
+
+/**************************** PROTOTYPES ****************************/
+
+/* Prototypes of the main of each tool */
+extern int
+       main_iwconfig(int       argc,
+                     char **   argv);
+extern int
+       main_iwlist(int argc,
+                   char **     argv);
+extern int
+       main_iwspy(int  argc,
+                  char **      argv);
+extern int
+       main_iwpriv(int argc,
+                   char **     argv);
+extern int
+       main_iwgetid(int        argc,
+                    char **    argv);
+
+/************************** MULTICALL HACK **************************/
+/*
+ * The idea for multicall is to put all the tools and the library in
+ * the same binary. This way, you can save the overhead of the library,
+ * of each tool, can better optimise the code and throw away the stuff
+ * you don't need from the library.
+ * This almost divide the size of the tools by two (without stripping).
+ * On the down side, you no longer have the libiw for other tools to
+ * use, but for the target systems (embedded), this doesn't matter
+ * much, as they just need to configure the card...
+ * Note that splitting the lib and the multicall tools would not
+ * make sense, as most gains are found in the inclusion of the lib...
+ *
+ * Our strategy is to include directly the *.c, rather than compile
+ * them separatly. This allow to simplify compilation and hide the
+ * multicall tweaks from the other tools.
+ * Yeah, this leads to a bit a preprocessor abuse...
+ * Jean II
+ */
+
+/* We need the library */
+#include "iwlib.c"
+
+/* Get iwconfig in there. Mandatory. */
+#define main(args...) main_iwconfig(args)
+#define iw_usage(args...) iwconfig_usage(args)
+#include "iwconfig.c"
+#undef iw_usage
+#undef main
+
+/* Get iwlist in there. Scanning support is pretty sweet. */
+#define main(args...) main_iwlist(args)
+#define iw_usage(args...) iwlist_usage(args)
+#include "iwlist.c"
+#undef iw_usage
+#undef main
+
+/* Get iwspy in there, it's not that big. */
+#define main(args...) main_iwspy(args)
+#include "iwspy.c"
+#undef main
+
+/* Get iwpriv in there. Mandatory for HostAP and some other drivers. */
+#define main(args...) main_iwpriv(args)
+#define iw_usage(args...) iwpriv_usage(args)
+#include "iwpriv.c"
+#undef iw_usage
+#undef main
+
+/* Do we really need iwgetid ? Well, it's not like it's a big one */
+#define main(args...) main_iwgetid(args)
+#define iw_usage(args...) iwgetid_usage(args)
+#include "iwgetid.c"
+#undef iw_usage
+#undef main
+
+/* iwevent is useless for most people, don't grab it ? */
+
+/* ifrename is big and useless for those systems */
+
+
+/******************************* MAIN ********************************/
+
+/*------------------------------------------------------------------*/
+/*
+ * The main !
+ */
+int
+main(int       argc,
+     char **   argv)
+{
+  char *       call_name = basename(argv[0]);  /* Strip path */
+
+  /* This is a testing hack */
+  if(!strcmp(call_name, "iwmulticall") && (argc > 0))
+    {
+      argv++;
+      argc--;
+      call_name = basename(argv[0]);
+    }
+
+  /* Just check the name under which we were called... */
+
+  if(!strcmp(call_name, "iwconfig"))
+    return(main_iwconfig(argc, argv));
+  if(!strcmp(call_name, "iwlist"))
+    return(main_iwlist(argc, argv));
+  if(!strcmp(call_name, "iwspy"))
+    return(main_iwspy(argc, argv));
+  if(!strcmp(call_name, "iwpriv"))
+    return(main_iwpriv(argc, argv));
+  if(!strcmp(call_name, "iwgetid"))
+    return(main_iwgetid(argc, argv));
+
+  /* Uh oh... Not supposed to come here. */
+  printf("iwmulticall : you are not supposed to call me this way...\n");
+  return(0);
+}
index 59b19bd..745d12d 100644 (file)
@@ -241,8 +241,6 @@ static void
 iw_usage(void)
 {
   fprintf(stderr, "Usage: iwpriv interface [private-command [private-arguments]]\n");
-  fprintf(stderr, "              interface [roam {on|off}]\n");
-  fprintf(stderr, "              interface [port {ad-hoc|managed|N}]\n");
 }
 
 /************************* SETTING ROUTINES **************************/
@@ -269,7 +267,7 @@ set_private_cmd(int         skfd,           /* Socket */
   int          offset = 0;     /* Space for sub-ioctl index */
 
   /* Check if we have a token index.
-   * Do it now so that sub-ioctl takes precendence, and so that we
+   * Do it now so that sub-ioctl takes precedence, and so that we
    * don't have to bother with it later on... */
   if((count >= 1) && (sscanf(args[0], "[%i]", &temp) == 1))
     {
@@ -412,14 +410,14 @@ set_private_cmd(int               skfd,           /* Socket */
          break;
 
        default:
-         fprintf(stderr, "Not yet implemented...\n");
+         fprintf(stderr, "Not implemented...\n");
          return(-1);
        }
          
       if((priv[k].set_args & IW_PRIV_SIZE_FIXED) &&
         (wrq.u.data.length != (priv[k].set_args & IW_PRIV_SIZE_MASK)))
        {
-         printf("The command %s need exactly %d argument...\n",
+         printf("The command %s needs exactly %d argument(s)...\n",
                 cmdname, priv[k].set_args & IW_PRIV_SIZE_MASK);
          return(-1);
        }
@@ -453,7 +451,7 @@ set_private_cmd(int         skfd,           /* Socket */
        }
       else
        {
-         /* Thirst case : args won't fit in wrq, or variable number of args */
+         /* Third case : args won't fit in wrq, or variable number of args */
          wrq.u.data.pointer = (caddr_t) buffer;
          wrq.u.data.flags = subcmd;
        }
@@ -538,7 +536,7 @@ set_private_cmd(int         skfd,           /* Socket */
                if(j)
                  printf("           %.*s", 
                         (int) strlen(cmdname), "                ");
-               printf("%s\n", iw_pr_ether(scratch, hwa->sa_data));
+               printf("%s\n", iw_saether_ntop(hwa, scratch));
              }
          }
          break;
@@ -620,7 +618,7 @@ print_priv_info(int         skfd,
     }
   else
     {
-      printf("%-8.16s  Available private ioctl :\n", ifname);
+      printf("%-8.16s  Available private ioctls :\n", ifname);
       /* Print them all */
       for(k = 0; k < n; k++)
        if(priv[k].name[0] != '\0')
index cbe6195..4516d57 100644 (file)
@@ -25,17 +25,22 @@ iwspy \- Get wireless statistics from specific nodes
 .\"
 .SH DESCRIPTION
 .B Iwspy
-is used to set a list of addresses in a wireless network interface and
-to read back quality of link information for each of those. This
-information is the same as the one available in
+is used to set a list of addresses to monitor in a wireless network
+interface and to read back quality of link information for each of
+those. This information is the same as the one available in
 .I /proc/net/wireless
 : quality of the link, signal strength and noise level.
 .PP
 This information is updated each time a new packet is received, so
-each address of the list add some overhead in the driver.
+each address of the list adds some overhead in the driver.
 .PP
-Note the this functionality work only for node part of the current
-wireless cells.
+Note that this functionality works only for nodes part of the current
+wireless cell, you can not monitor Access Points you are not
+associated with (you can use Scanning for that) and nodes in other
+cells. In Managed mode, in most case packets are relayed by the Access
+Point, in this case you will get the signal strength of the Access
+Point. For those reasons this functionality is mostly useful in Ad-Hoc
+and Master mode.
 .\"
 .\" PARAMETER part
 .\"
@@ -44,7 +49,7 @@ You may set any number of addresses up to 8.
 .TP
 .BR DNSNAME " | " IPADDR
 Set an IP address, or in some cases a DNS name (using the name
-resolver). As the hardware work with hardware addresses,
+resolver). As the hardware works with hardware addresses,
 .B iwspy
 will translate this IP address through
 .IR ARP .
@@ -73,10 +78,10 @@ Set the
 .I low
 and
 .I high
-signal strength threshold for the iwspy event (for driver that support
-it).
+signal strength threshold for the iwspy event (for drivers that
+support it).
 .br
-Every time the signal strengh for any of the address monitored
+Every time the signal strength for any of the address monitored
 with iwspy goes lower than the low threshold or goes higher than the
 high threshold, a Wireless Event will be generated.
 .br
index 35f5db9..9d10d38 100644 (file)
@@ -75,7 +75,7 @@ print_spy_info(int    skfd,
   for(i = 0; i < n; i++)
     {
       /* Print stats for each address */
-      printf("    %s : ", iw_pr_ether(temp, hwa[i].sa_data));
+      printf("    %s : ", iw_saether_ntop(&hwa[i], temp));
       iw_print_stats(temp, sizeof(temp), &qual[i], &range, has_range);
       printf("%s\n", temp);
     }
index 5950fd9..f32110c 100644 (file)
@@ -26,6 +26,7 @@ int main(int argc, char** argv)
 
        int devsock;
        struct ifreq ifbuffer;
+       char buf[20];
 
        if ((argc != 2) || (argv[1][0] == '-')) {
                printf("Usage: macaddr interface\n");
@@ -47,7 +48,7 @@ int main(int argc, char** argv)
        }
        close(devsock);
 
-       puts(iw_ether_ntoa((struct ether_addr *) ifbuffer.ifr_ifru.ifru_hwaddr.sa_data));
+       puts(iw_saether_ntop(&ifbuffer.ifr_ifru.ifru_hwaddr, buf));
 
        exit(0);
 }
diff --git a/wireless_tools/wireless.18.h b/wireless_tools/wireless.18.h
new file mode 100644 (file)
index 0000000..ae485f9
--- /dev/null
@@ -0,0 +1,1050 @@
+/*
+ * This file define a set of standard wireless extensions
+ *
+ * Version :   18      12.3.05
+ *
+ * Authors :   Jean Tourrilhes - HPL - <jt@hpl.hp.com>
+ * Copyright (c) 1997-2005 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
+ * driver.
+ * 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
+ * data exchanged...
+ * 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 :
+ *     # net/core/wireless.c
+ *
+ * Wireless Events (2002 -> onward) :
+ * --------------------------------
+ * Events are defined at the end of this file, and implemented in :
+ *     # net/core/wireless.c
+ *
+ * Other comments :
+ * --------------
+ * Do not add here things that are redundant with other mechanisms
+ * (drivers init, ifconfig, /proc/net/dev, ...) and with are not
+ * wireless specific.
+ *
+ * These wireless extensions are not magic : each driver has to provide
+ * support for them...
+ *
+ * IMPORTANT NOTE : As everything in the kernel, this is very much a
+ * work in progress. Contact me if you have ideas of improvements...
+ */
+
+/***************************** INCLUDES *****************************/
+
+/* To minimise problems in user space, I might remove those headers
+ * at some point. Jean II */
+#include <linux/types.h>               /* for "caddr_t" et al          */
+#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.
+ */
+#define WIRELESS_EXT   18
+
+/*
+ * Changes :
+ *
+ * V2 to V3
+ * --------
+ *     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
+ *
+ * V3 to V4
+ * --------
+ *     - Add sensitivity
+ *
+ * V4 to V5
+ * --------
+ *     - Missing encoding definitions in range
+ *     - Access points stuff
+ *
+ * V5 to V6
+ * --------
+ *     - 802.11 support (ESSID ioctls)
+ *
+ * V6 to V7
+ * --------
+ *     - define IW_ESSID_MAX_SIZE and IW_MAX_AP
+ *
+ * V7 to V8
+ * --------
+ *     - Changed my e-mail address
+ *     - More 802.11 support (nickname, rate, rts, frag)
+ *     - List index in frequencies
+ *
+ * V8 to V9
+ * --------
+ *     - 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
+ *
+ * V9 to V10
+ * ---------
+ *     - Add PM capability to range structure
+ *     - Add PM modifier : MAX/MIN/RELATIVE
+ *     - Add encoding option : IW_ENCODE_NOKEY
+ *     - Add TxPower ioctls (work like TxRate)
+ *
+ * V10 to V11
+ * ----------
+ *     - Add WE version in range (help backward/forward compatibility)
+ *     - Add retry ioctls (work like PM)
+ *
+ * V11 to V12
+ * ----------
+ *     - 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)
+ *
+ * V12 to V13
+ * ----------
+ *     - Document creation of new driver API.
+ *     - Extract union iwreq_data from struct iwreq (for new driver API).
+ *     - Rename SIOCSIWNAME as SIOCSIWCOMMIT
+ *
+ * V13 to V14
+ * ----------
+ *     - 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)
+ *
+ * V14 to V15
+ * ----------
+ *     - 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
+ *
+ * V15 to V16
+ * ----------
+ *     - 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
+ *
+ * V16 to V17
+ * ----------
+ *     - 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 <jkmaline@cc.hut.fi>)
+ * ----------
+ *     - Add support for WPA/WPA2
+ *     - Add extended encoding configuration (SIOCSIWENCODEEXT and
+ *       SIOCGIWENCODEEXT)
+ *     - Add SIOCSIWGENIE/SIOCGIWGENIE
+ *     - Add SIOCSIWMLME
+ *     - Add SIOCSIWPMKSA
+ *     - 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
+ */
+
+/**************************** 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. */
+
+/* Basic operations */
+#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) */
+
+/* Informative stuff */
+#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
+                                        * struct iw_mlme */
+/* 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
+ * 'mii-tool'.
+ * We now have 32 commands, so a bit more space ;-).
+ * Also, all 'odd' 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 */
+
+/* Even : get (world access), odd : 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
+                                        * IWEVGENIE events. */
+#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
+                                        * association. */
+#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
+                                        * association. */
+#define IWEVPMKIDCAND  0x8C09          /* PMKID candidate for RSN
+                                        * pre-authentication
+                                        * (struct iw_pmkid_cand) */
+
+#define IWEVFIRST      0x8C00
+
+/* ------------------------- 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 */
+#define IW_MAX_TXPOWER         8
+/* 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 */
+#define IW_MAX_SPY             8
+
+/* Maximum of address that you may get in the
+   list of access points in range */
+#define IW_MAX_AP              64
+
+/* Maximum size of the ESSID and NICKN strings */
+#define IW_ESSID_MAX_SIZE      32
+
+/* Modes of operation */
+#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) */
+
+/* Statistics flags (bitmask in updated) */
+#define IW_QUAL_QUAL_UPDATED   0x1     /* Value was updated since last read */
+#define IW_QUAL_LEVEL_UPDATED  0x2
+#define IW_QUAL_NOISE_UPDATED  0x4
+#define IW_QUAL_QUAL_INVALID   0x10    /* Driver doesn't provide value */
+#define IW_QUAL_LEVEL_INVALID  0x20
+#define IW_QUAL_NOISE_INVALID  0x40
+
+/* Frequency flags */
+#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  32      /* 256 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 */
+#define IW_POWER_FORCE_S       0x0400  /* Force PM procedure for sending unicast */
+#define IW_POWER_REPEATER      0x0800  /* Repeat broadcast messages in PM period */
+#define IW_POWER_MODIFIER      0x000F  /* Modify a parameter */
+#define IW_POWER_MIN           0x0001  /* Value is a minimum  */
+#define IW_POWER_MAX           0x0002  /* Value is a maximum */
+#define IW_POWER_RELATIVE      0x0004  /* Value is not in seconds/ms/us */
+
+/* Transmit Power flags available */
+#define IW_TXPOW_TYPE          0x00FF  /* Type of value */
+#define IW_TXPOW_DBM           0x0000  /* Value is in dBm */
+#define IW_TXPOW_MWATT         0x0001  /* Value is in mW */
+#define IW_TXPOW_RELATIVE      0x0002  /* Value is in arbitrary units */
+#define IW_TXPOW_RANGE         0x1000  /* Range of value between min/max */
+
+/* Retry limits and lifetime flags available */
+#define IW_RETRY_ON            0x0000  /* No details... */
+#define IW_RETRY_TYPE          0xF000  /* Type of parameter */
+#define IW_RETRY_LIMIT         0x1000  /* Maximum number of retries*/
+#define IW_RETRY_LIFETIME      0x2000  /* Maximum duration of retries in us */
+#define IW_RETRY_MODIFIER      0x000F  /* Modify a parameter */
+#define IW_RETRY_MIN           0x0001  /* Value is a minimum  */
+#define IW_RETRY_MAX           0x0002  /* Value is a maximum */
+#define IW_RETRY_RELATIVE      0x0004  /* Value is not in seconds/ms/us */
+
+/* Scanning request flags */
+#define IW_SCAN_DEFAULT                0x0000  /* Default scan of the driver */
+#define IW_SCAN_ALL_ESSID      0x0001  /* Scan all ESSIDs */
+#define IW_SCAN_THIS_ESSID     0x0002  /* Scan only this ESSID */
+#define IW_SCAN_ALL_FREQ       0x0004  /* Scan all Frequencies */
+#define IW_SCAN_THIS_FREQ      0x0008  /* Scan only this Frequency */
+#define IW_SCAN_ALL_MODE       0x0010  /* Scan all Modes */
+#define IW_SCAN_THIS_MODE      0x0020  /* Scan only this Mode */
+#define IW_SCAN_ALL_RATE       0x0040  /* Scan all Bit-Rates */
+#define IW_SCAN_THIS_RATE      0x0080  /* Scan only this Bit-Rate */
+/* struct iw_scan_req scan_type */
+#define IW_SCAN_TYPE_ACTIVE 0
+#define IW_SCAN_TYPE_PASSIVE 1
+/* Maximum size of returned data */
+#define IW_SCAN_MAX_DATA       4096    /* In bytes */
+
+/* Max number of char in custom event - use multiple of them if needed */
+#define IW_CUSTOM_MAX          256     /* In bytes */
+
+/* Generic information element */
+#define IW_GENERIC_IE_MAX      1024
+
+/* MLME requests (SIOCSIWMLME / struct iw_mlme) */
+#define IW_MLME_DEAUTH         0
+#define IW_MLME_DISASSOC       1
+
+/* SIOCSIWAUTH/SIOCGIWAUTH struct iw_param flags */
+#define IW_AUTH_INDEX          0x0FFF
+#define IW_AUTH_FLAGS          0xF000
+/* SIOCSIWAUTH/SIOCGIWAUTH parameters (0 .. 4095)
+ * (IW_AUTH_INDEX mask in struct iw_param flags; this is the index of the
+ * parameter that is being set/get to; value will be read/written to
+ * struct iw_param value field) */
+#define IW_AUTH_WPA_VERSION            0
+#define IW_AUTH_CIPHER_PAIRWISE                1
+#define IW_AUTH_CIPHER_GROUP           2
+#define IW_AUTH_KEY_MGMT               3
+#define IW_AUTH_TKIP_COUNTERMEASURES   4
+#define IW_AUTH_DROP_UNENCRYPTED       5
+#define IW_AUTH_80211_AUTH_ALG         6
+#define IW_AUTH_WPA_ENABLED            7
+#define IW_AUTH_RX_UNENCRYPTED_EAPOL   8
+#define IW_AUTH_ROAMING_CONTROL                9
+#define IW_AUTH_PRIVACY_INVOKED                10
+
+/* IW_AUTH_WPA_VERSION values (bit field) */
+#define IW_AUTH_WPA_VERSION_DISABLED   0x00000001
+#define IW_AUTH_WPA_VERSION_WPA                0x00000002
+#define IW_AUTH_WPA_VERSION_WPA2       0x00000004
+
+/* IW_AUTH_PAIRWISE_CIPHER and IW_AUTH_GROUP_CIPHER values (bit field) */
+#define IW_AUTH_CIPHER_NONE    0x00000001
+#define IW_AUTH_CIPHER_WEP40   0x00000002
+#define IW_AUTH_CIPHER_TKIP    0x00000004
+#define IW_AUTH_CIPHER_CCMP    0x00000008
+#define IW_AUTH_CIPHER_WEP104  0x00000010
+
+/* IW_AUTH_KEY_MGMT values (bit field) */
+#define IW_AUTH_KEY_MGMT_802_1X        1
+#define IW_AUTH_KEY_MGMT_PSK   2
+
+/* IW_AUTH_80211_AUTH_ALG values (bit field) */
+#define IW_AUTH_ALG_OPEN_SYSTEM        0x00000001
+#define IW_AUTH_ALG_SHARED_KEY 0x00000002
+#define IW_AUTH_ALG_LEAP       0x00000004
+
+/* IW_AUTH_ROAMING_CONTROL values */
+#define IW_AUTH_ROAMING_ENABLE 0       /* driver/firmware based roaming */
+#define IW_AUTH_ROAMING_DISABLE        1       /* user space program used for roaming
+                                        * control */
+
+/* SIOCSIWENCODEEXT definitions */
+#define IW_ENCODE_SEQ_MAX_SIZE 8
+/* struct iw_encode_ext ->alg */
+#define IW_ENCODE_ALG_NONE     0
+#define IW_ENCODE_ALG_WEP      1
+#define IW_ENCODE_ALG_TKIP     2
+#define IW_ENCODE_ALG_CCMP     3
+/* struct iw_encode_ext ->ext_flags */
+#define IW_ENCODE_EXT_TX_SEQ_VALID     0x00000001
+#define IW_ENCODE_EXT_RX_SEQ_VALID     0x00000002
+#define IW_ENCODE_EXT_GROUP_KEY                0x00000004
+#define IW_ENCODE_EXT_SET_TX_KEY       0x00000008
+
+/* IWEVMICHAELMICFAILURE : struct iw_michaelmicfailure ->flags */
+#define IW_MICFAILURE_KEY_ID   0x00000003 /* Key ID 0..3 */
+#define IW_MICFAILURE_GROUP    0x00000004
+#define IW_MICFAILURE_PAIRWISE 0x00000008
+#define IW_MICFAILURE_STAKEY   0x00000010
+#define IW_MICFAILURE_COUNT    0x00000060 /* 1 or 2 (0 = count not supported)
+                                           */
+
+/* Bit field values for enc_capa in struct iw_range */
+#define IW_ENC_CAPA_WPA                0x00000001
+#define IW_ENC_CAPA_WPA2       0x00000002
+#define IW_ENC_CAPA_CIPHER_TKIP        0x00000004
+#define IW_ENC_CAPA_CIPHER_CCMP        0x00000008
+
+/* Event capability macros - in (struct iw_range *)->event_capa
+ * Because we have more than 32 possible events, we use an array of
+ * 32 bit bitmasks. Note : 32 bits = 0x20 = 2^5. */
+#define IW_EVENT_CAPA_BASE(cmd)                ((cmd >= SIOCIWFIRSTPRIV) ? \
+                                        (cmd - SIOCIWFIRSTPRIV + 0x60) : \
+                                        (cmd - SIOCSIWCOMMIT))
+#define IW_EVENT_CAPA_INDEX(cmd)       (IW_EVENT_CAPA_BASE(cmd) >> 5)
+#define IW_EVENT_CAPA_MASK(cmd)                (1 << (IW_EVENT_CAPA_BASE(cmd) & 0x1F))
+/* Event capability constants - event autogenerated by the kernel
+ * This list is valid for most 802.11 devices, customise as needed... */
+#define IW_EVENT_CAPA_K_0      (IW_EVENT_CAPA_MASK(0x8B04) | \
+                                IW_EVENT_CAPA_MASK(0x8B06) | \
+                                IW_EVENT_CAPA_MASK(0x8B1A))
+#define IW_EVENT_CAPA_K_1      (IW_EVENT_CAPA_MASK(0x8B2A))
+/* "Easy" macro to set events in iw_range (less efficient) */
+#define IW_EVENT_CAPA_SET(event_capa, cmd) (event_capa[IW_EVENT_CAPA_INDEX(cmd)] |= IW_EVENT_CAPA_MASK(cmd))
+#define IW_EVENT_CAPA_SET_KERNEL(event_capa) {event_capa[0] |= IW_EVENT_CAPA_K_0; event_capa[1] |= IW_EVENT_CAPA_K_1; }
+
+
+/****************************** TYPES ******************************/
+
+/* --------------------------- SUBTYPES --------------------------- */
+/*
+ *     Generic format for most parameters that fit in an int
+ */
+struct iw_param
+{
+  __s32                value;          /* The value of the parameter itself */
+  __u8         fixed;          /* Hardware should not use auto select */
+  __u8         disabled;       /* Disable the feature */
+  __u16                flags;          /* Various specifc flags (if any) */
+};
+
+/*
+ *     For all data larger than 16 octets, we need to use a
+ *     pointer to memory allocated in user space.
+ */
+struct iw_point
+{
+  void __user  *pointer;       /* Pointer to the data  (in user space) */
+  __u16                length;         /* number of fields or size in bytes */
+  __u16                flags;          /* Optional params */
+};
+
+/*
+ *     A frequency
+ *     For numbers lower than 10^9, we encode the number in 'm' and
+ *     set 'e' to 0
+ *     For number greater than 10^9, we divide it by the lowest power
+ *     of 10 to get 'm' lower than 10^9, with 'm'= f / (10^'e')...
+ *     The power of 10 is in 'e', the result of the division is in 'm'.
+ */
+struct iw_freq
+{
+       __s32           m;              /* Mantissa */
+       __s16           e;              /* Exponent */
+       __u8            i;              /* List index (when in range struct) */
+       __u8            flags;          /* Flags (fixed/auto) */
+};
+
+/*
+ *     Quality of the link
+ */
+struct iw_quality
+{
+       __u8            qual;           /* link quality (%retries, SNR,
+                                          %missed beacons or better...) */
+       __u8            level;          /* signal level (dBm) */
+       __u8            noise;          /* noise level (dBm) */
+       __u8            updated;        /* Flags to know if updated */
+};
+
+/*
+ *     Packet discarded in the wireless adapter due to
+ *     "wireless" specific problems...
+ *     Note : the list of counter and statistics in net_device_stats
+ *     is already pretty exhaustive, and you should use that first.
+ *     This is only additional stats...
+ */
+struct iw_discarded
+{
+       __u32           nwid;           /* Rx : Wrong nwid/essid */
+       __u32           code;           /* Rx : Unable to code/decode (WEP) */
+       __u32           fragment;       /* Rx : Can't perform MAC reassembly */
+       __u32           retries;        /* Tx : Max MAC retries num reached */
+       __u32           misc;           /* Others cases */
+};
+
+/*
+ *     Packet/Time period missed in the wireless adapter due to
+ *     "wireless" specific problems...
+ */
+struct iw_missed
+{
+       __u32           beacon;         /* Missed beacons/superframe */
+};
+
+/*
+ *     Quality range (for spy threshold)
+ */
+struct iw_thrspy
+{
+       struct sockaddr         addr;           /* Source address (hw/mac) */
+       struct iw_quality       qual;           /* Quality of the link */
+       struct iw_quality       low;            /* Low threshold */
+       struct iw_quality       high;           /* High threshold */
+};
+
+/*
+ *     Optional data for scan request
+ *
+ *     Note: these optional parameters are controlling parameters for the
+ *     scanning behavior, these do not apply to getting scan results
+ *     (SIOCGIWSCAN). Drivers are expected to keep a local BSS table and
+ *     provide a merged results with all BSSes even if the previous scan
+ *     request limited scanning to a subset, e.g., by specifying an SSID.
+ *     Especially, scan results are required to include an entry for the
+ *     current BSS if the driver is in Managed mode and associated with an AP.
+ */
+struct iw_scan_req
+{
+       __u8            scan_type; /* IW_SCAN_TYPE_{ACTIVE,PASSIVE} */
+       __u8            essid_len;
+       __u8            num_channels; /* num entries in channel_list;
+                                      * 0 = scan all allowed channels */
+       __u8            flags; /* reserved as padding; use zero, this may
+                               * be used in the future for adding flags
+                               * to request different scan behavior */
+       struct sockaddr bssid; /* ff:ff:ff:ff:ff:ff for broadcast BSSID or
+                               * individual address of a specific BSS */
+
+       /*
+        * Use this ESSID if IW_SCAN_THIS_ESSID flag is used instead of using
+        * the current ESSID. This allows scan requests for specific ESSID
+        * without having to change the current ESSID and potentially breaking
+        * the current association.
+        */
+       __u8            essid[IW_ESSID_MAX_SIZE];
+
+       /*
+        * Optional parameters for changing the default scanning behavior.
+        * These are based on the MLME-SCAN.request from IEEE Std 802.11.
+        * TU is 1.024 ms. If these are set to 0, driver is expected to use
+        * reasonable default values. min_channel_time defines the time that
+        * will be used to wait for the first reply on each channel. If no
+        * replies are received, next channel will be scanned after this. If
+        * replies are received, total time waited on the channel is defined by
+        * max_channel_time.
+        */
+       __u32           min_channel_time; /* in TU */
+       __u32           max_channel_time; /* in TU */
+
+       struct iw_freq  channel_list[IW_MAX_FREQUENCIES];
+};
+
+/* ------------------------- WPA SUPPORT ------------------------- */
+
+/*
+ *     Extended data structure for get/set encoding (this is used with
+ *     SIOCSIWENCODEEXT/SIOCGIWENCODEEXT. struct iw_point and IW_ENCODE_*
+ *     flags are used in the same way as with SIOCSIWENCODE/SIOCGIWENCODE and
+ *     only the data contents changes (key data -> this structure, including
+ *     key data).
+ *
+ *     If the new key is the first group key, it will be set as the default
+ *     TX key. Otherwise, default TX key index is only changed if
+ *     IW_ENCODE_EXT_SET_TX_KEY flag is set.
+ *
+ *     Key will be changed with SIOCSIWENCODEEXT in all cases except for
+ *     special "change TX key index" operation which is indicated by setting
+ *     key_len = 0 and ext_flags |= IW_ENCODE_EXT_SET_TX_KEY.
+ *
+ *     tx_seq/rx_seq are only used when respective
+ *     IW_ENCODE_EXT_{TX,RX}_SEQ_VALID flag is set in ext_flags. Normal
+ *     TKIP/CCMP operation is to set RX seq with SIOCSIWENCODEEXT and start
+ *     TX seq from zero whenever key is changed. SIOCGIWENCODEEXT is normally
+ *     used only by an Authenticator (AP or an IBSS station) to get the
+ *     current TX sequence number. Using TX_SEQ_VALID for SIOCSIWENCODEEXT and
+ *     RX_SEQ_VALID for SIOCGIWENCODEEXT are optional, but can be useful for
+ *     debugging/testing.
+ */
+struct iw_encode_ext
+{
+       __u32           ext_flags; /* IW_ENCODE_EXT_* */
+       __u8            tx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
+       __u8            rx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
+       struct sockaddr addr; /* ff:ff:ff:ff:ff:ff for broadcast/multicast
+                              * (group) keys or unicast address for
+                              * individual keys */
+       __u16           alg; /* IW_ENCODE_ALG_* */
+       __u16           key_len;
+       __u8            key[0];
+};
+
+/* SIOCSIWMLME data */
+struct iw_mlme
+{
+       __u16           cmd; /* IW_MLME_* */
+       __u16           reason_code;
+       struct sockaddr addr;
+};
+
+/* SIOCSIWPMKSA data */
+#define IW_PMKSA_ADD           1
+#define IW_PMKSA_REMOVE                2
+#define IW_PMKSA_FLUSH         3
+
+#define IW_PMKID_LEN   16
+
+struct iw_pmksa
+{
+       __u32           cmd; /* IW_PMKSA_* */
+       struct sockaddr bssid;
+       __u8            pmkid[IW_PMKID_LEN];
+};
+
+/* IWEVMICHAELMICFAILURE data */
+struct iw_michaelmicfailure
+{
+       __u32           flags;
+       struct sockaddr src_addr;
+       __u8            tsc[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
+};
+
+/* IWEVPMKIDCAND data */
+#define IW_PMKID_CAND_PREAUTH  0x00000001 /* RNS pre-authentication enabled */
+struct iw_pmkid_cand
+{
+       __u32           flags; /* IW_PMKID_CAND_* */
+       __u32           index; /* the smaller the index, the higher the
+                               * priority */
+       struct sockaddr bssid;
+};
+
+/* ------------------------ WIRELESS STATS ------------------------ */
+/*
+ * Wireless statistics (used for /proc/net/wireless)
+ */
+struct iw_statistics
+{
+       __u16           status;         /* Status
+                                        * - device dependent for now */
+
+       struct iw_quality       qual;           /* Quality of the link
+                                                * (instant/mean/max) */
+       struct iw_discarded     discard;        /* Packet discarded counts */
+       struct iw_missed        miss;           /* Packet missed counts */
+};
+
+/* ------------------------ IOCTL REQUEST ------------------------ */
+/*
+ * This structure defines the payload of an ioctl, and is used 
+ * below.
+ *
+ * Note that this structure should fit on the memory footprint
+ * of iwreq (which is the same as ifreq), which mean a max size of
+ * 16 octets = 128 bits. Warning, pointers might be 64 bits wide...
+ * You should check this when increasing the structures defined
+ * above in this file...
+ */
+union  iwreq_data
+{
+       /* Config - generic */
+       char            name[IFNAMSIZ];
+       /* Name : used to verify the presence of  wireless extensions.
+        * Name of the protocol/provider... */
+
+       struct iw_point essid;          /* Extended network name */
+       struct iw_param nwid;           /* network id (or domain - the cell) */
+       struct iw_freq  freq;           /* frequency or channel :
+                                        * 0-1000 = channel
+                                        * > 1000 = frequency in Hz */
+
+       struct iw_param sens;           /* signal level threshold */
+       struct iw_param bitrate;        /* default bit rate */
+       struct iw_param txpower;        /* default transmit power */
+       struct iw_param rts;            /* RTS threshold threshold */
+       struct iw_param frag;           /* Fragmentation threshold */
+       __u32           mode;           /* Operation mode */
+       struct iw_param retry;          /* Retry limits & lifetime */
+
+       struct iw_point encoding;       /* Encoding stuff : tokens */
+       struct iw_param power;          /* PM duration/timeout */
+       struct iw_quality qual;         /* Quality part of statistics */
+
+       struct sockaddr ap_addr;        /* Access point address */
+       struct sockaddr addr;           /* Destination address (hw/mac) */
+
+       struct iw_param param;          /* Other small parameters */
+       struct iw_point data;           /* Other large parameters */
+};
+
+/*
+ * The structure to exchange data for ioctl.
+ * This structure is the same as 'struct ifreq', but (re)defined for
+ * convenience...
+ * Do I need to remind you about structure size (32 octets) ?
+ */
+struct iwreq 
+{
+       union
+       {
+               char    ifrn_name[IFNAMSIZ];    /* if name, e.g. "eth0" */
+       } ifr_ifrn;
+
+       /* Data part (defined just above) */
+       union   iwreq_data      u;
+};
+
+/* -------------------------- IOCTL DATA -------------------------- */
+/*
+ *     For those ioctl which want to exchange mode data that what could
+ *     fit in the above structure...
+ */
+
+/*
+ *     Range of parameters
+ */
+
+struct iw_range
+{
+       /* Informative stuff (to choose between different interface) */
+       __u32           throughput;     /* To give an idea... */
+       /* In theory this value should be the maximum benchmarked
+        * TCP/IP throughput, because with most of these devices the
+        * bit rate is meaningless (overhead an co) to estimate how
+        * fast the connection will go and pick the fastest one.
+        * I suggest people to play with Netperf or any benchmark...
+        */
+
+       /* NWID (or domain id) */
+       __u32           min_nwid;       /* Minimal NWID we are able to set */
+       __u32           max_nwid;       /* Maximal NWID we are able to set */
+
+       /* Old Frequency (backward compat - moved lower ) */
+       __u16           old_num_channels;
+       __u8            old_num_frequency;
+
+       /* Wireless event capability bitmasks */
+       __u32           event_capa[6];
+
+       /* signal level threshold range */
+       __s32           sensitivity;
+
+       /* Quality of link & SNR stuff */
+       /* Quality range (link, level, noise)
+        * If the quality is absolute, it will be in the range [0 ; max_qual],
+        * if the quality is dBm, it will be in the range [max_qual ; 0].
+        * Don't forget that we use 8 bit arithmetics... */
+       struct iw_quality       max_qual;       /* Quality of the link */
+       /* This should contain the average/typical values of the quality
+        * indicator. This should be the threshold between a "good" and
+        * a "bad" link (example : monitor going from green to orange).
+        * Currently, user space apps like quality monitors don't have any
+        * way to calibrate the measurement. With this, they can split
+        * the range between 0 and max_qual in different quality level
+        * (using a geometric subdivision centered on the average).
+        * I expect that people doing the user space apps will feedback
+        * us on which value we need to put in each driver... */
+       struct iw_quality       avg_qual;       /* Quality of the link */
+
+       /* Rates */
+       __u8            num_bitrates;   /* Number of entries in the list */
+       __s32           bitrate[IW_MAX_BITRATES];       /* list, in bps */
+
+       /* RTS threshold */
+       __s32           min_rts;        /* Minimal RTS threshold */
+       __s32           max_rts;        /* Maximal RTS threshold */
+
+       /* Frag threshold */
+       __s32           min_frag;       /* Minimal frag threshold */
+       __s32           max_frag;       /* Maximal frag threshold */
+
+       /* Power Management duration & timeout */
+       __s32           min_pmp;        /* Minimal PM period */
+       __s32           max_pmp;        /* Maximal PM period */
+       __s32           min_pmt;        /* Minimal PM timeout */
+       __s32           max_pmt;        /* Maximal PM timeout */
+       __u16           pmp_flags;      /* How to decode max/min PM period */
+       __u16           pmt_flags;      /* How to decode max/min PM timeout */
+       __u16           pm_capa;        /* What PM options are supported */
+
+       /* Encoder stuff */
+       __u16   encoding_size[IW_MAX_ENCODING_SIZES];   /* Different token sizes */
+       __u8    num_encoding_sizes;     /* Number of entry in the list */
+       __u8    max_encoding_tokens;    /* Max number of tokens */
+       /* For drivers that need a "login/passwd" form */
+       __u8    encoding_login_index;   /* token index for login token */
+
+       /* Transmit power */
+       __u16           txpower_capa;   /* What options are supported */
+       __u8            num_txpower;    /* Number of entries in the list */
+       __s32           txpower[IW_MAX_TXPOWER];        /* list, in bps */
+
+       /* Wireless Extension version info */
+       __u8            we_version_compiled;    /* Must be WIRELESS_EXT */
+       __u8            we_version_source;      /* Last update of source */
+
+       /* Retry limits and lifetime */
+       __u16           retry_capa;     /* What retry options are supported */
+       __u16           retry_flags;    /* How to decode max/min retry limit */
+       __u16           r_time_flags;   /* How to decode max/min retry life */
+       __s32           min_retry;      /* Minimal number of retries */
+       __s32           max_retry;      /* Maximal number of retries */
+       __s32           min_r_time;     /* Minimal retry lifetime */
+       __s32           max_r_time;     /* Maximal retry lifetime */
+
+       /* Frequency */
+       __u16           num_channels;   /* Number of channels [0; num - 1] */
+       __u8            num_frequency;  /* Number of entry in the list */
+       struct iw_freq  freq[IW_MAX_FREQUENCIES];       /* list */
+       /* Note : this frequency list doesn't need to fit channel numbers,
+        * because each entry contain its channel index */
+
+       __u32           enc_capa; /* IW_ENC_CAPA_* bit field */
+};
+
+/*
+ * Private ioctl interface information
+ */
+struct iw_priv_args
+{
+       __u32           cmd;            /* Number of the ioctl to issue */
+       __u16           set_args;       /* Type and number of args */
+       __u16           get_args;       /* Type and number of args */
+       char            name[IFNAMSIZ]; /* Name of the extension */
+};
+
+/* ----------------------- WIRELESS EVENTS ----------------------- */
+/*
+ * Wireless events are carried through the rtnetlink socket to user
+ * space. They are encapsulated in the IFLA_WIRELESS field of
+ * a RTM_NEWLINK message.
+ */
+
+/*
+ * A Wireless Event. Contains basically the same data as the ioctl...
+ */
+struct iw_event
+{
+       __u16           len;                    /* Real lenght of this stuff */
+       __u16           cmd;                    /* Wireless IOCTL */
+       union iwreq_data        u;              /* IOCTL fixed payload */
+};
+
+/* Size of the Event prefix (including padding and alignement junk) */
+#define IW_EV_LCP_LEN  (sizeof(struct iw_event) - sizeof(union iwreq_data))
+/* Size of the various events */
+#define IW_EV_CHAR_LEN (IW_EV_LCP_LEN + IFNAMSIZ)
+#define IW_EV_UINT_LEN (IW_EV_LCP_LEN + sizeof(__u32))
+#define IW_EV_FREQ_LEN (IW_EV_LCP_LEN + sizeof(struct iw_freq))
+#define IW_EV_POINT_LEN        (IW_EV_LCP_LEN + sizeof(struct iw_point))
+#define IW_EV_PARAM_LEN        (IW_EV_LCP_LEN + sizeof(struct iw_param))
+#define IW_EV_ADDR_LEN (IW_EV_LCP_LEN + sizeof(struct sockaddr))
+#define IW_EV_QUAL_LEN (IW_EV_LCP_LEN + sizeof(struct iw_quality))
+
+/* Note : in the case of iw_point, the extra data will come at the
+ * end of the event */
+
+#endif /* _LINUX_WIRELESS_H */
diff --git a/wireless_tools/wireless.19.h b/wireless_tools/wireless.19.h
new file mode 100644 (file)
index 0000000..dab5afd
--- /dev/null
@@ -0,0 +1,1069 @@
+/*
+ * This file define a set of standard wireless extensions
+ *
+ * Version :   19      18.3.05
+ *
+ * Authors :   Jean Tourrilhes - HPL - <jt@hpl.hp.com>
+ * Copyright (c) 1997-2005 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
+ * driver.
+ * 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
+ * data exchanged...
+ * 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 :
+ *     # net/core/wireless.c
+ *
+ * Wireless Events (2002 -> onward) :
+ * --------------------------------
+ * Events are defined at the end of this file, and implemented in :
+ *     # net/core/wireless.c
+ *
+ * Other comments :
+ * --------------
+ * Do not add here things that are redundant with other mechanisms
+ * (drivers init, ifconfig, /proc/net/dev, ...) and with are not
+ * wireless specific.
+ *
+ * These wireless extensions are not magic : each driver has to provide
+ * support for them...
+ *
+ * IMPORTANT NOTE : As everything in the kernel, this is very much a
+ * work in progress. Contact me if you have ideas of improvements...
+ */
+
+/***************************** INCLUDES *****************************/
+
+/* Do not put any header in this file, this creates a mess when
+ * exported to user space. Most users have included all the
+ * relevant headers anyway... Jean II */
+/*#include <linux/types.h>*/           /* for "caddr_t" et al          */
+/*#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.
+ */
+#define WIRELESS_EXT   19
+
+/*
+ * Changes :
+ *
+ * V2 to V3
+ * --------
+ *     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
+ *
+ * V3 to V4
+ * --------
+ *     - Add sensitivity
+ *
+ * V4 to V5
+ * --------
+ *     - Missing encoding definitions in range
+ *     - Access points stuff
+ *
+ * V5 to V6
+ * --------
+ *     - 802.11 support (ESSID ioctls)
+ *
+ * V6 to V7
+ * --------
+ *     - define IW_ESSID_MAX_SIZE and IW_MAX_AP
+ *
+ * V7 to V8
+ * --------
+ *     - Changed my e-mail address
+ *     - More 802.11 support (nickname, rate, rts, frag)
+ *     - List index in frequencies
+ *
+ * V8 to V9
+ * --------
+ *     - 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
+ *
+ * V9 to V10
+ * ---------
+ *     - Add PM capability to range structure
+ *     - Add PM modifier : MAX/MIN/RELATIVE
+ *     - Add encoding option : IW_ENCODE_NOKEY
+ *     - Add TxPower ioctls (work like TxRate)
+ *
+ * V10 to V11
+ * ----------
+ *     - Add WE version in range (help backward/forward compatibility)
+ *     - Add retry ioctls (work like PM)
+ *
+ * V11 to V12
+ * ----------
+ *     - 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)
+ *
+ * V12 to V13
+ * ----------
+ *     - Document creation of new driver API.
+ *     - Extract union iwreq_data from struct iwreq (for new driver API).
+ *     - Rename SIOCSIWNAME as SIOCSIWCOMMIT
+ *
+ * V13 to V14
+ * ----------
+ *     - 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)
+ *
+ * V14 to V15
+ * ----------
+ *     - 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
+ *
+ * V15 to V16
+ * ----------
+ *     - 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
+ *
+ * V16 to V17
+ * ----------
+ *     - 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 <jkmaline@cc.hut.fi>)
+ * ----------
+ *     - Add support for WPA/WPA2
+ *     - Add extended encoding configuration (SIOCSIWENCODEEXT and
+ *       SIOCGIWENCODEEXT)
+ *     - Add SIOCSIWGENIE/SIOCGIWGENIE
+ *     - Add SIOCSIWMLME
+ *     - Add SIOCSIWPMKSA
+ *     - 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
+ *
+ * V18 to V19
+ * ----------
+ *     - 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
+ */
+
+/**************************** 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. */
+
+/* Basic operations */
+#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) */
+
+/* Informative stuff */
+#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
+                                        * struct iw_mlme */
+/* 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
+ * 'mii-tool'.
+ * We now have 32 commands, so a bit more space ;-).
+ * Also, all 'odd' 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)
+
+/* Even : get (world access), odd : 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
+                                        * IWEVGENIE events. */
+#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
+                                        * association. */
+#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
+                                        * association. */
+#define IWEVPMKIDCAND  0x8C09          /* PMKID candidate for RSN
+                                        * pre-authentication
+                                        * (struct iw_pmkid_cand) */
+
+#define IWEVFIRST      0x8C00
+#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 */
+#define IW_MAX_TXPOWER         8
+/* 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 */
+#define IW_MAX_SPY             8
+
+/* Maximum of address that you may get in the
+   list of access points in range */
+#define IW_MAX_AP              64
+
+/* Maximum size of the ESSID and NICKN strings */
+#define IW_ESSID_MAX_SIZE      32
+
+/* Modes of operation */
+#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) */
+
+/* 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_ALL_INVALID    0x70
+
+/* Frequency flags */
+#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 */
+#define IW_POWER_FORCE_S       0x0400  /* Force PM procedure for sending unicast */
+#define IW_POWER_REPEATER      0x0800  /* Repeat broadcast messages in PM period */
+#define IW_POWER_MODIFIER      0x000F  /* Modify a parameter */
+#define IW_POWER_MIN           0x0001  /* Value is a minimum  */
+#define IW_POWER_MAX           0x0002  /* Value is a maximum */
+#define IW_POWER_RELATIVE      0x0004  /* Value is not in seconds/ms/us */
+
+/* Transmit Power flags available */
+#define IW_TXPOW_TYPE          0x00FF  /* Type of value */
+#define IW_TXPOW_DBM           0x0000  /* Value is in dBm */
+#define IW_TXPOW_MWATT         0x0001  /* Value is in mW */
+#define IW_TXPOW_RELATIVE      0x0002  /* Value is in arbitrary units */
+#define IW_TXPOW_RANGE         0x1000  /* Range of value between min/max */
+
+/* Retry limits and lifetime flags available */
+#define IW_RETRY_ON            0x0000  /* No details... */
+#define IW_RETRY_TYPE          0xF000  /* Type of parameter */
+#define IW_RETRY_LIMIT         0x1000  /* Maximum number of retries*/
+#define IW_RETRY_LIFETIME      0x2000  /* Maximum duration of retries in us */
+#define IW_RETRY_MODIFIER      0x000F  /* Modify a parameter */
+#define IW_RETRY_MIN           0x0001  /* Value is a minimum  */
+#define IW_RETRY_MAX           0x0002  /* Value is a maximum */
+#define IW_RETRY_RELATIVE      0x0004  /* Value is not in seconds/ms/us */
+
+/* Scanning request flags */
+#define IW_SCAN_DEFAULT                0x0000  /* Default scan of the driver */
+#define IW_SCAN_ALL_ESSID      0x0001  /* Scan all ESSIDs */
+#define IW_SCAN_THIS_ESSID     0x0002  /* Scan only this ESSID */
+#define IW_SCAN_ALL_FREQ       0x0004  /* Scan all Frequencies */
+#define IW_SCAN_THIS_FREQ      0x0008  /* Scan only this Frequency */
+#define IW_SCAN_ALL_MODE       0x0010  /* Scan all Modes */
+#define IW_SCAN_THIS_MODE      0x0020  /* Scan only this Mode */
+#define IW_SCAN_ALL_RATE       0x0040  /* Scan all Bit-Rates */
+#define IW_SCAN_THIS_RATE      0x0080  /* Scan only this Bit-Rate */
+/* struct iw_scan_req scan_type */
+#define IW_SCAN_TYPE_ACTIVE 0
+#define IW_SCAN_TYPE_PASSIVE 1
+/* Maximum size of returned data */
+#define IW_SCAN_MAX_DATA       4096    /* In bytes */
+
+/* Max number of char in custom event - use multiple of them if needed */
+#define IW_CUSTOM_MAX          256     /* In bytes */
+
+/* Generic information element */
+#define IW_GENERIC_IE_MAX      1024
+
+/* MLME requests (SIOCSIWMLME / struct iw_mlme) */
+#define IW_MLME_DEAUTH         0
+#define IW_MLME_DISASSOC       1
+
+/* SIOCSIWAUTH/SIOCGIWAUTH struct iw_param flags */
+#define IW_AUTH_INDEX          0x0FFF
+#define IW_AUTH_FLAGS          0xF000
+/* SIOCSIWAUTH/SIOCGIWAUTH parameters (0 .. 4095)
+ * (IW_AUTH_INDEX mask in struct iw_param flags; this is the index of the
+ * parameter that is being set/get to; value will be read/written to
+ * struct iw_param value field) */
+#define IW_AUTH_WPA_VERSION            0
+#define IW_AUTH_CIPHER_PAIRWISE                1
+#define IW_AUTH_CIPHER_GROUP           2
+#define IW_AUTH_KEY_MGMT               3
+#define IW_AUTH_TKIP_COUNTERMEASURES   4
+#define IW_AUTH_DROP_UNENCRYPTED       5
+#define IW_AUTH_80211_AUTH_ALG         6
+#define IW_AUTH_WPA_ENABLED            7
+#define IW_AUTH_RX_UNENCRYPTED_EAPOL   8
+#define IW_AUTH_ROAMING_CONTROL                9
+#define IW_AUTH_PRIVACY_INVOKED                10
+
+/* IW_AUTH_WPA_VERSION values (bit field) */
+#define IW_AUTH_WPA_VERSION_DISABLED   0x00000001
+#define IW_AUTH_WPA_VERSION_WPA                0x00000002
+#define IW_AUTH_WPA_VERSION_WPA2       0x00000004
+
+/* IW_AUTH_PAIRWISE_CIPHER and IW_AUTH_GROUP_CIPHER values (bit field) */
+#define IW_AUTH_CIPHER_NONE    0x00000001
+#define IW_AUTH_CIPHER_WEP40   0x00000002
+#define IW_AUTH_CIPHER_TKIP    0x00000004
+#define IW_AUTH_CIPHER_CCMP    0x00000008
+#define IW_AUTH_CIPHER_WEP104  0x00000010
+
+/* IW_AUTH_KEY_MGMT values (bit field) */
+#define IW_AUTH_KEY_MGMT_802_1X        1
+#define IW_AUTH_KEY_MGMT_PSK   2
+
+/* IW_AUTH_80211_AUTH_ALG values (bit field) */
+#define IW_AUTH_ALG_OPEN_SYSTEM        0x00000001
+#define IW_AUTH_ALG_SHARED_KEY 0x00000002
+#define IW_AUTH_ALG_LEAP       0x00000004
+
+/* IW_AUTH_ROAMING_CONTROL values */
+#define IW_AUTH_ROAMING_ENABLE 0       /* driver/firmware based roaming */
+#define IW_AUTH_ROAMING_DISABLE        1       /* user space program used for roaming
+                                        * control */
+
+/* SIOCSIWENCODEEXT definitions */
+#define IW_ENCODE_SEQ_MAX_SIZE 8
+/* struct iw_encode_ext ->alg */
+#define IW_ENCODE_ALG_NONE     0
+#define IW_ENCODE_ALG_WEP      1
+#define IW_ENCODE_ALG_TKIP     2
+#define IW_ENCODE_ALG_CCMP     3
+/* struct iw_encode_ext ->ext_flags */
+#define IW_ENCODE_EXT_TX_SEQ_VALID     0x00000001
+#define IW_ENCODE_EXT_RX_SEQ_VALID     0x00000002
+#define IW_ENCODE_EXT_GROUP_KEY                0x00000004
+#define IW_ENCODE_EXT_SET_TX_KEY       0x00000008
+
+/* IWEVMICHAELMICFAILURE : struct iw_michaelmicfailure ->flags */
+#define IW_MICFAILURE_KEY_ID   0x00000003 /* Key ID 0..3 */
+#define IW_MICFAILURE_GROUP    0x00000004
+#define IW_MICFAILURE_PAIRWISE 0x00000008
+#define IW_MICFAILURE_STAKEY   0x00000010
+#define IW_MICFAILURE_COUNT    0x00000060 /* 1 or 2 (0 = count not supported)
+                                           */
+
+/* Bit field values for enc_capa in struct iw_range */
+#define IW_ENC_CAPA_WPA                0x00000001
+#define IW_ENC_CAPA_WPA2       0x00000002
+#define IW_ENC_CAPA_CIPHER_TKIP        0x00000004
+#define IW_ENC_CAPA_CIPHER_CCMP        0x00000008
+
+/* Event capability macros - in (struct iw_range *)->event_capa
+ * Because we have more than 32 possible events, we use an array of
+ * 32 bit bitmasks. Note : 32 bits = 0x20 = 2^5. */
+#define IW_EVENT_CAPA_BASE(cmd)                ((cmd >= SIOCIWFIRSTPRIV) ? \
+                                        (cmd - SIOCIWFIRSTPRIV + 0x60) : \
+                                        (cmd - SIOCSIWCOMMIT))
+#define IW_EVENT_CAPA_INDEX(cmd)       (IW_EVENT_CAPA_BASE(cmd) >> 5)
+#define IW_EVENT_CAPA_MASK(cmd)                (1 << (IW_EVENT_CAPA_BASE(cmd) & 0x1F))
+/* Event capability constants - event autogenerated by the kernel
+ * This list is valid for most 802.11 devices, customise as needed... */
+#define IW_EVENT_CAPA_K_0      (IW_EVENT_CAPA_MASK(0x8B04) | \
+                                IW_EVENT_CAPA_MASK(0x8B06) | \
+                                IW_EVENT_CAPA_MASK(0x8B1A))
+#define IW_EVENT_CAPA_K_1      (IW_EVENT_CAPA_MASK(0x8B2A))
+/* "Easy" macro to set events in iw_range (less efficient) */
+#define IW_EVENT_CAPA_SET(event_capa, cmd) (event_capa[IW_EVENT_CAPA_INDEX(cmd)] |= IW_EVENT_CAPA_MASK(cmd))
+#define IW_EVENT_CAPA_SET_KERNEL(event_capa) {event_capa[0] |= IW_EVENT_CAPA_K_0; event_capa[1] |= IW_EVENT_CAPA_K_1; }
+
+
+/****************************** TYPES ******************************/
+
+/* --------------------------- SUBTYPES --------------------------- */
+/*
+ *     Generic format for most parameters that fit in an int
+ */
+struct iw_param
+{
+  __s32                value;          /* The value of the parameter itself */
+  __u8         fixed;          /* Hardware should not use auto select */
+  __u8         disabled;       /* Disable the feature */
+  __u16                flags;          /* Various specifc flags (if any) */
+};
+
+/*
+ *     For all data larger than 16 octets, we need to use a
+ *     pointer to memory allocated in user space.
+ */
+struct iw_point
+{
+  void __user  *pointer;       /* Pointer to the data  (in user space) */
+  __u16                length;         /* number of fields or size in bytes */
+  __u16                flags;          /* Optional params */
+};
+
+/*
+ *     A frequency
+ *     For numbers lower than 10^9, we encode the number in 'm' and
+ *     set 'e' to 0
+ *     For number greater than 10^9, we divide it by the lowest power
+ *     of 10 to get 'm' lower than 10^9, with 'm'= f / (10^'e')...
+ *     The power of 10 is in 'e', the result of the division is in 'm'.
+ */
+struct iw_freq
+{
+       __s32           m;              /* Mantissa */
+       __s16           e;              /* Exponent */
+       __u8            i;              /* List index (when in range struct) */
+       __u8            flags;          /* Flags (fixed/auto) */
+};
+
+/*
+ *     Quality of the link
+ */
+struct iw_quality
+{
+       __u8            qual;           /* link quality (%retries, SNR,
+                                          %missed beacons or better...) */
+       __u8            level;          /* signal level (dBm) */
+       __u8            noise;          /* noise level (dBm) */
+       __u8            updated;        /* Flags to know if updated */
+};
+
+/*
+ *     Packet discarded in the wireless adapter due to
+ *     "wireless" specific problems...
+ *     Note : the list of counter and statistics in net_device_stats
+ *     is already pretty exhaustive, and you should use that first.
+ *     This is only additional stats...
+ */
+struct iw_discarded
+{
+       __u32           nwid;           /* Rx : Wrong nwid/essid */
+       __u32           code;           /* Rx : Unable to code/decode (WEP) */
+       __u32           fragment;       /* Rx : Can't perform MAC reassembly */
+       __u32           retries;        /* Tx : Max MAC retries num reached */
+       __u32           misc;           /* Others cases */
+};
+
+/*
+ *     Packet/Time period missed in the wireless adapter due to
+ *     "wireless" specific problems...
+ */
+struct iw_missed
+{
+       __u32           beacon;         /* Missed beacons/superframe */
+};
+
+/*
+ *     Quality range (for spy threshold)
+ */
+struct iw_thrspy
+{
+       struct sockaddr         addr;           /* Source address (hw/mac) */
+       struct iw_quality       qual;           /* Quality of the link */
+       struct iw_quality       low;            /* Low threshold */
+       struct iw_quality       high;           /* High threshold */
+};
+
+/*
+ *     Optional data for scan request
+ *
+ *     Note: these optional parameters are controlling parameters for the
+ *     scanning behavior, these do not apply to getting scan results
+ *     (SIOCGIWSCAN). Drivers are expected to keep a local BSS table and
+ *     provide a merged results with all BSSes even if the previous scan
+ *     request limited scanning to a subset, e.g., by specifying an SSID.
+ *     Especially, scan results are required to include an entry for the
+ *     current BSS if the driver is in Managed mode and associated with an AP.
+ */
+struct iw_scan_req
+{
+       __u8            scan_type; /* IW_SCAN_TYPE_{ACTIVE,PASSIVE} */
+       __u8            essid_len;
+       __u8            num_channels; /* num entries in channel_list;
+                                      * 0 = scan all allowed channels */
+       __u8            flags; /* reserved as padding; use zero, this may
+                               * be used in the future for adding flags
+                               * to request different scan behavior */
+       struct sockaddr bssid; /* ff:ff:ff:ff:ff:ff for broadcast BSSID or
+                               * individual address of a specific BSS */
+
+       /*
+        * Use this ESSID if IW_SCAN_THIS_ESSID flag is used instead of using
+        * the current ESSID. This allows scan requests for specific ESSID
+        * without having to change the current ESSID and potentially breaking
+        * the current association.
+        */
+       __u8            essid[IW_ESSID_MAX_SIZE];
+
+       /*
+        * Optional parameters for changing the default scanning behavior.
+        * These are based on the MLME-SCAN.request from IEEE Std 802.11.
+        * TU is 1.024 ms. If these are set to 0, driver is expected to use
+        * reasonable default values. min_channel_time defines the time that
+        * will be used to wait for the first reply on each channel. If no
+        * replies are received, next channel will be scanned after this. If
+        * replies are received, total time waited on the channel is defined by
+        * max_channel_time.
+        */
+       __u32           min_channel_time; /* in TU */
+       __u32           max_channel_time; /* in TU */
+
+       struct iw_freq  channel_list[IW_MAX_FREQUENCIES];
+};
+
+/* ------------------------- WPA SUPPORT ------------------------- */
+
+/*
+ *     Extended data structure for get/set encoding (this is used with
+ *     SIOCSIWENCODEEXT/SIOCGIWENCODEEXT. struct iw_point and IW_ENCODE_*
+ *     flags are used in the same way as with SIOCSIWENCODE/SIOCGIWENCODE and
+ *     only the data contents changes (key data -> this structure, including
+ *     key data).
+ *
+ *     If the new key is the first group key, it will be set as the default
+ *     TX key. Otherwise, default TX key index is only changed if
+ *     IW_ENCODE_EXT_SET_TX_KEY flag is set.
+ *
+ *     Key will be changed with SIOCSIWENCODEEXT in all cases except for
+ *     special "change TX key index" operation which is indicated by setting
+ *     key_len = 0 and ext_flags |= IW_ENCODE_EXT_SET_TX_KEY.
+ *
+ *     tx_seq/rx_seq are only used when respective
+ *     IW_ENCODE_EXT_{TX,RX}_SEQ_VALID flag is set in ext_flags. Normal
+ *     TKIP/CCMP operation is to set RX seq with SIOCSIWENCODEEXT and start
+ *     TX seq from zero whenever key is changed. SIOCGIWENCODEEXT is normally
+ *     used only by an Authenticator (AP or an IBSS station) to get the
+ *     current TX sequence number. Using TX_SEQ_VALID for SIOCSIWENCODEEXT and
+ *     RX_SEQ_VALID for SIOCGIWENCODEEXT are optional, but can be useful for
+ *     debugging/testing.
+ */
+struct iw_encode_ext
+{
+       __u32           ext_flags; /* IW_ENCODE_EXT_* */
+       __u8            tx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
+       __u8            rx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
+       struct sockaddr addr; /* ff:ff:ff:ff:ff:ff for broadcast/multicast
+                              * (group) keys or unicast address for
+                              * individual keys */
+       __u16           alg; /* IW_ENCODE_ALG_* */
+       __u16           key_len;
+       __u8            key[0];
+};
+
+/* SIOCSIWMLME data */
+struct iw_mlme
+{
+       __u16           cmd; /* IW_MLME_* */
+       __u16           reason_code;
+       struct sockaddr addr;
+};
+
+/* SIOCSIWPMKSA data */
+#define IW_PMKSA_ADD           1
+#define IW_PMKSA_REMOVE                2
+#define IW_PMKSA_FLUSH         3
+
+#define IW_PMKID_LEN   16
+
+struct iw_pmksa
+{
+       __u32           cmd; /* IW_PMKSA_* */
+       struct sockaddr bssid;
+       __u8            pmkid[IW_PMKID_LEN];
+};
+
+/* IWEVMICHAELMICFAILURE data */
+struct iw_michaelmicfailure
+{
+       __u32           flags;
+       struct sockaddr src_addr;
+       __u8            tsc[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
+};
+
+/* IWEVPMKIDCAND data */
+#define IW_PMKID_CAND_PREAUTH  0x00000001 /* RNS pre-authentication enabled */
+struct iw_pmkid_cand
+{
+       __u32           flags; /* IW_PMKID_CAND_* */
+       __u32           index; /* the smaller the index, the higher the
+                               * priority */
+       struct sockaddr bssid;
+};
+
+/* ------------------------ WIRELESS STATS ------------------------ */
+/*
+ * Wireless statistics (used for /proc/net/wireless)
+ */
+struct iw_statistics
+{
+       __u16           status;         /* Status
+                                        * - device dependent for now */
+
+       struct iw_quality       qual;           /* Quality of the link
+                                                * (instant/mean/max) */
+       struct iw_discarded     discard;        /* Packet discarded counts */
+       struct iw_missed        miss;           /* Packet missed counts */
+};
+
+/* ------------------------ IOCTL REQUEST ------------------------ */
+/*
+ * This structure defines the payload of an ioctl, and is used 
+ * below.
+ *
+ * Note that this structure should fit on the memory footprint
+ * of iwreq (which is the same as ifreq), which mean a max size of
+ * 16 octets = 128 bits. Warning, pointers might be 64 bits wide...
+ * You should check this when increasing the structures defined
+ * above in this file...
+ */
+union  iwreq_data
+{
+       /* Config - generic */
+       char            name[IFNAMSIZ];
+       /* Name : used to verify the presence of  wireless extensions.
+        * Name of the protocol/provider... */
+
+       struct iw_point essid;          /* Extended network name */
+       struct iw_param nwid;           /* network id (or domain - the cell) */
+       struct iw_freq  freq;           /* frequency or channel :
+                                        * 0-1000 = channel
+                                        * > 1000 = frequency in Hz */
+
+       struct iw_param sens;           /* signal level threshold */
+       struct iw_param bitrate;        /* default bit rate */
+       struct iw_param txpower;        /* default transmit power */
+       struct iw_param rts;            /* RTS threshold threshold */
+       struct iw_param frag;           /* Fragmentation threshold */
+       __u32           mode;           /* Operation mode */
+       struct iw_param retry;          /* Retry limits & lifetime */
+
+       struct iw_point encoding;       /* Encoding stuff : tokens */
+       struct iw_param power;          /* PM duration/timeout */
+       struct iw_quality qual;         /* Quality part of statistics */
+
+       struct sockaddr ap_addr;        /* Access point address */
+       struct sockaddr addr;           /* Destination address (hw/mac) */
+
+       struct iw_param param;          /* Other small parameters */
+       struct iw_point data;           /* Other large parameters */
+};
+
+/*
+ * The structure to exchange data for ioctl.
+ * This structure is the same as 'struct ifreq', but (re)defined for
+ * convenience...
+ * Do I need to remind you about structure size (32 octets) ?
+ */
+struct iwreq 
+{
+       union
+       {
+               char    ifrn_name[IFNAMSIZ];    /* if name, e.g. "eth0" */
+       } ifr_ifrn;
+
+       /* Data part (defined just above) */
+       union   iwreq_data      u;
+};
+
+/* -------------------------- IOCTL DATA -------------------------- */
+/*
+ *     For those ioctl which want to exchange mode data that what could
+ *     fit in the above structure...
+ */
+
+/*
+ *     Range of parameters
+ */
+
+struct iw_range
+{
+       /* Informative stuff (to choose between different interface) */
+       __u32           throughput;     /* To give an idea... */
+       /* In theory this value should be the maximum benchmarked
+        * TCP/IP throughput, because with most of these devices the
+        * bit rate is meaningless (overhead an co) to estimate how
+        * fast the connection will go and pick the fastest one.
+        * I suggest people to play with Netperf or any benchmark...
+        */
+
+       /* NWID (or domain id) */
+       __u32           min_nwid;       /* Minimal NWID we are able to set */
+       __u32           max_nwid;       /* Maximal NWID we are able to set */
+
+       /* Old Frequency (backward compat - moved lower ) */
+       __u16           old_num_channels;
+       __u8            old_num_frequency;
+
+       /* Wireless event capability bitmasks */
+       __u32           event_capa[6];
+
+       /* signal level threshold range */
+       __s32           sensitivity;
+
+       /* Quality of link & SNR stuff */
+       /* Quality range (link, level, noise)
+        * If the quality is absolute, it will be in the range [0 ; max_qual],
+        * if the quality is dBm, it will be in the range [max_qual ; 0].
+        * Don't forget that we use 8 bit arithmetics... */
+       struct iw_quality       max_qual;       /* Quality of the link */
+       /* This should contain the average/typical values of the quality
+        * indicator. This should be the threshold between a "good" and
+        * a "bad" link (example : monitor going from green to orange).
+        * Currently, user space apps like quality monitors don't have any
+        * way to calibrate the measurement. With this, they can split
+        * the range between 0 and max_qual in different quality level
+        * (using a geometric subdivision centered on the average).
+        * I expect that people doing the user space apps will feedback
+        * us on which value we need to put in each driver... */
+       struct iw_quality       avg_qual;       /* Quality of the link */
+
+       /* Rates */
+       __u8            num_bitrates;   /* Number of entries in the list */
+       __s32           bitrate[IW_MAX_BITRATES];       /* list, in bps */
+
+       /* RTS threshold */
+       __s32           min_rts;        /* Minimal RTS threshold */
+       __s32           max_rts;        /* Maximal RTS threshold */
+
+       /* Frag threshold */
+       __s32           min_frag;       /* Minimal frag threshold */
+       __s32           max_frag;       /* Maximal frag threshold */
+
+       /* Power Management duration & timeout */
+       __s32           min_pmp;        /* Minimal PM period */
+       __s32           max_pmp;        /* Maximal PM period */
+       __s32           min_pmt;        /* Minimal PM timeout */
+       __s32           max_pmt;        /* Maximal PM timeout */
+       __u16           pmp_flags;      /* How to decode max/min PM period */
+       __u16           pmt_flags;      /* How to decode max/min PM timeout */
+       __u16           pm_capa;        /* What PM options are supported */
+
+       /* Encoder stuff */
+       __u16   encoding_size[IW_MAX_ENCODING_SIZES];   /* Different token sizes */
+       __u8    num_encoding_sizes;     /* Number of entry in the list */
+       __u8    max_encoding_tokens;    /* Max number of tokens */
+       /* For drivers that need a "login/passwd" form */
+       __u8    encoding_login_index;   /* token index for login token */
+
+       /* Transmit power */
+       __u16           txpower_capa;   /* What options are supported */
+       __u8            num_txpower;    /* Number of entries in the list */
+       __s32           txpower[IW_MAX_TXPOWER];        /* list, in bps */
+
+       /* Wireless Extension version info */
+       __u8            we_version_compiled;    /* Must be WIRELESS_EXT */
+       __u8            we_version_source;      /* Last update of source */
+
+       /* Retry limits and lifetime */
+       __u16           retry_capa;     /* What retry options are supported */
+       __u16           retry_flags;    /* How to decode max/min retry limit */
+       __u16           r_time_flags;   /* How to decode max/min retry life */
+       __s32           min_retry;      /* Minimal number of retries */
+       __s32           max_retry;      /* Maximal number of retries */
+       __s32           min_r_time;     /* Minimal retry lifetime */
+       __s32           max_r_time;     /* Maximal retry lifetime */
+
+       /* Frequency */
+       __u16           num_channels;   /* Number of channels [0; num - 1] */
+       __u8            num_frequency;  /* Number of entry in the list */
+       struct iw_freq  freq[IW_MAX_FREQUENCIES];       /* list */
+       /* Note : this frequency list doesn't need to fit channel numbers,
+        * because each entry contain its channel index */
+
+       __u32           enc_capa; /* IW_ENC_CAPA_* bit field */
+};
+
+/*
+ * Private ioctl interface information
+ */
+struct iw_priv_args
+{
+       __u32           cmd;            /* Number of the ioctl to issue */
+       __u16           set_args;       /* Type and number of args */
+       __u16           get_args;       /* Type and number of args */
+       char            name[IFNAMSIZ]; /* Name of the extension */
+};
+
+/* ----------------------- WIRELESS EVENTS ----------------------- */
+/*
+ * Wireless events are carried through the rtnetlink socket to user
+ * space. They are encapsulated in the IFLA_WIRELESS field of
+ * a RTM_NEWLINK message.
+ */
+
+/*
+ * A Wireless Event. Contains basically the same data as the ioctl...
+ */
+struct iw_event
+{
+       __u16           len;                    /* Real lenght of this stuff */
+       __u16           cmd;                    /* Wireless IOCTL */
+       union iwreq_data        u;              /* IOCTL fixed payload */
+};
+
+/* Size of the Event prefix (including padding and alignement junk) */
+#define IW_EV_LCP_LEN  (sizeof(struct iw_event) - sizeof(union iwreq_data))
+/* Size of the various events */
+#define IW_EV_CHAR_LEN (IW_EV_LCP_LEN + IFNAMSIZ)
+#define IW_EV_UINT_LEN (IW_EV_LCP_LEN + sizeof(__u32))
+#define IW_EV_FREQ_LEN (IW_EV_LCP_LEN + sizeof(struct iw_freq))
+#define IW_EV_PARAM_LEN        (IW_EV_LCP_LEN + sizeof(struct iw_param))
+#define IW_EV_ADDR_LEN (IW_EV_LCP_LEN + sizeof(struct sockaddr))
+#define IW_EV_QUAL_LEN (IW_EV_LCP_LEN + sizeof(struct iw_quality))
+
+/* iw_point events are special. First, the payload (extra data) come at
+ * the end of the event, so they are bigger than IW_EV_POINT_LEN. Second,
+ * we omit the pointer, so start at an offset. */
+#define IW_EV_POINT_OFF (((char *) &(((struct iw_point *) NULL)->length)) - \
+                         (char *) NULL)
+#define IW_EV_POINT_LEN        (IW_EV_LCP_LEN + sizeof(struct iw_point) - \
+                        IW_EV_POINT_OFF)
+
+#endif /* _LINUX_WIRELESS_H */
diff --git a/wireless_tools/wireless.20.h b/wireless_tools/wireless.20.h
new file mode 100644 (file)
index 0000000..888de4d
--- /dev/null
@@ -0,0 +1,1073 @@
+/*
+ * This file define a set of standard wireless extensions
+ *
+ * Version :   20      17.2.06
+ *
+ * Authors :   Jean Tourrilhes - HPL - <jt@hpl.hp.com>
+ * Copyright (c) 1997-2006 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
+ * driver.
+ * 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
+ * data exchanged...
+ * 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 :
+ *     # net/core/wireless.c
+ *
+ * Wireless Events (2002 -> onward) :
+ * --------------------------------
+ * Events are defined at the end of this file, and implemented in :
+ *     # net/core/wireless.c
+ *
+ * Other comments :
+ * --------------
+ * Do not add here things that are redundant with other mechanisms
+ * (drivers init, ifconfig, /proc/net/dev, ...) and with are not
+ * wireless specific.
+ *
+ * These wireless extensions are not magic : each driver has to provide
+ * support for them...
+ *
+ * IMPORTANT NOTE : As everything in the kernel, this is very much a
+ * work in progress. Contact me if you have ideas of improvements...
+ */
+
+/***************************** INCLUDES *****************************/
+
+/* Do not put any header in this file, this creates a mess when
+ * exported to user space. Most users have included all the
+ * relevant headers anyway... Jean II */
+/*#include <linux/types.h>*/           /* for "caddr_t" et al          */
+/*#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.
+ */
+#define WIRELESS_EXT   20
+
+/*
+ * Changes :
+ *
+ * V2 to V3
+ * --------
+ *     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
+ *
+ * V3 to V4
+ * --------
+ *     - Add sensitivity
+ *
+ * V4 to V5
+ * --------
+ *     - Missing encoding definitions in range
+ *     - Access points stuff
+ *
+ * V5 to V6
+ * --------
+ *     - 802.11 support (ESSID ioctls)
+ *
+ * V6 to V7
+ * --------
+ *     - define IW_ESSID_MAX_SIZE and IW_MAX_AP
+ *
+ * V7 to V8
+ * --------
+ *     - Changed my e-mail address
+ *     - More 802.11 support (nickname, rate, rts, frag)
+ *     - List index in frequencies
+ *
+ * V8 to V9
+ * --------
+ *     - 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
+ *
+ * V9 to V10
+ * ---------
+ *     - Add PM capability to range structure
+ *     - Add PM modifier : MAX/MIN/RELATIVE
+ *     - Add encoding option : IW_ENCODE_NOKEY
+ *     - Add TxPower ioctls (work like TxRate)
+ *
+ * V10 to V11
+ * ----------
+ *     - Add WE version in range (help backward/forward compatibility)
+ *     - Add retry ioctls (work like PM)
+ *
+ * V11 to V12
+ * ----------
+ *     - 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)
+ *
+ * V12 to V13
+ * ----------
+ *     - Document creation of new driver API.
+ *     - Extract union iwreq_data from struct iwreq (for new driver API).
+ *     - Rename SIOCSIWNAME as SIOCSIWCOMMIT
+ *
+ * V13 to V14
+ * ----------
+ *     - 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)
+ *
+ * V14 to V15
+ * ----------
+ *     - 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
+ *
+ * V15 to V16
+ * ----------
+ *     - 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
+ *
+ * V16 to V17
+ * ----------
+ *     - 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 <jkmaline@cc.hut.fi>)
+ * ----------
+ *     - Add support for WPA/WPA2
+ *     - Add extended encoding configuration (SIOCSIWENCODEEXT and
+ *       SIOCGIWENCODEEXT)
+ *     - Add SIOCSIWGENIE/SIOCGIWGENIE
+ *     - Add SIOCSIWMLME
+ *     - Add SIOCSIWPMKSA
+ *     - 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
+ *
+ * V18 to V19
+ * ----------
+ *     - 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
+ *
+ * V19 to V20
+ * ----------
+ *     - RtNetlink requests support (SET/GET)
+ */
+
+/**************************** 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. */
+
+/* Basic operations */
+#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) */
+
+/* Informative stuff */
+#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
+                                        * struct iw_mlme */
+/* 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
+ * 'mii-tool'.
+ * We now have 32 commands, so a bit more space ;-).
+ * Also, all 'odd' 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)
+
+/* Even : get (world access), odd : 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
+                                        * IWEVGENIE events. */
+#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
+                                        * association. */
+#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
+                                        * association. */
+#define IWEVPMKIDCAND  0x8C09          /* PMKID candidate for RSN
+                                        * pre-authentication
+                                        * (struct iw_pmkid_cand) */
+
+#define IWEVFIRST      0x8C00
+#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 */
+#define IW_MAX_TXPOWER         8
+/* 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 */
+#define IW_MAX_SPY             8
+
+/* Maximum of address that you may get in the
+   list of access points in range */
+#define IW_MAX_AP              64
+
+/* Maximum size of the ESSID and NICKN strings */
+#define IW_ESSID_MAX_SIZE      32
+
+/* Modes of operation */
+#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) */
+
+/* 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_ALL_INVALID    0x70
+
+/* Frequency flags */
+#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 */
+#define IW_POWER_FORCE_S       0x0400  /* Force PM procedure for sending unicast */
+#define IW_POWER_REPEATER      0x0800  /* Repeat broadcast messages in PM period */
+#define IW_POWER_MODIFIER      0x000F  /* Modify a parameter */
+#define IW_POWER_MIN           0x0001  /* Value is a minimum  */
+#define IW_POWER_MAX           0x0002  /* Value is a maximum */
+#define IW_POWER_RELATIVE      0x0004  /* Value is not in seconds/ms/us */
+
+/* Transmit Power flags available */
+#define IW_TXPOW_TYPE          0x00FF  /* Type of value */
+#define IW_TXPOW_DBM           0x0000  /* Value is in dBm */
+#define IW_TXPOW_MWATT         0x0001  /* Value is in mW */
+#define IW_TXPOW_RELATIVE      0x0002  /* Value is in arbitrary units */
+#define IW_TXPOW_RANGE         0x1000  /* Range of value between min/max */
+
+/* Retry limits and lifetime flags available */
+#define IW_RETRY_ON            0x0000  /* No details... */
+#define IW_RETRY_TYPE          0xF000  /* Type of parameter */
+#define IW_RETRY_LIMIT         0x1000  /* Maximum number of retries*/
+#define IW_RETRY_LIFETIME      0x2000  /* Maximum duration of retries in us */
+#define IW_RETRY_MODIFIER      0x000F  /* Modify a parameter */
+#define IW_RETRY_MIN           0x0001  /* Value is a minimum  */
+#define IW_RETRY_MAX           0x0002  /* Value is a maximum */
+#define IW_RETRY_RELATIVE      0x0004  /* Value is not in seconds/ms/us */
+
+/* Scanning request flags */
+#define IW_SCAN_DEFAULT                0x0000  /* Default scan of the driver */
+#define IW_SCAN_ALL_ESSID      0x0001  /* Scan all ESSIDs */
+#define IW_SCAN_THIS_ESSID     0x0002  /* Scan only this ESSID */
+#define IW_SCAN_ALL_FREQ       0x0004  /* Scan all Frequencies */
+#define IW_SCAN_THIS_FREQ      0x0008  /* Scan only this Frequency */
+#define IW_SCAN_ALL_MODE       0x0010  /* Scan all Modes */
+#define IW_SCAN_THIS_MODE      0x0020  /* Scan only this Mode */
+#define IW_SCAN_ALL_RATE       0x0040  /* Scan all Bit-Rates */
+#define IW_SCAN_THIS_RATE      0x0080  /* Scan only this Bit-Rate */
+/* struct iw_scan_req scan_type */
+#define IW_SCAN_TYPE_ACTIVE 0
+#define IW_SCAN_TYPE_PASSIVE 1
+/* Maximum size of returned data */
+#define IW_SCAN_MAX_DATA       4096    /* In bytes */
+
+/* Max number of char in custom event - use multiple of them if needed */
+#define IW_CUSTOM_MAX          256     /* In bytes */
+
+/* Generic information element */
+#define IW_GENERIC_IE_MAX      1024
+
+/* MLME requests (SIOCSIWMLME / struct iw_mlme) */
+#define IW_MLME_DEAUTH         0
+#define IW_MLME_DISASSOC       1
+
+/* SIOCSIWAUTH/SIOCGIWAUTH struct iw_param flags */
+#define IW_AUTH_INDEX          0x0FFF
+#define IW_AUTH_FLAGS          0xF000
+/* SIOCSIWAUTH/SIOCGIWAUTH parameters (0 .. 4095)
+ * (IW_AUTH_INDEX mask in struct iw_param flags; this is the index of the
+ * parameter that is being set/get to; value will be read/written to
+ * struct iw_param value field) */
+#define IW_AUTH_WPA_VERSION            0
+#define IW_AUTH_CIPHER_PAIRWISE                1
+#define IW_AUTH_CIPHER_GROUP           2
+#define IW_AUTH_KEY_MGMT               3
+#define IW_AUTH_TKIP_COUNTERMEASURES   4
+#define IW_AUTH_DROP_UNENCRYPTED       5
+#define IW_AUTH_80211_AUTH_ALG         6
+#define IW_AUTH_WPA_ENABLED            7
+#define IW_AUTH_RX_UNENCRYPTED_EAPOL   8
+#define IW_AUTH_ROAMING_CONTROL                9
+#define IW_AUTH_PRIVACY_INVOKED                10
+
+/* IW_AUTH_WPA_VERSION values (bit field) */
+#define IW_AUTH_WPA_VERSION_DISABLED   0x00000001
+#define IW_AUTH_WPA_VERSION_WPA                0x00000002
+#define IW_AUTH_WPA_VERSION_WPA2       0x00000004
+
+/* IW_AUTH_PAIRWISE_CIPHER and IW_AUTH_GROUP_CIPHER values (bit field) */
+#define IW_AUTH_CIPHER_NONE    0x00000001
+#define IW_AUTH_CIPHER_WEP40   0x00000002
+#define IW_AUTH_CIPHER_TKIP    0x00000004
+#define IW_AUTH_CIPHER_CCMP    0x00000008
+#define IW_AUTH_CIPHER_WEP104  0x00000010
+
+/* IW_AUTH_KEY_MGMT values (bit field) */
+#define IW_AUTH_KEY_MGMT_802_1X        1
+#define IW_AUTH_KEY_MGMT_PSK   2
+
+/* IW_AUTH_80211_AUTH_ALG values (bit field) */
+#define IW_AUTH_ALG_OPEN_SYSTEM        0x00000001
+#define IW_AUTH_ALG_SHARED_KEY 0x00000002
+#define IW_AUTH_ALG_LEAP       0x00000004
+
+/* IW_AUTH_ROAMING_CONTROL values */
+#define IW_AUTH_ROAMING_ENABLE 0       /* driver/firmware based roaming */
+#define IW_AUTH_ROAMING_DISABLE        1       /* user space program used for roaming
+                                        * control */
+
+/* SIOCSIWENCODEEXT definitions */
+#define IW_ENCODE_SEQ_MAX_SIZE 8
+/* struct iw_encode_ext ->alg */
+#define IW_ENCODE_ALG_NONE     0
+#define IW_ENCODE_ALG_WEP      1
+#define IW_ENCODE_ALG_TKIP     2
+#define IW_ENCODE_ALG_CCMP     3
+/* struct iw_encode_ext ->ext_flags */
+#define IW_ENCODE_EXT_TX_SEQ_VALID     0x00000001
+#define IW_ENCODE_EXT_RX_SEQ_VALID     0x00000002
+#define IW_ENCODE_EXT_GROUP_KEY                0x00000004
+#define IW_ENCODE_EXT_SET_TX_KEY       0x00000008
+
+/* IWEVMICHAELMICFAILURE : struct iw_michaelmicfailure ->flags */
+#define IW_MICFAILURE_KEY_ID   0x00000003 /* Key ID 0..3 */
+#define IW_MICFAILURE_GROUP    0x00000004
+#define IW_MICFAILURE_PAIRWISE 0x00000008
+#define IW_MICFAILURE_STAKEY   0x00000010
+#define IW_MICFAILURE_COUNT    0x00000060 /* 1 or 2 (0 = count not supported)
+                                           */
+
+/* Bit field values for enc_capa in struct iw_range */
+#define IW_ENC_CAPA_WPA                0x00000001
+#define IW_ENC_CAPA_WPA2       0x00000002
+#define IW_ENC_CAPA_CIPHER_TKIP        0x00000004
+#define IW_ENC_CAPA_CIPHER_CCMP        0x00000008
+
+/* Event capability macros - in (struct iw_range *)->event_capa
+ * Because we have more than 32 possible events, we use an array of
+ * 32 bit bitmasks. Note : 32 bits = 0x20 = 2^5. */
+#define IW_EVENT_CAPA_BASE(cmd)                ((cmd >= SIOCIWFIRSTPRIV) ? \
+                                        (cmd - SIOCIWFIRSTPRIV + 0x60) : \
+                                        (cmd - SIOCSIWCOMMIT))
+#define IW_EVENT_CAPA_INDEX(cmd)       (IW_EVENT_CAPA_BASE(cmd) >> 5)
+#define IW_EVENT_CAPA_MASK(cmd)                (1 << (IW_EVENT_CAPA_BASE(cmd) & 0x1F))
+/* Event capability constants - event autogenerated by the kernel
+ * This list is valid for most 802.11 devices, customise as needed... */
+#define IW_EVENT_CAPA_K_0      (IW_EVENT_CAPA_MASK(0x8B04) | \
+                                IW_EVENT_CAPA_MASK(0x8B06) | \
+                                IW_EVENT_CAPA_MASK(0x8B1A))
+#define IW_EVENT_CAPA_K_1      (IW_EVENT_CAPA_MASK(0x8B2A))
+/* "Easy" macro to set events in iw_range (less efficient) */
+#define IW_EVENT_CAPA_SET(event_capa, cmd) (event_capa[IW_EVENT_CAPA_INDEX(cmd)] |= IW_EVENT_CAPA_MASK(cmd))
+#define IW_EVENT_CAPA_SET_KERNEL(event_capa) {event_capa[0] |= IW_EVENT_CAPA_K_0; event_capa[1] |= IW_EVENT_CAPA_K_1; }
+
+
+/****************************** TYPES ******************************/
+
+/* --------------------------- SUBTYPES --------------------------- */
+/*
+ *     Generic format for most parameters that fit in an int
+ */
+struct iw_param
+{
+  __s32                value;          /* The value of the parameter itself */
+  __u8         fixed;          /* Hardware should not use auto select */
+  __u8         disabled;       /* Disable the feature */
+  __u16                flags;          /* Various specifc flags (if any) */
+};
+
+/*
+ *     For all data larger than 16 octets, we need to use a
+ *     pointer to memory allocated in user space.
+ */
+struct iw_point
+{
+  void __user  *pointer;       /* Pointer to the data  (in user space) */
+  __u16                length;         /* number of fields or size in bytes */
+  __u16                flags;          /* Optional params */
+};
+
+/*
+ *     A frequency
+ *     For numbers lower than 10^9, we encode the number in 'm' and
+ *     set 'e' to 0
+ *     For number greater than 10^9, we divide it by the lowest power
+ *     of 10 to get 'm' lower than 10^9, with 'm'= f / (10^'e')...
+ *     The power of 10 is in 'e', the result of the division is in 'm'.
+ */
+struct iw_freq
+{
+       __s32           m;              /* Mantissa */
+       __s16           e;              /* Exponent */
+       __u8            i;              /* List index (when in range struct) */
+       __u8            flags;          /* Flags (fixed/auto) */
+};
+
+/*
+ *     Quality of the link
+ */
+struct iw_quality
+{
+       __u8            qual;           /* link quality (%retries, SNR,
+                                          %missed beacons or better...) */
+       __u8            level;          /* signal level (dBm) */
+       __u8            noise;          /* noise level (dBm) */
+       __u8            updated;        /* Flags to know if updated */
+};
+
+/*
+ *     Packet discarded in the wireless adapter due to
+ *     "wireless" specific problems...
+ *     Note : the list of counter and statistics in net_device_stats
+ *     is already pretty exhaustive, and you should use that first.
+ *     This is only additional stats...
+ */
+struct iw_discarded
+{
+       __u32           nwid;           /* Rx : Wrong nwid/essid */
+       __u32           code;           /* Rx : Unable to code/decode (WEP) */
+       __u32           fragment;       /* Rx : Can't perform MAC reassembly */
+       __u32           retries;        /* Tx : Max MAC retries num reached */
+       __u32           misc;           /* Others cases */
+};
+
+/*
+ *     Packet/Time period missed in the wireless adapter due to
+ *     "wireless" specific problems...
+ */
+struct iw_missed
+{
+       __u32           beacon;         /* Missed beacons/superframe */
+};
+
+/*
+ *     Quality range (for spy threshold)
+ */
+struct iw_thrspy
+{
+       struct sockaddr         addr;           /* Source address (hw/mac) */
+       struct iw_quality       qual;           /* Quality of the link */
+       struct iw_quality       low;            /* Low threshold */
+       struct iw_quality       high;           /* High threshold */
+};
+
+/*
+ *     Optional data for scan request
+ *
+ *     Note: these optional parameters are controlling parameters for the
+ *     scanning behavior, these do not apply to getting scan results
+ *     (SIOCGIWSCAN). Drivers are expected to keep a local BSS table and
+ *     provide a merged results with all BSSes even if the previous scan
+ *     request limited scanning to a subset, e.g., by specifying an SSID.
+ *     Especially, scan results are required to include an entry for the
+ *     current BSS if the driver is in Managed mode and associated with an AP.
+ */
+struct iw_scan_req
+{
+       __u8            scan_type; /* IW_SCAN_TYPE_{ACTIVE,PASSIVE} */
+       __u8            essid_len;
+       __u8            num_channels; /* num entries in channel_list;
+                                      * 0 = scan all allowed channels */
+       __u8            flags; /* reserved as padding; use zero, this may
+                               * be used in the future for adding flags
+                               * to request different scan behavior */
+       struct sockaddr bssid; /* ff:ff:ff:ff:ff:ff for broadcast BSSID or
+                               * individual address of a specific BSS */
+
+       /*
+        * Use this ESSID if IW_SCAN_THIS_ESSID flag is used instead of using
+        * the current ESSID. This allows scan requests for specific ESSID
+        * without having to change the current ESSID and potentially breaking
+        * the current association.
+        */
+       __u8            essid[IW_ESSID_MAX_SIZE];
+
+       /*
+        * Optional parameters for changing the default scanning behavior.
+        * These are based on the MLME-SCAN.request from IEEE Std 802.11.
+        * TU is 1.024 ms. If these are set to 0, driver is expected to use
+        * reasonable default values. min_channel_time defines the time that
+        * will be used to wait for the first reply on each channel. If no
+        * replies are received, next channel will be scanned after this. If
+        * replies are received, total time waited on the channel is defined by
+        * max_channel_time.
+        */
+       __u32           min_channel_time; /* in TU */
+       __u32           max_channel_time; /* in TU */
+
+       struct iw_freq  channel_list[IW_MAX_FREQUENCIES];
+};
+
+/* ------------------------- WPA SUPPORT ------------------------- */
+
+/*
+ *     Extended data structure for get/set encoding (this is used with
+ *     SIOCSIWENCODEEXT/SIOCGIWENCODEEXT. struct iw_point and IW_ENCODE_*
+ *     flags are used in the same way as with SIOCSIWENCODE/SIOCGIWENCODE and
+ *     only the data contents changes (key data -> this structure, including
+ *     key data).
+ *
+ *     If the new key is the first group key, it will be set as the default
+ *     TX key. Otherwise, default TX key index is only changed if
+ *     IW_ENCODE_EXT_SET_TX_KEY flag is set.
+ *
+ *     Key will be changed with SIOCSIWENCODEEXT in all cases except for
+ *     special "change TX key index" operation which is indicated by setting
+ *     key_len = 0 and ext_flags |= IW_ENCODE_EXT_SET_TX_KEY.
+ *
+ *     tx_seq/rx_seq are only used when respective
+ *     IW_ENCODE_EXT_{TX,RX}_SEQ_VALID flag is set in ext_flags. Normal
+ *     TKIP/CCMP operation is to set RX seq with SIOCSIWENCODEEXT and start
+ *     TX seq from zero whenever key is changed. SIOCGIWENCODEEXT is normally
+ *     used only by an Authenticator (AP or an IBSS station) to get the
+ *     current TX sequence number. Using TX_SEQ_VALID for SIOCSIWENCODEEXT and
+ *     RX_SEQ_VALID for SIOCGIWENCODEEXT are optional, but can be useful for
+ *     debugging/testing.
+ */
+struct iw_encode_ext
+{
+       __u32           ext_flags; /* IW_ENCODE_EXT_* */
+       __u8            tx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
+       __u8            rx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
+       struct sockaddr addr; /* ff:ff:ff:ff:ff:ff for broadcast/multicast
+                              * (group) keys or unicast address for
+                              * individual keys */
+       __u16           alg; /* IW_ENCODE_ALG_* */
+       __u16           key_len;
+       __u8            key[0];
+};
+
+/* SIOCSIWMLME data */
+struct iw_mlme
+{
+       __u16           cmd; /* IW_MLME_* */
+       __u16           reason_code;
+       struct sockaddr addr;
+};
+
+/* SIOCSIWPMKSA data */
+#define IW_PMKSA_ADD           1
+#define IW_PMKSA_REMOVE                2
+#define IW_PMKSA_FLUSH         3
+
+#define IW_PMKID_LEN   16
+
+struct iw_pmksa
+{
+       __u32           cmd; /* IW_PMKSA_* */
+       struct sockaddr bssid;
+       __u8            pmkid[IW_PMKID_LEN];
+};
+
+/* IWEVMICHAELMICFAILURE data */
+struct iw_michaelmicfailure
+{
+       __u32           flags;
+       struct sockaddr src_addr;
+       __u8            tsc[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
+};
+
+/* IWEVPMKIDCAND data */
+#define IW_PMKID_CAND_PREAUTH  0x00000001 /* RNS pre-authentication enabled */
+struct iw_pmkid_cand
+{
+       __u32           flags; /* IW_PMKID_CAND_* */
+       __u32           index; /* the smaller the index, the higher the
+                               * priority */
+       struct sockaddr bssid;
+};
+
+/* ------------------------ WIRELESS STATS ------------------------ */
+/*
+ * Wireless statistics (used for /proc/net/wireless)
+ */
+struct iw_statistics
+{
+       __u16           status;         /* Status
+                                        * - device dependent for now */
+
+       struct iw_quality       qual;           /* Quality of the link
+                                                * (instant/mean/max) */
+       struct iw_discarded     discard;        /* Packet discarded counts */
+       struct iw_missed        miss;           /* Packet missed counts */
+};
+
+/* ------------------------ IOCTL REQUEST ------------------------ */
+/*
+ * This structure defines the payload of an ioctl, and is used 
+ * below.
+ *
+ * Note that this structure should fit on the memory footprint
+ * of iwreq (which is the same as ifreq), which mean a max size of
+ * 16 octets = 128 bits. Warning, pointers might be 64 bits wide...
+ * You should check this when increasing the structures defined
+ * above in this file...
+ */
+union  iwreq_data
+{
+       /* Config - generic */
+       char            name[IFNAMSIZ];
+       /* Name : used to verify the presence of  wireless extensions.
+        * Name of the protocol/provider... */
+
+       struct iw_point essid;          /* Extended network name */
+       struct iw_param nwid;           /* network id (or domain - the cell) */
+       struct iw_freq  freq;           /* frequency or channel :
+                                        * 0-1000 = channel
+                                        * > 1000 = frequency in Hz */
+
+       struct iw_param sens;           /* signal level threshold */
+       struct iw_param bitrate;        /* default bit rate */
+       struct iw_param txpower;        /* default transmit power */
+       struct iw_param rts;            /* RTS threshold threshold */
+       struct iw_param frag;           /* Fragmentation threshold */
+       __u32           mode;           /* Operation mode */
+       struct iw_param retry;          /* Retry limits & lifetime */
+
+       struct iw_point encoding;       /* Encoding stuff : tokens */
+       struct iw_param power;          /* PM duration/timeout */
+       struct iw_quality qual;         /* Quality part of statistics */
+
+       struct sockaddr ap_addr;        /* Access point address */
+       struct sockaddr addr;           /* Destination address (hw/mac) */
+
+       struct iw_param param;          /* Other small parameters */
+       struct iw_point data;           /* Other large parameters */
+};
+
+/*
+ * The structure to exchange data for ioctl.
+ * This structure is the same as 'struct ifreq', but (re)defined for
+ * convenience...
+ * Do I need to remind you about structure size (32 octets) ?
+ */
+struct iwreq 
+{
+       union
+       {
+               char    ifrn_name[IFNAMSIZ];    /* if name, e.g. "eth0" */
+       } ifr_ifrn;
+
+       /* Data part (defined just above) */
+       union   iwreq_data      u;
+};
+
+/* -------------------------- IOCTL DATA -------------------------- */
+/*
+ *     For those ioctl which want to exchange mode data that what could
+ *     fit in the above structure...
+ */
+
+/*
+ *     Range of parameters
+ */
+
+struct iw_range
+{
+       /* Informative stuff (to choose between different interface) */
+       __u32           throughput;     /* To give an idea... */
+       /* In theory this value should be the maximum benchmarked
+        * TCP/IP throughput, because with most of these devices the
+        * bit rate is meaningless (overhead an co) to estimate how
+        * fast the connection will go and pick the fastest one.
+        * I suggest people to play with Netperf or any benchmark...
+        */
+
+       /* NWID (or domain id) */
+       __u32           min_nwid;       /* Minimal NWID we are able to set */
+       __u32           max_nwid;       /* Maximal NWID we are able to set */
+
+       /* Old Frequency (backward compat - moved lower ) */
+       __u16           old_num_channels;
+       __u8            old_num_frequency;
+
+       /* Wireless event capability bitmasks */
+       __u32           event_capa[6];
+
+       /* signal level threshold range */
+       __s32           sensitivity;
+
+       /* Quality of link & SNR stuff */
+       /* Quality range (link, level, noise)
+        * If the quality is absolute, it will be in the range [0 ; max_qual],
+        * if the quality is dBm, it will be in the range [max_qual ; 0].
+        * Don't forget that we use 8 bit arithmetics... */
+       struct iw_quality       max_qual;       /* Quality of the link */
+       /* This should contain the average/typical values of the quality
+        * indicator. This should be the threshold between a "good" and
+        * a "bad" link (example : monitor going from green to orange).
+        * Currently, user space apps like quality monitors don't have any
+        * way to calibrate the measurement. With this, they can split
+        * the range between 0 and max_qual in different quality level
+        * (using a geometric subdivision centered on the average).
+        * I expect that people doing the user space apps will feedback
+        * us on which value we need to put in each driver... */
+       struct iw_quality       avg_qual;       /* Quality of the link */
+
+       /* Rates */
+       __u8            num_bitrates;   /* Number of entries in the list */
+       __s32           bitrate[IW_MAX_BITRATES];       /* list, in bps */
+
+       /* RTS threshold */
+       __s32           min_rts;        /* Minimal RTS threshold */
+       __s32           max_rts;        /* Maximal RTS threshold */
+
+       /* Frag threshold */
+       __s32           min_frag;       /* Minimal frag threshold */
+       __s32           max_frag;       /* Maximal frag threshold */
+
+       /* Power Management duration & timeout */
+       __s32           min_pmp;        /* Minimal PM period */
+       __s32           max_pmp;        /* Maximal PM period */
+       __s32           min_pmt;        /* Minimal PM timeout */
+       __s32           max_pmt;        /* Maximal PM timeout */
+       __u16           pmp_flags;      /* How to decode max/min PM period */
+       __u16           pmt_flags;      /* How to decode max/min PM timeout */
+       __u16           pm_capa;        /* What PM options are supported */
+
+       /* Encoder stuff */
+       __u16   encoding_size[IW_MAX_ENCODING_SIZES];   /* Different token sizes */
+       __u8    num_encoding_sizes;     /* Number of entry in the list */
+       __u8    max_encoding_tokens;    /* Max number of tokens */
+       /* For drivers that need a "login/passwd" form */
+       __u8    encoding_login_index;   /* token index for login token */
+
+       /* Transmit power */
+       __u16           txpower_capa;   /* What options are supported */
+       __u8            num_txpower;    /* Number of entries in the list */
+       __s32           txpower[IW_MAX_TXPOWER];        /* list, in bps */
+
+       /* Wireless Extension version info */
+       __u8            we_version_compiled;    /* Must be WIRELESS_EXT */
+       __u8            we_version_source;      /* Last update of source */
+
+       /* Retry limits and lifetime */
+       __u16           retry_capa;     /* What retry options are supported */
+       __u16           retry_flags;    /* How to decode max/min retry limit */
+       __u16           r_time_flags;   /* How to decode max/min retry life */
+       __s32           min_retry;      /* Minimal number of retries */
+       __s32           max_retry;      /* Maximal number of retries */
+       __s32           min_r_time;     /* Minimal retry lifetime */
+       __s32           max_r_time;     /* Maximal retry lifetime */
+
+       /* Frequency */
+       __u16           num_channels;   /* Number of channels [0; num - 1] */
+       __u8            num_frequency;  /* Number of entry in the list */
+       struct iw_freq  freq[IW_MAX_FREQUENCIES];       /* list */
+       /* Note : this frequency list doesn't need to fit channel numbers,
+        * because each entry contain its channel index */
+
+       __u32           enc_capa; /* IW_ENC_CAPA_* bit field */
+};
+
+/*
+ * Private ioctl interface information
+ */
+struct iw_priv_args
+{
+       __u32           cmd;            /* Number of the ioctl to issue */
+       __u16           set_args;       /* Type and number of args */
+       __u16           get_args;       /* Type and number of args */
+       char            name[IFNAMSIZ]; /* Name of the extension */
+};
+
+/* ----------------------- WIRELESS EVENTS ----------------------- */
+/*
+ * Wireless events are carried through the rtnetlink socket to user
+ * space. They are encapsulated in the IFLA_WIRELESS field of
+ * a RTM_NEWLINK message.
+ */
+
+/*
+ * A Wireless Event. Contains basically the same data as the ioctl...
+ */
+struct iw_event
+{
+       __u16           len;                    /* Real lenght of this stuff */
+       __u16           cmd;                    /* Wireless IOCTL */
+       union iwreq_data        u;              /* IOCTL fixed payload */
+};
+
+/* Size of the Event prefix (including padding and alignement junk) */
+#define IW_EV_LCP_LEN  (sizeof(struct iw_event) - sizeof(union iwreq_data))
+/* Size of the various events */
+#define IW_EV_CHAR_LEN (IW_EV_LCP_LEN + IFNAMSIZ)
+#define IW_EV_UINT_LEN (IW_EV_LCP_LEN + sizeof(__u32))
+#define IW_EV_FREQ_LEN (IW_EV_LCP_LEN + sizeof(struct iw_freq))
+#define IW_EV_PARAM_LEN        (IW_EV_LCP_LEN + sizeof(struct iw_param))
+#define IW_EV_ADDR_LEN (IW_EV_LCP_LEN + sizeof(struct sockaddr))
+#define IW_EV_QUAL_LEN (IW_EV_LCP_LEN + sizeof(struct iw_quality))
+
+/* iw_point events are special. First, the payload (extra data) come at
+ * the end of the event, so they are bigger than IW_EV_POINT_LEN. Second,
+ * we omit the pointer, so start at an offset. */
+#define IW_EV_POINT_OFF (((char *) &(((struct iw_point *) NULL)->length)) - \
+                         (char *) NULL)
+#define IW_EV_POINT_LEN        (IW_EV_LCP_LEN + sizeof(struct iw_point) - \
+                        IW_EV_POINT_OFF)
+
+#endif /* _LINUX_WIRELESS_H */